diff options
Diffstat (limited to 'contrib/ncurses/ncurses/base/MKkeyname.awk')
-rw-r--r-- | contrib/ncurses/ncurses/base/MKkeyname.awk | 58 |
1 files changed, 37 insertions, 21 deletions
diff --git a/contrib/ncurses/ncurses/base/MKkeyname.awk b/contrib/ncurses/ncurses/base/MKkeyname.awk index c06773350cc6..5aab9369857c 100644 --- a/contrib/ncurses/ncurses/base/MKkeyname.awk +++ b/contrib/ncurses/ncurses/base/MKkeyname.awk @@ -1,6 +1,6 @@ -# $Id: MKkeyname.awk,v 1.18 2000/12/10 02:25:23 tom Exp $ +# $Id: MKkeyname.awk,v 1.21 2002/02/23 22:36:33 tom Exp $ ############################################################################## -# Copyright (c) 1999,2000 Free Software Foundation, Inc. # +# Copyright (c) 1999-2001,2002 Free Software Foundation, Inc. # # # # Permission is hereby granted, free of charge, to any person obtaining a # # copy of this software and associated documentation files (the "Software"), # @@ -29,10 +29,7 @@ BEGIN { print "/* generated by MKkeyname.awk */" print "" - print "#include <ncurses_cfg.h>" - print "#include <stdlib.h>" - print "#include <string.h>" - print "#include <curses.h>" + print "#include <curses.priv.h>" print "#include <tic.h>" print "" print "const struct kn _nc_key_names[] = {" @@ -47,28 +44,47 @@ END { print "" print "NCURSES_EXPORT(NCURSES_CONST char *) keyname (int c)" print "{" + print "static char **table;" print "int i;" - print "static char name[20];" + print "char name[20];" print "char *p;" print "" print "\tfor (i = 0; _nc_key_names[i].name != 0; i++)" print "\t\tif (_nc_key_names[i].code == c)" print "\t\t\treturn (NCURSES_CONST char *)_nc_key_names[i].name;" print "\tif (c >= 256) return \"UNKNOWN KEY\";" - print "\tp = name;" - print "\tif (c >= 128) {" - print "\t\tstrcpy(p, \"M-\");" - print "\t\tp += 2;" - print "\t\tc -= 128;" + print "" + print "\tif (table == 0)" + print "\t\ttable = typeCalloc(char *, 256);" + print "\tif (table == 0)" + print "\t\treturn keyname(256);" + print "" + print "\tif (table[c] == 0) {" + print "\t\tp = name;" + print "\t\tif (c >= 128) {" + print "\t\t\tstrcpy(p, \"M-\");" + print "\t\t\tp += 2;" + print "\t\t\tc -= 128;" + print "\t\t}" + print "\t\tif (c < 0)" + print "\t\t\tsprintf(p, \"%d\", c);" + print "\t\telse if (c < 32)" + print "\t\t\tsprintf(p, \"^%c\", c + '@');" + print "\t\telse if (c == 127)" + print "\t\t\tstrcpy(p, \"^?\");" + print "\t\telse" + print "\t\t\tsprintf(p, \"%c\", c);" + print "\t\ttable[c] = strdup(name);" print "\t}" - print "\tif (c < 0)" - print "\t\tsprintf(p, \"%d\", c);" - print "\telse if (c < 32)" - print "\t\tsprintf(p, \"^%c\", c + '@');" - print "\telse if (c == 127)" - print "\t\tstrcpy(p, \"^?\");" - print "\telse" - print "\t\tsprintf(p, \"%c\", c);" - print "\treturn (NCURSES_CONST char *)name;" + print "\treturn (NCURSES_CONST char *)table[c];" + print "}" + print "" + print "#if USE_WIDEC_SUPPORT" + print "NCURSES_EXPORT(NCURSES_CONST char *) key_name (wchar_t c)" + print "{" + print "\tchar *result = keyname((int)c);" + print "\tif (!strncmp(result, \"M-\", 2)) result = \"UNKNOWN KEY\";" + print "\treturn result;" print "}" + print "#endif" } |