2795
|
1 |
#!/usr/local/dist/bin/perl
|
1826
|
2 |
'di';
|
|
3 |
'ig00';
|
|
4 |
###############################################
|
|
5 |
# Title: Tools/8bit/perl/generators/gen-isa2latex
|
|
6 |
# ID: $Id$
|
|
7 |
# Author: Franz Regensburger
|
|
8 |
# Copyright 1996 TU Muenchen
|
|
9 |
#
|
|
10 |
# generates documentation form on the basis of the configuration
|
|
11 |
# files for keyboard map and translations
|
|
12 |
#
|
|
13 |
# Franz Regensburger <regensbu@informatik.tu-muenchen.de> 8.3.95
|
|
14 |
###############################################
|
|
15 |
|
|
16 |
# I like to see the output as it happens (flushed output)
|
|
17 |
|
|
18 |
$| = 1;
|
|
19 |
|
|
20 |
# cash current working directory
|
|
21 |
require "pwd.pl";
|
|
22 |
&initpwd;
|
|
23 |
|
|
24 |
$initial_dir = $ENV{'PWD'};
|
|
25 |
|
|
26 |
########################
|
|
27 |
# comand line processing
|
|
28 |
# processes all known switches and ingnores others.
|
|
29 |
# First non-switch which is the name of a text file is
|
|
30 |
# interpreted as name of translation file.
|
|
31 |
# Second non-switch which is the name of a text file is
|
|
32 |
# interpreted as name of the keymap file.
|
|
33 |
#
|
|
34 |
|
|
35 |
# initialize
|
|
36 |
$translation_file="";
|
|
37 |
$keymap_file="";
|
|
38 |
$do_debug = 0;
|
|
39 |
$do_ddebug = 0;
|
|
40 |
$latex2e = 0;
|
|
41 |
|
|
42 |
|
|
43 |
while (@ARGV){
|
|
44 |
$cur_arg = shift @ARGV;
|
|
45 |
if ($cur_arg eq '-d') {$do_debug = 1;}
|
|
46 |
elsif ($cur_arg eq '-dd') {$do_debug = 1; $do_ddebug = 1;}
|
|
47 |
elsif ($cur_arg eq '-2e') {$latex2e = 1;}
|
|
48 |
elsif ((-T $cur_arg) && !$translation_file) {$translation_file = $cur_arg;}
|
|
49 |
elsif ((-T $cur_arg) && !$keymap_file) {$keymap_file = $cur_arg;}
|
|
50 |
}
|
|
51 |
|
|
52 |
# complain if no translationsfile is found
|
|
53 |
|
|
54 |
if ($translation_file eq "") {
|
|
55 |
print "\nno translation file suplied or argument is not a text file\n\n";
|
|
56 |
print "usage gen-isadoc [-d -dd -2e ] translation-file keymap-file\n",
|
|
57 |
"options must be seperated by blanks!";
|
|
58 |
die "\n";
|
|
59 |
}
|
|
60 |
|
|
61 |
if ($keymap_file eq "") {
|
|
62 |
print "\nno keymap file suplied or argument is not a text file\n\n";
|
|
63 |
print "usage gen-isadoc [-d -dd -2e] translation-file keymap-file\n",
|
|
64 |
"options must be seperated by blanks!";
|
|
65 |
die "\n";
|
|
66 |
}
|
|
67 |
|
|
68 |
print "debug mode is on\n" if $do_debug;
|
|
69 |
print "double debug mode is on\n" if $do_ddebug;
|
|
70 |
print "documentation is produced with LaTeX-2e\n" if ($do_debug & $latex2e);
|
|
71 |
print "documentation is produced with LaTeX 2.09\n" if ($do_debug &!$latex2e);
|
|
72 |
print "name of translation file is $translation_file\n" if $do_debug;
|
|
73 |
print "name of keymap file is $keymap_file\n" if $do_debug;
|
|
74 |
|
|
75 |
########################
|
|
76 |
# open the translations file
|
|
77 |
|
|
78 |
open(INFILE,$translation_file) || die "can't open $translation_file: $!\n";
|
|
79 |
print "opened translation file,\nprocessing\n" if $do_debug;
|
|
80 |
|
|
81 |
########################
|
|
82 |
# configuration of HI_TABLE
|
|
83 |
print "\nsetup for HI_TABLE\n" if $do_debug;
|
|
84 |
|
|
85 |
########################
|
|
86 |
# search for START_HI_TABLE
|
|
87 |
#
|
|
88 |
$start_hi_table =
|
|
89 |
&look_for_value('^\s*START_HI_TABLE\s*"(\d+)"',"START_HI_TABLE");
|
|
90 |
|
|
91 |
if ($start_hi_table eq "") {
|
|
92 |
die "\ncan't find START_HI_TABLE in translation file\n";}
|
|
93 |
|
|
94 |
if ($start_hi_table < 128 || 255 < $start_hi_table) {
|
|
95 |
die "\nSTART_HI_TABLE not in range 128 - 255\n";}
|
|
96 |
|
|
97 |
########################
|
|
98 |
# search for BEGIN_HI_TABLE
|
|
99 |
|
|
100 |
$found = &look_for_label('^\s*BEGIN_HI_TABL(E)',"BEGIN_HI_TABLE");
|
|
101 |
|
|
102 |
if ($found eq "") {
|
|
103 |
die "\ncan't find BEGIN_HI_TABLE in translation file\n";}
|
|
104 |
|
|
105 |
########################
|
|
106 |
# read the HI_TABLE
|
|
107 |
|
|
108 |
$index = 0;
|
|
109 |
#$max_hi_len = 0; # for pretty printing
|
|
110 |
$found = 0;
|
|
111 |
$end_hi_table = 0;
|
|
112 |
$pattern = '^>\s*"([^"]*)"\s*"([^"]*)"\s*"([^"]*)"';
|
|
113 |
|
|
114 |
while (<INFILE> ){
|
|
115 |
if (/^\s*END_HI_TABLE/){
|
|
116 |
print "line $.: END_HI_TABLE found\n" if $do_debug;
|
|
117 |
$found = 1;
|
|
118 |
$end_hi_table = $start_hi_table + $index - 1;
|
|
119 |
last;}
|
|
120 |
elsif (($temp1,$temp2,$temp3) = /$pattern/){
|
|
121 |
# no doubling of backslashes needed for docu files
|
|
122 |
# $max_hi_len = length($temp2) if $max_hi_len < length($temp2);
|
|
123 |
$hi_table[$index]= join('"',$temp2,$temp3);
|
|
124 |
# the " as seperator is perfect since it cannot occur inside the strings
|
|
125 |
# backslashes are duplicated
|
|
126 |
printf "line $.: \"%s\" \t\t \"%s\"\n",
|
|
127 |
$temp2,$temp3 if $do_ddebug;
|
|
128 |
$index++;
|
|
129 |
}
|
|
130 |
}
|
|
131 |
|
|
132 |
if (!$found){
|
|
133 |
die "\ncan't find END_HI_TABLE in translation file\n";}
|
|
134 |
|
|
135 |
if ($end_hi_table < $start_hi_table || 255 < $end_hi_table ){
|
|
136 |
die "\nEND_HI_TABLE $end_hi_table not in range $start_low_table - 255\n";}
|
|
137 |
else {print "computed index for END_HI_TABLE is $end_hi_table\n" if $do_debug;
|
|
138 |
# print "maximal length of entries is $max_hi_len\n" if $do_ddebug;
|
|
139 |
}
|
|
140 |
|
|
141 |
########################
|
|
142 |
# configuration of SEQ_TABLE
|
|
143 |
print "\nsetup for SEQ_TABLE\n" if $do_debug;
|
|
144 |
|
|
145 |
########################
|
|
146 |
# search for BEGIN_SEQ_TABLE
|
|
147 |
|
|
148 |
$found = &look_for_label('^\s*BEGIN_SEQ_TABL(E)',"BEGIN_SEQ_TABLE");
|
|
149 |
|
|
150 |
if ($found eq "") {
|
|
151 |
die "\ncan't find BEGIN_SEQ_TABLE in translation file\n";}
|
|
152 |
|
|
153 |
|
|
154 |
########################
|
|
155 |
# read the SEQ_TABLE
|
|
156 |
|
|
157 |
$index = 0;
|
|
158 |
#$max_seq_len = 0; # for pretty printing
|
|
159 |
$found = 0;
|
|
160 |
$seq_table = 0;
|
|
161 |
$pattern = '^>\s*"([^"]*)"\s*"([^"]*)"\s*"([^"]*)"\s*"([^"]*)"';
|
|
162 |
|
|
163 |
while (<INFILE> ){
|
|
164 |
if (/^\s*END_SEQ_TABLE/){
|
|
165 |
print "line $.: END_SEQ_TABLE found\n" if $do_debug;
|
|
166 |
$found = 1;
|
|
167 |
$seq_table = $index;
|
|
168 |
last;}
|
|
169 |
elsif (($temp1,$temp2,$temp3,$temp4) = /$pattern/){
|
|
170 |
# $max_seq_len = length($temp1) if $max_seq_len < length($temp1);
|
|
171 |
$seq_table[$index]= join('"',$temp1,$temp4);
|
|
172 |
# the " as seperator is perfect since it cannot occur inside the strings
|
|
173 |
# backslashes are only expanded in the latex replacement
|
|
174 |
printf "line $.: \"%s\" \t\t \"%s\"\n",
|
|
175 |
$temp3, $temp4 if $do_ddebug;
|
|
176 |
$index +=1;
|
|
177 |
}
|
|
178 |
}
|
|
179 |
|
|
180 |
if ($found == 0) {
|
|
181 |
die "\ncan't find END_SEQ_TABLE in translation file\n";}
|
|
182 |
else {print "computed index for SEQ_TABLE is $seq_table\n" if $do_debug;
|
|
183 |
# print "maximal length of entries is $max_seq_len\n" if $do_ddebug;
|
|
184 |
}
|
|
185 |
|
|
186 |
########################
|
|
187 |
# we reached the end of the translation file
|
|
188 |
|
|
189 |
print "\nprocessing of translation file completed\n" if $do_debug;
|
|
190 |
|
|
191 |
########################
|
|
192 |
# close the handle for config file
|
|
193 |
close(INFILE);
|
|
194 |
print "closed translation file\n" if $do_debug;
|
|
195 |
|
|
196 |
########################
|
|
197 |
# open the keymap file
|
|
198 |
|
|
199 |
open(INFILE,$keymap_file) || die "can't open $keymap_file: $!\n";
|
|
200 |
print "opened keymap file,\nprocessing\n" if $do_debug;
|
|
201 |
|
|
202 |
########################
|
|
203 |
# search for PACK
|
|
204 |
|
|
205 |
$pack = $ENV{'ISABELLE8BIT'};
|
|
206 |
|
|
207 |
if ($pack eq "") {
|
|
208 |
die "\ncan't find label PACK in keymap file\n";}
|
|
209 |
|
|
210 |
if (! (-d $pack)){
|
|
211 |
die "\nPACK is not a directory\n";}
|
|
212 |
|
|
213 |
|
|
214 |
########################
|
|
215 |
# configuration of KEY_MAP
|
|
216 |
print "\nsetup for KEY_MAP\n" if $do_debug;
|
|
217 |
|
|
218 |
########################
|
|
219 |
# search for BEGIN_KEY_MAP
|
|
220 |
|
|
221 |
$found = &look_for_label('^\s*BEGIN_KEY_MA(P)',"BEGIN_KEY_MAP");
|
|
222 |
|
|
223 |
if ($found eq "") {
|
|
224 |
die "\ncan't find BEGIN_KEY_MAP in keymap file\n";}
|
|
225 |
|
|
226 |
########################
|
|
227 |
# read the KEY_MAP
|
|
228 |
|
|
229 |
$index = 0;
|
|
230 |
$found = 0;
|
|
231 |
$end_key_map = 0;
|
|
232 |
$pattern =
|
|
233 |
'^\s*MOD\s*(None|Mod1|Mod2|Mod4|Shift|Ctrl)\s*KEY\s*([a-zA-Z]|F\d{1,2})\s*CODE\s*([0-9a-fA-F][0-9a-fA-F](\s*,\s*[0-9a-fA-F][0-9a-fA-F])*)\s*$';
|
|
234 |
|
|
235 |
#'
|
|
236 |
|
|
237 |
while (<INFILE> ){
|
|
238 |
if (/^\s*END_KEY_MAP/){
|
|
239 |
print "line $.: END_KEY_MAP found\n" if $do_debug;
|
|
240 |
$found = 1;
|
|
241 |
$end_key_map = $index - 1;
|
|
242 |
last;}
|
|
243 |
elsif (($modifiers,$key,$codeseq) = /$pattern/){
|
|
244 |
$key_map[$index]= join(':',$modifiers,$key,$codeseq);
|
|
245 |
print "line $.: \"$key_map[$index]\"\n" if $do_ddebug;
|
|
246 |
$index +=1;
|
|
247 |
}
|
|
248 |
else {
|
|
249 |
print "Is this a comment? line $.: $_\n" ;}
|
|
250 |
}
|
|
251 |
if (!$found){
|
|
252 |
die "\ncan't find END_KEY_MAP in keymap file\n";}
|
|
253 |
|
|
254 |
if ($end_low_table < $start_low_table){
|
|
255 |
die "\nNo entries in KEY_MAP\n";}
|
|
256 |
else {print
|
|
257 |
"computed index for END_KEY_MAP is $end_key_map\n" if $do_debug;}
|
|
258 |
|
|
259 |
########################
|
|
260 |
# we reached the end of the keymap file
|
|
261 |
|
|
262 |
print "\nprocessing of keymap file completed\n" if $do_debug;
|
|
263 |
|
|
264 |
########################
|
|
265 |
# close the handle for config file
|
|
266 |
close(INFILE);
|
|
267 |
print "closed keymap file\n" if $do_debug;
|
|
268 |
|
|
269 |
#######################################################################
|
|
270 |
# generate the documentation
|
|
271 |
#######################################################################
|
|
272 |
|
|
273 |
########################
|
|
274 |
# change to directory `doc'
|
|
275 |
|
|
276 |
chdir $pack."/doc" || die "can't cd to directory $pack/doc: $!\n";
|
|
277 |
|
|
278 |
|
|
279 |
########################
|
|
280 |
# open the file `fontindex.tex'
|
|
281 |
print "generating LaTeX file `fontindex.tex'\n" if $do_debug;
|
|
282 |
|
|
283 |
$filename = "fontindex.tex";
|
|
284 |
open(OUTFILE,">$filename") || die "can't open file $filename: $!\n";
|
|
285 |
print "opened $filename for writing\n" if $do_ddebug;
|
|
286 |
|
|
287 |
|
|
288 |
########################
|
|
289 |
# generate the fonttable
|
|
290 |
#
|
|
291 |
|
|
292 |
#initialize the fonttable
|
|
293 |
|
|
294 |
$index = $start_hi_table;
|
|
295 |
while ($index <= $end_hi_table) {
|
|
296 |
$fonttable[$index - $start_hi_table]=$hi_table[$index - $start_hi_table];
|
|
297 |
$index++;
|
|
298 |
}
|
|
299 |
|
|
300 |
# append information from the keymap
|
|
301 |
|
|
302 |
$index = 0;
|
|
303 |
while ($index <= $end_key_map) {
|
|
304 |
($mod,$key,$code) = split(/:/,$key_map[$index]);
|
|
305 |
# split the sequence of key codes
|
|
306 |
@codelist = split(/\s*,\s*/,$code);
|
|
307 |
|
|
308 |
if ($#codelist == 0 && # not a code sequence
|
|
309 |
$start_hi_table <= hex($codelist[0]) &&
|
|
310 |
hex($codelist[0]) <= $end_hi_table ) { # we are in range of hi_table
|
|
311 |
|
|
312 |
#translate the modifier
|
|
313 |
if ($mod eq "None") { # delete if None modifier
|
|
314 |
$mod = "";}
|
|
315 |
elsif ($mod eq "Mod1"){
|
|
316 |
$mod = "Meta";}
|
|
317 |
elsif ($mod eq "Mod2"){
|
|
318 |
$mod = "Alt";}
|
|
319 |
elsif ($mod eq "Mod4"){
|
|
320 |
$mod = "AltGraph";}
|
|
321 |
elsif ($mod eq "Ctrl"){
|
|
322 |
$mod = "Ctrl";}
|
|
323 |
|
|
324 |
$fonttable[hex($codelist[0]) - $start_hi_table] = join('"',
|
|
325 |
split(/\"/,$fonttable[hex($codelist[0]) - $start_hi_table]),
|
|
326 |
$mod." ".$key);
|
|
327 |
}
|
|
328 |
$index++;
|
|
329 |
}
|
|
330 |
|
|
331 |
|
|
332 |
## print the TeX prelude
|
|
333 |
if ($latex2e){
|
|
334 |
printf OUTFILE
|
|
335 |
'\documentclass[a4paper,11pt]{article}
|
|
336 |
\usepackage{latexsym,amssymb,supertab}
|
|
337 |
|
|
338 |
\begin{document}
|
|
339 |
|
|
340 |
\begin{center}
|
|
341 |
{\Large
|
|
342 |
Description of Isabelle Font \\\\
|
|
343 |
Indexed by Code}\\\\
|
|
344 |
Date: \today
|
|
345 |
|
|
346 |
\vspace*{.5cm}
|
|
347 |
|
|
348 |
\tablehead{\hline
|
|
349 |
Oct & Dec & Hex & ASCII & \LaTeX & Key Sequence\\\\
|
|
350 |
\hline}
|
|
351 |
\tabletail{\hline}
|
|
352 |
|
|
353 |
\begin{supertabular}{|l|l|l|l|l|l|}
|
|
354 |
';
|
|
355 |
}
|
|
356 |
else{
|
|
357 |
printf OUTFILE
|
|
358 |
'\documentstyle[a4,11pt,latexsym,amssymb,supertab]{article}
|
|
359 |
\begin{document}
|
|
360 |
|
|
361 |
\begin{center}
|
|
362 |
{\Large
|
|
363 |
Description of Isabelle Font \\\\
|
|
364 |
Indexed by Code}\\\\
|
|
365 |
Date: \today
|
|
366 |
|
|
367 |
\vspace*{.5cm}
|
|
368 |
|
|
369 |
\tablehead{\hline
|
|
370 |
Oct & Dec & Hex & ASCII & \LaTeX & Key Sequence\\\\
|
|
371 |
\hline}
|
|
372 |
\tabletail{\hline}
|
|
373 |
|
|
374 |
\begin{supertabular}{|l|l|l|l|l|l|}
|
|
375 |
';
|
|
376 |
}
|
|
377 |
## print the fonttable
|
|
378 |
|
|
379 |
$index = $start_hi_table;
|
|
380 |
while ($index <= $end_hi_table) {
|
|
381 |
($ascii,$latex,$keystring) = split(/\"/,
|
|
382 |
$fonttable[$index - $start_hi_table],3);
|
|
383 |
|
|
384 |
# generate List of Keystrokes
|
|
385 |
@keylist = split(/\"/,$keystring);
|
|
386 |
|
|
387 |
$keystring= shift(@keylist);
|
|
388 |
foreach $string (@keylist){
|
|
389 |
$keystring .= ", $string";}
|
|
390 |
|
|
391 |
if ($index == $end_hi_table) {
|
|
392 |
$postfix = "\\\\";}
|
|
393 |
else {$postfix = "\\nextline";}
|
|
394 |
|
|
395 |
|
|
396 |
printf(OUTFILE "%o & %d & %x & %s & %s & %s$postfix\n",
|
|
397 |
$index,
|
|
398 |
$index,
|
|
399 |
$index,
|
|
400 |
"\\verb*\"".$ascii."\"",
|
|
401 |
$latex,
|
|
402 |
$keystring);
|
|
403 |
|
|
404 |
$index++;
|
|
405 |
}
|
|
406 |
|
|
407 |
## print rest of TeX
|
|
408 |
printf OUTFILE
|
|
409 |
'\end{supertabular}
|
|
410 |
\end{center}
|
|
411 |
\end{document}
|
|
412 |
';
|
|
413 |
|
|
414 |
close(OUTFILE);
|
|
415 |
print "closed $filename\n" if $do_ddebug;
|
|
416 |
|
|
417 |
########################
|
|
418 |
# open the file `keyindex.tex'
|
|
419 |
print "generating LaTeX file `keyindex.tex'\n" if $do_debug;
|
|
420 |
|
|
421 |
$filename = "keyindex.tex";
|
|
422 |
open(OUTFILE,">$filename") || die "can't open file $filename: $!\n";
|
|
423 |
print "opened $filename for writing\n" if $do_ddebug;
|
|
424 |
|
|
425 |
|
|
426 |
########################
|
|
427 |
# generate an assoc array of those lex-expressions in seq_table that consist
|
|
428 |
# purely of hexnumbers or graphical characters (with highest bit set).
|
|
429 |
# These are candidates for the codesequences in key_map.
|
|
430 |
#
|
|
431 |
# This is just a simple heuristic!
|
|
432 |
#
|
|
433 |
|
|
434 |
print "compute the assoc array of code sequences\n" if $do_ddebug;
|
|
435 |
|
|
436 |
$index = 0;
|
|
437 |
while ($index < $seq_table ) {
|
|
438 |
($temp1,$temp2) = split(/\"/,$seq_table[$index]);
|
|
439 |
if ($temp1 =~ /^(\\x[0-9a-fA-F][0-9a-fA-F])+$/){# filter out the pure hex sequences
|
|
440 |
$temp1 =~ s/\\x([0-9a-fA-F][0-9a-fA-F])/$1,/g;
|
|
441 |
chop($temp1);
|
|
442 |
print "found candidate: key $temp1 latex $temp2\n" if $do_ddebug;
|
|
443 |
$assoc_seq_table{$temp1} = $temp2;}
|
|
444 |
elsif ($temp1 =~ /^([\x80-\xff])+$/){# filter out the pure graphical characters
|
|
445 |
$temp1 = unpack("H*",$temp1);
|
|
446 |
$temp1 =~ /^([0-9a-f][0-9a-f])+$/;
|
|
447 |
$temp1 =~ s/([0-9a-f][0-9a-f])/$1,/g;
|
|
448 |
chop($temp1);
|
|
449 |
print "found candidate: key $temp1 latex $temp2\n" if $do_ddebug;
|
|
450 |
$assoc_seq_table{$temp1} = $temp2;}
|
|
451 |
|
|
452 |
$index++;
|
|
453 |
}
|
|
454 |
|
|
455 |
########################
|
|
456 |
# generate the keytable
|
|
457 |
#
|
|
458 |
|
|
459 |
$index = 0;
|
|
460 |
while ($index <= $end_key_map) {
|
|
461 |
($mod,$key,$code) = split(/:/,$key_map[$index]);
|
|
462 |
|
|
463 |
#translate the modifier `None' for sorting; a dirty trick
|
|
464 |
if ($mod eq "None") { # delete if None modifier
|
|
465 |
$mod = "AAAA";}
|
|
466 |
|
|
467 |
@codelist = split(/\s*,\s*/,$code);
|
|
468 |
if ($#codelist != 0){ # we have a code sequence, look up in assoc array
|
|
469 |
$latex = $assoc_seq_table{join(',',@codelist)};
|
|
470 |
if ($latex eq "") {# there was no assoc
|
|
471 |
$latex = "unknown";}
|
|
472 |
}
|
|
473 |
elsif ( $start_hi_table <= hex($codelist[0]) &&
|
|
474 |
hex($codelist[0]) <= $end_hi_table ) {# we are in range of hi_table
|
|
475 |
@temp4 = split(/\"/,$hi_table[hex($codelist[0]) - $start_hi_table]);
|
|
476 |
$latex = pop(@temp4);}
|
|
477 |
|
|
478 |
else { # we can"t associate a LaTeX code
|
|
479 |
$latex = "unknown";}
|
|
480 |
|
|
481 |
$keytable[$index]= join('"',$mod,$key,join(',',@codelist),$latex);
|
|
482 |
$index++;
|
|
483 |
}
|
|
484 |
|
|
485 |
########################
|
|
486 |
# sort the keytable
|
|
487 |
#
|
|
488 |
|
|
489 |
@keytable = sort(sortbykey @keytable);
|
|
490 |
|
|
491 |
|
|
492 |
## print the TeX prelude
|
|
493 |
if ($latex2e){
|
|
494 |
printf OUTFILE
|
|
495 |
'\documentclass[a4paper,11pt]{article}
|
|
496 |
\usepackage{latexsym,amssymb,supertab}
|
|
497 |
|
|
498 |
\begin{document}
|
|
499 |
|
|
500 |
\begin{center}
|
|
501 |
{\Large
|
|
502 |
Description of Keyboard Mapping\\\\
|
|
503 |
Indexed by Key Sequence}\\\\
|
|
504 |
Date: \today
|
|
505 |
|
|
506 |
\vspace*{.5cm}
|
|
507 |
|
|
508 |
\tablehead{\hline
|
|
509 |
Key Sequence & Code Sequence in Hex & \LaTeX \\\\
|
|
510 |
\hline}
|
|
511 |
\tabletail{\hline}
|
|
512 |
|
|
513 |
\begin{supertabular}{|l|l|l|}
|
|
514 |
';
|
|
515 |
}
|
|
516 |
else {
|
|
517 |
printf OUTFILE
|
|
518 |
'\documentstyle[a4,11pt,latexsym,amssymb,supertab]{article}
|
|
519 |
\begin{document}
|
|
520 |
|
|
521 |
\begin{center}
|
|
522 |
{\Large
|
|
523 |
Description of Keyboard Mapping\\\\
|
|
524 |
Indexed by Key Sequence}\\\\
|
|
525 |
Date: \today
|
|
526 |
|
|
527 |
\vspace*{.5cm}
|
|
528 |
|
|
529 |
\tablehead{\hline
|
|
530 |
Key Sequence & Code Sequence in Hex & \LaTeX \\\\
|
|
531 |
\hline}
|
|
532 |
\tabletail{\hline}
|
|
533 |
|
|
534 |
\begin{supertabular}{|l|l|l|}
|
|
535 |
';
|
|
536 |
}
|
|
537 |
## print the keyboard mapping
|
|
538 |
|
|
539 |
$index = 0;
|
|
540 |
while ($index <= $end_key_map) {
|
|
541 |
($mod,$key,$code,$latex) = split(/\"/,$keytable[$index]);
|
|
542 |
|
|
543 |
#translate the modifier
|
|
544 |
if ($mod eq "AAAA") { # delete if AAAA rsp. None modifier
|
|
545 |
$mod = "";}
|
|
546 |
elsif ($mod eq "Mod1"){
|
|
547 |
$mod = "Meta";}
|
|
548 |
elsif ($mod eq "Mod2"){
|
|
549 |
$mod = "Alt";}
|
|
550 |
elsif ($mod eq "Mod4"){
|
|
551 |
$mod = "AltGraph";}
|
|
552 |
elsif ($mod eq "Ctrl"){
|
|
553 |
$mod = "Ctrl";}
|
|
554 |
|
|
555 |
if ($index == $end_key_map) {
|
|
556 |
$postfix = "\\\\";}
|
|
557 |
else {$postfix = "\\nextline";}
|
|
558 |
|
|
559 |
printf(OUTFILE "%s & %s & %s$postfix\n",
|
|
560 |
$mod." ".$key,
|
|
561 |
$code,
|
|
562 |
$latex);
|
|
563 |
|
|
564 |
$index++;
|
|
565 |
}
|
|
566 |
|
|
567 |
|
|
568 |
## print rest of TeX
|
|
569 |
printf OUTFILE
|
|
570 |
'\end{supertabular}
|
|
571 |
\end{center}
|
|
572 |
\end{document}
|
|
573 |
';
|
|
574 |
|
|
575 |
close(OUTFILE);
|
|
576 |
print "closed $filename\n" if $do_ddebug;
|
|
577 |
|
|
578 |
########################
|
|
579 |
# open the file `fkmatrix.tex'
|
|
580 |
print "generating LaTeX file `fkmatrix.tex'\n" if $do_debug;
|
|
581 |
|
|
582 |
$filename = "fkmatrix.tex";
|
|
583 |
open(OUTFILE,">$filename") || die "can't open file $filename: $!\n";
|
|
584 |
print "opened $filename for writing\n" if $do_ddebug;
|
|
585 |
|
|
586 |
|
|
587 |
########################
|
|
588 |
# generate the matrix for function key mappings
|
|
589 |
#
|
|
590 |
# we support only documentation of keys F1 - F12
|
|
591 |
|
|
592 |
# initialize the assoc array
|
|
593 |
|
|
594 |
$fkmat{"AAAA"} = join('"',(" "," "," "," "," "," "," "," "," "," "," "," "));
|
|
595 |
$fkmat{"Mod1"} = join('"',(" "," "," "," "," "," "," "," "," "," "," "," "));
|
|
596 |
$fkmat{"Mod2"} = join('"',(" "," "," "," "," "," "," "," "," "," "," "," "));
|
|
597 |
$fkmat{"Mod4"} = join('"',(" "," "," "," "," "," "," "," "," "," "," "," "));
|
|
598 |
$fkmat{"Ctrl"} = join('"',(" "," "," "," "," "," "," "," "," "," "," "," "));
|
|
599 |
|
|
600 |
print "building fkmatrix\n" if $do_ddebug;
|
|
601 |
|
|
602 |
$index = 0;
|
|
603 |
while ($index <= $end_key_map) {
|
|
604 |
local (@keylist);
|
|
605 |
|
|
606 |
($mod,$key,$code,$latex) = split(/\"/,$keytable[$index]);
|
|
607 |
|
|
608 |
if ($key =~ /^F\d{1,2}$/){ # key is a function key
|
|
609 |
$key =~ s/^F(\d{1,2})$/$1/;
|
|
610 |
@keylist = split(/\"/,$fkmat{$mod});
|
|
611 |
if( 0<$key && $key<=12){
|
|
612 |
# we support only F1 - F12
|
|
613 |
$keylist[$key-1]=$latex;}
|
|
614 |
$fkmat{$mod} = join('"',@keylist);
|
|
615 |
}
|
|
616 |
$index++;
|
|
617 |
}
|
|
618 |
print "fkmatrix completed\n" if $do_ddebug;
|
|
619 |
|
|
620 |
## print the TeX prelude
|
|
621 |
if ($latex2e){
|
|
622 |
printf OUTFILE
|
|
623 |
'\documentclass[a4paper,11pt]{article}
|
|
624 |
\usepackage{latexsym,latexsym,amssymb,supertab}
|
|
625 |
|
|
626 |
\begin{document}
|
|
627 |
|
|
628 |
\begin{center}
|
|
629 |
{\Large
|
|
630 |
Keyboard Mapping for Function Keys F1 - F12}\\\\
|
|
631 |
Date: \today
|
|
632 |
|
|
633 |
\vspace*{.5cm}
|
|
634 |
|
|
635 |
\tablehead{\hline
|
|
636 |
Modifier & F1 &F2 &F3 &F4 &F5 &F6 &F7 &F8 &F9 & F10 &F11 &F12\\\\
|
|
637 |
\hline}
|
|
638 |
\tabletail{\hline}
|
|
639 |
|
|
640 |
\begin{supertabular}{|l|l|l|l|l|l|l|l|l|l|l|l|l|}
|
|
641 |
';}
|
|
642 |
else {
|
|
643 |
printf OUTFILE
|
|
644 |
'\documentstyle[a4,11pt,latexsym,amssymb,supertab]{article}
|
|
645 |
\begin{document}
|
|
646 |
|
|
647 |
\begin{center}
|
|
648 |
{\Large
|
|
649 |
Keyboard Mapping for Function Keys F1 - F12}\\\\
|
|
650 |
Date: \today
|
|
651 |
|
|
652 |
\vspace*{.5cm}
|
|
653 |
|
|
654 |
\tablehead{\hline
|
|
655 |
Modifier & F1 &F2 &F3 &F4 &F5 &F6 &F7 &F8 &F9 & F10 &F11 &F12\\\\
|
|
656 |
\hline}
|
|
657 |
\tabletail{\hline}
|
|
658 |
|
|
659 |
\begin{supertabular}{|l|l|l|l|l|l|l|l|l|l|l|l|l|}
|
|
660 |
';
|
|
661 |
}
|
|
662 |
## print the matrix
|
|
663 |
printf(OUTFILE "None&%s\\nextline\n",
|
|
664 |
join('&',split(/\"/,$fkmat{"AAAA"})));
|
|
665 |
printf(OUTFILE "\\hline\n");
|
|
666 |
printf(OUTFILE "Shift&%s\\nextline\n",
|
|
667 |
join('&',split(/\"/,$fkmat{"Shift"})));
|
|
668 |
printf(OUTFILE "\\hline\n");
|
|
669 |
printf(OUTFILE "Alt&%s\\nextline\n",
|
|
670 |
join('&',split(/\"/,$fkmat{"Mod2"})));
|
|
671 |
printf(OUTFILE "\\hline\n");
|
|
672 |
printf(OUTFILE "AltGraph&%s\\nextline\n",
|
|
673 |
join('&',split(/\"/,$fkmat{"Mod4"})));
|
|
674 |
printf(OUTFILE "\\hline\n");
|
|
675 |
printf(OUTFILE "Ctrl&%s\\\\\n",
|
|
676 |
join('&',split(/\"/,$fkmat{"Ctrl"})));
|
|
677 |
printf(OUTFILE "\\hline\n");
|
|
678 |
printf(OUTFILE "Meta&%s\\nextline\n",
|
|
679 |
join('&',split(/\"/,$fkmat{"Mod1"})));
|
|
680 |
|
|
681 |
## print rest of TeX
|
|
682 |
printf OUTFILE
|
|
683 |
'\end{supertabular}
|
|
684 |
\end{center}
|
|
685 |
\end{document}
|
|
686 |
';
|
|
687 |
|
|
688 |
close(OUTFILE);
|
|
689 |
print "closed $filename\n" if $do_ddebug;
|
|
690 |
|
|
691 |
########################
|
|
692 |
# execute Makefile
|
|
693 |
|
|
694 |
print "\nexecuting Makefile\n" if $do_debug;
|
|
695 |
$status = system("make fontdocfiles") ;
|
|
696 |
if ($status) { die "\"make fontdocfiles\" executed abnormally: $!\n";}
|
|
697 |
|
|
698 |
#print "\nexecuting Makefile, cleaning up\n" if $do_debug;
|
|
699 |
#$status = system("make clean");
|
|
700 |
#if ($status) { die "\"make clean\" executed abnormally: $!\n";}
|
|
701 |
|
|
702 |
########################
|
|
703 |
# END of script
|
|
704 |
#
|
|
705 |
|
|
706 |
print "\ngeneration of font and keymap documentation properly terminated\n\n";
|
|
707 |
exit(0);
|
|
708 |
|
|
709 |
#######################################################################
|
|
710 |
# subroutines
|
|
711 |
#######################################################################
|
|
712 |
|
|
713 |
sub look_for_value {
|
|
714 |
local ($pattern,$label) = @_;
|
|
715 |
local ($temp) = "";
|
|
716 |
|
|
717 |
while (<INFILE> ){
|
|
718 |
if (($temp) = /$pattern/){
|
|
719 |
print "line $.: $label is $temp\n" if $do_debug;
|
|
720 |
last;}
|
|
721 |
}
|
|
722 |
return $temp;
|
|
723 |
}
|
|
724 |
|
|
725 |
|
|
726 |
sub look_for_label {
|
|
727 |
local ($pattern,$label) = @_;
|
|
728 |
local ($temp) = "";
|
|
729 |
|
|
730 |
while (<INFILE> ){
|
|
731 |
if (($temp) = /$pattern/){
|
|
732 |
print "line $.: $label found\n" if $do_debug;
|
|
733 |
last;}
|
|
734 |
}
|
|
735 |
return $temp;
|
|
736 |
}
|
|
737 |
|
|
738 |
sub replicate_until {
|
|
739 |
local ($pattern,$label) = @_;
|
|
740 |
local ($temp) = "";
|
|
741 |
|
|
742 |
while (<INFILE> ){
|
|
743 |
if (($temp) = /$pattern/){
|
|
744 |
print "line $.: $label found\n" if $do_debug;
|
|
745 |
last;}
|
|
746 |
else {printf(OUTFILE "%s",$_);}
|
|
747 |
}
|
|
748 |
return $temp;
|
|
749 |
}
|
|
750 |
|
|
751 |
sub skip_until {
|
|
752 |
local ($pattern,$label) = @_;
|
|
753 |
local ($temp) = "";
|
|
754 |
|
|
755 |
while (<INFILE> ){
|
|
756 |
if (($temp) = /$pattern/){
|
|
757 |
print "line $.: $label found\n" if $do_debug;
|
|
758 |
last;}
|
|
759 |
}
|
|
760 |
return $temp;
|
|
761 |
}
|
|
762 |
|
|
763 |
sub double_bs {
|
|
764 |
local ($string) = @_;
|
|
765 |
local ($element);
|
|
766 |
local (@temp1);
|
|
767 |
local (@temp2) = ();
|
|
768 |
|
|
769 |
# find the hex-numbers
|
|
770 |
@temp1 = split(/(\\x[0-9a-fA-F][0-9a-fA-F])/,$string);
|
|
771 |
|
|
772 |
#duplicate all backslashes in elements which are not hexnumbers
|
|
773 |
while(@temp1) {
|
|
774 |
$element = shift(@temp1);
|
|
775 |
if ($element =~ /\\x[0-9a-fA-F][0-9a-fA-F]/){
|
|
776 |
push(@temp2,$element);}
|
|
777 |
else{
|
|
778 |
$element =~ s/\\/\\\\/g;
|
|
779 |
push(@temp2,$element);}
|
|
780 |
}
|
|
781 |
return (join('',@temp2));
|
|
782 |
}
|
|
783 |
|
|
784 |
sub squeeze_bs {
|
|
785 |
local ($string) = @_;
|
|
786 |
|
|
787 |
$string =~ s/\\\\/\\/g;
|
|
788 |
return $string;
|
|
789 |
}
|
|
790 |
|
|
791 |
sub show_blanks {
|
|
792 |
local ($string) = @_;
|
|
793 |
|
|
794 |
$string =~ s/ /\\_/g;
|
|
795 |
return $string;
|
|
796 |
}
|
|
797 |
|
|
798 |
sub sortbykey {
|
|
799 |
local ($mod1,$key1,$code1,$latex1) = split(/\"/,$a);
|
|
800 |
local ($mod2,$key2,$code2,$latex2) = split(/\"/,$b);
|
|
801 |
|
|
802 |
if ($mod1 eq $mod2){ # subsort by key
|
|
803 |
if ($key1 =~ /^F\d{1,2}$/){ # key1 is a function key
|
|
804 |
if ($key2 =~ /^F\d{1,2}$/){ # key2 is a function key too
|
|
805 |
$key1 =~ s/^F(\d{1,2})$/$1/;
|
|
806 |
$key2 =~ s/^F(\d{1,2})$/$1/;
|
|
807 |
return (int($key1) <=> int($key2));}
|
|
808 |
else {return 1;} # function is always greater
|
|
809 |
}
|
|
810 |
elsif ($key2 =~ /^F\d{1,2}$/){ # key2 is a function key, key1 not
|
|
811 |
return -1;} # non function is always less
|
|
812 |
else { # both are non function keys
|
|
813 |
return ($key1 cmp $key2);}
|
|
814 |
}
|
|
815 |
else { return ($mod1 cmp $mod2);}
|
|
816 |
}
|
|
817 |
###############################################################
|
|
818 |
|
|
819 |
# These next few lines are legal in both Perl and nroff.
|
|
820 |
|
|
821 |
.00; # finish .ig
|
|
822 |
|
|
823 |
'di \" finish diversion--previous line must be blank
|
|
824 |
.nr nl 0-1 \" fake up transition to first page again
|
|
825 |
.nr % 0 \" start at page 1
|
|
826 |
'; __END__ ##### From here on it's a standard manual page #####
|