⛏️ index : haiku.git

author Jonathan Schleifer <js@webkeks.org> 2012-11-04 17:34:34.0 +01:00:00
committer Alexander von Gluck IV <kallisti5@unixzen.com> 2012-11-07 7:16:00.0 -06:00:00
commit
82d4090ea9d2cb147c2b044b671ab8db202ab5f2 [patch]
tree
95f159503b09c202f8327a7c5cf72b17eb83839a
parent
f1f8037f5a0e417cd4379349fb94ca9ea381a253
download
82d4090ea9d2cb147c2b044b671ab8db202ab5f2.tar.gz

Terminal: Make cursor blinking an option.

Signed-off-by: Rene Gollent <anevilyak@gmail.com>

Diff

 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 bbf1c78..d0864e7 100644
--- a/src/apps/terminal/AppearPrefView.cpp
+++ b/src/apps/terminal/AppearPrefView.cpp
@@ -80,6 +80,10 @@
		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 @@
		.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 @@
	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 @@
{
	fTabTitle->SetTarget(this);
	fWindowTitle->SetTarget(this);
	fBlinkCursor->SetTarget(this);
	fWarnOnExit->SetTarget(this);

	fFontSize->Menu()->SetTargetForItems(this);
@@ -291,6 +298,15 @@
		case MSG_COLOR_FIELD_CHANGED:
			fColorControl->SetValue(PrefHandler::Default()->getRGB(
				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:
diff --git a/src/apps/terminal/AppearPrefView.h b/src/apps/terminal/AppearPrefView.h
index 6f85e52..b1d2c26 100644
--- a/src/apps/terminal/AppearPrefView.h
+++ b/src/apps/terminal/AppearPrefView.h
@@ -23,10 +23,11 @@

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 @@
									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 694ea1c..c60d156 100644
--- a/src/apps/terminal/PrefHandler.cpp
+++ b/src/apps/terminal/PrefHandler.cpp
@@ -61,6 +61,7 @@

	{ 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 2e759f4..4181a85 100644
--- a/src/apps/terminal/TermConst.h
+++ b/src/apps/terminal/TermConst.h
@@ -131,6 +131,7 @@
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 aa3c441..cad69cc 100644
--- a/src/apps/terminal/TermView.cpp
+++ b/src/apps/terminal/TermView.cpp
@@ -54,6 +54,7 @@
#include <Window.h>

#include "InlineInput.h"
#include "PrefHandler.h"
#include "Shell.h"
#include "ShellParameters.h"
#include "TermConst.h"
@@ -1096,9 +1097,11 @@
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);