From 22d4709e8a30c8feb9b4da7d78e0ea6a57af83e8 Mon Sep 17 00:00:00 2001 From: Evan Gates Date: Tue, 21 Sep 2021 17:51:32 -0700 Subject: vis-lua: support themes in vis:message The commit that added vis:message[0] used the existing vis_message_show function which is used internaly to display lua stack traces. That function uses the internal error_file. vis_event_emit does not trigger events for internal files in order to avoid extra lua errors when already printing a lua stack trace[1]. Due to this setup any usage of vis:message showed the text in a window with default theme/syntax/status bar colors. Instead of using the internal vis_message_show function, create a new window and file that are not marked internal in the same manner as cmd_help so themes are applied. [0]: d815268 (vis-lua: implement vis:message(msg)) [1]: d555c90 (vis: properly redraw status bar of windows displaying internal files) --- vis-lua.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vis-lua.c b/vis-lua.c index 0642343..84f054c 100644 --- a/vis-lua.c +++ b/vis-lua.c @@ -781,7 +781,11 @@ static int info(lua_State *L) { static int message(lua_State *L) { Vis *vis = obj_ref_check(L, 1, "vis"); const char *msg = luaL_checkstring(L, 2); - vis_message_show(vis, msg); + if (msg && vis_window_new(vis, NULL)) { + text_appendf(vis->win->file->text, "%s\n", msg); + text_save(vis->win->file->text, NULL); + view_cursor_to(vis->win->view, 0); + } return 0; } -- cgit v1.2.3