From 2c56b80fde3764d7563da60af9cf9d18be293b80 Mon Sep 17 00:00:00 2001 From: Arijit Basu Date: Thu, 1 Apr 2021 22:26:54 +0530 Subject: [PATCH] Minor fixes --- Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 4 +++- src/app.rs | 2 +- src/config.rs | 13 ++++++++++++- src/ui.rs | 33 +++++++++++++++++---------------- 6 files changed, 35 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4428c33..792b7df 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1117,7 +1117,7 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "xplr" -version = "0.2.3" +version = "0.2.4" dependencies = [ "criterion", "crossterm", diff --git a/Cargo.toml b/Cargo.toml index 38b46d1..ac1ce75 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "xplr" -version = "0.2.3" # Update app.rs +version = "0.2.4" # Update app.rs authors = ["Arijit Basu "] edition = "2018" description = "An experimental, minimal, configurable TUI file explorer, stealing ideas from nnn and fzf." diff --git a/README.md b/README.md index ef4f28f..97dcab6 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,9 @@ cargo install xplr ```bash mkdir -p ~/.config/xplr -echo "PrintAppStateAndQuit" | xplr | yq ".config" -y | tee ~/.config/xplr/config.yml +xplr | yq ".config" -y | tee ~/.config/xplr/config.yml + +# When the app loads, press `#` ``` 3. Check the key bindings in the config file. diff --git a/src/app.rs b/src/app.rs index 6b231a5..5287daa 100644 --- a/src/app.rs +++ b/src/app.rs @@ -11,7 +11,7 @@ use std::collections::VecDeque; use std::fs; use std::path::PathBuf; -pub const VERSION: &str = "v0.2.3"; // Update Cargo.toml +pub const VERSION: &str = "v0.2.4"; // Update Cargo.toml pub const TEMPLATE_TABLE_ROW: &str = "TEMPLATE_TABLE_ROW"; diff --git a/src/config.rs b/src/config.rs index 61241b6..fd087ef 100644 --- a/src/config.rs +++ b/src/config.rs @@ -282,7 +282,7 @@ impl Default for KeyBindings { args: [] /: - help: find + help: search messages: - Call: command: bash @@ -451,6 +451,17 @@ impl Default for Config { - ResetInputBuffer - SwitchMode: default + esc: + help: cancel + messages: + - ResetInputBuffer + - SwitchMode: default + + q: + help: cancel & quit + messages: + - Terminate + on_number: help: input messages: diff --git a/src/ui.rs b/src/ui.rs index 7cee041..4235d47 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -297,7 +297,7 @@ fn draw_help_menu(f: &mut Frame, rect: Rect, app: &app::App, _: & .map(|l| Row::new(vec![Cell::from(l)])) .chain(mode.key_bindings.on_key.iter().filter_map(|(k, a)| { a.help.clone().map(|h| { - Row::new(vec![Cell::from(h.to_string()), Cell::from(k.to_string())]) + Row::new(vec![Cell::from(k.to_string()), Cell::from(h.to_string())]) }) })) .chain( @@ -307,7 +307,7 @@ fn draw_help_menu(f: &mut Frame, rect: Rect, app: &app::App, _: & .map(|a| ("a-Z", a.help.clone())) .filter_map(|(k, mh)| { mh.map(|h| { - Row::new(vec![Cell::from(h.to_string()), Cell::from(k.to_string())]) + Row::new(vec![Cell::from(k.to_string()), Cell::from(h.to_string())]) }) }), ) @@ -318,7 +318,7 @@ fn draw_help_menu(f: &mut Frame, rect: Rect, app: &app::App, _: & .map(|a| ("0-9", a.help.clone())) .filter_map(|(k, mh)| { mh.map(|h| { - Row::new(vec![Cell::from(h.to_string()), Cell::from(k.to_string())]) + Row::new(vec![Cell::from(k.to_string()), Cell::from(h.to_string())]) }) }), ) @@ -329,7 +329,7 @@ fn draw_help_menu(f: &mut Frame, rect: Rect, app: &app::App, _: & .map(|a| ("spcl chars", a.help.clone())) .filter_map(|(k, mh)| { mh.map(|h| { - Row::new(vec![Cell::from(h.to_string()), Cell::from(k.to_string())]) + Row::new(vec![Cell::from(k.to_string()), Cell::from(h.to_string())]) }) }), ) @@ -365,24 +365,25 @@ fn draw_input_buffer(f: &mut Frame, rect: Rect, app: &app::App, _ pub fn draw(f: &mut Frame, app: &app::App, hb: &Handlebars) { let rect = f.size(); - let chunks = Layout::default() - .direction(Direction::Vertical) - .margin(1) - .constraints([TUIConstraint::Max(rect.height - 5), TUIConstraint::Max(3)].as_ref()) - .split(rect); - let upper_chunks = Layout::default() + let chunks = Layout::default() .direction(Direction::Horizontal) .constraints([TUIConstraint::Percentage(70), TUIConstraint::Percentage(30)].as_ref()) + .split(rect); + + let left_chunks = Layout::default() + .direction(Direction::Vertical) + .constraints([TUIConstraint::Length(rect.height - 3), TUIConstraint::Min(3)].as_ref()) .split(chunks[0]); - let upper_left_chunks = Layout::default() + + let right_chunks = Layout::default() .direction(Direction::Vertical) .constraints([TUIConstraint::Percentage(50), TUIConstraint::Percentage(50)].as_ref()) - .split(upper_chunks[1]); + .split(chunks[1]); - draw_input_buffer(f, chunks[1], app, hb); - draw_table(f, upper_chunks[0], app, hb); - draw_selected(f, upper_left_chunks[0], app, hb); - draw_help_menu(f, upper_left_chunks[1], app, hb); + draw_table(f, left_chunks[0], app, hb); + draw_input_buffer(f, left_chunks[1], app, hb); + draw_selected(f, right_chunks[0], app, hb); + draw_help_menu(f, right_chunks[1], app, hb); }