diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2020-09-17 14:34:29 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2020-09-17 15:30:27 +0200 |
| commit | c02ff996418dd8e5c4115333c5a442e14e9add61 (patch) | |
| tree | 67cda7a89eb14f29d467ecc58299374b84302cc2 | |
| parent | bacc6e08a6297ecee09ba81f6fa0265b86c78adc (diff) | |
| download | vis-c02ff996418dd8e5c4115333c5a442e14e9add61.tar.gz vis-c02ff996418dd8e5c4115333c5a442e14e9add61.tar.xz | |
vis-lua: provide vis.register property
| -rw-r--r-- | vis-lua.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -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); } |
