Skip to content

Conversation

bfredl
Copy link
Member

@bfredl bfredl commented Aug 2, 2018

Fixes #7861, but currently only on BCE terminals. Also resizing the terminal is a lot smoother, as we don't literally need to fill the screen with space chars one at a time.

Problem is nvim very aggressively disables BCE, even if the terminal supports it. Though you can set XTERM_VERSION=xx to say "trust me, I use a non-broken terminal emulator" and it works with at least pangoterm (libvterm) and gnome-terminal (libvte).

What are these terminals that claim to be xterm but doesn't actually support BCE? I tried to navigate the tangle of interlinked issues but have a hard time to extract a list of terminals that were broken, and more importantly remain broken today. The most common complaints seem to be about conhost/WSL, and they claim to have fixed their stuff: microsoft/WSL#1706. Could we switch from (ridiculously narrow) whitelist to blacklist?

  • clear the screen correctly on BCE terminal
  • clear the screen correctly on non-BCE terminal
  • detect BCE more reasonably

@bfredl
Copy link
Member Author

bfredl commented Aug 2, 2018

Added a quickfix for invalid first line in non-BCE terminal, so this now actually fixes #7861. This case could be optimized more as I noted before #7861 (comment), but before spending a lot of time on this it would be good to know the true distribution of BCE vs non-BCE capable terminals.

@justinmk
Copy link
Member

justinmk commented Aug 3, 2018

Nice!

Could we switch from (ridiculously narrow) whitelist to blacklist?

The problem is ssh/screen/tmux. For example kitty won't support BCE. If the user doesn't have kitty's terminfo on the remote system, the remote terminfo often claims BCE support, then Nvim looks broken.

See also #7624 (though it sounds like you reviewed it already).

it would be good to know the true distribution of BCE vs non-BCE capable terminals.

The problem is how to detect them. We were depending on terminfo and getting lies.

@bfredl
Copy link
Member Author

bfredl commented Aug 3, 2018

But kitty calls itself xterm-kitty, we can easily detect that. And screen/tmux calls itself screen and not xterm. I know termcap is a bunch of lies, but I would expect a terminal that calls itself xterm-256color and nothing else to behave like an xterm, termcap doesn't need to enter that equation at all.

@justinmk
Copy link
Member

justinmk commented Aug 3, 2018

So we won't ever use BCE for screen/tmux (except for XTERM_VERSION), correct?

No objection to use TERM to detect kitty, though I would suggest that the decision be reflected by nvim -V3 (i.e., the final BCE value in there should say what we actually decided).

@justinmk
Copy link
Member

justinmk commented Aug 3, 2018

So we won't ever use BCE for screen/tmux (except for XTERM_VERSION)

Or if we implement termresponse detection #7490

@bfredl
Copy link
Member Author

bfredl commented Aug 3, 2018

Does tmux support bce or not? What is the problem, it being different from screen without having its own TERM?

@justinmk
Copy link
Member

justinmk commented Aug 3, 2018

This comment implies that tmux/screen don't support BCE. See also tmux/tmux#109 (comment)

@bfredl
Copy link
Member Author

bfredl commented Aug 3, 2018

Then tmux is no problem: when TERM is screen-*, we don't support bce just like now. The change we should do is just: if a terminal calls itelf xterm (and provides no extra info like VTEVERSION or similar, where we can blacklist if needed), we should expect it to behave like an xterm.

@bfredl
Copy link
Member Author

bfredl commented Aug 3, 2018

Allowing BCE also for "false" xterm is the conservative change. But beyond that, what are the terminals for which terminfo is actually lying? (not supporting BCE is fine as long the terminal is honest about it...) Is the terminfo for screen incorrect? If not, what is?

Also, in my empirical experiments, kitty actually seems to support BCE for full-screen clear, but not for scrolled-in area. But maybe it is not worth a special-case?

@justinmk
Copy link
Member

justinmk commented Aug 4, 2018

But beyond that, what are the terminals for which terminfo is actually lying?

