aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
authorKirawi2024-02-11 17:38:09 +0000
committerGitHub2024-02-11 17:38:09 +0000
commit786b5c533e32cfe88dbf8742fdbc18829fb46334 (patch)
tree3f59fdd093729bf868cd96623867a6392686cd83 /helix-term/src
parent581a1ebf5d327c1128fe6c283578e8f36a4b5fb5 (diff)
follow neovim's truecolor detection (#9577)
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/lib.rs25
1 files changed, 19 insertions, 6 deletions
diff --git a/helix-term/src/lib.rs b/helix-term/src/lib.rs
index b1413ed0..cdde86ec 100644
--- a/helix-term/src/lib.rs
+++ b/helix-term/src/lib.rs
@@ -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 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,
+ }
+}
+
/// 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