summaryrefslogtreecommitdiff
path: root/schist_desktop_gui/src/config/keys.rs
blob: d72fb125d74e70a20e6b496f315731f86d32c960 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Borrowed from https://github.com/squidowl/halloy/tree/main/data/src/config/keys.rs

use crate::{
    gui::screens::main_screen::View,
    shortcut::{shortcut, Command, KeyBind, Shortcut},
};

#[derive(Debug, Clone)]
pub struct Keyboard {
    pub activate: KeyBind,
    pub goto_next_item: KeyBind,
    pub goto_prev_item: KeyBind,
    pub goto_next_view: KeyBind,
    pub goto_prev_view: KeyBind,
    pub expand_item: KeyBind,
    pub collapse_item: KeyBind,
    pub goto_view_1: KeyBind,
    pub goto_view_2: KeyBind,
    pub goto_view_3: KeyBind,
}

impl Default for Keyboard {
    fn default() -> Self {
        Self {
            activate: KeyBind::activate(),
            goto_next_item: KeyBind::goto_next_item(),
            goto_prev_item: KeyBind::goto_prev_item(),
            goto_next_view: KeyBind::goto_next_view(),
            goto_prev_view: KeyBind::goto_prev_view(),
            expand_item: KeyBind::expand_item(),
            collapse_item: KeyBind::collapse_item(),
            goto_view_1: KeyBind::goto_view_1(),
            goto_view_2: KeyBind::goto_view_2(),
            goto_view_3: KeyBind::goto_view_3(),
        }
    }
}

impl Keyboard {
    pub fn shortcuts(&self) -> Vec<Shortcut> {
        vec![
            shortcut(self.activate.clone(), Command::Activate),
            shortcut(self.goto_next_item.clone(), Command::GotoNextItem),
            shortcut(self.goto_prev_item.clone(), Command::GotoPrevItem),
            shortcut(self.goto_next_view.clone(), Command::GotoNextView),
            shortcut(self.goto_prev_view.clone(), Command::GotoPrevView),
            shortcut(self.expand_item.clone(), Command::ExpandItem),
            shortcut(self.collapse_item.clone(), Command::CollapseItem),
            shortcut(self.goto_view_1.clone(), Command::GotoView(View::VIEW_1)),
            shortcut(self.goto_view_2.clone(), Command::GotoView(View::VIEW_2)),
            shortcut(self.goto_view_3.clone(), Command::GotoView(View::VIEW_3)),
        ]
    }
}