diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2015-12-30 14:06:45 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2015-12-31 13:20:11 +0100 |
| commit | 809a73a6a50d82da27f2df6fb1906c8a6d09d19d (patch) | |
| tree | 0cef39425f07f6478036ef432c64c61332816759 | |
| parent | 1417b20d388e9b87218691f1abc6204918fd87f9 (diff) | |
| download | vis-809a73a6a50d82da27f2df6fb1906c8a6d09d19d.tar.gz vis-809a73a6a50d82da27f2df6fb1906c8a6d09d19d.tar.xz | |
vis-lua: implement vis.open(filename)
| -rw-r--r-- | vis-lua.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -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 }, }; |
