vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit ab448e6b349f2c26b0c382f87d4d530d093c2955
parent ef9e6e4336176767d9bb8f05482e57fea9369417
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Wed, 30 Dec 2015 14:06:45 +0100

vis-lua: implement vis.open(filename)

Diffstat:
Mvis-lua.c | 12++++++++++++
1 file changed, 12 insertions(+), 0 deletions(-)

diff --git 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 }, };