]> ncurses.scripts.mit.edu Git - ncurses.git/blob - ncurses/MKunctrl.awk
ncurses 4.1
[ncurses.git] / ncurses / MKunctrl.awk
1 # $Id: MKunctrl.awk,v 1.3 1997/04/26 23:04:45 tom Exp $
2 ################################################################################
3 # Copyright 1997 by Thomas E. Dickey <dickey@clark.net>                        #
4 # All Rights Reserved.                                                         #
5 #                                                                              #
6 # Permission to use, copy, modify, and distribute this software and its        #
7 # documentation for any purpose and without fee is hereby granted, provided    #
8 # that the above copyright notice appear in all copies and that both that      #
9 # copyright notice and this permission notice appear in supporting             #
10 # documentation, and that the name of the above listed copyright holder(s) not #
11 # be used in advertising or publicity pertaining to distribution of the        #
12 # software without specific, written prior permission. THE ABOVE LISTED        #
13 # COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,    #
14 # INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT #
15 # SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY SPECIAL,        #
16 # INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM   #
17 # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE   #
18 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR    #
19 # PERFORMANCE OF THIS SOFTWARE.                                                #
20 ################################################################################
21
22 BEGIN   {
23                 print "/* generated by MKunctrl.awk */"
24                 print
25                 print "#include <curses.priv.h>"
26                 print
27         }
28 END     {
29                 print "NCURSES_CONST char *unctrl(register chtype ch)"
30                 print "{"
31                 printf "static const char* const table[] = {"
32                 for ( ch = 0; ch < 256; ch++ ) {
33                         gap = ","
34                         if ((ch % 8) == 0)
35                                 printf "\n    "
36                         if (ch < 32) {
37                                 printf "\"^\\%03o\"", ch + 64
38                         } else if (ch == 127) {
39                                 printf "\"^?\""
40                         } else {
41                                 printf "\"\\%03o\"", ch
42                                 gap = gap " "
43                         }
44                         if (ch == 255)
45                                 gap = "\n"
46                         else if (((ch + 1) % 8) != 0)
47                                 gap = gap " "
48                         printf "%s", gap
49                 }
50                 print "};"
51                 print ""
52                 print "\treturn (NCURSES_CONST char *)table[TextOf(ch)];"
53                 print "}"
54         }