bug-ncurses
[Top][All Lists]
Advanced

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

Re: nodelay(...), not working with get_wch


From: G. Branden Robinson
Subject: Re: nodelay(...), not working with get_wch
Date: Sat, 6 Jul 2024 07:26:00 -0500

Hi Giorgos,

At 2024-07-06T11:42:53+0300, Giorgos Xou wrote:
> Here's an example:
> 
> #include <ncurses.h>
> 
> int main (int argc, char ** argv)
> {
>   wint_t ch;
>   // int ch;
> 
>   initscr();
>   noecho();
>   nodelay(stdscr, true);
>   refresh();
> 
>   while (true) {
>     get_wch(&ch); // It should return -1 but it doesn't

Observe that even if it did "return -1", you're _not checking this
function's return value_.  You're discarding it.

There are two complicating factors that promote confusion here:

1.  As I noted in a patch last month to this list, some curses man pages
    have been sloppy about what constitute return values in C.

    * Don't refer to a function's modification of its arguments (those
      passed by reference) as "returning" them.  (X/Open Curses didn't
      do this, but Solaris 2.3 did, ...

2.  The narrow and wide curses APIs are not symmetric in this respect.

     Unlike wgetch(3NCURSES), wget_wch and its variants store the value
     of the input character in an additional wch parameter instead of
     the return value.

     Unlike ungetch, unget_wch cannot distinguish function key codes
     from conventional character codes.  An application can overcome
     this limitation by pushing function key codes with ungetch and
     subsequently checking the return value of wget_wch for a match with
     KEY_CODE_YES.

These clarifications were made in time for the ncurses 6.5 release.

Regards,
Branden

Attachment: signature.asc
Description: PGP signature


reply via email to

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