aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2017-01-27 15:16:10 +0100
committerMarc André Tanner <mat@brain-dump.org>2017-01-27 15:23:07 +0100
commit8871316904a9a9cf75f94fae4d6cef76b7271bc2 (patch)
treec21c46c47082e4caacac933801b1d973b6a3a42a
parent4738a2572fcbe492df4d0fbc8b7dbdd0f1d4d840 (diff)
downloadvis-8871316904a9a9cf75f94fae4d6cef76b7271bc2.tar.gz
vis-8871316904a9a9cf75f94fae4d6cef76b7271bc2.tar.xz
vis-lua: introduce vis:replace function
-rw-r--r--vis-lua.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/vis-lua.c b/vis-lua.c
index e42f867..4bec955 100644
--- a/vis-lua.c
+++ b/vis-lua.c
@@ -1044,6 +1044,25 @@ static int insert(lua_State *L) {
}
/***
+ * Replace keys at all cursor positions of active window.
+ *
+ * This function behaves as if the keys were entered in replace 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 replace
+ * @tparam string keys the keys to insert
+ * @see Vis:feedkeys
+ */
+static int replace(lua_State *L) {
+ Vis *vis = obj_ref_check(L, 1, "vis");
+ size_t len;
+ const char *keys = luaL_checklstring(L, 2, &len);
+ vis_replace_key(vis, keys, len);
+ return 0;
+}
+
+/***
* Currently active window.
* @tfield Window win
* @see windows
@@ -1121,6 +1140,7 @@ static const struct luaL_Reg vis_lua[] = {
{ "command_register", command_register },
{ "feedkeys", feedkeys },
{ "insert", insert },
+ { "replace", replace },
{ "action_register", action_register },
{ "__index", vis_index },
{ "__newindex", vis_newindex },