diff options
author | Kyohei Uto <im@kyoheiu.dev> | 2023-12-09 06:14:51 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-09 06:14:51 +0900 |
commit | 81494c291d472e48cbe59ce8a28787190f2ace10 (patch) | |
tree | 3e2616d21b8e7ded27f18e7b3f0c49bcbdc8ad9f | |
parent | 19e64ccc152dae99d21ae258b6bed04494d1eeff (diff) | |
parent | e82b2ce7baab98d1367a75a0b6faff23b7ba2fde (diff) |
Merge pull request #258 from kyoheiu/developv2.11.0
v2.11.0
-rw-r--r-- | CHANGELOG.md | 6 | ||||
-rw-r--r-- | Cargo.lock | 2 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | README.md | 5 | ||||
-rw-r--r-- | src/help.rs | 1 | ||||
-rw-r--r-- | src/run.rs | 73 |
6 files changed, 50 insertions, 39 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 0febc0a..3334892 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ ## Unreleased +## v2.11.0 (2023-12-09) + +### Added + +- `<C-h>` for Backspace functionality after `i`, `I`, `c`, `/`, `:` and `z`. + ## v2.10.2 (2023-11-26) ### Fixed @@ -330,7 +330,7 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "felix" -version = "2.10.2" +version = "2.11.0" dependencies = [ "bwrap", "chrono", @@ -1,6 +1,6 @@ [package] name = "felix" -version = "2.10.2" +version = "2.11.0" authors = ["Kyohei Uto <im@kyoheiu.dev>"] edition = "2021" description = "tui file manager with vim-like key mapping" @@ -25,6 +25,11 @@ For more detailed document, visit https://kyoheiu.dev/felix. ## New release +## v2.11.0 (2023-12-09) + +### Added + +- `<C-h>` for Backspace functionality after `i`, `I`, `c`, `/`, `:` and `z`. ## v2.10.2 (2023-11-26) ### Fixed diff --git a/src/help.rs b/src/help.rs index 7acc8ae..fa49c0d 100644 --- a/src/help.rs +++ b/src/help.rs @@ -74,6 +74,7 @@ N :Go backward to the item that matches the keyword. :q<CR> :Exit. :{command} :Execute a command e.g. :zip test *.md <Esc> :Return to the normal mode. +<C-h> :Works as Backspace after `i`, `I`, `c`, `/`, `:` and `z`. ZZ :Exit without cd to last working directory (if `match_vim_exit_behavior` is `false`). ZQ :cd into the last working directory and exit @@ -1942,26 +1942,25 @@ fn _run(mut state: State, session_path: PathBuf) -> Result<(), FxError> { .. }) = event::read()? { - // <C-r> to put the item name(s) in register - if modifiers == KeyModifiers::CONTROL - && code == KeyCode::Char('r') - { - if let Event::Key(KeyEvent { - code, - kind: KeyEventKind::Press, - .. - }) = event::read()? - { - if let Some(reg) = state.registers.check_reg(&code) + match (code, modifiers) { + (KeyCode::Char('r'), KeyModifiers::CONTROL) => { + if let Event::Key(KeyEvent { + code, + kind: KeyEventKind::Press, + .. + }) = event::read()? { - if !reg.is_empty() { - let to_be_inserted = reg - .iter() - .map(|x| x.file_name.clone()) - .collect::<Vec<String>>() - .join(" "); - for c in to_be_inserted.chars() { - if let Some(to_be_added) = + if let Some(reg) = + state.registers.check_reg(&code) + { + if !reg.is_empty() { + let to_be_inserted = reg + .iter() + .map(|x| x.file_name.clone()) + .collect::<Vec<String>>() + .join(" "); + for c in to_be_inserted.chars() { + if let Some(to_be_added) = unicode_width::UnicodeWidthChar::width(c) { if current_pos + to_be_added as u16 @@ -1973,33 +1972,32 @@ fn _run(mut state: State, session_path: PathBuf) -> Result<(), FxError> { current_char_pos += 1; current_pos += to_be_added as u16; } + } + go_to_info_line_and_reset(); + print!( + ":{}", + &command.iter().collect::<String>(), + ); + move_to(current_pos, 2); + screen.flush()?; + continue; + } else { + continue; } - go_to_info_line_and_reset(); - print!( - ":{}", - &command.iter().collect::<String>(), - ); - move_to(current_pos, 2); - screen.flush()?; - continue; } else { continue; } - } else { - continue; } } - } - match code { - KeyCode::Esc => { + (KeyCode::Esc, KeyModifiers::NONE) => { go_to_info_line_and_reset(); hide_cursor(); state.move_cursor(state.layout.y); break 'command; } - KeyCode::Left => { + (KeyCode::Left, KeyModifiers::NONE) => { if current_char_pos == 0 { continue; }; @@ -2014,7 +2012,7 @@ fn _run(mut state: State, session_path: PathBuf) -> Result<(), FxError> { } } - KeyCode::Right => { + (KeyCode::Right, KeyModifiers::NONE) => { if current_char_pos == command.len() { continue; }; @@ -2029,7 +2027,8 @@ fn _run(mut state: State, session_path: PathBuf) -> Result<(), FxError> { } } - KeyCode::Backspace => { + (KeyCode::Backspace, KeyModifiers::NONE) + | (KeyCode::Char('h'), KeyModifiers::CONTROL) => { if current_char_pos == 0 { continue; }; @@ -2049,7 +2048,7 @@ fn _run(mut state: State, session_path: PathBuf) -> Result<(), FxError> { } } - KeyCode::Char(c) => { + (KeyCode::Char(c), KeyModifiers::NONE) => { if let Some(to_be_added) = unicode_width::UnicodeWidthChar::width(c) { @@ -2071,7 +2070,7 @@ fn _run(mut state: State, session_path: PathBuf) -> Result<(), FxError> { } } - KeyCode::Enter => { + (KeyCode::Enter, KeyModifiers::NONE) => { hide_cursor(); //Set the command and argument(s). let commands: String = command.iter().collect(); |