From 4e3d346e9177b9a6ad3d84c28a39c08898e0a6ec Mon Sep 17 00:00:00 2001 From: Jonathan Schleifer Date: Sun, 4 Nov 2012 17:34:34 +0100 Subject: [PATCH] Terminal: Make cursor blinking an option. Signed-off-by: Rene Gollent --- src/apps/terminal/AppearPrefView.cpp | 16 ++++++++++++++++ src/apps/terminal/AppearPrefView.h | 4 +++- src/apps/terminal/PrefHandler.cpp | 1 + src/apps/terminal/TermConst.h | 1 + src/apps/terminal/TermView.cpp | 5 ++++- 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/apps/terminal/AppearPrefView.cpp b/src/apps/terminal/AppearPrefView.cpp index bbf1c78708..d0864e7c50 100644 --- a/src/apps/terminal/AppearPrefView.cpp +++ b/src/apps/terminal/AppearPrefView.cpp @@ -80,6 +80,10 @@ AppearancePrefView::AppearancePrefView(const char* name, NULL }; + fBlinkCursor = new BCheckBox( + B_TRANSLATE("Blink the cursor"), + new BMessage(MSG_BLINK_CURSOR_CHANGED)); + fWarnOnExit = new BCheckBox( B_TRANSLATE("Confirm exit if active programs exist"), new BMessage(MSG_WARN_ON_EXIT_CHANGED)); @@ -141,6 +145,7 @@ AppearancePrefView::AppearancePrefView(const char* name, .AddGlue() .Add(fColorControl = new BColorControl(BPoint(10, 10), B_CELLS_32x8, 8.0, "", new BMessage(MSG_COLOR_CHANGED))) + .Add(fBlinkCursor) .Add(fWarnOnExit); fTabTitle->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); @@ -157,6 +162,7 @@ AppearancePrefView::AppearancePrefView(const char* name, fColorControl->SetValue( PrefHandler::Default()->getRGB(PREF_TEXT_FORE_COLOR)); + fBlinkCursor->SetValue(PrefHandler::Default()->getBool(PREF_BLINK_CURSOR)); fWarnOnExit->SetValue(PrefHandler::Default()->getBool(PREF_WARN_ON_EXIT)); BTextControl* redInput = (BTextControl*)fColorControl->ChildAt(0); @@ -205,6 +211,7 @@ AppearancePrefView::AttachedToWindow() { fTabTitle->SetTarget(this); fWindowTitle->SetTarget(this); + fBlinkCursor->SetTarget(this); fWarnOnExit->SetTarget(this); fFontSize->Menu()->SetTargetForItems(this); @@ -293,6 +300,15 @@ AppearancePrefView::MessageReceived(BMessage* msg) fColorField->Menu()->FindMarked()->Label())); break; + case MSG_BLINK_CURSOR_CHANGED: + if (PrefHandler::Default()->getBool(PREF_BLINK_CURSOR) + != fBlinkCursor->Value()) { + PrefHandler::Default()->setBool(PREF_BLINK_CURSOR, + fBlinkCursor->Value()); + modified = true; + } + break; + case MSG_WARN_ON_EXIT_CHANGED: if (PrefHandler::Default()->getBool(PREF_WARN_ON_EXIT) != fWarnOnExit->Value()) { diff --git a/src/apps/terminal/AppearPrefView.h b/src/apps/terminal/AppearPrefView.h index 6f85e52835..b1d2c26009 100644 --- a/src/apps/terminal/AppearPrefView.h +++ b/src/apps/terminal/AppearPrefView.h @@ -23,10 +23,11 @@ static const uint32 MSG_COLOR_SCHEMA_CHANGED = 'mccs'; static const uint32 MSG_TAB_TITLE_SETTING_CHANGED = 'mtts'; static const uint32 MSG_WINDOW_TITLE_SETTING_CHANGED = 'mwts'; +static const uint32 MSG_BLINK_CURSOR_CHANGED = 'mbcc'; static const uint32 MSG_WARN_ON_EXIT_CHANGED = 'mwec'; static const uint32 MSG_COLS_CHANGED = 'mccl'; static const uint32 MSG_ROWS_CHANGED = 'mcrw'; -static const uint32 MSG_HISTORY_CHANGED = 'mhst'; +static const uint32 MSG_HISTORY_CHANGED = 'mhst'; static const uint32 MSG_PREF_MODIFIED = 'mpmo'; @@ -71,6 +72,7 @@ private: const color_schema** schemas, const color_schema* defaultItemName); + BCheckBox* fBlinkCursor; BCheckBox* fWarnOnExit; BMenuField* fFont; BMenuField* fFontSize; diff --git a/src/apps/terminal/PrefHandler.cpp b/src/apps/terminal/PrefHandler.cpp index 694ea1c907..c60d156ef5 100644 --- a/src/apps/terminal/PrefHandler.cpp +++ b/src/apps/terminal/PrefHandler.cpp @@ -61,6 +61,7 @@ static const pref_defaults kTermDefaults[] = { { PREF_TAB_TITLE, "%1d: %p" }, { PREF_WINDOW_TITLE, "Terminal %i: %t" }, + { PREF_BLINK_CURSOR, PREF_TRUE }, { PREF_WARN_ON_EXIT, PREF_TRUE }, { NULL, NULL}, diff --git a/src/apps/terminal/TermConst.h b/src/apps/terminal/TermConst.h index 2e759f4405..4181a85739 100644 --- a/src/apps/terminal/TermConst.h +++ b/src/apps/terminal/TermConst.h @@ -131,6 +131,7 @@ static const char* const PREF_SHELL = "Shell"; static const char* const PREF_TEXT_ENCODING = "Text encoding"; static const char* const PREF_GUI_LANGUAGE = "Language"; +static const char* const PREF_BLINK_CURSOR = "Blink the cursor"; static const char* const PREF_WARN_ON_EXIT = "Warn on exit"; static const char* const PREF_TAB_TITLE = "Tab title"; diff --git a/src/apps/terminal/TermView.cpp b/src/apps/terminal/TermView.cpp index aa3c441083..cad69cc2b7 100644 --- a/src/apps/terminal/TermView.cpp +++ b/src/apps/terminal/TermView.cpp @@ -54,6 +54,7 @@ #include #include "InlineInput.h" +#include "PrefHandler.h" #include "Shell.h" #include "ShellParameters.h" #include "TermConst.h" @@ -1096,9 +1097,11 @@ TermView::_DetachShell() void TermView::_Activate() { + bool blinkCursor = PrefHandler::Default()->getBool(PREF_BLINK_CURSOR); + fActive = true; - if (fCursorBlinkRunner == NULL) { + if (fCursorBlinkRunner == NULL && blinkCursor) { BMessage blinkMessage(kBlinkCursor); fCursorBlinkRunner = new (std::nothrow) BMessageRunner( BMessenger(this), &blinkMessage, kCursorBlinkInterval);