aboutsummaryrefslogtreecommitdiff
path: root/test/functional/terminal/highlight_spec.lua
diff options
context:
space:
mode:
authorGregory Anders <greg@gpanders.com>2024-12-17 07:11:41 -0600
committerGitHub <noreply@github.com>2024-12-17 07:11:41 -0600
commit0dd933265ff2e64786fd30f949e767e10f401519 (patch)
treec6dfd63bb7ff0d83f2d248e9f3f233bd446604f4 /test/functional/terminal/highlight_spec.lua
parentdf367cf91cdd805d907f758cb295c6b36fe39480 (diff)
downloadrneovim-0dd933265ff2e64786fd30f949e767e10f401519.tar.gz
rneovim-0dd933265ff2e64786fd30f949e767e10f401519.tar.bz2
rneovim-0dd933265ff2e64786fd30f949e767e10f401519.zip
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.
Diffstat (limited to 'test/functional/terminal/highlight_spec.lua')
-rw-r--r--test/functional/terminal/highlight_spec.lua91
1 files changed, 52 insertions, 39 deletions
diff --git a/test/functional/terminal/highlight_spec.lua b/test/functional/terminal/highlight_spec.lua
index 7822a27b93..5ed3c72b72 100644
--- a/test/functional/terminal/highlight_spec.lua
+++ b/test/functional/terminal/highlight_spec.lua
@@ -37,7 +37,7 @@ describe(':terminal highlight', function()
feed('i')
screen:expect([[
tty ready |
- {10: } |
+ ^ |
|*4
{5:-- TERMINAL --} |
]])
@@ -61,7 +61,7 @@ describe(':terminal highlight', function()
skip(is_os('win'))
screen:expect(sub([[
tty ready |
- {NUM:text}text{10: } |
+ {NUM:text}text^ |
|*4
{5:-- TERMINAL --} |
]]))
@@ -84,7 +84,7 @@ describe(':terminal highlight', function()
line6 |
line7 |
line8 |
- {10: } |
+ ^ |
{5:-- TERMINAL --} |
]])
feed('<c-\\><c-n>gg')
@@ -195,7 +195,7 @@ it('CursorLine and CursorColumn work in :terminal buffer in Normal mode', functi
local screen = Screen.new(50, 7)
screen:set_default_attr_ids({
[1] = { background = Screen.colors.Grey90 }, -- CursorLine, CursorColumn
- [2] = { reverse = true }, -- TermCursor
+ [2] = { reverse = true },
[3] = { bold = true }, -- ModeMsg
[4] = { background = Screen.colors.Grey90, reverse = true },
[5] = { background = Screen.colors.Red },
@@ -234,7 +234,7 @@ it('CursorLine and CursorColumn work in :terminal buffer in Normal mode', functi
foobar foobar foobar foobar foobar foobar foobar f|
oobar foobar foobar foobar foobar foobar foobar fo|
obar foobar foobar foobar foobar foobar foobar foo|
- bar foobar{2: } |
+ bar foobar^ |
{3:-- TERMINAL --} |
]])
-- Leaving terminal mode restores old values.
@@ -248,46 +248,60 @@ it('CursorLine and CursorColumn work in :terminal buffer in Normal mode', functi
{1:bar fooba^r }|
|
]])
- -- CursorLine and CursorColumn are combined with TermCursorNC.
- command('highlight TermCursorNC gui=reverse')
+
+ -- Skip the rest of these tests on Windows #31587
+ if is_os('win') then
+ return
+ end
+
+ -- CursorLine and CursorColumn are combined with terminal colors.
+ tt.set_reverse()
+ tt.feed_data(' foobar')
+ tt.clear_attrs()
screen:expect([[
tty ready{1: } |
foobar f{1:o}obar foobar foobar foobar foobar foobar |
foobar fo{1:o}bar foobar foobar foobar foobar foobar f|
oobar foo{1:b}ar foobar foobar foobar foobar foobar fo|
obar foob{1:a}r foobar foobar foobar foobar foobar foo|
- {1:bar fooba^r}{4: }{1: }|
+ {1:bar fooba^r}{4: foobar}{1: }|
|
]])
- feed('2gg11|')
+ feed('2gg15|')
screen:expect([[
- tty ready {1: } |
- {1: foobar fo^obar foobar foobar foobar foobar foobar }|
- foobar foo{1:b}ar foobar foobar foobar foobar foobar f|
- oobar foob{1:a}r foobar foobar foobar foobar foobar fo|
- obar fooba{1:r} foobar foobar foobar foobar foobar foo|
- bar foobar{4: } |
+ tty ready {1: } |
+ {1: foobar foobar^ foobar foobar foobar foobar foobar }|
+ foobar foobar {1:f}oobar foobar foobar foobar foobar f|
+ oobar foobar f{1:o}obar foobar foobar foobar foobar fo|
+ obar foobar fo{1:o}bar foobar foobar foobar foobar foo|
+ bar foobar{2: foo}{4:b}{2:ar} |
|
]])
- -- TermCursorNC has higher precedence.
- command('highlight TermCursorNC gui=NONE guibg=Red')
+
+ -- Set bg color to red
+ tt.feed_csi('48;2;255:0:0m')
+ tt.feed_data(' foobar')
+ tt.clear_attrs()
+ feed('2gg20|')
+
+ -- Terminal color has higher precedence
screen:expect([[
- tty ready {1: } |
- {1: foobar fo^obar foobar foobar foobar foobar foobar }|
- foobar foo{1:b}ar foobar foobar foobar foobar foobar f|
- oobar foob{1:a}r foobar foobar foobar foobar foobar fo|
- obar fooba{1:r} foobar foobar foobar foobar foobar foo|
- bar foobar{5: } |
+ tty ready {1: } |
+ {1: foobar foobar foob^ar foobar foobar foobar foobar }|
+ foobar foobar fooba{1:r} foobar foobar foobar foobar f|
+ oobar foobar foobar{1: }foobar foobar foobar foobar fo|
+ obar foobar foobar {1:f}oobar foobar foobar foobar foo|
+ bar foobar{2: foobar}{5: foobar} |
|
]])
feed('G$')
screen:expect([[
- tty ready{1: } |
- foobar f{1:o}obar foobar foobar foobar foobar foobar |
- foobar fo{1:o}bar foobar foobar foobar foobar foobar f|
- oobar foo{1:b}ar foobar foobar foobar foobar foobar fo|
- obar foob{1:a}r foobar foobar foobar foobar foobar foo|
- {1:bar fooba^r}{5: }{1: }|
+ tty ready {1: } |
+ foobar foobar foobar f{1:o}obar foobar foobar foobar |
+ foobar foobar foobar fo{1:o}bar foobar foobar foobar f|
+ oobar foobar foobar foo{1:b}ar foobar foobar foobar fo|
+ obar foobar foobar foob{1:a}r foobar foobar foobar foo|
+ {1:bar foobar}{4: foobar}{5: fooba^r}{1: }|
|
]])
end)
@@ -300,18 +314,17 @@ describe(':terminal highlight forwarding', function()
screen = Screen.new(50, 7)
screen:set_rgb_cterm(true)
screen:set_default_attr_ids({
- [1] = { { reverse = true }, { reverse = true } },
- [2] = { { bold = true }, { bold = true } },
- [3] = { { fg_indexed = true, foreground = tonumber('0xe0e000') }, { foreground = 3 } },
- [4] = { { foreground = tonumber('0xff8000') }, {} },
+ [1] = { { bold = true }, { bold = true } },
+ [2] = { { fg_indexed = true, foreground = tonumber('0xe0e000') }, { foreground = 3 } },
+ [3] = { { foreground = tonumber('0xff8000') }, {} },
})
command(("enew | call termopen(['%s'])"):format(testprg('tty-test')))
feed('i')
screen:expect([[
tty ready |
- {1: } |
+ ^ |
|*4
- {2:-- TERMINAL --} |
+ {1:-- TERMINAL --} |
]])
end)
@@ -326,9 +339,9 @@ describe(':terminal highlight forwarding', function()
screen:expect {
grid = [[
tty ready |
- {3:text}{4:color}text{1: } |
+ {2:text}{3:color}text^ |
|*4
- {2:-- TERMINAL --} |
+ {1:-- TERMINAL --} |
]],
}
end)
@@ -355,7 +368,7 @@ describe(':terminal highlight with custom palette', function()
feed('i')
screen:expect([[
tty ready |
- {7: } |
+ ^ |
|*4
{9:-- TERMINAL --} |
]])
@@ -369,7 +382,7 @@ describe(':terminal highlight with custom palette', function()
tt.feed_data('text')
screen:expect([[
tty ready |
- {1:text}text{7: } |
+ {1:text}text^ |
|*4
{9:-- TERMINAL --} |
]])