aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan de Boyne Pollard <J.deBoynePollard-newsgroups@NTLWorld.com>2017-05-03 22:54:09 +0100
committerJustin M. Keyes <justinkz@gmail.com>2017-05-23 15:24:34 +0200
commit36d1fd0602d440e4c20cee852bcc43bfa83cb80f (patch)
treec1a6353ee9c27e8ed7f17534c904f6506c7c47a8
parentc4a89502819c93ea53ad46225fd06fa9e879476a (diff)
downloadrneovim-36d1fd0602d440e4c20cee852bcc43bfa83cb80f.tar.gz
rneovim-36d1fd0602d440e4c20cee852bcc43bfa83cb80f.tar.bz2
rneovim-36d1fd0602d440e4c20cee852bcc43bfa83cb80f.zip
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.
-rw-r--r--src/nvim/tui/tui.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index 8d240c91ae..5d9db94948 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -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");