PDcurses: kbhit()


I managed to successfully install PDcurses, and am now faced with an interesting problem:

getch() is defined by curses, so no problem.

kbhit() is not used with curses, so... I'm stuck...

I want to have the functionality I had with conio.h, and I assume that there must be a substitute for kbhit(), since they emplemented getch() in the header.

Thanks for your help...

PS: this is because I want to clear the getch() stream. Do I need to clear the stream with curses? Also, the sbstitute for kbhit() would be nice for future reference, even if I don't need to clear the stream...
Last edited on
closed account (Dy7SLyTq)
a) getch() is implemented in curses like a lot of things. its not taken from conio.

b) if you really want it, i would make your own or...
c)use what curses has provided and use the multiple functions its provided for more functionality

http://www.tldp.org/HOWTO/NCURSES-Programming-HOWTO/helloworld.html

it uses ncurses but if i remember correctly pd curses is just the windows equiv
Will Ncurses getch() keep getting stuff from the buffer like the one from conio?

Ex: I press 'n' twice, and it regesters it, but with the conio version, it will get the second 'n' upon the next call, without user input.
closed account (Dy7SLyTq)
yeah thats how input functions work
How can I flush the buffer then?

I used to do it like this:

1
2
3
4
while(_kbhit())
{
    _getch();
}
Last edited on
closed account (Dy7SLyTq)
i dont know actually. i use c++ now and never ran into that when writing c
... you never had getch() skip the input prompt and just grab, from the buffer, the last character pressed??
closed account (Dy7SLyTq)
no because i either used scanf or unbuffered input
ooo... thanks for the help.

BTW, do you use PDcurses??
closed account (Dy7SLyTq)
not pd. i use ncurses on linux, but if im doing stuff windows ill either use the sdl, boost, or win32 api
hmm... I use boost.

Does boost have similar functions to curses?
Last edited on
closed account (Dy7SLyTq)
no... i believe in the heard but not seen paradigm from unix. the console program provides no interface unless there is an error. boost and *curses are two very different things. in this time and age i dont recommend building interfaces on a console. instead learn guis
Topic archived. No new replies allowed.