aboutsummaryrefslogtreecommitdiff
path: root/vis-lua.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2017-01-27 15:22:45 +0100
committerMarc André Tanner <mat@brain-dump.org>2017-01-27 15:22:45 +0100
commit4738a2572fcbe492df4d0fbc8b7dbdd0f1d4d840 (patch)
tree14fcf5e88b9f1e2c8124d5a18ba1e3a63124b544 /vis-lua.c
parent7dc877164eb4e33a1a6537ea391066464e932956 (diff)
downloadvis-4738a2572fcbe492df4d0fbc8b7dbdd0f1d4d840.tar.gz
vis-4738a2572fcbe492df4d0fbc8b7dbdd0f1d4d840.tar.xz
vis-lua: introduce vis:insert function
Diffstat (limited to 'vis-lua.c')
-rw-r--r--vis-lua.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/vis-lua.c b/vis-lua.c
index 842a979..e42f867 100644
--- a/vis-lua.c
+++ b/vis-lua.c
@@ -1025,6 +1025,25 @@ static int feedkeys(lua_State *L) {
}
/***
+ * Insert keys at all cursor positions of active window.
+ *
+ * This function behaves as if the keys were entered in insert mode,
+ * but in contrast to @{Vis:feedkeys} it bypasses the input queue,
+ * meaning mappings do not apply and the keys will not be recorded in macros.
+ *
+ * @function insert
+ * @tparam string keys the keys to insert
+ * @see Vis:feedkeys
+ */
+static int insert(lua_State *L) {
+ Vis *vis = obj_ref_check(L, 1, "vis");
+ size_t len;
+ const char *keys = luaL_checklstring(L, 2, &len);
+ vis_insert_key(vis, keys, len);
+ return 0;
+}
+
+/***
* Currently active window.
* @tfield Window win
* @see windows
@@ -1101,6 +1120,7 @@ static const struct luaL_Reg vis_lua[] = {
{ "textobject_register", textobject_register },
{ "command_register", command_register },
{ "feedkeys", feedkeys },
+ { "insert", insert },
{ "action_register", action_register },
{ "__index", vis_index },
{ "__newindex", vis_newindex },