Splitting quirks in serperate methods

This commit is contained in:
Markus Gans 2017-11-25 18:37:40 +01:00
parent 0c45d7d8bc
commit 64aa8d18b8
4 changed files with 388 additions and 253 deletions

View File

@ -1,3 +1,6 @@
2017-11-24 Markus Gans <guru.mail@muenster.de>
* Splitting quirks in serperate methods
2017-11-24 Markus Gans <guru.mail@muenster.de> 2017-11-24 Markus Gans <guru.mail@muenster.de>
* Detects Linux console font with 512 characters and * Detects Linux console font with 512 characters and
reduces the number of colors to 8 reduces the number of colors to 8

View File

@ -452,6 +452,7 @@ class FTerm
static void detectTerminal(); static void detectTerminal();
static void termtypeAnalysis(); static void termtypeAnalysis();
static char* init_256colorTerminal(); static char* init_256colorTerminal();
static char* determineMaxColor (char*&);
static char* parseAnswerbackMsg (char*&); static char* parseAnswerbackMsg (char*&);
static char* parseSecDA (char*&); static char* parseSecDA (char*&);
static void oscPrefix(); static void oscPrefix();
@ -464,6 +465,19 @@ class FTerm
static void init_termcaps_booleans(); static void init_termcaps_booleans();
static void init_termcaps_numeric(); static void init_termcaps_numeric();
static void init_termcaps_strings (char*&); static void init_termcaps_strings (char*&);
static void init_termcaps_quirks();
#if defined(__FreeBSD__) || defined(__DragonFly__)
static void init_termcaps_freebsd_quirks();
#endif
static void init_termcaps_cygwin_quirks();
static void init_termcaps_linux_quirks();
static void init_termcaps_xterm_quirks();
static void init_termcaps_rxvt_quirks();
static void init_termcaps_vte_quirks();
static void init_termcaps_putty_quirks();
static void init_termcaps_teraterm_quirks();
static void init_termcaps_screen_quirks();
static void init_termcaps_general_quirks();
static void init_termcaps_keys (char*&); static void init_termcaps_keys (char*&);
static void init_OptiMove(); static void init_OptiMove();
static void init_OptiAttr(); static void init_OptiAttr();

View File

