Use the Singleton design pattern to get a single object instance via FTerm

This commit is contained in:
Markus Gans 2019-05-27 00:50:11 +02:00
parent 75ec596323
commit 22e47adbcb
31 changed files with 463 additions and 320 deletions

View File

@ -1,3 +1,7 @@
2019-05-27 Markus Gans <guru.mail@muenster.de>
* Use the Singleton design pattern to get a single object instance
via FTerm
2019-05-17 Markus Gans <guru.mail@muenster.de>
* Move system calls to the new class FSystem

View File

@ -38,7 +38,7 @@ void tcapString (const std::string&, const char[]);
void debug (finalcut::FApplication&);
void booleans();
void numeric();
void string(finalcut::FTermcap::tcap_map*&);
void string();
//----------------------------------------------------------------------
@ -291,15 +291,17 @@ void numeric()
}
//----------------------------------------------------------------------
void string(finalcut::FTermcap::tcap_map*& tcap)
void string()
{
std::cout << "\r\n[String]\r\n";
finalcut::FTermcap::tcap_map (&tcap_strings)[] \
= finalcut::FTermcap::strings;
for (int n = 0; n <= data::getNumberOfItems(); n++ )
{
const std::string name = data::strings[n].name;
const fc::termcaps cap = data::strings[n].cap;
tcapString (name, tcap[cap].string);
tcapString (name, tcap_strings[cap].string);
}
}
@ -314,9 +316,6 @@ int main (int argc, char* argv[])
// Pointer to the global virtual terminal object
terminal = static_cast<finalcut::FVTerm*>(&TermApp);
finalcut::FTermcap::tcap_map* tcap;
tcap = finalcut::FTermcap::getTermcapMap();
std::cout << "--------\r\nFTermcap\r\n--------\r\n\n";
std::cout << "Terminal: " << TermApp.getTermType() << "\r\n";
@ -324,5 +323,5 @@ int main (int argc, char* argv[])
booleans();
numeric();
string(tcap);
string();
}

View File

@ -51,6 +51,7 @@ libfinal_la_SOURCES = \
ftermfreebsd.cpp \
ftermopenbsd.cpp \
ftermlinux.cpp \
ftermdebugdata.cpp \
ftermdetection.cpp \
ftermios.cpp \
fterm.cpp \

View File

@ -50,6 +50,7 @@ INCLUDE_HEADERS = \
ftermcap.h \
fterm.h \
ftermdata.h \
ftermdebugdata.h \
ftermios.h \
ftermdetection.h \
ftermcapquirks.h \
@ -114,6 +115,7 @@ OBJS = \
fkeyboard.o \
ftermcap.o \
fterm.o \
ftermdebugdata.o \
ftermios.o \
ftermdetection.o \
ftermcapquirks.o \

View File

@ -50,6 +50,7 @@ INCLUDE_HEADERS = \
ftermcap.h \
fterm.h \
ftermdata.h \
ftermdebugdata.h \
ftermios.h \
ftermdetection.h \
ftermcapquirks.h \
@ -114,6 +115,7 @@ OBJS = \
fkeyboard.o \
ftermcap.o \
fterm.o \
ftermdebugdata.o \
ftermios.o \
ftermdetection.o \
ftermcapquirks.o \

View File

@ -3,7 +3,7 @@
* *
* This file is part of the Final Cut widget toolkit *
* *
* Copyright 2013-2018 Markus Gans *
* Copyright 2013-2019 Markus Gans *
* *
* The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
@ -362,7 +362,7 @@ void FApplication::closeConfirmationDialog (FWidget* w, FCloseEvent* ev)
void FApplication::init (uInt64 key_time, uInt64 dblclick_time)
{
// Initialize keyboard
keyboard = FVTerm::getKeyboard();
keyboard = FVTerm::getFKeyboard();
// Set the keyboard keypress timeout
if ( keyboard )
@ -377,7 +377,7 @@ void FApplication::init (uInt64 key_time, uInt64 dblclick_time)
}
// Initialize mouse control
mouse = FVTerm::getMouseControl();
mouse = FVTerm::getFMouseControl();
// Set stdin number for a gpm-mouse
if ( mouse )

View File

