diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2007-10-28 20:28:29 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2007-10-28 20:28:29 +0000 |
commit | 788320264e75e648d77ffc0c334fb66a751d69b7 (patch) | |
tree | 298ff4ea102f20c52f04644dc433f81566a99442 | |
parent | 0919edb315104469feb4ac13bdd224966bc32de6 (diff) | |
download | zsh-788320264e75e648d77ffc0c334fb66a751d69b7.tar.gz zsh-788320264e75e648d77ffc0c334fb66a751d69b7.tar.xz zsh-788320264e75e648d77ffc0c334fb66a751d69b7.zip |
add zcurses timeout
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | Doc/Zsh/mod_curses.yo | 11 | ||||
-rw-r--r-- | Src/Modules/curses.c | 30 |
3 files changed, 42 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog index fb09814a3..c221337a6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2007-10-28 Peter Stephenson <p.w.stephenson@ntlworld.com> + * 24028: Doc/Zsh/mod_curses.yo, Src/Modules/curses.c: + add "zcurses timeout". + * 24027: Doc/Zsh/mod_curses.yo, Src/Modules/curses.c: add "touch", subwindows, optimized "refresh". diff --git a/Doc/Zsh/mod_curses.yo b/Doc/Zsh/mod_curses.yo index b53238288..b88c7979b 100644 --- a/Doc/Zsh/mod_curses.yo +++ b/Doc/Zsh/mod_curses.yo @@ -23,7 +23,8 @@ xitem(tt(zcurses) tt(string) var(targetwin) var(string) ) xitem(tt(zcurses) tt(border) var(targetwin) var(border) )( xitem(tt(zcurses) tt(attr) var(targetwin) [ var({+/-}attribute) | var(fg_col)tt(/)var(bg_col) ] [...]) xitem(tt(zcurses) tt(scroll) [ tt(on) | tt(off) | {+/-}var(lines) ]) -item(tt(input) var(targetwin) [ var(param) [ var(kpparm) ] ])( +xitem(tt(zcurses) tt(input) var(targetwin) [ var(param) [ var(kpparm) ] ]) +item(tt(zcurses) tt(timeout) var(targetwin) var(intval))( Manipulate curses windows. All uses of this command should be bracketed by `tt(zcurses init)' to initialise use of curses, and `tt(zcurses end)' to end it; omitting `tt(zcurses end)' can cause @@ -125,6 +126,14 @@ with the prefix `tt(KEY_)' removed. Other keys cause a value to be set in var(param) as before. On a succesful return only one of var(param) or var(kpparm) contains a non-empty string; the other is set to an empty string. + +tt(timeout) specifies a timeout value for input from var(targetwin). +If var(intval) is negative, `tt(zcurses input)' waits indefinitely for +a character to be typed; this is the default. If var(intval) is zero, +`tt(zcurses input)' returns immediately; if there is typeahead it is +returned, else no input is done and status 1 is returned. If var(intval) +is positive, `tt(zcurses input)' waits var(intval) milliseconds for +input and if there is none at the end of that period returns status 1. ) enditem() diff --git a/Src/Modules/curses.c b/Src/Modules/curses.c index 0f9647fb9..063ac9014 100644 --- a/Src/Modules/curses.c +++ b/Src/Modules/curses.c @@ -562,7 +562,7 @@ zccmd_refresh(const char *nam, char **args) static int -zccmd_move(const char *nam, char **args) +zccmd_move(const char *nam, char **args) { int y, x; LinkNode node; @@ -936,6 +936,33 @@ zccmd_input(const char *nam, char **args) static int +zccmd_timeout(const char *nam, char **args) +{ + LinkNode node; + ZCWin w; + int to; + char *eptr; + + node = zcurses_validate_window(args[0], ZCURSES_USED); + if (node == NULL) { + zwarnnam(nam, "%s: %s", zcurses_strerror(zc_errno), args[0]); + return 1; + } + + w = (ZCWin)getdata(node); + + to = (int)zstrtol(args[1], &eptr, 10); + if (*eptr) { + zwarnnam(nam, "timeout requires an integer: %s", args[1]); + return 1; + } + + wtimeout(w->win, to); + return 0; +} + + +static int zccmd_position(const char *nam, char **args) { LinkNode node; @@ -1019,6 +1046,7 @@ bin_zcurses(char *nam, char **args, Options ops, UNUSED(int func)) {"attr", zccmd_attr, 2, -1}, {"scroll", zccmd_scroll, 2, 2}, {"input", zccmd_input, 1, 3}, + {"timeout", zccmd_timeout, 2, 2}, {"touch", zccmd_touch, 1, -1}, {NULL, (zccmd_t)0, 0, 0} }; |