bug-ncurses
[Top][All Lists]
Advanced

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

raw() ignored while in getnstr()


From: Bill Gray
Subject: raw() ignored while in getnstr()
Date: Fri, 14 May 2021 23:24:59 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1

   Not sure if this is a bug,  peculiarity,  or feature.

   At least on my Xubuntu 20.04 box,  raw() ensures that Ctrl-C is
not caught as an interrupt causing immediate shutdown.  The exception
is when we're in getnstr().  Run the following minimal example,  and
you can hit keys and get their ASCII values on the screen,  including
Ctrl-C,  with no shutdown.

   Hit 'q',  and the program asks you to enter some text,  using
getnstr().  At this point,  even though raw() is set,  Ctrl-C aborts.
This happens in xterm and the Linux console.

   PDCurses doesn't do this (raw() means raw(),  even in getnstr()).
Is there some reason ncurses behaves this way?

Thanks!           -- Bill

#include <stdlib.h>
#include <string.h>
#include <curses.h>

int main( const int argc, const char *argv[])
{
    char text[80], c = 0;

    initscr();
    cbreak( );
    noecho( );
    clear( );
    raw( );
    keypad( stdscr, 1);
    mvaddstr( 4, 2, "Hit Ctrl-C and the program won't abort.");
    while( c != 'q')
        {
        c = getch( );
        sprintf( text, "%d (%c)  ", c, c);
        mvaddstr( 5, 2, text);
        }
    mvaddstr( 4, 2, "Hit Ctrl-C and the program will now abort.");
    mvaddstr( 5, 2, "Enter some text below:");
    move( 6, 2);
    echo( );
    getnstr( text, sizeof( text) - 1);
    endwin( );
    return( 0);
}



reply via email to

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