blob: 12613cea38955823e50c7f53f09d8895e46b7c79 (
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
30
|
BEGIN {
print ""
print "#include <stdlib.h>"
print "#include \"curses.h\""
print ""
print "struct kn {"
print "\tchar *name;"
print "\tint code;"
print "};"
print ""
print "struct kn key_names[] = {"
}
{printf "\t{\"%s\", %s,},\n", $1, $2;}
END {
print "};"
print ""
print "char *keyname(int c)"
print "{"
print "int i, size = sizeof(key_names)/sizeof(struct kn);"
print ""
print "\tfor (i = 0; i < size; i++) {"
print "\t\tif (key_names[i].code == c) return key_names[i].name;"
print "\t}"
print "\treturn NULL;"
print "}"
print ""
}
|