[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: notimeout() function
From: |
Thomas Dickey |
Subject: |
Re: notimeout() function |
Date: |
Sun, 05 Mar 2006 15:04:39 -0500 |
User-agent: |
Mutt/1.5.11+cvs20060126 |
On Thu, Feb 23, 2006 at 02:33:07PM -0800, Dan Gookin wrote:
> I'm running some tests on the notimeout() function and haven't noticed
> any real difference between the TRUE and FALSE states. I've turned on
> keypad() for the window, and with keypad() on, the delay is very
> noticeable. But when notimeout(win,TRUE) is set, the same delay
> happens. I believe, according to the documentation, that the TRUE
> state should disable the delay after the Esc key is pressed.
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 isto
differentiate between sequences received from a function key and those
typed by a user.
It sounds as if it should, but reading the code (this dates back quite a
while), I see that notimeout is only checked near the beginning of
wgetch(), when it is checking if there is data - the first character in
an input escape sequence - it's not going to stop it in the middle of an
escape sequence.
If there is no data in the input buffer (fifo), ncurses sets a timeout
unless notimeout is set.
Furthermore, there are two other variables that it checks before
deciding to do the timeout, set by these calls:
nodelay(win, TRUE);
halfdelay(1);
Either of those calls will make that initial timeout in wgetch() become
very small, so it returns an ERR.
There are actually 3 places that I see which are doing timeouts in the
code (via a function misleadingly named check_mouse_activity()):
a) the timeout controlled by notimeout/nodelay/halfdelay.
b) a timeout within the mouse-click code
c) the timeout used to terminate an escape sequence (which is
actually set by ESCDELAY).
>
> Does the ESCDELAY environment variable affect the delay? Or is the
Yes, that does affect it.
> delay set internally by NCurses? Or is there something else I'm
> missing? Here is the code I'm using to test:
>
> keypad(stdscr,TRUE);
> notimeout(stdscr,FALSE);
> addstr("Press the Esc key and note the delay:\n");
> refresh();
> wgetnstr(stdscr,input,79);
>
> notimeout(stdscr,TRUE);
> addstr("\nNow with notimeout TRUE, press Esc:\n");
> refresh();
> wgetnstr(stdscr,input,79);
>
> This is NCurses 5.4 on OS X 10.4.5
I checked back to 5.0, and it's the same behavior.
--
Thomas E. Dickey <address@hidden>
http://invisible-island.net
ftp://invisible-island.net
signature.asc
Description: Digital signature