Improve attribute setting for bold, reverse and underline output

This commit is contained in:
Markus Gans 2015-10-11 04:09:58 +02:00
parent eb05f1c1ed
commit a41727c4fc
10 changed files with 122 additions and 24 deletions

View File

@ -1,3 +1,6 @@
2015-10-11 Markus Gans <guru.mail@muenster.de>
* Improve attribute setting for bold, reverse and underline output
2015-10-10 Markus Gans <guru.mail@muenster.de> 2015-10-10 Markus Gans <guru.mail@muenster.de>
* Deactivate a key from the status bar automatically * Deactivate a key from the status bar automatically
after getting back from the callback. after getting back from the callback.

View File

@ -1,6 +1,19 @@
Bugs Bugs
~~~~ ~~~~
- -
Improvements
~~~~~~~~~~~~
- Use only termpap variables for FTerm::hideCursor()
- If t_exit_underline_mode == "\E[24m"
-> implement t_exit_bold_mode with "\E[21m"
-> implement t_exit_reverse_mode with "\E[27m"
- New behavior in FTerm::appendAttributes(...)
- 1st: reset don't needed attributes (bold, reverse and underline)
- 2nd: set the foreground and background color
- 3rd: set new attributes (bold, reverse and underline)
Missing Features Missing Features
~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~

View File

@ -198,12 +198,18 @@ void FDialog::drawTitleBar()
// draw the title button // draw the title button
gotoxy (xpos+xmin-1, ypos+ymin-1); gotoxy (xpos+xmin-1, ypos+ymin-1);
setColor (wc.titlebar_button_fg, wc.titlebar_button_bg); setColor (wc.titlebar_button_fg, wc.titlebar_button_bg);
if ( isMonochron() )
setReverse(true);
if ( isNewFont() ) if ( isNewFont() )
{ {
print (fc::NF_rev_menu_button1); print (fc::NF_rev_menu_button1);
print (fc::NF_rev_menu_button2); print (fc::NF_rev_menu_button2);
print (fc::NF_rev_menu_button3); print (fc::NF_rev_menu_button3);
} }
else if ( isMonochron() )
print ("[-]");
else else
print (" - "); print (" - ");
@ -213,9 +219,6 @@ void FDialog::drawTitleBar()
else else
setColor (wc.titlebar_inactive_fg, wc.titlebar_inactive_bg); setColor (wc.titlebar_inactive_fg, wc.titlebar_inactive_bg);
if ( isMonochron() )
setReverse(true);
i = width - 3 - int(length); i = width - 3 - int(length);
i = int(i/2); i = int(i/2);

View File

@ -138,8 +138,8 @@ void FLineEdit::drawInputField()
gotoxy (xpos+xmin-1, ypos+ymin-1); gotoxy (xpos+xmin-1, ypos+ymin-1);
if ( isMonochron() ) if ( isMonochron() )
{ {
setReverse(true);
print (' '); print (' ');
setUnderline(true);
} }
else if ( isActiveFocus ) else if ( isActiveFocus )
{ {
@ -190,7 +190,7 @@ void FLineEdit::drawInputField()
x++; x++;
} }
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setUnderline(false);
if ( isShadow ) if ( isShadow )
drawShadow (); drawShadow ();

View File

@ -565,7 +565,7 @@ FMessageBox::info (this, "Info", FString().sprintf("local(%d,%d) global(%d,%d)\n
ev = new FMouseEvent (MouseMove_Event, p, g, b); ev = new FMouseEvent (MouseMove_Event, p, g, b);
setClickedWidget(menubar); setClickedWidget(menubar);
FMenuBar* sm = reinterpret_cast<FMenuBar*>(menubar); FMenuBar* sm = reinterpret_cast<FMenuBar*>(menubar);
sm->onMouseMove(ev); sm->onMouseDown(ev);
delete ev; delete ev;
} }

View File

@ -137,6 +137,8 @@ void FMenuBar::drawItems()
iter = itemlist.begin(); iter = itemlist.begin();
end = itemlist.end(); end = itemlist.end();
if ( isMonochron() )
setReverse(true);
while ( iter != end ) while ( iter != end )
{ {
wchar_t* src; wchar_t* src;
@ -231,8 +233,11 @@ void FMenuBar::drawItems()
++iter; ++iter;
} }
for (; x <= screenWidth; x++) for (; x <= screenWidth; x++)
print (vmenubar, ' '); print (vmenubar, ' ');
if ( isMonochron() )
setReverse(false);
setUpdateVTerm(true); setUpdateVTerm(true);
} }

View File

