summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2022-02-15 17:14:06 +0100
committerCanop <cano.petrole@gmail.com>2022-02-15 17:14:06 +0100
commitaf3a1f3c3290f6b88c748bde656ef99ada1f3c7b (patch)
tree4a8ce6c617602b80c8de9d10b220694ce221275d
parent8ca1c3d09aaab7883f8ce9394fe7c43d96308903 (diff)
:previous_dir and :next_dir internals
Fix #502
-rw-r--r--CHANGELOG.md4
-rw-r--r--Cargo.lock15
-rw-r--r--Cargo.toml3
-rw-r--r--src/browser/browser_state.rs24
-rw-r--r--src/help/help_content.rs7
-rw-r--r--src/tree/tree.rs20
-rw-r--r--src/verb/builtin.rs6
-rw-r--r--src/verb/internal.rs4
-rw-r--r--website/docs/conf_verbs.md28
-rw-r--r--website/docs/img/logo.svg72
10 files changed, 73 insertions, 110 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2498c9e..88e2b77 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+### next
+- keep same line visible in preview when resizing
+- `:previous_dir` and `:next_dir` internals - Fix #502
+
### v1.9.2 - 2022-01-23
<a name="v1.9.2"></a>
- instead of crashing on syntect panic in code preview, fall back to unstyled text - Fix #485
diff --git a/Cargo.lock b/Cargo.lock
index 08297fe..acf9d65 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -324,21 +324,22 @@ dependencies = [
[[package]]
name = "crokey"
-version = "0.2.1"
+version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "023ac011343d16baf65a32e91b04c462a88065f1586fea673f92a3dab0b5c1db"
+checksum = "f4219688ddf851f784c11c8be2da562bcc911e20919119cb03f10fda27d231ef"
dependencies = [
"crokey-proc_macros",
"crossterm 0.22.1",
+ "once_cell",
+ "serde",
]
[[package]]
name = "crokey-proc_macros"
-version = "0.2.0"
+version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "22d6d508fa1a069ea01ccd610651c9652cfced32c0369a22d6a21b2a9633334a"
+checksum = "4d4832efaa2189caf3fbcf30a96e1f614503140712f7da8da4032ac1c841ac78"
dependencies = [
- "crossterm 0.22.1",
"proc-macro2",
"quote",
"syn",
@@ -1104,9 +1105,9 @@ dependencies = [
[[package]]
name = "once_cell"
-version = "1.8.0"
+version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56"
+checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5"
[[package]]
name = "onig"
diff --git a/Cargo.toml b/Cargo.toml
index 4e7e4de..d395fd3 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -28,7 +28,7 @@ char_reader = "0.1"
clap = { version="2.33", default-features=false, features=["suggestions", "color"] }
cli-log = "2.0"
chrono = "0.4"
-crokey = "0.2"
+crokey = "0.4.0"
crossbeam = "0.8"
crossterm = "0.22.1"
custom_error = "1.6"
@@ -100,6 +100,7 @@ harness = false
[patch.crates-io]
# bet = { path = "../bet" }
+# crokey = { path = "../crokey" }
# cli-log = { path = "../cli-log" }
# crossterm = { path = "../crossterm-rs/crossterm" }
# deser-hjson = { path = "../deser-hjson" }
diff --git a/src/browser/browser_state.rs b/src/browser/browser_state.rs
index 956e91e..94060b5 100644
--- a/src/browser/browser_state.rs
+++ b/src/browser/browser_state.rs
@@ -355,12 +355,32 @@ impl PanelState for BrowserState {
self.displayed_tree_mut().move_selection(-count, page_height, false);
CmdResult::Keep
}
+ Internal::previous_dir => {
+ self.displayed_tree_mut().try_select_previous_filtered(
+ |line| line.is_dir(),
+ page_height,
+ );
+ CmdResult::Keep
+ }
+ Internal::next_dir => {
+ self.displayed_tree_mut().try_select_next_filtered(
+ |line| line.is_dir(),
+ page_height,
+ );
+ CmdResult::Keep
+ }
Internal::previous_match => {
- self.displayed_tree_mut().try_select_previous_match(page_height);
+ self.displayed_tree_mut().try_select_previous_filtered(
+ |line| line.direct_match,
+ page_height,
+ );
CmdResult::Keep
}
Internal::next_match => {
- self.displayed_tree_mut().try_select_next_match(page_height);
+ self.displayed_tree_mut().try_select_next_filtered(
+ |line| line.direct_match,
+ page_height,
+ );
CmdResult::Keep
}
Internal::previous_same_depth => {
diff --git a/src/help/help_content.rs b/src/help/help_content.rs
index 47b93df..4ccac3a 100644
--- a/src/help/help_content.rs
+++ b/src/help/help_content.rs
@@ -69,13 +69,6 @@ ${features
* **${feature-name}:** ${feature-description}
}
-## Sponsorship
-
-**broot** is totally free for all uses.
-If you *want* to help me find time to improve it and build other free programs, consider sponsoring me.
-See https://dystroy.org/broot/community/#sponsorship
-
-
"#;
/// build a markdown expander which will need to be
diff --git a/src/tree/tree.rs b/src/tree/tree.rs
index 822f4e5..0ff91fe 100644
--- a/src/tree/tree.rs
+++ b/src/tree/tree.rs
@@ -367,14 +367,20 @@ impl Tree {
}
false
}
- pub fn try_select_previous_match(&mut self, page_height: usize) -> bool {
+ pub fn try_select_previous_filtered<F>(
+ &mut self,
+ filter: F,
+ page_height: usize,
+ ) -> bool where
+ F: Fn(&TreeLine) -> bool,
+ {
for di in (0..self.lines.len()).rev() {
let idx = (self.selection + di) % self.lines.len();
let line = &self.lines[idx];
if !line.is_selectable() {
continue;
}
- if !line.direct_match {
+ if !filter(line) {
continue;
}
if line.score > 0 {
@@ -385,14 +391,20 @@ impl Tree {
}
false
}
- pub fn try_select_next_match(&mut self, page_height: usize) -> bool {
+ pub fn try_select_next_filtered<F>(
+ &mut self,
+ filter: F,
+ page_height: usize,
+ ) -> bool where
+ F: Fn(&TreeLine) -> bool,
+ {
for di in 0..self.lines.len() {
let idx = (self.selection + di + 1) % self.lines.len();
let line = &self.lines[idx];
if !line.is_selectable() {
continue;
}
- if !line.direct_match {
+ if !filter(line) {
continue;
}
if line.score > 0 {
diff --git a/src/verb/builtin.rs b/src/verb/builtin.rs
index 205b722..8bf70d6 100644
--- a/src/verb/builtin.rs
+++ b/src/verb/builtin.rs
@@ -121,7 +121,7 @@ pub fn builtin_verbs() -> Vec<Verb> {
// but ctrl-f is useful for focusing on a file's parent
// (and keep the filter)
internal(focus)
- .with_key(key!(l))
+ .with_key(key!(L)) // hum... why this one ?
.with_key(key!(ctrl-f)),
internal(help)
.with_key(key!(F1))
@@ -153,7 +153,7 @@ pub fn builtin_verbs() -> Vec<Verb> {
StayInBroot,
)
.with_auto_exec(false)
- .with_key(key!(F2)),
+ .with_key(key!(f2)),
internal_bang(start_end_panel)
.with_key(key!(ctrl-p)),
// the char keys for mode_input are handled differently as they're not
@@ -194,7 +194,7 @@ pub fn builtin_verbs() -> Vec<Verb> {
.with_key(key!(ctrl-c))
.with_key(key!(ctrl-q))
.with_shortcut("q"),
- internal(refresh).with_key(key!(F5)),
+ internal(refresh).with_key(key!(f5)),
internal(root_up)
.with_key(key!(ctrl-up)),
internal(root_down)
diff --git a/src/verb/internal.rs b/src/verb/internal.rs
index 136e718..1bc9dd8 100644
--- a/src/verb/internal.rs
+++ b/src/verb/internal.rs
@@ -84,6 +84,9 @@ Internals! {
open_leave: "open file or directory according to OS (quit broot)" true,
mode_input: "enter the input mode" false,
mode_command: "enter the command mode" false,
+ previous_dir: "select the previous directory" false,
+ next_dir: "select the next directory" false,
+ previous_match: "select the previous match" false,
next_match: "select the next match" false,
next_same_depth: "select the next file at the same depth" false,
no_sort: "don't sort" false,
@@ -92,7 +95,6 @@ Internals! {
parent: "move to the parent directory" false,
panel_left: "focus panel on left" false,
panel_right: "focus panel on right" false,
- previous_match: "select the previous match" false,
previous_same_depth: "select the previous file at the same depth" false,
open_preview: "open the preview panel" true,
close_preview: "close the preview panel" false,
diff --git a/website/docs/conf_verbs.md b/website/docs/conf_verbs.md
index 2da2ebd..8612e8f 100644
--- a/website/docs/conf_verbs.md
+++ b/website/docs/conf_verbs.md
@@ -317,25 +317,30 @@ invocation | default key | default shortcut | behavior / details
:back | <kbd>Esc</kbd> | - | back to previous app state (see Usage page) |
:cd | <kbd>alt</kbd><kbd>enter</kbd> | - | leave broot and cd to the selected directory (needs the br shell function)
:chmod {args} | - | - | execute a chmod
+:clear_stage | - | cls | empty the staging area
:close_preview | - | - | close the preview panel
+:close_staging_area | - | csa | close the staging area panel
:copy_path | <kbd>alt</kbd><kbd>c</kbd> | - | copy path
:cp {newpath} | - | - | copy the file or directory to the provided name
-:help | <kbd>F1</kbd> | - | open the help page. Help page can also be open with <kbd>?</kbd>
:focus | <kbd>enter</kbd> | - | set the selected directory the root of the displayed tree |
+:help | <kbd>F1</kbd> | - | open the help page. Help page can also be open with <kbd>?</kbd>
:line_down | <kbd>↓</kbd> | - | scroll one line down or select the next line (can be used with an argument eg `:line_down 4`)
-:line_up | <kbd>↑</kbd> | - | scroll one line up or select the previous line
:line_down_no_cycle | - | - | same as line_down, but doesn't cycle
+:line_up | <kbd>↑</kbd> | - | scroll one line up or select the previous line
:line_up_no_cycle | - | - | same as line_down, but doesn't cycle
:mkdir {subpath} | - | md | create a directory
:mv {newpath} | - | - | move the file or directory to the provided path
+:next_dir | - | - | select the next directory
:next_match | <kbd>tab</kbd> | - | select the next matching file
-:open_stay | <kbd>enter</kbd> | - | open the selected file in the default OS opener, or focus the directory
-:open_preview | - | - | open the preview panel
:open_leave | <kbd>alt</kbd><kbd>enter</kbd> | - | open the selected file in the default OS opener and leave broot
+:open_preview | - | - | open the preview panel
+:open_staging_area | - | osa | open the staging area
+:open_stay | <kbd>enter</kbd> | - | open the selected file in the default OS opener, or focus the directory
:open_stay_filter | - | - | focus the directory but keeping the current filtering pattern
:page_down | <kbd>⇟</kbd> | - | scroll one page down
:page_up | <kbd>⇞</kbd> | - | scroll one page up
:parent | - | - | focus the parent directory
+:previous_dir | - | - | select the previous directory
:print_path | - | pp | print path and leave broot
:print_relative_path | - | pp | print relative path and leave broot
:print_tree | - | pt | print tree and leave broot
@@ -347,27 +352,24 @@ invocation | default key | default shortcut | behavior / details
:sort_by_count | - | - | sort by count (only one level of the tree is displayed)
:sort_by_date | - | - | sort by date
:sort_by_size | - | - | sort by size
+:stage | <kbd>+</kbd> | - | add selection to staging area
:toggle_counts | - | - | toggle display of total counts of files per directory
:toggle_dates | - | - | toggle display of last modified dates (looking for the most recently changed file, even deep)
:toggle_device_id | - | - | toggle display of device id (unix only)
:toggle_files | - | - | toggle showing files (or just folders)
-:toggle_git_ignore | - | - | toggle git ignore handling (auto, no or yes)
:toggle_git_file_info | - | - | toggle display of git file information
+:toggle_git_ignore | - | - | toggle git ignore handling (auto, no or yes)
:toggle_git_status | - | - | toggle showing only the file which would show up on `git status`
:toggle_hidden | - | - | toggle display of hidden files (the ones whose name starts with a dot on linux)
:toggle_perm | - | - | toggle display of permissions (not available on Windows)
:toggle_preview | - | - | toggle display of the preview panel
-:toggle_sizes | - | - | toggle the size mode
-:toggle_trim_root | - | - | toggle trimming of top level files in tree display
:toggle_second_tree | - | - | toggle displaying a second tree
-:up_tree | - | - | focus the parent of the current root
-:stage | <kbd>+</kbd> | - | add selection to staging area
-:unstage | <kbd>-</kbd> | - | remove selection from staging area
+:toggle_sizes | - | - | toggle the size mode
:toggle_stage | <kbd>ctrl</kbd><kbd>g</kbd> | - | add or remove selection to staging area
-:clear_stage | - | cls | empty the staging area
-:open_staging_area | - | osa | open the staging area
-:close_staging_area | - | csa | close the staging area panel
:toggle_staging_area | - | tsa | open/close the staging area panel
+:toggle_trim_root | - | - | toggle trimming of top level files in tree display
+:unstage | <kbd>-</kbd> | - | remove selection from staging area
+:up_tree | - | - | focus the parent of the current root
Note that
diff --git a/website/docs/img/logo.svg b/website/docs/img/logo.svg
deleted file mode 100644
index 6a7a9f4..0000000
--- a/website/docs/img/logo.svg
+++ /dev/null
@@ -1,72 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="17.316895mm"
- height="13.954481mm"
- viewBox="0 0 17.316895 13.954481"
- version="1.1"
- id="svg8"
- inkscape:version="0.92.3 (2405546, 2018-03-11)"
- sodipodi:docname="logo.svg">
- <defs
- id="defs2" />
- <sodipodi:namedview
- id="base"
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1.0"
- inkscape:pageopacity="0.0"
- inkscape:pageshadow="2"
- inkscape:zoom="1"
- inkscape:cx="271.16778"
- inkscape:cy="-136.03966"
- inkscape:document-units="mm"
- inkscape:current-layer="layer1"
- showgrid="false"
- inkscape:window-width="1875"
- inkscape:window-height="1056"
- inkscape:window-x="45"
- inkscape:window-y="24"
- inkscape:window-maximized="1"
- fit-margin-left="1"
- fit-margin-right="1"
- fit-margin-top="1"
- fit-margin-bottom="1" />
- <metadata
- id="metadata5">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <g
- inkscape:label="Layer 1"
- inkscape:groupmode="layer"
- id="layer1"
- transform="translate(-7.2089696,-100.69341)">
- <text
- xml:space="preserve"
- style="font-style:normal;font-weight:normal;font-size:5.953125px;line-height:125%;font-family:Sans;letter-spacing:0px;word-spacing:0px;fill:#0c0000;fill-opacity:1;stroke:none;stroke-width:0.26499999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- x="6.8791628"
- y="113.37917"
- id="text4520"><tspan
- sodipodi:role="line"
- id="tspan4518"
- x="6.8791628"
- y="113.37917"
- style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:14.11111069px;font-family:'DejaVu Sans Mono';-inkscape-font-specification:'DejaVu Sans Mono';fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.26499999;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1">b√</tspan></text>
- </g>
-</svg>