From d3def16584f7f35a64ab2bad578436bd13cc18b6 Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Fri, 12 Nov 2021 16:21:03 +0900 Subject: fix: shift-tab mappings broken after efc2b4c7 --- helix-term/src/keymap.rs | 16 ++++++++++++++++ helix-term/src/ui/menu.rs | 4 ++-- helix-term/src/ui/picker.rs | 4 ++-- helix-term/src/ui/prompt.rs | 4 ++-- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/helix-term/src/keymap.rs b/helix-term/src/keymap.rs index 1a9ea231..e3e01995 100644 --- a/helix-term/src/keymap.rs +++ b/helix-term/src/keymap.rs @@ -25,6 +25,22 @@ macro_rules! key { }; } +#[macro_export] +macro_rules! shift { + ($key:ident) => { + ::helix_view::input::KeyEvent { + code: ::helix_view::keyboard::KeyCode::$key, + modifiers: ::helix_view::keyboard::KeyModifiers::SHIFT, + } + }; + ($($ch:tt)*) => { + ::helix_view::input::KeyEvent { + code: ::helix_view::keyboard::KeyCode::Char($($ch)*), + modifiers: ::helix_view::keyboard::KeyModifiers::SHIFT, + } + }; +} + #[macro_export] macro_rules! ctrl { ($key:ident) => { diff --git a/helix-term/src/ui/menu.rs b/helix-term/src/ui/menu.rs index 8278bd29..e891c149 100644 --- a/helix-term/src/ui/menu.rs +++ b/helix-term/src/ui/menu.rs @@ -1,6 +1,6 @@ use crate::{ compositor::{Component, Compositor, Context, EventResult}, - ctrl, key, + ctrl, key, shift, }; use crossterm::event::Event; use tui::{buffer::Buffer as Surface, widgets::Table}; @@ -202,7 +202,7 @@ impl Component for Menu { return close_fn; } // arrow up/ctrl-p/shift-tab prev completion choice (including updating the doc) - key!(BackTab) | key!(Up) | ctrl!('p') | ctrl!('k') => { + shift!(BackTab) | key!(Up) | ctrl!('p') | ctrl!('k') => { self.move_up(); (self.callback_fn)(cx.editor, self.selection(), MenuEvent::Update); return EventResult::Consumed(None); diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs index 970d3946..c44b7625 100644 --- a/helix-term/src/ui/picker.rs +++ b/helix-term/src/ui/picker.rs @@ -1,6 +1,6 @@ use crate::{ compositor::{Component, Compositor, Context, EventResult}, - ctrl, key, + ctrl, key, shift, ui::EditorView, }; use crossterm::event::Event; @@ -404,7 +404,7 @@ impl Component for Picker { }))); match key_event.into() { - key!(BackTab) | key!(Up) | ctrl!('p') | ctrl!('k') => { + shift!(BackTab) | key!(Up) | ctrl!('p') | ctrl!('k') => { self.move_up(); } key!(Tab) | key!(Down) | ctrl!('n') | ctrl!('j') => { diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs index 9a60196f..deed1609 100644 --- a/helix-term/src/ui/prompt.rs +++ b/helix-term/src/ui/prompt.rs @@ -1,5 +1,5 @@ use crate::compositor::{Component, Compositor, Context, EventResult}; -use crate::{alt, ctrl, key, ui}; +use crate::{alt, ctrl, key, shift, ui}; use crossterm::event::Event; use helix_view::input::KeyEvent; use helix_view::keyboard::{KeyCode, KeyModifiers}; @@ -496,7 +496,7 @@ impl Component for Prompt { self.change_completion_selection(CompletionDirection::Forward); (self.callback_fn)(cx, &self.line, PromptEvent::Update) } - key!(BackTab) => { + shift!(BackTab) => { self.change_completion_selection(CompletionDirection::Backward); (self.callback_fn)(cx, &self.line, PromptEvent::Update) } -- cgit v1.2.3-70-g09d2