@@ -88,43 +88,44 @@ use std::collections::HashMap;
8888// }
8989
9090// #[cfg(feature = "term")]
91−pub use crossterm::event::{KeyCode, KeyEvent as Key, KeyModifiers as Modifiers};
91+pub use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
9292
93−pub type Keymap = HashMap<Key, Command>;
93+pub type Keymap = HashMap<KeyEvent, Command>;
9494pub type Keymaps = HashMap<Mode, Keymap>;
9595
96+#[macro_export]
9697macro_rules! key {
97− ($ch:expr) => {
98− Key {
99− code: KeyCode::Char($ch),
100− modifiers: Modifiers::NONE,
98+ ($($ch:tt)*) => {
99+ KeyEvent {
100+ code: KeyCode::Char($($ch)*),
101+ modifiers: KeyModifiers::NONE,
101102 }
102103 };
103104}
104105
105106macro_rules! shift {
106− ($ch:expr) => {
107− Key {
108− code: KeyCode::Char($ch),
109− modifiers: Modifiers::SHIFT,
107+ ($($ch:tt)*) => {
108+ KeyEvent {
109+ code: KeyCode::Char($($ch)*),
110+ modifiers: KeyModifiers::SHIFT,
110111 }
111112 };
112113}
113114
114115macro_rules! ctrl {
115− ($ch:expr) => {
116− Key {
117− code: KeyCode::Char($ch),
118− modifiers: Modifiers::CONTROL,
116+ ($($ch:tt)*) => {
117+ KeyEvent {
118+ code: KeyCode::Char($($ch)*),
119+ modifiers: KeyModifiers::CONTROL,
119120 }
120121 };
121122}
122123
123124macro_rules! alt {
124− ($ch:expr) => {
125− Key {
126− code: KeyCode::Char($ch),
127− modifiers: Modifiers::ALT,
125+ ($($ch:tt)*) => {
126+ KeyEvent {
127+ code: KeyCode::Char($($ch)*),
128+ modifiers: KeyModifiers::ALT,
128129 }
129130 };
130131}
@@ -228,26 +229,26 @@ pub fn default() -> Keymaps {
228229
229230 // C / altC = copy (repeat) selections on prev/next lines
230231
231− Key {
232+ KeyEvent {
232233 code: KeyCode::Esc,
233− modifiers: Modifiers::NONE
234+ modifiers: KeyModifiers::NONE
234235 } => commands::normal_mode,
235− Key {
236+ KeyEvent {
236237 code: KeyCode::PageUp,
237− modifiers: Modifiers::NONE
238+ modifiers: KeyModifiers::NONE
238239 } => commands::page_up,
239− Key {
240+ KeyEvent {
240241 code: KeyCode::PageDown,
241− modifiers: Modifiers::NONE
242+ modifiers: KeyModifiers::NONE
242243 } => commands::page_down,
243244 ctrl!('u') => commands::half_page_up,
244245 ctrl!('d') => commands::half_page_down,
245246
246247 ctrl!('p') => commands::file_picker,
247248 ctrl!('b') => commands::buffer_picker,
248− Key {
249+ KeyEvent {
249250 code: KeyCode::Tab,
250− modifiers: Modifiers::NONE
251+ modifiers: KeyModifiers::NONE
251252 } => commands::next_view,
252253
253254 // move under <space>c
@@ -280,9 +281,9 @@ pub fn default() -> Keymaps {
280281 shift!('T') => commands::extend_till_prev_char,
281282 shift!('F') => commands::extend_prev_char,
282283
283− Key {
284+ KeyEvent {
284285 code: KeyCode::Esc,
285− modifiers: Modifiers::NONE
286+ modifiers: KeyModifiers::NONE
286287 } => commands::exit_select_mode as Command,
287288 )
288289 .into_iter(),
@@ -294,25 +295,25 @@ pub fn default() -> Keymaps {
294295 Mode::Normal => normal,
295296 Mode::Select => select,
296297 Mode::Insert => hashmap!(
297− Key {
298+ KeyEvent {
298299 code: KeyCode::Esc,
299− modifiers: Modifiers::NONE
300+ modifiers: KeyModifiers::NONE
300301 } => commands::normal_mode as Command,
301− Key {
302+ KeyEvent {
302303 code: KeyCode::Backspace,
303− modifiers: Modifiers::NONE
304+ modifiers: KeyModifiers::NONE
304305 } => commands::insert::delete_char_backward,
305− Key {
306+ KeyEvent {
306307 code: KeyCode::Delete,
307− modifiers: Modifiers::NONE
308+ modifiers: KeyModifiers::NONE
308309 } => commands::insert::delete_char_forward,
309− Key {
310+ KeyEvent {
310311 code: KeyCode::Enter,
311− modifiers: Modifiers::NONE
312+ modifiers: KeyModifiers::NONE
312313 } => commands::insert::insert_newline,
313− Key {
314+ KeyEvent {
314315 code: KeyCode::Tab,
315− modifiers: Modifiers::NONE
316+ modifiers: KeyModifiers::NONE
316317 } => commands::insert::insert_tab,
317318
318319 ctrl!('x') => commands::completion,