summaryrefslogtreecommitdiffstats
path: root/src/app/selection.rs
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2022-07-10 22:28:15 +0200
committerCanop <cano.petrole@gmail.com>2022-07-10 22:29:23 +0200
commit94ef5f6ed4376df0d1b96b2ba38e8f5b2ca70ed9 (patch)
treed7056f2b4eb07aa4b2d99c0a832b560da90e766e /src/app/selection.rs
parentd4751c863011bf2583b07942363df3f70db37d97 (diff)
allow :focus based verbs to take a pattern
This allows verb definitions such as the following ones: ```Hjson { invocation: "gos" execution: ":focus" } { invocation: "go {path}" execution: ":focus {path}" } { invocation: "goroot" execution: ":focus /" } { invocation: "gotar {path}" execution: ":focus {path}/target" } ``` Fix #389
Diffstat (limited to 'src/app/selection.rs')
-rw-r--r--src/app/selection.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/app/selection.rs b/src/app/selection.rs
index e3a84f8..2fb56b7 100644
--- a/src/app/selection.rs
+++ b/src/app/selection.rs
@@ -96,6 +96,16 @@ impl Selection<'_> {
}
impl<'a> SelInfo<'a> {
+ pub fn from_path(path: &'a Path) -> Self {
+ Self::One(
+ Selection {
+ stype: SelectionType::from(path),
+ line: 0,
+ path,
+ is_exe: false, // OK, I don't know
+ }
+ )
+ }
pub fn count_paths(&self) -> usize {
match self {
SelInfo::None => 0,
@@ -124,6 +134,9 @@ impl<'a> SelInfo<'a> {
_ => None,
}
}
+ pub fn one_path(self) -> Option<&'a Path> {
+ self.one_sel().map(|sel| sel.path)
+ }
pub fn extension(&self) -> Option<&str> {
match self {
SelInfo::None => None,