diff --git a/ChangeLog b/ChangeLog index 79ebb5f0..4dd02b49 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2016-11-06 Markus Gans + * The use of xterm default colors now is configurable + 2016-11-05 Markus Gans * Determine xterm maximum number of colors via OSC 4 * The method clearArea can now fill the background diff --git a/src/fterm.cpp b/src/fterm.cpp index 8b6ba1da..3b6c6c0a 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -58,6 +58,7 @@ bool FTerm::ascii_console; bool FTerm::NewFont; bool FTerm::VGAFont; bool FTerm::cursor_optimisation; +bool FTerm::xterm_default_colors; termios FTerm::term_init; char FTerm::termtype[30] = ""; char* FTerm::term_name = 0; @@ -958,6 +959,25 @@ void FTerm::setXTermHighlightBackground (const FString& hbg) } } +//---------------------------------------------------------------------- +void FTerm::setXTermDefaults() +{ + setXTermMouseBackground("rgb:ffff/ffff/ffff"); + setXTermMouseForeground ("rgb:0000/0000/0000"); + + if ( ! gnome_terminal ) + setXTermCursorColor("rgb:ffff/ffff/ffff"); + + if ( xterm_default_colors + && ! (mintty_terminal || rxvt_terminal || screen_terminal) ) + { + // mintty and rxvt can't reset these settings + setXTermBackground("rgb:8080/a4a4/ecec"); + setXTermForeground("rgb:0000/0000/0000"); + setXTermHighlightBackground("rgb:8686/8686/8686"); + } +} + //---------------------------------------------------------------------- void FTerm::resetXTermColors() { @@ -1050,6 +1070,22 @@ void FTerm::resetXTermHighlightBackground() } } +//---------------------------------------------------------------------- +void FTerm::resetXTermDefaults() +{ + setXTermCursorColor("rgb:b1b1/b1b1/b1b1"); + resetXTermMouseForeground(); + resetXTermMouseBackground(); + resetXTermCursorColor(); + + if ( xterm_default_colors ) + { + resetXTermForeground(); + resetXTermBackground(); + resetXTermHighlightBackground(); + } +} + //---------------------------------------------------------------------- void FTerm::saveColorMap() { @@ -2900,27 +2936,28 @@ void FTerm::init() (*encoding_set)["ASCII"] = fc::ASCII; // Preset to false - utf8_console = \ - utf8_input = \ - utf8_state = \ - utf8_linux_terminal = \ - pc_charset_console = \ - vt100_console = \ - NewFont = \ - VGAFont = \ - ascii_console = \ - mouse_support = \ - force_vt100 = \ - tera_terminal = \ - kterm_terminal = \ - gnome_terminal = \ - kde_konsole = \ - rxvt_terminal = \ - urxvt_terminal = \ - mlterm_terminal = \ - mintty_terminal = \ - screen_terminal = \ - tmux_terminal = false; + utf8_console = \ + utf8_input = \ + utf8_state = \ + utf8_linux_terminal = \ + pc_charset_console = \ + vt100_console = \ + NewFont = \ + VGAFont = \ + ascii_console = \ + mouse_support = \ + force_vt100 = \ + tera_terminal = \ + kterm_terminal = \ + gnome_terminal = \ + kde_konsole = \ + rxvt_terminal = \ + urxvt_terminal = \ + mlterm_terminal = \ + mintty_terminal = \ + screen_terminal = \ + tmux_terminal = \ + xterm_default_colors = false; // Preset to true cursor_optimisation = true; @@ -3117,9 +3154,6 @@ void FTerm::init() std::fflush(stdout); } - setXTermCursorStyle(fc::blinking_underline); - setXTermColors(); - setRawMode(); if ( (xterm_terminal || urxvt_terminal) && ! rxvt_terminal ) @@ -3225,14 +3259,10 @@ void FTerm::finish() std::fflush(stdout); } - // reset xterm color settings to default - setXTermCursorColor("rgb:b1b1/b1b1/b1b1"); - resetXTermMouseForeground(); - resetXTermMouseBackground(); - resetXTermCursorColor(); - resetXTermForeground(); - resetXTermBackground(); - resetXTermHighlightBackground(); + // reset xterm color settings to default values + resetXTermDefaults(); + + // set xterm full block cursor setXTermCursorStyle(fc::steady_block); if ( FTermcap::max_color >= 16 && ! (kde_konsole || tera_terminal) ) @@ -3350,24 +3380,6 @@ void FTerm::finish() delete opti_move; } -//---------------------------------------------------------------------- -void FTerm::setXTermColors() -{ - setXTermMouseBackground("rgb:ffff/ffff/ffff"); - setXTermMouseForeground ("rgb:0000/0000/0000"); - - if ( ! gnome_terminal ) - setXTermCursorColor("rgb:ffff/ffff/ffff"); - - if ( ! (mintty_terminal || rxvt_terminal || screen_terminal) ) - { - // mintty and rxvt can't reset these settings - setXTermBackground("rgb:8080/a4a4/ecec"); - setXTermForeground("rgb:0000/0000/0000"); - setXTermHighlightBackground("rgb:8686/8686/8686"); - } -} - //---------------------------------------------------------------------- uInt FTerm::cp437_to_unicode (uChar c) { diff --git a/src/fterm.h b/src/fterm.h index 08ad1663..8264619b 100644 --- a/src/fterm.h +++ b/src/fterm.h @@ -142,6 +142,7 @@ class FTerm // Mutators static bool setCursorOptimisation (bool); + static void setXTermDefaultColors (bool); static void setConsoleCursor (fc::consoleCursorStyle, bool); static bool setRawMode (bool); static bool setRawMode(); @@ -177,6 +178,7 @@ class FTerm static void setXTermMouseForeground (const FString&); static void setXTermMouseBackground (const FString&); static void setXTermHighlightBackground (const FString&); + static void setXTermDefaults(); static void resetXTermColors(); static void resetXTermForeground(); static void resetXTermBackground(); @@ -184,6 +186,7 @@ class FTerm static void resetXTermMouseForeground(); static void resetXTermMouseBackground(); static void resetXTermHighlightBackground(); + static void resetXTermDefaults(); static void saveColorMap(); static void resetColorMap(); static void setPalette (short, int, int, int); @@ -248,6 +251,7 @@ class FTerm static bool NewFont; static bool VGAFont; static bool cursor_optimisation; + static bool xterm_default_colors; static fc::encoding Encoding; static char exit_message[8192]; @@ -300,7 +304,6 @@ class FTerm static void init_encoding(); void init(); void finish(); - static void setXTermColors(); static uInt cp437_to_unicode (uChar); static void signal_handler (int); @@ -492,6 +495,10 @@ inline bool FTerm::isUTF8_linux_terminal() inline bool FTerm::setCursorOptimisation (bool on) { return cursor_optimisation = (on) ? true : false; } +//---------------------------------------------------------------------- +inline void FTerm::setXTermDefaultColors (bool on) +{ xterm_default_colors = on; } + //---------------------------------------------------------------------- inline bool FTerm::setRawMode() { return setRawMode(true); } diff --git a/src/fwidget.cpp b/src/fwidget.cpp index e6834fad..8b60dc7b 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -1092,7 +1092,13 @@ void FWidget::show() // Important: Do not use setNewFont() or setVGAFont() after // the console character mapping has been initialized if ( getMainWidget() == this ) + { init_consoleCharMap(); + // set xterm underline cursor + setXTermCursorStyle(fc::blinking_underline); + // set xterm color settings to defaults + setXTermDefaults(); + } if ( ! show_root_widget ) { diff --git a/test/calculator.cpp b/test/calculator.cpp index ea2122b8..981e300f 100644 --- a/test/calculator.cpp +++ b/test/calculator.cpp @@ -243,7 +243,6 @@ Calc::Calc (FWidget* parent) setText ("calculator"); setGeometry (19, 6, 37, 18); addAccelerator('q'); // press 'q' to quit - //setShadow(); for (int key=0; key < Calc::NUM_OF_BUTTONS; key++) { diff --git a/test/ui.cpp b/test/ui.cpp index 022a3fdb..8dce781e 100644 --- a/test/ui.cpp +++ b/test/ui.cpp @@ -906,6 +906,7 @@ int main (int argc, char* argv[]) } FApplication app(argc, argv); + app.setXTermDefaultColors(true); app.setXTermTitle (title); //app.setEncoding("VT100");