Files
neovim/test/functional/ui/input_spec.lua
Olivier G-R f6fb370b1b keymap: add more (keypad) keycodes #9793
- K_KORIGIN instead of K_KCENTER: This name is similar to what is used
  by xev. Alternative could be K_KBEGIN as hinted here:
  https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-PC-Style-Function-Keys
  But I find Begin and Home too similar, and it might induced some
  confusion. The naming looked related to some old keyboard
  configuration.

- keymap.c: alias KPPeriod to kDel instead of kPoint.
  This might seems weird, but this is actually the behaviour that should
  be expected. libtermkey produces "KPPeriod" when num lock is off. To
  fix this would need to change this name in termkey.

closes #9780
closes #9793
2019-03-29 01:11:57 +01:00

274 lines
11 KiB
Lua

local helpers = require('test.functional.helpers')(after_each)
local clear, feed_command, nvim = helpers.clear, helpers.feed_command, helpers.nvim
local feed, next_msg, eq = helpers.feed, helpers.next_msg, helpers.eq
local command = helpers.command
local expect = helpers.expect
local write_file = helpers.write_file
local Screen = require('test.functional.ui.screen')
describe('mappings', function()
local cid
local add_mapping = function(mapping, send)
local cmd = "nnoremap "..mapping.." :call rpcnotify("..cid..", 'mapped', '"
..send:gsub('<', '<lt>').."')<cr>"
feed_command(cmd)
end
local check_mapping = function(mapping, expected)
feed(mapping)
eq({'notification', 'mapped', {expected}}, next_msg())
end
before_each(function()
clear()
cid = nvim('get_api_info')[1]
add_mapping('<s-up>', '<s-up>')
add_mapping('<s-up>', '<s-up>')
add_mapping('<c-s-up>', '<c-s-up>')
add_mapping('<c-s-a-up>', '<c-s-a-up>')
add_mapping('<c-s-a-d-up>', '<c-s-a-d-up>')
add_mapping('<c-d-a>', '<c-d-a>')
add_mapping('<d-1>', '<d-1>')
add_mapping('<khome>','<khome>')
add_mapping('<kup>','<kup>')
add_mapping('<kpageup>','<kpageup>')
add_mapping('<kleft>','<kleft>')
add_mapping('<korigin>','<korigin>')
add_mapping('<kright>','<kright>')
add_mapping('<kend>','<kend>')
add_mapping('<kdown>','<kdown>')
add_mapping('<kpagedown>','<kpagedown>')
add_mapping('<kinsert>','<kinsert>')
add_mapping('<kdel>','<kdel>')
add_mapping('<kdivide>','<kdivide>')
add_mapping('<kmultiply>','<kmultiply>')
add_mapping('<kminus>','<kminus>')
add_mapping('<kplus>','<kplus>')
add_mapping('<kenter>','<kenter>')
end)
it('ok', function()
check_mapping('<s-up>', '<s-up>')
check_mapping('<c-s-up>', '<c-s-up>')
check_mapping('<s-c-up>', '<c-s-up>')
check_mapping('<c-s-a-up>', '<c-s-a-up>')
check_mapping('<s-c-a-up>', '<c-s-a-up>')
check_mapping('<c-a-s-up>', '<c-s-a-up>')
check_mapping('<s-a-c-up>', '<c-s-a-up>')
check_mapping('<a-c-s-up>', '<c-s-a-up>')
check_mapping('<a-s-c-up>', '<c-s-a-up>')
check_mapping('<c-s-a-d-up>', '<c-s-a-d-up>')
check_mapping('<s-a-d-c-up>', '<c-s-a-d-up>')
check_mapping('<d-s-a-c-up>', '<c-s-a-d-up>')
check_mapping('<c-d-a>', '<c-d-a>')
check_mapping('<d-c-a>', '<c-d-a>')
check_mapping('<d-1>', '<d-1>')
check_mapping('<khome>','<khome>')
check_mapping('<KP7>','<khome>')
check_mapping('<kup>','<kup>')
check_mapping('<KP8>','<kup>')
check_mapping('<kpageup>','<kpageup>')
check_mapping('<KP9>','<kpageup>')
check_mapping('<kleft>','<kleft>')
check_mapping('<KP4>','<kleft>')
check_mapping('<korigin>','<korigin>')
check_mapping('<KP5>','<korigin>')
check_mapping('<kright>','<kright>')
check_mapping('<KP6>','<kright>')
check_mapping('<kend>','<kend>')
check_mapping('<KP1>','<kend>')
check_mapping('<kdown>','<kdown>')
check_mapping('<KP2>','<kdown>')
check_mapping('<kpagedown>','<kpagedown>')
check_mapping('<KP3>','<kpagedown>')
check_mapping('<kinsert>','<kinsert>')
check_mapping('<KP0>','<kinsert>')
check_mapping('<kdel>','<kdel>')
check_mapping('<KPPeriod>','<kdel>')
check_mapping('<kdivide>','<kdivide>')
check_mapping('<KPDiv>','<kdivide>')
check_mapping('<kmultiply>','<kmultiply>')
check_mapping('<KPMult>','<kmultiply>')
check_mapping('<kminus>','<kminus>')
check_mapping('<KPMinus>','<kminus>')
check_mapping('<kplus>','<kplus>')
check_mapping('<KPPlus>','<kplus>')
check_mapping('<kenter>','<kenter>')
check_mapping('<KPEnter>','<kenter>')
end)
end)
describe('feeding large chunks of input with <Paste>', function()
local screen
before_each(function()
clear()
screen = Screen.new()
screen:attach()
feed_command('set ruler')
end)
it('ok', function()
if helpers.skip_fragile(pending) then
return
end
local t = {}
for i = 1, 20000 do
t[i] = 'item ' .. tostring(i)
end
feed('i<Paste>')
screen:expect([[
^ |
~ |
~ |
~ |
~ |
~ |
~ |
~ |
~ |
~ |
~ |
~ |
~ |
-- INSERT (paste) -- |
]])
feed(table.concat(t, '<Enter>'))
screen:expect([[
item 19988 |
item 19989 |
item 19990 |
item 19991 |
item 19992 |
item 19993 |
item 19994 |
item 19995 |
item 19996 |
item 19997 |
item 19998 |
item 19999 |
item 20000^ |
-- INSERT (paste) -- |
]])
feed('<Paste>')
screen:expect([[
item 19988 |
item 19989 |
item 19990 |
item 19991 |
item 19992 |
item 19993 |
item 19994 |
item 19995 |
item 19996 |
item 19997 |
item 19998 |
item 19999 |
item 20000^ |
-- INSERT -- 20000,11 Bot |
]])
end)
end)
describe('input utf sequences that contain CSI/K_SPECIAL', function()
before_each(clear)
it('ok', function()
feed('i…<esc>')
expect('')
end)
end)
describe('input non-printable chars', function()
after_each(function()
os.remove('Xtest-overwrite')
end)
it("doesn't crash when echoing them back", function()
write_file("Xtest-overwrite", [[foobar]])
clear()
local screen = Screen.new(60,8)
screen:set_default_attr_ids({
[1] = {bold = true, foreground = Screen.colors.Blue1},
[2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
[3] = {bold = true, foreground = Screen.colors.SeaGreen4}
})
screen:attach()
command("set display-=msgsep shortmess-=F")
feed_command("e Xtest-overwrite")
screen:expect([[
^foobar |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
"Xtest-overwrite" [noeol] 1L, 6C |
]])
-- The timestamp is in second resolution, wait two seconds to be sure.
screen:sleep(2000)
write_file("Xtest-overwrite", [[smurf]])
feed_command("w")
screen:expect([[
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
"Xtest-overwrite" |
{2:WARNING: The file has been changed since reading it!!!} |
{3:Do you really want to write to it (y/n)?}^ |
]])
feed("u")
screen:expect([[
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
"Xtest-overwrite" |
{2:WARNING: The file has been changed since reading it!!!} |
{3:Do you really want to write to it (y/n)?}u |
{3:Do you really want to write to it (y/n)?}^ |
]])
feed("\005")
screen:expect([[
{1:~ }|
{1:~ }|
{1:~ }|
"Xtest-overwrite" |
{2:WARNING: The file has been changed since reading it!!!} |
{3:Do you really want to write to it (y/n)?}u |
{3:Do you really want to write to it (y/n)?} |
{3:Do you really want to write to it (y/n)?}^ |
]])
feed("n")
screen:expect([[
{1:~ }|
{1:~ }|
"Xtest-overwrite" |
{2:WARNING: The file has been changed since reading it!!!} |
{3:Do you really want to write to it (y/n)?}u |
{3:Do you really want to write to it (y/n)?} |
{3:Do you really want to write to it (y/n)?}n |
{3:Press ENTER or type command to continue}^ |
]])
feed("<cr>")
screen:expect([[
^foobar |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
|
]])
end)
end)