The use of xterm default colors now is configurable

This commit is contained in:
Markus Gans 2016-11-06 16:36:21 +01:00
parent e66f00ea92
commit 125c4b961b
6 changed files with 80 additions and 52 deletions

View File

@ -1,3 +1,6 @@
2016-11-06 Markus Gans <guru.mail@muenster.de>
* The use of xterm default colors now is configurable
2016-11-05 Markus Gans <guru.mail@muenster.de> 2016-11-05 Markus Gans <guru.mail@muenster.de>
* Determine xterm maximum number of colors via OSC 4 * Determine xterm maximum number of colors via OSC 4
* The method clearArea can now fill the background * The method clearArea can now fill the background

View File

@ -58,6 +58,7 @@ bool FTerm::ascii_console;
bool FTerm::NewFont; bool FTerm::NewFont;
bool FTerm::VGAFont; bool FTerm::VGAFont;
bool FTerm::cursor_optimisation; bool FTerm::cursor_optimisation;
bool FTerm::xterm_default_colors;
termios FTerm::term_init; termios FTerm::term_init;
char FTerm::termtype[30] = ""; char FTerm::termtype[30] = "";
char* FTerm::term_name = 0; 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() 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() void FTerm::saveColorMap()
{ {
@ -2920,7 +2956,8 @@ void FTerm::init()
mlterm_terminal = \ mlterm_terminal = \
mintty_terminal = \ mintty_terminal = \
screen_terminal = \ screen_terminal = \
tmux_terminal = false; tmux_terminal = \
xterm_default_colors = false;
// Preset to true // Preset to true
cursor_optimisation = true; cursor_optimisation = true;
@ -3117,9 +3154,6 @@ void FTerm::init()
std::fflush(stdout); std::fflush(stdout);
} }
setXTermCursorStyle(fc::blinking_underline);
setXTermColors();
setRawMode(); setRawMode();
if ( (xterm_terminal || urxvt_terminal) && ! rxvt_terminal ) if ( (xterm_terminal || urxvt_terminal) && ! rxvt_terminal )
@ -3225,14 +3259,10 @@ void FTerm::finish()
std::fflush(stdout); std::fflush(stdout);
} }
// reset xterm color settings to default // reset xterm color settings to default values
setXTermCursorColor("rgb:b1b1/b1b1/b1b1"); resetXTermDefaults();
resetXTermMouseForeground();
resetXTermMouseBackground(); // set xterm full block cursor
resetXTermCursorColor();
resetXTermForeground();
resetXTermBackground();
resetXTermHighlightBackground();
setXTermCursorStyle(fc::steady_block); setXTermCursorStyle(fc::steady_block);
if ( FTermcap::max_color >= 16 && ! (kde_konsole || tera_terminal) ) if ( FTermcap::max_color >= 16 && ! (kde_konsole || tera_terminal) )
@ -3350,24 +3380,6 @@ void FTerm::finish()
delete opti_move; 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) uInt FTerm::cp437_to_unicode (uChar c)
{ {

View File

@ -142,6 +142,7 @@ class FTerm
// Mutators // Mutators
static bool setCursorOptimisation (bool); static bool setCursorOptimisation (bool);
static void setXTermDefaultColors (bool);
static void setConsoleCursor (fc::consoleCursorStyle, bool); static void setConsoleCursor (fc::consoleCursorStyle, bool);
static bool setRawMode (bool); static bool setRawMode (bool);
static bool setRawMode(); static bool setRawMode();
@ -177,6 +178,7 @@ class FTerm
static void setXTermMouseForeground (const FString&); static void setXTermMouseForeground (const FString&);
static void setXTermMouseBackground (const FString&); static void setXTermMouseBackground (const FString&);
static void setXTermHighlightBackground (const FString&); static void setXTermHighlightBackground (const FString&);
static void setXTermDefaults();
static void resetXTermColors(); static void resetXTermColors();
static void resetXTermForeground(); static void resetXTermForeground();
static void resetXTermBackground(); static void resetXTermBackground();
@ -184,6 +186,7 @@ class FTerm
static void resetXTermMouseForeground(); static void resetXTermMouseForeground();
static void resetXTermMouseBackground(); static void resetXTermMouseBackground();
static void resetXTermHighlightBackground(); static void resetXTermHighlightBackground();
static void resetXTermDefaults();
static void saveColorMap(); static void saveColorMap();
static void resetColorMap(); static void resetColorMap();
static void setPalette (short, int, int, int); static void setPalette (short, int, int, int);
@ -248,6 +251,7 @@ class FTerm
static bool NewFont; static bool NewFont;
static bool VGAFont; static bool VGAFont;
static bool cursor_optimisation; static bool cursor_optimisation;
static bool xterm_default_colors;
static fc::encoding Encoding; static fc::encoding Encoding;
static char exit_message[8192]; static char exit_message[8192];
@ -300,7 +304,6 @@ class FTerm
static void init_encoding(); static void init_encoding();
void init(); void init();
void finish(); void finish();
static void setXTermColors();
static uInt cp437_to_unicode (uChar); static uInt cp437_to_unicode (uChar);
static void signal_handler (int); static void signal_handler (int);
@ -492,6 +495,10 @@ inline bool FTerm::isUTF8_linux_terminal()
inline bool FTerm::setCursorOptimisation (bool on) inline bool FTerm::setCursorOptimisation (bool on)
{ return cursor_optimisation = (on) ? true : false; } { return cursor_optimisation = (on) ? true : false; }
//----------------------------------------------------------------------
inline void FTerm::setXTermDefaultColors (bool on)
{ xterm_default_colors = on; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTerm::setRawMode() inline bool FTerm::setRawMode()
{ return setRawMode(true); } { return setRawMode(true); }

View File

@ -1092,7 +1092,13 @@ void FWidget::show()
// Important: Do not use setNewFont() or setVGAFont() after // Important: Do not use setNewFont() or setVGAFont() after
// the console character mapping has been initialized // the console character mapping has been initialized
if ( getMainWidget() == this ) if ( getMainWidget() == this )
{
init_consoleCharMap(); init_consoleCharMap();
// set xterm underline cursor
setXTermCursorStyle(fc::blinking_underline);
// set xterm color settings to defaults
setXTermDefaults();
}
if ( ! show_root_widget ) if ( ! show_root_widget )
{ {

View File

@ -243,7 +243,6 @@ Calc::Calc (FWidget* parent)
setText ("calculator"); setText ("calculator");
setGeometry (19, 6, 37, 18); setGeometry (19, 6, 37, 18);
addAccelerator('q'); // press 'q' to quit addAccelerator('q'); // press 'q' to quit
//setShadow();
for (int key=0; key < Calc::NUM_OF_BUTTONS; key++) for (int key=0; key < Calc::NUM_OF_BUTTONS; key++)
{ {

View File

@ -906,6 +906,7 @@ int main (int argc, char* argv[])
} }
FApplication app(argc, argv); FApplication app(argc, argv);
app.setXTermDefaultColors(true);
app.setXTermTitle (title); app.setXTermTitle (title);
//app.setEncoding("VT100"); //app.setEncoding("VT100");