Skip to content

Commit

Permalink
Sync branch (#677)
Browse files Browse the repository at this point in the history
- Selection indicator in input and logs pane title for people who hide
the selection pane.
  • Loading branch information
sayanarijit authored Nov 21, 2023
2 parents 50d9d1c + dd8bb74 commit 1629398
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/en/src/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ cargo install --locked xplr
[4]: https://github.com/sayanarijit/xplr/watchers
[5]: https://repology.org/badge/vertical-allrepos/xplr.svg
[6]: https://repology.org/project/xplr/versions
[7]: https://archlinux.org/packages/community/x86_64/xplr
[7]: https://archlinux.org/packages/extra/x86_64/xplr
[8]: https://aur.archlinux.org/packages/?O=0&SeB=n&K=xplr&outdated=&SB=n&SO=a&PP=50&do_Search=Go
[9]: https://github.com/shubham-cpp/void-pkg-templates
[10]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/file-managers/xplr/default.nix
Expand Down
21 changes: 18 additions & 3 deletions src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ fn read_only_indicator(app: &app::App) -> &str {
}
}

fn selection_indicator(app: &app::App) -> String {
let count = app.selection.len();
if count == 0 {
String::new()
} else {
format!(" {{{count} sel}}")
}
}

pub fn string_to_text<'a>(string: String) -> Text<'a> {
if *NO_COLOR {
Text::raw(string)
Expand Down Expand Up @@ -991,7 +1000,12 @@ fn draw_input_buffer<B: Backend>(
.scroll((0, scroll))
.block(block(
config,
format!(" Input [{}{}] ", app.mode.name, read_only_indicator(app)),
format!(
" Input [{}{}]{} ",
app.mode.name,
read_only_indicator(app),
selection_indicator(app),
),
));

f.render_widget(input_buf, layout_size);
Expand Down Expand Up @@ -1187,16 +1201,17 @@ fn draw_logs<B: Backend>(
let logs_count = if logs_count == 0 {
String::new()
} else {
format!("({logs_count}) ")
format!(" ({logs_count})")
};

let logs_list = List::new(logs).block(block(
config,
format!(
" Logs {}[{}{}] ",
" Logs{} [{}{}]{} ",
logs_count,
app.mode.name,
read_only_indicator(app),
selection_indicator(app)
),
));

Expand Down

0 comments on commit 1629398

Please sign in to comment.