runa_tui/config/
input.rs

1use serde::Deserialize;
2use std::vec;
3
4#[derive(Deserialize, Debug)]
5#[serde(default)]
6pub struct Keys {
7    open_file: Vec<String>,
8    go_up: Vec<String>,
9    go_down: Vec<String>,
10    go_parent: Vec<String>,
11    go_into_dir: Vec<String>,
12    quit: Vec<String>,
13    delete: Vec<String>,
14    copy: Vec<String>,
15    paste: Vec<String>,
16    rename: Vec<String>,
17    create: Vec<String>,
18    create_directory: Vec<String>,
19    filter: Vec<String>,
20    toggle_marker: Vec<String>,
21}
22
23#[derive(Deserialize, Debug)]
24#[serde(default)]
25pub struct Editor {
26    cmd: String,
27}
28
29impl Keys {
30    pub fn open_file(&self) -> &Vec<String> {
31        &self.open_file
32    }
33
34    pub fn go_up(&self) -> &Vec<String> {
35        &self.go_up
36    }
37
38    pub fn go_down(&self) -> &Vec<String> {
39        &self.go_down
40    }
41
42    pub fn go_parent(&self) -> &Vec<String> {
43        &self.go_parent
44    }
45
46    pub fn go_into_dir(&self) -> &Vec<String> {
47        &self.go_into_dir
48    }
49
50    pub fn quit(&self) -> &Vec<String> {
51        &self.quit
52    }
53
54    pub fn delete(&self) -> &Vec<String> {
55        &self.delete
56    }
57
58    pub fn copy(&self) -> &Vec<String> {
59        &self.copy
60    }
61
62    pub fn paste(&self) -> &Vec<String> {
63        &self.paste
64    }
65
66    pub fn rename(&self) -> &Vec<String> {
67        &self.rename
68    }
69
70    pub fn create(&self) -> &Vec<String> {
71        &self.create
72    }
73
74    pub fn create_directory(&self) -> &Vec<String> {
75        &self.create_directory
76    }
77
78    pub fn filter(&self) -> &Vec<String> {
79        &self.filter
80    }
81
82    pub fn toggle_marker(&self) -> &Vec<String> {
83        &self.toggle_marker
84    }
85}
86
87impl Default for Keys {
88    fn default() -> Self {
89        Keys {
90            open_file: vec!["Enter".into()],
91            go_up: vec!["k".into(), "Up".into()],
92            go_down: vec!["j".into(), "Down".into()],
93            go_parent: vec!["h".into(), "Left".into(), "Backspace".into()],
94            go_into_dir: vec!["l".into(), "Right".into()],
95            quit: vec!["q".into(), "Esc".into()],
96
97            delete: vec!["d".into()],
98            copy: vec!["y".into()],
99            paste: vec!["p".into()],
100            rename: vec!["r".into()],
101            create: vec!["n".into()],
102            create_directory: vec!["Shift+n".into()],
103            filter: vec!["f".into()],
104            toggle_marker: vec![" ".into()],
105        }
106    }
107}
108
109impl Editor {
110    pub fn cmd(&self) -> &str {
111        &self.cmd
112    }
113}
114
115impl Default for Editor {
116    fn default() -> Self {
117        Editor { cmd: "nvim".into() }
118    }
119}