From a80c0624fbd8bd1c784b0b5b7a0fd20b09d317b9 Mon Sep 17 00:00:00 2001 From: ache Date: Fri, 7 Oct 1994 08:58:58 +0000 Subject: Moved from ports with several enhancements --- lib/libncurses/lib_unctrl.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 lib/libncurses/lib_unctrl.c (limited to 'lib/libncurses/lib_unctrl.c') diff --git a/lib/libncurses/lib_unctrl.c b/lib/libncurses/lib_unctrl.c new file mode 100644 index 0000000..3c8f583 --- /dev/null +++ b/lib/libncurses/lib_unctrl.c @@ -0,0 +1,26 @@ +#include +#include + +char * + unctrl(register unsigned char uch) +{ + static char buffer[3] = "^x"; + + if (isgraph(uch)) { + /* + * Printable character. Simply return the character as a one-character + * string. + */ + buffer[1] = uch; + return &buffer[1]; + } + uch &= ~0x80; + /* + * It is a control character. DEL is handled specially (^?). All others + * use ^x notation, where x is the character code for the control character + * with 0x40 ORed in. (Control-A becomes ^A etc.). + */ buffer[1] = (uch == 0x7F ? '?' : (uch | 0x40)); + + return buffer; + +} -- cgit v1.1