Other than kitty and conhost/WSL (which apparently was fixed), I don't know.

It could be argued that my avoidance of BCE was an autoimmune response to the back-and-forth in kovidgoyal/kitty#160 . But I can imagine a user ssh'd to a system with a mismatched terminfo (presumably by unibilium or our builtins, e.g. for TERM=xterm-kitty we find the xterm terminfo, which will then claim BCE support), and I can imagine many users with incorrect $TERM values, and avoiding BCE avoided all of those support tickets. And furthermore the relative rarity of reliable BCE support in terminal emulators makes the risk questionable.

But I'm in favor of experimentation with current HEAD, if you are.

detect BCE more reasonably

For this item, are you thinking about term response / DECRQSS or something else?

@bfredl
Copy link
Member Author

bfredl commented Aug 10, 2018

For this item, are you thinking about term response / DECRQSS or something else?

I don't know about DECRQSS and how reliable it is, but if it works it can of course be used. I think I would start with: basically trust terminfo again, but add exceptions for known terminals (starting with kitty). If this becomes unmanagable we can switch strategy.

@justinmk
Copy link
Member

Let's do it.

@bfredl bfredl changed the title [WIP] tui: fix resize and use BCE more often [RFC] tui: fix resize and use BCE more often Aug 10, 2018
@bfredl
Copy link
Member Author

bfredl commented Aug 10, 2018

Ok, I added screen, tmux and kitty exceptions, should cover the most cases of broken terminfo or tmux-over-ssh (though it works on my computer without any extra check :P).

@kovidgoyal
Copy link

FYI: for kitty you can use DECCARA https://sw.kovidgoyal.net/kitty/protocol-extensions.html#setting-text-styles-colors-in-arbitrary-regions-of-the-screen much more powerful than bce allows you to set arbitrary text attributes in arbitrary regions of the screen with single escape code.

