-
-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main'
- Loading branch information
Showing
18 changed files
with
273 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "broot" | ||
version = "1.32.0" | ||
version = "1.32.1-dev" | ||
authors = ["dystroy <[email protected]>"] | ||
repository = "https://github.com/Canop/broot" | ||
homepage = "https://dystroy.org/broot" | ||
|
@@ -58,7 +58,7 @@ splitty = "1.0" | |
strict = "0.1.4" | ||
syntect = { package = "syntect-no-panic", version = "4.6.1" } # see issue #485 | ||
tempfile = "3.2" | ||
termimad = "0.26.1" | ||
termimad = "0.27.0" | ||
terminal-clipboard = { version = "0.4.1", optional = true } | ||
terminal-light = "1.1.1" | ||
toml = "0.8" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
use { | ||
crate::{ | ||
errors::ConfError, | ||
path::*, | ||
}, | ||
directories::UserDirs, | ||
lazy_regex::*, | ||
serde::Deserialize, | ||
std::collections::HashMap, | ||
}; | ||
|
||
|
||
type SpecialPathsConf = HashMap<GlobConf, SpecialHandlingConf>; | ||
|
||
#[derive(Clone, Debug, Deserialize, Hash, PartialEq, Eq)] | ||
#[serde(transparent)] | ||
pub struct GlobConf { | ||
pub pattern: String, | ||
} | ||
|
||
#[derive(Clone, Copy, Debug, Deserialize)] | ||
#[serde(untagged)] | ||
pub enum SpecialHandlingConf { | ||
Shortcut(SpecialHandlingShortcut), | ||
Detailed(SpecialHandling), | ||
} | ||
|
||
#[derive(Clone, Debug, Copy, Deserialize, PartialEq, Eq)] | ||
#[serde(rename_all = "snake_case")] | ||
pub enum SpecialHandlingShortcut { | ||
None, | ||
Enter, | ||
#[serde(alias = "no-enter")] | ||
NoEnter, | ||
Hide, | ||
#[serde(alias = "no-hide")] | ||
NoHide, | ||
} | ||
|
||
impl From<SpecialHandlingShortcut> for SpecialHandling { | ||
fn from(shortcut: SpecialHandlingShortcut) -> Self { | ||
use Directive::*; | ||
match shortcut { | ||
SpecialHandlingShortcut::None => SpecialHandling { | ||
show: Default, list: Default, sum: Default, | ||
}, | ||
SpecialHandlingShortcut::Enter => SpecialHandling { | ||
show: Always, list: Always, sum: Always, | ||
}, | ||
SpecialHandlingShortcut::NoEnter => SpecialHandling { | ||
show: Default, list: Never, sum: Never, | ||
}, | ||
SpecialHandlingShortcut::Hide => SpecialHandling { | ||
show: Never, list: Default, sum: Never, | ||
}, | ||
SpecialHandlingShortcut::NoHide => SpecialHandling { | ||
show: Always, list: Default, sum: Default, | ||
}, | ||
} | ||
} | ||
} | ||
|
||
impl From<SpecialHandlingConf> for SpecialHandling { | ||
fn from(conf: SpecialHandlingConf) -> Self { | ||
match conf { | ||
SpecialHandlingConf::Shortcut(shortcut) => shortcut.into(), | ||
SpecialHandlingConf::Detailed(handling) => handling, | ||
} | ||
} | ||
} | ||
|
||
impl TryFrom<&SpecialPathsConf> for SpecialPaths { | ||
type Error = ConfError; | ||
fn try_from(map: &SpecialPathsConf) -> Result<Self, ConfError> { | ||
let mut entries = Vec::new(); | ||
for (k, v) in map { | ||
entries.push(SpecialPath::new(k.to_glob()?, (*v).into())); | ||
} | ||
Ok(Self { entries }) | ||
} | ||
} | ||
|
||
impl GlobConf { | ||
pub fn to_glob(&self) -> Result<glob::Pattern, ConfError> { | ||
let s = regex_replace!(r"^~(/|$)", &self.pattern, |_, sep| { | ||
match UserDirs::new() { | ||
Some(dirs) => format!("{}{}", dirs.home_dir().to_string_lossy(), sep), | ||
None => "~/".to_string(), | ||
} | ||
}); | ||
let glob = if s.starts_with('/') || s.starts_with('~') { | ||
glob::Pattern::new(&s) | ||
} else { | ||
let pattern = format!("**/{}", &s); | ||
glob::Pattern::new(&pattern) | ||
}; | ||
glob.map_err(|_| ConfError::InvalidGlobPattern { | ||
pattern: self.pattern.to_string(), | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.