Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,
	T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=googlemail.com; s=20120113;
        h=from:to:cc:subject:date:message-id;
        bh=PIG/OEo3APgCam2gWMT58rUTSOim6IFDBZ+ltly+QWc=;
        b=hgmJdzcoxoK9TGTQW+NjUHgfkI1xzwLjb/XXQyhb05ugGgwrWdHoHKXvCDErskf5e9
         BCrlJt5hYecOCj8SOhy1Bx1+RNzC+sx35SC/TYJ4xjY48Zgsf1BfEjgGqf0PlaFjNwRF
         pnpmgiieOtkVDKhp3S94AocvrFjMZIh4QFkNGPioph+GF1t9kSWCmSiCwutsrehnaVKi
         MMMwzOI/+YQKSB9NKx4z1inxWr/f2TLsAFT6e1U3DMAa0dso3gWM0i6zo/HlKy6f5gLe
         3MDEYNckMaJSXDkCZf2qysBKUkdU04ZhuR1dm7pCtODP79MDIJXYHRWTRITh0ZIAqSOq
         RFzw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:to:cc:subject:date:message-id;
        bh=PIG/OEo3APgCam2gWMT58rUTSOim6IFDBZ+ltly+QWc=;
        b=SB6iEwNbR718X4m7I7nmY7qB7ZtyuUoRM67eTN2BEf7zaoMS+QfY74WJn3PZULCN0n
         pBDnfK7bd2DWzPFD+Ai9eIelXNXyK3OLq75CbkPHIjh+fekdBap3VHKm8GU1502tF3qP
         V9Rlr6mZKAg28CukKGNq7PDoqWLfX2Lu9UEdg54wXoutAcjr8U8/bQinXHbpdj5skccR
         utUwZtVYX56d8H+moU+5t0KHky4lFHhf1HFBFAz0iQnioAd1VVBg1x6atyYSz8OopFEY
         0zWr9RWZ45e/1iCSbMPujF7QhNml5soStF6mzqh2hGsmn/Q+TCKgowGpODSIj+6UIQNd
         8PcA==
X-Gm-Message-State: AD7BkJKoxvVHhslHEf928af7dtlFxqabsJE4RmntwCGorbqF+P13kF8O4k5g+Mb5c3/Mwg==
X-Received: by 10.194.60.200 with SMTP id j8mr20732327wjr.124.1457905887484;
        Sun, 13 Mar 2016 14:51:27 -0700 (PDT)
From: m0viefreak <m0viefreak.cm@googlemail.com>
To: zsh-workers@zsh.org
Cc: m0viefreak <m0viefreak.cm@googlemail.com>
Subject: [PATCH] Expose isearch and suffix regions to widgets.
Date: Sun, 13 Mar 2016 22:51:11 +0100
Message-Id: <1457905871-2808-1-git-send-email-m0viefreak.cm@googlemail.com>
X-Mailer: git-send-email 2.5.0.234.gefc8a62
X-Seq: zsh-workers 38145

This does the same as
  36445: Expose yankb, yanke, ZLE_YANK to widgets.
did, but for isearch and suffix regions.
---
 Doc/Zsh/zle.yo       | 26 +++++++++++++++++++++++
 Src/Zle/zle_params.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 86 insertions(+)

diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo
index 414c8dd..161cef7 100644
--- a/Doc/Zsh/zle.yo
+++ b/Doc/Zsh/zle.yo
@@ -835,6 +835,19 @@ which always gives the number of the history line being added to the main
 shell's history.  tt(HISTNO) refers to the line being retrieved within
 zle.
 )
+vindex(ISEARCH_ACTIVE)
+vindex(ISEARCH_START)
+vindex(ISEARCH_END)
+xitem(tt(ISEARCH_ACTIVE) (integer))
+xitem(tt(ISEARCH_START) (integer))
+item(tt(ISEARCH_END) (integer))(
+tt(ISEARCH_ACTIVE) indicates whether an incremental search minibuffer
+is active. tt(ISEARCH_START) and tt(ISEARCH_END) give the location of
+the matched pattern and are in the same units as tt(CURSOR). They are
+only valid for reading when tt(ISEARCH_ACTIVE) is non-zero.
+
+All parameters are read-only.
+)
 vindex(KEYMAP)
 item(tt(KEYMAP) (scalar))(
 The name of the currently selected keymap; read-only.
@@ -977,6 +990,19 @@ and tt(zle_highlight); see
 ifzman(the section CHARACTER HIGHLIGHTING below)\
 ifnzman(noderef(Character Highlighting)) for details.
 )
