From 3626d2107eae23433b88612b01bba7015951d37d Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 22 Sep 2019 21:51:55 +0200 Subject: terminfo_start: flush buffer #11074 This aligns with `terminfo_stop`, which also flushes the buffer after disabling things. This ensures Neovim gets the response to the terminal background query before exiting (`nvim -u NONE -cq` with e.g. urxvt or kitty). Caveats: * With kitty this causes some "flickering", likely since the alternate screen is being setup with `nvim -u NONE -cq`, whereas it would not be processed otherwise before quitting (as with the background query). * tmux after this patch may print ^[[I (CSI I / FocusGained) after `nvim -u NONE -cq`. Fixes https://github.com/neovim/neovim/issues/11062 --- src/nvim/tui/tui.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/tui/tui.c') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 791756e5c5..0b3bed1c76 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -312,6 +312,7 @@ static void terminfo_start(UI *ui) uv_pipe_init(&data->write_loop, &data->output_handle.pipe, 0); uv_pipe_open(&data->output_handle.pipe, data->out_fd); } + flush_buf(ui); } static void terminfo_stop(UI *ui) -- cgit From 445f2f409676f6e788861af439ce0b823aab3f37 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Tue, 24 Sep 2019 08:34:00 +0200 Subject: tui: flush ui buffer in tui_terminal_after_startup (#11083) This avoids having a dummy event to tickle the main loop. Confirmed using `nvim -u NONE -c 'au FocusGained * q'` in tmux (with `:set -g focus-events on`): without the flushing it would only exit after pressing a key. Moves the flushing done recently in 3626d2107. `nvim -u NONE -cq` is still working (i.e. consuming the response for the terminal background query itself), and the flickering mentioned in 3626d2107 is reduced again. Reverts part of bfb21f3e0 (#7729). --- src/nvim/tui/tui.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/nvim/tui/tui.c') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 0b3bed1c76..55c4a955c2 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -312,7 +312,6 @@ static void terminfo_start(UI *ui) uv_pipe_init(&data->write_loop, &data->output_handle.pipe, 0); uv_pipe_open(&data->output_handle.pipe, data->out_fd); } - flush_buf(ui); } static void terminfo_stop(UI *ui) @@ -364,6 +363,7 @@ static void tui_terminal_after_startup(UI *ui) // Emit this after Nvim startup, not during. This works around a tmux // 2.3 bug(?) which caused slow drawing during startup. #7649 unibi_out_ext(ui, data->unibi_ext.enable_focus_reporting); + flush_buf(ui); } static void tui_terminal_stop(UI *ui) @@ -431,9 +431,6 @@ static void tui_main(UIBridgeData *bridge, UI *ui) } if (!tui_is_stopped(ui)) { tui_terminal_after_startup(ui); - // Tickle `main_loop` with a dummy event, else the initial "focus-gained" - // terminal response may not get processed until user hits a key. - loop_schedule_deferred(&main_loop, event_create(loop_dummy_event, 0)); } // "Passive" (I/O-driven) loop: TUI thread "main loop". while (!tui_is_stopped(ui)) { -- cgit From 34d55f86077e8a937c1ac1b0a0c551a5968fa7f8 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 29 Sep 2019 03:06:36 +0200 Subject: terminfo_start: keep first flushing of ui buffer (#11118) Initially done in 3626d2107 (#11074, for #11062), it was reverted then in 445f2f409 (#11083, which added flushing later). But it is still required here to avoid the reporting of the background response with urxvt/kitty (`nvim -u NONE -cq`). Apparently I've tested this not enough with 445f2f409 (probably only within tmux). --- src/nvim/tui/tui.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/tui/tui.c') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 55c4a955c2..0c282a3f1f 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -312,6 +312,7 @@ static void terminfo_start(UI *ui) uv_pipe_init(&data->write_loop, &data->output_handle.pipe, 0); uv_pipe_open(&data->output_handle.pipe, data->out_fd); } + flush_buf(ui); } static void terminfo_stop(UI *ui) -- cgit From 8a4ae3d664a22cfaa3ec05635d26a8d662458c7e Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Mon, 30 Sep 2019 22:00:55 +0200 Subject: tui: improve handle_background_color: short-circuit (#11067) * handle_background_color: short-circuit if handled already * Unit tests for handle_background_color * set waiting_for_bg_response to false in tui_terminal_after_startup By then it should have been received. --- src/nvim/tui/tui.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/nvim/tui/tui.c') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 0c282a3f1f..4ca44b25f0 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -296,6 +296,7 @@ static void terminfo_start(UI *ui) unibi_out(ui, unibi_keypad_xmit); unibi_out(ui, unibi_clear_screen); // Ask the terminal to send us the background color. + data->input.waiting_for_bg_response = true; unibi_out_ext(ui, data->unibi_ext.get_bg); // Enable bracketed paste unibi_out_ext(ui, data->unibi_ext.enable_bracketed_paste); @@ -365,6 +366,11 @@ static void tui_terminal_after_startup(UI *ui) // 2.3 bug(?) which caused slow drawing during startup. #7649 unibi_out_ext(ui, data->unibi_ext.enable_focus_reporting); flush_buf(ui); + + if (data->input.waiting_for_bg_response) { + DLOG("did not get a response for terminal background query"); + data->input.waiting_for_bg_response = false; + } } static void tui_terminal_stop(UI *ui) -- cgit From 8e25cf3881bbc3d65645d1b2abc6fa46863b1765 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Wed, 2 Oct 2019 04:07:10 +0200 Subject: patch_terminfo_bugs: TERM=xterm with non-xterm: ignore smglr (#11132) "smglr" was added for TERM=xterm recently to the terminfo database, which causes display issues with terminals that use `TERM=xterm` by default for themselves, although not supporting it. This patch makes "smglr" to be ignored then. Fixes https://github.com/neovim/neovim/issues/10562 --- src/nvim/tui/tui.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/nvim/tui/tui.c') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 4ca44b25f0..956d4eb9da 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -93,7 +93,7 @@ typedef struct { int out_fd; bool scroll_region_is_full_screen; bool can_change_scroll_region; - bool can_set_lr_margin; + bool can_set_lr_margin; // smglr bool can_set_left_right_margin; bool can_scroll; bool can_erase_chars; @@ -1603,6 +1603,12 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, unibi_set_if_empty(ut, unibi_set_lr_margin, "\x1b[%i%p1%d;%p2%ds"); unibi_set_if_empty(ut, unibi_set_left_margin_parm, "\x1b[%i%p1%ds"); unibi_set_if_empty(ut, unibi_set_right_margin_parm, "\x1b[%i;%p2%ds"); + } else { + // Fix things advertised via TERM=xterm, for non-xterm. + if (unibi_get_str(ut, unibi_set_lr_margin)) { + ILOG("Disabling smglr with TERM=xterm for non-xterm."); + unibi_set_str(ut, unibi_set_lr_margin, NULL); + } } #ifdef WIN32 -- cgit From f96d1e6bc416fe0d1d11321234637695ff0e514e Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 3 Oct 2019 08:04:24 +0200 Subject: tui: fix handling of bg response after suspend (#11145) `tui_terminal_after_startup` gets called right after resuming from suspending (via `Ctrl-z`) already (not delayed as with the startup itself), and would set `waiting_for_bg_response` to false then directly. This results in the terminal response not being processed then anymore, and leaking into Neovim itself. This changes it to try 5 times always, which means that it typically would stop after a few characters of input from the user typically, e.g. with tmux, which does not send a reply. While it might be better to have something based on the time (e.g. only wait for max 1s), this appears to be easier to do. Fixes regression in 8a4ae3d. --- src/nvim/tui/tui.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src/nvim/tui/tui.c') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 956d4eb9da..150862bb18 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -296,7 +296,7 @@ static void terminfo_start(UI *ui) unibi_out(ui, unibi_keypad_xmit); unibi_out(ui, unibi_clear_screen); // Ask the terminal to send us the background color. - data->input.waiting_for_bg_response = true; + data->input.waiting_for_bg_response = 5; unibi_out_ext(ui, data->unibi_ext.get_bg); // Enable bracketed paste unibi_out_ext(ui, data->unibi_ext.enable_bracketed_paste); @@ -366,11 +366,6 @@ static void tui_terminal_after_startup(UI *ui) // 2.3 bug(?) which caused slow drawing during startup. #7649 unibi_out_ext(ui, data->unibi_ext.enable_focus_reporting); flush_buf(ui); - - if (data->input.waiting_for_bg_response) { - DLOG("did not get a response for terminal background query"); - data->input.waiting_for_bg_response = false; - } } static void tui_terminal_stop(UI *ui) -- cgit From 6fd6f4683d19d5ca18f48c1d1f0d87113e80368e Mon Sep 17 00:00:00 2001 From: erw7 Date: Mon, 21 Oct 2019 07:47:08 +0900 Subject: TUI/thread: guard env map from potential race with unibilium #11259 unibi_from_term calls getenv internally, so exclusive control is required. --- src/nvim/tui/tui.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/nvim/tui/tui.c') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 150862bb18..945b093f32 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -234,7 +234,9 @@ static void terminfo_start(UI *ui) // Set up unibilium/terminfo. char *termname = NULL; if (term) { + os_env_var_lock(); data->ut = unibi_from_term(term); + os_env_var_unlock(); if (data->ut) { termname = xstrdup(term); } -- cgit From eb509dc7c52cba4e837f4500dc28b0519d1fc11d Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Wed, 11 Sep 2019 12:26:21 +0200 Subject: tui: simplify branching of rgb vs cterm colors --- src/nvim/tui/tui.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'src/nvim/tui/tui.c') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 945b093f32..e984d0fc6e 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -515,20 +515,8 @@ static void update_attrs(UI *ui, int attr_id) } data->print_attr_id = attr_id; HlAttrs attrs = kv_A(data->attrs, (size_t)attr_id); - - int fg = ui->rgb ? attrs.rgb_fg_color : (attrs.cterm_fg_color - 1); - if (fg == -1) { - fg = ui->rgb ? data->clear_attrs.rgb_fg_color - : (data->clear_attrs.cterm_fg_color - 1); - } - - int bg = ui->rgb ? attrs.rgb_bg_color : (attrs.cterm_bg_color - 1); - if (bg == -1) { - bg = ui->rgb ? data->clear_attrs.rgb_bg_color - : (data->clear_attrs.cterm_bg_color - 1); - } - int attr = ui->rgb ? attrs.rgb_ae_attr : attrs.cterm_ae_attr; + bool bold = attr & HL_BOLD; bool italic = attr & HL_ITALIC; bool reverse = attr & HL_INVERSE; @@ -596,7 +584,10 @@ static void update_attrs(UI *ui, int attr_id) unibi_out_ext(ui, data->unibi_ext.set_underline_color); } } + + int fg, bg; if (ui->rgb) { + fg = (attrs.rgb_fg_color != -1) ? attrs.rgb_fg_color : data->clear_attrs.rgb_fg_color; if (fg != -1) { UNIBI_SET_NUM_VAR(data->params[0], (fg >> 16) & 0xff); // red UNIBI_SET_NUM_VAR(data->params[1], (fg >> 8) & 0xff); // green @@ -604,6 +595,7 @@ static void update_attrs(UI *ui, int attr_id) unibi_out_ext(ui, data->unibi_ext.set_rgb_foreground); } + bg = (attrs.rgb_bg_color != -1) ? attrs.rgb_bg_color : data->clear_attrs.rgb_bg_color; if (bg != -1) { UNIBI_SET_NUM_VAR(data->params[0], (bg >> 16) & 0xff); // red UNIBI_SET_NUM_VAR(data->params[1], (bg >> 8) & 0xff); // green @@ -611,11 +603,13 @@ static void update_attrs(UI *ui, int attr_id) unibi_out_ext(ui, data->unibi_ext.set_rgb_background); } } else { + fg = attrs.cterm_fg_color ? attrs.cterm_fg_color - 1 : (data->clear_attrs.cterm_fg_color - 1); if (fg != -1) { UNIBI_SET_NUM_VAR(data->params[0], fg); unibi_out(ui, unibi_set_a_foreground); } + bg = attrs.cterm_bg_color ? attrs.cterm_bg_color - 1 : (data->clear_attrs.cterm_bg_color - 1); if (bg != -1) { UNIBI_SET_NUM_VAR(data->params[0], bg); unibi_out(ui, unibi_set_a_background); -- cgit From 08fe10010ab438451d976e8fb412c3034d9ffeed Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Wed, 11 Sep 2019 12:30:29 +0200 Subject: terminal: enable pass through indexed colors to TUI --- src/nvim/tui/tui.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'src/nvim/tui/tui.c') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index e984d0fc6e..11746441aa 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -586,16 +586,27 @@ static void update_attrs(UI *ui, int attr_id) } int fg, bg; - if (ui->rgb) { - fg = (attrs.rgb_fg_color != -1) ? attrs.rgb_fg_color : data->clear_attrs.rgb_fg_color; + if (ui->rgb && !(attr & HL_FG_INDEXED)) { + fg = ((attrs.rgb_fg_color != -1) + ? attrs.rgb_fg_color : data->clear_attrs.rgb_fg_color); if (fg != -1) { UNIBI_SET_NUM_VAR(data->params[0], (fg >> 16) & 0xff); // red UNIBI_SET_NUM_VAR(data->params[1], (fg >> 8) & 0xff); // green UNIBI_SET_NUM_VAR(data->params[2], fg & 0xff); // blue unibi_out_ext(ui, data->unibi_ext.set_rgb_foreground); } + } else { + fg = (attrs.cterm_fg_color + ? attrs.cterm_fg_color - 1 : (data->clear_attrs.cterm_fg_color - 1)); + if (fg != -1) { + UNIBI_SET_NUM_VAR(data->params[0], fg); + unibi_out(ui, unibi_set_a_foreground); + } + } - bg = (attrs.rgb_bg_color != -1) ? attrs.rgb_bg_color : data->clear_attrs.rgb_bg_color; + if (ui->rgb && !(attr & HL_BG_INDEXED)) { + bg = ((attrs.rgb_bg_color != -1) + ? attrs.rgb_bg_color : data->clear_attrs.rgb_bg_color); if (bg != -1) { UNIBI_SET_NUM_VAR(data->params[0], (bg >> 16) & 0xff); // red UNIBI_SET_NUM_VAR(data->params[1], (bg >> 8) & 0xff); // green @@ -603,19 +614,15 @@ static void update_attrs(UI *ui, int attr_id) unibi_out_ext(ui, data->unibi_ext.set_rgb_background); } } else { - fg = attrs.cterm_fg_color ? attrs.cterm_fg_color - 1 : (data->clear_attrs.cterm_fg_color - 1); - if (fg != -1) { - UNIBI_SET_NUM_VAR(data->params[0], fg); - unibi_out(ui, unibi_set_a_foreground); - } - - bg = attrs.cterm_bg_color ? attrs.cterm_bg_color - 1 : (data->clear_attrs.cterm_bg_color - 1); + bg = (attrs.cterm_bg_color + ? attrs.cterm_bg_color - 1 : (data->clear_attrs.cterm_bg_color - 1)); if (bg != -1) { UNIBI_SET_NUM_VAR(data->params[0], bg); unibi_out(ui, unibi_set_a_background); } } + data->default_attr = fg == -1 && bg == -1 && !bold && !italic && !underline && !undercurl && !reverse && !standout && !strikethrough; -- cgit From 91f4bb0aeec0b2ae983ea310ada73be5f35f7c5c Mon Sep 17 00:00:00 2001 From: erw7 Date: Mon, 18 Nov 2019 05:58:58 +0900 Subject: TUI: use stdio names instead of magic numbers #11410 --- src/nvim/tui/tui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/tui/tui.c') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 11746441aa..60e1353000 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -220,7 +220,7 @@ static void terminfo_start(UI *ui) data->unibi_ext.reset_cursor_style = -1; data->unibi_ext.get_bg = -1; data->unibi_ext.set_underline_color = -1; - data->out_fd = 1; + data->out_fd = STDOUT_FILENO; data->out_isatty = os_isatty(data->out_fd); const char *term = os_getenv("TERM"); -- cgit From 65aca4d857ab9ff278f410b17ef31d91e48a37b7 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Thu, 19 Dec 2019 21:27:21 +0100 Subject: TUI: can make the cursor transparent #11519 when setting 'guicursor' highlight blend=100. --- src/nvim/tui/tui.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/nvim/tui/tui.c') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 60e1353000..e168cf079a 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -100,7 +100,7 @@ typedef struct { bool immediate_wrap_after_last_column; bool bce; bool mouse_enabled; - bool busy, is_invisible; + bool busy, is_invisible, want_invisible; bool cork, overflow; bool cursor_color_changed; bool is_starting; @@ -198,6 +198,7 @@ static void terminfo_start(UI *ui) data->default_attr = false; data->can_clear_attr = false; data->is_invisible = true; + data->want_invisible = false; data->busy = false; data->cork = false; data->overflow = false; @@ -1032,7 +1033,11 @@ static void tui_set_mode(UI *ui, ModeShape mode) if (c.id != 0 && c.id < (int)kv_size(data->attrs) && ui->rgb) { HlAttrs aep = kv_A(data->attrs, c.id); - if (aep.rgb_ae_attr & HL_INVERSE) { + + data->want_invisible = aep.hl_blend == 100; + if (data->want_invisible) { + unibi_out(ui, unibi_cursor_invisible); + } else if (aep.rgb_ae_attr & HL_INVERSE) { // We interpret "inverse" as "default" (no termcode for "inverse"...). // Hopefully the user's default cursor color is inverse. unibi_out_ext(ui, data->unibi_ext.reset_cursor_color); @@ -1980,10 +1985,12 @@ static void flush_buf(UI *ui) assert(data->is_invisible); // not busy and the cursor is invisible. Write a "cursor normal" command // after writing the buffer. - bufp->base = data->norm; - bufp->len = UV_BUF_LEN(data->normlen); - bufp++; - data->is_invisible = data->busy; + if (!data->want_invisible) { + bufp->base = data->norm; + bufp->len = UV_BUF_LEN(data->normlen); + bufp++; + } + data->is_invisible = false; } uv_write(&req, STRUCT_CAST(uv_stream_t, &data->output_handle), -- cgit From 45759e44f9cff9deef1538933fad3e42f94d5930 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 8 Jan 2020 01:08:55 -0500 Subject: Remove (void) hacks, Mark unused attrs --- src/nvim/tui/tui.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/nvim/tui/tui.c') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index e168cf079a..e9276db484 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1073,9 +1073,8 @@ static void tui_mode_change(UI *ui, String mode, Integer mode_idx) static void tui_grid_scroll(UI *ui, Integer g, Integer startrow, Integer endrow, Integer startcol, Integer endcol, - Integer rows, Integer cols) + Integer rows, Integer cols FUNC_ATTR_UNUSED) { - (void)cols; // unused TUIData *data = ui->data; UGrid *grid = &data->grid; int top = (int)startrow, bot = (int)endrow-1; -- cgit From 96059d72e539c0a23c1f7a24290f35247ff01749 Mon Sep 17 00:00:00 2001 From: Jakub Łuczyński Date: Mon, 24 Feb 2020 02:59:37 +0100 Subject: TUI: reset background color before scroll #11909 fixes #11893 --- src/nvim/tui/tui.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nvim/tui/tui.c') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index e9276db484..22f4501be2 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1099,6 +1099,7 @@ static void tui_grid_scroll(UI *ui, Integer g, Integer startrow, Integer endrow, set_scroll_region(ui, top, bot, left, right); } cursor_goto(ui, top, left); + update_attrs(ui, 0); if (rows > 0) { if (rows == 1) { -- cgit From 8b64a77144a87fbc9efe5535979ac612dc8e1f1b Mon Sep 17 00:00:00 2001 From: erw7 Date: Thu, 12 Mar 2020 15:16:25 +0900 Subject: Fix splitting issue on gnu screen gnu screen does not have smglr, but it inherits smglr from xterm and splitting will cause drawing problems. So disable smglr. --- src/nvim/tui/tui.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/nvim/tui/tui.c') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 22f4501be2..3e02910996 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1631,6 +1631,11 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, // per the screen manual; 2017-04 terminfo.src lacks these. unibi_set_if_empty(ut, unibi_to_status_line, "\x1b_"); unibi_set_if_empty(ut, unibi_from_status_line, "\x1b\\"); + // Fix an issue where smglr is inherited by TERM=screen.xterm. + if (unibi_get_str(ut, unibi_set_lr_margin)) { + ILOG("Disabling smglr with TERM=screen.xterm for screen."); + unibi_set_str(ut, unibi_set_lr_margin, NULL); + } } else if (tmux) { unibi_set_if_empty(ut, unibi_to_status_line, "\x1b_"); unibi_set_if_empty(ut, unibi_from_status_line, "\x1b\\"); -- cgit From 9333f86ab7d0e85d9f658bfe455860771de9b997 Mon Sep 17 00:00:00 2001 From: erw7 Date: Fri, 20 Mar 2020 03:31:10 +0900 Subject: TUI: do not use "nvim_get_option" in tui thread Since "nvim_get_option" is executed on the tui thread as a C function instead of msgpack-rpc, it accesses global variables that may change on the main thread. --- src/nvim/tui/tui.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/nvim/tui/tui.c') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 22f4501be2..99abdd033b 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1292,6 +1292,12 @@ static void tui_option_set(UI *ui, String name, Object value) data->print_attr_id = -1; invalidate(ui, 0, data->grid.height, 0, data->grid.width); } + if (strequal(name.data, "ttimeout")) { + data->input.ttimeout = value.data.boolean; + } + if (strequal(name.data, "ttimeoutlen")) { + data->input.ttimeoutlen = (long)value.data.integer; + } } static void tui_raw_line(UI *ui, Integer g, Integer linerow, Integer startcol, -- cgit From b3a66faf66f3e835b3d699a105d2cca2de5f151f Mon Sep 17 00:00:00 2001 From: Thomas Churchman Date: Tue, 14 Apr 2020 00:07:30 +0200 Subject: TUI: support setting cursor color in tmux (#12100) --- src/nvim/tui/tui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/tui/tui.c') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 99abdd033b..2a64b25a17 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1903,7 +1903,7 @@ static void augment_terminfo(TUIData *data, const char *term, // would use a tmux control sequence and an extra if(screen) test. data->unibi_ext.set_cursor_color = (int)unibi_add_ext_str( ut, NULL, TMUX_WRAP(tmux, "\033]Pl%p1%06x\033\\")); - } else if ((xterm || rxvt || alacritty) + } else if ((xterm || rxvt || tmux || alacritty) && (vte_version == 0 || vte_version >= 3900)) { // Supported in urxvt, newer VTE. data->unibi_ext.set_cursor_color = (int)unibi_add_ext_str( -- cgit From 8745247cba17bba41eb3f4fc396d30335625ab83 Mon Sep 17 00:00:00 2001 From: erw7 Date: Mon, 20 Apr 2020 21:50:44 +0900 Subject: tui: Don't call uv_write without output (#12146) Fixes #11653, #11990. Check for cursor visibility to toggle uv_write call. --- src/nvim/tui/tui.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src/nvim/tui/tui.c') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 0c330149d0..8bcdb681a2 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1973,7 +1973,23 @@ static void flush_buf(UI *ui) uv_buf_t *bufp = &bufs[0]; TUIData *data = ui->data; - if (data->bufpos <= 0 && data->busy == data->is_invisible) { + // The content of the output for each condition is shown in the following + // table. Therefore, if data->bufpos == 0 and N/A or invis + norm, there is + // no need to output it. + // + // | is_invisible | !is_invisible + // ------+-----------------+--------------+--------------- + // busy | want_invisible | N/A | invis + // | !want_invisible | N/A | invis + // ------+-----------------+--------------+--------------- + // !busy | want_invisible | N/A | invis + // | !want_invisible | norm | invis + norm + // ------+-----------------+--------------+--------------- + // + if (data->bufpos <= 0 + && ((data->is_invisible && data->busy) + || (data->is_invisible && !data->busy && data->want_invisible) + || (!data->is_invisible && !data->busy && !data->want_invisible))) { return; } @@ -2000,8 +2016,8 @@ static void flush_buf(UI *ui) bufp->base = data->norm; bufp->len = UV_BUF_LEN(data->normlen); bufp++; + data->is_invisible = false; } - data->is_invisible = false; } uv_write(&req, STRUCT_CAST(uv_stream_t, &data->output_handle), -- cgit From c5217c67df2e08b73ef3a8217b0d9c953467fde1 Mon Sep 17 00:00:00 2001 From: Kei Kamikawa Date: Sun, 26 Apr 2020 10:22:40 +0900 Subject: TUI: block signals on suspend #12180 fix #8075 --- src/nvim/tui/tui.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/nvim/tui/tui.c') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 8bcdb681a2..1aa8df905e 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -31,6 +31,7 @@ #include "nvim/event/signal.h" #include "nvim/os/input.h" #include "nvim/os/os.h" +#include "nvim/os/signal.h" #include "nvim/os/tty.h" #include "nvim/strings.h" #include "nvim/syntax.h" @@ -1239,7 +1240,9 @@ static void suspend_event(void **argv) tui_terminal_stop(ui); data->cont_received = false; stream_set_blocking(input_global_fd(), true); // normalize stream (#2598) + signal_stop(); kill(0, SIGTSTP); + signal_start(); while (!data->cont_received) { // poll the event loop until SIGCONT is received loop_poll_events(data->loop, -1); -- cgit From f3ffe0b325170dd214b80e371bee5a56b7054940 Mon Sep 17 00:00:00 2001 From: erw7 Date: Sun, 26 Apr 2020 22:15:47 +0900 Subject: tui: improve support for GNU Screen (#12098) Wrapping it in DCS allows the following features to work with GNU Screen. - Changing the cursor style. - bracketed paste. - focus reporting. --- src/nvim/tui/tui.c | 147 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 104 insertions(+), 43 deletions(-) (limited to 'src/nvim/tui/tui.c') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 1aa8df905e..228545a844 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -49,10 +49,15 @@ #define OUTBUF_SIZE 0xffff #define TOO_MANY_EVENTS 1000000 -#define STARTS_WITH(str, prefix) (strlen(str) >= (sizeof(prefix) - 1) \ - && 0 == memcmp((str), (prefix), sizeof(prefix) - 1)) -#define TMUX_WRAP(is_tmux, seq) ((is_tmux) \ - ? "\x1bPtmux;\x1b" seq "\x1b\\" : seq) +#define STARTS_WITH(str, prefix) \ + (strlen(str) >= (sizeof(prefix) - 1) && 0 == memcmp((str), (prefix), \ + sizeof(prefix) - 1)) +#define SCREEN_WRAP(is_screen, seq) ((is_screen) \ + ? DCS_STR seq STERM_STR : seq) +#define SCREEN_TMUX_WRAP(is_screen, is_tmux, seq) \ + ((is_screen) \ + ? DCS_STR seq STERM_STR : (is_tmux) \ + ? DCS_STR "tmux;\x1b" seq STERM_STR : seq) #define LINUXSET0C "\x1b[?0c" #define LINUXSET1C "\x1b[?1c" @@ -1538,7 +1543,10 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, bool rxvt = terminfo_is_term_family(term, "rxvt"); bool teraterm = terminfo_is_term_family(term, "teraterm"); bool putty = terminfo_is_term_family(term, "putty"); - bool screen = terminfo_is_term_family(term, "screen"); + bool screen = terminfo_is_term_family(term, "screen") && !os_getenv("TMUX"); + bool screen_host_linuxvt = + terminfo_is_term_family(screen && term[6] == '.' + ? term + 7 : NULL, "linux"); bool tmux = terminfo_is_term_family(term, "tmux") || !!os_getenv("TMUX"); bool st = terminfo_is_term_family(term, "st"); bool gnome = terminfo_is_term_family(term, "gnome") @@ -1697,8 +1705,9 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, #define XTERM_SETAB_16 \ "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e39%;m" - data->unibi_ext.get_bg = (int)unibi_add_ext_str(ut, "ext.get_bg", - "\x1b]11;?\x07"); + data->unibi_ext.get_bg = + (int)unibi_add_ext_str(ut, "ext.get_bg", + SCREEN_TMUX_WRAP(screen, tmux, "\x1b]11;?\x07")); // Terminals with 256-colour SGR support despite what terminfo says. if (unibi_get_num(ut, unibi_max_colors) < 256) { @@ -1733,6 +1742,32 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, data->unibi_ext.set_cursor_style = unibi_find_ext_str(ut, "Ss"); } + // GNU Screen does not have Ss/Se. When terminfo has Ss/Se, it is wrapped with + // DCS because it is inherited from the host terminal. + if (screen) { + size_t len; + size_t dcs_st_len = strlen(DCS_STR) + strlen(STERM_STR); + if (-1 != data->unibi_ext.set_cursor_style) { + const char *orig_ss = + unibi_get_ext_str(data->ut, (size_t)data->unibi_ext.reset_cursor_style); + len = STRLEN(orig_ss) + dcs_st_len + 1; + char *ss = xmalloc(len); + snprintf(ss, len, "%s%s%s", DCS_STR, orig_ss, STERM_STR); + unibi_set_ext_str(data->ut, (size_t)data->unibi_ext.set_cursor_style, ss); + xfree(ss); + } + if (-1 != data->unibi_ext.reset_cursor_style) { + const char *orig_se = + unibi_get_ext_str(data->ut, (size_t)data->unibi_ext.reset_cursor_style); + len = strlen(orig_se) + dcs_st_len + 1; + char *se = xmalloc(len); + snprintf(se, len, "%s%s%s", DCS_STR, orig_se, STERM_STR); + unibi_set_ext_str(data->ut, + (size_t)data->unibi_ext.reset_cursor_style, se); + xfree(se); + } + } + // Dickey ncurses terminfo includes Ss/Se capabilities since 2011-07-14. So // adding them to terminal types, that have such control sequences but lack // the correct terminfo entries, is a fixup, not an augmentation. @@ -1748,7 +1783,12 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, || (konsolev >= 180770) // #9364 || tmux // per tmux manual page // https://lists.gnu.org/archive/html/screen-devel/2013-03/msg00000.html - || screen + || (screen + && (!screen_host_linuxvt + || (screen_host_linuxvt + && (xterm_version || (vte_version > 0) || colorterm)))) + // Since GNU Screen does not support DECSCUSR, DECSCUSR is wrapped + // in DCS and output to the host terminal. || st // #7641 || rxvt // per command.C // per analysis of VT100Terminal.m @@ -1761,34 +1801,43 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, || (linuxvt && (xterm_version || (vte_version > 0) || colorterm)))) { data->unibi_ext.set_cursor_style = - (int)unibi_add_ext_str(ut, "Ss", "\x1b[%p1%d q"); + (int)unibi_add_ext_str(ut, "Ss", SCREEN_WRAP(screen, "\x1b[%p1%d q")); if (-1 == data->unibi_ext.reset_cursor_style) { data->unibi_ext.reset_cursor_style = (int)unibi_add_ext_str(ut, "Se", ""); } unibi_set_ext_str(ut, (size_t)data->unibi_ext.reset_cursor_style, - "\x1b[ q"); - } else if (linuxvt) { + SCREEN_WRAP(screen, "\x1b[ q")); + } else if (linuxvt || screen_host_linuxvt) { // Linux uses an idiosyncratic escape code to set the cursor shape and // does not support DECSCUSR. // See http://linuxgazette.net/137/anonymous.html for more info - data->unibi_ext.set_cursor_style = (int)unibi_add_ext_str(ut, "Ss", - "\x1b[?" - "%?" - // The parameter passed to Ss is the DECSCUSR parameter, so the - // terminal capability has to translate into the Linux idiosyncratic - // parameter. - // - // linuxvt only supports block and underline. It is also only - // possible to have a steady block (no steady underline) - "%p1%{2}%<" "%t%{8}" // blink block - "%e%p1%{2}%=" "%t%{112}" // steady block - "%e%p1%{3}%=" "%t%{4}" // blink underline (set to half block) - "%e%p1%{4}%=" "%t%{4}" // steady underline - "%e%p1%{5}%=" "%t%{2}" // blink bar (set to underline) - "%e%p1%{6}%=" "%t%{2}" // steady bar - "%e%{0}" // anything else - "%;" "%dc"); + // + // Since gnu Screen does not have Ss/Se, if the host terminal is a linux + // console that does not support xterm extensions, it will wraps the + // linux-specific sequence in DCS and outputs it. + data->unibi_ext.set_cursor_style = (int)unibi_add_ext_str( + ut, "Ss", + SCREEN_WRAP(screen, + "\x1b[?" + "%?" + // The parameter passed to Ss is the DECSCUSR parameter, + // so the + // terminal capability has to translate into the Linux + // idiosyncratic parameter. + // + // linuxvt only supports block and underline. It is also + // only possible to have a steady block (no steady + // underline) + "%p1%{2}%<" "%t%{8}" // blink block + "%e%p1%{2}%=" "%t%{112}" // steady block + "%e%p1%{3}%=" "%t%{4}" // blink underline (set to half + // block) + "%e%p1%{4}%=" "%t%{4}" // steady underline + "%e%p1%{5}%=" "%t%{2}" // blink bar (set to underline) + "%e%p1%{6}%=" "%t%{2}" // steady bar + "%e%{0}" // anything else + "%;" "%dc")); if (-1 == data->unibi_ext.reset_cursor_style) { data->unibi_ext.reset_cursor_style = (int)unibi_add_ext_str(ut, "Se", ""); @@ -1798,21 +1847,25 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, } else if (konsolev > 0 && konsolev < 180770) { // Konsole before version 18.07.70: set up a nonce profile. This has // side-effects on temporary font resizing. #6798 - data->unibi_ext.set_cursor_style = (int)unibi_add_ext_str(ut, "Ss", - TMUX_WRAP(tmux, "\x1b]50;CursorShape=%?" - "%p1%{3}%<" "%t%{0}" // block - "%e%p1%{5}%<" "%t%{2}" // underline - "%e%{1}" // everything else is bar - "%;%d;BlinkingCursorEnabled=%?" - "%p1%{1}%<" "%t%{1}" // Fortunately if we exclude zero as special, - "%e%p1%{1}%&" // in all other cases we can treat bit #0 as a flag. - "%;%d\x07")); + data->unibi_ext.set_cursor_style = (int)unibi_add_ext_str( + ut, "Ss", + SCREEN_TMUX_WRAP(screen, tmux, + "\x1b]50;CursorShape=%?" + "%p1%{3}%<" "%t%{0}" // block + "%e%p1%{5}%<" "%t%{2}" // underline + "%e%{1}" // everything else is bar + "%;%d;BlinkingCursorEnabled=%?" + "%p1%{1}%<" "%t%{1}" // Fortunately if we exclude + // zero as special, + "%e%p1%{1}%&" // in all other c2ses we can treat bit + // #0 as a flag. + "%;%d\x07")); if (-1 == data->unibi_ext.reset_cursor_style) { data->unibi_ext.reset_cursor_style = (int)unibi_add_ext_str(ut, "Se", ""); } unibi_set_ext_str(ut, (size_t)data->unibi_ext.reset_cursor_style, - "\x1b]50;\x07"); + SCREEN_TMUX_WRAP(screen, tmux, "\x1b]50;\x07")); } } } @@ -1841,6 +1894,8 @@ static void augment_terminfo(TUIData *data, const char *term, bool alacritty = terminfo_is_term_family(term, "alacritty"); // None of the following work over SSH; see :help TERM . bool iterm_pretending_xterm = xterm && iterm_env; + bool screen_host_rxvt = + terminfo_is_term_family(screen && term[6] == '.' ? term + 7 : NULL, "rxvt"); const char *xterm_version = os_getenv("XTERM_VERSION"); bool true_xterm = xterm && !!xterm_version && !bsdvt; @@ -1910,7 +1965,7 @@ static void augment_terminfo(TUIData *data, const char *term, // all panes, which is not particularly desirable. A better approach // would use a tmux control sequence and an extra if(screen) test. data->unibi_ext.set_cursor_color = (int)unibi_add_ext_str( - ut, NULL, TMUX_WRAP(tmux, "\033]Pl%p1%06x\033\\")); + ut, NULL, SCREEN_TMUX_WRAP(screen, tmux, "\033]Pl%p1%06x\033\\")); } else if ((xterm || rxvt || tmux || alacritty) && (vte_version == 0 || vte_version >= 3900)) { // Supported in urxvt, newer VTE. @@ -1930,21 +1985,27 @@ static void augment_terminfo(TUIData *data, const char *term, /// Terminals usually ignore unrecognized private modes, and there is no /// known ambiguity with these. So we just set them unconditionally. + /// If the DECSET is not supported by GNU Screen, it is wrapped with DCS and + /// sent to the host terminal. data->unibi_ext.enable_lr_margin = (int)unibi_add_ext_str( ut, "ext.enable_lr_margin", "\x1b[?69h"); data->unibi_ext.disable_lr_margin = (int)unibi_add_ext_str( ut, "ext.disable_lr_margin", "\x1b[?69l"); data->unibi_ext.enable_bracketed_paste = (int)unibi_add_ext_str( - ut, "ext.enable_bpaste", "\x1b[?2004h"); + ut, "ext.enable_bpaste", SCREEN_WRAP(screen, "\x1b[?2004h")); data->unibi_ext.disable_bracketed_paste = (int)unibi_add_ext_str( - ut, "ext.disable_bpaste", "\x1b[?2004l"); + ut, "ext.disable_bpaste", SCREEN_WRAP(screen, "\x1b[?2004l")); // For urxvt send BOTH xterm and old urxvt sequences. #8695 data->unibi_ext.enable_focus_reporting = (int)unibi_add_ext_str( ut, "ext.enable_focus", - rxvt ? "\x1b[?1004h\x1b]777;focus;on\x7" : "\x1b[?1004h"); + (rxvt || screen_host_rxvt) + ? SCREEN_WRAP(screen, "\x1b[?1004h\x1b]777;focus;on\x7") + : SCREEN_WRAP(screen, "\x1b[?1004h")); data->unibi_ext.disable_focus_reporting = (int)unibi_add_ext_str( ut, "ext.disable_focus", - rxvt ? "\x1b[?1004l\x1b]777;focus;off\x7" : "\x1b[?1004l"); + (rxvt || screen_host_rxvt) + ? SCREEN_WRAP(screen, "\x1b[?1004l\x1b]777;focus;off\x7") + : SCREEN_WRAP(screen, "\x1b[?1004l")); data->unibi_ext.enable_mouse = (int)unibi_add_ext_str( ut, "ext.enable_mouse", "\x1b[?1002h\x1b[?1006h"); data->unibi_ext.disable_mouse = (int)unibi_add_ext_str( -- cgit From 9d0222ee3e232be859c3c70e6681f7156b5ac9d5 Mon Sep 17 00:00:00 2001 From: erw7 Date: Tue, 28 Apr 2020 23:14:28 +0900 Subject: tui: Fix italics when $TERM is screen in tmux #12199 Tmux uses smso to display italics when the default-terminal is screen, screen-*. That's not the display the user wants, so change it to do the same display as before f3ffe0b32. fixes #12193. --- src/nvim/tui/tui.c | 49 +++++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 22 deletions(-) (limited to 'src/nvim/tui/tui.c') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 228545a844..2c4d02812b 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1543,10 +1543,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, bool rxvt = terminfo_is_term_family(term, "rxvt"); bool teraterm = terminfo_is_term_family(term, "teraterm"); bool putty = terminfo_is_term_family(term, "putty"); - bool screen = terminfo_is_term_family(term, "screen") && !os_getenv("TMUX"); - bool screen_host_linuxvt = - terminfo_is_term_family(screen && term[6] == '.' - ? term + 7 : NULL, "linux"); + bool screen = terminfo_is_term_family(term, "screen"); bool tmux = terminfo_is_term_family(term, "tmux") || !!os_getenv("TMUX"); bool st = terminfo_is_term_family(term, "st"); bool gnome = terminfo_is_term_family(term, "gnome") @@ -1563,6 +1560,10 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, bool mate_pretending_xterm = xterm && colorterm && strstr(colorterm, "mate-terminal"); bool true_xterm = xterm && !!xterm_version && !bsdvt; + bool true_screen = screen && !os_getenv("TMUX"); + bool screen_host_linuxvt = + terminfo_is_term_family(true_screen && term[6] == '.' + ? term + 7 : NULL, "linux"); bool cygwin = terminfo_is_term_family(term, "cygwin"); char *fix_normal = (char *)unibi_get_str(ut, unibi_cursor_normal); @@ -1707,7 +1708,8 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, data->unibi_ext.get_bg = (int)unibi_add_ext_str(ut, "ext.get_bg", - SCREEN_TMUX_WRAP(screen, tmux, "\x1b]11;?\x07")); + SCREEN_TMUX_WRAP(true_screen, + tmux, "\x1b]11;?\x07")); // Terminals with 256-colour SGR support despite what terminfo says. if (unibi_get_num(ut, unibi_max_colors) < 256) { @@ -1744,7 +1746,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, // GNU Screen does not have Ss/Se. When terminfo has Ss/Se, it is wrapped with // DCS because it is inherited from the host terminal. - if (screen) { + if (true_screen) { size_t len; size_t dcs_st_len = strlen(DCS_STR) + strlen(STERM_STR); if (-1 != data->unibi_ext.set_cursor_style) { @@ -1783,7 +1785,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, || (konsolev >= 180770) // #9364 || tmux // per tmux manual page // https://lists.gnu.org/archive/html/screen-devel/2013-03/msg00000.html - || (screen + || (true_screen && (!screen_host_linuxvt || (screen_host_linuxvt && (xterm_version || (vte_version > 0) || colorterm)))) @@ -1801,13 +1803,14 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, || (linuxvt && (xterm_version || (vte_version > 0) || colorterm)))) { data->unibi_ext.set_cursor_style = - (int)unibi_add_ext_str(ut, "Ss", SCREEN_WRAP(screen, "\x1b[%p1%d q")); + (int)unibi_add_ext_str(ut, "Ss", + SCREEN_WRAP(true_screen, "\x1b[%p1%d q")); if (-1 == data->unibi_ext.reset_cursor_style) { data->unibi_ext.reset_cursor_style = (int)unibi_add_ext_str(ut, "Se", ""); } unibi_set_ext_str(ut, (size_t)data->unibi_ext.reset_cursor_style, - SCREEN_WRAP(screen, "\x1b[ q")); + SCREEN_WRAP(true_screen, "\x1b[ q")); } else if (linuxvt || screen_host_linuxvt) { // Linux uses an idiosyncratic escape code to set the cursor shape and // does not support DECSCUSR. @@ -1818,7 +1821,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, // linux-specific sequence in DCS and outputs it. data->unibi_ext.set_cursor_style = (int)unibi_add_ext_str( ut, "Ss", - SCREEN_WRAP(screen, + SCREEN_WRAP(true_screen, "\x1b[?" "%?" // The parameter passed to Ss is the DECSCUSR parameter, @@ -1843,13 +1846,13 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, ""); } unibi_set_ext_str(ut, (size_t)data->unibi_ext.reset_cursor_style, - "\x1b[?c"); + SCREEN_WRAP(true_screen, "\x1b[?c")); } else if (konsolev > 0 && konsolev < 180770) { // Konsole before version 18.07.70: set up a nonce profile. This has // side-effects on temporary font resizing. #6798 data->unibi_ext.set_cursor_style = (int)unibi_add_ext_str( ut, "Ss", - SCREEN_TMUX_WRAP(screen, tmux, + SCREEN_TMUX_WRAP(true_screen, tmux, "\x1b]50;CursorShape=%?" "%p1%{3}%<" "%t%{0}" // block "%e%p1%{5}%<" "%t%{2}" // underline @@ -1865,7 +1868,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, ""); } unibi_set_ext_str(ut, (size_t)data->unibi_ext.reset_cursor_style, - SCREEN_TMUX_WRAP(screen, tmux, "\x1b]50;\x07")); + SCREEN_TMUX_WRAP(true_screen, tmux, "\x1b]50;\x07")); } } } @@ -1894,11 +1897,13 @@ static void augment_terminfo(TUIData *data, const char *term, bool alacritty = terminfo_is_term_family(term, "alacritty"); // None of the following work over SSH; see :help TERM . bool iterm_pretending_xterm = xterm && iterm_env; - bool screen_host_rxvt = - terminfo_is_term_family(screen && term[6] == '.' ? term + 7 : NULL, "rxvt"); const char *xterm_version = os_getenv("XTERM_VERSION"); bool true_xterm = xterm && !!xterm_version && !bsdvt; + bool true_screen = screen && !os_getenv("TMUX"); + bool screen_host_rxvt = + terminfo_is_term_family(true_screen + && term[6] == '.' ? term + 7 : NULL, "rxvt"); // Only define this capability for terminal types that we know understand it. if (dtterm // originated this extension @@ -1965,7 +1970,7 @@ static void augment_terminfo(TUIData *data, const char *term, // all panes, which is not particularly desirable. A better approach // would use a tmux control sequence and an extra if(screen) test. data->unibi_ext.set_cursor_color = (int)unibi_add_ext_str( - ut, NULL, SCREEN_TMUX_WRAP(screen, tmux, "\033]Pl%p1%06x\033\\")); + ut, NULL, SCREEN_TMUX_WRAP(true_screen, tmux, "\033]Pl%p1%06x\033\\")); } else if ((xterm || rxvt || tmux || alacritty) && (vte_version == 0 || vte_version >= 3900)) { // Supported in urxvt, newer VTE. @@ -1992,20 +1997,20 @@ static void augment_terminfo(TUIData *data, const char *term, data->unibi_ext.disable_lr_margin = (int)unibi_add_ext_str( ut, "ext.disable_lr_margin", "\x1b[?69l"); data->unibi_ext.enable_bracketed_paste = (int)unibi_add_ext_str( - ut, "ext.enable_bpaste", SCREEN_WRAP(screen, "\x1b[?2004h")); + ut, "ext.enable_bpaste", SCREEN_WRAP(true_screen, "\x1b[?2004h")); data->unibi_ext.disable_bracketed_paste = (int)unibi_add_ext_str( - ut, "ext.disable_bpaste", SCREEN_WRAP(screen, "\x1b[?2004l")); + ut, "ext.disable_bpaste", SCREEN_WRAP(true_screen, "\x1b[?2004l")); // For urxvt send BOTH xterm and old urxvt sequences. #8695 data->unibi_ext.enable_focus_reporting = (int)unibi_add_ext_str( ut, "ext.enable_focus", (rxvt || screen_host_rxvt) - ? SCREEN_WRAP(screen, "\x1b[?1004h\x1b]777;focus;on\x7") - : SCREEN_WRAP(screen, "\x1b[?1004h")); + ? SCREEN_WRAP(true_screen, "\x1b[?1004h\x1b]777;focus;on\x7") + : SCREEN_WRAP(true_screen, "\x1b[?1004h")); data->unibi_ext.disable_focus_reporting = (int)unibi_add_ext_str( ut, "ext.disable_focus", (rxvt || screen_host_rxvt) - ? SCREEN_WRAP(screen, "\x1b[?1004l\x1b]777;focus;off\x7") - : SCREEN_WRAP(screen, "\x1b[?1004l")); + ? SCREEN_WRAP(true_screen, "\x1b[?1004l\x1b]777;focus;off\x7") + : SCREEN_WRAP(true_screen, "\x1b[?1004l")); data->unibi_ext.enable_mouse = (int)unibi_add_ext_str( ut, "ext.enable_mouse", "\x1b[?1002h\x1b[?1006h"); data->unibi_ext.disable_mouse = (int)unibi_add_ext_str( -- cgit From 57a4f8905b179d5ccf292068cab4946c1d90a9c0 Mon Sep 17 00:00:00 2001 From: erw7 Date: Sun, 20 Jan 2019 15:31:32 +0900 Subject: win/TUI: enable mouse on ConEmu and vtpcon without vti --- src/nvim/tui/tui.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/nvim/tui/tui.c') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 2c4d02812b..b4d91a01fc 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -33,6 +33,9 @@ #include "nvim/os/os.h" #include "nvim/os/signal.h" #include "nvim/os/tty.h" +#ifdef WIN32 +# include "nvim/os/os_win_console.h" +#endif #include "nvim/strings.h" #include "nvim/syntax.h" #include "nvim/ui_bridge.h" @@ -1015,8 +1018,22 @@ static void tui_mouse_on(UI *ui) { TUIData *data = ui->data; if (!data->mouse_enabled) { +#ifdef WIN32 + // Windows versions with vtp(ENABLE_VIRTUAL_TERMINAL_PROCESSING) and + // no vti(ENABLE_VIRTUAL_TERMINAL_INPUT) will need to use mouse traking of + // libuv. For this reason, vtp (vterm) state of libuv is temporarily + // disabled because the control sequence needs to be processed by libuv + // instead of Windows vtp. + // ref. https://docs.microsoft.com/en-us/windows/console/setconsolemode + flush_buf(ui); + os_set_vtp(false); +#endif unibi_out_ext(ui, data->unibi_ext.enable_mouse); data->mouse_enabled = true; +#ifdef WIN32 + flush_buf(ui); + os_set_vtp(true); +#endif } } @@ -1024,8 +1041,22 @@ static void tui_mouse_off(UI *ui) { TUIData *data = ui->data; if (data->mouse_enabled) { +#ifdef WIN32 + // Windows versions with vtp(ENABLE_VIRTUAL_TERMINAL_PROCESSING) and + // no vti(ENABLE_VIRTUAL_TERMINAL_INPUT) will need to use mouse traking of + // libuv. For this reason, vtp (vterm) state of libuv is temporarily + // disabled because the control sequence needs to be processed by libuv + // instead of Windows vtp. + // ref. https://docs.microsoft.com/en-us/windows/console/setconsolemode + flush_buf(ui); + os_set_vtp(false); +#endif unibi_out_ext(ui, data->unibi_ext.disable_mouse); data->mouse_enabled = false; +#ifdef WIN32 + flush_buf(ui); + os_set_vtp(true); +#endif } } -- cgit From 5a69eb99b753c91f801c2338b99aa78eabba17bb Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 19 Jul 2020 18:45:26 +0200 Subject: tui.c: augment_terminfo: remove unused colorterm argument (#12602) It is unused since 8898793ad. --- src/nvim/tui/tui.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/tui/tui.c') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index b4d91a01fc..bfd9435c49 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -274,7 +274,7 @@ static void terminfo_start(UI *ui) : (konsole ? 1 : 0); patch_terminfo_bugs(data, term, colorterm, vtev, konsolev, iterm_env, nsterm); - augment_terminfo(data, term, colorterm, vtev, konsolev, iterm_env, nsterm); + augment_terminfo(data, term, vtev, konsolev, iterm_env, nsterm); data->can_change_scroll_region = !!unibi_get_str(data->ut, unibi_change_scroll_region); data->can_set_lr_margin = @@ -1907,7 +1907,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, /// This adds stuff that is not in standard terminfo as extended unibilium /// capabilities. static void augment_terminfo(TUIData *data, const char *term, - const char *colorterm, long vte_version, + long vte_version, long konsolev, bool iterm_env, bool nsterm) { unibi_term *ut = data->ut; -- cgit