From a40bbaf27d592e053789a53740ef0509a77d9246 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Thu, 21 Feb 2019 19:02:24 -0500 Subject: add symbols from --- src/unctrl/unctrl.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/unctrl/unctrl.c (limited to 'src/unctrl/unctrl.c') diff --git a/src/unctrl/unctrl.c b/src/unctrl/unctrl.c new file mode 100644 index 00000000..3ec00c33 --- /dev/null +++ b/src/unctrl/unctrl.c @@ -0,0 +1,29 @@ +#include +#include "curses.h" +#include "ctype.h" +#include "stddef.h" + +char * unctrl(chtype c) +{ + static char buf[3]; + char * ret = NULL; + int ch = c & A_CHARTEXT; + + if (iscntrl(ch)) { + buf[0] = '^'; + buf[1] = ch + 'A'; + buf[2] = '\0'; + ret = buf; + } else if (isprint(ch)) { + buf[0] = ch; + buf[1] = '\0'; + ret = buf; + } + + return ret; +} + +/* +XOPEN(4) +LINK(curses) +*/ -- cgit v1.2.1