aboutsummaryrefslogtreecommitdiff
path: root/vis-lua.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2015-12-31 12:39:20 +0100
committerMarc André Tanner <mat@brain-dump.org>2015-12-31 13:20:12 +0100
commit92fef29765f2a2f3098bbd48ce534e50dcfe4d99 (patch)
treef3f4dd115183ab9096f0e09bd9b11d6366ea6962 /vis-lua.c
parent8424980892a3c25d3e2a79ac9ebe3e7eadfa0d6d (diff)
downloadvis-92fef29765f2a2f3098bbd48ce534e50dcfe4d99.tar.gz
vis-92fef29765f2a2f3098bbd48ce534e50dcfe4d99.tar.xz
vis-lua: implement vis.events.{start,quit} events
Diffstat (limited to 'vis-lua.c')
-rw-r--r--vis-lua.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/vis-lua.c b/vis-lua.c
index 82281f1..5b44ea1 100644
--- a/vis-lua.c
+++ b/vis-lua.c
@@ -587,12 +587,21 @@ void vis_lua_start(Vis *vis) {
lua_getglobal(L, "require");
lua_pushstring(L, "visrc");
lua_pcall(L, 1, 0, 0);
+ vis_lua_event(vis, "start");
+ if (lua_isfunction(L, -1))
+ lua_pcall(L, 0, 0, 0);
+ lua_pop(L, 1);
}
void vis_lua_quit(Vis *vis) {
lua_State *L = vis->lua;
- if (L)
- lua_close(L);
+ if (!L)
+ return;
+ vis_lua_event(vis, "quit");
+ if (lua_isfunction(L, -1))
+ lua_pcall(L, 0, 0, 0);
+ lua_pop(L, 1);
+ lua_close(L);
}
void vis_lua_file_open(Vis *vis, File *file) {