From 083b0b53e450f317ca6e99cc1d077b10a5ac7d4d Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Mon, 28 Oct 2024 02:18:06 +0100 Subject: Add a new article on termios --- src/blog/termios/test.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/blog/termios/test.c (limited to 'src/blog/termios/test.c') diff --git a/src/blog/termios/test.c b/src/blog/termios/test.c new file mode 100644 index 0000000..dcb93d1 --- /dev/null +++ b/src/blog/termios/test.c @@ -0,0 +1,21 @@ +#include +#include +#include + +int +main(void) +{ + initscr(); /* Init screen */ + noecho(); /* Don’t echo keypresses */ + + for (;;) { + /* Read char and encode it as a string */ + char buf[5]; + vis(buf, getch(), VIS_WHITE, 0); + + clear(); /* Clear screen */ + printw("%s\n", buf); /* Write char to screen */ + refresh(); /* Refresh display */ + } + /* unreachable */ +} -- cgit v1.2.3