Methods outsourcing from FTerm to FTermXTerminal

This commit is contained in:
Markus Gans 2018-05-20 15:15:42 +02:00
parent a41f8a611c
commit b05873babb
23 changed files with 1871 additions and 904 deletions

View File

@ -1,3 +1,6 @@
2017-05-20 Markus Gans <guru.mail@muenster.de>
* Methods outsourcing from FTerm to FTermXTerminal
2017-05-06 Markus Gans <guru.mail@muenster.de> 2017-05-06 Markus Gans <guru.mail@muenster.de>
* Some protected data members in FTerm moved to private * Some protected data members in FTerm moved to private

View File

@ -123,25 +123,25 @@ Class digramm
│ ┌─────────────┐ │ ┌─────────────┐
├────┤ FMouseEvent │ ├────┤ FMouseEvent │
│ └─────────────┘ │ └─────────────┘
│ ┌─────────────┐ 1┌────────────────┐ │ ┌─────────────┐
├────┤ FWheelEvent │ ┌-----------┤ FTermDetection │ ├────┤ FWheelEvent │
│ └─────────────┘ : └────────────────┘ │ └─────────────┘
│ ┌─────────────┐ : 1┌────────────────┐ │ ┌─────────────┐
├────┤ FFocusEvent │ ┌-----------┤ FTermcapQuirks │ ├────┤ FFocusEvent │
│ └─────────────┘ : └────────────────┘ │ └─────────────┘
│ ┌─────────────┐ : 1┌──────────┐ │ ┌─────────────┐
┌────────┐ ├────┤ FAccelEvent │ ┌-----------┤ FTermcap │ ┌────────┐ ├────┤ FAccelEvent │
│ FEvent │◄─┤ └─────────────┘ : └──────────┘ │ FEvent │◄─┤ └─────────────┘
└───┬────┘ │ ┌──────────────┐ : 1┌──────────┐ └───┬────┘ │ ┌──────────────┐
:1 ├────┤ FResizeEvent │ ┌-----------┤ FTermios │ :1 ├────┤ FResizeEvent │
: │ └──────────────┘ : └──────────┘ : │ └──────────────┘
: │ ┌────────────┐ : 1┌────────────────┐ : │ ┌────────────┐
: ├────┤ FShowEvent │ ┌-----------┤ FTermXTerminal │ : ├────┤ FShowEvent │
: │ └────────────┘ : └────────────────┘ : │ └────────────┘
: │ ┌────────────┐ : 1┌───────────────┐ : │ ┌────────────┐
: ├────┤ FHideEvent │ ┌-----------┤ FColorPalette │ : ├────┤ FHideEvent │
: │ └────────────┘ : └───────────────┘ : │ └────────────┘
1┌───────────┐ : │ ┌─────────────┐ : 1┌───────────┐ : │ ┌─────────────┐
┌-----------┤ FOptiMove │ : ├────┤ FCloseEvent │ ┌-----------┤ FOptiMove │ : ├────┤ FCloseEvent │
: └───────────┘ : │ └─────────────┘ : └───────────┘ : │ └─────────────┘
: 1┌───────────┐ : │ ┌─────────────┐ : 1┌───────────┐ : │ ┌─────────────┐

View File

@ -8,25 +8,25 @@
│ ┌─────────────┐ │ ┌─────────────┐
├────┤ FMouseEvent │ ├────┤ FMouseEvent │
│ └─────────────┘ │ └─────────────┘
│ ┌─────────────┐ 1┌────────────────┐ │ ┌─────────────┐
├────┤ FWheelEvent │ ┌-----------┤ FTermDetection │ ├────┤ FWheelEvent │
│ └─────────────┘ : └────────────────┘ │ └─────────────┘
│ ┌─────────────┐ : 1┌────────────────┐ │ ┌─────────────┐
├────┤ FFocusEvent │ ┌-----------┤ FTermcapQuirks │ ├────┤ FFocusEvent │
│ └─────────────┘ : └────────────────┘ │ └─────────────┘
│ ┌─────────────┐ : 1┌──────────┐ │ ┌─────────────┐
┌────────┐ ├────┤ FAccelEvent │ ┌-----------┤ FTermcap │ ┌────────┐ ├────┤ FAccelEvent │
│ FEvent │◄─┤ └─────────────┘ : └──────────┘ │ FEvent │◄─┤ └─────────────┘
└───┬────┘ │ ┌──────────────┐ : 1┌──────────┐ └───┬────┘ │ ┌──────────────┐
:1 ├────┤ FResizeEvent │ ┌-----------┤ FTermios │ :1 ├────┤ FResizeEvent │
: │ └──────────────┘ : └──────────┘ : │ └──────────────┘
: │ ┌────────────┐ : 1┌────────────────┐ : │ ┌────────────┐
: ├────┤ FShowEvent │ ┌-----------┤ FTermXTerminal │ : ├────┤ FShowEvent │
: │ └────────────┘ : └────────────────┘ : │ └────────────┘
: │ ┌────────────┐ : 1┌───────────────┐ : │ ┌────────────┐
: ├────┤ FHideEvent │ ┌-----------┤ FColorPalette │ : ├────┤ FHideEvent │
: │ └────────────┘ : └───────────────┘ : │ └────────────┘
1┌───────────┐ : │ ┌─────────────┐ : 1┌───────────┐ : │ ┌─────────────┐
┌-----------┤ FOptiMove │ : ├────┤ FCloseEvent │ ┌-----------┤ FOptiMove │ : ├────┤ FCloseEvent │
: └───────────┘ : │ └─────────────┘ : └───────────┘ : │ └─────────────┘
: 1┌───────────┐ : │ ┌─────────────┐ : 1┌───────────┐ : │ ┌─────────────┐

51
doc/class_template.cpp Normal file
View File

@ -0,0 +1,51 @@
/***********************************************************************
* fclassname.cpp - [brief description] *
* *
* This file is part of the Final Cut widget toolkit *
* *
* Copyright [year] [Maintainer] *
* *
* 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/>. *
***********************************************************************/
#include "final/fclassname.h"
// static class attributes
//----------------------------------------------------------------------
// class fClassName
//----------------------------------------------------------------------
// constructors and destructor
//----------------------------------------------------------------------
fClassName::fClassName()
{ }
//----------------------------------------------------------------------
fClassName::~fClassName() // destructor
{ }
// public methods of fClassName
//----------------------------------------------------------------------
// protected methods of fClassName
//----------------------------------------------------------------------
// private methods of fClassName
//----------------------------------------------------------------------

128
doc/class_template.h Normal file
View File

@ -0,0 +1,128 @@
/***********************************************************************
* fclassname.h - [brief description] *
* *
* This file is part of the Final Cut widget toolkit *
* *
* Copyright [year] [Maintainer] *
* *
* 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
*
*
*
* fClassName
*
*/
#ifndef FCLASSNAME_H
#define FCLASSNAME_H
#if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT)
#error "Only <final/final.h> can be included directly."
#endif
//#include ...
//----------------------------------------------------------------------
// class fClassName
//----------------------------------------------------------------------
#pragma pack(push)
#pragma pack(1)
class fClassName
{
public:
// Using-declaration
// Typedefs and Enumerations
// Constants
// Constructors
fClassName();
// Destructor
~fClassName();
// Overloaded operators
// Accessors
// Inquiries
// Methods
// Event handlers
// Callback methods
// Data Members
protected:
// Typedefs and Enumerations
// Constants
// Accessors
// Inquiries
// Methods
// Event handlers
// Callback methods
// Data Members
private:
// Typedefs and Enumerations
// Constants
// Disable copy constructor
fClassName (const fClassName&);
// Disable assignment operator (=)
fClassName& operator = (const fClassName&);
// Accessors
// Inquiries
// Methods
// Event handlers
// Callback methods
// Data Members
// Friend class
};
#pragma pack(pop)
// fClassName inline functions
//----------------------------------------------------------------------
#endif // FCLASSNAME_H

View File

@ -39,6 +39,7 @@ class ProgressDialog : public FDialog
public: public:
// Constructor // Constructor
explicit ProgressDialog (FWidget* = 0); explicit ProgressDialog (FWidget* = 0);
// Destructor // Destructor
~ProgressDialog(); ~ProgressDialog();
@ -194,6 +195,7 @@ class TextWindow : public FDialog
public: public:
// Constructor // Constructor
explicit TextWindow (FWidget* = 0); explicit TextWindow (FWidget* = 0);
// Destructor // Destructor
~TextWindow(); ~TextWindow();
@ -205,6 +207,7 @@ class TextWindow : public FDialog
// Disable assignment operator (=) // Disable assignment operator (=)
TextWindow& operator = (const TextWindow&); TextWindow& operator = (const TextWindow&);
// Method
void adjustSize(); void adjustSize();
// Data Members // Data Members
@ -969,8 +972,8 @@ void MyDialog::cb_setTitlebar (FWidget* widget, data_ptr)
FLineEdit* lineedit = static_cast<FLineEdit*>(widget); FLineEdit* lineedit = static_cast<FLineEdit*>(widget);
FString title; FString title;
*lineedit >> title; *lineedit >> title;
setXTermTitle(title);; setTermTitle (title);
setText(title); setText (title);
redraw(); redraw();
} }
@ -1072,8 +1075,8 @@ int main (int argc, char* argv[])
// Create the application object app // Create the application object app
FApplication app(argc, argv); FApplication app(argc, argv);
app.setXTermDefaultColors(true); app.redefineDefaultColors(true);
app.setXTermTitle (title); app.setTermTitle (title);
// Force vt100 encoding // Force vt100 encoding
//app.setEncoding("VT100"); //app.setEncoding("VT100");

