Some small code splits
This commit is contained in:
parent
0b51df32b5
commit
ef21076bbd
|
@ -1,5 +1,6 @@
|
|||
2018-10-08 Markus Gans <guru.mail@muenster.de>
|
||||
* Move all termcap code into FTermcap
|
||||
* Some small code splits
|
||||
|
||||
2018-10-05 Markus Gans <guru.mail@muenster.de>
|
||||
* Remove redundant program code from FString
|
||||
|
|
164
src/fterm.cpp
164
src/fterm.cpp
|
@ -166,15 +166,9 @@ bool FTerm::setVGAFont()
|
|||
if ( data->isVGAFont() )
|
||||
return data->isVGAFont();
|
||||
|
||||
if ( isGnomeTerminal()
|
||||
|| isKdeTerminal()
|
||||
|| isPuttyTerminal()
|
||||
|| isTeraTerm()
|
||||
|| isCygwinTerminal()
|
||||
|| isMinttyTerm() )
|
||||
if ( hasNoFontSettingOption() )
|
||||
return false;
|
||||
|
||||
|
||||
if ( isXTerminal() || isScreenTerm()
|
||||
|| isUrxvtTerminal() || FTermcap::osc_support )
|
||||
{
|
||||
|
@ -215,12 +209,7 @@ bool FTerm::setNewFont()
|
|||
if ( isNewFont() )
|
||||
return true;
|
||||
|
||||
if ( isGnomeTerminal()
|
||||
|| isKdeTerminal()
|
||||
|| isPuttyTerminal()
|
||||
|| isTeraTerm()
|
||||
|| isCygwinTerminal()
|
||||
|| isMinttyTerm() )
|
||||
if ( hasNoFontSettingOption() )
|
||||
return false;
|
||||
|
||||
if ( isXTerminal() || isScreenTerm()
|
||||
|
@ -1418,10 +1407,22 @@ void FTerm::init_captureFontAndTitle()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTerm::redefineColorPalette()
|
||||
inline bool FTerm::hasNoFontSettingOption()
|
||||
{
|
||||
// Redefine the color palette
|
||||
if ( isGnomeTerminal()
|
||||
|| isKdeTerminal()
|
||||
|| isPuttyTerminal()
|
||||
|| isTeraTerm()
|
||||
|| isCygwinTerminal()
|
||||
|| isMinttyTerm() )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FTerm::canChangeColorPalette()
|
||||
{
|
||||
if ( isCygwinTerminal()
|
||||
|| isKdeTerminal()
|
||||
|| isTeraTerm()
|
||||
|
@ -1430,6 +1431,17 @@ void FTerm::redefineColorPalette()
|
|||
|| isOpenBSDTerm()
|
||||
|| isSunTerminal()
|
||||
|| isAnsiTerminal() )
|
||||
return false;
|
||||
|
||||
return FTermcap::can_change_color_palette;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTerm::redefineColorPalette()
|
||||
{
|
||||
// Redefine the color palette
|
||||
|
||||
if ( ! canChangeColorPalette() )
|
||||
return;
|
||||
|
||||
resetColorMap();
|
||||
|
@ -1444,14 +1456,7 @@ void FTerm::redefineColorPalette()
|
|||
//----------------------------------------------------------------------
|
||||
void FTerm::restoreColorPalette()
|
||||
{
|
||||
if ( isCygwinTerminal()
|
||||
|| isKdeTerminal()
|
||||
|| isTeraTerm()
|
||||
|| isMltermTerminal()
|
||||
|| isNetBSDTerm()
|
||||
|| isOpenBSDTerm()
|
||||
|| isSunTerminal()
|
||||
|| isAnsiTerminal() )
|
||||
if ( ! canChangeColorPalette() )
|
||||
return;
|
||||
|
||||
// Reset screen settings
|
||||
|
@ -1509,6 +1514,11 @@ void FTerm::setOverwriteCursorStyle()
|
|||
//----------------------------------------------------------------------
|
||||
void FTerm::enableMouse()
|
||||
{
|
||||
// Enable the terminal mouse support
|
||||
|
||||
if ( ! init_values.mouse_support )
|
||||
return;
|
||||
|
||||
bool gpm_mouse = false;
|
||||
bool xterm_mouse = false;
|
||||
|
||||
|
@ -1536,12 +1546,68 @@ void FTerm::enableMouse()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTerm::disableMouse()
|
||||
inline void FTerm::disableMouse()
|
||||
{
|
||||
// Disable the terminal mouse support
|
||||
|
||||
keyboard->disableMouseSequences();
|
||||
mouse->disable();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FTerm::enableKeypad()
|
||||
{
|
||||
// Enter 'keyboard_transmit' mode
|
||||
|
||||
if ( TCAP(fc::t_keypad_xmit) )
|
||||
{
|
||||
putstring (TCAP(fc::t_keypad_xmit));
|
||||
std::fflush(stdout);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FTerm::disableKeypad()
|
||||
{
|
||||
// Leave 'keyboard_transmit' mode
|
||||
|
||||
if ( TCAP(fc::t_keypad_local) )
|
||||
{
|
||||
putstring (TCAP(fc::t_keypad_local));
|
||||
std::fflush(stdout);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FTerm::enableAlternateCharset()
|
||||
{
|
||||
// Enable alternate charset
|
||||
|
||||
if ( TCAP(fc::t_enable_acs) )
|
||||
{
|
||||
putstring (TCAP(fc::t_enable_acs));
|
||||
std::fflush(stdout);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FTerm::enableApplicationEscKey()
|
||||
{
|
||||
// switch to application escape key mode
|
||||
|
||||
if ( isMinttyTerm() )
|
||||
FTerm::putstring (CSI "?7727h");
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FTerm::disableApplicationEscKey()
|
||||
{
|
||||
// Switch to normal escape key mode
|
||||
|
||||
if ( isMinttyTerm() )
|
||||
putstring (CSI "?7727l");
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTerm::useAlternateScreenBuffer()
|
||||
{
|
||||
|
@ -1652,7 +1718,6 @@ inline void FTerm::deallocationValues()
|
|||
//----------------------------------------------------------------------
|
||||
void FTerm::init (bool disable_alt_screen)
|
||||
{
|
||||
int stdout_no = FTermios::getStdOut();
|
||||
init_term_object = this;
|
||||
|
||||
// Initialize global values for all objects
|
||||
|
@ -1672,11 +1737,7 @@ void FTerm::init (bool disable_alt_screen)
|
|||
FTermios::storeTTYsettings();
|
||||
|
||||
// Get output baud rate
|
||||
uInt baud = FTermios::getBaudRate();
|
||||
data->setBaudrate(baud);
|
||||
|
||||
if ( isatty(stdout_no) )
|
||||
opti_move->setBaudRate(int(baud));
|
||||
initBaudRate();
|
||||
|
||||
// Terminal detection
|
||||
term_detection->setTermData(data);
|
||||
|
@ -1714,32 +1775,22 @@ void FTerm::init (bool disable_alt_screen)
|
|||
init_keyboard();
|
||||
|
||||
// Enable the terminal mouse support
|
||||
if ( init_values.mouse_support )
|
||||
enableMouse();
|
||||
enableMouse();
|
||||
|
||||
// Activate meta key sends escape
|
||||
if ( isXTerminal() )
|
||||
xterm->metaSendsESC(true);
|
||||
|
||||
// switch to application escape key mode
|
||||
if ( isMinttyTerm() )
|
||||
FTerm::putstring (CSI "?7727h");
|
||||
enableApplicationEscKey();
|
||||
|
||||
// Enter 'keyboard_transmit' mode
|
||||
if ( TCAP(fc::t_keypad_xmit) )
|
||||
{
|
||||
putstring (TCAP(fc::t_keypad_xmit));
|
||||
std::fflush(stdout);
|
||||
}
|
||||
enableKeypad();
|
||||
|
||||
useAlternateScreenBuffer();
|
||||
|
||||
// Enable alternate charset
|
||||
if ( TCAP(fc::t_enable_acs) )
|
||||
{
|
||||
putstring (TCAP(fc::t_enable_acs));
|
||||
std::fflush(stdout);
|
||||
}
|
||||
enableAlternateCharset();
|
||||
|
||||
// Save the used xterm font and window title
|
||||
init_captureFontAndTitle();
|
||||
|
@ -1822,6 +1873,17 @@ void FTerm::initTermspecifics()
|
|||
init_teraterm_charmap();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTerm::initBaudRate()
|
||||
{
|
||||
int stdout_no = FTermios::getStdOut();
|
||||
uInt baud = FTermios::getBaudRate();
|
||||
data->setBaudrate(baud);
|
||||
|
||||
if ( isatty(stdout_no) )
|
||||
opti_move->setBaudRate(int(baud));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTerm::finish()
|
||||
{
|
||||
|
@ -1860,12 +1922,8 @@ void FTerm::finish()
|
|||
if ( init_values.color_change )
|
||||
restoreColorPalette();
|
||||
|
||||
if ( isMinttyTerm() )
|
||||
{
|
||||
// Switch to normal escape key mode
|
||||
putstring (CSI "?7727l");
|
||||
std::fflush(stdout);
|
||||
}
|
||||
// Switch to normal escape key mode
|
||||
disableApplicationEscKey();
|
||||
|
||||
finishOSspecifics1();
|
||||
|
||||
|
@ -1885,11 +1943,7 @@ void FTerm::finish()
|
|||
useNormalScreenBuffer();
|
||||
|
||||
// leave 'keyboard_transmit' mode
|
||||
if ( TCAP(fc::t_keypad_local) )
|
||||
{
|
||||
putstring (TCAP(fc::t_keypad_local));
|
||||
std::fflush(stdout);
|
||||
}
|
||||
disableKeypad();
|
||||
|
||||
finish_encoding();
|
||||
|
||||
|
|
|
@ -26,18 +26,19 @@ namespace finalcut
|
|||
{
|
||||
|
||||
// static class attributes
|
||||
bool FTermcap::background_color_erase = false;
|
||||
bool FTermcap::automatic_left_margin = false;
|
||||
bool FTermcap::automatic_right_margin = false;
|
||||
bool FTermcap::eat_nl_glitch = false;
|
||||
bool FTermcap::ansi_default_color = false;
|
||||
bool FTermcap::osc_support = false;
|
||||
bool FTermcap::no_utf8_acs_chars = false;
|
||||
int FTermcap::max_color = 1;
|
||||
int FTermcap::tabstop = 8;
|
||||
int FTermcap::attr_without_color = 0;
|
||||
FTermData* FTermcap::fterm_data = 0;
|
||||
FTermDetection* FTermcap::term_detection = 0;
|
||||
bool FTermcap::background_color_erase = false;
|
||||
bool FTermcap::can_change_color_palette = false;
|
||||
bool FTermcap::automatic_left_margin = false;
|
||||
bool FTermcap::automatic_right_margin = false;
|
||||
bool FTermcap::eat_nl_glitch = false;
|
||||
bool FTermcap::ansi_default_color = false;
|
||||
bool FTermcap::osc_support = false;
|
||||
bool FTermcap::no_utf8_acs_chars = false;
|
||||
int FTermcap::max_color = 1;
|
||||
int FTermcap::tabstop = 8;
|
||||
int FTermcap::attr_without_color = 0;
|
||||
FTermData* FTermcap::fterm_data = 0;
|
||||
FTermDetection* FTermcap::term_detection = 0;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -96,7 +97,11 @@ void FTermcap::termcap()
|
|||
bool color256 = term_detection->canDisplay256Colors();
|
||||
|
||||
// Open termcap file
|
||||
#if defined(__sun) && defined(__SVR4)
|
||||
char* termtype = fterm_data->getTermType();
|
||||
#else
|
||||
const char* termtype = fterm_data->getTermType();
|
||||
#endif
|
||||
terminals.push_back(termtype); // available terminal type
|
||||
|
||||
if ( color256 ) // 1st fallback if not found
|
||||
|
@ -174,6 +179,9 @@ void FTermcap::termcapBoleans()
|
|||
// Screen erased with the background color
|
||||
background_color_erase = tgetflag(C_STR("ut"));
|
||||
|
||||
// Terminal is able to redefine existing colors
|
||||
can_change_color_palette = tgetflag(C_STR("cc"));
|
||||
|
||||
// t_cursor_left wraps from column 0 to last column
|
||||
automatic_left_margin = tgetflag(C_STR("bw"));
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ void FTermcapQuirks::terminalFixup()
|
|||
}
|
||||
else if ( td->isSunTerminal() )
|
||||
{
|
||||
sun();
|
||||
sunConsole();
|
||||
}
|
||||
else if ( td->isPuttyTerminal() )
|
||||
{
|
||||
|
@ -385,7 +385,7 @@ void FTermcapQuirks::teraterm()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermcapQuirks::sun()
|
||||
void FTermcapQuirks::sunConsole()
|
||||
{
|
||||
// Sun Microsystems workstation console eat_nl_glitch fix
|
||||
FTermcap::eat_nl_glitch = true;
|
||||
|
|
|
@ -367,12 +367,19 @@ class FTerm
|
|||
static void init_utf8_without_alt_charset();
|
||||
static void init_tab_quirks();
|
||||
static void init_captureFontAndTitle();
|
||||
static bool hasNoFontSettingOption();
|
||||
static bool canChangeColorPalette();
|
||||
static void redefineColorPalette();
|
||||
static void restoreColorPalette();
|
||||
static void setInsertCursorStyle();
|
||||
static void setOverwriteCursorStyle();
|
||||
static void enableMouse();
|
||||
static void disableMouse();
|
||||
static void enableApplicationEscKey();
|
||||
static void disableApplicationEscKey();
|
||||
static void enableKeypad();
|
||||
static void disableKeypad();
|
||||
static void enableAlternateCharset();
|
||||
static void useAlternateScreenBuffer();
|
||||
static void useNormalScreenBuffer();
|
||||
void allocationValues();
|
||||
|
@ -380,6 +387,7 @@ class FTerm
|
|||
void init (bool);
|
||||
void initOSspecifics();
|
||||
void initTermspecifics();
|
||||
void initBaudRate();
|
||||
void finish();
|
||||
void finishOSspecifics1();
|
||||
void finish_encoding();
|
||||
|
|
|
@ -109,6 +109,7 @@ class FTermcap
|
|||
|
||||
// Data Members
|
||||
static bool background_color_erase;
|
||||
static bool can_change_color_palette;
|
||||
static bool automatic_left_margin;
|
||||
static bool automatic_right_margin;
|
||||
static bool eat_nl_glitch;
|
||||
|
|
|
@ -82,7 +82,7 @@ class FTermcapQuirks
|
|||
static void vte();
|
||||
static void putty();
|
||||
static void teraterm();
|
||||
static void sun();
|
||||
static void sunConsole();
|
||||
static void screen();
|
||||
static void general();
|
||||
|
||||
|
|
Loading…
Reference in New Issue