+vindex(SUFFIX_ACTIVE)
+vindex(SUFFIX_START)
+vindex(SUFFIX_END)
+xitem(tt(SUFFIX_ACTIVE) (integer))
+xitem(tt(SUFFIX_START) (integer))
+item(tt(SUFFIX_END) (integer))(
+tt(SUFFIX_ACTIVE) indicates whether an auto-removable completion suffix
+is currently active. tt(SUFFIX_START) and tt(SUFFIX_END) give the
+location of the suffix and are in the same units as tt(CURSOR). They are
+only valid for reading when tt(SUFFIX_ACTIVE) is non-zero.
+
+All parameters are read-only.
+)
 vindex(UNDO_CHANGE_NO)
 item(tt(UNDO_CHANGE_NO) (integer))(
 A number representing the state of the undo history.  The only use
diff --git a/Src/Zle/zle_params.c b/Src/Zle/zle_params.c
index b5bb288..7cbb3df 100644
--- a/Src/Zle/zle_params.c
+++ b/Src/Zle/zle_params.c
@@ -103,6 +103,18 @@ static const struct gsu_integer yankend_gsu =
 { get_yankend, set_yankend, zleunsetfn };
 static const struct gsu_integer yankactive_gsu =
 { get_yankactive, NULL, zleunsetfn };
+static const struct gsu_integer isearchstart_gsu =
+{ get_isearchstart, NULL, zleunsetfn };
+static const struct gsu_integer isearchend_gsu =
+{ get_isearchend, NULL, zleunsetfn };
+static const struct gsu_integer isearchactive_gsu =
+{ get_isearchactive, NULL, zleunsetfn };
+static const struct gsu_integer suffixstart_gsu =
+{ get_suffixstart, NULL, zleunsetfn };
+static const struct gsu_integer suffixend_gsu =
+{ get_suffixend, NULL, zleunsetfn };
+static const struct gsu_integer suffixactive_gsu =
+{ get_suffixactive, NULL, zleunsetfn };
 
 static const struct gsu_array killring_gsu =
 { get_killring, set_killring, unset_killring };
@@ -152,6 +164,12 @@ static struct zleparam {
     { "YANK_START", PM_INTEGER, GSU(yankstart_gsu), NULL },
     { "YANK_END", PM_INTEGER, GSU(yankend_gsu), NULL },
     { "YANK_ACTIVE", PM_INTEGER | PM_READONLY, GSU(yankactive_gsu), NULL },
+    { "ISEARCH_START", PM_INTEGER, GSU(isearchstart_gsu), NULL },
+    { "ISEARCH_END", PM_INTEGER, GSU(isearchend_gsu), NULL },
+    { "ISEARCH_ACTIVE", PM_INTEGER | PM_READONLY, GSU(isearchactive_gsu), NULL },
+    { "SUFFIX_START", PM_INTEGER, GSU(suffixstart_gsu), NULL },
+    { "SUFFIX_END", PM_INTEGER, GSU(suffixend_gsu), NULL },
+    { "SUFFIX_ACTIVE", PM_INTEGER | PM_READONLY, GSU(suffixactive_gsu), NULL },
     { "ZLE_STATE", PM_SCALAR | PM_READONLY, GSU(zle_state_gsu), NULL },
     { NULL, 0, NULL, NULL }
 };
@@ -521,6 +539,48 @@ set_yankend(UNUSED(Param pm), zlong i)
 }
 
 /**/
+static zlong
+get_isearchstart(UNUSED(Param pm))
+{
+    return isearch_startpos;
+}
+
+/**/
+static zlong
+get_isearchend(UNUSED(Param pm))
+{
+    return isearch_endpos;
+}
+
+/**/
+static zlong
+get_isearchactive(UNUSED(Param pm))
+{
+    return isearch_active;
+}
+
+/**/
+static zlong
+get_suffixstart(UNUSED(Param pm))
+{
+    return zlecs - suffixlen;
+}
+
+/**/
+static zlong
+get_suffixend(UNUSED(Param pm))
+{
+    return zlecs;
+}
+
+/**/
+static zlong
+get_suffixactive(UNUSED(Param pm))
+{
+    return suffixlen;
+}
+
+/**/
 static char *
 get_cutbuffer(UNUSED(Param pm))
 {
-- 
2.5.0.234.gefc8a62

