Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-term/src/lib.rs')
| -rw-r--r-- | helix-term/src/lib.rs | 58 |
1 files changed, 9 insertions, 49 deletions
diff --git a/helix-term/src/lib.rs b/helix-term/src/lib.rs index 75b67479..a94c5e49 100644 --- a/helix-term/src/lib.rs +++ b/helix-term/src/lib.rs @@ -6,53 +6,31 @@ pub mod args; pub mod commands; pub mod compositor; pub mod config; -pub mod events; pub mod health; pub mod job; pub mod keymap; pub mod ui; - use std::path::Path; -use futures_util::Future; -mod handlers; - use ignore::DirEntry; -use url::Url; -#[cfg(windows)] +#[cfg(not(windows))] fn true_color() -> bool { - true + std::env::var("COLORTERM") + .map(|v| matches!(v.as_str(), "truecolor" | "24bit")) + .unwrap_or(false) } - -#[cfg(not(windows))] +#[cfg(windows)] fn true_color() -> bool { - if matches!( - std::env::var("COLORTERM").map(|v| matches!(v.as_str(), "truecolor" | "24bit")), - Ok(true) - ) { - return true; - } - - match termini::TermInfo::from_env() { - Ok(t) => { - t.extended_cap("RGB").is_some() - || t.extended_cap("Tc").is_some() - || (t.extended_cap("setrgbf").is_some() && t.extended_cap("setrgbb").is_some()) - } - Err(_) => false, - } + true } /// Function used for filtering dir entries in the various file pickers. fn filter_picker_entry(entry: &DirEntry, root: &Path, dedup_symlinks: bool) -> bool { - // We always want to ignore popular VCS directories, otherwise if + // We always want to ignore the .git directory, otherwise if // `ignore` is turned off, we end up with a lot of noise // in our picker. - if matches!( - entry.file_name().to_str(), - Some(".git" | ".pijul" | ".jj" | ".hg" | ".svn") - ) { + if entry.file_name() == ".git" { return false; } @@ -63,26 +41,8 @@ fn filter_picker_entry(entry: &DirEntry, root: &Path, dedup_symlinks: bool) -> b .path() .canonicalize() .ok() - .is_some_and(|path| !path.starts_with(root)); + .map_or(false, |path| !path.starts_with(root)); } true } - -/// Opens URL in external program. -fn open_external_url_callback( - url: Url, -) -> impl Future<Output = Result<job::Callback, anyhow::Error>> + Send + 'static { - let commands = open::commands(url.as_str()); - async { - for cmd in commands { - let mut command: tokio::process::Command = cmd.into(); - if command.output().await.is_ok() { - return Ok(job::Callback::Editor(Box::new(|_| {}))); - } - } - Ok(job::Callback::Editor(Box::new(move |editor| { - editor.set_error("Opening URL in external program failed") - }))) - } -} |