DECSCUSR - Set Cursor Style support for VTE >= 0.40.0 and gnome-terminal >= 3.16

This commit is contained in:
Markus Gans 2017-10-06 12:19:39 +02:00
parent 975212bac0
commit 0277abcbdb
10 changed files with 143 additions and 68 deletions

View File

@ -1,3 +1,8 @@
2017-10-02 Markus Gans <guru.mail@muenster.de>
* DECSCUSR - Set Cursor Style support for VTE >= 0.40.0 and
gnome-terminal >= 3.16
* Checks if the FScrollview viewport fits into the print area
2017-10-02 Markus Gans <guru.mail@muenster.de> 2017-10-02 Markus Gans <guru.mail@muenster.de>
* SGR and URXVT mouse support for coordinates greater-than * SGR and URXVT mouse support for coordinates greater-than
255 columns or lines 255 columns or lines

View File

@ -1,5 +1,5 @@
/************************************************************************ /************************************************************************
* os-choice.cpp - FButtonGroup with scroll view * * choice.cpp - FButtonGroup with scroll view *
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
@ -61,7 +61,7 @@ int main (int argc, char* argv[])
y = (app.getLineNumber() - h) / 2; y = (app.getLineNumber() - h) / 2;
dgl->setGeometry (x, y, w, h); dgl->setGeometry (x, y, w, h);
// Create another button group // Create a button group
FButtonGroup* checkButtonGroup = new FButtonGroup("choice", dgl); FButtonGroup* checkButtonGroup = new FButtonGroup("choice", dgl);
checkButtonGroup->setGeometry (2, 1, 16, 7); checkButtonGroup->setGeometry (2, 1, 16, 7);

View File

@ -433,6 +433,7 @@ class FTerm
static FTermcap::tcap_map* tcap; static FTermcap::tcap_map* tcap;
static bool mouse_support; static bool mouse_support;
static bool decscusr_support;
static bool terminal_detection; static bool terminal_detection;
static bool raw_mode; static bool raw_mode;
static bool input_data_pending; static bool input_data_pending;

View File

@ -467,7 +467,7 @@ int FApplication::gpmEvent (bool clear)
tv.tv_usec = 100000; // 100 ms tv.tv_usec = 100000; // 100 ms
result = select (max + 1, &ifds, 0, 0, &tv); result = select (max + 1, &ifds, 0, 0, &tv);
if ( FD_ISSET(stdin_no, &ifds) ) if ( result > 0 && FD_ISSET(stdin_no, &ifds) )
{ {
if ( clear ) if ( clear )
FD_CLR (stdin_no, &ifds); FD_CLR (stdin_no, &ifds);
@ -475,7 +475,7 @@ int FApplication::gpmEvent (bool clear)
return keyboard_event; return keyboard_event;
} }
if ( clear && FD_ISSET(gpm_fd, &ifds) ) if ( clear && result > 0 && FD_ISSET(gpm_fd, &ifds) )
FD_CLR (gpm_fd, &ifds); FD_CLR (gpm_fd, &ifds);
if ( result > 0 ) if ( result > 0 )
@ -498,7 +498,7 @@ inline bool FApplication::KeyPressed()
tv.tv_usec = 100000; // 100 ms tv.tv_usec = 100000; // 100 ms
result = select (stdin_no + 1, &ifds, 0, 0, &tv); result = select (stdin_no + 1, &ifds, 0, 0, &tv);
if ( FD_ISSET(stdin_no, &ifds) ) if ( result > 0 && FD_ISSET(stdin_no, &ifds) )
FD_CLR (stdin_no, &ifds); FD_CLR (stdin_no, &ifds);
return ( result > 0 ); return ( result > 0 );

View File

@ -1211,7 +1211,10 @@ void FListBox::adjustYOffset()
{ {
int element_count = int(getCount()); int element_count = int(getCount());
if ( element_count == 0 ) if ( getClientHeight() < 0 )
beep();
if ( element_count == 0 || getClientHeight() <= 0 )
return; return;
if ( yoffset > element_count - getClientHeight() ) if ( yoffset > element_count - getClientHeight() )
@ -1427,7 +1430,7 @@ void FListBox::drawList()
iter = index2iterator(int(start) + yoffset); iter = index2iterator(int(start) + yoffset);
for (uInt y = start; y < num; y++) for (uInt y = start; y < num && iter != itemlist.end() ; y++)
{ {
bool serach_mark = false bool serach_mark = false
, lineHasBrackets = hasBrackets(iter) , lineHasBrackets = hasBrackets(iter)

View File

@ -732,6 +732,14 @@ void FScrollView::copy2area()
, y_end = getViewportHeight() , y_end = getViewportHeight()
, x_end = getViewportWidth(); , x_end = getViewportWidth();
// viewport width does not fit into the print_area
if ( print_area->width <= ax + x_end )
x_end = print_area->width - ax;
// viewport height does not fit into the print_area
if ( print_area->height <= ay + y_end )
y_end = print_area->height - ay;
for (int y = 0; y < y_end; y++) // line loop for (int y = 0; y < y_end; y++) // line loop
{ {
char_data* vc; // viewport character char_data* vc; // viewport character

View File

@ -57,6 +57,7 @@ int FTerm::cursor_addres_lengths;
uInt FTerm::baudrate; uInt FTerm::baudrate;
bool FTerm::resize_term; bool FTerm::resize_term;
bool FTerm::mouse_support; bool FTerm::mouse_support;
bool FTerm::decscusr_support;
bool FTerm::terminal_detection; bool FTerm::terminal_detection;
bool FTerm::raw_mode; bool FTerm::raw_mode;
bool FTerm::input_data_pending; bool FTerm::input_data_pending;
@ -1051,13 +1052,16 @@ void FTerm::setXTermCursorStyle (fc::xtermCursorStyle style)
{ {
// Set the xterm cursor style // Set the xterm cursor style
if ( (gnome_terminal && ! decscusr_support) || kde_konsole )
return;
#if defined(__FreeBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__DragonFly__)
if ( isFreeBSDConsole() ) if ( isFreeBSDConsole() )
return; return;
#endif #endif
if ( (xterm_terminal || mintty_terminal) if ( xterm_terminal || mintty_terminal || decscusr_support )
&& ! (gnome_terminal || kde_konsole) )
{ {
putstringf (CSI "%d q", style); putstringf (CSI "%d q", style);
std::fflush(stdout); std::fflush(stdout);
@ -1168,6 +1172,9 @@ void FTerm::setXTermHighlightBackground (const FString& hbg)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::setXTermDefaults() void FTerm::setXTermDefaults()
{ {
if ( putty_terminal )
return;
setXTermMouseBackground("rgb:ffff/ffff/ffff"); setXTermMouseBackground("rgb:ffff/ffff/ffff");
setXTermMouseForeground ("rgb:0000/0000/0000"); setXTermMouseForeground ("rgb:0000/0000/0000");
@ -1188,6 +1195,10 @@ void FTerm::setXTermDefaults()
void FTerm::resetXTermColors() void FTerm::resetXTermColors()
{ {
// Reset the entire color table // Reset the entire color table
if ( putty_terminal )
return;
if ( xterm_terminal || screen_terminal || FTermcap::osc_support ) if ( xterm_terminal || screen_terminal || FTermcap::osc_support )
{ {
oscPrefix(); oscPrefix();
@ -1201,6 +1212,10 @@ void FTerm::resetXTermColors()
void FTerm::resetXTermForeground() void FTerm::resetXTermForeground()
{ {
// Reset the VT100 text foreground color // Reset the VT100 text foreground color
if ( putty_terminal )
return;
if ( xterm_terminal || screen_terminal || FTermcap::osc_support ) if ( xterm_terminal || screen_terminal || FTermcap::osc_support )
{ {
oscPrefix(); oscPrefix();
@ -1214,6 +1229,10 @@ void FTerm::resetXTermForeground()
void FTerm::resetXTermBackground() void FTerm::resetXTermBackground()
{ {
// Reset the VT100 text background color // Reset the VT100 text background color
if ( putty_terminal )
return;
if ( xterm_terminal || screen_terminal || FTermcap::osc_support ) if ( xterm_terminal || screen_terminal || FTermcap::osc_support )
{ {
oscPrefix(); oscPrefix();
@ -1227,6 +1246,10 @@ void FTerm::resetXTermBackground()
void FTerm::resetXTermCursorColor() void FTerm::resetXTermCursorColor()
{ {
// Reset the text cursor color // Reset the text cursor color
if ( putty_terminal )
return;
if ( xterm_terminal || screen_terminal || FTermcap::osc_support ) if ( xterm_terminal || screen_terminal || FTermcap::osc_support )
{ {
oscPrefix(); oscPrefix();
@ -1240,6 +1263,10 @@ void FTerm::resetXTermCursorColor()
void FTerm::resetXTermMouseForeground() void FTerm::resetXTermMouseForeground()
{ {
// Reset the mouse foreground color // Reset the mouse foreground color
if ( putty_terminal )
return;
if ( xterm_terminal || screen_terminal || FTermcap::osc_support ) if ( xterm_terminal || screen_terminal || FTermcap::osc_support )
{ {
oscPrefix(); oscPrefix();
@ -1253,6 +1280,10 @@ void FTerm::resetXTermMouseForeground()
void FTerm::resetXTermMouseBackground() void FTerm::resetXTermMouseBackground()
{ {
// Reset the mouse background color // Reset the mouse background color
if ( putty_terminal )
return;
if ( xterm_terminal || screen_terminal || FTermcap::osc_support ) if ( xterm_terminal || screen_terminal || FTermcap::osc_support )
{ {
oscPrefix(); oscPrefix();
@ -1266,6 +1297,10 @@ void FTerm::resetXTermMouseBackground()
void FTerm::resetXTermHighlightBackground() void FTerm::resetXTermHighlightBackground()
{ {
// Reset the highlight background color // Reset the highlight background color
if ( putty_terminal )
return;
if ( xterm_terminal || screen_terminal if ( xterm_terminal || screen_terminal
|| urxvt_terminal || FTermcap::osc_support ) || urxvt_terminal || FTermcap::osc_support )
{ {
@ -1279,6 +1314,9 @@ void FTerm::resetXTermHighlightBackground()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::resetXTermDefaults() void FTerm::resetXTermDefaults()
{ {
if ( putty_terminal )
return;
setXTermCursorColor("rgb:b1b1/b1b1/b1b1"); setXTermCursorColor("rgb:b1b1/b1b1/b1b1");
resetXTermMouseForeground(); resetXTermMouseForeground();
resetXTermMouseBackground(); resetXTermMouseBackground();
@ -2719,7 +2757,7 @@ char* FTerm::parseSecDA (char*& current_termtype)
try try
{ {
// secondary device attributes (SEC_DA) <- decTerminalID string // Secondary device attributes (SEC_DA) <- decTerminalID string
sec_da = new FString(getSecDA()); sec_da = new FString(getSecDA());
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
@ -2742,6 +2780,8 @@ char* FTerm::parseSecDA (char*& current_termtype)
num_components = sec_da_list.size(); num_components = sec_da_list.size();
// The second device attribute (SEC_DA) always has 3 parameters,
// otherwise it usually has a copy of the device attribute (primary DA)
if ( num_components == 3 ) if ( num_components == 3 )
sec_da_supported = true; sec_da_supported = true;
@ -2797,6 +2837,10 @@ char* FTerm::parseSecDA (char*& current_termtype)
// Each gnome-terminal should be able to use 256 colors // Each gnome-terminal should be able to use 256 colors
color256 = true; color256 = true;
new_termtype = const_cast<char*>("gnome-256color"); new_termtype = const_cast<char*>("gnome-256color");
// VTE 0.40.0 or higher and gnome-terminal 3.16 or higher
if ( terminal_id_version >= 4000 )
decscusr_support = true;
} }
break; break;
@ -3145,8 +3189,9 @@ void FTerm::init_termcaps()
FTermcap::attr_without_color = 0; FTermcap::attr_without_color = 0;
// PuTTY has NC=22 however, it can show underline and reverse // 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 ) if ( putty_terminal )
FTermcap::attr_without_color = 16; FTermcap::attr_without_color = 0;
// get termcap strings // get termcap strings
// ------------------- // -------------------
@ -3253,6 +3298,22 @@ void FTerm::init_termcaps()
"%t10%p1%{8}%-%d" "%t10%p1%{8}%-%d"
"%e48;5;%p1%d%;m"); "%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) ) if ( ! TCAP(fc::t_clr_bol) )
TCAP(fc::t_clr_bol) = \ TCAP(fc::t_clr_bol) = \
const_cast<char*>(CSI "1K"); const_cast<char*>(CSI "1K");
@ -3277,14 +3338,6 @@ void FTerm::init_termcaps()
TCAP(fc::t_enable_acs) = \ TCAP(fc::t_enable_acs) = \
const_cast<char*>(ESC "(B" ESC ")0"); const_cast<char*>(ESC "(B" ESC ")0");
if ( ! TCAP(fc::t_set_attributes) )
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%;");
if ( ! TCAP(fc::t_enter_am_mode) ) if ( ! TCAP(fc::t_enter_am_mode) )
TCAP(fc::t_enter_am_mode) = \ TCAP(fc::t_enter_am_mode) = \
const_cast<char*>(CSI "?7h"); const_cast<char*>(CSI "?7h");
@ -3419,11 +3472,12 @@ void FTerm::init_termcaps()
"v\301w\302x\263" "v\301w\302x\263"
"y\363z\362~\371"); "y\363z\362~\371");
TCAP(fc::t_set_attributes) = \ TCAP(fc::t_set_attributes) = \
const_cast<char*>(CSI "0%?%p1%p6%|" const_cast<char*>(CSI "0"
"%t;1%;%?%p2%t;" "%?%p1%p6%|%t;1%;"
"4%;%?%p1%p3%|" "%?%p2%t;4%;"
"%t;7%;%?%p4%t;" "%?%p1%p3%|%t;7%;"
"5%;m%?%p9%t\016%e\017%;"); "%?%p4%t;5%;m"
"%?%p9%t\016%e\017%;");
FTermcap::attr_without_color = 18; FTermcap::attr_without_color = 18;
} }
#endif #endif
@ -3683,6 +3737,7 @@ void FTerm::init()
no_half_block_character = \ no_half_block_character = \
ascii_console = \ ascii_console = \
mouse_support = \ mouse_support = \
decscusr_support = \
force_vt100 = \ force_vt100 = \
tera_terminal = \ tera_terminal = \
kterm_terminal = \ kterm_terminal = \
@ -3804,6 +3859,9 @@ void FTerm::init()
{ {
if ( ! getXTermColorName(256).isEmpty() ) if ( ! getXTermColorName(256).isEmpty() )
{ {
if ( putty_terminal )
new_termtype = const_cast<char*>("putty-256color");
else
new_termtype = const_cast<char*>("xterm-256color"); new_termtype = const_cast<char*>("xterm-256color");
} }
else if ( ! getXTermColorName(87).isEmpty() ) else if ( ! getXTermColorName(87).isEmpty() )