From a8609ccd901b1942e862c14205026d841e640add Mon Sep 17 00:00:00 2001 From: EliteTK Date: Thu, 10 Jul 2014 22:35:35 +0100 Subject: More stuff. --- ncurses.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 ncurses.c (limited to 'ncurses.c') diff --git a/ncurses.c b/ncurses.c new file mode 100644 index 0000000..ad7dced --- /dev/null +++ b/ncurses.c @@ -0,0 +1,32 @@ +#include + +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 */ + + printw("Type any character to see it in bold\n"); + ch = getch(); /* If raw() hadn't been called + * we have to press enter before it + * gets to the program */ + if(ch == KEY_F(1)) /* Without keypad enabled this will */ + printw("F1 Key pressed");/* not get to us either */ + /* Without noecho() some ugly escape + * charachters might have been printed + * on screen */ + else + { printw("The pressed key is "); + attron(A_BOLD); + printw("%c", ch); + attroff(A_BOLD); + } + refresh(); /* Print it on to the real screen */ + getch(); /* Wait for user input */ + endwin(); /* End curses mode */ + + return 0; +} -- cgit v1.2.3-54-g00ecf