zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] Include number of chars in zle unget mechanism in $PENDING calculation
@ 2017-03-01  1:25 Eric Freese
  2017-03-01  2:52 ` Bart Schaefer
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Freese @ 2017-03-01  1:25 UTC (permalink / raw)
  To: zsh-workers; +Cc: Eric Freese

Tested locally with the following:

  % self-insert() { echo "$PENDING" >> log; zle .self-insert -- $@ }
  % zle -N self-insert
  % foo() { zle -U "hello"; zle -U "world" }
  % zle -N foo
  % bindkey ^B foo

After pressing C-b, the buffer reads:

  worldhello

And the contents of log are:

  9
  8
  7
  6
  5
  4
  3
  2
  1
  0
---
 Src/Zle/zle_params.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Src/Zle/zle_params.c b/Src/Zle/zle_params.c
index 1e4c5b8..476e9a7 100644
--- a/Src/Zle/zle_params.c
+++ b/Src/Zle/zle_params.c
@@ -512,7 +512,7 @@ get_bufferlines(UNUSED(Param pm))
 static zlong
 get_pending(UNUSED(Param pm))
 {
-    return noquery(0);
+    return kungetct + noquery(0);
 }
 
 /**/
-- 
2.9.0


^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: [PATCH] Include number of chars in zle unget mechanism in $PENDING calculation
@ 2017-03-03 23:54 Eric Freese
  2017-03-04 14:53 ` Daniel Shahaf
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Freese @ 2017-03-03 23:54 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 2564 bytes --]

This looks great! Pulled it down and it solves my problem.

Would love to see this merged.

> How about...
>
> pws
>
> diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo
> index d68365b..b65e3be 100644
> --- a/Doc/Zsh/zle.yo
> +++ b/Doc/Zsh/zle.yo
> @@ -864,6 +864,12 @@ vindex(KEYS)
>  item(tt(KEYS) (scalar))(
>  The keys typed to invoke this widget, as a literal string; read-only.
>  )
> +vindex(KEYS_QUEUED_COUNT)
> +item(tt(KEYS_QUEUED_COUNT) (integer))(
> +The number of bytes pushed back to the input queue and therefore
> +available for reading immediately before any I/O is done; read-only.
> +See also tt(PENDING); the two values are distinct.
> +)
>  vindex(killring)
>  item(tt(killring) (array))(
>  The array of previously killed items, with the most recently killed
first.
> @@ -919,7 +925,8 @@ item(tt(PENDING) (integer))(
>  The number of bytes pending for input, i.e. the number of bytes which
have
>  already been typed and can immediately be read. On systems where the
shell
>  is not able to get this information, this parameter will always have a
> -value of zero.  Read-only.
> +value of zero.  Read-only.  See also tt(KEYS_QUEUED_COUNT); the two
> +values are distinct.
>  )
>  vindex(PREBUFFER)
>  item(tt(PREBUFFER) (scalar))(
> diff --git a/Src/Zle/zle_params.c b/Src/Zle/zle_params.c
> index 1e4c5b8..0a922d2 100644
> --- a/Src/Zle/zle_params.c
> +++ b/Src/Zle/zle_params.c
> @@ -85,6 +85,8 @@ static const struct gsu_integer cursor_gsu =
>  { get_cursor, set_cursor, zleunsetfn };
>  static const struct gsu_integer histno_gsu =
>  { get_histno, set_histno, zleunsetfn };
> +static const struct gsu_integer keys_queued_count_gsu =
> +{ get_keys_queued_count, NULL, zleunsetfn };
>  static const struct gsu_integer mark_gsu =
>  { get_mark, set_mark, zleunsetfn };
>  static const struct gsu_integer numeric_gsu =
> @@ -146,6 +148,8 @@ static struct zleparam {
>      { "HISTNO", PM_INTEGER, GSU(histno_gsu), NULL },
>      { "KEYMAP", PM_SCALAR | PM_READONLY, GSU(keymap_gsu), NULL },
>      { "KEYS", PM_SCALAR | PM_READONLY, GSU(keys_gsu), NULL },
> +    { "KEYS_QUEUED_COUNT", PM_INTEGER | PM_READONLY,
GSU(keys_queued_count_gsu),
> +      NULL},
>      { "killring", PM_ARRAY, GSU(killring_gsu), NULL },
>      { "LASTABORTEDSEARCH", PM_SCALAR | PM_READONLY,
GSU(lastabortedsearch_gsu),
>        NULL },
> @@ -458,6 +462,13 @@ get_keys(UNUSED(Param pm))
>  }
>
>  /**/
> +static zlong
> +get_keys_queued_count(UNUSED(Param pm))
> +{
> +    return kungetct;
> +}
> +
> +/**/
>  static void
>  set_numeric(UNUSED(Param pm), zlong x)
>  {

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-03-04 14:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-01  1:25 [PATCH] Include number of chars in zle unget mechanism in $PENDING calculation Eric Freese
2017-03-01  2:52 ` Bart Schaefer
2017-03-01  3:51   ` Eric Freese
2017-03-02 14:31     ` Peter Stephenson
2017-03-01 14:41   ` Eric Freese
2017-03-03 23:54 Eric Freese
2017-03-04 14:53 ` Daniel Shahaf

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).