summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikael Magnusson <mikachu@gmail.com>2015-12-16 06:51:54 +0100
committerMikael Magnusson <mikachu@gmail.com>2015-12-19 13:21:12 +0100
commitc3ea3ffa730037714fd1bb23b6fc1174b379368f (patch)
treefb2c46c01057bbdcbe02b8ce1254416bd5399248
parent1f2bdc2aa27141eb41f7b0765d79020b6af8bbd0 (diff)
downloadzsh-c3ea3ffa730037714fd1bb23b6fc1174b379368f.tar.gz
zsh-c3ea3ffa730037714fd1bb23b6fc1174b379368f.zip
36650: Add zle-line-pre-redraw hook for highlighting
-rw-r--r--ChangeLog5
-rw-r--r--Doc/Zsh/zle.yo5
-rw-r--r--Src/Zle/zle_main.c31
3 files changed, 40 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 54248963f..26add1966 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-12-19 Mikael Magnusson <mikachu@gmail.com>
+
+ * 36650: Doc/Zsh/zle.yo, Src/Zle/zle_main.c: Add
+ zle-line-pre-redraw hook for highlighting
+
2015-12-19 Daniel Shahaf <d.s@daniel.shahaf.name>
* unposted (after users/20873): Functions/Zle/edit-command-line:
diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo
index 7047b43d9..9c4623247 100644
--- a/Doc/Zsh/zle.yo
+++ b/Doc/Zsh/zle.yo
@@ -1087,6 +1087,11 @@ widget:
example(zle-isearch-exit+LPAR()RPAR() { zle -M ""; }
zle -N zle-isearch-exit)
)
+tindex(zle-line-pre-redraw)
+item(tt(zle-line-pre-redraw))(
+Executed whenever the input line is about to be redrawn, providing an
+opportunity to update the region_highlight array.
+)
tindex(zle-line-init)
item(tt(zle-line-init))(
Executed every time the line editor is started to read a new line
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index 1f0c07df4..7862d48fb 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -1025,6 +1025,31 @@ getrestchar(int inchar, char *outstr, int *outcount)
/**/
#endif
+static void redrawhook()
+{
+ Thingy initthingy;
+ if ((initthingy = rthingy_nocreate("zle-line-pre-redraw"))) {
+ int lastcmd_prev = lastcmd;
+ int old_incompfunc = incompfunc;
+ char *args[2];
+ Thingy lbindk_save = lbindk, bindk_save = bindk;
+ refthingy(lbindk_save);
+ refthingy(bindk_save);
+ args[0] = initthingy->nam;
+ args[1] = NULL;
+ incompfunc = 0;
+ execzlefunc(initthingy, args, 0);
+ incompfunc = old_incompfunc;
+ unrefthingy(initthingy);
+ unrefthingy(lbindk);
+ unrefthingy(bindk);
+ lbindk = lbindk_save;
+ bindk = bindk_save;
+ /* we can't set ZLE_NOTCOMMAND since it's not a legit widget, so
+ * restore lastcmd manually so that we don't mess up the global state */
+ lastcmd = lastcmd_prev;
+ }
+}
/**/
void
@@ -1084,6 +1109,8 @@ zlecore(void)
errflag |= ERRFLAG_ERROR;
break;
}
+
+ redrawhook();
#ifdef HAVE_POLL
if (baud && !(lastcmd & ZLE_MENUCMP)) {
struct pollfd pfd;
@@ -1113,6 +1140,7 @@ zlecore(void)
zrefresh();
freeheap();
+
}
region_active = 0;
@@ -1191,7 +1219,7 @@ zleread(char **lp, char **rp, int flags, int context, char *init, char *finish)
vistartchange = -1;
zleline = (ZLE_STRING_T)zalloc(((linesz = 256) + 2) * ZLE_CHAR_SIZE);
*zleline = ZWC('\0');
- virangeflag = lastcmd = done = zlecs = zlell = mark = 0;
+ virangeflag = lastcmd = done = zlecs = zlell = mark = yankb = yanke = 0;
vichgflag = 0;
viinsbegin = 0;
statusline = NULL;
@@ -1812,6 +1840,7 @@ recursiveedit(UNUSED(char **args))
{
int locerror;
+ redrawhook();
zrefresh();
zlecore();