mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
tui: Only use dtterm's extension where supported.
This limits the use of dtterm's extension to DECSLPP to only those terminal types where it is known to be supported. Because it can be potentially understood as genuine DECSLPP sequence, setting the number of lines to a number larger than 25, which of course can cause confusion (especially if it is the width parameter that results in this) only use it on terminals that are known to support the dtterm extension. rxvt (Unicode) also understands dtterm's extension.
This commit is contained in:

committed by
Justin M. Keyes

parent
c4a8950281
commit
36d1fd0602
@@ -53,6 +53,9 @@ typedef enum TermType {
|
||||
kTermiTerm,
|
||||
kTermKonsole,
|
||||
kTermRxvt,
|
||||
kTermDTTerm,
|
||||
kTermXTerm,
|
||||
kTermTeraTerm,
|
||||
} TermType;
|
||||
|
||||
typedef struct {
|
||||
@@ -425,9 +428,16 @@ static void tui_resize(UI *ui, Integer width, Integer height)
|
||||
ugrid_resize(&data->grid, (int)width, (int)height);
|
||||
|
||||
if (!got_winch) { // Try to resize the terminal window.
|
||||
char r[16]; // enough for 9999x9999
|
||||
snprintf(r, sizeof(r), "\x1b[8;%d;%dt", (int)height, (int)width);
|
||||
out(ui, r, strlen(r));
|
||||
// Only send this extension to terminal types that we know understand it.
|
||||
if (data->term == kTermDTTerm // originated this extension
|
||||
|| data->term == kTermXTerm // per xterm ctlseqs doco
|
||||
|| data->term == kTermKonsole // per commentary in VT102Emulation.cpp
|
||||
|| data->term == kTermTeraTerm // per TeraTerm "Supported Control Functions" doco
|
||||
|| data->term == kTermRxvt) { // per command.C
|
||||
char r[16]; // enough for 9999x9999
|
||||
snprintf(r, sizeof(r), "\x1b[8;%d;%dt", height, width);
|
||||
out(ui, r, strlen(r));
|
||||
}
|
||||
} else { // Already handled the SIGWINCH signal; avoid double-resize.
|
||||
got_winch = false;
|
||||
}
|
||||
@@ -957,6 +967,15 @@ static TermType detect_term(const char *term, const char *colorterm)
|
||||
if (colorterm && strstr(colorterm, "gnome-terminal")) {
|
||||
return kTermGnome;
|
||||
}
|
||||
if (STARTS_WITH(term, "xterm")) {
|
||||
return kTermXTerm;
|
||||
}
|
||||
if (STARTS_WITH(term, "dtterm")) {
|
||||
return kTermDTTerm;
|
||||
}
|
||||
if (STARTS_WITH(term, "teraterm")) {
|
||||
return kTermTeraTerm;
|
||||
}
|
||||
return kTermUnknown;
|
||||
}
|
||||
|
||||
@@ -977,14 +996,14 @@ static void fix_terminfo(TUIData *data)
|
||||
unibi_set_if_empty(ut, unibi_flash_screen, "\x1b[?5h$<20/>\x1b[?5l");
|
||||
unibi_set_if_empty(ut, unibi_enter_italics_mode, "\x1b[3m");
|
||||
unibi_set_if_empty(ut, unibi_to_status_line, "\x1b]2");
|
||||
} else if (STARTS_WITH(term, "xterm")) {
|
||||
} else if (data->term == kTermXTerm) {
|
||||
unibi_set_if_empty(ut, unibi_to_status_line, "\x1b]0;");
|
||||
} else if (STARTS_WITH(term, "screen") || STARTS_WITH(term, "tmux")) {
|
||||
unibi_set_if_empty(ut, unibi_to_status_line, "\x1b_");
|
||||
unibi_set_if_empty(ut, unibi_from_status_line, "\x1b\\");
|
||||
}
|
||||
|
||||
if (STARTS_WITH(term, "xterm") || data->term == kTermRxvt) {
|
||||
if (data->term == kTermXTerm || data->term == kTermRxvt) {
|
||||
const char *normal = unibi_get_str(ut, unibi_cursor_normal);
|
||||
if (!normal) {
|
||||
unibi_set_str(ut, unibi_cursor_normal, "\x1b[?25h");
|
||||
|
Reference in New Issue
Block a user