bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[NCURSES/Linux] Are timeout() and notimeout() working?


From: Vincenzo Romano
Subject: [NCURSES/Linux] Are timeout() and notimeout() working?
Date: Fri, 20 Feb 2009 10:26:20 +0100

Hi.

I think the notimeout() call is not working properly, at least in xterm
and linux terminal types. I hope I'm wrong.

I'm trying to read and interpret escape sequences. To do so I need to
set the timeout for escape sequences to (almost) zero, otherwise I can
be fooled by ESC key autorepeat, for example.

Accordingly to the documentation:
While interpreting an input escape sequence, wgetch sets a timer while
waiting for the next character. If notimeout(win, TRUE) is called, then
wgetch does not set a timer. The purpose of the timeout is to
differentiate between sequences received from a function key and those
typed by a user.
And:
The timeout and wtimeout routines set blocking or non-blocking read for
a given window. If delay is negative, blocking read is used (i.e., waits
indefinitely for input). If delay is zero, then non-blocking read is
used (i.e., read returns ERR if no input is waiting). If delay is
positive, then read  blocks  for  delay  milliseconds, and returns ERR
if there is still no input. Hence, these routines provide the same
functionality as nodelay, plus the additional capability of being able
to block for only delay milliseconds (where delay is positive).

In the attached fragment I would expect the program to exit as soon as
the ESC key is hit with a kind of prop rotating during the wait.
What actually happens is that the wgetch() just waits for a key press,
as shown by the exit value.

Things become "almost normal" if I call notimeout(win, FALSE).
In this case the first wgetch() doesn't block, but the program will have
a small (1 sec?) delay before exiting.

Now, while the gnome-terminal xterm implementation could be buggy, I
cannot thing about a bug in the text-mode Linux console "linux" terminal
type.

And, aside of these questions, is there a way to read the arrow keys
pressed along with the shift key?


-- 
Vincenzo Romano
NotOrAnd Information Technologies
cel. +39 339 8083886  | gtalk. address@hidden
fix. +39 0823 454163  | skype. notorand.it
fax. +39 02 700506964 | msn.   notorand.it
<Non quietis maribus nauta peritus>

Attachment: p.c
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]