Color setting improvements

This commit is contained in:
Markus Gans 2015-10-23 23:57:00 +02:00
parent 7e961d40c3
commit b9fa26965a
14 changed files with 241 additions and 200 deletions

View File

@ -1,3 +1,6 @@
2015-10-23 Markus Gans <guru.mail@muenster.de>
* Color setting improvements
2015-10-22 Markus Gans <guru.mail@muenster.de>
* Make cursor visibility more standards compliant.

View File

@ -185,7 +185,7 @@ void FButton::draw()
if ( ! is_Active && isMonochron() )
space = fc::MediumShade; // ▒
if ( (isMonochron() || getMaxColor() < 16) && is_ActiveFocus )
if ( isMonochron() && is_ActiveFocus )
{
txt = "<" + txt + ">";
length = int(txt.getLength());
@ -291,7 +291,7 @@ void FButton::draw()
setCursorPos ( xpos+xmin-1+margin+i+hotkeypos
, ypos+ymin-1+j ); // hotkey
if ( isMonochron() && is_ActiveFocus )
if ( (isMonochron() || getMaxColor() < 16) && is_ActiveFocus )
setBold();
for (int z=0; x < i+length && z < width; z++,x++)
@ -312,7 +312,7 @@ void FButton::draw()
}
}
if ( isMonochron() && is_ActiveFocus )
if ( (isMonochron() || getMaxColor() < 16) && is_ActiveFocus )
unsetBold();
for (x=i+length; x < width-1; x++)

View File

@ -206,6 +206,7 @@ void FDialog::drawTitleBar()
setReverse(true);
}
if ( isNewFont() )
{
print (fc::NF_rev_menu_button1);
@ -218,6 +219,8 @@ void FDialog::drawTitleBar()
print (" - ");
// fill with spaces (left of the title)
if ( getMaxColor() < 16 )
setBold();
if ( isActiveWindow() )
setColor (wc.titlebar_active_fg, wc.titlebar_active_bg);
else
@ -236,6 +239,8 @@ void FDialog::drawTitleBar()
for (; x+1+int(length) < width-1; x++)
print (' ');
if ( getMaxColor() < 16 )
unsetBold();
if ( isMonochron() )
setReverse(false);

View File

@ -55,7 +55,7 @@ FLineEdit::~FLineEdit() // destructor
setKDECursor(fc::UnderlineCursor);
setConsoleCursor(fc::underscore_cursor);
if ( isUrxvtTerminal() )
setXTermCursor("rgb:ffff/ffff/ffff");
setXTermCursorColor("rgb:ffff/ffff/ffff");
}
if ( hasFocus() )
hideCursor();
@ -175,6 +175,10 @@ void FLineEdit::drawInputField()
else
print (fc::RightHalfBlock); // ▐
}
if ( isActiveFocus && getMaxColor() < 16 )
setBold();
setColor (foregroundColor, backgroundColor);
show_text = text.mid(uInt(1+offset), uInt(width-2));
@ -193,6 +197,10 @@ void FLineEdit::drawInputField()
print (' ');
x++;
}
if ( isActiveFocus && getMaxColor() < 16 )
unsetBold();
if ( isMonochron() )
{
setReverse(false);
@ -466,7 +474,7 @@ void FLineEdit::onKeyPress (FKeyEvent* ev)
setKDECursor(fc::UnderlineCursor);
setConsoleCursor(fc::underscore_cursor);
if ( isUrxvtTerminal() )
setXTermCursor("rgb:ffff/ffff/ffff");
setXTermCursorColor("rgb:ffff/ffff/ffff");
}
else
{
@ -474,7 +482,7 @@ void FLineEdit::onKeyPress (FKeyEvent* ev)
setKDECursor(fc::BlockCursor);
setConsoleCursor(fc::full_block_cursor);
if ( isUrxvtTerminal() )
setXTermCursor("rgb:0000/0000/0000");
setXTermCursorColor("rgb:0000/0000/0000");
}
ev->accept();
break;
@ -717,7 +725,7 @@ void FLineEdit::onHide (FHideEvent*)
setKDECursor(fc::UnderlineCursor);
setConsoleCursor(fc::underscore_cursor);
if ( isUrxvtTerminal() )
setXTermCursor("rgb:ffff/ffff/ffff");
setXTermCursorColor("rgb:ffff/ffff/ffff");
}
if ( hasFocus() )
hideCursor();
@ -735,7 +743,7 @@ void FLineEdit::onFocusIn (FFocusEvent*)
setKDECursor(fc::UnderlineCursor);
setConsoleCursor(fc::underscore_cursor);
if ( isUrxvtTerminal() )
setXTermCursor("rgb:ffff/ffff/ffff");
setXTermCursorColor("rgb:ffff/ffff/ffff");
}
else
{
@ -743,7 +751,7 @@ void FLineEdit::onFocusIn (FFocusEvent*)
setKDECursor(fc::BlockCursor);
setConsoleCursor(fc::full_block_cursor);
if ( isUrxvtTerminal() )
setXTermCursor("rgb:0000/0000/0000");
setXTermCursorColor("rgb:0000/0000/0000");
}
if ( statusBar() )
{
@ -768,7 +776,7 @@ void FLineEdit::onFocusOut (FFocusEvent*)
setKDECursor(fc::UnderlineCursor);
setConsoleCursor(fc::underscore_cursor);
if ( isUrxvtTerminal() )
setXTermCursor("rgb:ffff/ffff/ffff");
setXTermCursorColor("rgb:ffff/ffff/ffff");
}
hideCursor();

