1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-03 10:21:46 +02:00

zsh-workers/10117

This commit is contained in:
Tanaka Akira 2000-03-13 17:00:37 +00:00
parent 336ba32a43
commit 1dbb0b4247
3 changed files with 43 additions and 11 deletions

View file

@ -184,7 +184,8 @@ xitem(tt(zle) tt(-C) var(widget) var(completion-widget) var(function))
xitem(tt(zle) tt(-R) [ tt(-c) ] [ var(display-string) ] [ var(string) ... ])
xitem(tt(zle) tt(-M) var(string))
xitem(tt(zle) tt(-U) var(string))
item(tt(zle) var(widget) tt([ -n) var(num) tt(]) tt([ -N ]) var(args) ...)(
xitem(tt(zle) var(widget) tt([ -n) var(num) tt(]) tt([ -N ]) var(args) ...)
item(tt(zle))(
The tt(zle) builtin performs a number of different actions concerning
ZLE. Which operation it performs depends on its options:
@ -289,5 +290,9 @@ tt(zle) command. Thus if a user defined widget requires an immediate beep,
it should call the tt(beep) widget directly.
)
enditem()
With no options and no arguments, only the returns status will be
set. It is zero if ZLE is currently active and widgets could be
invoked using this builtin command and non-zero if ZLE is not active.
)
enditem()

View file

@ -57,6 +57,8 @@ static struct zleparam {
zleunsetfn, NULL },
{ "CURSOR", PM_INTEGER, FN(set_cursor), FN(get_cursor),
zleunsetfn, NULL },
{ "MARK", PM_INTEGER, FN(set_mark), FN(get_mark),
zleunsetfn, NULL },
{ "LBUFFER", PM_SCALAR, FN(set_lbuffer), FN(get_lbuffer),
zleunsetfn, NULL },
{ "RBUFFER", PM_SCALAR, FN(set_rbuffer), FN(get_rbuffer),
@ -171,6 +173,25 @@ get_cursor(Param pm)
return cs;
}
/**/
static void
set_mark(Param pm, zlong x)
{
if (x < 0)
mark = 0;
else if (x > ll)
mark = ll;
else
mark = x;
}
/**/
static zlong
get_mark(Param pm)
{
return mark;
}
/**/
static void
set_lbuffer(Param pm, char *x)

View file

@ -434,7 +434,13 @@ bin_zle_refresh(char *name, char **args, char *ops, char func)
static int
bin_zle_mesg(char *name, char **args, char *ops, char func)
{
if (!zleactive) {
zerrnam(name, "can only be called from widget function", NULL, 0);
return 1;
}
showmsg(*args);
if (sfcontext != SFC_WIDGET)
zrefresh();
return 0;
}
@ -442,14 +448,14 @@ bin_zle_mesg(char *name, char **args, char *ops, char func)
static int
bin_zle_unget(char *name, char **args, char *ops, char func)
{
char *p = *args;
char *b = *args, *p = b + strlen(b);
if (!zleactive) {
zerrnam(name, "can only be called from widget function", NULL, 0);
return 1;
}
while (*p)
ungetkey((int) *p++);
while (p > b)
ungetkey((int) *--p);
return 0;
}
@ -589,18 +595,18 @@ bin_zle_call(char *name, char **args, char *ops, char func)
int ret, saveflag = 0;
char *wname = *args++;
if(!zleactive || incompctlfunc || incompfunc) {
if (!wname) {
if (saveflag)
zmod = modsave;
return (!zleactive || incompctlfunc || incompfunc ||
sfcontext != SFC_WIDGET);
}
if(!zleactive || incompctlfunc || incompfunc || sfcontext != SFC_WIDGET) {
zerrnam(name, "widgets can only be called when ZLE is active",
NULL, 0);
return 1;
}
if (!wname) {
zwarnnam(name, "wrong number of arguments", NULL, 0);
if (saveflag)
zmod = modsave;
return 1;
}
while (*args && **args == '-') {
char *num;
if (!args[0][1] || args[0][1] == '-') {