20348: rejig WIDGETSTYLE and add WIDGETFUNC

This commit is contained in:
Peter Stephenson 2004-09-10 18:03:33 +00:00
parent 6f607e1098
commit b12c168505
3 changed files with 37 additions and 9 deletions

View file

@ -1,3 +1,8 @@
2004-09-10 Peter Stephenson <pws@csr.com>
* 20348: Doc/Zsh/zle.yo, Src/Zle/zle_params.c: Rejig WIDGETSTYLE
and add WIDGETFUNC.
2004-09-09 Peter Stephenson <pws@csr.com>
* 20332: Src/Zle/zle_params.c, Doc/Zsh/zle.yo: add WIDGETSTYLE zle

View file

@ -732,15 +732,21 @@ vindex(WIDGET)
item(tt(WIDGET) (scalar))(
The name of the widget currently being executed; read-only.
)
vindex(WIDGETFUNC)
item(tt(WIDGETFUNC) (scalar))(
The name of the shell function that implements a widget defined with
either tt(zle -N) or tt(zle -C). In the former case, this is the second
argument to the tt(zle -N) command that defined the widget, or
the first argument if there was no second argument. In the latter case
this is the the third argument to the tt(zle -C) command that defined the
widget. Read-only.
)
vindex(WIDGETSTYLE)
item(tt(WIDGET) (scalar))(
Describes the implementation behind the widget currently being executed;
the second argument that followed tt(zle -C) or tt(zle -N) when the widget
was defined, if any. If the widget was defined with tt(zle -N) and there was
no second argument this is the same as the first argument. Hence for
tt(zle -N) this gives the name of the function that implements the widget,
and for tt(zle -C) this gives the internal completion widget that defines
the type of completion. Read-only.
item(tt(WIDGETSTYLE) (scalar))(
Describes the implementation behind the completion widget currently being
executed; the second argument that followed tt(zle -C) when the widget was
defined. This is the name of a builtin completion widget. For widgets
defined with tt(zle -N) this is set to the empty string. Read-only.
)
enditem()

View file

@ -93,6 +93,8 @@ static struct zleparam {
zleunsetfn, NULL },
{ "WIDGET", PM_SCALAR | PM_READONLY, NULL, FN(get_widget),
zleunsetfn, NULL },
{ "WIDGETFUNC", PM_SCALAR | PM_READONLY, NULL, FN(get_widgetfunc),
zleunsetfn, NULL },
{ "WIDGETSTYLE", PM_SCALAR | PM_READONLY, NULL, FN(get_widgetstyle),
zleunsetfn, NULL },
{ NULL, 0, NULL, NULL, NULL, NULL }
@ -280,6 +282,21 @@ get_widget(UNUSED(Param pm))
return bindk->nam;
}
/**/
static char *
get_widgetfunc(UNUSED(Param pm))
{
Widget widget = bindk->widget;
int flags = widget->flags;
if (flags & WIDGET_INT)
return ".internal"; /* Don't see how this can ever be returned... */
else if (flags & WIDGET_NCOMP)
return widget->u.comp.func;
else
return widget->u.fnnam;
}
/**/
static char *
get_widgetstyle(UNUSED(Param pm))
@ -292,7 +309,7 @@ get_widgetstyle(UNUSED(Param pm))
else if (flags & WIDGET_NCOMP)
return widget->u.comp.wid;
else
return widget->u.fnnam;
return "";
}
/**/