diff --git a/README.md b/README.md index a23f7d9..45c2a11 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,16 @@ in a terminal to launch Scooter. By default the current directory is used to sea scooter ../foo/bar` ``` -You can then enter some text to search with and text to replace matches with, toggle on or off fixed strings, and enter a regex pattern that filenames must match. A more extensive set of keymappings will be shown at the bottom of the window: these vary slightly depending on the screen you're on. +A set of keymappings will be shown at the bottom of the window: these vary slightly depending on the screen you're on. + +### Search fields + +When on the search screen the following fields are available: + +- **Search text**: Text to search with. Defaults to regex, unless "Fixed strings" is enabled, in which case this reverts to case-sensitive string search. +- **Replace text**: Text to replace the search text with. If searching with regex, this can include capture groups. +- **Fixed strings**: If enabled, search with plain case-sensitive strings. If disabled, search with regex. +- **Path pattern (regex)**: Regex pattern that file paths must match. The relative path of the file is matched against: for instance, if searching in `/foo/`, if the path pattern is set to `bar` then `/foo/bar.txt` and `/foo/bar/file.rs` will be included. In the same example, if the path pattern is set to `foo` then `/foo/bar.txt` will *not* be included, but `/foo/foo.txt` will be. ## Installation @@ -65,4 +74,4 @@ cargo install --path . ## Contributing -Contributions are very welcome! I'd be especially grateful for any contributions to add scooter to popular package managers. If you'd like to add a new feature, please create an issue first so we can discuss the idea, then create a PR with your changes. +Contributions are very welcome! I'd be especially grateful for any contributions to add Scooter to popular package managers. If you'd like to add a new feature, please create an issue first so we can discuss the idea, then create a PR with your changes. diff --git a/src/app.rs b/src/app.rs index c646607..6bcf680 100644 --- a/src/app.rs +++ b/src/app.rs @@ -152,7 +152,7 @@ pub enum FieldName { Search, Replace, FixedStrings, - FilenamePattern, + PathPattern, } pub struct SearchField { @@ -205,12 +205,7 @@ impl SearchFields { Checkbox, CheckboxField ); - define_field_accessor!( - filename_pattern, - FieldName::FilenamePattern, - Text, - TextField - ); + define_field_accessor!(path_pattern, FieldName::PathPattern, Text, TextField); pub fn focus_next(&mut self) { self.highlighted = (self.highlighted + 1) % self.fields.len(); @@ -263,7 +258,7 @@ impl SearchFields { field: Rc::new(RefCell::new(Field::checkbox(fixed_strings))), }, SearchField { - name: FieldName::FilenamePattern, + name: FieldName::PathPattern, field: Rc::new(RefCell::new(Field::text(filname_pattern.into()))), }, ], @@ -462,7 +457,7 @@ impl App { let mut results = vec![]; - let s = self.search_fields.filename_pattern().text(); + let s = self.search_fields.path_pattern().text(); let patt = if s.is_empty() { None } else { @@ -470,7 +465,7 @@ impl App { Err(e) => { info!("Error when parsing filname pattern regex {}", e); self.search_fields - .filename_pattern() + .path_pattern() .set_error("Couldn't parse regex".to_owned()); return Ok(false); } diff --git a/src/ui.rs b/src/ui.rs index 2b11222..f6290c7 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -23,7 +23,7 @@ impl FieldName { FieldName::Search => "Search text", FieldName::Replace => "Replace text", FieldName::FixedStrings => "Fixed strings", - FieldName::FilenamePattern => "Filename pattern (regex)", + FieldName::PathPattern => "Path pattern (regex)", } } } diff --git a/tests/app.rs b/tests/app.rs index d3575ad..87c4bae 100644 --- a/tests/app.rs +++ b/tests/app.rs @@ -113,7 +113,7 @@ async fn test_back_from_results() { assert_eq!(app.search_fields.search().text, "foo"); assert_eq!(app.search_fields.replace().text, "bar"); assert!(app.search_fields.fixed_strings().checked); - assert_eq!(app.search_fields.filename_pattern().text, "pattern"); + assert_eq!(app.search_fields.path_pattern().text, "pattern"); assert_eq!(app.current_screen, CurrentScreen::Searching); assert_eq!(app.results, Results::Loading); } diff --git a/tests/fields.rs b/tests/fields.rs index 78b8d4d..e12858e 100644 --- a/tests/fields.rs +++ b/tests/fields.rs @@ -87,7 +87,7 @@ fn test_search_fields() { field: Rc::new(RefCell::new(Field::checkbox(false))), }, SearchField { - name: FieldName::FilenamePattern, + name: FieldName::PathPattern, field: Rc::new(RefCell::new(Field::text(""))), }, ],