mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-06 08:51:14 -03:00
Check max_colors with rest of checks in input.cpp.
... with a terminal set up.
This commit is contained in:
@@ -299,9 +299,11 @@ static int interrupt_handler() {
|
||||
}
|
||||
|
||||
void update_fish_color_support(void) {
|
||||
// Infer term256 support. If fish_term256 is set, we respect it; otherwise try to detect it from
|
||||
// the TERM variable.
|
||||
// Detect or infer term256 support. If fish_term256 is set, we respect it;
|
||||
// otherwise try to detect terminfo else infer it from the TERM variable.
|
||||
env_var_t fish_term256 = env_get_string(L"fish_term256");
|
||||
int err_ret;
|
||||
|
||||
bool support_term256;
|
||||
if (!fish_term256.missing_or_empty()) {
|
||||
support_term256 = from_string<bool>(fish_term256);
|
||||
@@ -309,6 +311,8 @@ void update_fish_color_support(void) {
|
||||
env_var_t term = env_get_string(L"TERM");
|
||||
if (term.missing()) {
|
||||
support_term256 = false;
|
||||
} else if (setupterm(NULL, STDOUT_FILENO, &err_ret) != ERR) {
|
||||
support_term256 = (max_colors >= 256);
|
||||
} else if (term.find(L"256color") != wcstring::npos) {
|
||||
// Explicitly supported.
|
||||
support_term256 = true;
|
||||
|
||||
@@ -47,10 +47,7 @@ int (*output_get_writer())(char) { return out; }
|
||||
// Returns true if we think the term256 support is "native" as opposed to forced.
|
||||
static bool term256_support_is_native(void) { return max_colors >= 256; }
|
||||
|
||||
color_support_t output_get_color_support(void) {
|
||||
if (term256_support_is_native()) { return color_support_term256 | color_support; }
|
||||
return color_support;
|
||||
}
|
||||
color_support_t output_get_color_support(void) { return color_support; }
|
||||
|
||||
void output_set_color_support(color_support_t val) { color_support = val; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user