Skip to content

Commit

Permalink
follow neovim's truecolor detection
Browse files Browse the repository at this point in the history
  • Loading branch information
kirawi committed Feb 9, 2024
1 parent f8e2d82 commit 85cecf2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions helix-term/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ signal-hook = "0.3"
tokio-stream = "0.1"
futures-util = { version = "0.3", features = ["std", "async-await"], default-features = false }
arc-swap = { version = "1.6.0" }
termini = "1"

# Logging
fern = "0.6"
Expand Down
25 changes: 19 additions & 6 deletions helix-term/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,30 @@ use url::Url;

pub use keymap::macros::*;

#[cfg(not(windows))]
fn true_color() -> bool {
std::env::var("COLORTERM")
.map(|v| matches!(v.as_str(), "truecolor" | "24bit"))
.unwrap_or(false)
}
#[cfg(windows)]
fn true_color() -> bool {
true
}

#[cfg(not(windows))]
fn true_color() -> bool {
if std::env::var("COLORTERM")
.map(|v| matches!(v.as_str(), "truecolor" | "24bit"))
.is_ok()
{
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,
}
}

/// 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 the .git directory, otherwise if
Expand Down

0 comments on commit 85cecf2

Please sign in to comment.