Parse ascii newline/tab/escape as special keys instead of control keys
Fixes #3439
This commit is contained in:
parent
8000cd092f
commit
562ee6143a
14
src/keys.cc
14
src/keys.cc
|
@ -89,7 +89,18 @@ KeyList parse_keys(StringView str)
|
||||||
{
|
{
|
||||||
if (*it != '<')
|
if (*it != '<')
|
||||||
{
|
{
|
||||||
result.emplace_back(Key::Modifiers::None, *it);
|
auto convert = [](Codepoint cp) -> Codepoint {
|
||||||
|
switch (cp)
|
||||||
|
{
|
||||||
|
case '\n': return Key::Return;
|
||||||
|
case '\r': return Key::Return;
|
||||||
|
case '\b': return Key::Backspace;
|
||||||
|
case '\t': return Key::Tab;
|
||||||
|
case '\033': return Key::Escape;
|
||||||
|
default: return cp;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
result.emplace_back(Key::Modifiers::None, convert(*it));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,6 +230,7 @@ UnitTest test_keys{[]()
|
||||||
kak_assert(parse_keys("X") == KeyList{ {'X'} });
|
kak_assert(parse_keys("X") == KeyList{ {'X'} });
|
||||||
kak_assert(parse_keys("<s-up>") == KeyList{ shift({Key::Up}) });
|
kak_assert(parse_keys("<s-up>") == KeyList{ shift({Key::Up}) });
|
||||||
kak_assert(parse_keys("<s-tab>") == KeyList{ shift({Key::Tab}) });
|
kak_assert(parse_keys("<s-tab>") == KeyList{ shift({Key::Tab}) });
|
||||||
|
kak_assert(parse_keys("\n") == KeyList{ Key::Return });
|
||||||
|
|
||||||
kak_assert(key_to_str(shift({Key::Tab})) == "<s-tab>");
|
kak_assert(key_to_str(shift({Key::Tab})) == "<s-tab>");
|
||||||
|
|
||||||
|
|
1
test/regression/3439-parse-ascii-newline-as-return/cmd
Normal file
1
test/regression/3439-parse-ascii-newline-as-return/cmd
Normal file
|
@ -0,0 +1 @@
|
||||||
|
|
1
test/regression/3439-parse-ascii-newline-as-return/in
Normal file
1
test/regression/3439-parse-ascii-newline-as-return/in
Normal file
|
@ -0,0 +1 @@
|
||||||
|
|
4
test/regression/3439-parse-ascii-newline-as-return/out
Normal file
4
test/regression/3439-parse-ascii-newline-as-return/out
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
|
1
test/regression/3439-parse-ascii-newline-as-return/rc
Normal file
1
test/regression/3439-parse-ascii-newline-as-return/rc
Normal file
|
@ -0,0 +1 @@
|
||||||
|
exec O %sh{ printf '1\n 2\n 3' } <esc>
|
Loading…
Reference in New Issue
Block a user