From 6a7f12527b1d5f562c8e762126719706329aae8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Sat, 21 May 2016 23:45:34 +0200 Subject: vis: refactor status line handling Make window status bar content configurable via Lua. --- vis.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'vis.c') diff --git a/vis.c b/vis.c index 3fabe5b..a5a2e1b 100644 --- a/vis.c +++ b/vis.c @@ -157,11 +157,17 @@ static void window_free(Win *win) { free(win); } -static void window_highlight(void *ctx) { +static void window_draw(void *ctx) { Win *win = ctx; + if (!win->ui) + return; Vis *vis = win->vis; - if (!win->file->internal && vis->event && vis->event->win_highlight) - vis->event->win_highlight(vis, win, win->horizon); + if (!win->file->internal && vis->event) { + if (win->lexer_name && vis->event->win_highlight) + vis->event->win_highlight(vis, win, win->horizon); + if (vis->event->win_status) + vis->event->win_status(vis, win); + } } Win *window_new_file(Vis *vis, File *file) { @@ -172,6 +178,7 @@ Win *window_new_file(Vis *vis, File *file) { win->file = file; win->jumplist = ringbuf_alloc(31); win->event.data = win; + win->event.draw = window_draw; win->horizon = 1 << 15; win->view = view_new(file->text, &win->event); win->ui = vis->ui->window_new(vis->ui, win->view, file, UI_OPTION_STATUSBAR); @@ -268,7 +275,6 @@ bool vis_window_syntax_set(Win *win, const char *syntax) { } free(win->lexer_name); win->lexer_name = syntax ? strdup(syntax) : NULL; - win->event.highlight = syntax ? window_highlight : NULL; return !syntax || win->lexer_name; } @@ -1133,10 +1139,6 @@ void vis_exit(Vis *vis, int status) { vis->exit_status = status; } -const char *vis_mode_status(Vis *vis) { - return vis->mode->status; -} - void vis_insert_tab(Vis *vis) { if (!vis->expandtab) { vis_insert_key(vis, "\t", 1); -- cgit v1.2.3