From 5469f5fbacc59303b4c33166a656ce52d1ea4fa5 Mon Sep 17 00:00:00 2001 From: Emil Date: Sun, 24 Sep 2023 05:19:25 +0000 Subject: [PATCH] init --- README | 2 ++ nckey.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 README create mode 100644 nckey.c diff --git a/README b/README new file mode 100644 index 0000000..6187b01 --- /dev/null +++ b/README @@ -0,0 +1,2 @@ +Use baked or the command specified in the file (see `head -2 nckey.c'). +Public Domain. Now I can remove it from my hard drive. diff --git a/nckey.c b/nckey.c new file mode 100644 index 0000000..3b79f2d --- /dev/null +++ b/nckey.c @@ -0,0 +1,39 @@ +/* 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 +#include +#include +#include +#include + +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(); +}