aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2016-07-03 01:55:09 -0400
committerGitHub <noreply@github.com>2016-07-03 01:55:09 -0400
commitc402f6e7a9135490a9f05e4cac733e41c6815b2d (patch)
tree9e90c402b768cbd2bf013447d84ebcba19b79c08 /src
parentf80eb768c75de2065626203de001738e1dda436e (diff)
parent173d366a5b0b5f0784a1da8aef4fe5d0cab7e1ec (diff)
downloadrneovim-c402f6e7a9135490a9f05e4cac733e41c6815b2d.tar.gz
rneovim-c402f6e7a9135490a9f05e4cac733e41c6815b2d.tar.bz2
rneovim-c402f6e7a9135490a9f05e4cac733e41c6815b2d.zip
Merge #5001 from justinmk/t_colors
TUI: infer 256 colors more liberally; listen to unibilium in other cases
Diffstat (limited to 'src')
-rw-r--r--src/nvim/globals.h2
-rw-r--r--src/nvim/main.c3
-rw-r--r--src/nvim/option.c1
-rw-r--r--src/nvim/tui/tui.c11
4 files changed, 9 insertions, 8 deletions
diff --git a/src/nvim/globals.h b/src/nvim/globals.h
index 42fde50bee..7f91903106 100644
--- a/src/nvim/globals.h
+++ b/src/nvim/globals.h
@@ -414,7 +414,7 @@ EXTERN int provider_call_nesting INIT(= 0);
EXTERN char_u hash_removed;
-EXTERN int t_colors INIT(= 0); /* int value of T_CCO */
+EXTERN int t_colors INIT(= 256); // int value of T_CCO
/*
* When highlight_match is TRUE, highlight a match, starting at the cursor
diff --git a/src/nvim/main.c b/src/nvim/main.c
index a876a0ad21..5cd1dbb467 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -276,7 +276,6 @@ int main(int argc, char **argv)
printf(_("%d files to edit\n"), GARGCOUNT);
full_screen = true;
- t_colors = 256;
check_tty(&params);
/*
@@ -1671,8 +1670,6 @@ static bool do_user_initialization(void)
}
/// Source startup scripts
-///
-/// @param[in]
static void source_startup_scripts(const mparm_T *const parmp)
FUNC_ATTR_NONNULL_ALL
{
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 020a119fd3..a844c4ed80 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -4404,6 +4404,7 @@ bool get_tty_option(char *name, char **value)
if (is_tty_option(name)) {
if (value) {
+ // XXX: All other t_* options were removed in 3baba1e7.
*value = xstrdup("");
}
return true;
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index 50558e644a..d220df508a 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -135,6 +135,8 @@ static void terminfo_start(UI *ui)
data->ut = unibi_dummy();
}
fix_terminfo(data);
+ // Set 't_Co' from the result of unibilium & fix_terminfo.
+ t_colors = unibi_get_num(data->ut, unibi_max_colors);
// Enter alternate screen and clear
unibi_out(ui, unibi_enter_ca_mode);
unibi_out(ui, unibi_clear_screen);
@@ -786,6 +788,7 @@ static void fix_terminfo(TUIData *data)
unibi_term *ut = data->ut;
const char *term = os_getenv("TERM");
+ const char *colorterm = os_getenv("COLORTERM");
if (!term) {
goto end;
}
@@ -831,10 +834,10 @@ static void fix_terminfo(TUIData *data)
#define XTERM_SETAB \
"\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m"
- if (os_getenv("COLORTERM") != NULL
- && (!strcmp(term, "xterm") || !strcmp(term, "screen"))) {
- // probably every modern terminal that sets TERM=xterm supports 256
- // colors(eg: gnome-terminal). Also do it when TERM=screen.
+ if ((colorterm && strstr(colorterm, "256"))
+ || strstr(term, "256")
+ || strstr(term, "xterm")) {
+ // Assume TERM~=xterm or COLORTERM~=256 supports 256 colors.
unibi_set_num(ut, unibi_max_colors, 256);
unibi_set_str(ut, unibi_set_a_foreground, XTERM_SETAF);
unibi_set_str(ut, unibi_set_a_background, XTERM_SETAB);