Some small code splits

This commit is contained in:
Markus Gans 2018-10-09 00:33:26 +02:00
parent 0b51df32b5
commit ef21076bbd
7 changed files with 142 additions and 70 deletions

View File

@ -1,5 +1,6 @@
2018-10-08 Markus Gans <guru.mail@muenster.de> 2018-10-08 Markus Gans <guru.mail@muenster.de>
* Move all termcap code into FTermcap * Move all termcap code into FTermcap
* Some small code splits
2018-10-05 Markus Gans <guru.mail@muenster.de> 2018-10-05 Markus Gans <guru.mail@muenster.de>
* Remove redundant program code from FString * Remove redundant program code from FString

View File

@ -166,15 +166,9 @@ bool FTerm::setVGAFont()
if ( data->isVGAFont() ) if ( data->isVGAFont() )
return data->isVGAFont(); return data->isVGAFont();
if ( isGnomeTerminal() if ( hasNoFontSettingOption() )
|| isKdeTerminal()
|| isPuttyTerminal()
|| isTeraTerm()
|| isCygwinTerminal()
|| isMinttyTerm() )
return false; return false;
if ( isXTerminal() || isScreenTerm() if ( isXTerminal() || isScreenTerm()
|| isUrxvtTerminal() || FTermcap::osc_support ) || isUrxvtTerminal() || FTermcap::osc_support )
{ {
@ -215,12 +209,7 @@ bool FTerm::setNewFont()
if ( isNewFont() ) if ( isNewFont() )
return true; return true;
if ( isGnomeTerminal() if ( hasNoFontSettingOption() )
|| isKdeTerminal()
|| isPuttyTerminal()
|| isTeraTerm()
|| isCygwinTerminal()
|| isMinttyTerm() )
return false; return false;
if ( isXTerminal() || isScreenTerm() 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() if ( isCygwinTerminal()
|| isKdeTerminal() || isKdeTerminal()
|| isTeraTerm() || isTeraTerm()
@ -1430,6 +1431,17 @@ void FTerm::redefineColorPalette()
|| isOpenBSDTerm() || isOpenBSDTerm()
|| isSunTerminal() || isSunTerminal()
|| isAnsiTerminal() ) || isAnsiTerminal() )
return false;
return FTermcap::can_change_color_palette;
}
//----------------------------------------------------------------------
void FTerm::redefineColorPalette()
{
// Redefine the color palette
if ( ! canChangeColorPalette() )
return; return;
resetColorMap(); resetColorMap();
@ -1444,14 +1456,7 @@ void FTerm::redefineColorPalette()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::restoreColorPalette() void FTerm::restoreColorPalette()
{ {
if ( isCygwinTerminal() if ( ! canChangeColorPalette() )
|| isKdeTerminal()
|| isTeraTerm()
|| isMltermTerminal()
|| isNetBSDTerm()
|| isOpenBSDTerm()
|| isSunTerminal()
|| isAnsiTerminal() )
return; return;
// Reset screen settings // Reset screen settings
@ -1509,6 +1514,11 @@ void FTerm::setOverwriteCursorStyle()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::enableMouse() void FTerm::enableMouse()
{ {
// Enable the terminal mouse support
if ( ! init_values.mouse_support )
return;
bool gpm_mouse = false; bool gpm_mouse = false;
bool xterm_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(); keyboard->disableMouseSequences();
mouse->disable(); 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() void FTerm::useAlternateScreenBuffer()
{ {
@ -1652,7 +1718,6 @@ inline void FTerm::deallocationValues()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::init (bool disable_alt_screen) void FTerm::init (bool disable_alt_screen)
{ {
int stdout_no = FTermios::getStdOut();
init_term_object = this; init_term_object = this;
// Initialize global values for all objects // Initialize global values for all objects
@ -1672,11 +1737,7 @@ void FTerm::init (bool disable_alt_screen)
FTermios::storeTTYsettings(); FTermios::storeTTYsettings();
// Get output baud rate // Get output baud rate
uInt baud = FTermios::getBaudRate(); initBaudRate();
data->setBaudrate(baud);
if ( isatty(stdout_no) )
opti_move->setBaudRate(int(baud));
// Terminal detection // Terminal detection
term_detection->setTermData(data); term_detection->setTermData(data);
@ -1714,32 +1775,22 @@ void FTerm::init (bool disable_alt_screen)
init_keyboard(); init_keyboard();
// Enable the terminal mouse support // Enable the terminal mouse support
if ( init_values.mouse_support ) enableMouse();
enableMouse();
// Activate meta key sends escape // Activate meta key sends escape
if ( isXTerminal() ) if ( isXTerminal() )
xterm->metaSendsESC(true); xterm->metaSendsESC(true);
// switch to application escape key mode // switch to application escape key mode
if ( isMinttyTerm() ) enableApplicationEscKey();
FTerm::putstring (CSI "?7727h");
// Enter 'keyboard_transmit' mode // Enter 'keyboard_transmit' mode
if ( TCAP(fc::t_keypad_xmit) ) enableKeypad();
{
putstring (TCAP(fc::t_keypad_xmit));
std::fflush(stdout);
}
useAlternateScreenBuffer(); useAlternateScreenBuffer();
// Enable alternate charset // Enable alternate charset
if ( TCAP(fc::t_enable_acs) ) enableAlternateCharset();
{
putstring (TCAP(fc::t_enable_acs));
std::fflush(stdout);
}
// Save the used xterm font and window title // Save the used xterm font and window title
init_captureFontAndTitle(); init_captureFontAndTitle();
@ -1822,6 +1873,17 @@ void FTerm::initTermspecifics()
init_teraterm_charmap(); 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() void FTerm::finish()
{ {
@ -1860,12 +1922,8 @@ void FTerm::finish()
if ( init_values.color_change ) if ( init_values.color_change )
restoreColorPalette(); restoreColorPalette();
if ( isMinttyTerm() ) // Switch to normal escape key mode
{ disableApplicationEscKey();
// Switch to normal escape key mode
putstring (CSI "?7727l");
std::fflush(stdout);
}
finishOSspecifics1(); finishOSspecifics1();
@ -1885,11 +1943,7 @@ void FTerm::finish()
useNormalScreenBuffer(); useNormalScreenBuffer();
// leave 'keyboard_transmit' mode // leave 'keyboard_transmit' mode
if ( TCAP(fc::t_keypad_local) ) disableKeypad();
{
putstring (TCAP(fc::t_keypad_local));
std::fflush(stdout);
}
finish_encoding(); finish_encoding();

View File

@ -26,18 +26,19 @@ namespace finalcut
{ {
// static class attributes // static class attributes
bool FTermcap::background_color_erase = false; bool FTermcap::background_color_erase = false;
bool FTermcap::automatic_left_margin = false; bool FTermcap::can_change_color_palette = false;
bool FTermcap::automatic_right_margin = false; bool FTermcap::automatic_left_margin = false;
bool FTermcap::eat_nl_glitch = false; bool FTermcap::automatic_right_margin = false;
bool FTermcap::ansi_default_color = false; bool FTermcap::eat_nl_glitch = false;
bool FTermcap::osc_support = false; bool FTermcap::ansi_default_color = false;
bool FTermcap::no_utf8_acs_chars = false; bool FTermcap::osc_support = false;
int FTermcap::max_color = 1; bool FTermcap::no_utf8_acs_chars = false;
int FTermcap::tabstop = 8; int FTermcap::max_color = 1;
int FTermcap::attr_without_color = 0; int FTermcap::tabstop = 8;
FTermData* FTermcap::fterm_data = 0; int FTermcap::attr_without_color = 0;
FTermDetection* FTermcap::term_detection = 0; FTermData* FTermcap::fterm_data = 0;
FTermDetection* FTermcap::term_detection = 0;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -96,7 +97,11 @@ void FTermcap::termcap()
bool color256 = term_detection->canDisplay256Colors(); bool color256 = term_detection->canDisplay256Colors();
// Open termcap file // Open termcap file
#if defined(__sun) && defined(__SVR4)
char* termtype = fterm_data->getTermType();
#else
const char* termtype = fterm_data->getTermType(); const char* termtype = fterm_data->getTermType();
#endif
terminals.push_back(termtype); // available terminal type terminals.push_back(termtype); // available terminal type
if ( color256 ) // 1st fallback if not found if ( color256 ) // 1st fallback if not found
@ -174,6 +179,9 @@ void FTermcap::termcapBoleans()
// Screen erased with the background color // Screen erased with the background color
background_color_erase = tgetflag(C_STR("ut")); 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 // t_cursor_left wraps from column 0 to last column
automatic_left_margin = tgetflag(C_STR("bw")); automatic_left_margin = tgetflag(C_STR("bw"));

View File

@ -89,7 +89,7 @@ void FTermcapQuirks::terminalFixup()
} }
else if ( td->isSunTerminal() ) else if ( td->isSunTerminal() )
{ {
sun(); sunConsole();
} }
else if ( td->isPuttyTerminal() ) 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 // Sun Microsystems workstation console eat_nl_glitch fix
FTermcap::eat_nl_glitch = true; FTermcap::eat_nl_glitch = true;

View File

@ -367,12 +367,19 @@ class FTerm
static void init_utf8_without_alt_charset(); static void init_utf8_without_alt_charset();
static void init_tab_quirks(); static void init_tab_quirks();
static void init_captureFontAndTitle(); static void init_captureFontAndTitle();
static bool hasNoFontSettingOption();
static bool canChangeColorPalette();
static void redefineColorPalette(); static void redefineColorPalette();
static void restoreColorPalette(); static void restoreColorPalette();
static void setInsertCursorStyle(); static void setInsertCursorStyle();
static void setOverwriteCursorStyle(); static void setOverwriteCursorStyle();
static void enableMouse(); static void enableMouse();
static void disableMouse(); static void disableMouse();
static void enableApplicationEscKey();
static void disableApplicationEscKey();
static void enableKeypad();
static void disableKeypad();
static void enableAlternateCharset();
static void useAlternateScreenBuffer(); static void useAlternateScreenBuffer();
static void useNormalScreenBuffer(); static void useNormalScreenBuffer();
void allocationValues(); void allocationValues();
@ -380,6 +387,7 @@ class FTerm
void init (bool); void init (bool);
void initOSspecifics(); void initOSspecifics();
void initTermspecifics(); void initTermspecifics();
void initBaudRate();
void finish(); void finish();
void finishOSspecifics1(); void finishOSspecifics1();
void finish_encoding(); void finish_encoding();

View File

@ -109,6 +109,7 @@ class FTermcap
// Data Members // Data Members
static bool background_color_erase; static bool background_color_erase;
static bool can_change_color_palette;
static bool automatic_left_margin; static bool automatic_left_margin;
static bool automatic_right_margin; static bool automatic_right_margin;
static bool eat_nl_glitch; static bool eat_nl_glitch;

View File

@ -82,7 +82,7 @@ class FTermcapQuirks
static void vte(); static void vte();
static void putty(); static void putty();
static void teraterm(); static void teraterm();
static void sun(); static void sunConsole();
static void screen(); static void screen();
static void general(); static void general();