summaryrefslogtreecommitdiffstats
path: root/src/key_command
diff options
context:
space:
mode:
Diffstat (limited to 'src/key_command')
-rw-r--r--src/key_command/command.rs3
-rw-r--r--src/key_command/constants.rs1
-rw-r--r--src/key_command/impl_appcommand.rs1
-rw-r--r--src/key_command/impl_appexecute.rs1
-rw-r--r--src/key_command/impl_comment.rs1
-rw-r--r--src/key_command/impl_display.rs1
-rw-r--r--src/key_command/impl_from_str.rs11
7 files changed, 19 insertions, 0 deletions
diff --git a/src/key_command/command.rs b/src/key_command/command.rs
index d4710eb..4469ebe 100644
--- a/src/key_command/command.rs
+++ b/src/key_command/command.rs
@@ -102,6 +102,9 @@ pub enum Command {
SearchGlob {
pattern: String,
},
+ SearchRegex {
+ pattern: String,
+ },
SearchString {
pattern: String,
},
diff --git a/src/key_command/constants.rs b/src/key_command/constants.rs
index 4c808db..356997a 100644
--- a/src/key_command/constants.rs
+++ b/src/key_command/constants.rs
@@ -58,6 +58,7 @@ cmd_constants![
(CMD_SEARCH_STRING, "search"),
(CMD_SEARCH_INCREMENTAL, "search_inc"),
(CMD_SEARCH_GLOB, "search_glob"),
+ (CMD_SEARCH_REGEX, "search_regex"),
(CMD_SEARCH_NEXT, "search_next"),
(CMD_SEARCH_PREV, "search_prev"),
(CMD_SELECT_FILES, "select"),
diff --git a/src/key_command/impl_appcommand.rs b/src/key_command/impl_appcommand.rs
index e6595a8..655ff64 100644
--- a/src/key_command/impl_appcommand.rs
+++ b/src/key_command/impl_appcommand.rs
@@ -61,6 +61,7 @@ impl AppCommand for Command {
Self::SearchString { .. } => CMD_SEARCH_STRING,
Self::SearchIncremental { .. } => CMD_SEARCH_INCREMENTAL,
Self::SearchGlob { .. } => CMD_SEARCH_GLOB,
+ Self::SearchRegex { .. } => CMD_SEARCH_REGEX,
Self::SearchNext => CMD_SEARCH_NEXT,
Self::SearchPrev => CMD_SEARCH_PREV,
diff --git a/src/key_command/impl_appexecute.rs b/src/key_command/impl_appexecute.rs
index 1786e96..c4571ea 100644
--- a/src/key_command/impl_appexecute.rs
+++ b/src/key_command/impl_appexecute.rs
@@ -105,6 +105,7 @@ impl AppExecute for Command {
}
Self::TouchFile { file_name } => touch_file::touch_file(context, file_name),
Self::SearchGlob { pattern } => search_glob::search_glob(context, pattern.as_str()),
+ Self::SearchRegex { pattern } => search_regex::search_regex(context, pattern.as_str()),
Self::SearchString { pattern } => {
search_string::search_string(context, pattern.as_str(), false);
Ok(())
diff --git a/src/key_command/impl_comment.rs b/src/key_command/impl_comment.rs
index 85be947..9549621 100644
--- a/src/key_command/impl_comment.rs
+++ b/src/key_command/impl_comment.rs
@@ -91,6 +91,7 @@ impl CommandComment for Command {
Self::SearchString { .. } => "Search",
Self::SearchIncremental { .. } => "Search as you type",
Self::SearchGlob { .. } => "Search with globbing",
+ Self::SearchRegex { .. } => "Search with regex",
Self::SearchNext => "Next search entry",
Self::SearchPrev => "Previous search entry",
diff --git a/src/key_command/impl_display.rs b/src/key_command/impl_display.rs
index b15fd43..d00c88e 100644
--- a/src/key_command/impl_display.rs
+++ b/src/key_command/impl_display.rs
@@ -46,6 +46,7 @@ impl std::fmt::Display for Command {
Self::RenameFile { new_name } => write!(f, "{} {:?}", self.command(), new_name),
Self::SearchGlob { pattern } => write!(f, "{} {}", self.command(), pattern),
+ Self::SearchRegex { pattern } => write!(f, "{} {}", self.command(), pattern),
Self::SearchString { pattern } => write!(f, "{} {}", self.command(), pattern),
Self::SelectFiles { pattern, options } => {
write!(f, "{} {} {}", self.command(), pattern, options)
diff --git a/src/key_command/impl_from_str.rs b/src/key_command/impl_from_str.rs
index 0b76d38..1080198 100644
--- a/src/key_command/impl_from_str.rs
+++ b/src/key_command/impl_from_str.rs
@@ -320,6 +320,16 @@ impl std::str::FromStr for Command {
pattern: arg.to_string(),
}),
}
+ } else if command == CMD_SEARCH_REGEX {
+ match arg {
+ "" => Err(JoshutoError::new(
+ JoshutoErrorKind::InvalidParameters,
+ format!("{}: Expected 1, got 0", command),
+ )),
+ arg => Ok(Self::SearchRegex {
+ pattern: arg.to_string(),
+ }),
+ }
} else if command == CMD_SELECT_FILES {
let mut options = SelectOption::default();
let mut pattern = "";
@@ -356,6 +366,7 @@ impl std::str::FromStr for Command {
match arg.as_str() {
"--type=string" => set_type = SetType::String,
"--type=glob" => set_type = SetType::Glob,
+ "--type=regex" => set_type = SetType::Regex,
"--type=fzf" => set_type = SetType::Fzf,
s => value = s,
}