mirror of
https://github.com/mawww/kakoune.git
synced 2024-11-23 23:34:12 +03:00
Make space a named key to correctly handle shift modifier
This commit is contained in:
parent
36eebbce4f
commit
658b6b0f1a
@ -1003,7 +1003,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
if (key == ' ' and
|
||||
if (key == Key::Space and
|
||||
not (m_completions.flags & Completions::Flags::Quoted) and // if token is quoted, this space does not end it
|
||||
can_auto_insert_completion())
|
||||
m_line_editor.insert_from(line.char_count_to(m_completions.start),
|
||||
|
@ -49,6 +49,8 @@ Optional<Codepoint> Key::codepoint() const
|
||||
return '\n';
|
||||
if (*this == Key::Tab)
|
||||
return '\t';
|
||||
if (*this == Key::Space)
|
||||
return ' ';
|
||||
if (*this == Key::Escape)
|
||||
return 0x1B;
|
||||
if (modifiers == Modifiers::None and key > 27 and
|
||||
@ -60,7 +62,7 @@ Optional<Codepoint> Key::codepoint() const
|
||||
struct KeyAndName { const char* name; Codepoint key; };
|
||||
static constexpr KeyAndName keynamemap[] = {
|
||||
{ "ret", Key::Return },
|
||||
{ "space", ' ' },
|
||||
{ "space", Key::Space },
|
||||
{ "tab", Key::Tab },
|
||||
{ "lt", '<' },
|
||||
{ "gt", '>' },
|
||||
@ -99,6 +101,7 @@ KeyList parse_keys(StringView str)
|
||||
case '\r': return Key::Return;
|
||||
case '\b': return Key::Backspace;
|
||||
case '\t': return Key::Tab;
|
||||
case ' ': return Key::Space;
|
||||
case '\033': return Key::Escape;
|
||||
default: return cp;
|
||||
}
|
||||
@ -225,9 +228,9 @@ String key_to_str(Key key)
|
||||
UnitTest test_keys{[]()
|
||||
{
|
||||
KeyList keys{
|
||||
{ ' ' },
|
||||
{Key::Space},
|
||||
{ 'c' },
|
||||
{ Key::Up },
|
||||
{Key::Up},
|
||||
alt('j'),
|
||||
ctrl('r'),
|
||||
shift(Key::Up),
|
||||
|
@ -53,6 +53,7 @@ struct Key
|
||||
End,
|
||||
Insert,
|
||||
Tab,
|
||||
Space,
|
||||
F1,
|
||||
F2,
|
||||
F3,
|
||||
|
@ -1293,7 +1293,7 @@ void select_object(Context& context, NormalParams params)
|
||||
{ alt('w'), select_word<WORD> },
|
||||
{ 's', select_sentence },
|
||||
{ 'p', select_paragraph },
|
||||
{ ' ', select_whitespaces },
|
||||
{ Key::Space, select_whitespaces },
|
||||
{ 'i', select_indent },
|
||||
{ 'n', select_number },
|
||||
{ 'u', select_argument },
|
||||
@ -1399,7 +1399,7 @@ void select_object(Context& context, NormalParams params)
|
||||
{{alt('w')}, "WORD"},
|
||||
{{'s'}, "sentence"},
|
||||
{{'p'}, "paragraph"},
|
||||
{{' '}, "whitespaces"},
|
||||
{{Key::Space}, "whitespaces"},
|
||||
{{'i'}, "indent"},
|
||||
{{'u'}, "argument"},
|
||||
{{'n'}, "number"},
|
||||
@ -2278,8 +2278,8 @@ static constexpr HashMap<Key, NormalCmd, MemoryDomain::Undefined, KeymapBackend>
|
||||
{ {'!'}, {"insert command output", insert_output<PasteMode::Insert>} },
|
||||
{ {alt('!')}, {"append command output", insert_output<PasteMode::Append>} },
|
||||
|
||||
{ {' '}, {"remove all selections except main", keep_selection} },
|
||||
{ {alt(' ')}, {"remove main selection", remove_selection} },
|
||||
{ {Key::Space}, {"remove all selections except main", keep_selection} },
|
||||
{ {alt(Key::Space)}, {"remove main selection", remove_selection} },
|
||||
{ {';'}, {"reduce selections to their cursor", clear_selections} },
|
||||
{ {alt(';')}, {"swap selections cursor and anchor", flip_selections} },
|
||||
{ {alt(':')}, {"ensure selection cursor is after anchor", ensure_forward} },
|
||||
|
@ -705,6 +705,8 @@ Optional<Key> TerminalUI::get_next_key()
|
||||
return Key::Return;
|
||||
if (c == control('i'))
|
||||
return Key::Tab;
|
||||
if (c == ' ')
|
||||
return Key::Space;
|
||||
if (c == m_original_termios.c_cc[VERASE])
|
||||
return Key::Backspace;
|
||||
if (c == 127) // when it's not backspace
|
||||
@ -719,7 +721,7 @@ Optional<Key> TerminalUI::get_next_key()
|
||||
// Special case: you can type NUL with Ctrl-2 or Ctrl-Shift-2 or
|
||||
// Ctrl-Backtick, but the most straightforward way is Ctrl-Space.
|
||||
if (c == 0)
|
||||
return ctrl(' ');
|
||||
return ctrl(Key::Space);
|
||||
// Represent Ctrl-letter combinations in lower-case, to be clear
|
||||
// that Shift is not involved.
|
||||
if (c < 27)
|
||||
@ -908,7 +910,7 @@ Optional<Key> TerminalUI::get_next_key()
|
||||
|
||||
switch (code)
|
||||
{
|
||||
case ' ': return Key{mod, ' '};
|
||||
case ' ': return Key{mod, Key::Space};
|
||||
case 'A': return Key{mod, Key::Up};
|
||||
case 'B': return Key{mod, Key::Down};
|
||||
case 'C': return Key{mod, Key::Right};
|
||||
|
Loading…
Reference in New Issue
Block a user