Reputation: 633
My situation:
char str [41];
wgetnstr(contentWin, str, 40);
I want be able to catch F2 key in this moment. I think about catch character, then compare and then (if != F2) put it in to the terminal and str without using wgetnstr().
Is there different (easier) way? Thanks :-).
Upvotes: 3
Views: 1693
Reputation: 6018
Not that I know of. You might want to create your own function that is similar to wgetnstr()
that does the checking for F2 etc....
You could base the function on the following code which captures F2.
#include <ncurses.h>
int main()
{
int ch;
initscr(); /* Start curses mode */
raw(); /* Line buffering disabled */
keypad(stdscr, TRUE); /* We get F1, F2 etc.. */
noecho(); /* Don't echo() while we do getch */
while( (ch = wgetch(stdscr) ) != KEY_F(2))
{
printw("Key code: %u Key: %c\n", ch, ch);
refresh(); /* Print it on to the real screen */
}
endwin(); /* End curses mode */
printf("F2 pressed .. program exiting\n");
return(0);
}
Upvotes: 1