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

PATCH: $PENDING



We were discussing this some time ago.

This patchlet adds the zle special parameter $PENDING which uses
FIONREAD, if available, to return the number of bytes pending to be
read.

I've changed i-c-w to use it, but didn't change predict-on.

Or is this one of the cases where I should have asked before
commiting?


Bye
 Sven

Index: Doc/Zsh/zle.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/zle.yo,v
retrieving revision 1.2
diff -u -r1.2 zle.yo
--- Doc/Zsh/zle.yo	2000/04/01 20:43:44	1.2
+++ Doc/Zsh/zle.yo	2000/04/05 08:32:37
@@ -185,6 +185,12 @@
 item(tt(HISTNO) (integer))(
 The current history number.
 )
+vindex(PENDING)
+item(tt(PENDING) (integer))(
+The number of bytes pending for input. On systems where the shell is
+not able to get this information, this parameter will always have a
+value of zero.
+)
 enditem()
 sect(Standard Widgets)
 cindex(widgets, standard)
Index: Functions/Zle/incremental-complete-word
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/Zle/incremental-complete-word,v
retrieving revision 1.2
diff -u -r1.2 incremental-complete-word
--- Functions/Zle/incremental-complete-word	2000/04/01 20:49:47	1.2
+++ Functions/Zle/incremental-complete-word	2000/04/05 08:32:37
@@ -75,27 +75,31 @@
     else
       LBUFFER="$LBUFFER$key"
     fi
-    lastl="$LBUFFER"
-    lastr="$RBUFFER"
-    [[ "$twid" = "$wid" ]] && comppostfuncs=( "$post[@]" )
-    toolong=''
-    zle $twid "$@"
-    LBUFFER="$lastl"
-    RBUFFER="$lastr"
-    num=$_lastcomp[nmatches]
-    if (( ! num )); then
-      word=''
-      state='-no match-'
-    elif [[ "${LBUFFER}${RBUFFER}" = *${_lastcomp[unambiguous]}* ]]; then
-      word=''
-      state='-no prefix-'
+    if (( ! PENDING )); then
+      lastl="$LBUFFER"
+      lastr="$RBUFFER"
+      [[ "$twid" = "$wid" ]] && comppostfuncs=( "$post[@]" )
+      toolong=''
+      zle $twid "$@"
+      LBUFFER="$lastl"
+      RBUFFER="$lastr"
+      num=$_lastcomp[nmatches]
+      if (( ! num )); then
+        word=''
+        state='-no match-'
+      elif [[ "${LBUFFER}${RBUFFER}" = *${_lastcomp[unambiguous]}* ]]; then
+        word=''
+        state='-no prefix-'
+      else
+        word="${_lastcomp[unambiguous]}"
+        state=''
+      fi
+      zformat -f pstr "$pmpt" "u:${word}" "s:$state" "n:$num" \
+                              "l:$toolong" "c:${_lastcomp[completer][2,-1]}"
+      zle -R "$pstr"
     else
-      word="${_lastcomp[unambiguous]}"
-      state=''
+      zle -R
     fi
-    zformat -f pstr "$pmpt" "u:${word}" "s:$state" "n:$num" \
-                            "l:$toolong" "c:${_lastcomp[completer][2,-1]}"
-    zle -R "$pstr"
     read -k key
   done
 
Index: Src/utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/utils.c,v
retrieving revision 1.1.1.59
diff -u -r1.1.1.59 utils.c
--- Src/utils.c	2000/03/10 01:13:54	1.1.1.59
+++ Src/utils.c	2000/04/05 08:32:38
@@ -1315,7 +1315,7 @@
 }
 
 /**/
-int
+mod_export int
 noquery(int purge)
 {
     int c, val = 0;
Index: Src/Zle/zle_params.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_params.c,v
retrieving revision 1.1.1.16
diff -u -r1.1.1.16 zle_params.c
--- Src/Zle/zle_params.c	2000/03/13 17:00:54	1.1.1.16
+++ Src/Zle/zle_params.c	2000/04/05 08:32:38
@@ -77,6 +77,8 @@
         zleunsetfn, NULL },
     { "BUFFERLINES", PM_INTEGER | PM_READONLY, NULL, FN(get_bufferlines),
         zleunsetfn, NULL },
+    { "PENDING", PM_INTEGER | PM_READONLY, NULL, FN(get_pending),
+        zleunsetfn, NULL },
     { NULL, 0, NULL, NULL, NULL, NULL }
 };
 
@@ -314,4 +316,11 @@
 get_bufferlines(Param pm)
 {
     return nlnct;
+}
+
+/**/
+static zlong
+get_pending(Param pm)
+{
+    return noquery(0);
 }

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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