diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-12-08 10:02:44 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-12-08 10:02:44 +0100 |
| commit | 0508cb652e6ec6c926b8fbaca7c79bdd386252fe (patch) | |
| tree | 2ff308fb639ae03992eaff0fd4b961e4a86526e0 /vis-lua.c | |
| parent | b33fe9f37d6a9c672650df1c61e897f2582ef563 (diff) | |
| download | vis-0508cb652e6ec6c926b8fbaca7c79bdd386252fe.tar.gz vis-0508cb652e6ec6c926b8fbaca7c79bdd386252fe.tar.xz | |
vis-lua: add optional help parameter to mapping functions
Diffstat (limited to 'vis-lua.c')
| -rw-r--r-- | vis-lua.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -692,9 +692,9 @@ static int keymap(lua_State *L, Vis *vis, Win *win) { int mode = luaL_checkint(L, 2); const char *key = luaL_checkstring(L, 3); - if (!key || !lua_isfunction(L, 4)) goto err; + const char *help = luaL_optstring(L, 5, NULL); if (!(binding = calloc(1, sizeof *binding)) || !(action = calloc(1, sizeof *action))) goto err; @@ -706,7 +706,7 @@ static int keymap(lua_State *L, Vis *vis, Win *win) { *action = (KeyAction){ .name = NULL, - .help = NULL, + .help = help ? strdup(help) : help, .func = keymapping, .arg = (const Arg){ .v = func, @@ -739,7 +739,9 @@ err: * * @function map * @tparam int mode the mode to which the mapping should be added + * @tparam string key the key to map * @tparam function func the Lua function to handle the key mapping + * @tparam[opt] string help the single line help text as displayed in `:help` * @treturn bool whether the mapping was successfully established * @see Window:map */ @@ -1149,7 +1151,9 @@ static int window_cursors_iterator(lua_State *L) { * * @function map * @tparam int mode the mode to which the mapping should be added + * @tparam string key the key to map * @tparam function func the Lua function to handle the key mapping + * @tparam[opt] string help the single line help text as displayed in `:help` * @treturn bool whether the mapping was successfully established * @see Vis:map */ |