@ -3,7 +3,7 @@
* *
* This file is part of the Final Cut widget toolkit *
* *
* Copyright 2018 Markus Gans *
* Copyright 2018-2019 Markus Gans *
* *
* The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
@ -30,6 +30,7 @@
#include "final/fkeyboard.h"
#include "final/fkey_map.h"
#include "final/fterm.h"
#include "final/ftermios.h"
namespace finalcut
@ -112,6 +113,14 @@ void FKeyboard::setTermcapMap (fc::fkeymap* keymap)
key_map = keymap;
}
//----------------------------------------------------------------------
void FKeyboard::init()
{
#if defined(__linux__)
linux = FTerm::getFTermLinux();
#endif
}
//----------------------------------------------------------------------
bool& FKeyboard::unprocessedInput()
{

View File

@ -558,7 +558,7 @@ int FMenu::adjustX (int x_pos)
// Is menu outside on the right of the screen?
if ( x_pos + int(max_item_width) >= int(getDesktopWidth() - 1) )
{
x_pos = int(getDesktopWidth() - max_item_width + 1);
x_pos = int(getDesktopWidth() - max_item_width - 1);
// Menu to large for the screen
if ( x_pos < 1 )
x_pos = 1;

View File

@ -44,7 +44,6 @@ int (*FTerm::Fputchar)(int);
FTerm::initializationValues FTerm::init_values;
FTermData* FTerm::data = nullptr;
FSystem* FTerm::fsys = nullptr;
FTermcap::tcap_map* FTerm::tcap = nullptr;
FOptiMove* FTerm::opti_move = nullptr;
FOptiAttr* FTerm::opti_attr = nullptr;
FTermDetection* FTerm::term_detection = nullptr;
@ -338,6 +337,9 @@ bool FTerm::setOldFont()
//----------------------------------------------------------------------
int FTerm::openConsole()
{
if ( ! data )
data = FTerm::getFTermData();
int fd = data->getTTYFileDescriptor();
const char* termfilename = data->getTermFileName();
@ -373,6 +375,9 @@ int FTerm::openConsole()
//----------------------------------------------------------------------
int FTerm::closeConsole()
{
if ( ! data )
data = FTerm::getFTermData();
int fd = data->getTTYFileDescriptor();
int ret = -1;
@ -490,6 +495,9 @@ void FTerm::detectTermSize()
{
// Detect the terminal width and height
if ( ! data )
data = FTerm::getFTermData();
struct winsize win_size;
bool close_after_detect = false;
int fd = data->getTTYFileDescriptor();
@ -958,14 +966,13 @@ void FTerm::init_global_values (bool disable_alt_screen)
data->useAlternateScreen(! disable_alt_screen);
// Initialize xterm object
xterm->setFTermDetection(term_detection);
xterm->init();
if ( ! init_values.terminal_detection )
term_detection->setTerminalDetection (false);
#if DEBUG
debug_data->setFTermDetection(term_detection);
debug_data->setFTermData(data);
debug_data->init();
#endif
}
@ -1182,9 +1189,7 @@ void FTerm::init_teraterm_charmap()
//----------------------------------------------------------------------
void FTerm::init_keyboard()
{
#if defined(__linux__)
keyboard->setFTermLinux (linux);
#endif
keyboard->init();
}
//----------------------------------------------------------------------
@ -1192,13 +1197,7 @@ void FTerm::init_termcap()
{
// Initialize the terminal capabilities
FTermcap termcap;
termcap.setFTermData(data);
termcap.setFTermDetection(term_detection);
termcap.init();
// Share the terminal capabilities
tcap = termcap.getTermcapMap();
FTermcap::init();
}
//----------------------------------------------------------------------
@ -1207,8 +1206,6 @@ void FTerm::init_quirks()
// Initialize terminal quirks
FTermcapQuirks quirks;
quirks.setFTermData (data);
quirks.setFTermDetection (term_detection);
quirks.terminalFixup(); // Fix terminal quirks
}
@ -1837,8 +1834,6 @@ void FTerm::init (bool disable_alt_screen)
initBaudRate();
// Terminal detection
term_detection->setFTermData(data);
term_detection->setFSystem(fsys);
term_detection->detect();
setTermType (term_detection->getTermType());
@ -1927,9 +1922,6 @@ void FTerm::init (bool disable_alt_screen)
void FTerm::initOSspecifics()
{
#if defined(__linux__)
linux->setFTermData(data);
linux->setFSystem(fsys);
linux->setFTermDetection(term_detection);
linux->init(); // Initialize Linux console
#if DEBUG
@ -1939,8 +1931,6 @@ void FTerm::initOSspecifics()
#endif // defined(__linux__)
#if defined(__FreeBSD__) || defined(__DragonFly__)
freebsd->setFSystem(fsys);
if ( init_values.meta_sends_escape )
freebsd->enableMetaSendsEscape();
else
@ -1953,8 +1943,6 @@ void FTerm::initOSspecifics()
freebsd->init(); // Initialize BSD console
#elif defined(__NetBSD__) || defined(__OpenBSD__)
openbsd->setFSystem(fsys);
if ( init_values.meta_sends_escape )
openbsd->enableMetaSendsEscape();
else

View File

@ -3,7 +3,7 @@
* *
* This file is part of the Final Cut widget toolkit *
* *
* Copyright 2015-2018 Markus Gans *
* Copyright 2015-2019 Markus Gans *
* *
* The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
@ -24,6 +24,7 @@
#include <string>
#include <vector>
#include "final/fterm.h"
#include "final/ftermcap.h"
namespace finalcut
@ -59,21 +60,11 @@ FTermDetection* FTermcap::term_detection = nullptr;
*/
// public methods of FTermcap
//----------------------------------------------------------------------
void FTermcap::setFTermData (FTermData* data)
{
fterm_data = data;
}
//----------------------------------------------------------------------
void FTermcap::setFTermDetection (FTermDetection* td)
{
term_detection = td;
}
//----------------------------------------------------------------------
void FTermcap::init()
{
fterm_data = FTerm::getFTermData();
term_detection = FTerm::getFTermDetection();
termcap();
}
@ -225,8 +216,8 @@ void FTermcap::termcapStrings (char*& buffer)
// Get termcap strings
// Read termcap output strings
for (std::size_t i = 0; tcap[i].tname[0] != 0; i++)
tcap[i].string = tgetstr(tcap[i].tname, &buffer);
for (std::size_t i = 0; strings[i].tname[0] != 0; i++)
strings[i].string = tgetstr(strings[i].tname, &buffer);
}
//----------------------------------------------------------------------
@ -326,7 +317,7 @@ void FTermcap::termcapKeysVt100 (char*& buffer)
// private Data Member of FTermcap - termcap capabilities
//----------------------------------------------------------------------
FTermcap::tcap_map FTermcap::tcap[] =
FTermcap::tcap_map FTermcap::strings[] =
{
// .------------- term string
// | .-------- Tcap-code

View File

@ -28,7 +28,6 @@ namespace finalcut
{
// static class attributes
FTermcap::tcap_map* FTermcapQuirks::tcap = nullptr;
FTermData* FTermcapQuirks::fterm_data = nullptr;
FTermDetection* FTermcapQuirks::term_detection = nullptr;
@ -40,9 +39,7 @@ FTermDetection* FTermcapQuirks::term_detection = nullptr;
// constructors and destructor
//----------------------------------------------------------------------
FTermcapQuirks::FTermcapQuirks()
{
tcap = FTermcap::getTermcapMap();
}
{ }
//----------------------------------------------------------------------
FTermcapQuirks::~FTermcapQuirks() // destructor
@ -51,22 +48,10 @@ FTermcapQuirks::~FTermcapQuirks() // destructor
// public methods of FTermcapQuirks
//----------------------------------------------------------------------
void FTermcapQuirks::setFTermData (FTermData* data)
{
fterm_data = data;
}
//----------------------------------------------------------------------
void FTermcapQuirks::setFTermDetection (FTermDetection* td)
{
term_detection = td;
}
// private methods of FTermcapQuirks
//----------------------------------------------------------------------
void FTermcapQuirks::terminalFixup()
{
fterm_data = FTerm::getFTermData();
term_detection = FTerm::getFTermDetection();
auto& td = term_detection;
if ( td->isCygwinTerminal() )
@ -118,8 +103,10 @@ void FTermcapQuirks::terminalFixup()
ecma48();
}
#if defined(__FreeBSD__) || defined(__DragonFly__)
// private methods of FTermcapQuirks
//----------------------------------------------------------------------
#if defined(__FreeBSD__) || defined(__DragonFly__)
void FTermcapQuirks::freebsd()
{
// FreeBSD console fixes

48
src/ftermdebugdata.cpp Normal file
View File

@ -0,0 +1,48 @@
/***********************************************************************
* ftermdebugdata.cpp - Debug data class for FTerm *
* *
* This file is part of the Final Cut widget toolkit *
* *
* Copyright 2019 Markus Gans *
* *
* The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
* 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/ftermdata.h"
#include "final/ftermdetection.h"
#include "final/ftermdebugdata.h"
namespace finalcut
{
// static class attributes
FTermData* FTermDebugData::data = nullptr;
FTermDetection* FTermDebugData::term_detection = nullptr;
//----------------------------------------------------------------------
// class FClassName
//----------------------------------------------------------------------
// public methods of FClassName
//----------------------------------------------------------------------
void FTermDebugData::init()
{
data = FTerm::getFTermData();
term_detection = FTerm::getFTermDetection();
}
} // namespace finalcut

View File

@ -85,18 +85,6 @@ FTermDetection::~FTermDetection() // destructor
// public methods of FTermDetection
//----------------------------------------------------------------------
void FTermDetection::setFTermData (FTermData* data)
{
fterm_data = data;
}
//----------------------------------------------------------------------
void FTermDetection::setFSystem (FSystem* fsys)
{
fsystem = fsys;
}
//----------------------------------------------------------------------
void FTermDetection::setTtyTypeFileName (char ttytype_filename[])
{
@ -110,6 +98,8 @@ void FTermDetection::setTtyTypeFileName (char ttytype_filename[])
//----------------------------------------------------------------------
void FTermDetection::detect()
{
fterm_data = FTerm::getFTermData();
fsystem = FTerm::getFSystem();
deallocation();
// Set the variable 'termtype' to the predefined type of the terminal

View File

@ -85,6 +85,8 @@ void FTermFreeBSD::init()
if ( ! isFreeBSDConsole() )
return;
fsystem = FTerm::getFSystem();
if ( meta_sends_escape )
{
// save current left alt key mapping

View File

@ -137,7 +137,7 @@ bool FTermLinux::isLinuxConsole()
// Check if it's a Linux console
if ( ! fsystem )
return false;
fsystem = FTerm::getFSystem();
char arg = 0;
int fd_tty = FTerm::getTTYFileDescriptor();
@ -153,6 +153,9 @@ void FTermLinux::init()
{
// initialize Linux console
fterm_data = FTerm::getFTermData();
fsystem = FTerm::getFSystem();
term_detection = FTerm::getFTermDetection();
screen_unicode_map.entries = nullptr;
screen_font.data = nullptr;
@ -480,7 +483,7 @@ int FTermLinux::getFramebuffer_bpp()
struct fb_fix_screeninfo fb_fix;
if ( ! fsystem )
return -1;
fsystem = FTerm::getFSystem();
if ( (fd = fsystem->open(fb, O_RDWR)) < 0 )
{
@ -737,7 +740,7 @@ inline uInt16 FTermLinux::getInputStatusRegisterOne()
// Gets the VGA input-status-register-1
if ( ! fsystem )
return 0x3da;
fsystem = FTerm::getFSystem();
// Miscellaneous output (read port)
static constexpr uInt16 misc_read = 0x3cc;
@ -754,7 +757,7 @@ uChar FTermLinux::readAttributeController (uChar index)
// Reads a byte from the attribute controller from a given index
if ( ! fsystem )
return 0;
fsystem = FTerm::getFSystem();
uChar res;
// Attribute controller (write port)
@ -782,7 +785,7 @@ void FTermLinux::writeAttributeController (uChar index, uChar data)
// Writes a byte from the attribute controller from a given index
if ( ! fsystem )
return;
fsystem = FTerm::getFSystem();
// Attribute controller (write port)
static constexpr uInt16 attrib_cntlr_write = 0x3c0;
@ -822,7 +825,7 @@ int FTermLinux::setBlinkAsIntensity (bool enable)
// That permits 16 colors for background
if ( ! fsystem )
return -1;
fsystem = FTerm::getFSystem();
int fd_tty = FTerm::getTTYFileDescriptor();
@ -891,7 +894,7 @@ bool FTermLinux::resetVGAPalette()
// Reset the vga color map
if ( ! fsystem )
return false;
fsystem = FTerm::getFSystem();
if ( has_saved_palette )
{

View File

@ -61,6 +61,8 @@ void FTermOpenBSD::init()
if ( ! isBSDConsole() )
return;
fsystem = FTerm::getFSystem();
if ( meta_sends_escape )
{
// save current left alt key mapping

View File

@ -41,7 +41,6 @@ const FString* FTermXTerminal::cursor_color = nullptr;
const FString* FTermXTerminal::mouse_foreground_color = nullptr;
const FString* FTermXTerminal::mouse_background_color = nullptr;
const FString* FTermXTerminal::highlight_background_color = nullptr;
FTermcap::tcap_map* FTermXTerminal::tcap = nullptr;
FTermDetection* FTermXTerminal::term_detection = nullptr;
fc::xtermCursorStyle FTermXTerminal::cursor_style = fc::unknown_cursor_style;
@ -58,8 +57,6 @@ FTermXTerminal::FTermXTerminal()
mouse_support = \
meta_sends_esc = \
xterm_default_colors = false;
tcap = FTermcap::getTermcapMap();
}
//----------------------------------------------------------------------
@ -229,6 +226,12 @@ void FTermXTerminal::metaSendsESC (bool enable)
disableXTermMetaSendsESC();
}
//----------------------------------------------------------------------
void FTermXTerminal::init()
{
term_detection = FTerm::getFTermDetection();
}
//----------------------------------------------------------------------
void FTermXTerminal::setDefaults()
{

View File

@ -54,7 +54,6 @@ FTerm* FVTerm::fterm = nullptr;
FVTerm::term_area* FVTerm::vterm = nullptr;
FVTerm::term_area* FVTerm::vdesktop = nullptr;
FVTerm::term_area* FVTerm::active_area = nullptr;
FTermcap::tcap_map* FVTerm::tcap = nullptr;
FKeyboard* FVTerm::keyboard = nullptr;
FVTerm::charData FVTerm::term_attribute;
FVTerm::charData FVTerm::next_attribute;
@ -1873,9 +1872,6 @@ void FVTerm::init (bool disable_alt_screen)
// next_attribute contains the state of the next printed character
std::memcpy (&next_attribute, &term_attribute, sizeof(next_attribute));
// Receive the terminal capabilities
tcap = FTermcap::getTermcapMap();
// Create virtual terminal
FRect term_geometry (0, 0, getColumnNumber(), getLineNumber());
createVTerm (term_geometry.getSize());
@ -1886,8 +1882,8 @@ void FVTerm::init (bool disable_alt_screen)
vdesktop->visible = true;
active_area = vdesktop;
// Initialize keyboard
keyboard = FTerm::getKeyboard();
// Get FKeyboard object
keyboard = FTerm::getFKeyboard();
// Hide the input cursor
hideCursor();

View File

@ -116,11 +116,6 @@ class FKeyboard final
void disableUTF8();
void enableMouseSequences();
void disableMouseSequences();
#if defined(__linux__)
void setFTermLinux (FTermLinux*);
#endif
void setPressCommand (FKeyboardCommand);
void setReleaseCommand (FKeyboardCommand);
void setEscPressedCommand (FKeyboardCommand);
@ -129,6 +124,7 @@ class FKeyboard final
bool isInputDataPending();
// Methods
static void init();
bool& unprocessedInput();
bool isKeyPressed();
void clearKeyBuffer();
@ -229,12 +225,6 @@ inline void FKeyboard::enableMouseSequences()
inline void FKeyboard::disableMouseSequences()
{ mouse_support = false; }
#if defined(__linux__)
//----------------------------------------------------------------------
inline void FKeyboard::setFTermLinux (FTermLinux* linux_obj)
{ linux = linux_obj; }
#endif
//----------------------------------------------------------------------
inline void FKeyboard::setPressCommand (FKeyboardCommand cmd)
{ keypressed_cmd = cmd; }

View File

@ -176,12 +176,9 @@ class FTerm final
// Accessors
virtual const char* getClassName() const;
static FKeyboard* getKeyboard();
static FMouseControl* getMouseControl();
static std::size_t getLineNumber();
static std::size_t getColumnNumber();
static const FString getKeyName (FKey);
static FOptiMove* getFOptiMove();
static int getTTYFileDescriptor();
static char* getTermType();
static char* getTermFileName();
@ -190,9 +187,24 @@ class FTerm final
initializationValues& getInitValues();
characterSub& getCharSubstitutionMap();
#if DEBUG
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(__linux__)
static FTermLinux* getFTermLinux();
#elif defined(__FreeBSD__) || defined(__DragonFly__)
static FTermFreeBSD* getFTermFreeBSD();
#elif defined(__NetBSD__) || defined(__OpenBSD__)
static FTermOpenBSD* getFTermOpenBSD();
#endif
#if DEBUG
FTermDebugData& getFTermDebugData();
#endif
@ -231,6 +243,7 @@ class FTerm final
static bool canChangeColorPalette();
// Mutators
static void setFSystem (FSystem*);
static void setTermType (const char[]);
static void setInsertCursor (bool);
static void redefineDefaultColors (bool);
@ -398,7 +411,6 @@ class FTerm final
// Data Members
static FTermData* data;
static FSystem* fsys;
static FTermcap::tcap_map* tcap;
static FOptiMove* opti_move;
static FOptiAttr* opti_attr;
static FTermDetection* term_detection;
@ -427,17 +439,9 @@ class FTerm final
inline const char* FTerm::getClassName() const
{ return "FTerm"; }
//----------------------------------------------------------------------
inline FKeyboard* FTerm::getKeyboard()
{ return ( keyboard ) ? keyboard : 0; }
//----------------------------------------------------------------------
inline FMouseControl* FTerm::getMouseControl()
{ return ( mouse ) ? mouse : 0; }
//----------------------------------------------------------------------
inline int FTerm::getTTYFileDescriptor()
{ return data->getTTYFileDescriptor(); }
{ return ( data ) ? data->getTTYFileDescriptor() : 0; }
//----------------------------------------------------------------------
inline char* FTerm::getTermType()
@ -463,18 +467,235 @@ inline FTerm::initializationValues& FTerm::getInitValues()
inline FTerm::characterSub& FTerm::getCharSubstitutionMap()
{ return data->getCharSubstitutionMap(); }
#if DEBUG
//----------------------------------------------------------------------
inline FTermData* FTerm::getFTermData()
{ return data; }
{
if ( data == 0 )
{
try
{
data = new FTermData;
}
catch (const std::bad_alloc& ex)
{
std::cerr << bad_alloc_str << ex.what() << std::endl;
std::abort();
}
}
return data;
}
//----------------------------------------------------------------------
inline FSystem* FTerm::getFSystem()
{
if ( fsys == 0 )
{
try
{
fsys = new FSystemImpl;
}
catch (const std::bad_alloc& ex)
{
std::cerr << bad_alloc_str << ex.what() << std::endl;
std::abort();
}
}
return fsys;
}
//----------------------------------------------------------------------
inline FOptiMove* FTerm::getFOptiMove()
{
if ( opti_move == 0 )
{
try
{
opti_move = new FOptiMove;
}
catch (const std::bad_alloc& ex)
{
std::cerr << bad_alloc_str << ex.what() << std::endl;
std::abort();
}
}
return opti_move;
}
//----------------------------------------------------------------------
inline FOptiAttr* FTerm::getFOptiAttr()
{
if ( opti_attr == 0 )
{
try
{
opti_attr = new FOptiAttr;
}
catch (const std::bad_alloc& ex)
{
std::cerr << bad_alloc_str << ex.what() << std::endl;
std::abort();
}
}
return opti_attr;
}
//----------------------------------------------------------------------
inline FTermDetection* FTerm::getFTermDetection()
{ return term_detection; }
{
if ( term_detection == 0 )
{
try
{
term_detection = new FTermDetection;
}
catch (const std::bad_alloc& ex)
{
std::cerr << bad_alloc_str << ex.what() << std::endl;
std::abort();
}
}
return term_detection;
}
//----------------------------------------------------------------------
inline FTermXTerminal* FTerm::getFTermXTerminal()
{
if ( xterm == 0 )
{
try
{
xterm = new FTermXTerminal;
}
catch (const std::bad_alloc& ex)
{
std::cerr << bad_alloc_str << ex.what() << std::endl;
std::abort();
}
}
return xterm;
}
//----------------------------------------------------------------------
inline FKeyboard* FTerm::getFKeyboard()
{
if ( keyboard == 0 )
{
try
{
keyboard = new FKeyboard;
}
catch (const std::bad_alloc& ex)
{
std::cerr << bad_alloc_str << ex.what() << std::endl;
std::abort();
}
}
return keyboard;
}
//----------------------------------------------------------------------
inline FMouseControl* FTerm::getFMouseControl()
{
if ( mouse == 0 )
{
try
{
mouse = new FMouseControl;
}
catch (const std::bad_alloc& ex)
{
std::cerr << bad_alloc_str << ex.what() << std::endl;
std::abort();
}
}
return mouse;
}
#if defined(__linux__)
//----------------------------------------------------------------------
inline FTermLinux* FTerm::getFTermLinux()
{
if ( linux == 0 )
{
try
{
linux = new FTermLinux;
}
catch (const std::bad_alloc& ex)
{
std::cerr << bad_alloc_str << ex.what() << std::endl;
std::abort();
}
}
return linux;
}
#elif defined(__FreeBSD__) || defined(__DragonFly__)
//----------------------------------------------------------------------
inline FTermFreeBSD* FTerm::getFTermFreeBSD()
{
if ( freebsd == 0 )
{
try
{
freebsd = new FTermFreeBSD;
}
catch (const std::bad_alloc& ex)
{
std::cerr << bad_alloc_str << ex.what() << std::endl;
std::abort();
}
}
return freebsd;
}
#elif defined(__NetBSD__) || defined(__OpenBSD__)
//----------------------------------------------------------------------
inline FTermOpenBSD* FTerm::getFTermOpenBSD()
{
if ( openbsd == 0 )
{
try
{
openbsd = new FTermOpenBSD;
}
catch (const std::bad_alloc& ex)
{
std::cerr << bad_alloc_str << ex.what() << std::endl;
std::abort();
}
}
return openbsd;
}
#endif
#if DEBUG
//----------------------------------------------------------------------
inline FTermDebugData& FTerm::getFTermDebugData()
{ return *debug_data; }
{
if ( debug_data == 0 )
{
try
{
debug_data = new FTermDebugData;
}
catch (const std::bad_alloc& ex)
{
std::cerr << bad_alloc_str << ex.what() << std::endl;
std::abort();
}
}
return *debug_data;
}
#endif // DEBUG
//----------------------------------------------------------------------
@ -581,6 +802,10 @@ inline bool FTerm::hasHalfBlockCharacter()
inline bool FTerm::hasAlternateScreen()
{ return data->hasAlternateScreen(); }
//----------------------------------------------------------------------
inline void FTerm::setFSystem (FSystem* fsystem)
{ fsys = fsystem; }
//----------------------------------------------------------------------
inline bool FTerm::setUTF8()
{ return setUTF8(true); }
@ -589,10 +814,6 @@ inline bool FTerm::setUTF8()
inline bool FTerm::unsetUTF8()
{ return setUTF8(false); }
//----------------------------------------------------------------------
inline FOptiMove* FTerm::getFOptiMove()
{ return opti_move; }
//----------------------------------------------------------------------
inline void FTerm::changeTermSizeFinished()
{ data->setTermResized(false); }

View File

@ -64,7 +64,8 @@
// FTermcap string macro
#define TCAP(...) tcap[__VA_ARGS__].string
//#define TCAP(...) tcap_strings[__VA_ARGS__].string
#define TCAP(...) FTermcap::strings[__VA_ARGS__].string
namespace finalcut
{
@ -95,15 +96,6 @@ class FTermcap final
// Accessors
const char* getClassName() const;
static tcap_map* getTermcapMap()
{
return tcap;
}
// Mutator
static void setFTermData (FTermData*);
static void setFTermDetection (FTermDetection*);
// Methods
static void init();
@ -119,6 +111,7 @@ class FTermcap final
static int max_color;
static int tabstop;
static int attr_without_color;
static tcap_map strings[];
private:
// Methods
@ -132,7 +125,6 @@ class FTermcap final
static void termcapKeysVt100 (char*&);
// Data Member
static tcap_map tcap[];
static FTermData* fterm_data;
static FTermDetection* term_detection;
};

View File

@ -63,10 +63,6 @@ class FTermcapQuirks final
// Accessor
virtual const char* getClassName() const;
// Mutator
static void setFTermData (FTermData*);
static void setFTermDetection (FTermDetection*);
// Methods
static void terminalFixup();
@ -88,7 +84,6 @@ class FTermcapQuirks final
static void ecma48();
// Data Members
static FTermcap::tcap_map* tcap;
static FTermData* fterm_data;
static FTermDetection* term_detection;
};

View File

@ -38,6 +38,9 @@
namespace finalcut
{
// class forward declaration
class FTerm;
#if DEBUG
//----------------------------------------------------------------------
// class FTermDebugData
@ -67,25 +70,16 @@ class FTermDebugData final
#if defined(__linux__)
int getFramebufferBpp();
#endif
// Mutators
void setFTermDetection (FTermDetection*);
void setFTermData (FTermData*);
// Methods
static void init();
private:
// Data Members
FTermDetection* term_detection{nullptr};
FTermData* data{nullptr};
static FTermData* data;
static FTermDetection* term_detection;
};
// FTermDebugData inline functions
//----------------------------------------------------------------------
inline void FTermDebugData::setFTermDetection (FTermDetection* obj)
{ term_detection = obj; }
//----------------------------------------------------------------------
inline void FTermDebugData::setFTermData (FTermData* obj)
{ data = obj; }
//----------------------------------------------------------------------
inline const FString& FTermDebugData::getAnswerbackString()
{ return term_detection->getAnswerbackString(); }

View File

@ -154,8 +154,6 @@ class FTermDetection final
static void setScreenTerm (bool);
static void setTmuxTerm (bool);
static void setTerminalDetection (bool);
static void setFTermData (FTermData*);
static void setFSystem (FSystem*);
static void setTtyTypeFileName (char[]);
// Methods

View File

@ -83,7 +83,6 @@ class FTermFreeBSD final
static bool isFreeBSDConsole();
// Mutators
static void setFSystem (FSystem*);
static void setCursorStyle (CursorStyle, bool);
static void enableChangeCursorStyle();
static void disableChangeCursorStyle();
@ -119,10 +118,6 @@ inline const char* FTermFreeBSD::getClassName() const
//----------------------------------------------------------------------
#if defined(__FreeBSD__) || defined(__DragonFly__)
inline void FTermFreeBSD::setFSystem (FSystem* fsys)
{ fsystem = fsys; }
//----------------------------------------------------------------------
inline void FTermFreeBSD::enableChangeCursorStyle()
{ change_cursorstyle = true; }

View File

@ -88,9 +88,6 @@ class FTermLinux final
static int getFramebufferBpp();
// Mutators
static void setFTermData (FTermData*);
static void setFSystem (FSystem*);
static void setFTermDetection (FTermDetection*);
static char* setCursorStyle (fc::linuxConsoleCursorStyle, bool);
static bool setPalette (FColor, int, int, int);
static void setUTF8 (bool);
@ -206,18 +203,6 @@ inline const char* FTermLinux::getClassName() const
inline int FTermLinux::getFramebufferBpp()
{ return framebuffer_bpp; }
//----------------------------------------------------------------------
inline void FTermLinux::setFTermData (FTermData* data)
{ fterm_data = data; }
//----------------------------------------------------------------------
inline void FTermLinux::setFSystem (FSystem* fsys)
{ fsystem = fsys; }
//----------------------------------------------------------------------
inline void FTermLinux::setFTermDetection (FTermDetection* td)
{ term_detection = td; }
//----------------------------------------------------------------------
inline bool FTermLinux::hasShadowCharacter()
{ return shadow_character; }

View File

@ -75,7 +75,6 @@ class FTermOpenBSD final
static bool isBSDConsole();
// Mutators
static void setFSystem (FSystem*);
static void disableMetaSendsEscape();
static void enableMetaSendsEscape();
@ -106,10 +105,6 @@ inline const char* FTermOpenBSD::getClassName() const
//----------------------------------------------------------------------
#if defined(__NetBSD__) || defined(__OpenBSD__)
inline void FTermOpenBSD::setFSystem (FSystem* fsys)
{ fsystem = fsys; }
//----------------------------------------------------------------------
inline void FTermOpenBSD::enableMetaSendsEscape()
{ meta_sends_escape = true; }

View File

@ -60,7 +60,6 @@ class FTermXTerminal final
virtual ~FTermXTerminal();
// Mutators
static void setFTermDetection (FTermDetection*);
static void redefineDefaultColors (bool);
static void setCursorStyle (fc::xtermCursorStyle);
static void setFont (const FString&);
@ -94,6 +93,7 @@ class FTermXTerminal final
static bool hasTitle();
// Methods
static void init();
static void setDefaults();
static void resetColorMap();
static void resetForeground();
@ -150,7 +150,6 @@ class FTermXTerminal final
static const FString* mouse_foreground_color;
static const FString* mouse_background_color;
static const FString* highlight_background_color;
static FTermcap::tcap_map* tcap;
static FTermDetection* term_detection;
static fc::xtermCursorStyle cursor_style;
};
@ -161,10 +160,6 @@ class FTermXTerminal final
inline const char* FTermXTerminal::getClassName() const
{ return "FTermXTerminal"; }
//----------------------------------------------------------------------
inline void FTermXTerminal::setFTermDetection (FTermDetection* td)
{ term_detection = td; }
//----------------------------------------------------------------------
inline void FTermXTerminal::redefineDefaultColors (bool enable)
{ xterm_default_colors = enable; }

View File

@ -324,8 +324,8 @@ class FVTerm
std::size_t getLineNumber();
std::size_t getColumnNumber();
static bool charEncodable (wchar_t);
static FKeyboard* getKeyboard();
static FMouseControl* getMouseControl();
static FKeyboard* getFKeyboard();
static FMouseControl* getFMouseControl();
FTerm::initializationValues& getInitValues();
// Mutators
@ -482,7 +482,6 @@ class FVTerm
static charData s_ch; // shadow character
static charData i_ch; // inherit background character
static FPoint* term_pos; // terminal cursor position
static FTermcap::tcap_map* tcap;
static FKeyboard* keyboard;
static bool terminal_update_complete;
static bool terminal_update_pending;
@ -1076,12 +1075,12 @@ inline bool FVTerm::charEncodable (wchar_t c)
{ return FTerm::charEncodable(c); }
//----------------------------------------------------------------------
inline FKeyboard* FVTerm::getKeyboard()
{ return FTerm::getKeyboard(); }
inline FKeyboard* FVTerm::getFKeyboard()
{ return FTerm::getFKeyboard(); }
//----------------------------------------------------------------------
inline FMouseControl* FVTerm::getMouseControl()
{ return FTerm::getMouseControl(); }
inline FMouseControl* FVTerm::getFMouseControl()
{ return FTerm::getFMouseControl(); }
//----------------------------------------------------------------------
inline FTerm::initializationValues& FVTerm::getInitValues()

View File

@ -3,7 +3,7 @@
* *
* This file is part of the Final Cut widget toolkit *
* *
* Copyright 2018 Markus Gans *
* Copyright 2018-2019 Markus Gans *
* *
* The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
@ -227,20 +227,16 @@ void FTermcapQuirksTest::classNameTest()
//----------------------------------------------------------------------
void FTermcapQuirksTest::generalTest()
{
finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap();
finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapStrings();
constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1;
for (std::size_t i = 0; i < last_item; i++)
memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0]));
finalcut::FTermData data;
finalcut::FTermcap::tabstop = -1;
finalcut::FTermcap::attr_without_color = -1;
finalcut::FTermcap::can_change_color_palette = false;
finalcut::FTermcapQuirks quirks;
finalcut::FTermDetection detect;
quirks.setFTermData(&data);
quirks.setFTermDetection (&detect);
quirks.terminalFixup();
CPPUNIT_ASSERT ( finalcut::FTermcap::tabstop == 8 );
@ -294,20 +290,18 @@ void FTermcapQuirksTest::generalTest()
//----------------------------------------------------------------------
void FTermcapQuirksTest::xtermTest()
{
finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap();
finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapStrings();
constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1;
for (std::size_t i = 0; i < last_item; i++)
memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0]));
finalcut::FTermData data;
finalcut::FTermData& data = *finalcut::FTerm::getFTermData();
finalcut::FTermDetection& detect = *finalcut::FTerm::getFTermDetection();
finalcut::FTermcapQuirks quirks;
finalcut::FTermDetection detect;
finalcut::FTermcap::can_change_color_palette = false;
detect.setXTerminal (true);
data.setTermType ("xterm");
quirks.setFTermData(&data);
quirks.setFTermDetection (&detect);
quirks.terminalFixup();
CPPUNIT_ASSERT ( finalcut::FTermcap::can_change_color_palette );
@ -327,16 +321,16 @@ void FTermcapQuirksTest::xtermTest()
//----------------------------------------------------------------------
void FTermcapQuirksTest::freebsdTest()
{
finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap();
finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapStrings();
constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1;
for (std::size_t i = 0; i < last_item; i++)
memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0]));
finalcut::FTermData data;
finalcut::FTermData& data = *finalcut::FTerm::getFTermData();
finalcut::FTermDetection& detect = *finalcut::FTerm::getFTermDetection();
finalcut::FTermcap::attr_without_color = -1;
finalcut::FTermcapQuirks quirks;
finalcut::FTermDetection detect;
detect.setFreeBSDTerm (true);
data.setTermType ("xterm-16color");
quirks.setFTermData(&data);
@ -366,20 +360,18 @@ void FTermcapQuirksTest::freebsdTest()
//----------------------------------------------------------------------
void FTermcapQuirksTest::cygwinTest()
{
finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap();
finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapStrings();
constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1;
for (std::size_t i = 0; i < last_item; i++)
memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0]));
finalcut::FTermData data;
finalcut::FTermData& data = *finalcut::FTerm::getFTermData();
finalcut::FTermDetection& detect = *finalcut::FTerm::getFTermDetection();
finalcut::FTermcap::background_color_erase = false;
finalcut::FTermcapQuirks quirks;
finalcut::FTermDetection detect;
detect.setCygwinTerminal (true);
data.setTermType ("cygwin");
quirks.setFTermData(&data);
quirks.setFTermDetection (&detect);
quirks.terminalFixup();
CPPUNIT_ASSERT ( finalcut::FTermcap::background_color_erase == true );
@ -393,21 +385,19 @@ void FTermcapQuirksTest::cygwinTest()
//----------------------------------------------------------------------
void FTermcapQuirksTest::linuxTest()
{
finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap();
finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapStrings();
constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1;
for (std::size_t i = 0; i < last_item; i++)
memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0]));
finalcut::FTermData data;
finalcut::FTermData& data = *finalcut::FTerm::getFTermData();
finalcut::FTermDetection& detect = *finalcut::FTerm::getFTermDetection();
finalcut::FTermcap::max_color = 8;
finalcut::FTermcap::attr_without_color = -1;
finalcut::FTermcapQuirks quirks;
finalcut::FTermDetection detect;
detect.setLinuxTerm (true);
data.setTermType ("linux");
quirks.setFTermData(&data);
quirks.setFTermDetection (&detect);
quirks.terminalFixup();
// 8 colors
@ -467,19 +457,17 @@ void FTermcapQuirksTest::linuxTest()
//----------------------------------------------------------------------
void FTermcapQuirksTest::rxvtTest()
{
finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap();
finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapStrings();
constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1;
for (std::size_t i = 0; i < last_item; i++)
memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0]));
finalcut::FTermData data;
finalcut::FTermData& data = *finalcut::FTerm::getFTermData();
finalcut::FTermDetection& detect = *finalcut::FTerm::getFTermDetection();
finalcut::FTermcapQuirks quirks;
finalcut::FTermDetection detect;
detect.setRxvtTerminal (true);
data.setTermType ("rxvt");
quirks.setFTermData(&data);
quirks.setFTermDetection (&detect);
quirks.terminalFixup();
// rxvt
@ -510,20 +498,18 @@ void FTermcapQuirksTest::rxvtTest()
//----------------------------------------------------------------------
void FTermcapQuirksTest::vteTest()
{
finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap();
finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapStrings();
constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1;
for (std::size_t i = 0; i < last_item; i++)
memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0]));
finalcut::FTermData data;
finalcut::FTermData& data = *finalcut::FTerm::getFTermData();
finalcut::FTermDetection& detect = *finalcut::FTerm::getFTermDetection();
finalcut::FTermcap::attr_without_color = -1;
finalcut::FTermcapQuirks quirks;
finalcut::FTermDetection detect;
detect.setGnomeTerminal (true);
data.setTermType ("gnome-256color");
quirks.setFTermData(&data);
quirks.setFTermDetection (&detect);
quirks.terminalFixup();
CPPUNIT_ASSERT ( finalcut::FTermcap::attr_without_color == 0 );
@ -536,23 +522,21 @@ void FTermcapQuirksTest::vteTest()
//----------------------------------------------------------------------
void FTermcapQuirksTest::puttyTest()
{
finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap();
finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapStrings();
constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1;
for (std::size_t i = 0; i < last_item; i++)
memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0]));
finalcut::FTermData data;
finalcut::FTermData& data = *finalcut::FTerm::getFTermData();
finalcut::FTermDetection& detect = *finalcut::FTerm::getFTermDetection();
finalcut::FTermcap::background_color_erase = false;
finalcut::FTermcap::can_change_color_palette = false;
finalcut::FTermcap::osc_support = false;
finalcut::FTermcap::attr_without_color = -1;
finalcut::FTermcapQuirks quirks;
finalcut::FTermDetection detect;
detect.setPuttyTerminal (true);
data.setTermType ("putty");
quirks.setFTermData(&data);
quirks.setFTermDetection (&detect);
quirks.terminalFixup();
CPPUNIT_ASSERT ( finalcut::FTermcap::background_color_erase == true );
@ -628,20 +612,18 @@ void FTermcapQuirksTest::puttyTest()
//----------------------------------------------------------------------
void FTermcapQuirksTest::teratermTest()
{
finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap();
finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapStrings();
constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1;
for (std::size_t i = 0; i < last_item; i++)
memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0]));
finalcut::FTermData data;
finalcut::FTermData& data = *finalcut::FTerm::getFTermData();
finalcut::FTermDetection& detect = *finalcut::FTerm::getFTermDetection();
finalcut::FTermcap::eat_nl_glitch = false;
finalcut::FTermcapQuirks quirks;
finalcut::FTermDetection detect;
detect.setTeraTerm (true);
data.setTermType ("teraterm");
quirks.setFTermData(&data);
quirks.setFTermDetection (&detect);
quirks.terminalFixup();
CPPUNIT_ASSERT ( finalcut::FTermcap::eat_nl_glitch == true );
@ -660,20 +642,18 @@ void FTermcapQuirksTest::teratermTest()
//----------------------------------------------------------------------
void FTermcapQuirksTest::sunTest()
{
finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap();
finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapStrings();
constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1;
for (std::size_t i = 0; i < last_item; i++)
memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0]));
finalcut::FTermData data;
finalcut::FTermData& data = *finalcut::FTerm::getFTermData();
finalcut::FTermDetection& detect = *finalcut::FTerm::getFTermDetection();
finalcut::FTermcap::eat_nl_glitch = false;
finalcut::FTermcapQuirks quirks;
finalcut::FTermDetection detect;
detect.setSunTerminal (true);
data.setTermType ("sun-color");
quirks.setFTermData(&data);
quirks.setFTermDetection (&detect);
quirks.terminalFixup();
CPPUNIT_ASSERT ( finalcut::FTermcap::eat_nl_glitch == true );
@ -780,20 +760,18 @@ void FTermcapQuirksTest::sunTest()
//----------------------------------------------------------------------
void FTermcapQuirksTest::screenTest()
{
finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapMap();
finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::getTermcapStrings();
constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1;
for (std::size_t i = 0; i < last_item; i++)
memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0]));
finalcut::FTermData data;
finalcut::FTermData& data = *finalcut::FTerm::getFTermData();
finalcut::FTermDetection& detect = *finalcut::FTerm::getFTermDetection();
finalcut::FTermcapQuirks quirks;
finalcut::FTermDetection detect;
finalcut::FTermcap::can_change_color_palette = false;
detect.setScreenTerm (true);
data.setTermType ("screen-256color");
quirks.setFTermData(&data);
quirks.setFTermDetection (&detect);
quirks.terminalFixup();
CPPUNIT_ASSERT ( finalcut::FTermcap::can_change_color_palette );

View File

@ -3,7 +3,7 @@
* *
* This file is part of the Final Cut widget toolkit *
* *
* Copyright 2018 Markus Gans *
* Copyright 2018-2019 Markus Gans *
* *
* The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
@ -471,11 +471,10 @@ void FTermDetectionTest::classNameTest()
//----------------------------------------------------------------------
void FTermDetectionTest::ansiTest()
{
finalcut::FTermData data;
finalcut::FTermData& data = *finalcut::FTerm::getFTermData();
finalcut::FTermDetection detect;
setenv ("TERM", "ansi", 1);
data.setTermFileName(C_STR("ansi"));
detect.setFTermData(&data);
pid_t pid = forkProcess();
@ -541,10 +540,9 @@ void FTermDetectionTest::ansiTest()
//----------------------------------------------------------------------
void FTermDetectionTest::xtermTest()
{
finalcut::FTermData data;
finalcut::FTermData& data = *finalcut::FTerm::getFTermData();
finalcut::FTermDetection detect;
data.setTermFileName(C_STR("xterm"));
detect.setFTermData(&data);
detect.setTerminalDetection(true);
pid_t pid = forkProcess();
@ -603,10 +601,9 @@ void FTermDetectionTest::xtermTest()
//----------------------------------------------------------------------
void FTermDetectionTest::rxvtTest()
{
finalcut::FTermData data;
finalcut::FTermData& data = *finalcut::FTerm::getFTermData();
finalcut::FTermDetection detect;
data.setTermFileName(C_STR("rxvt-cygwin-native"));
detect.setFTermData(&data);
detect.setTerminalDetection(true);
pid_t pid = forkProcess();
@ -666,10 +663,9 @@ void FTermDetectionTest::rxvtTest()
//----------------------------------------------------------------------
void FTermDetectionTest::urxvtTest()
{
finalcut::FTermData data;
finalcut::FTermData& data = *finalcut::FTerm::getFTermData();
finalcut::FTermDetection detect;
data.setTermFileName(C_STR("rxvt-unicode-256color"));
detect.setFTermData(&data);
detect.setTerminalDetection(true);
pid_t pid = forkProcess();
@ -728,10 +724,9 @@ void FTermDetectionTest::urxvtTest()
//----------------------------------------------------------------------
void FTermDetectionTest::mltermTest()
{
finalcut::FTermData data;
finalcut::FTermData& data = *finalcut::FTerm::getFTermData();
finalcut::FTermDetection detect;
data.setTermFileName(C_STR("mlterm"));
detect.setFTermData(&data);
detect.setTerminalDetection(true);
pid_t pid = forkProcess();
@ -798,10 +793,9 @@ void FTermDetectionTest::mltermTest()
//----------------------------------------------------------------------
void FTermDetectionTest::puttyTest()
{
finalcut::FTermData data;
finalcut::FTermData& data = *finalcut::FTerm::getFTermData();
finalcut::FTermDetection detect;
data.setTermFileName(C_STR("xterm"));
detect.setFTermData(&data);
detect.setTerminalDetection(true);
pid_t pid = forkProcess();
@ -861,10 +855,9 @@ void FTermDetectionTest::puttyTest()
//----------------------------------------------------------------------
void FTermDetectionTest::kdeKonsoleTest()
{
finalcut::FTermData data;
finalcut::FTermData& data = *finalcut::FTerm::getFTermData();
finalcut::FTermDetection detect;
data.setTermFileName(C_STR("xterm-256color"));
detect.setFTermData(&data);
detect.setTerminalDetection(true);
pid_t pid = forkProcess();
@ -923,10 +916,9 @@ void FTermDetectionTest::kdeKonsoleTest()
//----------------------------------------------------------------------
void FTermDetectionTest::gnomeTerminalTest()
{
finalcut::FTermData data;
finalcut::FTermData& data = *finalcut::FTerm::getFTermData();
finalcut::FTermDetection detect;
data.setTermFileName(C_STR("xterm-256color"));
detect.setFTermData(&data);
detect.setTerminalDetection(true);
pid_t pid = forkProcess();
@ -986,10 +978,9 @@ void FTermDetectionTest::gnomeTerminalTest()
//----------------------------------------------------------------------
void FTermDetectionTest::newerVteTerminalTest()
{
finalcut::FTermData data;
finalcut::FTermData& data = *finalcut::FTerm::getFTermData();
finalcut::FTermDetection detect;
data.setTermFileName(C_STR("xterm-256color"));
detect.setFTermData(&data);
detect.setTerminalDetection(true);
pid_t pid = forkProcess();
@ -1049,10 +1040,9 @@ void FTermDetectionTest::newerVteTerminalTest()
//----------------------------------------------------------------------
void FTermDetectionTest::ktermTest()
{
finalcut::FTermData data;
finalcut::FTermData& data = *finalcut::FTerm::getFTermData();
finalcut::FTermDetection detect;
data.setTermFileName(C_STR("kterm"));
detect.setFTermData(&data);
detect.setTerminalDetection(true);
pid_t pid = forkProcess();
@ -1119,10 +1109,9 @@ void FTermDetectionTest::ktermTest()
//----------------------------------------------------------------------
void FTermDetectionTest::teraTermTest()
{
finalcut::FTermData data;
finalcut::FTermData& data = *finalcut::FTerm::getFTermData();
finalcut::FTermDetection detect;
data.setTermFileName(C_STR("xterm"));
detect.setFTermData(&data);
detect.setTerminalDetection(true);
pid_t pid = forkProcess();
@ -1182,10 +1171,9 @@ void FTermDetectionTest::teraTermTest()
//----------------------------------------------------------------------
void FTermDetectionTest::cygwinTest()
{
finalcut::FTermData data;
finalcut::FTermData& data = *finalcut::FTerm::getFTermData();
finalcut::FTermDetection detect;
data.setTermFileName(C_STR("cygwin"));
detect.setFTermData(&data);
detect.setTerminalDetection(true);
pid_t pid = forkProcess();
@ -1245,10 +1233,9 @@ void FTermDetectionTest::cygwinTest()
//----------------------------------------------------------------------
void FTermDetectionTest::minttyTest()
{
finalcut::FTermData data;
finalcut::FTermData& data = *finalcut::FTerm::getFTermData();
finalcut::FTermDetection detect;
data.setTermFileName(C_STR("xterm-256color"));
detect.setFTermData(&data);
detect.setTerminalDetection(true);
pid_t pid = forkProcess();
@ -1308,10 +1295,9 @@ void FTermDetectionTest::minttyTest()
//----------------------------------------------------------------------
void FTermDetectionTest::linuxTest()
{
finalcut::FTermData data;
finalcut::FTermData& data = *finalcut::FTerm::getFTermData();
finalcut::FTermDetection detect;
data.setTermFileName(C_STR("linux"));
detect.setFTermData(&data);
detect.setTerminalDetection(true);
pid_t pid = forkProcess();
@ -1378,10 +1364,9 @@ void FTermDetectionTest::linuxTest()
//----------------------------------------------------------------------
void FTermDetectionTest::freebsdTest()
{
finalcut::FTermData data;
finalcut::FTermData& data = *finalcut::FTerm::getFTermData();
finalcut::FTermDetection detect;
data.setTermFileName(C_STR("xterm"));
detect.setFTermData(&data);
detect.setTerminalDetection(true);
pid_t pid = forkProcess();
@ -1451,10 +1436,9 @@ void FTermDetectionTest::freebsdTest()
//----------------------------------------------------------------------
void FTermDetectionTest::netbsdTest()
{
finalcut::FTermData data;
finalcut::FTermData& data = *finalcut::FTerm::getFTermData();
finalcut::FTermDetection detect;
data.setTermFileName(C_STR("wsvt25"));
detect.setFTermData(&data);
detect.setTerminalDetection(true);
pid_t pid = forkProcess();
@ -1522,10 +1506,9 @@ void FTermDetectionTest::netbsdTest()
//----------------------------------------------------------------------
void FTermDetectionTest::openbsdTest()
{
finalcut::FTermData data;
finalcut::FTermData& data = *finalcut::FTerm::getFTermData();
finalcut::FTermDetection detect;
data.setTermFileName(C_STR("vt220"));
detect.setFTermData(&data);
detect.setTerminalDetection(true);
pid_t pid = forkProcess();
@ -1593,10 +1576,9 @@ void FTermDetectionTest::openbsdTest()
//----------------------------------------------------------------------
void FTermDetectionTest::sunTest()
{
finalcut::FTermData data;
finalcut::FTermData& data = *finalcut::FTerm::getFTermData();
finalcut::FTermDetection detect;
data.setTermFileName(C_STR("sun-color"));
detect.setFTermData(&data);
pid_t pid = forkProcess();
@ -1662,10 +1644,9 @@ void FTermDetectionTest::sunTest()
//----------------------------------------------------------------------
void FTermDetectionTest::screenTest()
{
finalcut::FTermData data;
finalcut::FTermData& data = *finalcut::FTerm::getFTermData();
finalcut::FTermDetection detect;
data.setTermFileName(C_STR("screen"));
detect.setFTermData(&data);
detect.setTerminalDetection(true);
pid_t pid = forkProcess();
@ -1731,10 +1712,9 @@ void FTermDetectionTest::screenTest()
//----------------------------------------------------------------------
void FTermDetectionTest::tmuxTest()
{
finalcut::FTermData data;
finalcut::FTermData& data = *finalcut::FTerm::getFTermData();
finalcut::FTermDetection detect;
data.setTermFileName(C_STR("screen"));
detect.setFTermData(&data);
detect.setTerminalDetection(true);
pid_t pid = forkProcess();
@ -1836,9 +1816,8 @@ void FTermDetectionTest::ttytypeTest()
ttytype << "vt100" << "\t" << "ttyp6" << std::endl;
ttytype.close();
finalcut::FTermData data;
finalcut::FTermData& data = *finalcut::FTerm::getFTermData();
finalcut::FTermDetection detect;
detect.setFTermData(&data);
detect.setTerminalDetection(true);
detect.setTtyTypeFileName(C_STR("new-root-dir/etc/ttytype"));