Minor fixes

pull/3/head
Arijit Basu 3 years ago
parent f176655325
commit 2c56b80fde
No known key found for this signature in database
GPG Key ID: 7D7BF809E7378863

2
Cargo.lock generated

@ -1117,7 +1117,7 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]] [[package]]
name = "xplr" name = "xplr"
version = "0.2.3" version = "0.2.4"
dependencies = [ dependencies = [
"criterion", "criterion",
"crossterm", "crossterm",

@ -1,6 +1,6 @@
[package] [package]
name = "xplr" name = "xplr"
version = "0.2.3" # Update app.rs version = "0.2.4" # Update app.rs
authors = ["Arijit Basu <sayanarijit@gmail.com>"] authors = ["Arijit Basu <sayanarijit@gmail.com>"]
edition = "2018" edition = "2018"
description = "An experimental, minimal, configurable TUI file explorer, stealing ideas from nnn and fzf." description = "An experimental, minimal, configurable TUI file explorer, stealing ideas from nnn and fzf."

@ -41,7 +41,9 @@ cargo install xplr
```bash ```bash
mkdir -p ~/.config/xplr 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. 3. Check the key bindings in the config file.

@ -11,7 +11,7 @@ use std::collections::VecDeque;
use std::fs; use std::fs;
use std::path::PathBuf; 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"; pub const TEMPLATE_TABLE_ROW: &str = "TEMPLATE_TABLE_ROW";

@ -282,7 +282,7 @@ impl Default for KeyBindings {
args: [] args: []
/: /:
help: find help: search
messages: messages:
- Call: - Call:
command: bash command: bash
@ -451,6 +451,17 @@ impl Default for Config {
- ResetInputBuffer - ResetInputBuffer
- SwitchMode: default - SwitchMode: default
esc:
help: cancel
messages:
- ResetInputBuffer
- SwitchMode: default
q:
help: cancel & quit
messages:
- Terminate
on_number: on_number:
help: input help: input
messages: messages:

@ -297,7 +297,7 @@ fn draw_help_menu<B: Backend>(f: &mut Frame<B>, rect: Rect, app: &app::App, _: &
.map(|l| Row::new(vec![Cell::from(l)])) .map(|l| Row::new(vec![Cell::from(l)]))
.chain(mode.key_bindings.on_key.iter().filter_map(|(k, a)| { .chain(mode.key_bindings.on_key.iter().filter_map(|(k, a)| {
a.help.clone().map(|h| { 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( .chain(
@ -307,7 +307,7 @@ fn draw_help_menu<B: Backend>(f: &mut Frame<B>, rect: Rect, app: &app::App, _: &
.map(|a| ("a-Z", a.help.clone())) .map(|a| ("a-Z", a.help.clone()))
.filter_map(|(k, mh)| { .filter_map(|(k, mh)| {
mh.map(|h| { 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<B: Backend>(f: &mut Frame<B>, rect: Rect, app: &app::App, _: &
.map(|a| ("0-9", a.help.clone())) .map(|a| ("0-9", a.help.clone()))
.filter_map(|(k, mh)| { .filter_map(|(k, mh)| {
mh.map(|h| { 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<B: Backend>(f: &mut Frame<B>, rect: Rect, app: &app::App, _: &
.map(|a| ("spcl chars", a.help.clone())) .map(|a| ("spcl chars", a.help.clone()))
.filter_map(|(k, mh)| { .filter_map(|(k, mh)| {
mh.map(|h| { 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<B: Backend>(f: &mut Frame<B>, rect: Rect, app: &app::App, _
pub fn draw<B: Backend>(f: &mut Frame<B>, app: &app::App, hb: &Handlebars) { pub fn draw<B: Backend>(f: &mut Frame<B>, app: &app::App, hb: &Handlebars) {
let rect = f.size(); 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) .direction(Direction::Horizontal)
.constraints([TUIConstraint::Percentage(70), TUIConstraint::Percentage(30)].as_ref()) .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]); .split(chunks[0]);
let upper_left_chunks = Layout::default()
let right_chunks = Layout::default()
.direction(Direction::Vertical) .direction(Direction::Vertical)
.constraints([TUIConstraint::Percentage(50), TUIConstraint::Percentage(50)].as_ref()) .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, left_chunks[0], app, hb);
draw_table(f, upper_chunks[0], app, hb); draw_input_buffer(f, left_chunks[1], app, hb);
draw_selected(f, upper_left_chunks[0], app, hb); draw_selected(f, right_chunks[0], app, hb);
draw_help_menu(f, upper_left_chunks[1], app, hb); draw_help_menu(f, right_chunks[1], app, hb);
} }

Loading…
Cancel
Save