diff --git a/ChangeLog b/ChangeLog index e9d814ce..750627de 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2020-05-28 Markus Gans + * FColorPalette now also uses polymorphism, so you can now + easily create your own color palette theme + 2020-05-26 Markus Gans * FWidgetColors now uses polymorphism, so you can now easily create your own widget color theme diff --git a/src/Makefile.am b/src/Makefile.am index dadf1af8..098d9dbf 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -70,6 +70,7 @@ libfinal_la_SOURCES = \ foptimove.cpp \ ftermbuffer.cpp \ fapplication.cpp \ + fcolorpalette.cpp \ fwidgetcolors.cpp \ fwidget.cpp \ fwidget_functions.cpp \ diff --git a/src/Makefile.clang b/src/Makefile.clang index 80e85541..e5ce296d 100644 --- a/src/Makefile.clang +++ b/src/Makefile.clang @@ -145,6 +145,7 @@ OBJS = \ foptimove.o \ ftermbuffer.o \ fapplication.o \ + fcolorpalette.o \ fwidgetcolors.o \ fwidget.o \ fwidget_functions.o \ diff --git a/src/Makefile.gcc b/src/Makefile.gcc index 7998d9c6..e40bad84 100644 --- a/src/Makefile.gcc +++ b/src/Makefile.gcc @@ -145,6 +145,7 @@ OBJS = \ foptimove.o \ ftermbuffer.o \ fapplication.o \ + fcolorpalette.o \ fwidgetcolors.o \ fwidget.o \ fwidget_functions.o \ diff --git a/src/fcolorpalette.cpp b/src/fcolorpalette.cpp new file mode 100644 index 00000000..15f5d8b9 --- /dev/null +++ b/src/fcolorpalette.cpp @@ -0,0 +1,169 @@ +/*********************************************************************** +* fcolorpalette.cpp - Define RGB color value for a palette entry * +* * +* This file is part of the Final Cut widget toolkit * +* * +* Copyright 2020 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 * +* as published by the Free Software Foundation; either version 3 of * +* the License, or (at your option) any later version. * +* * +* The Final Cut is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public * +* License along with this program. If not, see * +* . * +***********************************************************************/ + +#include "final/fcolorpalette.h" + +namespace finalcut +{ + +//---------------------------------------------------------------------- +// class FColorPalette +//---------------------------------------------------------------------- + +// constructors and destructor +//---------------------------------------------------------------------- +FColorPalette::FColorPalette (FSetPalette f) + : set_palette{f} +{ } + +//---------------------------------------------------------------------- +FColorPalette::~FColorPalette() // destructor +{ } + + +// protected methods of FColorPalette +//---------------------------------------------------------------------- +void FColorPalette::setPalette (FColor index, int r, int g, int b) +{ + set_palette (index, r, g, b); +} + + +//---------------------------------------------------------------------- +// class default8ColorPalette +//---------------------------------------------------------------------- + +// constructors and destructor +//---------------------------------------------------------------------- +default8ColorPalette::default8ColorPalette (FSetPalette f) + : FColorPalette(f) +{ } + +//---------------------------------------------------------------------- +default8ColorPalette::~default8ColorPalette() +{ } + +// public methods of default8ColorPalette +//---------------------------------------------------------------------- +void default8ColorPalette::setColorPalette() +{ + setPalette (fc::Black, 0x00, 0x00, 0x00); + setPalette (fc::Blue, 0x10, 0x3b, 0x9e); + setPalette (fc::Green, 0x18, 0x78, 0x18); + setPalette (fc::Cyan, 0xa0, 0xb2, 0xb2); + setPalette (fc::Red, 0xb2, 0x18, 0x18); + setPalette (fc::Magenta, 0xb2, 0x18, 0xb2); + setPalette (fc::Brown, 0xe8, 0x87, 0x1f); + setPalette (fc::LightGray, 0xe0, 0xe0, 0xe0); + // The same colors again... + setPalette (fc::DarkGray, 0x00, 0x00, 0x00); + setPalette (fc::LightBlue, 0x10, 0x3b, 0x9e); + setPalette (fc::LightGreen, 0x18, 0x78, 0x18); + setPalette (fc::Cyan, 0xa0, 0xb2, 0xb2); + setPalette (fc::LightRed, 0xb2, 0x18, 0x18); + setPalette (fc::LightMagenta, 0xb2, 0x18, 0xb2); + setPalette (fc::Yellow, 0xe8, 0x87, 0x1f); + setPalette (fc::White, 0xe0, 0xe0, 0xe0); +} + +//---------------------------------------------------------------------- +void default8ColorPalette::resetColorPalette() +{ + set_palette (fc::Black, 0x00, 0x00, 0x00); + set_palette (fc::Blue, 0x00, 0x00, 0xaa); + set_palette (fc::Green, 0x00, 0xaa, 0x00); + set_palette (fc::Cyan, 0x00, 0x55, 0xaa); + set_palette (fc::Red, 0xaa, 0x00, 0x00); + set_palette (fc::Magenta, 0xaa, 0x00, 0xaa); + set_palette (fc::Brown, 0xaa, 0xaa, 0x00); + set_palette (fc::LightGray, 0xaa, 0xaa, 0xaa); + set_palette (fc::DarkGray, 0x55, 0x55, 0x55); + set_palette (fc::LightBlue, 0x55, 0x55, 0xff); + set_palette (fc::LightGreen, 0x55, 0xff, 0x55); + set_palette (fc::LightCyan, 0x55, 0xff, 0xff); + set_palette (fc::LightRed, 0xff, 0x55, 0x55); + set_palette (fc::LightMagenta, 0xff, 0x55, 0xff); + set_palette (fc::Yellow, 0xff, 0xff, 0x55); + set_palette (fc::White, 0xff, 0xff, 0xff); +} + + +//---------------------------------------------------------------------- +// class default16ColorPalette +//---------------------------------------------------------------------- + +// constructors and destructor +//---------------------------------------------------------------------- +default16ColorPalette::default16ColorPalette (FSetPalette f) + : FColorPalette(f) +{ } + +//---------------------------------------------------------------------- +default16ColorPalette::~default16ColorPalette() +{ } + +// public methods of default8ColorPalette +//---------------------------------------------------------------------- +void default16ColorPalette::setColorPalette() +{ + setPalette (fc::Black, 0x00, 0x00, 0x00); + setPalette (fc::Blue, 0x10, 0x3b, 0x9e); + setPalette (fc::Green, 0x18, 0x78, 0x18); + setPalette (fc::Cyan, 0x55, 0x6a, 0xcf); + setPalette (fc::Red, 0xba, 0x1a, 0x1a); + setPalette (fc::Magenta, 0xb2, 0x18, 0xb2); + setPalette (fc::Brown, 0xe8, 0x87, 0x1f); + setPalette (fc::LightGray, 0xbc, 0xbc, 0xbc); + setPalette (fc::DarkGray, 0x50, 0x50, 0x50); + setPalette (fc::LightBlue, 0x80, 0xa4, 0xec); + setPalette (fc::LightGreen, 0x5e, 0xeb, 0x5c); + setPalette (fc::LightCyan, 0x62, 0xbf, 0xf8); + setPalette (fc::LightRed, 0xee, 0x44, 0x44); + setPalette (fc::LightMagenta, 0xe9, 0xad, 0xff); + setPalette (fc::Yellow, 0xfb, 0xe8, 0x67); + setPalette (fc::White, 0xff, 0xff, 0xff); +} + +//---------------------------------------------------------------------- +void default16ColorPalette::resetColorPalette() +{ + set_palette (fc::Black, 0x00, 0x00, 0x00); + set_palette (fc::Blue, 0x00, 0x00, 0xaa); + set_palette (fc::Green, 0x00, 0xaa, 0x00); + set_palette (fc::Cyan, 0x00, 0x55, 0xaa); + set_palette (fc::Red, 0xaa, 0x00, 0x00); + set_palette (fc::Magenta, 0xaa, 0x00, 0xaa); + set_palette (fc::Brown, 0xaa, 0xaa, 0x00); + set_palette (fc::LightGray, 0xaa, 0xaa, 0xaa); + set_palette (fc::DarkGray, 0x55, 0x55, 0x55); + set_palette (fc::LightBlue, 0x55, 0x55, 0xff); + set_palette (fc::LightGreen, 0x55, 0xff, 0x55); + set_palette (fc::LightCyan, 0x55, 0xff, 0xff); + set_palette (fc::LightRed, 0xff, 0x55, 0x55); + set_palette (fc::LightMagenta, 0xff, 0x55, 0xff); + set_palette (fc::Yellow, 0xff, 0xff, 0x55); + set_palette (fc::White, 0xff, 0xff, 0xff); +} + + +} // namespace finalcut + diff --git a/src/fterm.cpp b/src/fterm.cpp index 1a4146f9..25dd888b 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -28,7 +28,6 @@ #include "final/fapplication.h" #include "final/fc.h" #include "final/fcharmap.h" -#include "final/fcolorpalette.h" #include "final/fkey_map.h" #include "final/fkeyboard.h" #include "final/flog.h" @@ -181,6 +180,13 @@ int FTerm::getMaxColor() return FTermcap::max_color; } +//---------------------------------------------------------------------- +FTerm::FColorPalettePtr& FTerm::getColorPaletteTheme() +{ + static FColorPalettePtr* color_theme = new FColorPalettePtr(); + return *color_theme; +} + //---------------------------------------------------------------------- FTermData* FTerm::getFTermData() { @@ -1883,9 +1889,11 @@ void FTerm::redefineColorPalette() saveColorMap(); if ( getMaxColor() >= 16 ) - FColorPalette::set16ColorPalette (FTerm::setPalette); + setColorPaletteTheme(&FTerm::setPalette); else // 8 colors - FColorPalette::set8ColorPalette (FTerm::setPalette); + setColorPaletteTheme(&FTerm::setPalette); + + getColorPaletteTheme()->setColorPalette(); } //---------------------------------------------------------------------- @@ -1895,11 +1903,7 @@ void FTerm::restoreColorPalette() return; // Reset screen settings - if ( getMaxColor() >= 16 ) - FColorPalette::reset16ColorPalette (FTerm::setPalette); - else // 8 colors - FColorPalette::reset8ColorPalette (FTerm::setPalette); - + getColorPaletteTheme()->resetColorPalette(); getFTermXTerminal()->resetColorMap(); resetColorMap(); } @@ -2498,6 +2502,13 @@ void FTerm::finish_encoding() #endif } +//---------------------------------------------------------------------- +void FTerm::destroyColorPaletteTheme() +{ + const FColorPalettePtr* theme = &(getColorPaletteTheme()); + delete theme; +} + //---------------------------------------------------------------------- void FTerm::setSignalHandler() { diff --git a/src/fwidget.cpp b/src/fwidget.cpp index b0218ff5..083ca1a7 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -2001,7 +2001,7 @@ void FWidget::initColorTheme() //---------------------------------------------------------------------- void FWidget::destroyColorTheme() { - FWidgetColorsPtr* theme = &(getColorTheme()); + const FWidgetColorsPtr* theme = &(getColorTheme()); delete theme; } diff --git a/src/include/final/fcolorpalette.h b/src/include/final/fcolorpalette.h index 1f519f40..4830102e 100644 --- a/src/include/final/fcolorpalette.h +++ b/src/include/final/fcolorpalette.h @@ -46,27 +46,30 @@ namespace finalcut // class FColorPalette //---------------------------------------------------------------------- -class FColorPalette final +class FColorPalette { public: + // Typedef + typedef std::function FSetPalette; + // Constructor - FColorPalette() = default; + FColorPalette(FSetPalette); // Destructor - ~FColorPalette(); + virtual ~FColorPalette(); // Accessor - const FString getClassName() const; + virtual const FString getClassName() const; // Methods - template - static void set8ColorPalette (funcT); - template - static void set16ColorPalette (funcT); - template - static void reset8ColorPalette (funcT); - template - static void reset16ColorPalette (funcT); + virtual void setColorPalette() = 0; + virtual void resetColorPalette() = 0; + + protected: + void setPalette (FColor, int, int, int); + + // Data members + FSetPalette set_palette; }; // FColorPalette inline functions @@ -74,85 +77,85 @@ class FColorPalette final inline const FString FColorPalette::getClassName() const { return "FColorPalette"; } -// constructors and destructor -//---------------------------------------------------------------------- -inline FColorPalette::~FColorPalette() // destructor -{ } -// public methods of FColorPalette -//---------------------------------------------------------------------- -template -void FColorPalette::set8ColorPalette (funcT set_palette) -{ - set_palette (fc::Black, 0x00, 0x00, 0x00); - set_palette (fc::Blue, 0x10, 0x3b, 0x9e); - set_palette (fc::Green, 0x18, 0x78, 0x18); - set_palette (fc::Cyan, 0xa0, 0xb2, 0xb2); - set_palette (fc::Red, 0xb2, 0x18, 0x18); - set_palette (fc::Magenta, 0xb2, 0x18, 0xb2); - set_palette (fc::Brown, 0xe8, 0x87, 0x1f); - set_palette (fc::LightGray, 0xe0, 0xe0, 0xe0); - // The same colors again... - set_palette (fc::DarkGray, 0x00, 0x00, 0x00); - set_palette (fc::LightBlue, 0x10, 0x3b, 0x9e); - set_palette (fc::LightGreen, 0x18, 0x78, 0x18); - set_palette (fc::Cyan, 0xa0, 0xb2, 0xb2); - set_palette (fc::LightRed, 0xb2, 0x18, 0x18); - set_palette (fc::LightMagenta, 0xb2, 0x18, 0xb2); - set_palette (fc::Yellow, 0xe8, 0x87, 0x1f); - set_palette (fc::White, 0xe0, 0xe0, 0xe0); -} +/* Inheritance diagram + * ═══════════════════ + * + * ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏ + * ▕ FColorPalette ▏ + * ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏ + * ▲ + * │ + * ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏ + * ▕ default8ColorPalette ▏ + * ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏ + */ //---------------------------------------------------------------------- -template -void FColorPalette::set16ColorPalette (funcT set_palette) +// class default8ColorPalette +//---------------------------------------------------------------------- + +class default8ColorPalette final : public FColorPalette { - set_palette (fc::Black, 0x00, 0x00, 0x00); - set_palette (fc::Blue, 0x10, 0x3b, 0x9e); - set_palette (fc::Green, 0x18, 0x78, 0x18); - set_palette (fc::Cyan, 0x55, 0x6a, 0xcf); - set_palette (fc::Red, 0xba, 0x1a, 0x1a); - set_palette (fc::Magenta, 0xb2, 0x18, 0xb2); - set_palette (fc::Brown, 0xe8, 0x87, 0x1f); - set_palette (fc::LightGray, 0xbc, 0xbc, 0xbc); - set_palette (fc::DarkGray, 0x50, 0x50, 0x50); - set_palette (fc::LightBlue, 0x80, 0xa4, 0xec); - set_palette (fc::LightGreen, 0x5e, 0xeb, 0x5c); - set_palette (fc::LightCyan, 0x62, 0xbf, 0xf8); - set_palette (fc::LightRed, 0xee, 0x44, 0x44); - set_palette (fc::LightMagenta, 0xe9, 0xad, 0xff); - set_palette (fc::Yellow, 0xfb, 0xe8, 0x67); - set_palette (fc::White, 0xff, 0xff, 0xff); -} + public: + // Constructor + default8ColorPalette (FSetPalette); + + // Destructor + ~default8ColorPalette(); + + // Accessor + virtual const FString getClassName() const; + + // Methods + void setColorPalette(); + void resetColorPalette(); +}; + +// default8ColorPalette inline functions +//---------------------------------------------------------------------- +inline const FString default8ColorPalette::getClassName() const +{ return "default8ColorPalette"; } + + +/* Inheritance diagram + * ═══════════════════ + * + * ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏ + * ▕ FColorPalette ▏ + * ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏ + * ▲ + * │ + * ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏ + * ▕ default16ColorPalette ▏ + * ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏ + */ //---------------------------------------------------------------------- -template -void FColorPalette::reset8ColorPalette (funcT set_palette) -{ - reset16ColorPalette(set_palette); -} - +// class default16ColorPalette //---------------------------------------------------------------------- -template -void FColorPalette::reset16ColorPalette (funcT set_palette) + +class default16ColorPalette final : public FColorPalette { - set_palette (fc::Black, 0x00, 0x00, 0x00); - set_palette (fc::Blue, 0x00, 0x00, 0xaa); - set_palette (fc::Green, 0x00, 0xaa, 0x00); - set_palette (fc::Cyan, 0x00, 0x55, 0xaa); - set_palette (fc::Red, 0xaa, 0x00, 0x00); - set_palette (fc::Magenta, 0xaa, 0x00, 0xaa); - set_palette (fc::Brown, 0xaa, 0xaa, 0x00); - set_palette (fc::LightGray, 0xaa, 0xaa, 0xaa); - set_palette (fc::DarkGray, 0x55, 0x55, 0x55); - set_palette (fc::LightBlue, 0x55, 0x55, 0xff); - set_palette (fc::LightGreen, 0x55, 0xff, 0x55); - set_palette (fc::LightCyan, 0x55, 0xff, 0xff); - set_palette (fc::LightRed, 0xff, 0x55, 0x55); - set_palette (fc::LightMagenta, 0xff, 0x55, 0xff); - set_palette (fc::Yellow, 0xff, 0xff, 0x55); - set_palette (fc::White, 0xff, 0xff, 0xff); -} + public: + // Constructor + default16ColorPalette (FSetPalette); + + // Destructor + ~default16ColorPalette(); + + // Accessor + virtual const FString getClassName() const; + + // Methods + void setColorPalette(); + void resetColorPalette(); +}; + +// default16ColorPalette inline functions +//---------------------------------------------------------------------- +inline const FString default16ColorPalette::getClassName() const +{ return "default16ColorPalette"; } } // namespace finalcut diff --git a/src/include/final/fterm.h b/src/include/final/fterm.h index 31292bc8..955b9af1 100644 --- a/src/include/final/fterm.h +++ b/src/include/final/fterm.h @@ -112,12 +112,14 @@ #include #include #include +#include #include #include #include #include #include "final/fc.h" +#include "final/fcolorpalette.h" #include "final/fstring.h" #include "final/fsystem.h" @@ -125,6 +127,7 @@ namespace finalcut { // class forward declaration +class FColorPalette; class FKeyboard; class FMouseControl; class FOptiAttr; @@ -159,6 +162,7 @@ class FTerm final public: // Typedef typedef std::function defaultPutChar; + typedef std::shared_ptr FColorPalettePtr; // Constructor explicit FTerm (bool = false); @@ -173,215 +177,219 @@ class FTerm final FTerm& operator = (const FTerm&) = delete; // Accessors - static const FString getClassName(); - static std::size_t getLineNumber(); - static std::size_t getColumnNumber(); - static const FString getKeyName (FKey); - static int getTTYFileDescriptor(); - static const char* getTermType(); - static const char* getTermFileName(); - static int getTabstop(); - static int getMaxColor(); - charSubstitution& getCharSubstitutionMap(); + static const FString getClassName(); + static std::size_t getLineNumber(); + static std::size_t getColumnNumber(); + static const FString getKeyName (FKey); + static int getTTYFileDescriptor(); + static const char* getTermType(); + static const char* getTermFileName(); + static int getTabstop(); + static int getMaxColor(); + static FColorPalettePtr& getColorPaletteTheme(); + charSubstitution& getCharSubstitutionMap(); - static FTermData* getFTermData(); - static FSystem* getFSystem(); - static FOptiMove* getFOptiMove(); - static FOptiAttr* getFOptiAttr(); - static FTermDetection* getFTermDetection(); - static FTermXTerminal* getFTermXTerminal(); - static FKeyboard* getFKeyboard(); - static FMouseControl* getFMouseControl(); + static FTermData* getFTermData(); + static FSystem* getFSystem(); + static FOptiMove* getFOptiMove(); + static FOptiAttr* getFOptiAttr(); + static FTermDetection* getFTermDetection(); + static FTermXTerminal* getFTermXTerminal(); + static FKeyboard* getFKeyboard(); + static FMouseControl* getFMouseControl(); #if defined(UNIT_TEST) - static FTermLinux* getFTermLinux(); - static FTermFreeBSD* getFTermFreeBSD(); - static FTermOpenBSD* getFTermOpenBSD(); + static FTermLinux* getFTermLinux(); + static FTermFreeBSD* getFTermFreeBSD(); + static FTermOpenBSD* getFTermOpenBSD(); #elif defined(__linux__) - static FTermLinux* getFTermLinux(); + static FTermLinux* getFTermLinux(); #elif defined(__FreeBSD__) || defined(__DragonFly__) - static FTermFreeBSD* getFTermFreeBSD(); + static FTermFreeBSD* getFTermFreeBSD(); #elif defined(__NetBSD__) || defined(__OpenBSD__) - static FTermOpenBSD* getFTermOpenBSD(); + static FTermOpenBSD* getFTermOpenBSD(); #endif #if DEBUG - static FTermDebugData& getFTermDebugData(); + static FTermDebugData& getFTermDebugData(); #endif // Inquiries - static bool isNormal (const FChar* const&); - static bool isRaw(); - static bool hasUTF8(); - static bool hasVT100(); - static bool hasASCII(); - static bool isMonochron(); - static bool isXTerminal(); - static bool isAnsiTerminal(); - static bool isRxvtTerminal(); - static bool isUrxvtTerminal(); - static bool isMltermTerminal(); - static bool isPuttyTerminal(); - static bool isKdeTerminal(); - static bool isGnomeTerminal(); - static bool isKtermTerminal(); - static bool isTeraTerm(); - static bool isSunTerminal(); - static bool isCygwinTerminal(); - static bool isMinttyTerm(); - static bool isLinuxTerm(); - static bool isFreeBSDTerm(); - static bool isNetBSDTerm(); - static bool isOpenBSDTerm(); - static bool isScreenTerm(); - static bool isTmuxTerm(); - static bool isNewFont(); - static bool isCursorHideable(); - static bool hasChangedTermSize(); - static bool hasShadowCharacter(); - static bool hasHalfBlockCharacter(); - static bool hasAlternateScreen(); - static bool canChangeColorPalette(); + static bool isNormal (const FChar* const&); + static bool isRaw(); + static bool hasUTF8(); + static bool hasVT100(); + static bool hasASCII(); + static bool isMonochron(); + static bool isXTerminal(); + static bool isAnsiTerminal(); + static bool isRxvtTerminal(); + static bool isUrxvtTerminal(); + static bool isMltermTerminal(); + static bool isPuttyTerminal(); + static bool isKdeTerminal(); + static bool isGnomeTerminal(); + static bool isKtermTerminal(); + static bool isTeraTerm(); + static bool isSunTerminal(); + static bool isCygwinTerminal(); + static bool isMinttyTerm(); + static bool isLinuxTerm(); + static bool isFreeBSDTerm(); + static bool isNetBSDTerm(); + static bool isOpenBSDTerm(); + static bool isScreenTerm(); + static bool isTmuxTerm(); + static bool isNewFont(); + static bool isCursorHideable(); + static bool hasChangedTermSize(); + static bool hasShadowCharacter(); + static bool hasHalfBlockCharacter(); + static bool hasAlternateScreen(); + static bool canChangeColorPalette(); // Mutators - static void setFSystem (FSystem*); - static void setTermType (const char[]); - static void setInsertCursor (bool); - static void setInsertCursor(); - static void unsetInsertCursor(); - static void redefineDefaultColors (bool); - static void setDblclickInterval (const uInt64); - static bool setUTF8 (bool); - static bool setUTF8(); - static bool unsetUTF8(); + static void setFSystem (FSystem*); + static void setTermType (const char[]); + static void setInsertCursor (bool); + static void setInsertCursor(); + static void unsetInsertCursor(); + static void redefineDefaultColors (bool); + static void setDblclickInterval (const uInt64); + static bool setUTF8 (bool); + static bool setUTF8(); + static bool unsetUTF8(); // Methods - static bool setVGAFont(); - static bool setNewFont(); - static bool setOldFont(); - static int openConsole(); - static int closeConsole(); - static const char* moveCursorString (int, int, int, int); - static const char* cursorsVisibilityString (bool); - static void detectTermSize(); - static void setTermSize (const FSize&); - static void setTermTitle (const FString&); - static void setKDECursor (fc::kdeKonsoleCursorShape); - static void saveColorMap(); - static void resetColorMap(); - static void setPalette (FColor, int, int, int); - static void setBeep (int, int); - static void resetBeep(); - static void beep(); + static bool setVGAFont(); + static bool setNewFont(); + static bool setOldFont(); + static int openConsole(); + static int closeConsole(); + static const char* moveCursorString (int, int, int, int); + static const char* cursorsVisibilityString (bool); + static void detectTermSize(); + static void setTermSize (const FSize&); + static void setTermTitle (const FString&); + static void setKDECursor (fc::kdeKonsoleCursorShape); + static void saveColorMap(); + static void resetColorMap(); + static void setPalette (FColor, int, int, int); + template + static void setColorPaletteTheme (FColorPalette::FSetPalette); + static void setBeep (int, int); + static void resetBeep(); + static void beep(); - static void setEncoding (fc::encoding); - static fc::encoding getEncoding(); - static std::string getEncodingString(); - static bool charEncodable (wchar_t); - static wchar_t charEncode (wchar_t); - static wchar_t charEncode (wchar_t, fc::encoding); + static void setEncoding (fc::encoding); + static fc::encoding getEncoding(); + static std::string getEncodingString(); + static bool charEncodable (wchar_t); + static wchar_t charEncode (wchar_t); + static wchar_t charEncode (wchar_t, fc::encoding); - static bool scrollTermForward(); - static bool scrollTermReverse(); + static bool scrollTermForward(); + static bool scrollTermReverse(); - static defaultPutChar& putchar(); // function pointer + static defaultPutChar& putchar(); // function pointer template - static void putstringf (const char[], Args&&...); - static void putstring (const char[], int = 1); - static int putchar_ASCII (int); - static int putchar_UTF8 (int); + static void putstringf (const char[], Args&&...); + static void putstring (const char[], int = 1); + static int putchar_ASCII (int); + static int putchar_UTF8 (int); - static void initScreenSettings(); - static const char* changeAttribute (FChar*&, FChar*&); - static void changeTermSizeFinished(); - static void exitWithMessage (const FString&) + static void initScreenSettings(); + static const char* changeAttribute (FChar*&, FChar*&); + static void changeTermSizeFinished(); + static void exitWithMessage (const FString&) #if defined(__clang__) || defined(__GNUC__) __attribute__((noreturn)) #endif - ; + ; private: // Methods - static FStartOptions& getStartOptions(); - static void init_global_values (bool); - static void init_terminal_device_path(); - static void oscPrefix(); - static void oscPostfix(); - static void init_alt_charset(); - static void init_pc_charset(); - static void init_cygwin_charmap(); - static void init_teraterm_charmap(); - static void init_fixed_max_color(); - static void init_keyboard(); - static void init_termcap(); - static void init_quirks(); - static void init_optiMove(); - static void init_optiAttr(); - static void init_font(); - static void init_locale(); - static void init_encoding(); - static void init_encoding_set(); - static void init_term_encoding(); - static void init_individual_term_encoding(); - static void init_force_vt100_encoding(); - static void init_utf8_without_alt_charset(); - static void init_tab_quirks(); - static void init_captureFontAndTitle(); - static bool hasNoFontSettingOption(); - static void redefineColorPalette(); - static void restoreColorPalette(); - static void setInsertCursorStyle(); - static void setOverwriteCursorStyle(); - static const char* enableCursorString(); - static const char* disableCursorString(); - static void enableMouse(); - static void disableMouse(); - static void enableApplicationEscKey(); - static void disableApplicationEscKey(); - static void enableKeypad(); - static void disableKeypad(); - static void enableAlternateCharset(); - static void useAlternateScreenBuffer(); - static void useNormalScreenBuffer(); - void allocationValues(); - void deallocationValues(); - void init (bool); - bool init_terminal(); - void initOSspecifics(); - void initTermspecifics(); - void initBaudRate(); - void finish(); - void finishOSspecifics1(); - void finish_encoding(); - static void setSignalHandler(); - static void resetSignalHandler(); - static void signal_handler (int); + static FStartOptions& getStartOptions(); + static void init_global_values (bool); + static void init_terminal_device_path(); + static void oscPrefix(); + static void oscPostfix(); + static void init_alt_charset(); + static void init_pc_charset(); + static void init_cygwin_charmap(); + static void init_teraterm_charmap(); + static void init_fixed_max_color(); + static void init_keyboard(); + static void init_termcap(); + static void init_quirks(); + static void init_optiMove(); + static void init_optiAttr(); + static void init_font(); + static void init_locale(); + static void init_encoding(); + static void init_encoding_set(); + static void init_term_encoding(); + static void init_individual_term_encoding(); + static void init_force_vt100_encoding(); + static void init_utf8_without_alt_charset(); + static void init_tab_quirks(); + static void init_captureFontAndTitle(); + static bool hasNoFontSettingOption(); + static void redefineColorPalette(); + static void restoreColorPalette(); + static void setInsertCursorStyle(); + static void setOverwriteCursorStyle(); + static const char* enableCursorString(); + static const char* disableCursorString(); + static void enableMouse(); + static void disableMouse(); + static void enableApplicationEscKey(); + static void disableApplicationEscKey(); + static void enableKeypad(); + static void disableKeypad(); + static void enableAlternateCharset(); + static void useAlternateScreenBuffer(); + static void useNormalScreenBuffer(); + void allocationValues(); + void deallocationValues(); + void init (bool); + bool init_terminal(); + void initOSspecifics(); + void initTermspecifics(); + void initBaudRate(); + void finish(); + void finishOSspecifics1(); + void finish_encoding(); + void destroyColorPaletteTheme(); + static void setSignalHandler(); + static void resetSignalHandler(); + static void signal_handler (int); // Data members - static FTermData* data; - static FSystem* fsys; - static FOptiMove* opti_move; - static FOptiAttr* opti_attr; - static FTermDetection* term_detection; - static FTermXTerminal* xterm; - static FKeyboard* keyboard; - static FMouseControl* mouse; + static FTermData* data; + static FSystem* fsys; + static FOptiMove* opti_move; + static FOptiAttr* opti_attr; + static FTermDetection* term_detection; + static FTermXTerminal* xterm; + static FKeyboard* keyboard; + static FMouseControl* mouse; #if defined(UNIT_TEST) #undef linux - static FTermLinux* linux; - static FTermFreeBSD* freebsd; - static FTermOpenBSD* openbsd; + static FTermLinux* linux; + static FTermFreeBSD* freebsd; + static FTermOpenBSD* openbsd; #elif defined(__linux__) #undef linux - static FTermLinux* linux; + static FTermLinux* linux; #elif defined(__FreeBSD__) || defined(__DragonFly__) - static FTermFreeBSD* freebsd; + static FTermFreeBSD* freebsd; #elif defined(__NetBSD__) || defined(__OpenBSD__) - static FTermOpenBSD* openbsd; + static FTermOpenBSD* openbsd; #endif #if DEBUG - static FTermDebugData* debug_data; + static FTermDebugData* debug_data; #endif }; @@ -430,6 +438,13 @@ inline bool FTerm::setUTF8() inline bool FTerm::unsetUTF8() { return setUTF8(false); } +//---------------------------------------------------------------------- +template +inline void FTerm::setColorPaletteTheme (FColorPalette::FSetPalette f) +{ + getColorPaletteTheme() = std::make_shared(f); +} + //---------------------------------------------------------------------- template inline void FTerm::putstringf (const char format[], Args&&... args) diff --git a/src/include/final/fwidgetcolors.h b/src/include/final/fwidgetcolors.h index 65372621..2777cd99 100644 --- a/src/include/final/fwidgetcolors.h +++ b/src/include/final/fwidgetcolors.h @@ -146,6 +146,19 @@ class FWidgetColors }; +/* Inheritance diagram + * ═══════════════════ + * + * ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏ + * ▕ FWidgetColors ▏ + * ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏ + * ▲ + * │ + * ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏ + * ▕ default8ColorTheme ▏ + * ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏ + */ + //---------------------------------------------------------------------- // class default8ColorTheme //---------------------------------------------------------------------- @@ -157,13 +170,26 @@ class default8ColorTheme final : public FWidgetColors default8ColorTheme(); // Destructor - virtual ~default8ColorTheme() override; + ~default8ColorTheme() override; // Method void setColorTheme() override; }; +/* Inheritance diagram + * ═══════════════════ + * + * ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏ + * ▕ FWidgetColors ▏ + * ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏ + * ▲ + * │ + * ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏ + * ▕ default16ColorTheme ▏ + * ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏ + */ + //---------------------------------------------------------------------- // class default16ColorTheme //---------------------------------------------------------------------- @@ -175,7 +201,7 @@ class default16ColorTheme final : public FWidgetColors default16ColorTheme(); // Destructor - virtual ~default16ColorTheme() override; + ~default16ColorTheme() override; // Method void setColorTheme() override;