aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/keymap.c29
-rw-r--r--src/nvim/keymap.h29
-rw-r--r--src/nvim/terminal.c52
-rw-r--r--src/nvim/tui/input.c17
-rw-r--r--test/functional/terminal/helpers.lua4
-rw-r--r--test/functional/terminal/tui_spec.lua46
-rw-r--r--test/functional/ui/input_spec.lua4
7 files changed, 156 insertions, 25 deletions
diff --git a/src/nvim/keymap.c b/src/nvim/keymap.c
index 9ad9640834..1e305528ba 100644
--- a/src/nvim/keymap.c
+++ b/src/nvim/keymap.c
@@ -221,6 +221,35 @@ static const struct key_name_entry {
{ K_F35, "F35" },
{ K_F36, "F36" },
{ K_F37, "F37" },
+ { K_F38, "F38" },
+ { K_F39, "F39" },
+ { K_F40, "F40" },
+
+ { K_F41, "F41" },
+ { K_F42, "F42" },
+ { K_F43, "F43" },
+ { K_F44, "F44" },
+ { K_F45, "F45" },
+ { K_F46, "F46" },
+ { K_F47, "F47" },
+ { K_F48, "F48" },
+ { K_F49, "F49" },
+ { K_F50, "F50" },
+
+ { K_F51, "F51" },
+ { K_F52, "F52" },
+ { K_F53, "F53" },
+ { K_F54, "F54" },
+ { K_F55, "F55" },
+ { K_F56, "F56" },
+ { K_F57, "F57" },
+ { K_F58, "F58" },
+ { K_F59, "F59" },
+ { K_F60, "F60" },
+
+ { K_F61, "F61" },
+ { K_F62, "F62" },
+ { K_F63, "F63" },
{ K_XF1, "xF1" },
{ K_XF2, "xF2" },
diff --git a/src/nvim/keymap.h b/src/nvim/keymap.h
index ae2ec7835e..9dff8ba333 100644
--- a/src/nvim/keymap.h
+++ b/src/nvim/keymap.h
@@ -325,6 +325,35 @@ enum key_extra {
#define K_F35 TERMCAP2KEY('F', 'P')
#define K_F36 TERMCAP2KEY('F', 'Q')
#define K_F37 TERMCAP2KEY('F', 'R')
+#define K_F38 TERMCAP2KEY('F', 'S')
+#define K_F39 TERMCAP2KEY('F', 'T')
+#define K_F40 TERMCAP2KEY('F', 'U')
+
+#define K_F41 TERMCAP2KEY('F', 'V')
+#define K_F42 TERMCAP2KEY('F', 'W')
+#define K_F43 TERMCAP2KEY('F', 'X')
+#define K_F44 TERMCAP2KEY('F', 'Y')
+#define K_F45 TERMCAP2KEY('F', 'Z')
+#define K_F46 TERMCAP2KEY('F', 'a')
+#define K_F47 TERMCAP2KEY('F', 'b')
+#define K_F48 TERMCAP2KEY('F', 'c')
+#define K_F49 TERMCAP2KEY('F', 'd')
+#define K_F50 TERMCAP2KEY('F', 'e')
+
+#define K_F51 TERMCAP2KEY('F', 'f')
+#define K_F52 TERMCAP2KEY('F', 'g')
+#define K_F53 TERMCAP2KEY('F', 'h')
+#define K_F54 TERMCAP2KEY('F', 'i')
+#define K_F55 TERMCAP2KEY('F', 'j')
+#define K_F56 TERMCAP2KEY('F', 'k')
+#define K_F57 TERMCAP2KEY('F', 'l')
+#define K_F58 TERMCAP2KEY('F', 'm')
+#define K_F59 TERMCAP2KEY('F', 'n')
+#define K_F60 TERMCAP2KEY('F', 'o')
+
+#define K_F61 TERMCAP2KEY('F', 'p')
+#define K_F62 TERMCAP2KEY('F', 'q')
+#define K_F63 TERMCAP2KEY('F', 'r')
// extra set of shifted function keys F1-F4, for vt100 compatible xterm
#define K_S_XF1 TERMCAP2KEY(KS_EXTRA, KE_S_XF1)
diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c
index f4baa92f5b..59e0d4da6c 100644
--- a/src/nvim/terminal.c
+++ b/src/nvim/terminal.c
@@ -1205,6 +1205,58 @@ static VTermKey convert_key(int key, VTermModifier *statep)
return VTERM_KEY_FUNCTION(36);
case K_F37:
return VTERM_KEY_FUNCTION(37);
+ case K_F38:
+ return VTERM_KEY_FUNCTION(38);
+ case K_F39:
+ return VTERM_KEY_FUNCTION(39);
+ case K_F40:
+ return VTERM_KEY_FUNCTION(40);
+ case K_F41:
+ return VTERM_KEY_FUNCTION(41);
+ case K_F42:
+ return VTERM_KEY_FUNCTION(42);
+ case K_F43:
+ return VTERM_KEY_FUNCTION(43);
+ case K_F44:
+ return VTERM_KEY_FUNCTION(44);
+ case K_F45:
+ return VTERM_KEY_FUNCTION(45);
+ case K_F46:
+ return VTERM_KEY_FUNCTION(46);
+ case K_F47:
+ return VTERM_KEY_FUNCTION(47);
+ case K_F48:
+ return VTERM_KEY_FUNCTION(48);
+ case K_F49:
+ return VTERM_KEY_FUNCTION(49);
+ case K_F50:
+ return VTERM_KEY_FUNCTION(50);
+ case K_F51:
+ return VTERM_KEY_FUNCTION(51);
+ case K_F52:
+ return VTERM_KEY_FUNCTION(52);
+ case K_F53:
+ return VTERM_KEY_FUNCTION(53);
+ case K_F54:
+ return VTERM_KEY_FUNCTION(54);
+ case K_F55:
+ return VTERM_KEY_FUNCTION(55);
+ case K_F56:
+ return VTERM_KEY_FUNCTION(56);
+ case K_F57:
+ return VTERM_KEY_FUNCTION(57);
+ case K_F58:
+ return VTERM_KEY_FUNCTION(58);
+ case K_F59:
+ return VTERM_KEY_FUNCTION(59);
+ case K_F60:
+ return VTERM_KEY_FUNCTION(60);
+ case K_F61:
+ return VTERM_KEY_FUNCTION(61);
+ case K_F62:
+ return VTERM_KEY_FUNCTION(62);
+ case K_F63:
+ return VTERM_KEY_FUNCTION(63);
default:
return VTERM_KEY_NONE;
diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c
index 24958ce041..17656c5ddc 100644
--- a/src/nvim/tui/input.c
+++ b/src/nvim/tui/input.c
@@ -439,22 +439,6 @@ static HandleState handle_bracketed_paste(TermInput *input)
return kNotApplicable;
}
-// ESC NUL => <Esc>
-static bool handle_forced_escape(TermInput *input)
-{
- if (rbuffer_size(input->read_stream.buffer) > 1
- && !rbuffer_cmp(input->read_stream.buffer, "\x1b\x00", 2)) {
- // skip the ESC and NUL and push one <esc> to the input buffer
- size_t rcnt;
- termkey_push_bytes(input->tk, rbuffer_read_ptr(input->read_stream.buffer,
- &rcnt), 1);
- rbuffer_consumed(input->read_stream.buffer, 2);
- tk_getkeys(input, true);
- return true;
- }
- return false;
-}
-
static void set_bg_deferred(void **argv)
{
char *bgvalue = argv[0];
@@ -583,7 +567,6 @@ static void handle_raw_buffer(TermInput *input, bool force)
if (!force
&& (handle_focus_event(input)
|| (is_paste = handle_bracketed_paste(input)) != kNotApplicable
- || handle_forced_escape(input)
|| (is_bc = handle_background_color(input)) != kNotApplicable)) {
if (is_paste == kIncomplete || is_bc == kIncomplete) {
// Wait for the next input, leaving it in the raw buffer due to an
diff --git a/test/functional/terminal/helpers.lua b/test/functional/terminal/helpers.lua
index c5315d0185..51ecae663a 100644
--- a/test/functional/terminal/helpers.lua
+++ b/test/functional/terminal/helpers.lua
@@ -7,7 +7,9 @@ local nvim_dir = helpers.nvim_dir
local feed_command, nvim = helpers.feed_command, helpers.nvim
local function feed_data(data)
- nvim('set_var', 'term_data', data)
+ -- A string containing NUL bytes is not converted to a Blob when
+ -- calling nvim_set_var() API, so convert it using Lua instead.
+ nvim('exec_lua', 'vim.g.term_data = ...', {data})
nvim('command', 'call jobsend(b:terminal_job_id, term_data)')
end
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
index c37cde06ab..8c6cba4def 100644
--- a/test/functional/terminal/tui_spec.lua
+++ b/test/functional/terminal/tui_spec.lua
@@ -214,7 +214,7 @@ describe('TUI', function()
]])
end)
- it('interprets ESC+key as ALT chord', function()
+ it('interprets ESC+key as ALT chord in i_CTRL-V', function()
-- Vim represents ALT/META by setting the "high bit" of the modified key:
-- ALT+j inserts "ê". Nvim does not (#3982).
feed_data('i\022\027j')
@@ -229,6 +229,38 @@ describe('TUI', function()
]])
end)
+ it('interprets <Esc>[27u as <Esc>', function()
+ feed_command('nnoremap <M-;> <Nop>')
+ feed_command('nnoremap <Esc> AESC<Esc>')
+ feed_command('nnoremap ; Asemicolon<Esc>')
+ feed_data('\027[27u;')
+ screen:expect([[
+ ESCsemicolo{1:n} |
+ {4:~ }|
+ {4:~ }|
+ {4:~ }|
+ {5:[No Name] [+] }|
+ |
+ {3:-- TERMINAL --} |
+ ]])
+ -- <Esc>; should be recognized as <M-;> when <M-;> is mapped
+ feed_data('\027;')
+ screen:expect_unchanged()
+ end)
+
+ it('interprets <Esc><Nul> as <M-C-Space> #17198', function()
+ feed_data('i\022\027\000')
+ screen:expect([[
+ <M-C-Space>{1: } |
+ {4:~ }|
+ {4:~ }|
+ {4:~ }|
+ {5:[No Name] [+] }|
+ {3:-- INSERT --} |
+ {3:-- TERMINAL --} |
+ ]])
+ end)
+
it('accepts ASCII control sequences', function()
feed_data('i')
feed_data('\022\007') -- ctrl+g
@@ -271,7 +303,7 @@ describe('TUI', function()
{3:-- TERMINAL --} |
]])
feed_data('\027[201~') -- End paste.
- feed_data('\027\000') -- ESC: go to Normal mode.
+ feed_data('\027[27u') -- ESC: go to Normal mode.
wait_for_mode('n')
screen:expect([[
"pasted from termina{1:l}" |
@@ -453,7 +485,7 @@ describe('TUI', function()
{3:-- TERMINAL --} |
]]}
-- Dot-repeat/redo.
- feed_data('\027\000')
+ feed_data('\027[27u')
wait_for_mode('n')
feed_data('.')
screen:expect{grid=[[
@@ -499,7 +531,7 @@ describe('TUI', function()
vim.paste = function(lines, phase) error("fake fail") end
]], {})
-- Prepare something for dot-repeat/redo.
- feed_data('ifoo\n\027\000')
+ feed_data('ifoo\n\027[27u')
wait_for_mode('n')
screen:expect{grid=[[
foo |
@@ -541,7 +573,7 @@ describe('TUI', function()
{3:-- TERMINAL --} |
]]}
-- Editor should still work after failed/drained paste.
- feed_data('ityped input...\027\000')
+ feed_data('ityped input...\027[27u')
screen:expect{grid=[[
foo |
foo |
@@ -575,7 +607,7 @@ describe('TUI', function()
vim.paste = function(lines, phase) return false end
]], {})
feed_data('\027[200~line A\nline B\n\027[201~')
- feed_data('ifoo\n\027\000')
+ feed_data('ifoo\n\027[27u')
expect_child_buf_lines({'foo',''})
end)
@@ -669,7 +701,7 @@ describe('TUI', function()
{3:-- INSERT --} |
{3:-- TERMINAL --} |
]])
- feed_data('\027\000') -- ESC: go to Normal mode.
+ feed_data('\027[27u') -- ESC: go to Normal mode.
wait_for_mode('n')
-- Dot-repeat/redo.
feed_data('.')
diff --git a/test/functional/ui/input_spec.lua b/test/functional/ui/input_spec.lua
index b581e147e3..8925dda730 100644
--- a/test/functional/ui/input_spec.lua
+++ b/test/functional/ui/input_spec.lua
@@ -52,6 +52,8 @@ describe('mappings', function()
add_mapping('<kenter>','<kenter>')
add_mapping('<kcomma>','<kcomma>')
add_mapping('<kequal>','<kequal>')
+ add_mapping('<f38>','<f38>')
+ add_mapping('<f63>','<f63>')
end)
it('ok', function()
@@ -108,6 +110,8 @@ describe('mappings', function()
check_mapping('<KPComma>','<kcomma>')
check_mapping('<kequal>','<kequal>')
check_mapping('<KPEquals>','<kequal>')
+ check_mapping('<f38>','<f38>')
+ check_mapping('<f63>','<f63>')
end)
it('support meta + multibyte char mapping', function()