about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDaniel Shahaf <d.s@daniel.shahaf.name>2015-09-10 19:14:26 +0000
committerDaniel Shahaf <d.s@daniel.shahaf.name>2015-09-10 19:14:34 +0000
commitc088906423ba22eef8d57c84b396f8d5be83ca45 (patch)
tree269b097837199371430d443050ec43b31f5bab57
parente86b3cce47e62c263301322ce24b56cf04b8cdb8 (diff)
downloadzsh-c088906423ba22eef8d57c84b396f8d5be83ca45.tar.gz
zsh-c088906423ba22eef8d57c84b396f8d5be83ca45.tar.xz
zsh-c088906423ba22eef8d57c84b396f8d5be83ca45.zip
36445: Expose yankb, yanke, ZLE_YANK to widgets.
-rw-r--r--ChangeLog5
-rw-r--r--Doc/Zsh/zle.yo12
-rw-r--r--Src/Zle/zle_params.c30
3 files changed, 47 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 3dfd8ba53..e1d43da83 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-10  Daniel Shahaf  <d.s@daniel.shahaf.name>
+
+	* 36445: Doc/Zsh/zle.yo Src/Zle/zle_params.c: Expose yankb,
+	yanke, ZLE_YANK to widgets.
+
 2015-09-10  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
 	* 36478: Src/pattern.c, Src/zsh.h, Src/Zle/comp.h,
diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo
index 0613697a0..2c539c460 100644
--- a/Doc/Zsh/zle.yo
+++ b/Doc/Zsh/zle.yo
@@ -1005,6 +1005,18 @@ executed; the second argument that followed tt(zle -C) when the widget was
 defined.  This is the name of a builtin completion widget.  For widgets
 defined with tt(zle -N) this is set to the empty string.  Read-only.
 )
+vindex(YANK_ACTIVE)
+vindex(YANK_START)
+vindex(YANK_END)
+xitem(tt(YANK_ACTIVE) (integer))
+xitem(tt(YANK_START) (integer))
+item(tt(YANK_END) (integer))(
+These three parameters indicate whether text has just been yanked (pasted)
+into the buffer.  tt(YANK_START) and tt(YANK_END) are in the same unit sas
+tt(CURSOR), and are only valid when tt(YANK_ACTIVE) is non-zero.
+
+All three are read-only.
+)
 vindex(ZLE_STATE)
 item(tt(ZLE_STATE) (scalar))(
 Contains a set of space-separated words that describe the current tt(zle)
diff --git a/Src/Zle/zle_params.c b/Src/Zle/zle_params.c
index b84e72088..000bc388c 100644
--- a/Src/Zle/zle_params.c
+++ b/Src/Zle/zle_params.c
@@ -97,6 +97,12 @@ static const struct gsu_integer undo_change_no_gsu =
 { get_undo_current_change, NULL, zleunsetfn };
 static const struct gsu_integer undo_limit_no_gsu =
 { get_undo_limit_change, set_undo_limit_change, zleunsetfn };
+static const struct gsu_integer yankstart_gsu =
+{ get_yankstart, NULL, zleunsetfn };
+static const struct gsu_integer yankend_gsu =
+{ get_yankend, NULL, zleunsetfn };
+static const struct gsu_integer yankactive_gsu =
+{ get_yankactive, NULL, zleunsetfn };
 
 static const struct gsu_array killring_gsu =
 { get_killring, set_killring, unset_killring };
@@ -143,6 +149,9 @@ static struct zleparam {
     { "WIDGET", PM_SCALAR | PM_READONLY, GSU(widget_gsu), NULL },
     { "WIDGETFUNC", PM_SCALAR | PM_READONLY, GSU(widgetfunc_gsu), NULL },
     { "WIDGETSTYLE", PM_SCALAR | PM_READONLY, GSU(widgetstyle_gsu), NULL },
+    { "YANK_START", PM_INTEGER | PM_READONLY, GSU(yankstart_gsu), NULL },
+    { "YANK_END", PM_INTEGER | PM_READONLY, GSU(yankend_gsu), NULL },
+    { "YANK_ACTIVE", PM_INTEGER | PM_READONLY, GSU(yankactive_gsu), NULL },
     { "ZLE_STATE", PM_SCALAR | PM_READONLY, GSU(zle_state_gsu), NULL },
     { NULL, 0, NULL, NULL }
 };
@@ -477,6 +486,27 @@ get_pending(UNUSED(Param pm))
 }
 
 /**/
+static zlong
+get_yankstart(UNUSED(Param pm))
+{
+    return yankb;
+}
+
+/**/
+static zlong
+get_yankend(UNUSED(Param pm))
+{
+    return yanke;
+}
+
+/**/
+static zlong
+get_yankactive(UNUSED(Param pm))
+{
+    return lastcmd & ZLE_YANK;
+}
+
+/**/
 static char *
 get_cutbuffer(UNUSED(Param pm))
 {