Improve attribute setting for bold, reverse and underline output
This commit is contained in:
parent
eb05f1c1ed
commit
a41727c4fc
|
@ -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>
|
||||
* Deactivate a key from the status bar automatically
|
||||
after getting back from the callback.
|
||||
|
|
13
doc/TODO
13
doc/TODO
|
@ -2,6 +2,19 @@ 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
|
||||
~~~~~~~~~~~~~~~~
|
||||
- application menu
|
||||
|
|
|
@ -198,12 +198,18 @@ void FDialog::drawTitleBar()
|
|||
// draw the title button
|
||||
gotoxy (xpos+xmin-1, ypos+ymin-1);
|
||||
setColor (wc.titlebar_button_fg, wc.titlebar_button_bg);
|
||||
|
||||
if ( isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
if ( isNewFont() )
|
||||
{
|
||||
print (fc::NF_rev_menu_button1);
|
||||
print (fc::NF_rev_menu_button2);
|
||||
print (fc::NF_rev_menu_button3);
|
||||
}
|
||||
else if ( isMonochron() )
|
||||
print ("[-]");
|
||||
else
|
||||
print (" - ");
|
||||
|
||||
|
@ -213,9 +219,6 @@ void FDialog::drawTitleBar()
|
|||
else
|
||||
setColor (wc.titlebar_inactive_fg, wc.titlebar_inactive_bg);
|
||||
|
||||
if ( isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
i = width - 3 - int(length);
|
||||
i = int(i/2);
|
||||
|
||||
|
|
|
@ -138,8 +138,8 @@ void FLineEdit::drawInputField()
|
|||
gotoxy (xpos+xmin-1, ypos+ymin-1);
|
||||
if ( isMonochron() )
|
||||
{
|
||||
setReverse(true);
|
||||
print (' ');
|
||||
setUnderline(true);
|
||||
}
|
||||
else if ( isActiveFocus )
|
||||
{
|
||||
|
@ -190,7 +190,7 @@ void FLineEdit::drawInputField()
|
|||
x++;
|
||||
}
|
||||
if ( isMonochron() )
|
||||
setReverse(false);
|
||||
setUnderline(false);
|
||||
|
||||
if ( isShadow )
|
||||
drawShadow ();
|
||||
|
|
|
@ -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);
|
||||
setClickedWidget(menubar);
|
||||
FMenuBar* sm = reinterpret_cast<FMenuBar*>(menubar);
|
||||
sm->onMouseMove(ev);
|
||||
sm->onMouseDown(ev);
|
||||
delete ev;
|
||||
}
|
||||
|
||||
|
|
|
@ -137,6 +137,8 @@ void FMenuBar::drawItems()
|
|||
iter = itemlist.begin();
|
||||
end = itemlist.end();
|
||||
|
||||
if ( isMonochron() )
|
||||
setReverse(true);
|
||||
while ( iter != end )
|
||||
{
|
||||
wchar_t* src;
|
||||
|
@ -231,8 +233,11 @@ void FMenuBar::drawItems()
|
|||
|
||||
++iter;
|
||||
}
|
||||
|
||||
for (; x <= screenWidth; x++)
|
||||
print (vmenubar, ' ');
|
||||
if ( isMonochron() )
|
||||
setReverse(false);
|
||||
|
||||
setUpdateVTerm(true);
|
||||
}
|
||||
|
|
|
@ -61,7 +61,8 @@ void FSwitch::drawCheckButton()
|
|||
{
|
||||
if ( hasFocus() && ! button_pressed )
|
||||
{
|
||||
|
||||
if ( isMonochron() )
|
||||
setBold(true);
|
||||
if ( isMonochron() || getMaxColor() < 16 )
|
||||
{
|
||||
wcsncpy ( on, L" <On>", 6);
|
||||
|
@ -75,7 +76,16 @@ void FSwitch::drawCheckButton()
|
|||
setColor (wc.button_active_focus_fg, wc.button_active_bg);
|
||||
else
|
||||
setColor (wc.button_hotkey_fg, wc.button_active_bg);
|
||||
|
||||
if ( isMonochron() )
|
||||
setReverse(true);
|
||||
print (on);
|
||||
if ( isMonochron() )
|
||||
{
|
||||
setReverse(false);
|
||||
setBold(false);
|
||||
}
|
||||
|
||||
setColor (wc.button_inactive_fg, wc.button_inactive_bg);
|
||||
print (off);
|
||||
setCursorPos ( xpos + xmin + 1 + switch_offset_pos
|
||||
|
@ -85,8 +95,11 @@ void FSwitch::drawCheckButton()
|
|||
{
|
||||
setColor (wc.button_inactive_fg, wc.button_inactive_bg);
|
||||
print (on);
|
||||
|
||||
if ( hasFocus() && ! button_pressed )
|
||||
{
|
||||
if ( isMonochron() )
|
||||
setBold(true);
|
||||
if ( isMonochron() || getMaxColor() < 16 )
|
||||
{
|
||||
wcsncpy ( off, L"<Off>", 6);
|
||||
|
@ -100,7 +113,16 @@ void FSwitch::drawCheckButton()
|
|||
setColor (wc.button_active_focus_fg, wc.button_active_bg);
|
||||
else
|
||||
setColor (wc.button_hotkey_fg, wc.button_active_bg);
|
||||
|
||||
if ( isMonochron() )
|
||||
setReverse(true);
|
||||
print (off);
|
||||
if ( isMonochron() )
|
||||
{
|
||||
setReverse(false);
|
||||
setBold(false);
|
||||
}
|
||||
|
||||
setCursorPos ( xpos + xmin + 5 + switch_offset_pos
|
||||
, ypos + ymin - 1 );
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@ bool FTerm::non_blocking_stdin;
|
|||
bool FTerm::gpm_mouse_enabled;
|
||||
bool FTerm::color256;
|
||||
bool FTerm::monochron;
|
||||
bool FTerm::exit_underline_caused_reset;
|
||||
bool FTerm::background_color_erase;
|
||||
bool FTerm::automatic_left_margin;
|
||||
bool FTerm::automatic_right_margin;
|
||||
|
@ -1103,6 +1104,19 @@ void FTerm::init_termcaps()
|
|||
tcap[t_cursor_address].string = \
|
||||
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
|
||||
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* sp = tcap[t_set_color_pair].string;
|
||||
|
||||
if ( monochron )
|
||||
return;
|
||||
|
||||
if ( AF && AB )
|
||||
{
|
||||
int ansi_fg = vga2ansi(fg);
|
||||
|
@ -3226,13 +3243,23 @@ bool FTerm::setTermBold (bool on)
|
|||
char* us = tcap[t_enter_underline_mode].string;
|
||||
char* mr = tcap[t_enter_reverse_mode].string;
|
||||
|
||||
// "t_exit_attribute_mode" will reset all attributes!
|
||||
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);
|
||||
|
||||
if ( reverse && me && mr )
|
||||
// reverse mode restore
|
||||
if ( term_reverse && me && mr )
|
||||
appendOutputBuffer (mr);
|
||||
}
|
||||
term_bold = false;
|
||||
|
@ -3262,11 +3289,22 @@ bool FTerm::setTermReverse (bool on)
|
|||
char* us = tcap[t_enter_underline_mode].string;
|
||||
char* md = tcap[t_enter_bold_mode].string;
|
||||
|
||||
// "t_exit_standout_mode" will reset all attributes!
|
||||
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 )
|
||||
appendOutputBuffer (us);
|
||||
|
||||
// bold mode restore
|
||||
if ( term_bold && md && se )
|
||||
appendOutputBuffer (md);
|
||||
}
|
||||
|
@ -3302,12 +3340,25 @@ bool FTerm::setTermUnderline (bool on)
|
|||
|
||||
appendOutputBuffer (ue);
|
||||
|
||||
if ( term_reverse && se && mr && strcmp(ue, se) == 0 )
|
||||
if ( exit_underline_caused_reset )
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
// reverse mode restore
|
||||
if ( term_reverse && se && mr )
|
||||
appendOutputBuffer (mr);
|
||||
|
||||
if ( term_bold && md && se && strcmp(ue, se) == 0 )
|
||||
// bold mode restore
|
||||
if ( term_bold && md && se )
|
||||
appendOutputBuffer (md);
|
||||
}
|
||||
}
|
||||
term_underline = false;
|
||||
}
|
||||
return term_underline;
|
||||
|
|
|
@ -130,6 +130,7 @@ class FTerm
|
|||
static bool tmux_terminal;
|
||||
static bool terminal_updates;
|
||||
static bool vterm_updates;
|
||||
static bool exit_underline_caused_reset;
|
||||
static bool background_color_erase;
|
||||
static bool automatic_left_margin;
|
||||
static bool automatic_right_margin;
|
||||
|
|
|
@ -341,15 +341,15 @@ void FWidget::setColorTheme()
|
|||
wc.menu_inactive_bg = fc::LightGray;
|
||||
wc.menu_hotkey_fg = fc::Red;
|
||||
wc.menu_hotkey_bg = fc::LightGray;
|
||||
wc.statusbar_fg = fc::LightGray;
|
||||
wc.statusbar_bg = fc::Blue;
|
||||
wc.statusbar_fg = fc::Black;
|
||||
wc.statusbar_bg = fc::LightGray;
|
||||
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_active_fg = fc::Blue;
|
||||
wc.statusbar_active_bg = fc::LightGray;
|
||||
wc.statusbar_active_fg = fc::LightGray;
|
||||
wc.statusbar_active_bg = fc::Black;
|
||||
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_bg = fc::LightGray;
|
||||
wc.scrollbar_button_fg = fc::Black;
|
||||
|
|
Loading…
Reference in New Issue