From 50e422659bb1533da2d5f04bbd17de062dcad84b Mon Sep 17 00:00:00 2001 From: Tim Allen Date: Thu, 15 Mar 2018 23:02:27 +1100 Subject: Add support for the shift modifier. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Because keyboard layouts vary, the shift-modifier `` is only supported for special keys (like `` and ``) and for ASCII lowercase where we assume the shift-modifier just produces the matching uppercase character. Even that's not universally true, since in Turkish `i` and `I` are not an uppercase/lowercase pair, but Kakoune's default keyboard mappings already assume en-US mappings for mnemonic purposes. Mappings of the form `` are normalized to `` when `x` is an ASCII character. `` is removed, since we can now say ``. --- src/input_handler.cc | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/input_handler.cc') diff --git a/src/input_handler.cc b/src/input_handler.cc index 2ee1d40d..1466ae02 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -461,15 +461,15 @@ public: } else if (key == ctrl('w')) to_next_word_begin(m_cursor_pos, m_line); - else if (key == ctrlalt('w')) + else if (key == ctrl(alt('w'))) to_next_word_begin(m_cursor_pos, m_line); else if (key == ctrl('b')) to_prev_word_begin(m_cursor_pos, m_line); - else if (key == ctrlalt('b')) + else if (key == ctrl(alt('b'))) to_prev_word_begin(m_cursor_pos, m_line); else if (key == ctrl('e')) to_next_word_end(m_cursor_pos, m_line); - else if (key == ctrlalt('e')) + else if (key == ctrl(alt('e'))) to_next_word_end(m_cursor_pos, m_line); else if (key == ctrl('k')) m_line = m_line.substr(0_char, m_cursor_pos).str(); @@ -623,7 +623,7 @@ public: it = std::find_if(m_choices.begin(), m_selected, match_filter); select(it); } - else if (key == Key::Up or key == Key::BackTab or + else if (key == Key::Up or key == shift(Key::Tab) or key == ctrl('p') or (not m_edit_filter and key == 'k')) { ChoiceList::const_reverse_iterator selected(m_selected+1); @@ -837,9 +837,9 @@ public: m_refresh_completion_pending = true; } } - else if (key == Key::Tab or key == Key::BackTab) // tab completion + else if (key == Key::Tab or key == shift(Key::Tab)) // tab completion { - const bool reverse = (key == Key::BackTab); + const bool reverse = (key == shift(Key::Tab)); CandidateList& candidates = m_completions.candidates; // first try, we need to ask our completer for completions if (candidates.empty()) @@ -1568,8 +1568,10 @@ InputHandler::ScopedForceNormal::~ScopedForceNormal() static bool is_valid(Key key) { + constexpr Key::Modifiers valid_mods = (Key::Modifiers::Control | Key::Modifiers::Alt | Key::Modifiers::Shift); + return key != Key::Invalid and - ((key.modifiers & ~Key::Modifiers::ControlAlt) or key.key <= 0x10FFFF); + ((key.modifiers & ~valid_mods) or key.key <= 0x10FFFF); } void InputHandler::handle_key(Key key) -- cgit v1.2.3