diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2016-07-03 01:17:26 -0400 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2016-07-03 01:21:33 -0400 |
commit | c00231078790e7f700b820a96f69387c42518a10 (patch) | |
tree | 0320ac74ca14f6a2064b53545a476f294f0e1abc /src | |
parent | fab62141c8bd10bc55d857e94e5b686434015d34 (diff) | |
download | rneovim-c00231078790e7f700b820a96f69387c42518a10.tar.gz rneovim-c00231078790e7f700b820a96f69387c42518a10.tar.bz2 rneovim-c00231078790e7f700b820a96f69387c42518a10.zip |
tui: Assume 256 colors in most cases.
Assume 256 colors if:
- $TERM contains "xterm" or "256"
- $COLORTERM contains "256"
Closes #2912
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/tui/tui.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index ea10130056..d220df508a 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -788,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; } @@ -833,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); |