2018-05-20 15:15:42 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ftermxterminal.h - Contains all xterm-specific terminal functions *
|
|
|
|
* *
|
|
|
|
* This file is part of the Final Cut widget toolkit *
|
|
|
|
* *
|
2019-01-04 02:18:54 +01:00
|
|
|
* Copyright 2018-2019 Markus Gans *
|
2018-05-20 15:15:42 +02:00
|
|
|
* *
|
|
|
|
* 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 *
|
|
|
|
* <http://www.gnu.org/licenses/>. *
|
|
|
|
***********************************************************************/
|
|
|
|
|
|
|
|
/* Standalone class
|
|
|
|
* ════════════════
|
|
|
|
*
|
|
|
|
* ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏
|
|
|
|
* ▕ FTermXTerminal ▏
|
|
|
|
* ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FTERMXTERMINAL_H
|
|
|
|
#define FTERMXTERMINAL_H
|
|
|
|
|
|
|
|
#if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT)
|
|
|
|
#error "Only <final/final.h> can be included directly."
|
|
|
|
#endif
|
|
|
|
|
2018-09-20 23:59:01 +02:00
|
|
|
namespace finalcut
|
|
|
|
{
|
2018-05-20 15:15:42 +02:00
|
|
|
|
2019-07-21 23:31:21 +02:00
|
|
|
// class forward declaration
|
|
|
|
class FString;
|
|
|
|
class FSystem;
|
|
|
|
class FTermDetection;
|
|
|
|
|
2018-05-20 15:15:42 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FTermXTerminal
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2019-01-04 02:18:54 +01:00
|
|
|
class FTermXTerminal final
|
2018-05-20 15:15:42 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
// Constructors
|
|
|
|
FTermXTerminal();
|
|
|
|
|
2019-10-08 04:37:19 +02:00
|
|
|
// Disable copy constructor
|
|
|
|
FTermXTerminal (const FTermXTerminal&) = delete;
|
|
|
|
|
2018-05-20 15:15:42 +02:00
|
|
|
// Destructor
|
2018-09-24 04:02:35 +02:00
|
|
|
virtual ~FTermXTerminal();
|
2018-05-20 15:15:42 +02:00
|
|
|
|
2019-10-08 04:37:19 +02:00
|
|
|
// Disable assignment operator (=)
|
|
|
|
FTermXTerminal& operator = (const FTermXTerminal&) = delete;
|
|
|
|
|
2018-05-20 15:15:42 +02:00
|
|
|
// Mutators
|
2019-10-05 23:20:07 +02:00
|
|
|
void redefineDefaultColors (bool);
|
|
|
|
void setCursorStyle (fc::xtermCursorStyle);
|
|
|
|
void setFont (const FString&);
|
|
|
|
void setTitle (const FString&);
|
|
|
|
void setTermSize (const FSize&);
|
|
|
|
void setForeground (const FString&);
|
|
|
|
void setBackground (const FString&);
|
|
|
|
void setCursorColor (const FString&);
|
|
|
|
void setMouseForeground (const FString&);
|
|
|
|
void setMouseBackground (const FString&);
|
|
|
|
void setHighlightBackground (const FString&);
|
2018-05-20 15:15:42 +02:00
|
|
|
static void setMouseSupport (bool);
|
|
|
|
static void setMouseSupport();
|
|
|
|
static void unsetMouseSupport();
|
2019-10-05 23:20:07 +02:00
|
|
|
void metaSendsESC (bool);
|
2018-05-20 15:15:42 +02:00
|
|
|
|
|
|
|
// Accessors
|
2019-10-05 23:20:07 +02:00
|
|
|
const FString getClassName() const;
|
|
|
|
fc::xtermCursorStyle getCursorStyle();
|
|
|
|
const FString getFont();
|
|
|
|
const FString getTitle();
|
|
|
|
const FString getForeground();
|
|
|
|
const FString getBackground();
|
|
|
|
const FString getCursorColor();
|
|
|
|
const FString getMouseForeground();
|
|
|
|
const FString getMouseBackground();
|
|
|
|
const FString getHighlightBackground();
|
2018-05-20 15:15:42 +02:00
|
|
|
|
|
|
|
// Inquiries
|
2019-10-05 23:20:07 +02:00
|
|
|
bool hasFont();
|
|
|
|
bool hasTitle();
|
2018-05-20 15:15:42 +02:00
|
|
|
|
|
|
|
// Methods
|
2019-10-05 23:20:07 +02:00
|
|
|
void init();
|
|
|
|
void setDefaults();
|
|
|
|
void resetColorMap();
|
|
|
|
void resetForeground();
|
|
|
|
void resetBackground();
|
|
|
|
void resetCursorColor();
|
|
|
|
void resetMouseForeground();
|
|
|
|
void resetMouseBackground();
|
|
|
|
void resetHighlightBackground();
|
|
|
|
void resetDefaults();
|
|
|
|
void captureFontAndTitle();
|
2018-05-20 15:15:42 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Methods
|
2019-10-05 23:20:07 +02:00
|
|
|
void setXTermCursorStyle();
|
|
|
|
void setXTermFont();
|
|
|
|
void setXTermTitle();
|
|
|
|
void setXTermSize();
|
|
|
|
void setXTermForeground();
|
|
|
|
void setXTermBackground();
|
|
|
|
void setXTermCursorColor();
|
|
|
|
void setXTermMouseForeground();
|
|
|
|
void setXTermMouseBackground();
|
|
|
|
void setXTermHighlightBackground();
|
|
|
|
void setXTerm8ColorDefaults();
|
|
|
|
void setXTerm16ColorDefaults();
|
|
|
|
void setXTermDefaultsMouseCursor();
|
|
|
|
bool canSetXTermBackground();
|
|
|
|
void resetXTermColorMap();
|
|
|
|
void resetXTermForeground();
|
|
|
|
void resetXTermBackground();
|
|
|
|
void resetXTermCursorColor();
|
|
|
|
void resetXTermMouseForeground();
|
|
|
|
void resetXTermMouseBackground();
|
|
|
|
void resetXTermHighlightBackground();
|
|
|
|
bool canResetColor();
|
|
|
|
void oscPrefix();
|
|
|
|
void oscPostfix();
|
|
|
|
const FString captureXTermFont();
|
|
|
|
const FString captureXTermTitle();
|
2018-05-20 15:15:42 +02:00
|
|
|
static void enableXTermMouse();
|
|
|
|
static void disableXTermMouse();
|
2019-10-05 23:20:07 +02:00
|
|
|
void enableXTermMetaSendsESC();
|
|
|
|
void disableXTermMetaSendsESC();
|
2018-05-20 15:15:42 +02:00
|
|
|
|
2019-09-04 23:57:31 +02:00
|
|
|
// Data members
|
2019-10-05 23:20:07 +02:00
|
|
|
static bool mouse_support;
|
|
|
|
bool meta_sends_esc{false};
|
|
|
|
bool xterm_default_colors{false};
|
|
|
|
std::size_t term_width{80};
|
|
|
|
std::size_t term_height{24};
|
|
|
|
FString xterm_font{};
|
|
|
|
FString xterm_title{};
|
|
|
|
FString foreground_color{};
|
|
|
|
FString background_color{};
|
|
|
|
FString cursor_color{};
|
|
|
|
FString mouse_foreground_color{};
|
|
|
|
FString mouse_background_color{};
|
|
|
|
FString highlight_background_color{};
|
|
|
|
static FSystem* fsystem;
|
|
|
|
FTermDetection* term_detection{nullptr};
|
|
|
|
fc::xtermCursorStyle cursor_style{fc::unknown_cursor_style};
|
2018-05-20 15:15:42 +02:00
|
|
|
};
|
2019-09-08 02:04:24 +02:00
|
|
|
|
2018-05-20 15:15:42 +02:00
|
|
|
|
|
|
|
// FTermXTerminal inline functions
|
2018-08-09 00:04:00 +02:00
|
|
|
//----------------------------------------------------------------------
|
2019-10-05 23:20:07 +02:00
|
|
|
inline const FString FTermXTerminal::getClassName() const
|
2018-08-09 00:04:00 +02:00
|
|
|
{ return "FTermXTerminal"; }
|
|
|
|
|
2018-05-20 15:15:42 +02:00
|
|
|
//----------------------------------------------------------------------
|
2018-12-22 23:50:10 +01:00
|
|
|
inline void FTermXTerminal::redefineDefaultColors (bool enable)
|
|
|
|
{ xterm_default_colors = enable; }
|
2018-05-20 15:15:42 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline fc::xtermCursorStyle FTermXTerminal::getCursorStyle()
|
|
|
|
{ return cursor_style; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2019-10-01 23:14:00 +02:00
|
|
|
inline const FString FTermXTerminal::getFont()
|
2018-05-20 15:15:42 +02:00
|
|
|
{ return xterm_font; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2019-10-01 23:14:00 +02:00
|
|
|
inline const FString FTermXTerminal::getTitle()
|
2018-05-20 15:15:42 +02:00
|
|
|
{ return xterm_title; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2019-10-01 23:14:00 +02:00
|
|
|
inline const FString FTermXTerminal::getForeground()
|
2018-05-20 15:15:42 +02:00
|
|
|
{ return foreground_color; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2019-10-01 23:14:00 +02:00
|
|
|
inline const FString FTermXTerminal::getBackground()
|
2018-05-20 15:15:42 +02:00
|
|
|
{ return background_color; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2019-10-01 23:14:00 +02:00
|
|
|
inline const FString FTermXTerminal::getCursorColor()
|
2018-05-20 15:15:42 +02:00
|
|
|
{ return cursor_color; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2019-10-01 23:14:00 +02:00
|
|
|
inline const FString FTermXTerminal::getMouseForeground()
|
2018-05-20 15:15:42 +02:00
|
|
|
{ return mouse_foreground_color; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2019-10-01 23:14:00 +02:00
|
|
|
inline const FString FTermXTerminal::getMouseBackground()
|
2018-05-20 15:15:42 +02:00
|
|
|
{ return mouse_background_color; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2019-10-01 23:14:00 +02:00
|
|
|
inline const FString FTermXTerminal::getHighlightBackground()
|
2018-05-20 15:15:42 +02:00
|
|
|
{ return highlight_background_color; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTermXTerminal::hasFont()
|
2019-10-01 23:14:00 +02:00
|
|
|
{ return bool(xterm_font.getLength() > 2); }
|
2018-05-20 15:15:42 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FTermXTerminal::hasTitle()
|
2019-10-01 23:14:00 +02:00
|
|
|
{ return bool(xterm_title.getLength() > 0); }
|
2018-05-20 15:15:42 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FTermXTerminal::setMouseSupport()
|
|
|
|
{ setMouseSupport (true); }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FTermXTerminal::unsetMouseSupport()
|
|
|
|
{ setMouseSupport (false); }
|
|
|
|
|
2018-09-20 23:59:01 +02:00
|
|
|
} // namespace finalcut
|
2018-05-20 15:15:42 +02:00
|
|
|
|
|
|
|
#endif // FTERMXTERMINAL_H
|