diff --git a/ChangeLog b/ChangeLog index ccd563be..35003322 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 * Use the override specifier diff --git a/src/fterm.cpp b/src/fterm.cpp index 249ad834..12c0756c 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -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() { diff --git a/src/ftermcapquirks.cpp b/src/ftermcapquirks.cpp index 17eff812..9cf10be6 100644 --- a/src/ftermcapquirks.cpp +++ b/src/ftermcapquirks.cpp @@ -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,42 +550,46 @@ void FTermcapQuirks::general() if ( ! TCAP(fc::t_cursor_address) ) TCAP(fc::t_cursor_address) = \ C_STR(CSI "%i%p1%d;%p2%dH"); +} +//---------------------------------------------------------------------- +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 ) - { - // 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 + if ( ! TCAP(fc::t_exit_underline_mode) + || std::strncmp(TCAP(fc::t_exit_underline_mode), CSI "24m", 5) != 0 ) + return; - TCAP(fc::t_exit_dbl_underline_mode) = \ - C_STR(CSI "24m"); + // 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 - TCAP(fc::t_exit_bold_mode) = \ - C_STR(CSI "22m"); // Exit dim, too + TCAP(fc::t_exit_dbl_underline_mode) = \ + C_STR(CSI "24m"); - TCAP(fc::t_exit_dim_mode) = \ - C_STR(CSI "22m"); + TCAP(fc::t_exit_bold_mode) = \ + C_STR(CSI "22m"); // Exit dim, too - TCAP(fc::t_exit_underline_mode) = \ - C_STR(CSI "24m"); + TCAP(fc::t_exit_dim_mode) = \ + C_STR(CSI "22m"); - TCAP(fc::t_exit_blink_mode) = \ - C_STR(CSI "25m"); + TCAP(fc::t_exit_underline_mode) = \ + C_STR(CSI "24m"); - TCAP(fc::t_exit_reverse_mode) = \ - C_STR(CSI "27m"); + TCAP(fc::t_exit_blink_mode) = \ + C_STR(CSI "25m"); - TCAP(fc::t_exit_secure_mode) = \ - C_STR(CSI "28m"); + TCAP(fc::t_exit_reverse_mode) = \ + C_STR(CSI "27m"); - TCAP(fc::t_enter_crossed_out_mode) = \ - C_STR(CSI "9m"); + TCAP(fc::t_exit_secure_mode) = \ + C_STR(CSI "28m"); - TCAP(fc::t_exit_crossed_out_mode) = \ - C_STR(CSI "29m"); - } + TCAP(fc::t_enter_crossed_out_mode) = \ + C_STR(CSI "9m"); + + TCAP(fc::t_exit_crossed_out_mode) = \ + C_STR(CSI "29m"); } } // namespace finalcut diff --git a/src/ftermdetection.cpp b/src/ftermdetection.cpp index cd17c098..861dd739 100644 --- a/src/ftermdetection.cpp +++ b/src/ftermdetection.cpp @@ -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; diff --git a/src/fwidget.cpp b/src/fwidget.cpp index 9794b637..b12561ea 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -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 diff --git a/src/fwidgetcolors.cpp b/src/fwidgetcolors.cpp index f7bf5cf7..8a98bbc4 100644 --- a/src/fwidgetcolors.cpp +++ b/src/fwidgetcolors.cpp @@ -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 @@ * . * ***********************************************************************/ +#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 diff --git a/src/include/final/fterm.h b/src/include/final/fterm.h index fd0dc0a6..edf382f3 100644 --- a/src/include/final/fterm.h +++ b/src/include/final/fterm.h @@ -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(); diff --git a/src/include/final/ftermcapquirks.h b/src/include/final/ftermcapquirks.h index 947b95f5..45a36de1 100644 --- a/src/include/final/ftermcapquirks.h +++ b/src/include/final/ftermcapquirks.h @@ -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;