if (!true_xterm) {
// Cannot trust terminfo; safer to disable BCE. #7624
if (tmux || screen || kitty) {
// Disable BCE in some cases we know it is not working. #8806
unibi_set_bool(ut, unibi_back_color_erase, false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Since this drives the TUIData.bce value, nvim -V3 should correctly reflect whether BCE is in effect.

@bfredl bfredl merged commit b5cfac0 into neovim:master Aug 15, 2018
@justinmk justinmk removed the RFC label Aug 15, 2018
@bfredl bfredl mentioned this pull request Oct 2, 2018
@mqudsi mqudsi mentioned this pull request Oct 24, 2018
mqudsi added a commit to mqudsi/neovim that referenced this pull request Oct 24, 2018
justinmk added a commit to justinmk/neovim that referenced this pull request Dec 30, 2018
Besides the "visible" improvements, this release features numerous
internal improvements to the UI/screen code and test infrastructure.

Numerous patches were merged from Vim, which are not mentioned below.

FEATURES:

07ad5d7 clipboard: Support custom VimL functions neovim#9304
725da1f neovim#9401 win/TUI: Improve terminal/console support
7a8dadb neovim#9077 startup: Use $XDG_CONFIG_DIRS/nvim/sysinit.vim if it exists
feec926 neovim#9299 support <cmd> mapping in more places
0653ed6 neovim#9028 diff/highlight: Show underline for low-priority CursorLine
bddcbbb signs: Add "numhl" argument neovim#9113
05f9c7c clipboard: support Wayland (neovim#9230)
14ae394 neovim#9052 TUI: add support for undercurl and underline color
4fa3492 neovim#9023 man.vim: soft (dynamic) wrap neovim#9023

API:

8b39e4e neovim#6920 API: implement object namespaces
b1aaa0a API: Implement nvim_win_set_buf() neovim#9100
8de87c7 neovim#8180 API: virtual text annotations (nvim_buf_set_virtual_text)
2b9fc9a neovim#8660 API: add nvim_buf_is_loaded()
    API: buf_get_lines, buf_line_count handle unloaded buffers
88f77c2 API: nvim_buf_get_offset_for_line
94841e5 API/UI: neovim#8221 ext_newgrid, ext_hlstate
    (use line-based rather than char-based updates)

UI

b5cfac0 neovim#8806 TUI: use BCE again more often, (smoother resizes/scrolling)
77b5e9a neovim#9315 screen: add missing status redraw when redraw_later(CLEAR) was used
5f15788 TUI: clip invalid regions on resize (neovim#8779), fixes neovim#8774
c936ae0 neovim#9193 TUI: improvements for scrolling and clearing
f204274 neovim#9143 UI: disable clearing almost everywhere
f4b2b66 neovim#9079 TUI: always use safe cursor movement after resize
d36afaf neovim#9211 ui_options: also send when starting or from OptionSet
67f80d4 TUI: Avoid reset_cursor_color in old VTE neovim#9191
e55ebae neovim#9021 don't erase screen on `:hi Normal` during startup
c5790d9 neovim#8915 TUI: Hint wrapped lines to terminals.

FIXES:

231de72 RPC: turn errors from async calls into notifications
907ad92 TUI: Restore terminal title via "title stacking" (neovim#9407)
cb76a8a genappimage: Unset $ARGV0 at invocation neovim#9376
b48efd9 neovim#9347 TUI: FreeBSD: Improve support for BSD vt console
c16529a TUI: Konsole 18.07.70 supports DECSCUSR (neovim#9364)
aec096f os/lang: use the correct LC_NUMERIC also for OS X
5fee0be provider: improve error message (neovim#9344)
3c42d7a TUI: alacritty supports set_cursor_color neovim#9353
7bff9a5 TUI: Alacritty supports DECSCUSR (neovim#9048)
57acfce macOS: infer primary language if $LANG is empty neovim#9345
bc132ae runtime/syntax: Fix highlighting of augroup contents (neovim#9328)
715fdfe neovim#9297 VimL/confirm(): Show dialog even if :silent
799d9c3 clipboard: Prefer xclip (neovim#9302)
6dae777 provider/nodejs: fix npm,yarn detection
16bc1e9 neovim#9218 channel: avoid buffering output when only terminal and no callbacks are active
72fecad neovim#8804 Fix crash in lang_init() on macOS if lang_region = NULL
d581398 ruby: detect rbenv shims for other versions (neovim#8733)
e568ac7 neovim#9123 third-party/unibilium: Fix parsing of extended capability entries
c4c74c3 jobstart(): Fix hang on non-executable cwd neovim#9204
1cf50cb provider/nodejs: Simultaneously query npm and yarn neovim#9054
6c496db undo: Fix infinite loop if undo_read_byte returns EOF neovim#2880
f8f8357 neovim#9034 'swapfile: always show dialog'

CHANGES:

c236e80 neovim#9024 --embed: wait for UI unless --headless
180b50d neovim#9248 python: 'neovim' module was renamed to 'pynvim'
2000b6a neovim#8589 VimL: Remove legacy aliases "v:errmsg", "v:shell_error", "v:this_session"
deb18a0 defaults: background=dark neovim#2894 (neovim#9205)
c1187d4 defaults: win: 'shellpipe' for cmd.exe (neovim#8827)
justinmk added a commit to justinmk/neovim that referenced this pull request Dec 31, 2018
Besides the "visible" improvements, this release features numerous
internal improvements to the UI/screen code and test infrastructure.

Numerous patches were merged from Vim, which are not mentioned below.

FEATURES:

07ad5d7 clipboard: Support custom VimL functions neovim#9304
725da1f neovim#9401 win/TUI: Improve terminal/console support
7a8dadb neovim#9077 startup: Use $XDG_CONFIG_DIRS/nvim/sysinit.vim if it exists
feec926 neovim#9299 support <cmd> mapping in more places
0653ed6 neovim#9028 diff/highlight: Show underline for low-priority CursorLine
bddcbbb signs: Add "numhl" argument neovim#9113
05f9c7c clipboard: support Wayland (neovim#9230)
14ae394 neovim#9052 TUI: add support for undercurl and underline color
4fa3492 neovim#9023 man.vim: soft (dynamic) wrap neovim#9023

API:

8b39e4e neovim#6920 API: implement object namespaces
b1aaa0a API: Implement nvim_win_set_buf() neovim#9100
8de87c7 neovim#8180 API: virtual text annotations (nvim_buf_set_virtual_text)
2b9fc9a neovim#8660 API: add nvim_buf_is_loaded()
    API: buf_get_lines, buf_line_count handle unloaded buffers
88f77c2 API: nvim_buf_get_offset_for_line
94841e5 API/UI: neovim#8221 ext_newgrid, ext_hlstate
    (use line-based rather than char-based updates)

UI

b5cfac0 neovim#8806 TUI: use BCE again more often, (smoother resizes/scrolling)
77b5e9a neovim#9315 screen: add missing status redraw when redraw_later(CLEAR) was used
5f15788 TUI: clip invalid regions on resize (neovim#8779), fixes neovim#8774
c936ae0 neovim#9193 TUI: improvements for scrolling and clearing
f204274 neovim#9143 UI: disable clearing almost everywhere
f4b2b66 neovim#9079 TUI: always use safe cursor movement after resize
d36afaf neovim#9211 ui_options: also send when starting or from OptionSet
67f80d4 TUI: Avoid reset_cursor_color in old VTE neovim#9191
e55ebae neovim#9021 don't erase screen on `:hi Normal` during startup
c5790d9 neovim#8915 TUI: Hint wrapped lines to terminals.

FIXES:

231de72 RPC: turn errors from async calls into notifications
907ad92 TUI: Restore terminal title via "title stacking" (neovim#9407)
cb76a8a genappimage: Unset $ARGV0 at invocation neovim#9376
b48efd9 neovim#9347 TUI: FreeBSD: Improve support for BSD vt console
c16529a TUI: Konsole 18.07.70 supports DECSCUSR (neovim#9364)
aec096f os/lang: use the correct LC_NUMERIC also for OS X
5fee0be provider: improve error message (neovim#9344)
3c42d7a TUI: alacritty supports set_cursor_color neovim#9353
7bff9a5 TUI: Alacritty supports DECSCUSR (neovim#9048)
57acfce macOS: infer primary language if $LANG is empty neovim#9345
bc132ae runtime/syntax: Fix highlighting of augroup contents (neovim#9328)
715fdfe neovim#9297 VimL/confirm(): Show dialog even if :silent
799d9c3 clipboard: Prefer xclip (neovim#9302)
6dae777 provider/nodejs: fix npm,yarn detection
16bc1e9 neovim#9218 channel: avoid buffering output when only terminal and no callbacks are active
72fecad neovim#8804 Fix crash in lang_init() on macOS if lang_region = NULL
d581398 ruby: detect rbenv shims for other versions (neovim#8733)
e568ac7 neovim#9123 third-party/unibilium: Fix parsing of extended capability entries
c4c74c3 jobstart(): Fix hang on non-executable cwd neovim#9204
1cf50cb provider/nodejs: Simultaneously query npm and yarn neovim#9054
6c496db undo: Fix infinite loop if undo_read_byte returns EOF neovim#2880
f8f8357 neovim#9034 'swapfile: always show dialog'

CHANGES:

c236e80 neovim#9024 --embed: wait for UI unless --headless
180b50d neovim#9248 python: 'neovim' module was renamed to 'pynvim'
2000b6a neovim#8589 VimL: Remove legacy aliases "v:errmsg", "v:shell_error", "v:this_session"
deb18a0 defaults: background=dark neovim#2894 (neovim#9205)
c1187d4 defaults: win: 'shellpipe' for cmd.exe (neovim#8827)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TUI: corrupt display after resize + termguicolors, sign column, colorscheme
4 participants