Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Identify "active" region?



2008/5/4 Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>:
> On Sat, 03 May 2008 17:52:19 -0700
>  Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>  > There doesn't seem to be any way to determine that there's an active
>  > region except to override set-mark-command and exchange-point-and-mark
>  > to stash something in a global variable.  Have I missed something?
>
>  No, that's worth adding.  I'll do it if no one gets to it first.  It
>  should be trivial: a new ZLE variable tied into the integer controlling
>  this.  There's no reason it shouldn't be writable, either.

This seems to do the trick:

diff --git a/Src/Zle/zle_params.c b/Src/Zle/zle_params.c
index a04ee72..5b8cc30 100644
--- a/Src/Zle/zle_params.c
+++ b/Src/Zle/zle_params.c
@@ -89,6 +89,8 @@ static const struct gsu_integer numeric_gsu =
 { get_numeric, set_numeric, unset_numeric };
 static const struct gsu_integer pending_gsu =
 { get_pending, NULL, zleunsetfn };
+static const struct gsu_integer region_gsu =
+{ get_region_active, set_region_active, zleunsetfn };

 static const struct gsu_array killring_gsu =
 { get_killring, set_killring, unset_killring };
@@ -125,7 +127,8 @@ static struct zleparam {
     { "POSTDISPLAY", PM_SCALAR, GSU(postdisplay_gsu), NULL },
     { "PREBUFFER",  PM_SCALAR | PM_READONLY,  GSU(prebuffer_gsu), NULL },
     { "PREDISPLAY", PM_SCALAR, GSU(predisplay_gsu), NULL },
-    { "RBUFFER", PM_SCALAR,  GSU(rbuffer_gsu), NULL },
+    { "RBUFFER", PM_SCALAR, GSU(rbuffer_gsu), NULL },
+    { "REGION", PM_INTEGER, GSU(region_gsu), NULL},
     { "region_highlight", PM_ARRAY, GSU(region_highlight_gsu), NULL },
     { "WIDGET", PM_SCALAR | PM_READONLY, GSU(widget_gsu), NULL },
     { "WIDGETFUNC", PM_SCALAR | PM_READONLY, GSU(widgetfunc_gsu), NULL },
@@ -252,6 +255,20 @@ get_mark(UNUSED(Param pm))

 /**/
 static void
+set_region_active(UNUSED(Param pm), zlong x)
+{
+    region_active = !!x;
+}
+
+/**/
+static zlong
+get_region_active(UNUSED(Param pm))
+{
+    return region_active;
+}
+
+/**/
+static void
 set_lbuffer(UNUSED(Param pm), char *x)
 {
     ZLE_STRING_T y;


-- 
Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author