Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable true colors if the terminfo RGB capability is set #1932

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ syntect = "5.0.0"
# sysinfo: no default features to disable the use of threads
sysinfo = { version = "0.29.0", default-features = false, features = [] }
terminal-colorsaurus = "0.4.1"
terminfo = "0.9.0"
unicode-segmentation = "1.10.1"
unicode-width = "=0.1.12"
xdg = "2.4.1"
Expand Down
9 changes: 7 additions & 2 deletions src/options/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -662,10 +662,15 @@ fn set_true_color(opt: &mut cli::Opt) {
}

fn is_truecolor_terminal(env: &DeltaEnv) -> bool {
env.colorterm
let rgb_cap = terminfo::Database::from_env()
.map(|db| db.raw("RGB").is_some())
.unwrap_or(false);
let colorterm = env
.colorterm
.as_ref()
.map(|colorterm| colorterm == "truecolor" || colorterm == "24bit")
.unwrap_or(false)
.unwrap_or(false);
rgb_cap || colorterm
}

#[cfg(test)]
Expand Down