简体   繁体   中英

cin.ignore equivalent in `ncurses`

I have this much cleaner variant to system("Pause") that waits for the user to press enter:

#include <iostream>
void pause()
{
    std::cin.get();
    std::cin.ignore();
}

However, I couldn't find a clean variant to system("CLS") (or system("clear") ), so I switched the whole application to ncurses . After some reading I found out that ncurses has its own set of I/O functions and that std::cout and std::cin got replaced with echo() and getch() .

That function pause() also has to be converted to ncurses , but my problem is that I don't know the correct equivalent to std::cin.ignore .

You can discard input in curses using these functions (not just ncurses):

  • flushinp

    The flushinp routine throws away any typeahead that has been typed by the user and has not yet been read by the program.

  • intrflush

    If the intrflush option is enabled ( bf is TRUE), and an interrupt key is pressed on the keyboard (interrupt, break, quit), all output in the tty driver queue will be flushed, giving the effect of faster response to the interrupt, but causing curses to have the wrong idea of what is on the screen. Disabling the option ( bf is FALSE) prevents the flush. The default for the option is inherited from the tty driver settings. The window argument is ignored.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM