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>
* SGR and URXVT mouse support for coordinates greater-than
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 *
* *
@ -61,7 +61,7 @@ int main (int argc, char* argv[])
y = (app.getLineNumber() - h) / 2;
dgl->setGeometry (x, y, w, h);
// Create another button group
// Create a button group
FButtonGroup* checkButtonGroup = new FButtonGroup("choice", dgl);
checkButtonGroup->setGeometry (2, 1, 16, 7);

View File

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

View File

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

View File

@ -1211,7 +1211,10 @@ void FListBox::adjustYOffset()
{
int element_count = int(getCount());
if ( element_count == 0 )
if ( getClientHeight() < 0 )
beep();
if ( element_count == 0 || getClientHeight() <= 0 )
return;
if ( yoffset > element_count - getClientHeight() )
@ -1427,7 +1430,7 @@ void FListBox::drawList()
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
, lineHasBrackets = hasBrackets(iter)

View File

@ -732,6 +732,14 @@ void FScrollView::copy2area()
, y_end = getViewportHeight()
, 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
{
char_data* vc; // viewport character

View File

@ -57,6 +57,7 @@ int FTerm::cursor_addres_lengths;
uInt FTerm::baudrate;
bool FTerm::resize_term;
bool FTerm::mouse_support;
bool FTerm::decscusr_support;
bool FTerm::terminal_detection;
bool FTerm::raw_mode;
bool FTerm::input_data_pending;
@ -1051,13 +1052,16 @@ void FTerm::setXTermCursorStyle (fc::xtermCursorStyle style)
{
// Set the xterm cursor style
if ( (gnome_terminal && ! decscusr_support) || kde_konsole )
return;
#if defined(__FreeBSD__) || defined(__DragonFly__)
if ( isFreeBSDConsole() )
return;
#endif
if ( (xterm_terminal || mintty_terminal)
&& ! (gnome_terminal || kde_konsole) )
if ( xterm_terminal || mintty_terminal || decscusr_support )
{
putstringf (CSI "%d q", style);
std::fflush(stdout);
@ -1168,6 +1172,9 @@ void FTerm::setXTermHighlightBackground (const FString& hbg)
//----------------------------------------------------------------------
void FTerm::setXTermDefaults()
{
if ( putty_terminal )
return;
setXTermMouseBackground("rgb:ffff/ffff/ffff");
setXTermMouseForeground ("rgb:0000/0000/0000");
@ -1188,6 +1195,10 @@ void FTerm::setXTermDefaults()
void FTerm::resetXTermColors()
{
// Reset the entire color table
if ( putty_terminal )
return;
if ( xterm_terminal || screen_terminal || FTermcap::osc_support )
{
oscPrefix();
@ -1201,6 +1212,10 @@ void FTerm::resetXTermColors()
void FTerm::resetXTermForeground()
{
// Reset the VT100 text foreground color
if ( putty_terminal )
return;
if ( xterm_terminal || screen_terminal || FTermcap::osc_support )
{
oscPrefix();
@ -1214,6 +1229,10 @@ void FTerm::resetXTermForeground()
void FTerm::resetXTermBackground()
{
// Reset the VT100 text background color
if ( putty_terminal )
return;
if ( xterm_terminal || screen_terminal || FTermcap::osc_support )
{
oscPrefix();
@ -1227,6 +1246,10 @@ void FTerm::resetXTermBackground()
void FTerm::resetXTermCursorColor()
{
// Reset the text cursor color
if ( putty_terminal )
return;
if ( xterm_terminal || screen_terminal || FTermcap::osc_support )
{
oscPrefix();
@ -1240,6 +1263,10 @@ void FTerm::resetXTermCursorColor()
void FTerm::resetXTermMouseForeground()
{
// Reset the mouse foreground color
if ( putty_terminal )
return;
if ( xterm_terminal || screen_terminal || FTermcap::osc_support )
{
oscPrefix();
@ -1253,6 +1280,10 @@ void FTerm::resetXTermMouseForeground()
void FTerm::resetXTermMouseBackground()
{
// Reset the mouse background color
if ( putty_terminal )
return;
if ( xterm_terminal || screen_terminal || FTermcap::osc_support )
{
oscPrefix();
@ -1266,6 +1297,10 @@ void FTerm::resetXTermMouseBackground()
void FTerm::resetXTermHighlightBackground()
{
// Reset the highlight background color
if ( putty_terminal )
return;
if ( xterm_terminal || screen_terminal
|| urxvt_terminal || FTermcap::osc_support )
{
@ -1279,6 +1314,9 @@ void FTerm::resetXTermHighlightBackground()
//----------------------------------------------------------------------
void FTerm::resetXTermDefaults()
{
if ( putty_terminal )
return;
setXTermCursorColor("rgb:b1b1/b1b1/b1b1");
resetXTermMouseForeground();
resetXTermMouseBackground();
@ -2719,7 +2757,7 @@ char* FTerm::parseSecDA (char*& current_termtype)
try
{
// secondary device attributes (SEC_DA) <- decTerminalID string
// Secondary device attributes (SEC_DA) <- decTerminalID string
sec_da = new FString(getSecDA());
}
catch (const std::bad_alloc& ex)
@ -2742,6 +2780,8 @@ char* FTerm::parseSecDA (char*& current_termtype)
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 )
sec_da_supported = true;
@ -2797,6 +2837,10 @@ char* FTerm::parseSecDA (char*& current_termtype)
// Each gnome-terminal should be able to use 256 colors
color256 = true;
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;
@ -3145,8 +3189,9 @@ void FTerm::init_termcaps()
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 = 16;
FTermcap::attr_without_color = 0;
// get termcap strings
// -------------------
@ -3253,6 +3298,22 @@ void FTerm::init_termcaps()
"%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");
@ -3277,14 +3338,6 @@ void FTerm::init_termcaps()
TCAP(fc::t_enable_acs) = \
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) )
TCAP(fc::t_enter_am_mode) = \
const_cast<char*>(CSI "?7h");
@ -3419,11 +3472,12 @@ void FTerm::init_termcaps()
"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%;");
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
@ -3683,6 +3737,7 @@ void FTerm::init()
no_half_block_character = \
ascii_console = \
mouse_support = \
decscusr_support = \
force_vt100 = \
tera_terminal = \
kterm_terminal = \
@ -3804,6 +3859,9 @@ void FTerm::init()
{
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() )