Mercurial > hg > octave-terminal
changeset 475:28167349d46a
[project @ 1994-06-21 21:08:12 by jwe]
author | jwe |
---|---|
date | Tue, 21 Jun 1994 21:08:12 +0000 |
parents | 4e6f2e50e173 |
children | de9de43ad21f |
files | src/g-builtins.cc |
diffstat | 1 files changed, 39 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/g-builtins.cc +++ b/src/g-builtins.cc @@ -1055,6 +1055,26 @@ return retval; } +tree_constant * +builtin_kbhit (const tree_constant *args, int nargin, int nargout) +{ + tree_constant *retval = NULL_TREE_CONST; + +// XXX FIXME XXX -- add timeout and default value args? + + if (interactive) + { + int c = kbhit (); + char *s = new char [2]; + s[0] = c; + s[1] = '\0'; + retval = new tree_constant [2]; + retval [0] = tree_constant (s); + } + + return retval; +} + /* * Maybe help in debugging. */ @@ -1281,6 +1301,8 @@ tree_constant * builtin_pause (const tree_constant *args, int nargin, int nargout) { + tree_constant *retval = NULL_TREE_CONST; + if (! (nargin == 1 || nargin == 2)) { print_usage ("pause"); @@ -1289,13 +1311,25 @@ if (interactive) { - if (nargin == 2) - sleep (NINT (args[1].double_value ())); - else if (kbhit () == EOF) - clean_up_and_exit (0); + switch (nargin) + { + case 2: + { + int delay = NINT (args[1].double_value ()); + if (delay > 0) + { + sleep (delay); + break; + } + } + default: + if (kbhit () == EOF) + clean_up_and_exit (0); + break; + } } - return NULL_TREE_CONST; + return retval; } /*