diff --git a/Cargo.lock b/Cargo.lock index 0575e6c..afbf4f2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1362,7 +1362,7 @@ dependencies = [ [[package]] name = "xplr" -version = "0.4.2" +version = "0.4.3" dependencies = [ "anyhow", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 1fd24ae..2d05f81 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "xplr" -version = "0.4.2" # Update config.yml, config.rs and default.nix +version = "0.4.3" # Update config.yml, config.rs and default.nix authors = ["Arijit Basu "] edition = "2018" description = "A hackable, minimal, fast TUI file explorer, stealing ideas from nnn and fzf" diff --git a/RELEASE.md b/RELEASE.md new file mode 100644 index 0000000..2602d4b --- /dev/null +++ b/RELEASE.md @@ -0,0 +1,7 @@ +Process +------- +- [ ] Update `Cargo.toml` version. +- [ ] Update `config.yml` version. +- [ ] Update `Config::is_compatible()` and `Config::upgrade_notification()`. +- [ ] Publish GitHub tag. +- [ ] Update Wiki and docs. diff --git a/default.nix b/default.nix index 1229a6c..fb6c9f3 100644 --- a/default.nix +++ b/default.nix @@ -4,9 +4,9 @@ with import {}; rustPlatform.buildRustPackage rec { name = "xplr"; - version = "0.4.2"; + version = "0.4.3"; src = fetchTarball - ("https://github.com/sayanarijit/xplr/archive/refs/tags/v0.4.2.tar.gz"); + ("https://github.com/sayanarijit/xplr/archive/refs/tags/v0.4.3.tar.gz"); buildInputs = [ cargo ]; checkPhase = ""; cargoSha256 = "0000000000000000000000000000000000000000000000000000"; diff --git a/src/config.rs b/src/config.rs index 1dce127..68e6d70 100644 --- a/src/config.rs +++ b/src/config.rs @@ -559,6 +559,7 @@ impl Config { pub fn is_compatible(&self) -> Result { let result = match self.parsed_version()? { + (0, 4, 3) => true, (0, 4, 2) => true, (0, 4, 1) => true, (0, 4, 0) => true, @@ -570,8 +571,8 @@ impl Config { pub fn upgrade_notification(&self) -> Result> { let result = match self.parsed_version()? { - (0, 4, 2) => None, - (_, _, _) => Some("New version available"), + (0, 4, 3) => None, + (_, _, _) => Some("App version updated"), }; Ok(result) diff --git a/src/config.yml b/src/config.yml index 2fd88e9..3b86771 100644 --- a/src/config.yml +++ b/src/config.yml @@ -1,4 +1,4 @@ -version: v0.4.2 +version: v0.4.3 general: show_hidden: false prompt: diff --git a/src/ui.rs b/src/ui.rs index 6f75bf2..df1356b 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -10,13 +10,9 @@ use tui::layout::Rect; use tui::layout::{Constraint as TuiConstraint, Direction, Layout}; use tui::style::{Color, Style}; use tui::text::{Span, Spans}; -use tui::widgets::{ - Block, Borders, Cell, List, ListItem, ListState, Paragraph, Row, Table, TableState, -}; +use tui::widgets::{Block, Borders, Cell, List, ListItem, Paragraph, Row, Table}; use tui::Frame; -const TOTAL_ROWS: usize = 50; - #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] struct NodeUiMetadata { @@ -87,20 +83,17 @@ impl NodeUiMetadata { fn draw_table(f: &mut Frame, rect: Rect, app: &app::App, hb: &Handlebars) { let config = app.config().to_owned(); + let header_height = config.general.table.header.height.unwrap_or(1); + let height: usize = (rect.height.max(header_height + 2) - (header_height + 2)).into(); let rows = app .directory_buffer() .map(|dir| { - let offset = ( - dir.focus.max(TOTAL_ROWS) - TOTAL_ROWS, - dir.focus.max(TOTAL_ROWS), - ); - dir.nodes .iter() .enumerate() - .skip_while(|(i, _)| *i < offset.0) - .take_while(|(i, _)| *i <= offset.1) + .skip(height * (dir.focus / height)) + .take(height) .map(|(index, node)| { let is_focused = dir.focus == index; @@ -242,20 +235,20 @@ fn draw_table(f: &mut Frame, rect: Rect, app: &app::App, hb: &Han .map(|c| Cell::from(c.format.to_owned().unwrap_or_default())) .collect::>(), ) - .height(config.general.table.header.height.unwrap_or_default()) + .height(header_height) .style(config.general.table.header.style.into()), ); - let mut table_state = TableState::default(); - table_state.select(app.directory_buffer().map(|dir| dir.focus)); - - f.render_stateful_widget(table, rect, &mut table_state); + f.render_widget(table, rect); } fn draw_selection(f: &mut Frame, rect: Rect, app: &app::App, _: &Handlebars) { let selection: Vec = app .selection() .iter() + .rev() + .take((rect.height.max(2) - 2).into()) + .rev() .map(|n| n.absolute_path.clone()) .map(ListItem::new) .collect(); @@ -269,11 +262,7 @@ fn draw_selection(f: &mut Frame, rect: Rect, app: &app::App, _: & .title(format!(" Selection ({}) ", selection_count)), ); - let mut list_state = ListState::default(); - if selection_count > 0 { - list_state.select(Some(selection_count.max(1) - 1)); - } - f.render_stateful_widget(selection_list, rect, &mut list_state); + f.render_widget(selection_list, rect); } fn draw_help_menu(f: &mut Frame, rect: Rect, app: &app::App, _: &Handlebars) {