summaryrefslogtreecommitdiffhomepage
path: root/src/blog/termios/test.c
blob: dcb93d19b2ddfbb605560ee40b7b510b927cf631 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <curses.h>
#include <stdio.h>
#include <vis.h>

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 */
}