From 58bd7494636a39b95702b3e7c74872c2018aceff Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Thu, 9 Jul 2015 23:29:51 +0200 Subject: [PATCH] Better contrast on 8 color terminals --- ChangeLog | 3 +++ src/fbutton.cpp | 9 +++------ src/flistbox.cpp | 18 ++++++++++++++++-- src/fswitch.cpp | 43 ++++++++++++++++++++++++++++++++++--------- src/fwidget.cpp | 26 +++++++++++++------------- test/calculator.cpp | 2 +- 6 files changed, 70 insertions(+), 31 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6064bea4..e54c9aa8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2015-06-09 Markus Gans + * Better contrast on 8 color terminals + 2015-06-07 Markus Gans * Bug fix disable cursor on focus FSwitch * Hold down the mouse button displays FSwitch in a different color. diff --git a/src/fbutton.cpp b/src/fbutton.cpp index 1280e0d1..95a1046a 100644 --- a/src/fbutton.cpp +++ b/src/fbutton.cpp @@ -150,10 +150,10 @@ void FButton::draw() else d = 0; - if ( ! isActive && (isMonochron() || getMaxColor() < 16) ) + if ( ! isActive && isMonochron() ) space = fc::MediumShade; // ▒ - if ( isMonochron() && isActiveFocus ) + if ( (isMonochron() || getMaxColor() < 16) && isActiveFocus ) { txt = "<" + txt + ">"; length = int(txt.getLength()); @@ -202,10 +202,7 @@ void FButton::draw() } else if ( ! isMonochron() ) { - if ( ! isActive && getMaxColor() < 16 ) - setColor (button_fg, button_bg); - else - setColor (button_bg, parentWidget()->getBackgroundColor()); + setColor (button_bg, parentWidget()->getBackgroundColor()); gotoxy (xpos+xmin-1+d, ypos+ymin-1); for (int y=1; y <= height; y++) { diff --git a/src/flistbox.cpp b/src/flistbox.cpp index 7182c61e..de103b97 100644 --- a/src/flistbox.cpp +++ b/src/flistbox.cpp @@ -242,6 +242,7 @@ void FListBox::drawList() bool serach_mark = false; bool lineHasBrackets = hasBrackets(int(y)+yoffset+1); bool isLineSelected = isSelected(int(y)+yoffset+1); + bool isCurrentLine = bool(uInt(y)+uInt(yoffset)+1 == uInt(current)); if ( isLineSelected ) { @@ -258,7 +259,7 @@ void FListBox::drawList() setColor (wc.list_fg, wc.list_bg); } - if ( uInt(y)+uInt(yoffset)+1 == uInt(current) ) + if ( isCurrentLine ) { if ( isLineSelected ) { @@ -298,7 +299,10 @@ void FListBox::drawList() setReverse(false); // print the entry - print (' '); + if ( isMonochron() && isCurrentLine ) + print ('>'); + else + print (' '); if ( lineHasBrackets ) { const wchar_t* element_str; @@ -373,6 +377,11 @@ void FListBox::drawList() } i++; } + if ( isMonochron() && isCurrentLine ) + { + print ('<'); + i++; + } for (; b+i < uInt(width-nf_offset-3); i++) print (' '); } @@ -397,6 +406,11 @@ void FListBox::drawList() print (element_str[i]); } + if ( isMonochron() && isCurrentLine ) + { + print ('<'); + i++; + } for (; i < uInt(width-nf_offset-3); i++) print (' '); } diff --git a/src/fswitch.cpp b/src/fswitch.cpp index fb7802b7..069fca31 100644 --- a/src/fswitch.cpp +++ b/src/fswitch.cpp @@ -56,29 +56,54 @@ void FSwitch::drawCheckButton() if ( ! isVisible() ) return; - gotoxy (xpos+xmin-1+switch_offset_pos, ypos+ymin-1); + wchar_t on[6] = L" On "; + wchar_t off[6] = L" Off "; + gotoxy (xpos+xmin-1+switch_offset_pos, ypos+ymin-1); if ( checked ) { if ( hasFocus() && ! button_pressed ) - setColor (wc.button_hotkey_fg, wc.button_active_focus_bg); + { + + if ( isMonochron() || getMaxColor() < 16 ) + { + wcsncpy ( on, L" ", 6); + setColor (wc.button_active_focus_fg, wc.button_active_focus_bg); + } + else + setColor (wc.button_hotkey_fg, wc.button_active_focus_bg); + } else - setColor (wc.button_hotkey_fg, wc.button_active_bg); - print (" On "); + if ( isMonochron() || getMaxColor() < 16 ) + setColor (wc.button_active_focus_fg, wc.button_active_bg); + else + setColor (wc.button_hotkey_fg, wc.button_active_bg); + print (on); setColor (wc.button_inactive_fg, wc.button_inactive_bg); - print (" Off "); + print (off); setCursorPos ( xpos + xmin + 1 + switch_offset_pos, ypos + ymin - 1 ); } else { setColor (wc.button_inactive_fg, wc.button_inactive_bg); - print (" On "); + print (on); if ( hasFocus() && ! button_pressed ) - setColor (wc.button_hotkey_fg, wc.button_active_focus_bg); + { + if ( isMonochron() || getMaxColor() < 16 ) + { + wcsncpy ( off, L"", 6); + setColor (wc.button_active_focus_fg, wc.button_active_focus_bg); + } + else + setColor (wc.button_hotkey_fg, wc.button_active_focus_bg); + } else - setColor (wc.button_hotkey_fg, wc.button_active_bg); - print (" Off "); + if ( isMonochron() || getMaxColor() < 16 ) + setColor (wc.button_active_focus_fg, wc.button_active_bg); + else + setColor (wc.button_hotkey_fg, wc.button_active_bg); + print (off); setCursorPos ( xpos + xmin + 5 + switch_offset_pos, ypos + ymin - 1 ); } diff --git a/src/fwidget.cpp b/src/fwidget.cpp index 71126956..3b9328d5 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -258,7 +258,7 @@ void FWidget::setColorTheme() if ( max_color < 16 ) // for 8 color mode { wc.term_fg = fc::Black; - wc.term_bg = fc::Cyan; + wc.term_bg = fc::Blue; wc.list_fg = fc::Black; wc.list_bg = fc::LightGray; wc.selected_list_fg = fc::Blue; @@ -266,9 +266,9 @@ void FWidget::setColorTheme() wc.dialog_fg = fc::Black; wc.dialog_emphasis_fg = fc::Blue; wc.dialog_bg = fc::LightGray; - wc.error_box_fg = fc::LightGray; - wc.error_box_emphasis_fg = fc::Brown; - wc.error_box_bg = fc::Red; + wc.error_box_fg = fc::Black; + wc.error_box_emphasis_fg = fc::Red; + wc.error_box_bg = fc::LightGray; wc.shadow_fg = fc::Black; wc.shadow_bg = fc::LightGray; // only for transparent shadow wc.current_element_focus_fg = fc::LightGray; @@ -300,13 +300,13 @@ void FWidget::setColorTheme() wc.toggle_button_inactive_bg = fc::LightGray; wc.button_active_focus_fg = fc::LightGray; wc.button_active_focus_bg = fc::Blue; - wc.button_active_fg = fc::Black; - wc.button_active_bg = fc::Cyan; - wc.button_inactive_fg = fc::Cyan; - wc.button_inactive_bg = fc::LightGray; + wc.button_active_fg = fc::LightGray; + wc.button_active_bg = fc::Blue; + wc.button_inactive_fg = fc::LightGray; + wc.button_inactive_bg = fc::Cyan; wc.button_hotkey_fg = fc::Red; wc.titlebar_active_fg = fc::LightGray; - wc.titlebar_active_bg = fc::Blue; + wc.titlebar_active_bg = fc::Red; wc.titlebar_inactive_fg = fc::Black; wc.titlebar_inactive_bg = fc::LightGray; wc.titlebar_button_fg = fc::Black; @@ -320,11 +320,11 @@ void FWidget::setColorTheme() wc.statusbar_active_bg = fc::LightGray; wc.statusbar_active_hotkey_fg = fc::Red; wc.statusbar_active_hotkey_bg = fc::LightGray; - wc.scrollbar_fg = fc::Blue; + wc.scrollbar_fg = fc::Black; wc.scrollbar_bg = fc::LightGray; - wc.scrollbar_button_fg = fc::LightGray; - wc.scrollbar_button_bg = fc::Black; - wc.progressbar_fg = fc::Blue; + wc.scrollbar_button_fg = fc::Black; + wc.scrollbar_button_bg = fc::LightGray; + wc.progressbar_fg = fc::Black; wc.progressbar_bg = fc::LightGray; } } diff --git a/test/calculator.cpp b/test/calculator.cpp index 7b19df8a..46eb68d4 100644 --- a/test/calculator.cpp +++ b/test/calculator.cpp @@ -313,7 +313,7 @@ void Calc::drawDispay() print(display); print(L' '); - setColor(fc::Black, fc::White); + setColor(wc.dialog_fg, wc.dialog_bg); if ( isNewFont() ) { FString bottom_line(33, wchar_t(fc::NF_border_line_bottom));