feat(terminal)!: cursor shape and blink (#31562)

When a terminal application running inside the terminal emulator sets
the cursor shape or blink status of the cursor, update the cursor in the
parent terminal to match.

This removes the "virtual cursor" that has been in use by the terminal
emulator since the beginning. The original rationale for using the
virtual cursor was to avoid having to support additional UI methods to
change the cursor color for other (non-TUI) UIs, instead relying on the
TermCursor and TermCursorNC highlight groups.

The TermCursor highlight group is now used in the default 'guicursor'
value, which has a new entry for Terminal mode. However, the
TermCursorNC highlight group is no longer supported: since terminal
windows now use the real cursor, when the window is not focused there is
no cursor displayed in the window at all, so there is nothing to
highlight. Users can still use the StatusLineTermNC highlight group to
differentiate non-focused terminal windows.

BREAKING CHANGE: The TermCursorNC highlight group is no longer supported.
This commit is contained in:
Gregory Anders
2024-12-17 07:11:41 -06:00
committed by GitHub
parent df367cf91c
commit 0dd933265f
43 changed files with 903 additions and 541 deletions

View File

@ -39,7 +39,7 @@ describe(':terminal scrollback', function()
line28 |
line29 |
line30 |
{1: } |
^ |
{3:-- TERMINAL --} |
]])
end)
@ -67,7 +67,7 @@ describe(':terminal scrollback', function()
line2 |
line3 |
line4 |
{1: } |
^ |
{3:-- TERMINAL --} |
]])
end)
@ -84,7 +84,7 @@ describe(':terminal scrollback', function()
line3 |
line4 |
line5 |
{1: } |
^ |
{3:-- TERMINAL --} |
]])
eq(7, api.nvim_buf_line_count(0))
@ -102,7 +102,7 @@ describe(':terminal scrollback', function()
line5 |
line6 |
line7 |
line8{1: } |
line8^ |
{3:-- TERMINAL --} |
]])
@ -135,7 +135,7 @@ describe(':terminal scrollback', function()
line5 |
line6 |
line7 |
^line8{2: } |
^line8 |
|
]])
end)
@ -151,7 +151,7 @@ describe(':terminal scrollback', function()
line3 |
line4 |
rows: 5, cols: 28 |
{2:^ } |
^ |
|
]])
end
@ -168,7 +168,7 @@ describe(':terminal scrollback', function()
screen:expect([[
rows: 5, cols: 28 |
rows: 3, cols: 26 |
{2:^ } |
^ |
|
]])
eq(8, api.nvim_buf_line_count(0))
@ -201,7 +201,7 @@ describe(':terminal scrollback', function()
screen:expect([[
tty ready |
rows: 4, cols: 30 |
{1: } |
^ |
|
{3:-- TERMINAL --} |
]])
@ -220,7 +220,7 @@ describe(':terminal scrollback', function()
screen:expect([[
rows: 4, cols: 30 |
rows: 3, cols: 30 |
{1: } |
^ |
{3:-- TERMINAL --} |
]])
eq(4, api.nvim_buf_line_count(0))
@ -235,7 +235,7 @@ describe(':terminal scrollback', function()
screen:expect([[
rows: 4, cols: 30 |
rows: 3, cols: 30 |
{1: } |
^ |
{3:-- TERMINAL --} |
]])
end)
@ -252,14 +252,14 @@ describe(':terminal scrollback', function()
line2 |
line3 |
line4 |
{1: } |
^ |
{3:-- TERMINAL --} |
]])
screen:try_resize(screen._width, screen._height - 3)
screen:expect([[
line4 |
rows: 3, cols: 30 |
{1: } |
^ |
{3:-- TERMINAL --} |
]])
eq(7, api.nvim_buf_line_count(0))
@ -278,7 +278,7 @@ describe(':terminal scrollback', function()
line4 |
rows: 3, cols: 30 |
rows: 4, cols: 30 |
{1: } |
^ |
{3:-- TERMINAL --} |
]])
end
@ -300,7 +300,7 @@ describe(':terminal scrollback', function()
rows: 3, cols: 30 |
rows: 4, cols: 30 |
rows: 7, cols: 30 |
{1: } |
^ |
{3:-- TERMINAL --} |
]])
eq(9, api.nvim_buf_line_count(0))
@ -337,7 +337,7 @@ describe(':terminal scrollback', function()
rows: 4, cols: 30 |
rows: 7, cols: 30 |
rows: 11, cols: 30 |
{1: } |
^ |
|
{3:-- TERMINAL --} |
]])
@ -362,7 +362,7 @@ describe(':terminal prints more lines than the screen height and exits', functio
line8 |
line9 |
|
[Process exited 0]{2: } |
[Process exited 0]^ |
{5:-- TERMINAL --} |
]])
feed('<cr>')
@ -454,7 +454,7 @@ describe("'scrollback' option", function()
39: line |
40: line |
|
${1: } |
$^ |
{3:-- TERMINAL --} |
]],
}
@ -493,7 +493,7 @@ describe("'scrollback' option", function()
line28 |
line29 |
line30 |
{1: } |
^ |
{3:-- TERMINAL --} |
]])
local term_height = 6 -- Actual terminal screen height, not the scrollback
@ -634,7 +634,7 @@ describe('pending scrollback line handling', function()
screen:expect [[
hi |*4
|
[Process exited 0]{2: } |
[Process exited 0]^ |
{3:-- TERMINAL --} |
]]
assert_alive()