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