aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/tui/tui.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/tui/tui.c')
-rw-r--r--src/nvim/tui/tui.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index 62bc81ba64..d220df508a 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -11,6 +11,7 @@
#include "nvim/vim.h"
#include "nvim/ui.h"
#include "nvim/map.h"
+#include "nvim/main.h"
#include "nvim/memory.h"
#include "nvim/api/vim.h"
#include "nvim/api/private/helpers.h"
@@ -134,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);
@@ -261,7 +264,7 @@ static void sigwinch_cb(SignalWatcher *watcher, int signum, void *data)
UI *ui = data;
update_size(ui);
// run refresh_event in nvim main loop
- loop_schedule(&loop, event_create(1, refresh_event, 0));
+ loop_schedule(&main_loop, event_create(1, refresh_event, 0));
}
static bool attrs_differ(HlAttrs a1, HlAttrs a2)
@@ -681,7 +684,7 @@ static void invalidate(UI *ui, int top, int bot, int left, int right)
intersects->right = MAX(right, intersects->right);
} else {
// Else just add a new entry;
- kv_push(Rect, data->invalid_regions, ((Rect){top, bot, left, right}));
+ kv_push(data->invalid_regions, ((Rect) { top, bot, left, right }));
}
}
@@ -785,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;
}
@@ -830,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);