diff options
author | Canop <cano.petrole@gmail.com> | 2022-09-22 23:32:35 +0200 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2022-09-22 23:34:56 +0200 |
commit | 0f5193f31eeeb9f6e721806fca8f3acde6b52da9 (patch) | |
tree | 3c8e433ba74864c220c7fa60fd2abe1f47114005 | |
parent | b92b296030083e801cb54de56cfeb345ea1383ca (diff) |
allow showing only file name on path searches
Using
show_matching_characters_on_path_searches: false
Fix #490
-rw-r--r-- | CHANGELOG.md | 3 | ||||
-rw-r--r-- | Cargo.lock | 2 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/conf/conf.rs | 3 | ||||
-rw-r--r-- | src/display/displayable_tree.rs | 38 | ||||
-rw-r--r-- | src/tree/tree_options.rs | 10 | ||||
-rw-r--r-- | website/docs/conf_file.md | 18 | ||||
-rw-r--r-- | website/docs/img/subpath-match-not-shown.png | bin | 0 -> 28051 bytes | |||
-rw-r--r-- | website/docs/img/subpath-match-shown.png | bin | 0 -> 39960 bytes |
9 files changed, 55 insertions, 21 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ca38ef..f836d3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +### next +- with `show_matching_characters_on_path_searches: false`, it's possible to show only file names even when searching paths - Fix #490 + ### v1.14.3 - 2022-09-12 <a name="v1.14.3"></a> - fix crash with token searches - Fix #504 - Thanks @FedericoStra @@ -140,7 +140,7 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "broot" -version = "1.14.3" +version = "1.14.4-dev" dependencies = [ "ahash 0.7.6", "ansi_colours", @@ -1,6 +1,6 @@ [package] name = "broot" -version = "1.14.3" +version = "1.14.4-dev" authors = ["dystroy <denys.seguret@gmail.com>"] repository = "https://github.com/Canop/broot" homepage = "https://dystroy.org/broot" diff --git a/src/conf/conf.rs b/src/conf/conf.rs index 2dd0891..3be2b71 100644 --- a/src/conf/conf.rs +++ b/src/conf/conf.rs @@ -102,6 +102,8 @@ pub struct Conf { #[serde(default)] pub imports: Vec<Import>, + #[serde(alias="show-matching-characters-on-path-searches")] + pub show_matching_characters_on_path_searches: Option<bool>, } impl Conf { @@ -179,6 +181,7 @@ impl Conf { overwrite!(self, quit_on_last_cancel, conf); overwrite!(self, file_sum_threads_count, conf); overwrite!(self, max_staged_count, conf); + overwrite!(self, show_matching_characters_on_path_searches, conf); self.verbs.append(&mut conf.verbs); // the following maps are "additive": we can add entries from several // config files and they still make sense diff --git a/src/display/displayable_tree.rs b/src/display/displayable_tree.rs index 0b310f2..5e8696e 100644 --- a/src/display/displayable_tree.rs +++ b/src/display/displayable_tree.rs @@ -305,23 +305,27 @@ impl<'a, 's, 't> DisplayableTree<'a, 's, 't> { cw.queue_char(style, ' ')?; cw.queue_char(style, ' ')?; } - if pattern_object.subpath && line.unlisted == 0 { - let name_match = self.tree.options.pattern.pattern - .search_string(&line.subpath); - let mut path_ms = MatchedString::new( - name_match, - &line.subpath, - style, - char_match_style, - ); - let name_ms = path_ms.split_on_last('/'); - cond_bg!(parent_style, self, selected, self.skin.parent); - if name_ms.is_some() { - path_ms.base_style = parent_style; - } - path_ms.queue_on(cw)?; - if let Some(name_ms) = name_ms { - name_ms.queue_on(cw)?; + if pattern_object.subpath { + if self.tree.options.show_matching_characters_on_path_searches && line.unlisted == 0 { + let name_match = self.tree.options.pattern.pattern + .search_string(&line.subpath); + let mut path_ms = MatchedString::new( + name_match, + &line.subpath, + style, + char_match_style, + ); + let name_ms = path_ms.split_on_last('/'); + cond_bg!(parent_style, self, selected, self.skin.parent); + if name_ms.is_some() { + path_ms.base_style = parent_style; + } + path_ms.queue_on(cw)?; + if let Some(name_ms) = name_ms { + name_ms.queue_on(cw)?; + } + } else { + cw.queue_str(style, &line.name)?; } } else { let name_match = self.tree.options.pattern.pattern diff --git a/src/tree/tree_options.rs b/src/tree/tree_options.rs index 7548e50..5cd8584 100644 --- a/src/tree/tree_options.rs +++ b/src/tree/tree_options.rs @@ -31,6 +31,7 @@ pub struct TreeOptions { pub date_time_format: &'static str, pub sort: Sort, pub cols_order: Cols, // order of columns + pub show_matching_characters_on_path_searches: bool, } impl TreeOptions { @@ -54,6 +55,7 @@ impl TreeOptions { date_time_format: self.date_time_format, sort: self.sort, cols_order: self.cols_order, + show_matching_characters_on_path_searches: self.show_matching_characters_on_path_searches, } } /// counts must be computed, either for sorting or just for display @@ -86,12 +88,15 @@ impl TreeOptions { })?; self.apply_launch_args(&conf_matches); } - if let Some(b) = &config.show_selection_mark { - self.show_selection_mark = *b; + if let Some(b) = config.show_selection_mark { + self.show_selection_mark = b; } if let Some(format) = &config.date_time_format { self.set_date_time_format(format.clone()); } + if let Some(b) = config.show_matching_characters_on_path_searches { + self.show_matching_characters_on_path_searches = b; + } self.cols_order = config .cols_order .as_ref() @@ -195,6 +200,7 @@ impl Default for TreeOptions { date_time_format: "%Y/%m/%d %R", sort: Sort::None, cols_order: DEFAULT_COLS, + show_matching_characters_on_path_searches: true, } } } diff --git a/website/docs/conf_file.md b/website/docs/conf_file.md index 5cab485..1f9d069 100644 --- a/website/docs/conf_file.md +++ b/website/docs/conf_file.md @@ -282,3 +282,21 @@ quit_on_last_cancel: true ```TOML quit_on_last_cancel = true ``` +## Only show file name even when the pattern is on paths + +When your search pattern is applied to a path, the path is shown on each line so that you see why the line matches: + +![shown](img/subpath-match-shown.png) + +If you don't really need to see matching characters, you may get a cleaner display with just file names with this option: + +```Hjson +show_matching_characters_on_path_searches: false +``` +```TOML +show_matching_characters_on_path_searches = false +``` + +which gives this: + +![not shown](img/subpath-match-not-shown.png) diff --git a/website/docs/img/subpath-match-not-shown.png b/website/docs/img/subpath-match-not-shown.png Binary files differnew file mode 100644 index 0000000..19930dd --- /dev/null +++ b/website/docs/img/subpath-match-not-shown.png diff --git a/website/docs/img/subpath-match-shown.png b/website/docs/img/subpath-match-shown.png Binary files differnew file mode 100644 index 0000000..231c972 --- /dev/null +++ b/website/docs/img/subpath-match-shown.png |