Skip to content

Commit 237d089

Browse files
committed
Enable true colors if the terminfo RGB capability is set
This allows delta to work properly on Direct Color terminals like xterm-direct and foot-direct. This adds a dependency on the "terminfo" crate in order to read the `RGB` capability. The crate is used by wezterm, among others. Fixes #1931
1 parent ef3e1be commit 237d089

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ syntect = "5.0.0"
5454
# sysinfo: no default features to disable the use of threads
5555
sysinfo = { version = "0.29.0", default-features = false, features = [] }
5656
terminal-colorsaurus = "0.4.1"
57+
terminfo = "0.9.0"
5758
unicode-segmentation = "1.10.1"
5859
unicode-width = "=0.1.12"
5960
xdg = "2.4.1"

src/options/set.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -662,10 +662,15 @@ fn set_true_color(opt: &mut cli::Opt) {
662662
}
663663

664664
fn is_truecolor_terminal(env: &DeltaEnv) -> bool {
665-
env.colorterm
665+
let rgb_cap = terminfo::Database::from_env()
666+
.map(|db| db.raw("RGB").is_some())
667+
.unwrap_or(false);
668+
let colorterm = env
669+
.colorterm
666670
.as_ref()
667671
.map(|colorterm| colorterm == "truecolor" || colorterm == "24bit")
668-
.unwrap_or(false)
672+
.unwrap_or(false);
673+
rgb_cap || colorterm
669674
}
670675

671676
#[cfg(test)]

0 commit comments

Comments
 (0)