Skip to content

Commit

Permalink
keymap: added gh for goto home dir
Browse files Browse the repository at this point in the history
Signed-off-by: aserowy <serowy@hotmail.com>
  • Loading branch information
aserowy committed Feb 19, 2024
1 parent ae5c7b5 commit 86d1f4c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ to navigation.
| keys | action |
| ---------- | --------------------------------------------------------- |
| h, l | move cursor left/right |
| 0, $ | movve cursor to line start/end |
| 0, $ | move cursor to line start/end |
| j, k | navigating the current directory |
| m | go into normal mode |
| dd | delete the current line |
Expand Down
2 changes: 1 addition & 1 deletion y1337-frontend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ futures = "0.3.30"
ratatui = "0.26.1"
y1337-keymap = { path = "../y1337-keymap" }
tokio = { version = "1.35.1", features = ["full"] }
dirs = "5.0.1"
csv = "1.3.0"
thiserror = "1.0.56"
notify = { version = "6.1.1", default-features = false, features = ["macos_fsevent"] }
infer = "0.15.0"
dirs = "5.0.1"
1 change: 1 addition & 0 deletions y1337-keymap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ edition = "2021"

[dependencies]
crossterm = "0.27.0"
dirs = "5.0.1"
thiserror = "1.0.56"
15 changes: 14 additions & 1 deletion y1337-keymap/src/map.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::collections::HashMap;
use std::{collections::HashMap, path::PathBuf};

use crate::{
key::{Key, KeyCode, KeyModifier},
Expand Down Expand Up @@ -89,6 +89,13 @@ impl Default for KeyMap {
TextModification::DeleteLineOnCursor,
),
),
(
vec![
Key::new(KeyCode::from_char('g'), vec![]),
Key::new(KeyCode::from_char('h'), vec![]),
],
Binding::Message(Message::SelectPath(get_home_path())),
),
(
vec![Key::new(KeyCode::from_char('h'), vec![])],
Binding::Message(Message::SelectParent),
Expand Down Expand Up @@ -322,3 +329,9 @@ fn add_mapping(
}
}
}

fn get_home_path() -> PathBuf {
dirs::home_dir()
.expect("Failed to get home directory")
.to_path_buf()
}

0 comments on commit 86d1f4c

Please sign in to comment.