aboutsummaryrefslogtreecommitdiff
path: root/vis-lua.c
diff options
context:
space:
mode:
authorEvan Gates <evan.gates@gmail.com>2021-09-21 17:51:32 -0700
committerEvan Gates <evan.gates@gmail.com>2022-06-15 14:26:31 -0600
commit22d4709e8a30c8feb9b4da7d78e0ea6a57af83e8 (patch)
tree3eb173cd832ed8ee7091b601295c6cd9bd0d6ad5 /vis-lua.c
parent3365b72de5d329f2b2158dd81035f0c3b522b125 (diff)
downloadvis-22d4709e8a30c8feb9b4da7d78e0ea6a57af83e8.tar.gz
vis-22d4709e8a30c8feb9b4da7d78e0ea6a57af83e8.tar.xz
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)
Diffstat (limited to 'vis-lua.c')
-rw-r--r--vis-lua.c6
1 files changed, 5 insertions, 1 deletions
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;
}