From 809a73a6a50d82da27f2df6fb1906c8a6d09d19d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Wed, 30 Dec 2015 14:06:45 +0100 Subject: vis-lua: implement vis.open(filename) --- vis-lua.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'vis-lua.c') diff --git a/vis-lua.c b/vis-lua.c index e8cfee4..17fabc5 100644 --- a/vis-lua.c +++ b/vis-lua.c @@ -228,11 +228,23 @@ static int info(lua_State *L) { return 0; } +static int open(lua_State *L) { + Vis *vis = lua_touserdata(L, lua_upvalueindex(1)); + const char *name = luaL_checkstring(L, 1); + File *file = NULL; + if (vis_window_new(vis, name)) + file = obj_ref_new(L, vis->win->file, "vis.file"); + if (!file) + lua_pushnil(L); + return 1; +} + static const struct luaL_Reg vis_lua[] = { { "files", files }, { "windows", windows }, { "command", command }, { "info", info }, + { "open", open }, { NULL, NULL }, }; -- cgit v1.2.3