diff options
| author | Jakob Kaivo <jkk@ung.org> | 2019-02-21 19:02:24 -0500 |
|---|---|---|
| committer | Jakob Kaivo <jkk@ung.org> | 2019-02-21 19:02:24 -0500 |
| commit | a40bbaf27d592e053789a53740ef0509a77d9246 (patch) | |
| tree | 596e34cc3d682fca9a1da8a98a7fc79e844414a6 /src | |
| parent | 7f1d93d30fa55dc5e7cfdf8a846326cbd2941d7c (diff) | |
add symbols from <unctrl.h>
Diffstat (limited to 'src')
| -rw-r--r-- | src/unctrl/chtype.ref | 3 | ||||
| -rw-r--r-- | src/unctrl/unctrl.c | 29 |
2 files changed, 32 insertions, 0 deletions
diff --git a/src/unctrl/chtype.ref b/src/unctrl/chtype.ref new file mode 100644 index 00000000..cc36394f --- /dev/null +++ b/src/unctrl/chtype.ref @@ -0,0 +1,3 @@ +#include <term.h> +REFERENCE(curses/chtype.c) +XOPEN(4) 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 <unctrl.h> +#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) +*/ |
