Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: Add $OVERSTRIKE in zle widgets
- X-seq: zsh-workers 28117
- From: Frank Terbeck <ft@xxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: PATCH: Add $OVERSTRIKE in zle widgets
- Date: Tue, 3 Aug 2010 02:57:33 +0200
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
I recently started using vi mode in zle. I'm dynamically setting
$psvar[1] to either "i" or "c" and use `reset-prompt' to redraw the
prompt via `zle-keymap-select'.
I wanted to have "r" displayed if `vi-replace' was used to put zle in
overstrike mode. I couldn't come up with an easy solution, though.
This adds a read-only integer parameter `$OVERSTRIKE' to the set of
special parameters available in zle-widgets. Since `zle-keymap-select'
is a widget, it has access to the parameter. That makes it trivial to
set $psvar[1] to "r" if zle is in overstrike mode.
Do others think that's useful enough to have in zsh?
Regards, Frank
---
Doc/Zsh/zle.yo | 4 ++++
Src/Zle/zle_params.c | 10 ++++++++++
2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo
index 0e2fea5..a1a5092 100644
--- a/Doc/Zsh/zle.yo
+++ b/Doc/Zsh/zle.yo
@@ -754,6 +754,10 @@ called with the tt(zle) builtin command will use the value
assigned. If it is unset inside a widget function, builtin widgets
called behave as if no numeric argument was given.
)
+vindex(OVERSTRIKE)
+item(tt(OVERSTRIKE) (integer))(
+Non-zero if tt(zle) is in overstrike mode; zero otherwise. Read-only.
+)
vindex(PENDING)
item(tt(PENDING) (integer))(
The number of bytes pending for input, i.e. the number of bytes which have
diff --git a/Src/Zle/zle_params.c b/Src/Zle/zle_params.c
index 2883c0f..2c598f1 100644
--- a/Src/Zle/zle_params.c
+++ b/Src/Zle/zle_params.c
@@ -87,6 +87,8 @@ static const struct gsu_integer mark_gsu =
{ get_mark, set_mark, zleunsetfn };
static const struct gsu_integer numeric_gsu =
{ get_numeric, set_numeric, unset_numeric };
+static const struct gsu_integer overstrike_gsu =
+{ get_overstrike, NULL, zleunsetfn };
static const struct gsu_integer pending_gsu =
{ get_pending, NULL, zleunsetfn };
static const struct gsu_integer region_active_gsu =
@@ -124,6 +126,7 @@ static struct zleparam {
{ "LBUFFER", PM_SCALAR, GSU(lbuffer_gsu), NULL },
{ "MARK", PM_INTEGER, GSU(mark_gsu), NULL },
{ "NUMERIC", PM_INTEGER | PM_UNSET, GSU(numeric_gsu), NULL },
+ { "OVERSTRIKE", PM_INTEGER | PM_READONLY, GSU(overstrike_gsu), NULL },
{ "PENDING", PM_INTEGER | PM_READONLY, GSU(pending_gsu), NULL },
{ "POSTDISPLAY", PM_SCALAR, GSU(postdisplay_gsu), NULL },
{ "PREBUFFER", PM_SCALAR | PM_READONLY, GSU(prebuffer_gsu), NULL },
@@ -459,6 +462,13 @@ get_bufferlines(UNUSED(Param pm))
/**/
static zlong
+get_overstrike(UNUSED(Param pm))
+{
+ return !insmode;
+}
+
+/**/
+static zlong
get_pending(UNUSED(Param pm))
{
return noquery(0);
--
1.7.2.rc2
Messages sorted by:
Reverse Date,
Date,
Thread,
Author