vis

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

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

commit 439e0acd1ea97ba8a9d3b4f9ec0fed6180920176
parent 144492710c21827ad762a62675ec7462c834e325
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Thu, 17 Sep 2020 14:58:09 +0200

vis-lua: provide vis.mark property

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

diff --git a/vis-lua.c b/vis-lua.c @@ -1387,6 +1387,10 @@ static int redraw(lua_State *L) { * Register name in use. * @tfield string register */ +/*** + * Mark name in use. + * @tfield string mark + */ static int vis_index(lua_State *L) { Vis *vis = obj_ref_check(L, 1, "vis"); @@ -1435,6 +1439,12 @@ static int vis_index(lua_State *L) { return 1; } + if (strcmp(key, "mark") == 0) { + char name = vis_mark_to(vis, vis_mark_used(vis)); + lua_pushlstring(L, &name, 1); + return 1; + } + if (strcmp(key, "ui") == 0) { obj_ref_new(L, vis->ui, VIS_LUA_TYPE_UI); return 1; @@ -1475,6 +1485,13 @@ static int vis_newindex(lua_State *L) { vis_register(vis, vis_register_from(vis, name[0])); return 0; } + + if (strcmp(key, "mark") == 0) { + const char *name = luaL_checkstring(L, 3); + if (strlen(name) == 1) + vis_mark(vis, vis_mark_from(vis, name[0])); + return 0; + } } return newindex_common(L); }