|
1 | 1 | use super::super::app::{ActiveBlock, App, RouteId};
|
2 | 2 | use crate::event::Key;
|
| 3 | + |
3 | 4 | pub fn down_event(key: Key) -> bool {
|
4 |
| - match key { |
5 |
| - Key::Down | Key::Char('j') | Key::Ctrl('n') => true, |
6 |
| - _ => false, |
7 |
| - } |
| 5 | + matches!(key, Key::Down | Key::Char('j') | Key::Ctrl('n')) |
8 | 6 | }
|
9 | 7 |
|
10 | 8 | pub fn up_event(key: Key) -> bool {
|
11 |
| - match key { |
12 |
| - Key::Up | Key::Char('k') | Key::Ctrl('p') => true, |
13 |
| - _ => false, |
14 |
| - } |
| 9 | + matches!(key, Key::Up | Key::Char('k') | Key::Ctrl('p')) |
15 | 10 | }
|
16 | 11 |
|
17 | 12 | pub fn left_event(key: Key) -> bool {
|
18 |
| - match key { |
19 |
| - Key::Left | Key::Char('h') | Key::Ctrl('b') => true, |
20 |
| - _ => false, |
21 |
| - } |
| 13 | + matches!(key, Key::Left | Key::Char('h') | Key::Ctrl('b')) |
22 | 14 | }
|
23 | 15 |
|
24 | 16 | pub fn right_event(key: Key) -> bool {
|
25 |
| - match key { |
26 |
| - Key::Right | Key::Char('l') | Key::Ctrl('f') => true, |
27 |
| - _ => false, |
28 |
| - } |
| 17 | + matches!(key, Key::Right | Key::Char('l') | Key::Ctrl('f')) |
29 | 18 | }
|
30 | 19 |
|
31 | 20 | pub fn high_event(key: Key) -> bool {
|
32 |
| - match key { |
33 |
| - Key::Char('H') => true, |
34 |
| - _ => false, |
35 |
| - } |
| 21 | + matches!(key, Key::Char('H')) |
36 | 22 | }
|
37 | 23 |
|
38 | 24 | pub fn middle_event(key: Key) -> bool {
|
39 |
| - match key { |
40 |
| - Key::Char('M') => true, |
41 |
| - _ => false, |
42 |
| - } |
| 25 | + matches!(key, Key::Char('M')) |
43 | 26 | }
|
44 | 27 |
|
45 | 28 | pub fn low_event(key: Key) -> bool {
|
46 |
| - match key { |
47 |
| - Key::Char('L') => true, |
48 |
| - _ => false, |
49 |
| - } |
| 29 | + matches!(key, Key::Char('L')) |
50 | 30 | }
|
51 | 31 |
|
52 | 32 | pub fn on_down_press_handler<T>(selection_data: &[T], selection_index: Option<usize>) -> usize {
|
|
0 commit comments