From c02ff996418dd8e5c4115333c5a442e14e9add61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Thu, 17 Sep 2020 14:34:29 +0200 Subject: vis-lua: provide vis.register property --- vis-lua.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/vis-lua.c b/vis-lua.c index fc2e5c2..0e5a7ec 100644 --- a/vis-lua.c +++ b/vis-lua.c @@ -1385,6 +1385,10 @@ static int redraw(lua_State *L) { * Currently unconsumed keys in the input queue. * @tfield string input_queue */ +/*** + * Register name in use. + * @tfield string register + */ static int vis_index(lua_State *L) { Vis *vis = obj_ref_check(L, 1, "vis"); @@ -1422,6 +1426,12 @@ static int vis_index(lua_State *L) { return 1; } + if (strcmp(key, "register") == 0) { + char name = vis_register_to(vis, vis_register_used(vis)); + lua_pushlstring(L, &name, 1); + return 1; + } + if (strcmp(key, "registers") == 0) { obj_ref_new(L, vis->ui, VIS_LUA_TYPE_REGISTERS); return 1; @@ -1460,6 +1470,13 @@ static int vis_newindex(lua_State *L) { vis_window_focus(obj_ref_check(L, 3, VIS_LUA_TYPE_WINDOW)); return 0; } + + if (strcmp(key, "register") == 0) { + const char *name = luaL_checkstring(L, 3); + if (strlen(name) == 1) + vis_register(vis, vis_register_from(vis, name[0])); + return 0; + } } return newindex_common(L); } -- cgit v1.2.3