45
fonts/README.txt Normal file
View File

@ -0,0 +1,45 @@
How can I use the new graphical font under the Linux text console?
------------------------------------------------------------------
Simply start your program with the parameter `--newfont`.
How can I use the new graphical font under X11?
-----------------------------------------------
The use of the new graphical font under X11 is only possible with
the terminal emulators xterm or urxvt, because only these terminal
emulators can change the font by using an escape sequence.
For an xterm, the "Allow Font Ops" option must be set.
Install the gzip compressed X11 pcf bitmap font 8x16graph.pcf.gz on your xserver:
---------------------------------------------------------------------------------
1. Create as user root the font directory
mkdir /usr/share/fonts/X11/misc/finalcut/
2. Copy the files 8x16graph.pcf.gz, fonts.dir and fonts.alias
into the just created directory
cp 8x16graph.pcf.gz fonts.dir fonts.alias /usr/share/fonts/X11/misc/finalcut/
3. Add the new dir to X font path
xset fp+ /usr/share/fonts/X11/misc/finalcut/
(You can insert this command into the ~/.xinitrc to make the
font path permanently usable)
4. Check if the font is available to the xserver
xlsfonts | grep 8x16graph
5. Start your program with the parameter --newfont
ui --newfont

View File

@ -963,6 +963,7 @@ enum scrollBarMode
// Xterm cursor style // Xterm cursor style
enum xtermCursorStyle enum xtermCursorStyle
{ {
unknown_cursor_style = -1,
blinking_block = 0, blinking_block = 0,
blinking_block_default = 1, blinking_block_default = 1,
steady_block = 2, steady_block = 2,

View File

@ -23,14 +23,38 @@
/* Base class /* Base class
* *
* *
* 1 1 * 1 1
* FTerm -- - - - FOptiMove * FTerm -- - - - FTermios
* : * :
* :
* : 1
* :- - - - FTermcap
* :
* :
* : 1
* :- - - - FTermcapQuirks
* :
* :
* : 1
* :- - - - FTermDetection
* :
* :
* : 1
* :- - - - FTermXTerminal
* :
* :
* : 1
* :- - - - FColorPalette
* :
* : * :
* : 1 * : 1
* :- - - - FOptiAttr * :- - - - FOptiAttr
* : * :
* : * :
* : 1
* :- - - - FOptiMove
* :
* :
* : * * : *
* :- - - - FString * :- - - - FString
* : * :
@ -123,6 +147,7 @@
#include "final/ftermcapquirks.h" #include "final/ftermcapquirks.h"
#include "final/ftermdetection.h" #include "final/ftermdetection.h"
#include "final/ftermios.h" #include "final/ftermios.h"
#include "final/ftermxterminal.h"
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -190,6 +215,7 @@ class FTerm
#endif #endif
// Inquiries // Inquiries
static bool isCursorHidden();
static bool isKeypressTimeout (timeval*); static bool isKeypressTimeout (timeval*);
static bool isNormal (char_data*&); static bool isNormal (char_data*&);
static bool isRaw(); static bool isRaw();
@ -223,11 +249,14 @@ class FTerm
// Mutators // Mutators
static void setTermType (char[]); static void setTermType (char[]);
static void setInsertCursor (bool on);
static void setInsertCursor();
static void unsetInsertCursor();
static bool setCursorOptimisation (bool); static bool setCursorOptimisation (bool);
static void setXTermDefaultColors (bool); static void redefineDefaultColors (bool);
#if defined(__linux__) #if defined(__linux__)
static void setLinuxConsoleCursorStyle \ static char* setLinuxConsoleCursorStyle \
(fc::linuxConsoleCursorStyle, bool); (fc::linuxConsoleCursorStyle, bool);
#endif #endif
@ -253,31 +282,14 @@ class FTerm
static bool setNewFont(); static bool setNewFont();
static bool setOldFont(); static bool setOldFont();
static char* moveCursor (int, int, int, int); static char* moveCursor (int, int, int, int);
static char* cursorsVisibility (bool);
static void printMoveDurations(); static void printMoveDurations();
static char* enableCursor(); static char* enableCursor();
static char* disableCursor(); static char* disableCursor();
static void detectTermSize(); static void detectTermSize();
static void setTermSize (int, int); static void setTermSize (int, int);
static void setTermTitle(const FString&);
static void setKDECursor (fc::kdeKonsoleCursorShape); static void setKDECursor (fc::kdeKonsoleCursorShape);
static const FString* getXTermFont();
static const FString* getXTermTitle();
static void setXTermCursorStyle (fc::xtermCursorStyle);
static void setXTermTitle (const FString&);
static void setXTermForeground (const FString&);
static void setXTermBackground (const FString&);
static void setXTermCursorColor (const FString&);
static void setXTermMouseForeground (const FString&);
static void setXTermMouseBackground (const FString&);
static void setXTermHighlightBackground (const FString&);
static void setXTermDefaults();
static void resetXTermColors();
static void resetXTermForeground();
static void resetXTermBackground();
static void resetXTermCursorColor();
static void resetXTermMouseForeground();
static void resetXTermMouseBackground();
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);
@ -331,21 +343,13 @@ class FTerm
static uInt getCursorAddressLengths(); static uInt getCursorAddressLengths();
// Methods // Methods
#if defined(__linux__) static void initScreenSettings();
static void initLinuxConsoleCharMap();
#endif
#if defined(__FreeBSD__) || defined(__DragonFly__)
static void initFreeBSDConsoleCharMap();
#endif
static bool charEncodable (uInt); static bool charEncodable (uInt);
static uInt charEncode (uInt); static uInt charEncode (uInt);
static uInt charEncode (uInt, fc::encoding); static uInt charEncode (uInt, fc::encoding);
static char* changeAttribute ( char_data*& static char* changeAttribute ( char_data*&
, char_data*& ); , char_data*& );
static void changeTermSizeFinished(); static void changeTermSizeFinished();
static void xtermMetaSendsESC (bool);
static void exitWithMessage (std::string) static void exitWithMessage (std::string)
#if defined(__clang__) || defined(__GNUC__) #if defined(__clang__) || defined(__GNUC__)
__attribute__((noreturn)) __attribute__((noreturn))
@ -428,6 +432,7 @@ class FTerm
static int setUnicodeMap (struct unimapdesc*); static int setUnicodeMap (struct unimapdesc*);
static int getUnicodeMap (); static int getUnicodeMap ();
static void initLinuxConsole(); static void initLinuxConsole();
static void initLinuxConsoleCharMap();
#endif #endif
#if defined(__FreeBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__DragonFly__)
@ -436,6 +441,7 @@ class FTerm
static bool setFreeBSDAlt2Meta(); static bool setFreeBSDAlt2Meta();
static bool resetFreeBSDAlt2Meta(); static bool resetFreeBSDAlt2Meta();
static void initFreeBSDConsole(); static void initFreeBSDConsole();
static void initFreeBSDConsoleCharMap();
#endif #endif
#if defined(__NetBSD__) || defined(__OpenBSD__) #if defined(__NetBSD__) || defined(__OpenBSD__)
@ -474,11 +480,12 @@ class FTerm
static void init_tab_quirks(); static void init_tab_quirks();
static void redefineColorPalette(); static void redefineColorPalette();
static void restoreColorPalette(); static void restoreColorPalette();
static void setInsertCursorStyle();
static void setOverwriteCursorStyle();
static void enableMouse(); static void enableMouse();
static void disableMouse(); static void disableMouse();
static void useAlternateScreenBuffer(); static void useAlternateScreenBuffer();
static void useNormalScreenBuffer(); static void useNormalScreenBuffer();
static void captureXTermFontAndTitle();
void allocationValues(); void allocationValues();
void deallocationValues(); void deallocationValues();
void init(); void init();
@ -504,7 +511,7 @@ class FTerm
static bool shadow_character; static bool shadow_character;
static bool half_block_character; static bool half_block_character;
static bool cursor_optimisation; static bool cursor_optimisation;
static bool xterm_default_colors; static bool hidden_cursor;
static bool use_alternate_screen; static bool use_alternate_screen;
static bool input_data_pending; static bool input_data_pending;
static bool non_blocking_stdin; static bool non_blocking_stdin;
@ -554,9 +561,10 @@ class FTerm
static FOptiMove* opti_move; static FOptiMove* opti_move;
static FOptiAttr* opti_attr; static FOptiAttr* opti_attr;
static FTermDetection* term_detection; static FTermDetection* term_detection;
static FTermXTerminal* xterm;
static FMouseControl* mouse; static FMouseControl* mouse;
static const FString* xterm_font; static const FString* save_xterm_font;
static const FString* xterm_title; static const FString* save_xterm_title;
static struct colorEnv static struct colorEnv
{ {
@ -582,8 +590,8 @@ class FTerm
{ {
void setDefault() void setDefault()
{ {
terminal_id_type = -1; terminal_id_type = -1;
terminal_id_version = -1; terminal_id_version = -1;
terminal_id_hardware = -1; terminal_id_hardware = -1;
} }
@ -649,6 +657,10 @@ inline int FTerm::getFramebufferBpp()
{ return framebuffer_bpp; } { return framebuffer_bpp; }
#endif #endif
//----------------------------------------------------------------------
inline bool FTerm::isCursorHidden()
{ return hidden_cursor; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTerm::isKeypressTimeout (timeval* time) inline bool FTerm::isKeypressTimeout (timeval* time)
{ return FObject::isTimeout (time, key_timeout); } { return FObject::isTimeout (time, key_timeout); }
@ -762,12 +774,16 @@ inline bool FTerm::isUTF8()
{ return utf8_state; } { return utf8_state; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTerm::setCursorOptimisation (bool on) inline void FTerm::setInsertCursor()
{ return cursor_optimisation = ( on ) ? true : false; } { setInsertCursor(true); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FTerm::setXTermDefaultColors (bool on) inline void FTerm::unsetInsertCursor()
{ xterm_default_colors = on; } { setInsertCursor(false); }
//----------------------------------------------------------------------
inline bool FTerm::setCursorOptimisation (bool on)
{ return cursor_optimisation = ( on ) ? true : false; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FTerm::setKeypressTimeout (const long timeout) inline void FTerm::setKeypressTimeout (const long timeout)

View File

@ -0,0 +1,218 @@
/***********************************************************************
* ftermxterminal.h - Contains all xterm-specific terminal functions *
* *
* This file is part of the Final Cut widget toolkit *
* *
* Copyright 2018 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 *
* <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
#include "final/fc.h"
#include "final/fstring.h"
#include "final/ftermcap.h"
#include "final/ftermdetection.h"
//----------------------------------------------------------------------
// class FTermXTerminal
//----------------------------------------------------------------------
#pragma pack(push)
#pragma pack(1)
class FTermXTerminal
{
public:
// Constructors
FTermXTerminal();
// Destructor
~FTermXTerminal();
// Mutators
static void setTermcapMap (FTermcap::tcap_map*);
static void setFTermDetection (FTermDetection*);
static void redefineDefaultColors (bool);
static void setCursorStyle (fc::xtermCursorStyle);
static void setFont (const FString&);
static void setTitle (const FString&);
static void setForeground (const FString&);
static void setBackground (const FString&);
static void setCursorColor (const FString&);
static void setMouseForeground (const FString&);
static void setMouseBackground (const FString&);
static void setHighlightBackground (const FString&);
static void setMouseSupport (bool);
static void setMouseSupport();
static void unsetMouseSupport();
static void metaSendsESC (bool);
// Accessors
static fc::xtermCursorStyle getCursorStyle();
static const FString* getFont();
static const FString* getTitle();
static const FString* getForeground();
static const FString* getBackground();
static const FString* getCursorColor();
static const FString* getMouseForeground();
static const FString* getMouseBackground();
static const FString* getHighlightBackground();
// Inquiries
static bool hasFont();
static bool hasTitle();
// Methods
static void setDefaults();
static void resetColorMap();
static void resetForeground();
static void resetBackground();
static void resetCursorColor();
static void resetMouseForeground();
static void resetMouseBackground();
static void resetHighlightBackground();
static void resetDefaults();
static void captureFontAndTitle();
private:
// Methods
static void setXTermCursorStyle();
static void setXTermFont();
static void setXTermTitle();
static void setXTermForeground();
static void setXTermBackground();
static void setXTermCursorColor();
static void setXTermMouseForeground();
static void setXTermMouseBackground();
static void setXTermHighlightBackground();
static void setXTerm8ColorDefaults();
static void setXTerm16ColorDefaults();
static void resetXTermColorMap();
static void resetXTermForeground();
static void resetXTermBackground();
static void resetXTermCursorColor();
static void resetXTermMouseForeground();
static void resetXTermMouseBackground();
static void resetXTermHighlightBackground();
static void oscPrefix();
static void oscPostfix();
static const FString* captureXTermFont();
static const FString* captureXTermTitle();
static void enableXTermMouse();
static void disableXTermMouse();
static void enableXTermMetaSendsESC();
static void disableXTermMetaSendsESC();
// Data Members
static FTermcap::tcap_map* tcap;
static FTermDetection* term_detection;
static fc::xtermCursorStyle cursor_style;
static const FString* xterm_font;
static const FString* xterm_title;
static const FString* foreground_color;
static const FString* background_color;
static const FString* cursor_color;
static const FString* mouse_foreground_color;
static const FString* mouse_background_color;
static const FString* highlight_background_color;
static bool mouse_support;
static bool meta_sends_esc;
static bool xterm_default_colors;
};
#pragma pack(pop)
// FTermXTerminal inline functions
//----------------------------------------------------------------------
inline void FTermXTerminal::setTermcapMap (FTermcap::tcap_map* tc)
{ tcap = tc; }
//----------------------------------------------------------------------
inline void FTermXTerminal::setFTermDetection (FTermDetection* td)
{ term_detection = td; }
//----------------------------------------------------------------------
inline void FTermXTerminal::redefineDefaultColors (bool on)
{ xterm_default_colors = on; }
//----------------------------------------------------------------------
inline fc::xtermCursorStyle FTermXTerminal::getCursorStyle()
{ return cursor_style; }
//----------------------------------------------------------------------
inline const FString* FTermXTerminal::getFont()
{ return xterm_font; }
//----------------------------------------------------------------------
inline const FString* FTermXTerminal::getTitle()
{ return xterm_title; }
//----------------------------------------------------------------------
inline const FString* FTermXTerminal::getForeground()
{ return foreground_color; }
//----------------------------------------------------------------------
inline const FString* FTermXTerminal::getBackground()
{ return background_color; }
//----------------------------------------------------------------------
inline const FString* FTermXTerminal::getCursorColor()
{ return cursor_color; }
//----------------------------------------------------------------------
inline const FString* FTermXTerminal::getMouseForeground()
{ return mouse_foreground_color; }
//----------------------------------------------------------------------
inline const FString* FTermXTerminal::getMouseBackground()
{ return mouse_background_color; }
//----------------------------------------------------------------------
inline const FString* FTermXTerminal::getHighlightBackground()
{ return highlight_background_color; }
//----------------------------------------------------------------------
inline bool FTermXTerminal::hasFont()
{ return bool(xterm_font && xterm_font->getLength() > 2); }
//----------------------------------------------------------------------
inline bool FTermXTerminal::hasTitle()
{ return bool(xterm_title && xterm_title->getLength() > 0); }
//----------------------------------------------------------------------
inline void FTermXTerminal::setMouseSupport()
{ setMouseSupport (true); }
//----------------------------------------------------------------------
inline void FTermXTerminal::unsetMouseSupport()
{ setMouseSupport (false); }
#endif // FTERMXTERMINAL_H

View File

@ -129,9 +129,9 @@ class FVTerm : public FTerm
// Mutators // Mutators
static void setTermXY (register int, register int); static void setTermXY (register int, register int);
static bool hideCursor (bool); static void hideCursor (bool);
static bool hideCursor(); static void hideCursor();
static bool showCursor(); static void showCursor();
void setPrintCursor (const FPoint&); void setPrintCursor (const FPoint&);
void setPrintCursor (register int, register int); void setPrintCursor (register int, register int);
void setColor (short, short); void setColor (short, short);
@ -202,7 +202,6 @@ class FVTerm : public FTerm
static bool unsetInheritBackground(); static bool unsetInheritBackground();
// Inquiries // Inquiries
static bool isCursorHidden();
static bool isBold(); static bool isBold();
static bool isDim(); static bool isDim();
static bool isItalic(); static bool isItalic();
@ -275,11 +274,6 @@ class FVTerm : public FTerm
bool hasChildPrintArea() const; bool hasChildPrintArea() const;
bool isVirtualWindow() const; bool isVirtualWindow() const;
// Mutator
static void setInsertCursorStyle (bool on);
static void setInsertCursorStyle();
static void unsetInsertCursorStyle();
// Methods // Methods
void createArea ( const FRect& void createArea ( const FRect&
, const FPoint& , const FPoint&
@ -443,7 +437,6 @@ class FVTerm : public FTerm
static char_data i_ch; // inherit background character static char_data i_ch; // inherit background character
static FPoint* term_pos; // terminal cursor position static FPoint* term_pos; // terminal cursor position
static termcap_map* tcap; static termcap_map* tcap;
static bool hidden_cursor;
static bool terminal_update_complete; static bool terminal_update_complete;
static bool terminal_update_pending; static bool terminal_update_pending;
static bool force_terminal_update; static bool force_terminal_update;
@ -552,11 +545,11 @@ inline FVTerm::char_data FVTerm::getAttribute()
{ return next_attribute; } { return next_attribute; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FVTerm::hideCursor() inline void FVTerm::hideCursor()
{ return hideCursor(true); } { return hideCursor(true); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FVTerm::showCursor() inline void FVTerm::showCursor()
{ return hideCursor(false); } { return hideCursor(false); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -774,10 +767,6 @@ inline bool FVTerm::setInheritBackground()
inline bool FVTerm::unsetInheritBackground() inline bool FVTerm::unsetInheritBackground()
{ return setInheritBackground(false); } { return setInheritBackground(false); }
//----------------------------------------------------------------------
inline bool FVTerm::isCursorHidden()
{ return hidden_cursor; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FVTerm::isBold() inline bool FVTerm::isBold()
{ return next_attribute.attr.bit.bold; } { return next_attribute.attr.bit.bold; }
@ -858,14 +847,6 @@ inline bool FVTerm::hasChildPrintArea() const
inline bool FVTerm::isVirtualWindow() const inline bool FVTerm::isVirtualWindow() const
{ return vwin; } { return vwin; }
//----------------------------------------------------------------------
inline void FVTerm::setInsertCursorStyle()
{ setInsertCursorStyle(true); }
//----------------------------------------------------------------------
inline void FVTerm::unsetInsertCursorStyle()
{ setInsertCursorStyle(false); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FVTerm::setPrintArea (term_area* area) inline void FVTerm::setPrintArea (term_area* area)
{ print_area = area; } { print_area = area; }

View File

@ -41,6 +41,7 @@ libfinal_la_SOURCES = \
ftextview.cpp \ ftextview.cpp \
fstatusbar.cpp \ fstatusbar.cpp \
ftermcapquirks.cpp \ ftermcapquirks.cpp \
ftermxterminal.cpp \
ftermdetection.cpp \ ftermdetection.cpp \
ftermios.cpp \ ftermios.cpp \
fterm.cpp \ fterm.cpp \
@ -104,6 +105,7 @@ finalcutinclude_HEADERS = \
../include/final/ftcap_map.h \ ../include/final/ftcap_map.h \
../include/final/ftermcap.h \ ../include/final/ftermcap.h \
../include/final/ftermcapquirks.h \ ../include/final/ftermcapquirks.h \
../include/final/ftermxterminal.h \
../include/final/ftermdetection.h \ ../include/final/ftermdetection.h \
../include/final/ftermios.h \ ../include/final/ftermios.h \
../include/final/fterm.h \ ../include/final/fterm.h \

View File

@ -47,6 +47,7 @@ INCLUDE_HEADERS = \
ftermios.h \ ftermios.h \
ftermdetection.h \ ftermdetection.h \
ftermcapquirks.h \ ftermcapquirks.h \
ftermxterminal.h \
fvterm.h \ fvterm.h \
ftextview.h \ ftextview.h \
ftogglebutton.h \ ftogglebutton.h \
@ -101,6 +102,7 @@ OBJS = \
ftermios.o \ ftermios.o \
ftermdetection.o \ ftermdetection.o \
ftermcapquirks.o \ ftermcapquirks.o \
ftermxterminal.o \
fvterm.o \ fvterm.o \
fevent.o \ fevent.o \
foptiattr.o \ foptiattr.o \

View File

@ -47,6 +47,7 @@ INCLUDE_HEADERS = \
ftermios.h \ ftermios.h \
ftermdetection.h \ ftermdetection.h \
ftermcapquirks.h \ ftermcapquirks.h \
ftermxterminal.h \
fvterm.h \ fvterm.h \
ftextview.h \ ftextview.h \
ftogglebutton.h \ ftogglebutton.h \
@ -101,6 +102,7 @@ OBJS = \
ftermios.o \ ftermios.o \
ftermdetection.o \ ftermdetection.o \
ftermcapquirks.o \ ftermcapquirks.o \
ftermxterminal.o \
fvterm.o \ fvterm.o \
fevent.o \ fevent.o \
foptiattr.o \ foptiattr.o \

View File

@ -136,10 +136,10 @@ am_libfinal_la_OBJECTS = fstring.lo fpoint.lo frect.lo fscrollbar.lo \
fdialoglistmenu.lo fmenubar.lo fmenuitem.lo fradiomenuitem.lo \ fdialoglistmenu.lo fmenubar.lo fmenuitem.lo fradiomenuitem.lo \
fcheckmenuitem.lo fmenulist.lo fdialog.lo fscrollview.lo \ fcheckmenuitem.lo fmenulist.lo fdialog.lo fscrollview.lo \
fwindow.lo fmessagebox.lo ftooltip.lo ffiledialog.lo \ fwindow.lo fmessagebox.lo ftooltip.lo ffiledialog.lo \
ftextview.lo fstatusbar.lo ftermcapquirks.lo ftermdetection.lo \ ftextview.lo fstatusbar.lo ftermcapquirks.lo ftermxterminal.lo \
ftermios.lo fterm.lo fvterm.lo fevent.lo foptiattr.lo \ ftermdetection.lo ftermios.lo fterm.lo fvterm.lo fevent.lo \
foptimove.lo ftermbuffer.lo fapplication.lo fcolorpalette.lo \ foptiattr.lo foptimove.lo ftermbuffer.lo fapplication.lo \
fwidgetcolors.lo fwidget.lo fobject.lo fcolorpalette.lo fwidgetcolors.lo fwidget.lo fobject.lo
libfinal_la_OBJECTS = $(am_libfinal_la_OBJECTS) libfinal_la_OBJECTS = $(am_libfinal_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@) AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
@ -414,6 +414,7 @@ libfinal_la_SOURCES = \
ftextview.cpp \ ftextview.cpp \
fstatusbar.cpp \ fstatusbar.cpp \
ftermcapquirks.cpp \ ftermcapquirks.cpp \
ftermxterminal.cpp \
ftermdetection.cpp \ ftermdetection.cpp \
ftermios.cpp \ ftermios.cpp \
fterm.cpp \ fterm.cpp \
@ -475,6 +476,7 @@ finalcutinclude_HEADERS = \
../include/final/ftcap_map.h \ ../include/final/ftcap_map.h \
../include/final/ftermcap.h \ ../include/final/ftermcap.h \
../include/final/ftermcapquirks.h \ ../include/final/ftermcapquirks.h \
../include/final/ftermxterminal.h \
../include/final/ftermdetection.h \ ../include/final/ftermdetection.h \
../include/final/ftermios.h \ ../include/final/ftermios.h \
../include/final/fterm.h \ ../include/final/fterm.h \
@ -603,6 +605,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftermcapquirks.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftermcapquirks.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftermdetection.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftermdetection.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftermios.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftermios.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftermxterminal.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftextview.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftextview.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftogglebutton.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftogglebutton.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftooltip.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftooltip.Plo@am__quote@

View File

@ -69,7 +69,7 @@ FLineEdit::FLineEdit (const FString& txt, FWidget* parent)
FLineEdit::~FLineEdit() // destructor FLineEdit::~FLineEdit() // destructor
{ {
if ( ! insert_mode ) if ( ! insert_mode )
setInsertCursorStyle(); setInsertCursor();
} }
// FLineEdit operators // FLineEdit operators
@ -611,16 +611,16 @@ void FLineEdit::onAccel (FAccelEvent* ev)
void FLineEdit::onHide (FHideEvent*) void FLineEdit::onHide (FHideEvent*)
{ {
if ( ! insert_mode ) if ( ! insert_mode )
setInsertCursorStyle(); setInsertCursor();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FLineEdit::onFocusIn (FFocusEvent*) void FLineEdit::onFocusIn (FFocusEvent*)
{ {
if ( insert_mode ) if ( insert_mode )
setInsertCursorStyle(); setInsertCursor();
else else
unsetInsertCursorStyle(); unsetInsertCursor();
if ( getStatusBar() ) if ( getStatusBar() )
{ {
@ -640,7 +640,7 @@ void FLineEdit::onFocusOut (FFocusEvent*)
} }
if ( ! insert_mode ) if ( ! insert_mode )
setInsertCursorStyle(); setInsertCursor();
} }
@ -885,9 +885,9 @@ inline void FLineEdit::keyInsert()
insert_mode = not insert_mode; insert_mode = not insert_mode;
if ( insert_mode ) if ( insert_mode )
setInsertCursorStyle(); setInsertCursor();
else else
unsetInsertCursorStyle(); unsetInsertCursor();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -28,6 +28,7 @@
#include "final/fmouse.h" #include "final/fmouse.h"
#include "final/fterm.h" #include "final/fterm.h"
#include "final/ftermxterminal.h"
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1632,23 +1633,11 @@ FMouse* FMouseControl::getMouseWithEvent()
void FMouseControl::xtermMouse (bool on) void FMouseControl::xtermMouse (bool on)
{ {
// activate/deactivate the xterm mouse support // activate/deactivate the xterm mouse support
if ( ! use_xterm_mouse ) if ( ! use_xterm_mouse )
return; return;
if ( on ) FTermXTerminal::setMouseSupport (on);
putstring (CSI "?1001s" // save old highlight mouse tracking
CSI "?1000h" // enable x11 mouse tracking
CSI "?1002h" // enable cell motion mouse tracking
CSI "?1015h" // enable urxvt mouse mode
CSI "?1006h"); // enable SGR mouse mode
else
putstring (CSI "?1006l" // disable SGR mouse mode
CSI "?1015l" // disable urxvt mouse mode
CSI "?1002l" // disable cell motion mouse tracking
CSI "?1000l" // disable x11 mouse tracking
CSI "?1001r"); // restore old highlight mouse tracking
std::fflush(stdout);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

File diff suppressed because it is too large Load Diff

View File

@ -179,7 +179,7 @@ void FTermcapQuirks::init_termcap_linux_quirks()
/* Same settings are used by cygwin */ /* Same settings are used by cygwin */
// Set ansi foreground and background color // Set ansi foreground and background color
if ( FTermcap::max_color > 8 ) if ( FTerm::getMaxColor() > 8 )
{ {
TCAP(fc::t_set_a_foreground) = \ TCAP(fc::t_set_a_foreground) = \
C_STR(CSI "3%p1%{8}%m%d%?%p1%{7}%>%t;1%e;22%;m"); C_STR(CSI "3%p1%{8}%m%d%?%p1%{7}%>%t;1%e;22%;m");

926
src/ftermxterminal.cpp Normal file
View File

@ -0,0 +1,926 @@
/***********************************************************************
* ftermxterminal.cpp - Contains all xterm-specific terminal functions *
* *
* This file is part of the Final Cut widget toolkit *
* *
* Copyright 2018 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 *
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#include "final/fterm.h"
#include "final/ftermxterminal.h"
// static class attributes
bool FTermXTerminal::mouse_support;
bool FTermXTerminal::meta_sends_esc;
bool FTermXTerminal::xterm_default_colors;
FTermcap::tcap_map* FTermXTerminal::tcap = 0;
FTermDetection* FTermXTerminal::term_detection = 0;
fc::xtermCursorStyle FTermXTerminal::cursor_style = fc::unknown_cursor_style;
const FString* FTermXTerminal::xterm_font = 0;
const FString* FTermXTerminal::xterm_title = 0;
const FString* FTermXTerminal::foreground_color = 0;
const FString* FTermXTerminal::background_color = 0;
const FString* FTermXTerminal::cursor_color = 0;
const FString* FTermXTerminal::mouse_foreground_color = 0;
const FString* FTermXTerminal::mouse_background_color = 0;
const FString* FTermXTerminal::highlight_background_color = 0;
//----------------------------------------------------------------------
// class FTermXTerminal
//----------------------------------------------------------------------
// constructors and destructor
//----------------------------------------------------------------------
FTermXTerminal::FTermXTerminal()
{
// Preset to false
mouse_support = \
meta_sends_esc = \
xterm_default_colors = false;
}
//----------------------------------------------------------------------
FTermXTerminal::~FTermXTerminal() // destructor
{
if ( highlight_background_color )
delete highlight_background_color;
if ( mouse_background_color )
delete mouse_background_color;
if ( mouse_foreground_color )
delete mouse_foreground_color;
if ( cursor_color )
delete cursor_color;
if ( background_color )
delete background_color;
if ( foreground_color )
delete foreground_color;
if ( xterm_title )
delete xterm_title;
if ( xterm_font )
delete xterm_font;
}
// public methods of FTermXTerminal
//----------------------------------------------------------------------
void FTermXTerminal::setCursorStyle (fc::xtermCursorStyle style)
{
// Set the xterm cursor style
cursor_style = style;
setXTermCursorStyle();
}
//----------------------------------------------------------------------
void FTermXTerminal::setFont (const FString& fontname)
{
// Change the XTerm font (needs the allowFontOps resource)
if ( xterm_font )
delete xterm_font;
xterm_font = new FString(fontname);
setXTermFont();
}
//----------------------------------------------------------------------
void FTermXTerminal::setTitle (const FString& title)
{
// Set the xterm title
if ( xterm_title )
delete xterm_title;
xterm_title = new FString(title);
setXTermTitle();
}
//----------------------------------------------------------------------
void FTermXTerminal::setForeground (const FString& fg)
{
// Set the XTerm text foreground color
if ( foreground_color )
delete foreground_color;
foreground_color = new FString(fg);
setXTermForeground();
}
//----------------------------------------------------------------------
void FTermXTerminal::setBackground (const FString& bg)
{
// Set the XTerm text background color
if ( background_color )
delete background_color;
background_color = new FString(bg);
setXTermBackground();
}
//----------------------------------------------------------------------
void FTermXTerminal::setCursorColor (const FString& cc)
{
// Set the text cursor color
if ( cursor_color )
delete cursor_color;
cursor_color = new FString(cc);
setXTermCursorColor();
}
//----------------------------------------------------------------------
void FTermXTerminal::setMouseForeground (const FString& mfg)
{
// Set the mouse foreground color
if ( mouse_foreground_color )
delete mouse_foreground_color;
mouse_foreground_color = new FString(mfg);
setXTermMouseForeground();
}
//----------------------------------------------------------------------
void FTermXTerminal::setMouseBackground (const FString& mbg)
{
// Set the mouse background color
if ( mouse_background_color )
delete mouse_background_color;
mouse_background_color = new FString(mbg);
setXTermMouseBackground();
}
//----------------------------------------------------------------------
void FTermXTerminal::setHighlightBackground (const FString& hbg)
{
// Set the highlight background color
if ( highlight_background_color )
delete highlight_background_color;
highlight_background_color = new FString(hbg);
setXTermHighlightBackground();
}
//----------------------------------------------------------------------
void FTermXTerminal::setMouseSupport (bool on)
{
// activate/deactivate the xterm mouse support
if ( on )
enableXTermMouse();
else
disableXTermMouse();
}
//----------------------------------------------------------------------
void FTermXTerminal::metaSendsESC (bool on)
{
// activate/deactivate the xterm meta key sends escape prefix
if ( on )
enableXTermMetaSendsESC();
else
disableXTermMetaSendsESC();
}
//----------------------------------------------------------------------
void FTermXTerminal::setDefaults()
{
// Redefinition of the XTerm default colors
// for the final cut color theme
if ( FTerm::getMaxColor() >= 16 )
setXTerm16ColorDefaults();
else
setXTerm8ColorDefaults();
}
//----------------------------------------------------------------------
void FTermXTerminal::resetColorMap()
{
// Reset the entire color table
resetXTermColorMap();
}
//----------------------------------------------------------------------
void FTermXTerminal::resetForeground()
{
// Reset the XTerm text foreground color
if ( foreground_color )
delete foreground_color;
foreground_color = 0;
resetXTermForeground();
}
//----------------------------------------------------------------------
void FTermXTerminal::resetBackground()
{
// Reset the XTerm text background color
if ( background_color )
delete background_color;
background_color = 0;
resetXTermBackground();
}
//----------------------------------------------------------------------
void FTermXTerminal::resetCursorColor()
{
// Reset the text cursor color
if ( cursor_color )
delete cursor_color;
cursor_color = 0;
resetXTermCursorColor();
}
//----------------------------------------------------------------------
void FTermXTerminal::resetMouseForeground()
{
// Reset the mouse foreground color
if ( mouse_foreground_color )
delete mouse_foreground_color;
mouse_foreground_color = 0;
resetXTermMouseForeground();
}
//----------------------------------------------------------------------
void FTermXTerminal::resetMouseBackground()
{
// Reset the mouse background color
if ( mouse_background_color )
delete mouse_background_color;
mouse_background_color = 0;
resetXTermMouseBackground();
}
//----------------------------------------------------------------------
void FTermXTerminal::resetHighlightBackground()
{
// Reset the highlight background color
if ( highlight_background_color )
delete highlight_background_color;
highlight_background_color = 0;
resetXTermHighlightBackground();
}
//----------------------------------------------------------------------
void FTermXTerminal::resetDefaults()
{
if ( term_detection->isPuttyTerminal() )
return;
// Redefines the cursor color if resetCursorColor() doesn't work
setCursorColor("rgb:b1b1/b1b1/b1b1");
// Reset mouse color to default
resetMouseForeground();
resetMouseBackground();
// Reset text cursor color to default
resetCursorColor();
if ( xterm_default_colors )
{
// Reset text foreground, text background, and mouse text highlight
// colors to default values
resetForeground();
resetBackground();
resetHighlightBackground();
}
}
//----------------------------------------------------------------------
void FTermXTerminal::captureFontAndTitle()
{
if ( ( term_detection->isXTerminal()
|| term_detection->isUrxvtTerminal() )
&& ! term_detection->isRxvtTerminal() )
{
if ( xterm_font )
delete xterm_font;
if ( xterm_title )
delete xterm_title;
FTermios::setCaptureSendCharacters();
xterm_font = captureXTermFont();
xterm_title = captureXTermTitle();
FTermios::unsetCaptureSendCharacters();
}
}
// private methods of FTermXTerminal
//----------------------------------------------------------------------
void FTermXTerminal::setXTermCursorStyle()
{
// Set the xterm cursor style
#if defined(__FreeBSD__) || defined(__DragonFly__)
if ( FTerm::isFreeBSDConsole() )
return;
#endif
if ( term_detection->isGnomeTerminal()
&& ! term_detection->hasSetCursorStyleSupport() )
return;
if ( term_detection->isKdeTerminal() )
return;
if ( TCAP(fc::t_cursor_style)
|| term_detection->isXTerminal()
|| term_detection->isMinttyTerm()
|| term_detection->hasSetCursorStyleSupport() )
{
FTerm::putstringf (CSI "%d q", cursor_style);
std::fflush(stdout);
}
}
//----------------------------------------------------------------------
void FTermXTerminal::setXTermTitle()
{
// Set the xterm title
if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm()
|| term_detection->isMinttyTerm()
|| term_detection->isPuttyTerminal()
|| FTermcap::osc_support )
{
oscPrefix();
FTerm::putstringf (OSC "0;%s" BEL, xterm_title->c_str());
oscPostfix();
std::fflush(stdout);
}
}
//----------------------------------------------------------------------
void FTermXTerminal::setXTermFont()
{
// Change the XTerm font (needs the allowFontOps resource)
if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm()
|| term_detection->isUrxvtTerminal()
|| FTermcap::osc_support )
{
oscPrefix();
FTerm::putstringf (OSC "50;%s" BEL, xterm_font->c_str() );
oscPostfix();
}
}
//----------------------------------------------------------------------
void FTermXTerminal::setXTermForeground()
{
// Set the XTerm text foreground color
if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm()
|| term_detection->isMinttyTerm()
|| term_detection->isMltermTerminal()
|| FTermcap::osc_support )
{
oscPrefix();
FTerm::putstringf (OSC "10;%s" BEL, foreground_color->c_str());
oscPostfix();
std::fflush(stdout);
}
}
//----------------------------------------------------------------------
void FTermXTerminal::setXTermBackground()
{
// Set the XTerm text background color
if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm()
|| term_detection->isMinttyTerm()
|| term_detection->isMltermTerminal()
|| FTermcap::osc_support )
{
oscPrefix();
FTerm::putstringf (OSC "11;%s" BEL, background_color->c_str());
oscPostfix();
std::fflush(stdout);
}
}
//----------------------------------------------------------------------
void FTermXTerminal::setXTermCursorColor()
{
// Set the text cursor color
if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm()
|| term_detection->isMinttyTerm()
|| term_detection->isUrxvtTerminal()
|| FTermcap::osc_support )
{
oscPrefix();
FTerm::putstringf (OSC "12;%s" BEL, cursor_color->c_str());
oscPostfix();
std::fflush(stdout);
}
}
//----------------------------------------------------------------------
void FTermXTerminal::setXTermMouseForeground()
{
// Set the mouse foreground color
if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm()
|| term_detection->isUrxvtTerminal()
|| FTermcap::osc_support )
{
oscPrefix();
FTerm::putstringf (OSC "13;%s" BEL, mouse_foreground_color->c_str());
oscPostfix();
std::fflush(stdout);
}
}
//----------------------------------------------------------------------
void FTermXTerminal::setXTermMouseBackground()
{
// Set the mouse background color
if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm()
|| FTermcap::osc_support )
{
oscPrefix();
FTerm::putstringf (OSC "14;%s" BEL, mouse_background_color->c_str());
oscPostfix();
std::fflush(stdout);
}
}
//----------------------------------------------------------------------
void FTermXTerminal::setXTermHighlightBackground()
{
// Set the highlight background color
if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm()
|| term_detection->isUrxvtTerminal()
|| FTermcap::osc_support )
{
oscPrefix();
FTerm::putstringf (OSC "17;%s" BEL, highlight_background_color->c_str());
oscPostfix();
std::fflush(stdout);
}
}
//----------------------------------------------------------------------
void FTermXTerminal::setXTerm8ColorDefaults()
{
// Redefinition of the XTerm default colors
// for the final cut 8 color theme
if ( term_detection->isPuttyTerminal() )
return;
setMouseBackground("rgb:ffff/ffff/ffff"); // white
setMouseForeground ("rgb:0000/0000/0000"); // black
if ( ! term_detection->isGnomeTerminal() )
setCursorColor("rgb:ffff/ffff/ffff"); // white
if ( xterm_default_colors
&& ! (term_detection->isMinttyTerm()
|| term_detection->isRxvtTerminal()
|| term_detection->isScreenTerm()) )
{
// mintty and rxvt can't reset these settings
setBackground("rgb:2222/2222/b2b2"); // blue
setForeground("rgb:0000/0000/0000"); // black
setHighlightBackground("rgb:8787/8787/8787"); // gray53
}
}
//----------------------------------------------------------------------
void FTermXTerminal::setXTerm16ColorDefaults()
{
// Redefinition of the XTerm default colors
// for the final cut 16 color theme
if ( term_detection->isPuttyTerminal() )
return;
setMouseBackground("rgb:ffff/ffff/ffff"); // white
setMouseForeground ("rgb:0000/0000/0000"); // black
if ( ! term_detection->isGnomeTerminal() )
setCursorColor("rgb:ffff/ffff/ffff"); // white
if ( xterm_default_colors
&& ! (term_detection->isMinttyTerm()
|| term_detection->isRxvtTerminal()
|| term_detection->isScreenTerm()) )
{
// mintty and rxvt can't reset these settings
setBackground("rgb:8080/a4a4/ecec"); // very light blue
setForeground("rgb:0000/0000/0000"); // black
setHighlightBackground("rgb:8787/8787/8787"); // gray53
}
}
//----------------------------------------------------------------------
void FTermXTerminal::resetXTermColorMap()
{
// Reset the entire color table
if ( term_detection->isGnomeTerminal()
&& term_detection->getGnomeTerminalID() < 3502 )
return;
if ( term_detection->isPuttyTerminal() )
return;
if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm()
|| FTermcap::osc_support )
{
oscPrefix();
FTerm::putstringf (OSC "104" BEL);
oscPostfix();
std::fflush(stdout);
}
}
//----------------------------------------------------------------------
void FTermXTerminal::resetXTermForeground()
{
// Reset the XTerm text foreground color
if ( term_detection->isGnomeTerminal()
&& term_detection->getGnomeTerminalID() < 3502 )
return;
if ( term_detection->isPuttyTerminal() )
return;
if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm()
|| FTermcap::osc_support )
{
oscPrefix();
FTerm::putstring (OSC "110" BEL);
oscPostfix();
std::fflush(stdout);
}
}
//----------------------------------------------------------------------
void FTermXTerminal::resetXTermBackground()
{
// Reset the XTerm text background color
if ( term_detection->isGnomeTerminal()
&& term_detection->getGnomeTerminalID() < 3502 )
return;
if ( term_detection->isPuttyTerminal() )
return;
if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm()
|| FTermcap::osc_support )
{
oscPrefix();
FTerm::putstring (OSC "111" BEL);
oscPostfix();
std::fflush(stdout);
}
}
//----------------------------------------------------------------------
void FTermXTerminal::resetXTermCursorColor()
{
// Reset the text cursor color
if ( term_detection->isGnomeTerminal()
&& term_detection->getGnomeTerminalID() < 3502 )
return;
if ( term_detection->isPuttyTerminal() )
return;
if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm()
|| FTermcap::osc_support )
{
oscPrefix();
FTerm::putstring (OSC "112" BEL);
oscPostfix();
std::fflush(stdout);
}
}
//----------------------------------------------------------------------
void FTermXTerminal::resetXTermMouseForeground()
{
// Reset the mouse foreground color
if ( term_detection->isGnomeTerminal()
&& term_detection->getGnomeTerminalID() < 3502 )
return;
if ( term_detection->isPuttyTerminal() )
return;
if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm()
|| FTermcap::osc_support )
{
oscPrefix();
FTerm::putstring (OSC "113" BEL);
oscPostfix();
std::fflush(stdout);
}
}
//----------------------------------------------------------------------
void FTermXTerminal::resetXTermMouseBackground()
{
// Reset the mouse background color
if ( term_detection->isGnomeTerminal()
&& term_detection->getGnomeTerminalID() < 3502 )
return;
if ( term_detection->isPuttyTerminal() )
return;
if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm()
|| FTermcap::osc_support )
{
oscPrefix();
FTerm::putstring (OSC "114" BEL);
oscPostfix();
std::fflush(stdout);
}
}
//----------------------------------------------------------------------
void FTermXTerminal::resetXTermHighlightBackground()
{
// Reset the highlight background color
if ( term_detection->isGnomeTerminal()
&& term_detection->getGnomeTerminalID() < 3502 )
return;
if ( term_detection->isPuttyTerminal() )
return;
if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm()
|| term_detection->isUrxvtTerminal()
|| FTermcap::osc_support )
{
oscPrefix();
FTerm::putstringf (OSC "117" BEL);
oscPostfix();
std::fflush(stdout);
}
}
//----------------------------------------------------------------------
void FTermXTerminal::oscPrefix()
{
if ( term_detection->isTmuxTerm() )
{
// tmux device control string
FTerm::putstring (ESC "Ptmux;" ESC);
}
else if ( term_detection->isScreenTerm() )
{
// GNU Screen device control string
FTerm::putstring (ESC "P");
}
}
//----------------------------------------------------------------------
void FTermXTerminal::oscPostfix()
{
if ( term_detection->isScreenTerm()
|| term_detection->isTmuxTerm() )
{
// GNU Screen/tmux string terminator
FTerm::putstring (ESC "\\");
}
}
//----------------------------------------------------------------------
const FString* FTermXTerminal::captureXTermFont()
{
if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm()
|| FTermcap::osc_support )
{
fd_set ifds;
struct timeval tv;
int stdin_no = FTermios::getStdIn();
oscPrefix();
FTerm::putstring (OSC "50;?" BEL); // get font
oscPostfix();
std::fflush(stdout);
FD_ZERO(&ifds);
FD_SET(stdin_no, &ifds);
tv.tv_sec = 0;
tv.tv_usec = 150000; // 150 ms
// Read the terminal answer
if ( select(stdin_no + 1, &ifds, 0, 0, &tv) > 0 )
{
char temp[150] = {};
if ( std::scanf("\033]50;%148[^\n]s", temp) == 1 )
{
FString* xtermfont;
std::size_t n = std::strlen(temp);
// BEL + '\0' = string terminator
if ( n >= 5 && temp[n - 1] == BEL[0] && temp[n] == '\0' )
temp[n - 1] = '\0';
try
{
xtermfont = new FString(temp);
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
return 0;
}
return xtermfont;
}
}
}
return 0;
}
//----------------------------------------------------------------------
const FString* FTermXTerminal::captureXTermTitle()
{
if ( term_detection->isKdeTerminal() )
return 0;
fd_set ifds;
struct timeval tv;
int stdin_no = FTermios::getStdIn();
FTerm::putstring (CSI "21t"); // get title
std::fflush(stdout);
FD_ZERO(&ifds);
FD_SET(stdin_no, &ifds);
tv.tv_sec = 0;
tv.tv_usec = 150000; // 150 ms
// read the terminal answer
if ( select (stdin_no + 1, &ifds, 0, 0, &tv) > 0 )
{
char temp[512] = {};
if ( std::scanf("\033]l%509[^\n]s", temp) == 1 )
{
std::size_t n = std::strlen(temp);
// Esc + \ = OSC string terminator
if ( n >= 2 && temp[n - 2] == ESC[0] && temp[n - 1] == '\\' )
{
FString* xtermtitle;
if ( n < 4 )
return 0;
temp[n - 2] = '\0';
try
{
xtermtitle = new FString(temp);
}
catch (const std::bad_alloc& ex)
{
std::cerr << "not enough memory to alloc " << ex.what() << std::endl;
return 0;
}
return xtermtitle;
}
}
}
return 0;
}
//----------------------------------------------------------------------
void FTermXTerminal::enableXTermMouse()
{
// activate the xterm mouse support
if ( mouse_support )
return;
FTerm::putstring (CSI "?1001s" // save old highlight mouse tracking
CSI "?1000h" // enable x11 mouse tracking
CSI "?1002h" // enable cell motion mouse tracking
CSI "?1015h" // enable urxvt mouse mode
CSI "?1006h"); // enable SGR mouse mode
std::fflush(stdout);
mouse_support = true;
}
//----------------------------------------------------------------------
void FTermXTerminal::disableXTermMouse()
{
// deactivate the xterm mouse support
if ( ! mouse_support )
return;
FTerm::putstring (CSI "?1006l" // disable SGR mouse mode
CSI "?1015l" // disable urxvt mouse mode
CSI "?1002l" // disable cell motion mouse tracking
CSI "?1000l" // disable x11 mouse tracking
CSI "?1001r"); // restore old highlight mouse tracking
std::fflush(stdout);
mouse_support = false;
}
//----------------------------------------------------------------------
void FTermXTerminal::enableXTermMetaSendsESC()
{
// activate the xterm meta key sends escape prefix
if ( meta_sends_esc )
return;
FTerm::putstring (CSI "?1036s" // save meta key sends escape
CSI "?1036h"); // enable meta key sends escape
std::fflush(stdout);
meta_sends_esc = true;
}
//----------------------------------------------------------------------
void FTermXTerminal::disableXTermMetaSendsESC()
{
// deactivate the xterm meta key sends escape prefix
if ( ! meta_sends_esc )
return;
FTerm::putstring (CSI "?1036r"); // restore meta key sends escape
std::fflush(stdout);
meta_sends_esc = false;
}

View File

@ -33,7 +33,6 @@
static FVTerm* init_object = 0; static FVTerm* init_object = 0;
// static class attributes // static class attributes
bool FVTerm::hidden_cursor;
bool FVTerm::terminal_update_complete; bool FVTerm::terminal_update_complete;
bool FVTerm::terminal_update_pending; bool FVTerm::terminal_update_pending;
bool FVTerm::force_terminal_update; bool FVTerm::force_terminal_update;
@ -131,46 +130,16 @@ void FVTerm::setTermXY (register int x, register int y)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FVTerm::hideCursor (bool on) void FVTerm::hideCursor (bool on)
{ {
// Hides or shows the input cursor on the terminal // Hides or shows the input cursor on the terminal
if ( on == hidden_cursor )
return hidden_cursor;
if ( on ) char* visibility_str = cursorsVisibility (on);
{
char* hide_str = disableCursor();
if ( hide_str ) if ( visibility_str )
{ appendOutputBuffer(visibility_str);
appendOutputBuffer (hide_str);
hidden_cursor = true; // global
}
}
else
{
char* show_str = enableCursor();
if ( show_str )
{
appendOutputBuffer (show_str);
hidden_cursor = false;
}
}
flush_out(); flush_out();
#if defined(__linux__)
if ( ! hidden_cursor && isLinuxTerm() )
setLinuxConsoleCursorStyle (getLinuxConsoleCursorStyle(), false);
#endif
#if defined(__FreeBSD__) || defined(__DragonFly__)
if ( ! hidden_cursor )
setFreeBSDConsoleCursorStyle (getFreeBSDConsoleCursorStyle(), false);
#endif
return hidden_cursor;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -713,43 +682,6 @@ FVTerm::term_area* FVTerm::getPrintArea()
return vdesktop; return vdesktop;
} }
//----------------------------------------------------------------------
void FVTerm::setInsertCursorStyle (bool on)
{
if ( on )
{
setXTermCursorStyle(fc::blinking_underline);
setKDECursor(fc::UnderlineCursor);
#if defined(__linux__)
setLinuxConsoleCursorStyle (fc::underscore_cursor, isCursorHidden());
#endif
#if defined(__FreeBSD__) || defined(__DragonFly__)
setFreeBSDConsoleCursorStyle (fc::destructive_cursor, isCursorHidden());
#endif
if ( isUrxvtTerminal() )
setXTermCursorColor("rgb:ffff/ffff/ffff");
}
else
{
setXTermCursorStyle(fc::steady_block);
setKDECursor(fc::BlockCursor);
#if defined(__linux__)
setLinuxConsoleCursorStyle (fc::full_block_cursor, isCursorHidden());
#endif
#if defined(__FreeBSD__) || defined(__DragonFly__)
setFreeBSDConsoleCursorStyle (fc::normal_cursor, isCursorHidden());
#endif
if ( isUrxvtTerminal() )
setXTermCursorColor("rgb:eeee/0000/0000");
}
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::createArea ( const FRect& r void FVTerm::createArea ( const FRect& r
, const FPoint& p , const FPoint& p
@ -2134,7 +2066,6 @@ void FVTerm::init()
} }
// Preset to false // Preset to false
hidden_cursor = \
terminal_update_pending = \ terminal_update_pending = \
force_terminal_update = \ force_terminal_update = \
stop_terminal_updates = false; stop_terminal_updates = false;

View File

@ -1160,21 +1160,8 @@ void FWidget::show()
if ( ! init_desktop ) if ( ! init_desktop )
{ {
#if defined(__linux__) // Sets the initial screen settings
// Important: Do not use setNewFont() or setVGAFont() after initScreenSettings();
// the console character mapping has been initialized
initLinuxConsoleCharMap();
#endif
#if defined(__FreeBSD__) || defined(__DragonFly__)
initFreeBSDConsoleCharMap();
#endif
// set xterm underline cursor
setXTermCursorStyle(fc::blinking_underline);
// set xterm color settings to defaults
setXTermDefaults();
// draw the vdesktop // draw the vdesktop
FWidget* r = getRootWidget(); FWidget* r = getRootWidget();

View File

@ -150,8 +150,8 @@ void FStringTest::tearDown()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FStringTest::classNameTest() void FStringTest::classNameTest()
{ {
FString s; FString str;
const char* const classname = s.getClassName(); const char* const classname = str.getClassName();
CPPUNIT_ASSERT ( std::strcmp(classname, "FString") == 0 ); CPPUNIT_ASSERT ( std::strcmp(classname, "FString") == 0 );
} }
@ -1379,7 +1379,7 @@ void FStringTest::insertTest()
void FStringTest::replaceTest() void FStringTest::replaceTest()
{ {
const FString str = "Look behind you, a three-headed monkey!"; const FString str = "Look behind you, a three-headed monkey!";
FString s = str; FString s1 = str;
const FString from1 = "three"; const FString from1 = "three";
const std::wstring from2 = L"three"; const std::wstring from2 = L"three";
const wchar_t from3[] = L"three"; const wchar_t from3[] = L"three";
@ -1395,184 +1395,184 @@ void FStringTest::replaceTest()
const wchar_t to6 = '3'; const wchar_t to6 = '3';
const char to7 = '3'; const char to7 = '3';
CPPUNIT_ASSERT ( s.replace(from1, to1) CPPUNIT_ASSERT ( s1.replace(from1, to1)
== "Look behind you, a 3-headed monkey!" ); == "Look behind you, a 3-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from1, to2) CPPUNIT_ASSERT ( s1.replace(from1, to2)
== "Look behind you, a 3-headed monkey!" ); == "Look behind you, a 3-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from1, to3) CPPUNIT_ASSERT ( s1.replace(from1, to3)
== "Look behind you, a 3-headed monkey!" ); == "Look behind you, a 3-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from1, to4) CPPUNIT_ASSERT ( s1.replace(from1, to4)
== "Look behind you, a 3-headed monkey!" ); == "Look behind you, a 3-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from1, to5) CPPUNIT_ASSERT ( s1.replace(from1, to5)
== "Look behind you, a 3-headed monkey!" ); == "Look behind you, a 3-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from1, to6) CPPUNIT_ASSERT ( s1.replace(from1, to6)
== "Look behind you, a 3-headed monkey!" ); == "Look behind you, a 3-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from1, to7) CPPUNIT_ASSERT ( s1.replace(from1, to7)
== "Look behind you, a 3-headed monkey!" ); == "Look behind you, a 3-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from2, to1) CPPUNIT_ASSERT ( s1.replace(from2, to1)
== "Look behind you, a 3-headed monkey!" ); == "Look behind you, a 3-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from2, to2) CPPUNIT_ASSERT ( s1.replace(from2, to2)
== "Look behind you, a 3-headed monkey!" ); == "Look behind you, a 3-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from2, to3) CPPUNIT_ASSERT ( s1.replace(from2, to3)
== "Look behind you, a 3-headed monkey!" ); == "Look behind you, a 3-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from2, to4) CPPUNIT_ASSERT ( s1.replace(from2, to4)
== "Look behind you, a 3-headed monkey!" ); == "Look behind you, a 3-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from2, to5) CPPUNIT_ASSERT ( s1.replace(from2, to5)
== "Look behind you, a 3-headed monkey!" ); == "Look behind you, a 3-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from2, to6) CPPUNIT_ASSERT ( s1.replace(from2, to6)
== "Look behind you, a 3-headed monkey!" ); == "Look behind you, a 3-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from2, to7) CPPUNIT_ASSERT ( s1.replace(from2, to7)
== "Look behind you, a 3-headed monkey!" ); == "Look behind you, a 3-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from3, to1) CPPUNIT_ASSERT ( s1.replace(from3, to1)
== "Look behind you, a 3-headed monkey!" ); == "Look behind you, a 3-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from3, to2) CPPUNIT_ASSERT ( s1.replace(from3, to2)
== "Look behind you, a 3-headed monkey!" ); == "Look behind you, a 3-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from3, to3) CPPUNIT_ASSERT ( s1.replace(from3, to3)
== "Look behind you, a 3-headed monkey!" ); == "Look behind you, a 3-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from3, to4) CPPUNIT_ASSERT ( s1.replace(from3, to4)
== "Look behind you, a 3-headed monkey!" ); == "Look behind you, a 3-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from3, to5) CPPUNIT_ASSERT ( s1.replace(from3, to5)
== "Look behind you, a 3-headed monkey!" ); == "Look behind you, a 3-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from3, to6) CPPUNIT_ASSERT ( s1.replace(from3, to6)
== "Look behind you, a 3-headed monkey!" ); == "Look behind you, a 3-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from3, to7) CPPUNIT_ASSERT ( s1.replace(from3, to7)
== "Look behind you, a 3-headed monkey!" ); == "Look behind you, a 3-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from4, to1) CPPUNIT_ASSERT ( s1.replace(from4, to1)
== "Look behind you, a 3-headed monkey!" ); == "Look behind you, a 3-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from4, to2) CPPUNIT_ASSERT ( s1.replace(from4, to2)
== "Look behind you, a 3-headed monkey!" ); == "Look behind you, a 3-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from4, to3) CPPUNIT_ASSERT ( s1.replace(from4, to3)
== "Look behind you, a 3-headed monkey!" ); == "Look behind you, a 3-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from4, to4) CPPUNIT_ASSERT ( s1.replace(from4, to4)
== "Look behind you, a 3-headed monkey!" ); == "Look behind you, a 3-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from4, to5) CPPUNIT_ASSERT ( s1.replace(from4, to5)
== "Look behind you, a 3-headed monkey!" ); == "Look behind you, a 3-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from4, to6) CPPUNIT_ASSERT ( s1.replace(from4, to6)
== "Look behind you, a 3-headed monkey!" ); == "Look behind you, a 3-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from4, to7) CPPUNIT_ASSERT ( s1.replace(from4, to7)
== "Look behind you, a 3-headed monkey!" ); == "Look behind you, a 3-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from5, to1) CPPUNIT_ASSERT ( s1.replace(from5, to1)
== "Look behind you, a 3-headed monkey!" ); == "Look behind you, a 3-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from5, to2) CPPUNIT_ASSERT ( s1.replace(from5, to2)
== "Look behind you, a 3-headed monkey!" ); == "Look behind you, a 3-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from5, to3) CPPUNIT_ASSERT ( s1.replace(from5, to3)
== "Look behind you, a 3-headed monkey!" ); == "Look behind you, a 3-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from5, to4) CPPUNIT_ASSERT ( s1.replace(from5, to4)
== "Look behind you, a 3-headed monkey!" ); == "Look behind you, a 3-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from5, to5) CPPUNIT_ASSERT ( s1.replace(from5, to5)
== "Look behind you, a 3-headed monkey!" ); == "Look behind you, a 3-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from5, to6) CPPUNIT_ASSERT ( s1.replace(from5, to6)
== "Look behind you, a 3-headed monkey!" ); == "Look behind you, a 3-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from5, to7) CPPUNIT_ASSERT ( s1.replace(from5, to7)
== "Look behind you, a 3-headed monkey!" ); == "Look behind you, a 3-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from6, to1) CPPUNIT_ASSERT ( s1.replace(from6, to1)
== "Look behind you3 a three-headed monkey!" ); == "Look behind you3 a three-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from6, to2) CPPUNIT_ASSERT ( s1.replace(from6, to2)
== "Look behind you3 a three-headed monkey!" ); == "Look behind you3 a three-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from6, to3) CPPUNIT_ASSERT ( s1.replace(from6, to3)
== "Look behind you3 a three-headed monkey!" ); == "Look behind you3 a three-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from6, to4) CPPUNIT_ASSERT ( s1.replace(from6, to4)
== "Look behind you3 a three-headed monkey!" ); == "Look behind you3 a three-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from6, to5) CPPUNIT_ASSERT ( s1.replace(from6, to5)
== "Look behind you3 a three-headed monkey!" ); == "Look behind you3 a three-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from6, to6) CPPUNIT_ASSERT ( s1.replace(from6, to6)
== "Look behind you3 a three-headed monkey!" ); == "Look behind you3 a three-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from6, to7) CPPUNIT_ASSERT ( s1.replace(from6, to7)
== "Look behind you3 a three-headed monkey!" ); == "Look behind you3 a three-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from7, to1) CPPUNIT_ASSERT ( s1.replace(from7, to1)
== "Look behind you3 a three-headed monkey!" ); == "Look behind you3 a three-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from7, to2) CPPUNIT_ASSERT ( s1.replace(from7, to2)
== "Look behind you3 a three-headed monkey!" ); == "Look behind you3 a three-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from7, to3) CPPUNIT_ASSERT ( s1.replace(from7, to3)
== "Look behind you3 a three-headed monkey!" ); == "Look behind you3 a three-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from7, to4) CPPUNIT_ASSERT ( s1.replace(from7, to4)
== "Look behind you3 a three-headed monkey!" ); == "Look behind you3 a three-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from7, to5) CPPUNIT_ASSERT ( s1.replace(from7, to5)
== "Look behind you3 a three-headed monkey!" ); == "Look behind you3 a three-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from7, to6) CPPUNIT_ASSERT ( s1.replace(from7, to6)
== "Look behind you3 a three-headed monkey!" ); == "Look behind you3 a three-headed monkey!" );
s = str; s1 = str;
CPPUNIT_ASSERT ( s.replace(from7, to7) CPPUNIT_ASSERT ( s1.replace(from7, to7)
== "Look behind you3 a three-headed monkey!" ); == "Look behind you3 a three-headed monkey!" );
s = "A big ball and a small ball"; s1 = "A big ball and a small ball";
CPPUNIT_ASSERT ( s.replace("ball", "globe") CPPUNIT_ASSERT ( s1.replace("ball", "globe")
== "A big globe and a small globe" ); == "A big globe and a small globe" );
s = "ABC"; s1 = "ABC";
FString empty; FString empty;
CPPUNIT_ASSERT ( s.replace('B', "") == "AC" ); CPPUNIT_ASSERT ( s1.replace('B', "") == "AC" );
CPPUNIT_ASSERT ( s.replace(L'B', "") == "AC" ); CPPUNIT_ASSERT ( s1.replace(L'B', "") == "AC" );
CPPUNIT_ASSERT ( s.replace(from1, empty) == "ABC" ); CPPUNIT_ASSERT ( s1.replace(from1, empty) == "ABC" );
CPPUNIT_ASSERT ( s.replace(from3, empty) == "ABC" ); CPPUNIT_ASSERT ( s1.replace(from3, empty) == "ABC" );
CPPUNIT_ASSERT ( s.replace(from5, to5) == "ABC" ); CPPUNIT_ASSERT ( s1.replace(from5, to5) == "ABC" );
CPPUNIT_ASSERT ( s.replace(empty, to1) == "ABC" ); CPPUNIT_ASSERT ( s1.replace(empty, to1) == "ABC" );
CPPUNIT_ASSERT ( s.replace(from6, empty) == "ABC" ); CPPUNIT_ASSERT ( s1.replace(from6, empty) == "ABC" );
empty = ""; empty = "";
CPPUNIT_ASSERT ( s.replace(from1, empty) == "ABC" ); CPPUNIT_ASSERT ( s1.replace(from1, empty) == "ABC" );
CPPUNIT_ASSERT ( s.replace(from3, empty) == "ABC" ); CPPUNIT_ASSERT ( s1.replace(from3, empty) == "ABC" );
CPPUNIT_ASSERT ( s.replace(from5, to5) == "ABC" ); CPPUNIT_ASSERT ( s1.replace(from5, to5) == "ABC" );
CPPUNIT_ASSERT ( s.replace(empty, to1) == "ABC" ); CPPUNIT_ASSERT ( s1.replace(empty, to1) == "ABC" );
CPPUNIT_ASSERT ( s.replace(from6, empty) == "ABC" ); CPPUNIT_ASSERT ( s1.replace(from6, empty) == "ABC" );
s.clear(); s1.clear();
CPPUNIT_ASSERT ( s.replace(from1, to1).isNull() ); CPPUNIT_ASSERT ( s1.replace(from1, to1).isNull() );
CPPUNIT_ASSERT ( s.replace(from1, to1).isEmpty() ); CPPUNIT_ASSERT ( s1.replace(from1, to1).isEmpty() );
CPPUNIT_ASSERT ( s.replace(from6, to1).isNull() ); CPPUNIT_ASSERT ( s1.replace(from6, to1).isNull() );
CPPUNIT_ASSERT ( s.replace(from6, to1).isEmpty() ); CPPUNIT_ASSERT ( s1.replace(from6, to1).isEmpty() );
CPPUNIT_ASSERT ( s.replace(from5, to5).isNull() ); CPPUNIT_ASSERT ( s1.replace(from5, to5).isNull() );
CPPUNIT_ASSERT ( s.replace(from5, to5).isEmpty() ); CPPUNIT_ASSERT ( s1.replace(from5, to5).isEmpty() );
CPPUNIT_ASSERT ( s.replace(from7, to7).isNull() ); CPPUNIT_ASSERT ( s1.replace(from7, to7).isNull() );
CPPUNIT_ASSERT ( s.replace(from7, to7).isEmpty() ); CPPUNIT_ASSERT ( s1.replace(from7, to7).isEmpty() );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------