40 lines
829 B
C
40 lines
829 B
C
/* nckey.c - displays the current key according to ncurses
|
|
EXEC:cc -Wall -Wextra -Wpedantic -pipe -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -o nckey nckey.c -lncurses -ltinfo:STOP */
|
|
|
|
#include <signal.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
#include <ncurses.h>
|
|
|
|
int
|
|
main (void)
|
|
{
|
|
int c, c2, run = 1;
|
|
initscr();
|
|
raw();
|
|
noecho();
|
|
notimeout(stdscr, TRUE);
|
|
keypad(stdscr, TRUE);
|
|
notimeout(stdscr, FALSE);
|
|
ESCDELAY = 0;
|
|
mvprintw(0, 0, "type q (113) to exit. everything is in decimal.");
|
|
while (run)
|
|
{
|
|
c = getch();
|
|
mvprintw(1, 0, " ");
|
|
if (c == 'q')
|
|
{ run = 0; }
|
|
if (c == 27)
|
|
{
|
|
mvprintw(1, 0, "ESC");
|
|
c2 = getch();
|
|
mvprintw(1, 4, "%.3d %c", c2, c2);
|
|
}
|
|
else
|
|
{ mvprintw(1, 0, "%.3d %c", c, c); }
|
|
refresh();
|
|
}
|
|
endwin();
|
|
}
|