diff --git a/src/client.cc b/src/client.cc index 0211c81b..3d4e90dd 100644 --- a/src/client.cc +++ b/src/client.cc @@ -258,7 +258,7 @@ void Client::on_buffer_reload_key(Key key) { auto& buffer = context().buffer(); - if (key == 'y' or key == ctrl('m')) + if (key == 'y' or key == Key::Return) reload_buffer(); else if (key == 'n' or key == Key::Escape) { diff --git a/src/input_handler.cc b/src/input_handler.cc index dacb29a2..772be7d9 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -515,7 +515,7 @@ public: return false; }; - if (key == ctrl('m')) + if (key == Key::Return) { if (context().has_client()) context().client().menu_hide(); @@ -543,7 +543,7 @@ public: m_callback(selected, MenuEvent::Abort, context()); } } - else if (key == Key::Down or key == ctrl('i') or + else if (key == Key::Down or key == Key::Tab or key == ctrl('n') or (not m_edit_filter and key == 'j')) { auto it = std::find_if(m_selected+1, m_choices.end(), match_filter); @@ -665,7 +665,7 @@ public: const String& line = m_line_editor.line(); bool showcompl = false; - if (key == ctrl('m')) // enter + if (key == Key::Return) { if (not context().history_disabled()) history_push(history, line); @@ -761,7 +761,7 @@ public: showcompl = true; } } - else if (key == ctrl('i') or key == Key::BackTab) // tab completion + else if (key == Key::Tab or key == Key::BackTab) // tab completion { const bool reverse = (key == Key::BackTab); CandidateList& candidates = m_completions.candidates; diff --git a/src/keys.cc b/src/keys.cc index ce710b80..91917ee0 100644 --- a/src/keys.cc +++ b/src/keys.cc @@ -23,9 +23,9 @@ static Key canonicalize_ifn(Key key) Optional Key::codepoint() const { - if (*this == ctrl('m')) + if (*this == Key::Return) return '\n'; - if (*this == ctrl('i')) + if (*this == Key::Tab) return '\t'; if (modifiers == Modifiers::None and key > 27 and (key < 0xD800 or key > 0xDFFF)) // avoid surrogates @@ -35,9 +35,9 @@ Optional Key::codepoint() const struct KeyAndName { const char* name; Codepoint key; }; static constexpr KeyAndName keynamemap[] = { - { "ret", '\r' }, + { "ret", Key::Return }, { "space", ' ' }, - { "tab", '\t' }, + { "tab", Key::Tab }, { "lt", '<' }, { "gt", '>' }, { "backspace", Key::Backspace}, diff --git a/src/keys.hh b/src/keys.hh index f085effe..0e93da8c 100644 --- a/src/keys.hh +++ b/src/keys.hh @@ -36,6 +36,7 @@ struct Key Backspace = 0xD800, Delete, Escape, + Return, Up, Down, Left, @@ -44,6 +45,7 @@ struct Key PageDown, Home, End, + Tab, BackTab, F1, F2, diff --git a/src/ncurses_ui.cc b/src/ncurses_ui.cc index 249e8614..167f75f6 100644 --- a/src/ncurses_ui.cc +++ b/src/ncurses_ui.cc @@ -499,6 +499,10 @@ Key NCursesUI::get_key() if (c > 0 and c < 27) { + if (c == control('m') or c == control('j')) + return Key::Return; + if (c == control('i')) + return Key::Tab; if (c == control('z')) { raise(SIGTSTP);