From 92fef29765f2a2f3098bbd48ce534e50dcfe4d99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Thu, 31 Dec 2015 12:39:20 +0100 Subject: vis-lua: implement vis.events.{start,quit} events --- vis-lua.c | 13 +++++++++++-- 1 file 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) { -- cgit v1.2.3