diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2017-05-27 18:39:57 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2017-05-27 18:39:57 +0200 |
| commit | e7bfcf4fe6480e217e972889f69e1c44c4057c97 (patch) | |
| tree | 31c2083e108b682a9d210e6897eaedc8126ef20e /vis-lua.c | |
| parent | fa93b6c3292acdbfe71c9a341ba319ecc0d0d9cb (diff) | |
| download | vis-e7bfcf4fe6480e217e972889f69e1c44c4057c97.tar.gz vis-e7bfcf4fe6480e217e972889f69e1c44c4057c97.tar.xz | |
vis-lua: expose functions to unmap key bindings
Diffstat (limited to 'vis-lua.c')
| -rw-r--r-- | vis-lua.c | 40 |
1 files changed, 40 insertions, 0 deletions
@@ -906,6 +906,32 @@ static int map(lua_State *L) { } /*** + * Unmap a global key binding. + * + * @function unmap + * @tparam int mode the mode from which the mapping should be removed + * @tparam string key the mapping to remove + * @treturn bool whether the mapping was successfully removed + * @see Window:unmap + */ +static int keyunmap(lua_State *L, Vis *vis, Win *win) { + enum VisMode mode = luaL_checkint(L, 2); + const char *key = luaL_checkstring(L, 3); + bool ret; + if (!win) + ret = vis_mode_unmap(vis, mode, key); + else + ret = vis_window_mode_unmap(win, mode, key); + lua_pushboolean(L, ret); + return 1; +} + +static int unmap(lua_State *L) { + Vis *vis = obj_ref_check(L, 1, "vis"); + return keyunmap(L, vis, NULL); +} + +/*** * Get all currently active mappings of a mode. * * @function mappings @@ -1421,6 +1447,7 @@ static const struct luaL_Reg vis_lua[] = { { "info", info }, { "message", message }, { "map", map }, + { "unmap", unmap }, { "mappings", mappings }, { "operator", operator }, { "operator_register", operator_register }, @@ -1597,6 +1624,18 @@ static int window_map(lua_State *L) { } /*** + * Remove a window local key mapping. + * The function signature is the same as for @{Vis:unmap}. + * @function unmap + * @param ... + * @see Vis:unmap + */ +static int window_unmap(lua_State *L) { + Win *win = obj_ref_check(L, 1, VIS_LUA_TYPE_WINDOW); + return keyunmap(L, win->vis, win); +} + +/*** * Define a display style. * @function style_define * @tparam int id the style id to use @@ -1676,6 +1715,7 @@ static const struct luaL_Reg window_funcs[] = { { "__newindex", newindex_common }, { "cursors_iterator", window_cursors_iterator }, { "map", window_map }, + { "unmap", window_unmap }, { "style_define", window_style_define }, { "style", window_style }, { "status", window_status }, |
