Better background color for all terminals with a fixed color palette

This commit is contained in:
Markus Gans 2019-01-03 20:56:09 +01:00
parent 72fab50cbf
commit c365f07298
8 changed files with 63 additions and 55 deletions

View File

@ -3,6 +3,7 @@
* Integration of an output filter to replace missing characters
* Better Linux console support for UTF-8 encoding
(Default is PC charset encoding)
* Better background color for all terminals with a fixed color palette
2018-12-31 Markus Gans <guru.mail@muenster.de>
* Use the override specifier

View File

@ -133,6 +133,22 @@ bool FTerm::isCursorHideable()
return false;
}
//----------------------------------------------------------------------
bool FTerm::canChangeColorPalette()
{
if ( isCygwinTerminal()
|| isKdeTerminal()
|| isTeraTerm()
|| isMltermTerminal()
|| isNetBSDTerm()
|| isOpenBSDTerm()
|| isSunTerminal()
|| isAnsiTerminal() )
return false;
return FTermcap::can_change_color_palette;
}
//----------------------------------------------------------------------
void FTerm::setTermType (const char term_name[])
{
@ -1487,22 +1503,6 @@ inline bool FTerm::hasNoFontSettingOption()
return false;
}
//----------------------------------------------------------------------
inline bool FTerm::canChangeColorPalette()
{
if ( isCygwinTerminal()
|| isKdeTerminal()
|| isTeraTerm()
|| isMltermTerminal()
|| isNetBSDTerm()
|| isOpenBSDTerm()
|| isSunTerminal()
|| isAnsiTerminal() )
return false;
return FTermcap::can_change_color_palette;
}
//----------------------------------------------------------------------
void FTerm::redefineColorPalette()
{

View File

@ -3,7 +3,7 @@
* *
* This file is part of the Final Cut widget toolkit *
* *
* Copyright 2018 Markus Gans *
* Copyright 2018-2019 Markus Gans *
* *
* The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
@ -67,7 +67,7 @@ void FTermcapQuirks::setFTermDetection (FTermDetection* td)
//----------------------------------------------------------------------
void FTermcapQuirks::terminalFixup()
{
auto td = term_detection;
auto& td = term_detection;
if ( td->isCygwinTerminal() )
{
@ -114,6 +114,8 @@ void FTermcapQuirks::terminalFixup()
// Fixes general quirks
general();
// ECMA-48 (ANSI X3.64) compatible terminal
ecma48();
}
#if defined(__FreeBSD__) || defined(__DragonFly__)
@ -548,11 +550,16 @@ void FTermcapQuirks::general()
if ( ! TCAP(fc::t_cursor_address) )
TCAP(fc::t_cursor_address) = \
C_STR(CSI "%i%p1%d;%p2%dH");
}
// Test for standard ECMA-48 (ANSI X3.64) terminal
if ( TCAP(fc::t_exit_underline_mode)
&& std::strncmp(TCAP(fc::t_exit_underline_mode), CSI "24m", 5) == 0 )
//----------------------------------------------------------------------
void FTermcapQuirks::ecma48()
{
// Test for standard ECMA-48 (ANSI X3.64) terminal
if ( ! TCAP(fc::t_exit_underline_mode)
|| std::strncmp(TCAP(fc::t_exit_underline_mode), CSI "24m", 5) != 0 )
return;
// Seems to be a ECMA-48 (ANSI X3.64) compatible terminal
TCAP(fc::t_enter_dbl_underline_mode) = \
C_STR(CSI "21m"); // Exit single underline, too
@ -584,6 +591,5 @@ void FTermcapQuirks::general()
TCAP(fc::t_exit_crossed_out_mode) = \
C_STR(CSI "29m");
}
}
} // namespace finalcut

View File

@ -3,7 +3,7 @@
* *
* This file is part of the Final Cut widget toolkit *
* *
* Copyright 2018 Markus Gans *
* Copyright 2018-2019 Markus Gans *
* *
* The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
@ -457,7 +457,10 @@ char* FTermDetection::termtype_256color_quirks()
if ( (color_env.string5 && std::strlen(color_env.string5) > 0)
|| (color_env.string6 && std::strlen(color_env.string6) > 0) )
{
terminal_type.kde_konsole = true;
new_termtype = C_STR("konsole-256color");
}
if ( color_env.string3 && std::strlen(color_env.string3) > 0 )
decscusr_support = true;

View File

@ -3,7 +3,7 @@
* *
* This file is part of the Final Cut widget toolkit *
* *
* Copyright 2015-2018 Markus Gans *
* Copyright 2015-2019 Markus Gans *
* *
* The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
@ -2331,16 +2331,9 @@ void FWidget::setColorTheme()
// Sets the default color theme
if ( getMaxColor() < 16 ) // for 8 color mode
{
wc.set8ColorTheme();
}
else
{
wc.set16ColorTheme();
if ( isKdeTerminal() )
wc.term_bg = fc::SkyBlue2;
}
}
} // namespace finalcut

View File

@ -3,7 +3,7 @@
* *
* This file is part of the Final Cut widget toolkit *
* *
* Copyright 2018 Markus Gans *
* Copyright 2018-2019 Markus Gans *
* *
* The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
@ -20,6 +20,7 @@
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#include "final/fterm.h"
#include "final/fwidgetcolors.h"
namespace finalcut
@ -206,6 +207,9 @@ void FWidgetColors::set16ColorTheme()
scrollbar_button_bg = fc::LightGray;
progressbar_fg = fc::DarkGray;
progressbar_bg = fc::LightBlue;
if ( ! FTerm::canChangeColorPalette() && FTerm::getMaxColor() > 16 )
term_bg = fc::SkyBlue2;
}
} // namespace finalcut

View File

@ -224,6 +224,7 @@ class FTerm
static bool hasShadowCharacter();
static bool hasHalfBlockCharacter();
static bool hasAlternateScreen();
static bool canChangeColorPalette();
// Mutators
static void setTermType (const char[]);
@ -364,7 +365,6 @@ class FTerm
static void init_tab_quirks();
static void init_captureFontAndTitle();
static bool hasNoFontSettingOption();
static bool canChangeColorPalette();
static void redefineColorPalette();
static void restoreColorPalette();
static void setInsertCursorStyle();

View File

@ -3,7 +3,7 @@
* *
* This file is part of the Final Cut widget toolkit *
* *
* Copyright 2018 Markus Gans *
* Copyright 2018-2019 Markus Gans *
* *
* The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
@ -85,6 +85,7 @@ class FTermcapQuirks
static void sunConsole();
static void screen();
static void general();
static void ecma48();
// Data Members
static FTermcap::tcap_map* tcap;