View File

@ -263,19 +263,26 @@ void FListBox::drawList()
if ( isCurrentLine )
{
if ( isFocus && getMaxColor() < 16 )
setBold();
if ( isLineSelected )
{
if ( isMonochron() )
setBold();
else if ( isFocus )
setColor ( wc.selected_current_element_focus_fg
, wc.selected_current_element_focus_bg );
else
setColor ( wc.selected_current_element_fg
, wc.selected_current_element_bg );
setCursorPos ( xpos+xmin+1
, ypos+ymin+int(y) ); // first character
}
else
{
if ( isMonochron() )
unsetBold();
else if ( isFocus )
if ( isFocus )
{
setColor ( wc.current_element_focus_fg
, wc.current_element_focus_bg );
@ -297,8 +304,13 @@ void FListBox::drawList()
if ( isMonochron() )
setReverse(false);
}
else if ( isMonochron() )
else
{
if ( isFocus && getMaxColor() < 16 )
unsetBold();
if ( isMonochron() )
setReverse(true);
}
// print the entry
if ( isMonochron() && isCurrentLine )

View File

@ -204,6 +204,7 @@ void FMenuItem::processClicked()
//----------------------------------------------------------------------
void FMenuItem::onAccel (FAccelEvent* ev)
{
beep(); // activate by key
if ( isActivated() && ! isSelected() )
{
if ( super_menu && isMenuBar(super_menu) )

View File

@ -129,6 +129,7 @@ void FProgressbar::drawBar()
}
if ( isMonochron() )
setReverse(false);
updateTerminal();
flush_out();
}

View File

@ -80,11 +80,11 @@ void FScrollbar::init()
//----------------------------------------------------------------------
void FScrollbar::draw()
{
//setUpdateVTerm(false);
setUpdateVTerm(false);
drawButtons();
currentSliderPos = -1;
drawBar();
//setUpdateVTerm(true);
setUpdateVTerm(true);
}
//----------------------------------------------------------------------

View File

@ -62,11 +62,13 @@ void FSwitch::drawCheckButton()
if ( hasFocus() && ! button_pressed )
{
if ( isMonochron() )
setBold(true);
if ( isMonochron() || getMaxColor() < 16 )
{
wcsncpy ( on, L" <On>", 6);
setBold(true);
}
else if ( getMaxColor() < 16 )
{
setBold(true);
setColor (wc.button_active_focus_fg, wc.button_active_focus_bg);
}
else
@ -84,10 +86,10 @@ void FSwitch::drawCheckButton()
print (on);
if ( isMonochron() )
{
setReverse(true);
if ( isMonochron() || getMaxColor() < 16 )
setBold(false);
}
setColor (wc.button_inactive_fg, wc.button_inactive_bg);
print (off);
@ -108,10 +110,13 @@ void FSwitch::drawCheckButton()
if ( hasFocus() && ! button_pressed )
{
if ( isMonochron() )
setBold(true);
if ( isMonochron() || getMaxColor() < 16 )
{
wcsncpy ( off, L"<Off>", 6);
setBold(true);
}
else if ( getMaxColor() < 16 )
{
setBold(true);
setColor (wc.button_active_focus_fg, wc.button_active_focus_bg);
}
else
@ -128,7 +133,7 @@ void FSwitch::drawCheckButton()
print (off);
if ( isMonochron() )
if ( isMonochron() || getMaxColor() < 16 )
setBold(false);
setCursorPos ( xpos + xmin + 5 + switch_offset_pos

View File

@ -1054,7 +1054,7 @@ void FTerm::init_termcaps()
tcap[t_set_a_background].string = \
const_cast<char*>("\033[4%p1%{8}%m%d%?%p1%{7}%>%t;5%e;25%;m");
}
else if ( tera_terminal && color256 )
else if ( tera_terminal )
{
tcap[t_set_a_foreground].string = \
const_cast<char*>("\033[38;5;%p1%dm");
@ -1497,10 +1497,10 @@ void FTerm::init()
setXTermMouseBackground("rgb:ffff/ffff/ffff");
setXTermMouseForeground ("rgb:0000/0000/0000");
if ( ! gnome_terminal )
setXTermCursor("rgb:ffff/ffff/ffff");
if ( ! gnome_terminal && ! mintty_terminal )
setXTermCursorColor("rgb:ffff/ffff/ffff");
if ( ! mintty_terminal )
{
// gnome-terminal and mintty can't reset these settings
// mintty can't reset these settings
setXTermBackground("rgb:8080/a4a4/ecec");
setXTermForeground("rgb:0000/0000/0000");
setXTermHighlightBackground("rgb:b1b1/b1b1/b1b1");
@ -1587,15 +1587,14 @@ void FTerm::finish()
putstring (tcap[t_exit_attribute_mode].string);
fflush(stdout);
}
if ( ! gnome_terminal )
{
setXTermCursor("rgb:b1b1/b1b1/b1b1");
// reset xterm color settings to default
setXTermCursorColor("rgb:b1b1/b1b1/b1b1");
resetXTermMouseForeground();
resetXTermMouseBackground();
resetXTermCursor();
resetXTermCursorColor();
resetXTermForeground();
resetXTermBackground();
}
setXTermCursorStyle(fc::steady_block);
if ( max_color >= 16 && ! kde_konsole && ! tera_terminal )
@ -2773,7 +2772,7 @@ void FTerm::setXTermBackground (const FString& bg)
}
//----------------------------------------------------------------------
void FTerm::setXTermCursor (const FString& cc)
void FTerm::setXTermCursorColor (const FString& cc)
{
// Set the text cursor color
if ( xterm || mintty_terminal || urxvt_terminal )
@ -2822,7 +2821,7 @@ void FTerm::resetXTermForeground()
// Reset the VT100 text foreground color
if ( xterm )
{
putstring("\033]110;\07");
putstring("\033]110\07");
fflush(stdout);
}
}
@ -2833,18 +2832,18 @@ void FTerm::resetXTermBackground()
// Reset the VT100 text background color
if ( xterm )
{
putstring("\033]111;\07");
putstring("\033]111\07");
fflush(stdout);
}
}
//----------------------------------------------------------------------
void FTerm::resetXTermCursor()
void FTerm::resetXTermCursorColor()
{
// Reset the text cursor color
if ( xterm )
{
putstring("\033]112;\07");
putstring("\033]112\07");
fflush(stdout);
}
}
@ -2855,7 +2854,7 @@ void FTerm::resetXTermMouseForeground()
// Reset the mouse foreground color
if ( xterm )
{
putstring("\033]113;\07");
putstring("\033]113\07");
fflush(stdout);
}
}
@ -2866,7 +2865,7 @@ void FTerm::resetXTermMouseBackground()
// Reset the mouse background color
if ( xterm )
{
putstring("\033]114;\07");
putstring("\033]114\07");
fflush(stdout);
}
}

View File

@ -315,13 +315,13 @@ class FTerm
static void setXTermTitle (const FString&);
static void setXTermForeground (const FString&);
static void setXTermBackground (const FString&);
static void setXTermCursor (const FString&);
static void setXTermCursorColor (const FString&);
static void setXTermMouseForeground (const FString&);
static void setXTermMouseBackground (const FString&);
static void setXTermHighlightBackground (const FString&);
static void resetXTermForeground();
static void resetXTermBackground();
static void resetXTermCursor();
static void resetXTermCursorColor();
static void resetXTermMouseForeground();
static void resetXTermMouseBackground();
static void saveColorMap();

View File

@ -93,6 +93,7 @@ void FTextView::draw()
setUpdateVTerm(true);
}
}
setCursorPos(1,1);
updateTerminal();
flush_out();
}

