Terminal: Make the cursor color configurable.
Signed-off-by: Adrien Destugues - PulkoMandy <pulkomandy@pulkomandy.tk>
This commit is contained in:
parent
82d4090ea9
commit
6b0d18cd44
@ -75,6 +75,8 @@ AppearancePrefView::AppearancePrefView(const char* name,
|
||||
const char* kColorTable[] = {
|
||||
B_TRANSLATE("Text"),
|
||||
B_TRANSLATE("Background"),
|
||||
B_TRANSLATE("Cursor text"),
|
||||
B_TRANSLATE("Cursor background"),
|
||||
B_TRANSLATE("Selected text"),
|
||||
B_TRANSLATE("Selected background"),
|
||||
NULL
|
||||
|
@ -44,6 +44,8 @@ static const pref_defaults kTermDefaults[] = {
|
||||
|
||||
{ PREF_TEXT_FORE_COLOR, " 0, 0, 0" },
|
||||
{ PREF_TEXT_BACK_COLOR, "255, 255, 255" },
|
||||
{ PREF_CURSOR_FORE_COLOR, " 0, 0, 0" },
|
||||
{ PREF_CURSOR_BACK_COLOR, "255, 200, 0" },
|
||||
{ PREF_SELECT_FORE_COLOR, "255, 255, 255" },
|
||||
{ PREF_SELECT_BACK_COLOR, " 0, 0, 0" },
|
||||
|
||||
|
@ -103,6 +103,8 @@ static const char* const PREF_HALF_FONT_SIZE = "Half Font Size";
|
||||
|
||||
static const char* const PREF_TEXT_FORE_COLOR = "Text";
|
||||
static const char* const PREF_TEXT_BACK_COLOR = "Background";
|
||||
static const char* const PREF_CURSOR_FORE_COLOR = "Cursor text";
|
||||
static const char* const PREF_CURSOR_BACK_COLOR = "Cursor background";
|
||||
static const char* const PREF_SELECT_FORE_COLOR = "Selected text";
|
||||
static const char* const PREF_SELECT_BACK_COLOR = "Selected background";
|
||||
|
||||
|
@ -886,6 +886,14 @@ TermView::SetTextColor(rgb_color fore, rgb_color back)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TermView::SetCursorColor(rgb_color fore, rgb_color back)
|
||||
{
|
||||
fCursorForeColor = fore;
|
||||
fCursorBackColor = back;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TermView::SetSelectColor(rgb_color fore, rgb_color back)
|
||||
{
|
||||
@ -1143,13 +1151,8 @@ TermView::_DrawLinePart(int32 x1, int32 y1, uint32 attr, char *buf,
|
||||
|
||||
// Selection check.
|
||||
if (cursor) {
|
||||
rgb_fore.red = 255 - rgb_fore.red;
|
||||
rgb_fore.green = 255 - rgb_fore.green;
|
||||
rgb_fore.blue = 255 - rgb_fore.blue;
|
||||
|
||||
rgb_back.red = 255 - rgb_back.red;
|
||||
rgb_back.green = 255 - rgb_back.green;
|
||||
rgb_back.blue = 255 - rgb_back.blue;
|
||||
rgb_fore = fCursorForeColor;
|
||||
rgb_back = fCursorBackColor;
|
||||
} else if (mouse) {
|
||||
rgb_fore = fSelectForeColor;
|
||||
rgb_back = fSelectBackColor;
|
||||
@ -1225,15 +1228,8 @@ TermView::_DrawCursor()
|
||||
} else {
|
||||
if (selected)
|
||||
SetHighColor(fSelectBackColor);
|
||||
else {
|
||||
rgb_color color = kTermColorTable[IS_BACKCOLOR(attr)];
|
||||
if (cursorVisible) {
|
||||
color.red = 255 - color.red;
|
||||
color.green = 255 - color.green;
|
||||
color.blue = 255 - color.blue;
|
||||
}
|
||||
SetHighColor(color);
|
||||
}
|
||||
else
|
||||
SetHighColor(fCursorBackColor);
|
||||
|
||||
FillRect(rect);
|
||||
}
|
||||
|
@ -77,6 +77,7 @@ public:
|
||||
int *rows, int *columns);
|
||||
|
||||
void SetTextColor(rgb_color fore, rgb_color back);
|
||||
void SetCursorColor(rgb_color fore, rgb_color back);
|
||||
void SetSelectColor(rgb_color fore, rgb_color back);
|
||||
|
||||
int Encoding() const;
|
||||
@ -255,6 +256,8 @@ private:
|
||||
InlineInput* fInline;
|
||||
|
||||
// Color and Attribute.
|
||||
rgb_color fCursorForeColor;
|
||||
rgb_color fCursorBackColor;
|
||||
rgb_color fSelectForeColor;
|
||||
rgb_color fSelectBackColor;
|
||||
|
||||
|
@ -1018,6 +1018,8 @@ TermWindow::_SetTermColors(TermViewContainerView* containerView)
|
||||
TermView *termView = containerView->GetTermView();
|
||||
termView->SetTextColor(handler->getRGB(PREF_TEXT_FORE_COLOR), background);
|
||||
|
||||
termView->SetCursorColor(handler->getRGB(PREF_CURSOR_FORE_COLOR),
|
||||
handler->getRGB(PREF_CURSOR_BACK_COLOR));
|
||||
termView->SetSelectColor(handler->getRGB(PREF_SELECT_FORE_COLOR),
|
||||
handler->getRGB(PREF_SELECT_BACK_COLOR));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user