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