diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2017-01-14 10:44:30 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2017-01-14 10:44:30 +0100 |
| commit | 7f0309f5835f12396a395681d8abfc3d844d3ae8 (patch) | |
| tree | dc33d25063241d0ea7c24f81949c91ca8d7db858 /vis-lua.c | |
| parent | 91e0c6e2c6dea4f57d355a436980d46d7be6d81f (diff) | |
| download | vis-7f0309f5835f12396a395681d8abfc3d844d3ae8.tar.gz vis-7f0309f5835f12396a395681d8abfc3d844d3ae8.tar.xz | |
vis-lua: allow mode changes by setting vis.mode
Diffstat (limited to 'vis-lua.c')
| -rw-r--r-- | vis-lua.c | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -1054,6 +1054,19 @@ static int vis_index(lua_State *L) { return index_common(L); } +static int vis_newindex(lua_State *L) { + Vis *vis = obj_ref_check(L, 1, "vis"); + if (lua_isstring(L, 2)) { + const char *key = lua_tostring(L, 2); + if (strcmp(key, "mode") == 0) { + enum VisMode mode = luaL_checkunsigned(L, 3); + vis_mode_switch(vis, mode); + return 0; + } + } + return newindex_common(L); +} + static const struct luaL_Reg vis_lua[] = { { "files", files }, { "windows", windows }, @@ -1072,7 +1085,7 @@ static const struct luaL_Reg vis_lua[] = { { "feedkeys", feedkeys }, { "action_register", action_register }, { "__index", vis_index }, - { "__newindex", newindex_common }, + { "__newindex", vis_newindex }, { NULL, NULL }, }; |
