Mercurial > hg > octave-avbm
changeset 3658:808f399398c9
[project @ 2000-04-11 19:45:44 by jwe]
author | jwe |
---|---|
date | Tue, 11 Apr 2000 19:45:44 +0000 |
parents | a908150a3a32 |
children | e68976912bb5 |
files | src/ChangeLog src/sysdep.cc |
diffstat | 2 files changed, 21 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2000-04-11 John W. Eaton <jwe@bevo.che.wisc.edu> + + * sysdep.cc (kbhit): Also clear cin if at EOF. + 2000-04-11 Joao Cardoso <jcardoso@inescn.pt> * sysdep.cc (kbhit): New arg, wait.
--- a/src/sysdep.cc +++ b/src/sysdep.cc @@ -215,10 +215,7 @@ #if defined (ONLRET) s.c_oflag &= ~(ONLRET); #endif - if (wait) - s.c_cc[VMIN] = 1; - else - s.c_cc[VMIN] = 0; + s.c_cc[VMIN] = wait ? 1 : 0; s.c_cc[VTIME] = 0; } else @@ -227,6 +224,7 @@ s = save_term; } + tcsetattr (tty_fd, TCSAFLUSH, &s); } #elif defined (HAVE_TERMIO_H) @@ -260,11 +258,7 @@ #if defined (ONLRET) s.c_oflag &= ~(ONLRET); #endif - if (wait) - s.c_cc[VMIN] = 1; - else - s.c_cc[VMIN] = 0; - s.c_cc[VTIME] = 0; + s.c_cc[VMIN] = wait ? 1 : 0; } else { @@ -272,6 +266,7 @@ s = save_term; } + ioctl (tty_fd, TCSETAW, &s); } #elif defined (HAVE_SGTTY_H) @@ -303,6 +298,7 @@ s = save_term; } + ioctl (tty_fd, TIOCSETN, &s); } #else @@ -317,12 +313,15 @@ int kbhit (bool wait) { - int c; - raw_mode (1, wait); - c = std::cin.get (); - if (std::cin.fail()) - std::cin.clear (); - raw_mode (0, 1); + raw_mode (true, wait); + + int c = std::cin.get (); + + if (std::cin.fail () || std::cin.eof ()) + std::cin.clear (); + + raw_mode (false, true); + return c; } @@ -431,19 +430,12 @@ // XXX FIXME XXX -- add timeout and default value args? - int nargin = args.length (); - if (interactive) { - int c; + int c = kbhit (args.length () == 0); - if (nargin == 1) - c = kbhit (false); - else - c = kbhit (true); - - if (c == -1) - c = 0; + if (c == -1) + c = 0; char *s = new char [2]; s[0] = c;