@ -61,7 +61,8 @@ void FSwitch::drawCheckButton()
{ {
if ( hasFocus() && ! button_pressed ) if ( hasFocus() && ! button_pressed )
{ {
if ( isMonochron() )
setBold(true);
if ( isMonochron() || getMaxColor() < 16 ) if ( isMonochron() || getMaxColor() < 16 )
{ {
wcsncpy ( on, L" <On>", 6); wcsncpy ( on, L" <On>", 6);
@ -75,7 +76,16 @@ void FSwitch::drawCheckButton()
setColor (wc.button_active_focus_fg, wc.button_active_bg); setColor (wc.button_active_focus_fg, wc.button_active_bg);
else else
setColor (wc.button_hotkey_fg, wc.button_active_bg); setColor (wc.button_hotkey_fg, wc.button_active_bg);
if ( isMonochron() )
setReverse(true);
print (on); print (on);
if ( isMonochron() )
{
setReverse(false);
setBold(false);
}
setColor (wc.button_inactive_fg, wc.button_inactive_bg); setColor (wc.button_inactive_fg, wc.button_inactive_bg);
print (off); print (off);
setCursorPos ( xpos + xmin + 1 + switch_offset_pos setCursorPos ( xpos + xmin + 1 + switch_offset_pos
@ -85,8 +95,11 @@ void FSwitch::drawCheckButton()
{ {
setColor (wc.button_inactive_fg, wc.button_inactive_bg); setColor (wc.button_inactive_fg, wc.button_inactive_bg);
print (on); print (on);
if ( hasFocus() && ! button_pressed ) if ( hasFocus() && ! button_pressed )
{ {
if ( isMonochron() )
setBold(true);
if ( isMonochron() || getMaxColor() < 16 ) if ( isMonochron() || getMaxColor() < 16 )
{ {
wcsncpy ( off, L"<Off>", 6); wcsncpy ( off, L"<Off>", 6);
@ -100,7 +113,16 @@ void FSwitch::drawCheckButton()
setColor (wc.button_active_focus_fg, wc.button_active_bg); setColor (wc.button_active_focus_fg, wc.button_active_bg);
else else
setColor (wc.button_hotkey_fg, wc.button_active_bg); setColor (wc.button_hotkey_fg, wc.button_active_bg);
if ( isMonochron() )
setReverse(true);
print (off); print (off);
if ( isMonochron() )
{
setReverse(false);
setBold(false);
}
setCursorPos ( xpos + xmin + 5 + switch_offset_pos setCursorPos ( xpos + xmin + 5 + switch_offset_pos
, ypos + ymin - 1 ); , ypos + ymin - 1 );
} }

View File

@ -55,6 +55,7 @@ bool FTerm::non_blocking_stdin;
bool FTerm::gpm_mouse_enabled; bool FTerm::gpm_mouse_enabled;
bool FTerm::color256; bool FTerm::color256;
bool FTerm::monochron; bool FTerm::monochron;
bool FTerm::exit_underline_caused_reset;
bool FTerm::background_color_erase; bool FTerm::background_color_erase;
bool FTerm::automatic_left_margin; bool FTerm::automatic_left_margin;
bool FTerm::automatic_right_margin; bool FTerm::automatic_right_margin;
@ -1103,6 +1104,19 @@ void FTerm::init_termcaps()
tcap[t_cursor_address].string = \ tcap[t_cursor_address].string = \
const_cast<char*>("\033[%i%p1%d;%p2%dH"); const_cast<char*>("\033[%i%p1%d;%p2%dH");
// test if "ue" reset all attributes
if ( tcap[t_exit_underline_mode].string )
{
if ( strncmp(tcap[t_exit_underline_mode].string, "\033[m", 3) == 0
|| strncmp(tcap[t_exit_underline_mode].string, "\033G0", 3) == 0
|| strncmp(tcap[t_exit_underline_mode].string, "\033[7m", 4) == 0
|| strcmp ( tcap[t_exit_underline_mode].string
, tcap[t_exit_standout_mode].string ) == 0 )
exit_underline_caused_reset = true;
else
exit_underline_caused_reset = false;
}
// read termcap key strings // read termcap key strings
for (int i=0; Fkey[i].tname[0] != 0; i++) for (int i=0; Fkey[i].tname[0] != 0; i++)
{ {
@ -3024,6 +3038,9 @@ void FTerm::setTermColor (register int fg, register int bg)
char* Sb = tcap[t_set_background].string; char* Sb = tcap[t_set_background].string;
char* sp = tcap[t_set_color_pair].string; char* sp = tcap[t_set_color_pair].string;
if ( monochron )
return;
if ( AF && AB ) if ( AF && AB )
{ {
int ansi_fg = vga2ansi(fg); int ansi_fg = vga2ansi(fg);
@ -3226,13 +3243,23 @@ bool FTerm::setTermBold (bool on)
char* us = tcap[t_enter_underline_mode].string; char* us = tcap[t_enter_underline_mode].string;
char* mr = tcap[t_enter_reverse_mode].string; char* mr = tcap[t_enter_reverse_mode].string;
// "t_exit_attribute_mode" will reset all attributes!
appendOutputBuffer (me); appendOutputBuffer (me);
setTermColor (fg_color, bg_color); // restore the last color
if ( underline && ue && us ) // last color restore
if ( ! monochron )
{
fg_color = fg_term_color;
bg_color = bg_term_color;
fg_term_color = -1;
bg_term_color = -1;
setTermColor (fg_color, bg_color);
}
// underline mode restore
if ( term_underline && ue && us )
appendOutputBuffer (us); appendOutputBuffer (us);
// reverse mode restore
if ( reverse && me && mr ) if ( term_reverse && me && mr )
appendOutputBuffer (mr); appendOutputBuffer (mr);
} }
term_bold = false; term_bold = false;
@ -3262,11 +3289,22 @@ bool FTerm::setTermReverse (bool on)
char* us = tcap[t_enter_underline_mode].string; char* us = tcap[t_enter_underline_mode].string;
char* md = tcap[t_enter_bold_mode].string; char* md = tcap[t_enter_bold_mode].string;
// "t_exit_standout_mode" will reset all attributes!
appendOutputBuffer (se); appendOutputBuffer (se);
// last color restore
if ( ! monochron )
{
fg_color = fg_term_color;
bg_color = bg_term_color;
fg_term_color = -1;
bg_term_color = -1;
setTermColor (fg_color, bg_color);
}
// underline mode restore
if ( term_underline && ue && us ) if ( term_underline && ue && us )
appendOutputBuffer (us); appendOutputBuffer (us);
// bold mode restore
if ( term_bold && md && se ) if ( term_bold && md && se )
appendOutputBuffer (md); appendOutputBuffer (md);
} }
@ -3302,11 +3340,24 @@ bool FTerm::setTermUnderline (bool on)
appendOutputBuffer (ue); appendOutputBuffer (ue);
if ( term_reverse && se && mr && strcmp(ue, se) == 0 ) if ( exit_underline_caused_reset )
appendOutputBuffer (mr); {
// last color restore
if ( term_bold && md && se && strcmp(ue, se) == 0 ) if ( ! monochron )
appendOutputBuffer (md); {
fg_color = fg_term_color;
bg_color = bg_term_color;
fg_term_color = -1;
bg_term_color = -1;
setTermColor (fg_color, bg_color);
}
// reverse mode restore
if ( term_reverse && se && mr )
appendOutputBuffer (mr);
// bold mode restore
if ( term_bold && md && se )
appendOutputBuffer (md);
}
} }
term_underline = false; term_underline = false;
} }

View File

@ -130,6 +130,7 @@ class FTerm
static bool tmux_terminal; static bool tmux_terminal;
static bool terminal_updates; static bool terminal_updates;
static bool vterm_updates; static bool vterm_updates;
static bool exit_underline_caused_reset;
static bool background_color_erase; static bool background_color_erase;
static bool automatic_left_margin; static bool automatic_left_margin;
static bool automatic_right_margin; static bool automatic_right_margin;

View File

@ -341,15 +341,15 @@ void FWidget::setColorTheme()
wc.menu_inactive_bg = fc::LightGray; wc.menu_inactive_bg = fc::LightGray;
wc.menu_hotkey_fg = fc::Red; wc.menu_hotkey_fg = fc::Red;
wc.menu_hotkey_bg = fc::LightGray; wc.menu_hotkey_bg = fc::LightGray;
wc.statusbar_fg = fc::LightGray; wc.statusbar_fg = fc::Black;
wc.statusbar_bg = fc::Blue; wc.statusbar_bg = fc::LightGray;
wc.statusbar_hotkey_fg = fc::Red; wc.statusbar_hotkey_fg = fc::Red;
wc.statusbar_hotkey_bg = fc::Blue; wc.statusbar_hotkey_bg = fc::LightGray;
wc.statusbar_separator_fg = fc::Black; wc.statusbar_separator_fg = fc::Black;
wc.statusbar_active_fg = fc::Blue; wc.statusbar_active_fg = fc::LightGray;
wc.statusbar_active_bg = fc::LightGray; wc.statusbar_active_bg = fc::Black;
wc.statusbar_active_hotkey_fg = fc::Red; wc.statusbar_active_hotkey_fg = fc::Red;
wc.statusbar_active_hotkey_bg = fc::LightGray; wc.statusbar_active_hotkey_bg = fc::Black;
wc.scrollbar_fg = fc::Black; wc.scrollbar_fg = fc::Black;
wc.scrollbar_bg = fc::LightGray; wc.scrollbar_bg = fc::LightGray;
wc.scrollbar_button_fg = fc::Black; wc.scrollbar_button_fg = fc::Black;