@ -426,7 +426,8 @@ void FDialog::onKeyPress (FKeyEvent* ev)
updateTerminal(); updateTerminal();
} }
if ( ev->key() == fc::Fckey_caret ) // Ctrl+^ (Ctrl+6) if ( ev->key() == fc::Fckey_caret // Ctrl+^ (Ctrl+6)
|| ev->key() == fc::Fkey_f22 ) // Shift+F10
{ {
ev->accept(); ev->accept();
// open the titlebar menu // open the titlebar menu

View File

@ -2449,8 +2449,20 @@ void FTerm::initLinuxConsole()
FTermcap::max_color = 16; FTermcap::max_color = 16;
else else
FTermcap::max_color = 8; FTermcap::max_color = 8;
}
#endif #endif
// Underline cursor
setLinuxConsoleCursorStyle (fc::underscore_cursor, true);
// Framebuffer color depth in bits per pixel
int bpp = getFramebuffer_bpp();
if ( bpp >= 4 )
FTermcap::max_color = 16;
#if DEBUG
framebuffer_bpp = bpp;
#endif
}
detectTermSize(); detectTermSize();
closeConsole(); closeConsole();
@ -2460,22 +2472,6 @@ void FTerm::initLinuxConsole()
std::cerr << "can not open the console.\n"; std::cerr << "can not open the console.\n";
std::abort(); std::abort();
} }
if ( linux_terminal )
{
// Underline cursor
setLinuxConsoleCursorStyle (fc::underscore_cursor, true);
// Framebuffer color depth in bits per pixel
int bpp = getFramebuffer_bpp();
if ( bpp >= 4 )
FTermcap::max_color = 16;
#if DEBUG
framebuffer_bpp = bpp;
#endif
}
} }
#endif #endif
@ -2542,6 +2538,9 @@ void FTerm::initFreeBSDConsole()
// map meta key to left alt key // map meta key to left alt key
setFreeBSDAlt2Meta(); setFreeBSDAlt2Meta();
// Initialize FreeBSD console cursor
setFreeBSDConsoleCursorStyle (fc::destructive_cursor, true);
} }
} }
#endif #endif
@ -2710,30 +2709,8 @@ void FTerm::detectTerminal()
// Identify the terminal via the secondary device attributes (SEC_DA) // Identify the terminal via the secondary device attributes (SEC_DA)
new_termtype = parseSecDA (new_termtype); new_termtype = parseSecDA (new_termtype);
// Determine xterm maximum number of colors via OSC 4 // Determines the maximum number of colors
if ( ! color256 new_termtype = determineMaxColor(new_termtype);
&& ! cygwin_terminal
&& ! tera_terminal
&& ! linux_terminal
&& ! netbsd_terminal
&& ! getXTermColorName(0).isEmpty() )
{
if ( ! getXTermColorName(256).isEmpty() )
{
if ( putty_terminal )
new_termtype = const_cast<char*>("putty-256color");
else
new_termtype = const_cast<char*>("xterm-256color");
}
else if ( ! getXTermColorName(87).isEmpty() )
{
new_termtype = const_cast<char*>("xterm-88color");
}
else if ( ! getXTermColorName(15).isEmpty() )
{
new_termtype = const_cast<char*>("xterm-16color");
}
}
if ( cygwin_terminal if ( cygwin_terminal
|| putty_terminal || putty_terminal
@ -2743,11 +2720,6 @@ void FTerm::detectTerminal()
FTermcap::max_color = 16; FTermcap::max_color = 16;
} }
// Initialize FreeBSD console cursor
#if defined(__FreeBSD__) || defined(__DragonFly__)
setFreeBSDConsoleCursorStyle (fc::destructive_cursor, true);
#endif
t.c_lflag |= uInt(ICANON | ECHO); t.c_lflag |= uInt(ICANON | ECHO);
tcsetattr(stdin_no, TCSADRAIN, &t); tcsetattr(stdin_no, TCSADRAIN, &t);
} }
@ -2905,6 +2877,40 @@ char* FTerm::init_256colorTerminal()
return new_termtype; return new_termtype;
} }
//----------------------------------------------------------------------
char* FTerm::determineMaxColor (char*& current_termtype)
{
// Determine xterm maximum number of colors via OSC 4
char* new_termtype = current_termtype;
if ( ! color256
&& ! cygwin_terminal
&& ! tera_terminal
&& ! linux_terminal
&& ! netbsd_terminal
&& ! getXTermColorName(0).isEmpty() )
{
if ( ! getXTermColorName(256).isEmpty() )
{
if ( putty_terminal )
new_termtype = const_cast<char*>("putty-256color");
else
new_termtype = const_cast<char*>("xterm-256color");
}
else if ( ! getXTermColorName(87).isEmpty() )
{
new_termtype = const_cast<char*>("xterm-88color");
}
else if ( ! getXTermColorName(15).isEmpty() )
{
new_termtype = const_cast<char*>("xterm-16color");
}
}
return new_termtype;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
char* FTerm::parseAnswerbackMsg (char*& current_termtype) char* FTerm::parseAnswerbackMsg (char*& current_termtype)
{ {
@ -3367,6 +3373,9 @@ void FTerm::init_termcaps()
// Get termcap strings // Get termcap strings
init_termcaps_strings(buffer); init_termcaps_strings(buffer);
// Fix terminal quirks
init_termcaps_quirks();
// Get termcap keys // Get termcap keys
init_termcaps_keys(buffer); init_termcaps_keys(buffer);
@ -3403,10 +3412,6 @@ void FTerm::init_termcaps_booleans()
// U8 is nonzero for terminals with no VT100 line-drawing in UTF-8 mode // U8 is nonzero for terminals with no VT100 line-drawing in UTF-8 mode
FTermcap::no_utf8_acs_chars = bool(tgetnum(const_cast<char*>("U8")) != 0); FTermcap::no_utf8_acs_chars = bool(tgetnum(const_cast<char*>("U8")) != 0);
// Tera Term eat_nl_glitch fix
if ( tera_terminal )
FTermcap::eat_nl_glitch = true;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -3414,8 +3419,6 @@ void FTerm::init_termcaps_numeric()
{ {
// Get termcap numeric // Get termcap numeric
static const int not_available = -1;
// Maximum number of colors on screen // Maximum number of colors on screen
FTermcap::max_color = std::max( FTermcap::max_color FTermcap::max_color = std::max( FTermcap::max_color
, tgetnum(const_cast<char*>("Co")) ); , tgetnum(const_cast<char*>("Co")) );
@ -3431,23 +3434,8 @@ void FTerm::init_termcaps_numeric()
// Get initial spacing for hardware tab stop // Get initial spacing for hardware tab stop
FTermcap::tabstop = tgetnum(const_cast<char*>("it")); FTermcap::tabstop = tgetnum(const_cast<char*>("it"));
if ( FTermcap::tabstop == not_available )
FTermcap::tabstop = 8;
// Get video attributes that cannot be used with colors // Get video attributes that cannot be used with colors
FTermcap::attr_without_color = tgetnum(const_cast<char*>("NC")); FTermcap::attr_without_color = tgetnum(const_cast<char*>("NC"));
if ( FTermcap::attr_without_color == not_available )
FTermcap::attr_without_color = 0;
// gnome-terminal has NC=16 however, it can use the dim attribute
if ( gnome_terminal )
FTermcap::attr_without_color = 0;
// PuTTY has NC=22 however, it can show underline and reverse
// and since version 0.71 is the dim attribute is also supported
if ( putty_terminal )
FTermcap::attr_without_color = 0;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -3458,24 +3446,179 @@ void FTerm::init_termcaps_strings (char*& buffer)
// Read termcap output strings // Read termcap output strings
for (int i = 0; tcap[i].tname[0] != 0; i++) for (int i = 0; tcap[i].tname[0] != 0; i++)
tcap[i].string = tgetstr(tcap[i].tname, &buffer); tcap[i].string = tgetstr(tcap[i].tname, &buffer);
}
//----------------------------------------------------------------------
void FTerm::init_termcaps_quirks()
{
if ( cygwin_terminal )
{
init_termcaps_cygwin_quirks();
}
else if ( linux_terminal )
{
init_termcaps_linux_quirks();
}
else if ( rxvt_terminal )
{
init_termcaps_rxvt_quirks();
}
else if ( gnome_terminal )
{
init_termcaps_vte_quirks();
}
else if ( tera_terminal )
{
init_termcaps_teraterm_quirks();
}
else if ( putty_terminal )
{
init_termcaps_putty_quirks();
}
else if ( screen_terminal )
{
init_termcaps_screen_quirks();
}
#if defined(__FreeBSD__) || defined(__DragonFly__)
else if ( isFreeBSDConsole() )
{
init_termcaps_freebsd_quirks()
}
#endif
// xterm and compatible terminals
if ( xterm_terminal && ! putty_terminal )
init_termcaps_xterm_quirks();
// Fixes general quirks
init_termcaps_general_quirks();
}
#if defined(__FreeBSD__) || defined(__DragonFly__)
//----------------------------------------------------------------------
static void FTerm::init_termcaps_freebsd_quirks()
{
// FreeBSD console fixes
TCAP(fc::t_acs_chars) = \
const_cast<char*>("-\036.\0370\333"
"a\260f\370g\361"
"h\261j\331k\277"
"l\332m\300n\305"
"q\304t\303u\264"
"v\301w\302x\263"
"y\363z\362~\371");
TCAP(fc::t_set_attributes) = \
const_cast<char*>(CSI "0"
"%?%p1%p6%|%t;1%;"
"%?%p2%t;4%;"
"%?%p1%p3%|%t;7%;"
"%?%p4%t;5%;m"
"%?%p9%t\016%e\017%;");
FTermcap::attr_without_color = 18;
}
#endif
//----------------------------------------------------------------------
void FTerm::init_termcaps_cygwin_quirks()
{
// Set invisible cursor for cygwin terminal // Set invisible cursor for cygwin terminal
if ( cygwin_terminal && ! TCAP(fc::t_cursor_invisible) ) if ( ! TCAP(fc::t_cursor_invisible) )
TCAP(fc::t_cursor_invisible) = \ TCAP(fc::t_cursor_invisible) = \
const_cast<char*>(CSI "?25l"); const_cast<char*>(CSI "?25l");
// Set visible cursor for cygwin terminal // Set visible cursor for cygwin terminal
if ( cygwin_terminal && ! TCAP(fc::t_cursor_visible) ) if ( ! TCAP(fc::t_cursor_visible) )
TCAP(fc::t_cursor_visible) = \ TCAP(fc::t_cursor_visible) = \
const_cast<char*>(CSI "?25h"); const_cast<char*>(CSI "?25h");
// Set ansi blink for cygwin terminal // Set ansi blink for cygwin terminal
if ( cygwin_terminal && ! TCAP(fc::t_enter_blink_mode) ) if ( ! TCAP(fc::t_enter_blink_mode) )
TCAP(fc::t_enter_blink_mode) = \ TCAP(fc::t_enter_blink_mode) = \
const_cast<char*>(CSI "5m"); const_cast<char*>(CSI "5m");
// Set background color erase for cygwin terminal
FTermcap::background_color_erase = true;
// Set ansi foreground and background color
if ( FTermcap::max_color > 8 )
{
TCAP(fc::t_set_a_foreground) = \
const_cast<char*>(CSI "3%p1%{8}%m%d%?%p1%{7}%>%t;1%e;21%;m");
TCAP(fc::t_set_a_background) = \
const_cast<char*>(CSI "4%p1%{8}%m%d%?%p1%{7}%>%t;5%e;25%;m");
}
else
{
TCAP(fc::t_set_a_foreground) = \
const_cast<char*>(CSI "3%p1%dm");
TCAP(fc::t_set_a_background) = \
const_cast<char*>(CSI "4%p1%dm");
}
TCAP(fc::t_orig_pair) = \
const_cast<char*>(CSI "39;49;25m");
// Avoid dim + underline
TCAP(fc::t_enter_dim_mode) = 0;
TCAP(fc::t_exit_dim_mode) = 0;
TCAP(fc::t_enter_underline_mode) = 0;
TCAP(fc::t_exit_underline_mode) = 0;
FTermcap::attr_without_color = 18;
}
//----------------------------------------------------------------------
void FTerm::init_termcaps_linux_quirks()
{
// Set ansi foreground and background color
if ( FTermcap::max_color > 8 )
{
TCAP(fc::t_set_a_foreground) = \
const_cast<char*>(CSI "3%p1%{8}%m%d%?%p1%{7}%>%t;1%e;21%;m");
TCAP(fc::t_set_a_background) = \
const_cast<char*>(CSI "4%p1%{8}%m%d%?%p1%{7}%>%t;5%e;25%;m");
}
else
{
TCAP(fc::t_set_a_foreground) = \
const_cast<char*>(CSI "3%p1%dm");
TCAP(fc::t_set_a_background) = \
const_cast<char*>(CSI "4%p1%dm");
}
TCAP(fc::t_orig_pair) = \
const_cast<char*>(CSI "39;49;25m");
// Avoid dim + underline
TCAP(fc::t_enter_dim_mode) = 0;
TCAP(fc::t_exit_dim_mode) = 0;
TCAP(fc::t_enter_underline_mode) = 0;
TCAP(fc::t_exit_underline_mode) = 0;
FTermcap::attr_without_color = 18;
}
//----------------------------------------------------------------------
void FTerm::init_termcaps_xterm_quirks()
{
// Fallback if "Ic" is not found
if ( ! TCAP(fc::t_initialize_color) )
{
TCAP(fc::t_initialize_color) = \
const_cast<char*>(OSC "4;%p1%d;rgb:"
"%p2%{255}%*%{1000}%/%2.2X/"
"%p3%{255}%*%{1000}%/%2.2X/"
"%p4%{255}%*%{1000}%/%2.2X" ESC "\\");
}
}
//----------------------------------------------------------------------
void FTerm::init_termcaps_rxvt_quirks()
{
// Set enter/exit alternative charset mode for rxvt terminal // Set enter/exit alternative charset mode for rxvt terminal
if ( rxvt_terminal && std::strncmp(termtype, "rxvt-16color", 12) == 0 ) if ( std::strncmp(termtype, "rxvt-16color", 12) == 0 )
{ {
TCAP(fc::t_enter_alt_charset_mode) = \ TCAP(fc::t_enter_alt_charset_mode) = \
const_cast<char*>(ESC "(0"); const_cast<char*>(ESC "(0");
@ -3483,140 +3626,165 @@ void FTerm::init_termcaps_strings (char*& buffer)
const_cast<char*>(ESC "(B"); const_cast<char*>(ESC "(B");
} }
// set exit underline for gnome terminal
if ( gnome_terminal )
TCAP(fc::t_exit_underline_mode) = \
const_cast<char*>(CSI "24m");
// Set background color erase for cygwin terminal
if ( cygwin_terminal )
FTermcap::background_color_erase = true;
// Set ansi foreground and background color // Set ansi foreground and background color
if ( linux_terminal || cygwin_terminal ) if ( ! urxvt_terminal )
{
if ( FTermcap::max_color > 8 )
{
TCAP(fc::t_set_a_foreground) = \
const_cast<char*>(CSI "3%p1%{8}%m%d%?%p1%{7}%>%t;1%e;21%;m");
TCAP(fc::t_set_a_background) = \
const_cast<char*>(CSI "4%p1%{8}%m%d%?%p1%{7}%>%t;5%e;25%;m");
}
else
{
TCAP(fc::t_set_a_foreground) = \
const_cast<char*>(CSI "3%p1%dm");
TCAP(fc::t_set_a_background) = \
const_cast<char*>(CSI "4%p1%dm");
}
TCAP(fc::t_orig_pair) = \
const_cast<char*>(CSI "39;49;25m");
// Avoid dim + underline
TCAP(fc::t_enter_dim_mode) = 0;
TCAP(fc::t_exit_dim_mode) = 0;
TCAP(fc::t_enter_underline_mode) = 0;
TCAP(fc::t_exit_underline_mode) = 0;
FTermcap::attr_without_color = 18;
}
else if ( rxvt_terminal && ! urxvt_terminal )
{ {
TCAP(fc::t_set_a_foreground) = \ TCAP(fc::t_set_a_foreground) = \
const_cast<char*>(CSI "%?%p1%{8}%<%t%p1%{30}%+%e%p1%'R'%+%;%dm"); const_cast<char*>(CSI "%?%p1%{8}%<%t%p1%{30}%+%e%p1%'R'%+%;%dm");
TCAP(fc::t_set_a_background) = \ TCAP(fc::t_set_a_background) = \
const_cast<char*>(CSI "%?%p1%{8}%<%t%p1%'('%+%e%p1%{92}%+%;%dm"); const_cast<char*>(CSI "%?%p1%{8}%<%t%p1%'('%+%e%p1%{92}%+%;%dm");
} }
else if ( tera_terminal ) }
{
TCAP(fc::t_set_a_foreground) = \ //----------------------------------------------------------------------
const_cast<char*>(CSI "38;5;%p1%dm"); void FTerm::init_termcaps_vte_quirks()
TCAP(fc::t_set_a_background) = \ {
const_cast<char*>(CSI "48;5;%p1%dm"); // gnome-terminal has NC=16 however, it can use the dim attribute
TCAP(fc::t_exit_attribute_mode) = \ FTermcap::attr_without_color = 0;
const_cast<char*>(CSI "0m" SI);
// set exit underline for gnome terminal
TCAP(fc::t_exit_underline_mode) = \
const_cast<char*>(CSI "24m");
}
//----------------------------------------------------------------------
void FTerm::init_termcaps_putty_quirks()
{
FTermcap::background_color_erase = true;
FTermcap::osc_support = true;
// PuTTY has NC=22 however, it can show underline and reverse
// and since version 0.71 is the dim attribute is also supported
FTermcap::attr_without_color = 0;
// Set ansi foreground and background color
TCAP(fc::t_set_a_foreground) = \
const_cast<char*>(CSI "%?%p1%{8}%<"
"%t3%p1%d"
"%e%p1%{16}%<"
"%t9%p1%{8}%-%d"
"%e38;5;%p1%d%;m");
TCAP(fc::t_set_a_background) = \
const_cast<char*>(CSI "%?%p1%{8}%<"
"%t4%p1%d"
"%e%p1%{16}%<"
"%t10%p1%{8}%-%d"
"%e48;5;%p1%d%;m");
TCAP(fc::t_set_attributes) = \
const_cast<char*>(CSI "0"
"%?%p1%p6%|%t;1%;"
"%?%p5%t;2%;" // since putty 0.71
"%?%p2%t;4%;"
"%?%p1%p3%|%t;7%;"
"%?%p4%t;5%;m"
"%?%p9%t\016%e\017%;");
// PuTTY 0.71 or higher
TCAP(fc::t_enter_dim_mode) = \
const_cast<char*>(CSI "2m");
// PuTTY 0.71 or higher
TCAP(fc::t_exit_dim_mode) = \
const_cast<char*>(CSI "22m");
if ( ! TCAP(fc::t_clr_bol) )
TCAP(fc::t_clr_bol) = \
const_cast<char*>(CSI "1K");
if ( ! TCAP(fc::t_orig_pair) )
TCAP(fc::t_orig_pair) = \ TCAP(fc::t_orig_pair) = \
const_cast<char*>(CSI "39;49m"); const_cast<char*>(CSI "39;49m");
}
else if ( putty_terminal ) if ( ! TCAP(fc::t_orig_colors) )
TCAP(fc::t_orig_colors) = \
const_cast<char*>(OSC "R");
if ( ! TCAP(fc::t_column_address) )
TCAP(fc::t_column_address) = \
const_cast<char*>(CSI "%i%p1%dG");
if ( ! TCAP(fc::t_row_address) )
TCAP(fc::t_row_address) = \
const_cast<char*>(CSI "%i%p1%dd");
if ( ! TCAP(fc::t_enable_acs) )
TCAP(fc::t_enable_acs) = \
const_cast<char*>(ESC "(B" ESC ")0");
if ( ! TCAP(fc::t_enter_am_mode) )
TCAP(fc::t_enter_am_mode) = \
const_cast<char*>(CSI "?7h");
if ( ! TCAP(fc::t_exit_am_mode) )
TCAP(fc::t_exit_am_mode) = \
const_cast<char*>(CSI "?7l");
if ( ! TCAP(fc::t_enter_pc_charset_mode) )
TCAP(fc::t_enter_pc_charset_mode) = \
const_cast<char*>(CSI "11m");
if ( ! TCAP(fc::t_exit_pc_charset_mode) )
TCAP(fc::t_exit_pc_charset_mode) = \
const_cast<char*>(CSI "10m");
if ( ! TCAP(fc::t_key_mouse) )
TCAP(fc::t_key_mouse) = \
const_cast<char*>(CSI "M");
}
//----------------------------------------------------------------------
void FTerm::init_termcaps_teraterm_quirks()
{
// Tera Term eat_nl_glitch fix
FTermcap::eat_nl_glitch = true;
// Tera Term color settings
TCAP(fc::t_set_a_foreground) = \
const_cast<char*>(CSI "38;5;%p1%dm");
TCAP(fc::t_set_a_background) = \
const_cast<char*>(CSI "48;5;%p1%dm");
TCAP(fc::t_exit_attribute_mode) = \
const_cast<char*>(CSI "0m" SI);
TCAP(fc::t_orig_pair) = \
const_cast<char*>(CSI "39;49m");
}
//----------------------------------------------------------------------
void FTerm::init_termcaps_screen_quirks()
{
// Fallback if "Ic" is not found
if ( ! TCAP(fc::t_initialize_color) )
{ {
FTermcap::background_color_erase = true; if ( tmux_terminal )
FTermcap::osc_support = true; {
TCAP(fc::t_initialize_color) = \
TCAP(fc::t_set_a_foreground) = \ const_cast<char*>(ESC "Ptmux;" ESC OSC "4;%p1%d;rgb:"
const_cast<char*>(CSI "%?%p1%{8}%<" "%p2%{255}%*%{1000}%/%2.2X/"
"%t3%p1%d" "%p3%{255}%*%{1000}%/%2.2X/"
"%e%p1%{16}%<" "%p4%{255}%*%{1000}%/%2.2X" BEL ESC "\\");
"%t9%p1%{8}%-%d" }
"%e38;5;%p1%d%;m"); else
{
TCAP(fc::t_set_a_background) = \ TCAP(fc::t_initialize_color) = \
const_cast<char*>(CSI "%?%p1%{8}%<" const_cast<char*>(ESC "P" OSC "4;%p1%d;rgb:"
"%t4%p1%d" "%p2%{255}%*%{1000}%/%2.2X/"
"%e%p1%{16}%<" "%p3%{255}%*%{1000}%/%2.2X/"
"%t10%p1%{8}%-%d" "%p4%{255}%*%{1000}%/%2.2X" BEL ESC "\\");
"%e48;5;%p1%d%;m"); }
TCAP(fc::t_set_attributes) = \
const_cast<char*>(CSI "0"
"%?%p1%p6%|%t;1%;"
"%?%p5%t;2%;" // since putty 0.71
"%?%p2%t;4%;"
"%?%p1%p3%|%t;7%;"
"%?%p4%t;5%;m"
"%?%p9%t\016%e\017%;");
// PuTTY 0.71 or higher
TCAP(fc::t_enter_dim_mode) = \
const_cast<char*>(CSI "2m");
// PuTTY 0.71 or higher
TCAP(fc::t_exit_dim_mode) = \
const_cast<char*>(CSI "22m");
if ( ! TCAP(fc::t_clr_bol) )
TCAP(fc::t_clr_bol) = \
const_cast<char*>(CSI "1K");
if ( ! TCAP(fc::t_orig_pair) )
TCAP(fc::t_orig_pair) = \
const_cast<char*>(CSI "39;49m");
if ( ! TCAP(fc::t_orig_colors) )
TCAP(fc::t_orig_colors) = \
const_cast<char*>(OSC "R");
if ( ! TCAP(fc::t_column_address) )
TCAP(fc::t_column_address) = \
const_cast<char*>(CSI "%i%p1%dG");
if ( ! TCAP(fc::t_row_address) )
TCAP(fc::t_row_address) = \
const_cast<char*>(CSI "%i%p1%dd");
if ( ! TCAP(fc::t_enable_acs) )
TCAP(fc::t_enable_acs) = \
const_cast<char*>(ESC "(B" ESC ")0");
if ( ! TCAP(fc::t_enter_am_mode) )
TCAP(fc::t_enter_am_mode) = \
const_cast<char*>(CSI "?7h");
if ( ! TCAP(fc::t_exit_am_mode) )
TCAP(fc::t_exit_am_mode) = \
const_cast<char*>(CSI "?7l");
if ( ! TCAP(fc::t_enter_pc_charset_mode) )
TCAP(fc::t_enter_pc_charset_mode) = \
const_cast<char*>(CSI "11m");
if ( ! TCAP(fc::t_exit_pc_charset_mode) )
TCAP(fc::t_exit_pc_charset_mode) = \
const_cast<char*>(CSI "10m");
if ( ! TCAP(fc::t_key_mouse) )
TCAP(fc::t_key_mouse) = \
const_cast<char*>(CSI "M");
} }
}
//----------------------------------------------------------------------
void FTerm::init_termcaps_general_quirks()
{
static const int not_available = -1;
if ( FTermcap::tabstop == not_available )
FTermcap::tabstop = 8;
if ( FTermcap::attr_without_color == not_available )
FTermcap::attr_without_color = 0;
// Fallback if "AF" is not found // Fallback if "AF" is not found
if ( ! TCAP(fc::t_set_a_foreground) ) if ( ! TCAP(fc::t_set_a_foreground) )
@ -3631,41 +3799,11 @@ void FTerm::init_termcaps_strings (char*& buffer)
// Fallback if "Ic" is not found // Fallback if "Ic" is not found
if ( ! TCAP(fc::t_initialize_color) ) if ( ! TCAP(fc::t_initialize_color) )
{ {
if ( screen_terminal ) TCAP(fc::t_initialize_color) = \
{ const_cast<char*>(OSC "P%p1%x"
if ( tmux_terminal ) "%p2%{255}%*%{1000}%/%02x"
{ "%p3%{255}%*%{1000}%/%02x"
TCAP(fc::t_initialize_color) = \ "%p4%{255}%*%{1000}%/%02x");
const_cast<char*>(ESC "Ptmux;" ESC OSC "4;%p1%d;rgb:"
"%p2%{255}%*%{1000}%/%2.2X/"
"%p3%{255}%*%{1000}%/%2.2X/"
"%p4%{255}%*%{1000}%/%2.2X" BEL ESC "\\");
}
else
{
TCAP(fc::t_initialize_color) = \
const_cast<char*>(ESC "P" OSC "4;%p1%d;rgb:"
"%p2%{255}%*%{1000}%/%2.2X/"
"%p3%{255}%*%{1000}%/%2.2X/"
"%p4%{255}%*%{1000}%/%2.2X" BEL ESC "\\");
}
}
else if ( xterm_terminal && ! putty_terminal )
{
TCAP(fc::t_initialize_color) = \
const_cast<char*>(OSC "4;%p1%d;rgb:"
"%p2%{255}%*%{1000}%/%2.2X/"
"%p3%{255}%*%{1000}%/%2.2X/"
"%p4%{255}%*%{1000}%/%2.2X" ESC "\\");
}
else
{
TCAP(fc::t_initialize_color) = \
const_cast<char*>(OSC "P%p1%x"
"%p2%{255}%*%{1000}%/%02x"
"%p3%{255}%*%{1000}%/%02x"
"%p4%{255}%*%{1000}%/%02x");
}
} }
// Fallback if "ti" is not found // Fallback if "ti" is not found
@ -3718,28 +3856,6 @@ void FTerm::init_termcaps_strings (char*& buffer)
TCAP(fc::t_exit_crossed_out_mode) = \ TCAP(fc::t_exit_crossed_out_mode) = \
const_cast<char*>(CSI "29m"); const_cast<char*>(CSI "29m");
} }
#if defined(__FreeBSD__) || defined(__DragonFly__)
if ( isFreeBSDConsole() )
{
TCAP(fc::t_acs_chars) = \
const_cast<char*>("-\036.\0370\333"
"a\260f\370g\361"
"h\261j\331k\277"
"l\332m\300n\305"
"q\304t\303u\264"
"v\301w\302x\263"
"y\363z\362~\371");
TCAP(fc::t_set_attributes) = \
const_cast<char*>(CSI "0"
"%?%p1%p6%|%t;1%;"
"%?%p2%t;4%;"
"%?%p1%p3%|%t;7%;"
"%?%p4%t;5%;m"
"%?%p9%t\016%e\017%;");
FTermcap::attr_without_color = 18;
}
#endif
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -3795,6 +3911,7 @@ void FTerm::init_termcaps_keys (char*& buffer)
if ( std::strncmp(Fkey[i].tname, "krx", 3) == 0 ) if ( std::strncmp(Fkey[i].tname, "krx", 3) == 0 )
Fkey[i].string = const_cast<char*>(CSI "C"); // Key right Fkey[i].string = const_cast<char*>(CSI "C"); // Key right
if ( std::strncmp(Fkey[i].tname, "klx", 3) == 0 ) if ( std::strncmp(Fkey[i].tname, "klx", 3) == 0 )
Fkey[i].string = const_cast<char*>(CSI "D"); // Key left Fkey[i].string = const_cast<char*>(CSI "D"); // Key left