Refresh after running command

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

2
Cargo.lock generated

@ -1133,7 +1133,7 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "xplr"
version = "0.1.7"
version = "0.1.8"
dependencies = [
"criterion",
"crossterm",

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

@ -49,5 +49,7 @@ TODO research
- [ ] Research saner configuration formats.
- [ ] Research saner key binding options.
- [ ] Research how to go beyond filesystem and explore any tree-like structure.
- [ ] Research ways to make it faster (load and run).
- [ ] Research ways to implement a plugin system.
- [ ] CLI options and help menu.
- [ ] Go beyond research and implement things.

@ -16,14 +16,14 @@ fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("focus next item", |b| {
b.iter(|| {
app.clone()
.handle(&config::Action::Global(config::GlobalAction::FocusNextItem))
.handle(&config::Action::Global(config::GlobalAction::FocusNext))
})
});
c.bench_function("focus previous item", |b| {
b.iter(|| {
app.clone().handle(&config::Action::Global(
config::GlobalAction::FocusPreviousItem,
config::GlobalAction::FocusPrevious,
))
})
});
@ -31,14 +31,14 @@ fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("focus first item", |b| {
b.iter(|| {
app.clone()
.handle(&config::Action::Global(config::GlobalAction::FocusFirstItem))
.handle(&config::Action::Global(config::GlobalAction::FocusFirst))
})
});
c.bench_function("focus last item", |b| {
b.iter(|| {
app.clone()
.handle(&config::Action::Global(config::GlobalAction::FocusLastItem))
.handle(&config::Action::Global(config::GlobalAction::FocusLast))
})
});
}

@ -14,7 +14,7 @@ use std::io::BufReader;
use std::path::Path;
use std::path::PathBuf;
pub const VERSION: &str = "v0.1.7"; // Update Cargo.toml
pub const VERSION: &str = "v0.1.8"; // Update Cargo.toml
pub const UNSUPPORTED_STR: &str = "???";
pub const TOTAL_ROWS: usize = 50;
@ -301,15 +301,33 @@ impl App {
})
}
pub fn refresh(self) -> Result<Self, Error> {
Self::new(
&self.config,
&self.directory_buffer.pwd,
&self.saved_buffers,
&self.selected_paths,
self.mode,
self.show_hidden,
self.directory_buffer.focus,
)
}
pub fn exit_submode(self) -> Result<Self, Error> {
let mut app = self;
let mode = match app.mode {
let mode = match self.mode {
Mode::ExploreSubmode(_) => Mode::Explore,
Mode::SelectSubmode(_) => Mode::Select,
m => m,
};
app.mode = mode;
Ok(app)
Self::new(
&self.config,
&self.directory_buffer.pwd,
&self.saved_buffers,
&self.selected_paths,
mode,
self.show_hidden,
self.directory_buffer.focus,
)
}
pub fn toggle_hidden(self) -> Result<Self, Error> {
@ -765,9 +783,10 @@ pub fn create() -> Result<App, Error> {
};
if !config.version.eq(VERSION) {
return Err(Error::IncompatibleVersion(
format!("Config file {} is outdated", config_file.to_string_lossy()),
));
return Err(Error::IncompatibleVersion(format!(
"Config file {} is outdated",
config_file.to_string_lossy()
)));
}
let root = Path::new("/");

@ -230,9 +230,10 @@ impl Default for KeyBindings {
help: edit
actions:
- Call:
command: vim
command: bash
args:
- "{{shellescape relativePath}}"
- -c
- FILE="{{shellescape relativePath}}" && "${EDITOR:-vim}" "${FILE:?}"
forward-slash:
help: search
actions:
@ -472,11 +473,11 @@ impl Default for GeneralConfig {
- format: "╰─"
normal_ui:
prefix: " "
suffix: " "
prefix: " "
suffix: ""
focused_ui:
prefix: "▸ ["
prefix: "▸["
suffix: "]"
style:
fg: Blue
@ -486,7 +487,7 @@ impl Default for GeneralConfig {
bits: 0
selected_ui:
prefix: " {"
prefix: " {"
suffix: "}"
style:
fg: LightGreen

@ -87,6 +87,7 @@ fn main() -> Result<(), Error> {
let stdout = AlternateScreen::from(stdout);
let backend = CrosstermBackend::new(stdout);
terminal = Terminal::new(backend)?;
a = a.refresh()?;
terminal.draw(|f| {
ui::draw(&a, &hb, f, &mut table_state, &mut list_state)
})?;

Loading…
Cancel
Save