View File

@ -207,7 +207,9 @@ void FWidget::setColorTheme()
wc.current_element_fg = fc::LightGray;
wc.current_element_bg = fc::Blue;
wc.current_inc_search_element_fg = fc::LightRed;
wc.selected_current_element_fg = fc::LightBlue;
wc.selected_current_element_focus_fg = fc::LightBlue;
wc.selected_current_element_focus_bg = fc::Blue;
wc.selected_current_element_fg = fc::Cyan;
wc.selected_current_element_bg = fc::Blue;
wc.label_fg = fc::Black;
wc.label_bg = fc::White;
@ -292,9 +294,11 @@ void FWidget::setColorTheme()
wc.current_element_focus_bg = fc::Red;
wc.current_element_fg = fc::LightGray;
wc.current_element_bg = fc::Blue;
wc.current_inc_search_element_fg = fc::Red;
wc.selected_current_element_fg = fc::Blue;
wc.selected_current_element_bg = fc::Red;
wc.current_inc_search_element_fg = fc::Brown;
wc.selected_current_element_focus_fg = fc::Blue;
wc.selected_current_element_focus_bg = fc::Red;
wc.selected_current_element_fg = fc::Cyan;
wc.selected_current_element_bg = fc::Blue;
wc.label_fg = fc::Black;
wc.label_bg = fc::LightGray;
wc.label_inactive_fg = fc::Cyan;

View File

@ -152,6 +152,8 @@ class FWidget : public FObject, public FTerm
uChar current_element_fg;
uChar current_element_bg;
uChar current_inc_search_element_fg;
uChar selected_current_element_focus_fg;
uChar selected_current_element_focus_bg;
uChar selected_current_element_fg;
uChar selected_current_element_bg;
uChar label_fg;