3 # dselect - Debian package maintenance user interface
4 # mkcurkeys.pl - generate strings mapping key names to ncurses numbers
6 # Copyright © 1995 Ian Jackson <ian@chiark.greenend.org.uk>
8 # This is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 $#ARGV == 1 || die ("usage: mkcurkeys.pl <filename> <curses.h>");
23 open(OV
,"<$ARGV[0]") || die $!;
26 /^#/ && next; # skip comments
27 /\S/ || next; # ignore blank lines
28 /^(\w+)\s+(\S.*\S)\s*$/ || die ("cannot parse line:\n$_\n");
34 for ($i=1, $let='A'; $i<=26; $i++, $let++) {
39 open(NCH
,"<$ARGV[1]") || die $!;
42 m/#define KEY_(\w+)\s+\d+\s+/ || next;
51 next unless m|^/\* (\w[\w ]+\w) \*/$|;
54 next if s/^shifted /shift / ? m/ .* .* / : m/ .* /;
60 printf(<<'END') || die $!;
62 * WARNING - THIS FILE IS GENERATED AUTOMATICALLY - DO NOT EDIT
63 * It is generated by mkcurkeys.pl from <curses.h>
64 * and keyoverride. If you want to override things try adding
65 * them to keyoverride.
70 for ($i=33; $i<=126; $i++) {
73 if ($v eq ',') { $comma=$k; next; }
79 $b+0 eq $b ?
$a <=> $b : -1
84 $v= $name{$k} if defined($name{$k});
85 $v= $over{$k} if defined($over{$k});
86 next if $v eq '[elide]';
90 for ($i=1; $i<64; $i++) {
91 $k= "KEY_F($i)"; $v= "F$i";
95 $k=$comma; $v=','; &p
;
97 print(<<'END') || die $!;
101 close(STDOUT
) || die $!;
105 $o= ''; y/A-Z/a-z/; $_= " $_";
117 $v =~ s/["\\]/\\$&/g;
118 printf(" { %-15s \"%-20s },\n",