summaryrefslogtreecommitdiff
path: root/unctrl/unctrl.c
blob: 608503683dd1eabe56407844fdbf0f1abb317ab2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <unctrl.h>
#include "../curses/_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)
*/