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

Re: PATCH: command line highlighting



On Thu, 03 Apr 2008 16:11:13 +0200
Oliver Kiddle <okiddle@xxxxxxxxxxx> wrote:
> By the way, the documented feature that accepting a line does not save
> region_highlight doesn't appear to work. For me, the variable and the
> highlights are persisting.

I got confused.  region_highlight doesn't get unset when it goes out of
scope: this is standard behaviour for ZLE variables and we need the effect
to persist for the life of the command line here, too.  So it needs to be
reset explicitly.  Clearly it won't be valid for a new line.

(For that reason, history could be a bit of a nightmare to get right.)

> > We need to be able to see if a key is read within the time and if it is
> > unget it and return (like sit-for in Emacs).  Something like
> >   read -kt 1 && zle -U $REPLY
> > should work, but I haven't played around with it yet.
> 
> I had to add a call to "zle -R" so that it doesn't wait till the end of
> the widget to display the highlight but otherwise, that seems to work.
> An additional key typed in less than a second will remove the
> highlighting but that's actually fine.

Yes, that was deliberate.

Index: Src/Zle/zle_main.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_main.c,v
retrieving revision 1.106
diff -u -r1.106 zle_main.c
--- Src/Zle/zle_main.c	3 Apr 2008 15:20:30 -0000	1.106
+++ Src/Zle/zle_main.c	3 Apr 2008 15:23:51 -0000
@@ -1225,6 +1225,8 @@
     zleline = NULL;
     forget_edits();
     errno = old_errno;
+    /* highlight no longer valid */
+    set_region_highlight(NULL, NULL);
     return s;
 }
 
Index: Src/Zle/zle_refresh.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_refresh.c,v
retrieving revision 1.54
diff -u -r1.54 zle_refresh.c
--- Src/Zle/zle_refresh.c	3 Apr 2008 11:39:12 -0000	1.54
+++ Src/Zle/zle_refresh.c	3 Apr 2008 15:23:51 -0000
@@ -434,6 +434,11 @@
 }
 
 
+/*
+ * The parameter system requires the pm argument, but this
+ * may be NULL if called directly.
+ */
+
 /**/
 void
 set_region_highlight(UNUSED(Param pm), char **aval)

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070



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