From 41bb6ef5819cbd72a355019b1acec076c8fe1bfe Mon Sep 17 00:00:00 2001
From: Jonathan Schleifer <js@webkeks.org>
Date: Mon, 5 Nov 2012 11:24:07 +0100
Subject: [PATCH] Terminal: Make the cursor color configurable.
---
src/apps/terminal/AppearPrefView.cpp | 2 ++
src/apps/terminal/PrefHandler.cpp | 2 ++
src/apps/terminal/TermConst.h | 2 ++
src/apps/terminal/TermView.cpp | 28 ++++++++++++----------------
src/apps/terminal/TermView.h | 3 +++
src/apps/terminal/TermWindow.cpp | 2 ++
6 files changed, 23 insertions(+), 16 deletions(-)
diff --git a/src/apps/terminal/AppearPrefView.cpp b/src/apps/terminal/AppearPrefView.cpp
index d0864e7..eea2156 100644
a
|
b
|
AppearancePrefView::AppearancePrefView(const char* name,
|
75 | 75 | const char* kColorTable[] = { |
76 | 76 | B_TRANSLATE("Text"), |
77 | 77 | B_TRANSLATE("Background"), |
| 78 | B_TRANSLATE("Cursor text"), |
| 79 | B_TRANSLATE("Cursor background"), |
78 | 80 | B_TRANSLATE("Selected text"), |
79 | 81 | B_TRANSLATE("Selected background"), |
80 | 82 | NULL |
diff --git a/src/apps/terminal/PrefHandler.cpp b/src/apps/terminal/PrefHandler.cpp
index c60d156..030b62e 100644
a
|
b
|
static const pref_defaults kTermDefaults[] = {
|
44 | 44 | |
45 | 45 | { PREF_TEXT_FORE_COLOR, " 0, 0, 0" }, |
46 | 46 | { PREF_TEXT_BACK_COLOR, "255, 255, 255" }, |
| 47 | { PREF_CURSOR_FORE_COLOR, " 0, 0, 0" }, |
| 48 | { PREF_CURSOR_BACK_COLOR, "255, 200, 0" }, |
47 | 49 | { PREF_SELECT_FORE_COLOR, "255, 255, 255" }, |
48 | 50 | { PREF_SELECT_BACK_COLOR, " 0, 0, 0" }, |
49 | 51 | |
diff --git a/src/apps/terminal/TermConst.h b/src/apps/terminal/TermConst.h
index 4181a85..cf0a31c 100644
a
|
b
|
static const char* const PREF_HALF_FONT_SIZE = "Half Font Size";
|
103 | 103 | |
104 | 104 | static const char* const PREF_TEXT_FORE_COLOR = "Text"; |
105 | 105 | static const char* const PREF_TEXT_BACK_COLOR = "Background"; |
| 106 | static const char* const PREF_CURSOR_FORE_COLOR = "Cursor text"; |
| 107 | static const char* const PREF_CURSOR_BACK_COLOR = "Cursor background"; |
106 | 108 | static const char* const PREF_SELECT_FORE_COLOR = "Selected text"; |
107 | 109 | static const char* const PREF_SELECT_BACK_COLOR = "Selected background"; |
108 | 110 | |
diff --git a/src/apps/terminal/TermView.cpp b/src/apps/terminal/TermView.cpp
index cad69cc..5070021 100644
a
|
b
|
TermView::SetTextColor(rgb_color fore, rgb_color back)
|
887 | 887 | |
888 | 888 | |
889 | 889 | void |
| 890 | TermView::SetCursorColor(rgb_color fore, rgb_color back) |
| 891 | { |
| 892 | fCursorForeColor = fore; |
| 893 | fCursorBackColor = back; |
| 894 | } |
| 895 | |
| 896 | |
| 897 | void |
890 | 898 | TermView::SetSelectColor(rgb_color fore, rgb_color back) |
891 | 899 | { |
892 | 900 | fSelectForeColor = fore; |
… |
… |
TermView::_DrawLinePart(int32 x1, int32 y1, uint32 attr, char *buf,
|
1143 | 1151 | |
1144 | 1152 | // Selection check. |
1145 | 1153 | if (cursor) { |
1146 | | rgb_fore.red = 255 - rgb_fore.red; |
1147 | | rgb_fore.green = 255 - rgb_fore.green; |
1148 | | rgb_fore.blue = 255 - rgb_fore.blue; |
1149 | | |
1150 | | rgb_back.red = 255 - rgb_back.red; |
1151 | | rgb_back.green = 255 - rgb_back.green; |
1152 | | rgb_back.blue = 255 - rgb_back.blue; |
| 1154 | rgb_fore = fCursorForeColor; |
| 1155 | rgb_back = fCursorBackColor; |
1153 | 1156 | } else if (mouse) { |
1154 | 1157 | rgb_fore = fSelectForeColor; |
1155 | 1158 | rgb_back = fSelectBackColor; |
… |
… |
TermView::_DrawCursor()
|
1225 | 1228 | } else { |
1226 | 1229 | if (selected) |
1227 | 1230 | SetHighColor(fSelectBackColor); |
1228 | | else { |
1229 | | rgb_color color = kTermColorTable[IS_BACKCOLOR(attr)]; |
1230 | | if (cursorVisible) { |
1231 | | color.red = 255 - color.red; |
1232 | | color.green = 255 - color.green; |
1233 | | color.blue = 255 - color.blue; |
1234 | | } |
1235 | | SetHighColor(color); |
1236 | | } |
| 1231 | else |
| 1232 | SetHighColor(fCursorBackColor); |
1237 | 1233 | |
1238 | 1234 | FillRect(rect); |
1239 | 1235 | } |
diff --git a/src/apps/terminal/TermView.h b/src/apps/terminal/TermView.h
index 96e62f1..68272ee 100644
a
|
b
|
public:
|
77 | 77 | int *rows, int *columns); |
78 | 78 | |
79 | 79 | void SetTextColor(rgb_color fore, rgb_color back); |
| 80 | void SetCursorColor(rgb_color fore, rgb_color back); |
80 | 81 | void SetSelectColor(rgb_color fore, rgb_color back); |
81 | 82 | |
82 | 83 | int Encoding() const; |
… |
… |
private:
|
255 | 256 | InlineInput* fInline; |
256 | 257 | |
257 | 258 | // Color and Attribute. |
| 259 | rgb_color fCursorForeColor; |
| 260 | rgb_color fCursorBackColor; |
258 | 261 | rgb_color fSelectForeColor; |
259 | 262 | rgb_color fSelectBackColor; |
260 | 263 | |
diff --git a/src/apps/terminal/TermWindow.cpp b/src/apps/terminal/TermWindow.cpp
index 1fe2ccb..f039c95 100644
a
|
b
|
TermWindow::_SetTermColors(TermViewContainerView* containerView)
|
1018 | 1018 | TermView *termView = containerView->GetTermView(); |
1019 | 1019 | termView->SetTextColor(handler->getRGB(PREF_TEXT_FORE_COLOR), background); |
1020 | 1020 | |
| 1021 | termView->SetCursorColor(handler->getRGB(PREF_CURSOR_FORE_COLOR), |
| 1022 | handler->getRGB(PREF_CURSOR_BACK_COLOR)); |
1021 | 1023 | termView->SetSelectColor(handler->getRGB(PREF_SELECT_FORE_COLOR), |
1022 | 1024 | handler->getRGB(PREF_SELECT_BACK_COLOR)); |
1023 | 1025 | } |