diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/context/perl/cont_set.pm | 498 | ||||
-rw-r--r-- | scripts/context/perl/mptopdf.pl | 94 | ||||
-rw-r--r-- | scripts/context/perl/texexec.pl | 430 | ||||
-rw-r--r-- | scripts/context/perl/texexec.rme | 6 | ||||
-rw-r--r-- | scripts/context/perl/texfont.pl | 13 | ||||
-rw-r--r-- | scripts/context/perl/texutil.pl | 4 | ||||
-rw-r--r-- | scripts/context/ruby/texmfstart.rb | 2 | ||||
-rw-r--r-- | scripts/context/ruby/texsync.rb | 200 | ||||
-rw-r--r-- | scripts/context/ruby/textools.rb | 137 | ||||
-rw-r--r-- | scripts/context/ruby/xmltools.rb | 236 | ||||
-rw-r--r-- | scripts/context/ruby/xmpl/switch.rb | 54 |
11 files changed, 424 insertions, 1250 deletions
diff --git a/scripts/context/perl/cont_set.pm b/scripts/context/perl/cont_set.pm index c14cc679c..9c6d2cbcd 100644 --- a/scripts/context/perl/cont_set.pm +++ b/scripts/context/perl/cont_set.pm @@ -1,7 +1,7 @@ #D \module #D [ file=cont\_set.pm, #D version=1999.04.01, -#D title=General modules, +#D title=General modules, #D subtitle=showing \CONTEXT\ commands, #D author=Hans Hagen, #D date=\currentdate, @@ -9,187 +9,187 @@ #D suggestions={Tobias Burnus \& Taco Hoekater}] #C #C This module is part of the \CONTEXT\ macro||package and is -#C therefore copyrighted by \PRAGMA. See licen-en.pdf for -#C details. +#C therefore copyrighted by \PRAGMA. See licen-en.pdf for +#C details. -# todo: tacos speed patch +# todo: tacos speed patch -#D As always: thanks to Taco and Tobias for testing this -#D module and providing suggestions and code snippets as -#D well as haunting bugs. +#D As always: thanks to Taco and Tobias for testing this +#D module and providing suggestions and code snippets as +#D well as haunting bugs. -package cont_set ; +package cont_set ; #D This module (package) deals with providing help information #D about the \CONTEXT\ commands. The data needed is derived #D from the setup files by \CONTEXT\ itself. The data is -#D stored in files with suffix \type {tws} (tex work setup). -#D This module introduces some subroutines: -#D +#D stored in files with suffix \type {tws} (tex work setup). +#D This module introduces some subroutines: +#D #D \starttabulatie[|Tl|p|] -#D \NC \type {set\_setup\_interface} \NC sets the primary interface -#D to search in \NC \NR -#D \NC \type {set\_setup\_title} \NC sets the title of the main -#D window title \NC \NR -#D \NC \type {setups\_found} \NC locate the \type {tws} files -#D using the \type {kpsewhich} -#D program \NC \NR -#D \NC \type {show\_setups} \NC allocate the radio buttons -#D that can be used to select a -#D command set \NC \NR -#D \NC \type {load\_setup(filename)} \NC load the names \type {tws} -#D file \NC \NR -#D \NC \type {load\_setups} \NC all found command files can -#D be loaded at once \NC \NR -#D \NC \type {setup\_found(filename)} \NC this routine returns~1 when -#D the file is loaded \NC \NR -#D \NC \type {update\_setup} \NC when we browse the list with -#D commands, this routine takes care -#D of updating the text area \NC \NR -#D \NC \type {change\_setup} \NC we can manually set the -#D command set we want to browse, -#D and this routine takes care of -#D this \NC \NR -#D \NC \type {show\_setup(command)} \NC context sensitive help can be +#D \NC \type {set\_setup\_interface} \NC sets the primary interface +#D to search in \NC \NR +#D \NC \type {set\_setup\_title} \NC sets the title of the main +#D window title \NC \NR +#D \NC \type {setups\_found} \NC locate the \type {tws} files +#D using the \type {kpsewhich} +#D program \NC \NR +#D \NC \type {show\_setups} \NC allocate the radio buttons +#D that can be used to select a +#D command set \NC \NR +#D \NC \type {load\_setup(filename)} \NC load the names \type {tws} +#D file \NC \NR +#D \NC \type {load\_setups} \NC all found command files can +#D be loaded at once \NC \NR +#D \NC \type {setup\_found(filename)} \NC this routine returns~1 when +#D the file is loaded \NC \NR +#D \NC \type {update\_setup} \NC when we browse the list with +#D commands, this routine takes care +#D of updating the text area \NC \NR +#D \NC \type {change\_setup} \NC we can manually set the +#D command set we want to browse, +#D and this routine takes care of +#D this \NC \NR +#D \NC \type {show\_setup(command)} \NC context sensitive help can be #D provided by calling this sub \NC \NR #D \stoptabulatie -#D -#D First we load some packages and set some constants. +#D +#D First we load some packages and set some constants. use Tk ; use Tk::ROText ; -use Config ; +use Config ; use strict; use subs qw/ update_setup / ; my $dosish = ($Config{'osname'} =~ /dos|win/i) ; -my $default_size = $dosish ? 9 : 12 ; +my $default_size = $dosish ? 9 : 12 ; my $textfont = "Courier $default_size " ; my $userfont = "Courier $default_size italic" ; my $buttonfont = "Helvetica $default_size bold " ; -unless ($dosish) +unless ($dosish) { $textfont = "-adobe-courier-bold-r-normal--$default_size-120-75-75-m-70-iso8859-1" ; $userfont = "-adobe-courier-bold-o-normal--$default_size-120-75-75-m-70-iso8859-1" ; $buttonfont = "-adobe-helvetica-bold-r-normal--$default_size-120-75-75-p-69-iso8859-1" } + +my $s_vertical = 30 ; +my $s_horizontal = 72 ; +my $c_horizontal = 24 ; -my $s_vertical = 30 ; -my $s_horizontal = 72 ; -my $c_horizontal = 24 ; - -#D The main window is not resizable, but the text area and -#D command list will have scrollbars. +#D The main window is not resizable, but the text area and +#D command list will have scrollbars. -my %lw ; # stack of lists +my %lw ; # stack of lists my $mw = MainWindow -> new ( -title => 'ConTeXt commands' ) ; -$mw -> withdraw() ; $mw -> resizable ('y', 'y') ; +$mw -> withdraw() ; $mw -> resizable ('y', 'y') ; -sub SetupWindow { return $mw } ; +sub SetupWindow { return $mw } ; -my $bw = $mw -> Frame () ; # buttons -my $tw = $mw -> Frame () ; # sw + fw -my $fw = $tw -> Frame () ; # string + list +my $bw = $mw -> Frame () ; # buttons +my $tw = $mw -> Frame () ; # sw + fw +my $fw = $tw -> Frame () ; # string + list -my $request = $fw -> Entry ( -font => $textfont , +my $request = $fw -> Entry ( -font => $textfont , -background => 'ivory1' , - -width => $c_horizontal ) ; + -width => $c_horizontal ) ; my $cw = $fw -> Scrolled ( 'Listbox' , -scrollbars => 'e' , -font => $textfont , - -width => $c_horizontal , + -width => $c_horizontal , -selectbackground => 'gray' , -background => 'ivory1' , -selectmode => 'browse' ) ; $cw -> pack ( -side => 'bottom' , -fill => 'both' , -expand => 1 ) ; -$request -> pack ( -side => 'top' , -fill => 'x' ) ; +$request -> pack ( -side => 'top' , -fill => 'x' ) ; my $sw = $tw -> Scrolled ( 'ROText' , -scrollbars => 'se' , - -height => $s_vertical , - -width => $s_horizontal , + -height => $s_vertical , + -width => $s_horizontal , -wrap => 'none' , -background => 'ivory1' , -font => $textfont ) ; -#D And the whole bunch of widgets are packed in the main -#D window. +#D And the whole bunch of widgets are packed in the main +#D window. -sub pack_them_all +sub pack_them_all { $sw -> pack ( -side => 'left' , -fill => 'both' , -expand => 1 ) ; - $fw -> pack ( -side => 'right' , -fill => 'y' , -expand => 0 ) ; + $fw -> pack ( -side => 'right' , -fill => 'y' , -expand => 0 ) ; $bw -> pack ( -side => 'top' , -fill => 'x' , -anchor => 'w' , -expand => 1 ) ; $tw -> pack ( -side => 'bottom', -fill => 'both' , -expand => 1 ) } -sub unpack_them_all +sub unpack_them_all { } -pack_them_all ; +pack_them_all ; #D We scan for available setup files, with suffix \type {tws}. #D These should be somewhere on the system, grouped in one #D directory. At least the english file \type {cont-en.tws} -#D should be found. +#D should be found. -my $tws_path = '' ; -my @setup_files = ('cont-en.tws') ; -my $setup_file = $setup_files[0] ; -my $setup_interface = 'en' ; +my $tws_path = '' ; +my @setup_files = ('cont-en.tws') ; +my $setup_file = $setup_files[0] ; +my $setup_interface = 'en' ; my $old_setup_file = '' ; -sub set_setup_interface - { $setup_interface = shift } +sub set_setup_interface + { $setup_interface = shift } -sub set_setup_title +sub set_setup_title { $mw -> configure ( -title => shift ) } -sub setups_found - { $tws_path = `kpsewhich --format="other text files" --progname=context cont-en.tws` ; - $tws_path =~ s/cont-en\.tws.*// ; - chop $tws_path ; - @setup_files = glob ("$tws_path*.tws") ; - if (@setup_files) - { foreach (@setup_files) { s/\.tws// ; s/.*\/// } +sub setups_found + { $tws_path = `kpsewhich --format="other text files" --progname=context cont-en.tws` ; + $tws_path =~ s/cont-en\.tws.*// ; + chop $tws_path ; + @setup_files = glob ("$tws_path*.tws") ; + if (@setup_files) + { foreach (@setup_files) { s/\.tws// ; s/.*\/// } $setup_file = $setup_files[0] ; - return 1 } - else - { return 0 } } + return 1 } + else + { return 0 } } -#D A hide button +#D A hide button sub show_hide_button { my $hb = $bw -> Button ( -text => "hide" , - -font => $buttonfont , - -command => \&hide_widget ) ; - $hb -> pack ( -padx => '2p', - -pady => '2p', - -side => 'right' ) } + -font => $buttonfont , + command => \&hide_widget ) ; + $hb -> pack ( -padx => '2p', + -pady => '2p', + -side => 'right' ) } -sub hide_widget - { $mw -> withdraw() } +sub hide_widget + { $mw -> withdraw() } -#D The setup files can be shown and chosen. +#D The setup files can be shown and chosen. -sub show_setups - { unpack_them_all ; +sub show_setups + { unpack_them_all ; foreach (@setup_files) - { $lw{$_} = $bw -> Radiobutton ( -text => lc $_ , - -value => $_ , - -font => $buttonfont , + { $lw{$_} = $bw -> Radiobutton ( -text => lc $_ , + -value => $_ , + -font => $buttonfont , -selectcolor => 'ivory1' , - -indicatoron => 0 , + -indicatoron => 0 , command => \&change_setup , -variable => \$setup_file ) ; - $lw{$_} -> pack ( -padx => '2p', - -pady => '2p', - -side => 'left' ) } + $lw{$_} -> pack ( -padx => '2p', + -pady => '2p', + -side => 'left' ) } pack_them_all } $cw -> bind ('<B1-Motion>', \&update_setup ) ; @@ -207,36 +207,36 @@ $sw -> tag ('configure', 'par' , -lmargin1 => '4m' , -lmargin2 => '6m' ) ; my %setups ; -my %commands ; -my %loadedsetups ; -my %positions ; -my %crosslinks ; +my %commands ; +my %loadedsetups ; +my %positions ; +my %crosslinks ; -my $current_setup = '' ; +my $current_setup = '' ; #D Setups are organized in files called \type {*.tws} and #D alike. Several files can be loaded simultaneously. When #D loading, we grab whole paragraphs. The variables and values #D belonging to a command, are stored in the hash table \type #D {setups}, one per language. The command templates are -#D stored in \type {commands}. -#D +#D stored in \type {commands}. +#D #D A \type {tws} file is generated by \CONTEXT\ from the setup #D definition files. Only \CONTEXT\ knows the current meaning #D of commands and keywords. The files are generating by -#D simply saying something like: -#D -#D \starttypen -#D texexec --interface=en setupd -#D texexec --interface=de setupd -#D texexec --interface=nl setupd -#D texexec --interface=cz setupd -#D texexec --interface=it setupd -#D \stoptypen -#D -#D This results in files formatted as: -#D +#D simply saying something like: +#D #D \starttypen +#D texexec --interface=en setupd +#D texexec --interface=de setupd +#D texexec --interface=nl setupd +#D texexec --interface=cz setupd +#D texexec --interface=it setupd +#D \stoptypen +#D +#D This results in files formatted as: +#D +#D \starttypen #D startsetup #D com:setupcolors #D typ:vars/ @@ -249,22 +249,22 @@ my $current_setup = '' ; #D \stoptypen #D #D This format can be stored rather efficient and parsed rather -#D fast. What more do we need. +#D fast. What more do we need. -sub load_setup - { my $filename = shift ; +sub load_setup + { my $filename = shift ; unless (keys %{$commands{$filename}}) { local $/ = 'stopsetup' ; # in plaats van '' ivm unix ; (taco) - $current_setup = '' ; + $current_setup = '' ; if (open(SETUP, "$tws_path$filename.tws" )) - { my $position = 0 ; + { my $position = 0 ; while (<SETUP>) { chomp ; s/startsetup//mso ; - s/stopsetup//mso ; # redundant geworden + s/stopsetup//mso ; # redundant geworden s/\r\n //gms ; # in plaats van s/ //gms ; (taco) s/com\:(.*?)\:\s(.*)//mso ; - my $string = $1 ; + my $string = $1 ; my $command = $1 ; my $setup = $2 ; ++$position ; @@ -280,20 +280,20 @@ sub load_setup $cw -> selectionSet ('0.0', '0.0') ; $cw -> activate ('0.0') ; $setup_file = $filename ; - update_setup } + update_setup } -sub load_setups +sub load_setups { foreach my $setup (@setup_files) { load_setup ($setup) } ; $mw -> deiconify() } -#D The core of this module deals with transforming the -#D definitions like shown earlier. Details on the format -#D can be found in the file \type {setupd.tex}. We use the -#D \type {Tk::Text} automatic hanging identation features. -#D The next subs are examples of the kind you write once +#D The core of this module deals with transforming the +#D definitions like shown earlier. Details on the format +#D can be found in the file \type {setupd.tex}. We use the +#D \type {Tk::Text} automatic hanging identation features. +#D The next subs are examples of the kind you write once #D and never look at again. -my @arguments = () ; +my @arguments = () ; my $nested_setup = 0 ; my $continue_setup = 0 ; my $argument = 0 ; @@ -344,23 +344,23 @@ sub show_command $stopsuffix = $2 } } sub show_left_argument - { local $_ = shift ; + { local $_ = shift ; my @thearg = split (/\//, $arg{$arguments[$_]}) ; $sw -> insert ('end', $thearg[1], ['par',$thearg[0]] ) } sub show_middle_argument - { local $_ = shift ; + { local $_ = shift ; my @thearg = split (/\//, $arg{$arguments[$_]}) ; if ($thearg[1]) - { $sw -> insert ('end', $thearg[2], 'par' ) } + { $sw -> insert ('end', $thearg[2], 'par' ) } else { $sw -> insert ('end', $thearg[2], ['par',$thearg[0]] ) } } sub show_right_argument - { local $_ = shift ; + { local $_ = shift ; my @thearg = split (/\//, $arg{$arguments[$_]}) ; $sw -> insert ('end', $thearg[3], ['par',$thearg[0]] ) ; - ++$argument } + ++$argument } sub show_reference { if (($nested_setup<=1)&&(defined($arguments[$argument]))) @@ -371,7 +371,7 @@ sub show_reference show_right_argument ($argument) } } } sub show_stop_command - { my $before_stop = shift ; + { my $before_stop = shift ; if ($stopcommand) { if ($stopsuffix) { $sw -> insert ('end', '\\stop', 'command' ) ; @@ -380,23 +380,23 @@ sub show_stop_command { $sw -> insert ('end', $stopcommand, 'command' ) } } } sub show_whatever_left - { while ($argument<@arguments) + { while ($argument<@arguments) { $sw -> insert ('end', "\n" ) ; show_left_argument ($argument) ; show_middle_argument ($argument) ; - show_right_argument ($argument) ; - ++$argument } + show_right_argument ($argument) ; + ++$argument } if ($stopcommand) { $sw -> insert ('end', "\n...\n...\n...\n", 'par') ; show_stop_command } } -sub do_update_setup # type: 0=all 1=vars 2=vals - { my ($command, $type) = @_ ; +sub do_update_setup # type: 0=all 1=vars 2=vals + { my ($command, $type) = @_ ; my $setup = $setups{$setup_file}{$command} ; - my $default = '' ; - my $key = '' ; - my $meaning = '' ; - my @values = () ; + my $default = '' ; + my $key = '' ; + my $meaning = '' ; + my @values = () ; local $_ ; ++$nested_setup ; while ($setup=~/(typ|var|val|ivr|ivl)\:(.*?)\:\s/mgo) @@ -405,9 +405,9 @@ sub do_update_setup # type: 0=all 1=vars 2=vals if (($key=~/var/o)&&($type!=2)) { $_ = $meaning ; s/(.*?)\:(.*?)\:(.*)//o ; if (($nested_setup>1)&&(!$2)) { next } - $key = $1 ; + $key = $1 ; if ($3) { $default = $3 } else { $default = '' } - $_= $2 ; s/\s//go ; @values = split (/,/,$_) ; + $_= $2 ; s/\s//go ; @values = split (/,/,$_) ; if ($continue_setup) { $sw -> insert ('end', ",\n ", 'par') } else @@ -419,8 +419,8 @@ sub do_update_setup # type: 0=all 1=vars 2=vals #while (1) while (@values) { my $value = shift @values ; - if ($value =~ /^\*/o) - { $value =~ s/^\*//o ; + if ($value =~ /^\*/o) + { $value =~ s/^\*//o ; $sw -> insert ('end', lc $value, ['variable','par'] ) } elsif ($value eq $default) { $sw -> insert ('end', $value, ['default','par'] ) } @@ -442,10 +442,10 @@ sub do_update_setup # type: 0=all 1=vars 2=vals show_left_argument($argument) ; #while (1) while (@values) - { unless (@values) { last } + { unless (@values) { last } my $value = shift (@values) ; if ($value =~ /^\*/o) - { $value =~ s/^\*//o ; + { $value =~ s/^\*//o ; $sw -> insert ('end', lc $value, ['variable','par'] ) } elsif ($value eq $default) { $sw -> insert ('end', $value, ['default','par'] ) } @@ -467,13 +467,13 @@ sub do_update_setup # type: 0=all 1=vars 2=vals $arguments =~ s/stp//go } @arguments = split (/\//,$arguments) ; if (@arguments) - { for (my $i=0;$i<@arguments;$i++) + { for (my $i=0;$i<@arguments;$i++) { show_left_argument ($i) ; show_middle_argument ($i) ; show_right_argument ($i) } - if ($stopcommand) + if ($stopcommand) { $sw -> insert ('end', ' ... ') ; - show_stop_command } + show_stop_command } $sw -> insert ('end', "\n\n") ; show_command ($command) } $argument = 0 ; @@ -486,23 +486,23 @@ sub do_update_setup # type: 0=all 1=vars 2=vals do_update_setup ($1,2) } show_reference } --$nested_setup ; - if (($continue_setup)&&(!$nested_setup)) + if (($continue_setup)&&(!$nested_setup)) { show_right_argument ; show_whatever_left } } #D Now the real work is done, we only have to define a few -#D housekeeping routines. The next sub adapts the text area -#D to the current selected command and normally is bound to -#D the list browsing commands. +#D housekeeping routines. The next sub adapts the text area +#D to the current selected command and normally is bound to +#D the list browsing commands. -sub update_setup +sub update_setup { $old_setup_file = $setup_file ; if (keys %{$commands{$setup_file}}) - { my $key ; + { my $key ; unless ($cw->curselection) - { $cw -> selectionSet('0.0','0.0') } + { $cw -> selectionSet('0.0','0.0') } $key = $cw -> get($cw->curselection) ; - if ($current_setup ne $key) + if ($current_setup ne $key) { $current_setup = $key ; $sw -> delete ('1.0', 'end' ) ; $nested_setup = 0 ; @@ -510,58 +510,58 @@ sub update_setup $stopcommand = '' ; $stopsuffix = '' ; do_update_setup ($key,0) ; - $mw -> raise ; + $mw -> raise ; $mw -> focus } } } #D In editors we want to provide context sensitive help #D information. The next sub first tries to locate the #D commands asked for in the setup data currently selected, -#D and when not found takes a look at all the loaded files. - -sub show_setup +#D and when not found takes a look at all the loaded files. + +sub show_setup { my $asked_for = shift ; - unless ($asked_for) { return } - my $found = 0 ; - $asked_for =~ s/^\\// ; - if ($setup_interface) - { $found = 0 ; - foreach my $name (@setup_files) - { if (($name=~/\-$setup_interface/)&&(exists($commands{$name}{$asked_for}))) - { $found = 1 ; - $setup_file = $name ; - last } } } - if (!($found)&&(exists($commands{$setup_file}{$asked_for}))) - { $found = 1 } - else - { $found = 0 ; - foreach my $name (@setup_files) - { if (exists($commands{$name}{$asked_for})) - { $found = 1 ; - $setup_file = $name ; - last } } } - if ($found) + unless ($asked_for) { return } + my $found = 0 ; + $asked_for =~ s/^\\// ; + if ($setup_interface) + { $found = 0 ; + foreach my $name (@setup_files) + { if (($name=~/\-$setup_interface/)&&(exists($commands{$name}{$asked_for}))) + { $found = 1 ; + $setup_file = $name ; + last } } } + if (!($found)&&(exists($commands{$setup_file}{$asked_for}))) + { $found = 1 } + else + { $found = 0 ; + foreach my $name (@setup_files) + { if (exists($commands{$name}{$asked_for})) + { $found = 1 ; + $setup_file = $name ; + last } } } + if ($found) { my @list = sort {lc $a cmp lc $b} keys %{$commands{$setup_file}} ; $cw -> delete ('0.0', 'end') ; $cw -> insert ('end', @list) ; - $found = 0 ; - foreach (@list) { if ($_ eq $asked_for) { last } ++$found } - my $index = "$found.0" ; + $found = 0 ; + foreach (@list) { if ($_ eq $asked_for) { last } ++$found } + my $index = "$found.0" ; $cw -> selectionSet ($index, $index) ; $cw -> activate ($index) ; $cw -> see ($index) ; update_setup ; - $mw -> raise ; - $mw -> focus } } + $mw -> raise ; + $mw -> focus } } #D Whenever a new set of commands is selected (by means of the #D buttons on top the screen) the list and text are to be -#D updated. +#D updated. -sub change_setup - { my $command = '' ; +sub change_setup + { my $command = '' ; if ($old_setup_file) { unless ($cw->curselection) - { $cw -> selectionSet('0.0','0.0') } + { $cw -> selectionSet('0.0','0.0') } $command = $cw -> get($cw->curselection) ; my $position = $positions{$old_setup_file}{$command} ; $command = $crosslinks{$setup_file}[$position] } @@ -569,102 +569,102 @@ sub change_setup my @list = sort {lc $a cmp lc $b} keys %{$commands{$setup_file}} ; $cw -> delete ('0.0', 'end') ; $cw -> insert ('end', @list) ; - if ($command) - { show_setup($command) } - else - { $cw -> selectionClear ('0.0','end') ; + if ($command) + { show_setup($command) } + else + { $cw -> selectionClear ('0.0','end') ; $cw -> selectionSet ('0.0', '0.0') ; $cw -> see ('0.0') ; $cw -> activate ('0.0') } update_setup ; - $mw -> raise ; + $mw -> raise ; $mw -> focus } #D Sometimes we want to make sure the dat is loaded indeed: sub setup_found - { my $filename = shift ; - if (-e "$tws_path$filename.tws") - { $setup_file = $filename ; - return 1 } - else + { my $filename = shift ; + if (-e "$tws_path$filename.tws") + { $setup_file = $filename ; + return 1 } + else { return 0 } } -#D The next feature is dedicated to Tobias, who suggested -#D it, and Taco, who saw it as yet another proof of the -#D speed of \PERL. It's also dedicated to Ton, who needs it -#D for translating the big manual. +#D The next feature is dedicated to Tobias, who suggested +#D it, and Taco, who saw it as yet another proof of the +#D speed of \PERL. It's also dedicated to Ton, who needs it +#D for translating the big manual. -sub handle_request +sub handle_request { my $index = $cw -> index('end') ; - unless ($index) { return } - my $req = $request -> get ; - unless ($req) { return } - $req =~ s/\\//o ; - $req =~ s/\s//go ; - $request -> delete('0','end') ; - $request -> insert('0',$req) ; - unless ($req) { return } - my ($l,$c) = split (/\./,$index) ; + unless ($index) { return } + my $req = $request -> get ; + unless ($req) { return } + $req =~ s/\\//o ; + $req =~ s/\s//go ; + $request -> delete('0','end') ; + $request -> insert('0',$req) ; + unless ($req) { return } + my ($l,$c) = split (/\./,$index) ; for (my $i=0;$i<=$l;$i++) - { $index = "$i.0" ; - my $str = $cw -> get ($index, $index) ; - if ($str =~ /^$req/) - { $cw -> selectionClear ('0.0','end') ; - $cw -> selectionSet ($index, $index) ; + { $index = "$i.0" ; + my $str = $cw -> get ($index, $index) ; + if ($str =~ /^$req/) + { $cw -> selectionClear ('0.0','end') ; + $cw -> selectionSet ($index, $index) ; $cw -> activate ($index) ; $cw -> see ($index) ; - update_setup ; - $mw -> raise ; + update_setup ; + $mw -> raise ; $mw -> focus ; - return } } } + return } } } $request -> bind ('<Return>', sub { handle_request } ) ; -sub insert_request +sub insert_request { my ($self, $chr) = @_ ; - if ($self ne $request) + if ($self ne $request) { $request -> insert ('end', $chr) } - handle_request } + handle_request } foreach my $chr ('a'..'z','A'..'Z') - { $mw -> bind ( "<KeyPress-$chr>", sub { insert_request(shift, $chr) } ) } + { $mw -> bind ( "<KeyPress-$chr>", sub { insert_request(shift, $chr) } ) } $mw -> bind ( "<backslash>", sub { insert_request(shift, "\\") } ) ; sub delete_request { my $self = shift ; - if ($self ne $request) - { my $to = $request -> index ('end') ; + if ($self ne $request) + { my $to = $request -> index ('end') ; my $from = $to - 1 ; if ($from<0) { $from = 0 } $request -> delete ($from,$to) } - handle_request } + handle_request } $mw -> bind ( "<BackSpace>", sub { delete_request } ) ; -sub new_request +sub new_request { $request -> delete (0,'end') ; handle_request } $mw -> bind ( "<space>", sub { new_request } ) ; -#D Just in case: +#D Just in case: -sub raise_setup +sub raise_setup { $mw -> raise } -sub dont_exit - { $mw -> protocol( 'WM_DELETE_WINDOW' => sub { } ) } +sub dont_exit + { $mw -> protocol( 'WM_DELETE_WINDOW' => sub { } ) } -#D An example use is: +#D An example use is: #D -#D \starttypen -#D load_setup ("cont-$nl") ; -#D show_setup ('omlijnd') ; +#D \starttypen +#D load_setup ("cont-$nl") ; +#D show_setup ('omlijnd') ; #D MainLoop () ; -#D \stoptypen +#D \stoptypen #D -#D Now everything is done, we return 1: +#D Now everything is done, we return 1: 1 ; diff --git a/scripts/context/perl/mptopdf.pl b/scripts/context/perl/mptopdf.pl index 0528a4010..337869519 100644 --- a/scripts/context/perl/mptopdf.pl +++ b/scripts/context/perl/mptopdf.pl @@ -1,7 +1,7 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' && eval 'exec perl -S $0 $argv:q' if 0; -# MikTeX users can set environment variable TEXSYSTEM to "miktex". +# MikTeX users can set environment variable TEXSYSTEM to "miktex". #D \module #D [ file=mptopdf.pl, @@ -17,70 +17,68 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' && eval 'exec perl -S $0 $ #C therefore copyrighted by \PRAGMA. See licen-en.pdf for #C details. -# use File::Copy ; # not in every perl +# use File::Copy ; # not in every perl use Config ; use Getopt::Long ; -use strict ; +use strict ; $Getopt::Long::passthrough = 1 ; # no error message $Getopt::Long::autoabbrev = 1 ; # partial switch accepted -my $Help = my $Latex = my $RawMP = 0 ; -my $PassOn = '' ; +my $Help = my $Latex = my $RawMP = 0 ; +my $PassOn = '' ; &GetOptions ( "help" => \$Help , - "rawmp" => \$RawMP, + "rawmp" => \$RawMP, "passon" => \$PassOn, "latex" => \$Latex ) ; - -my $program = "MPtoPDF 1.3" ; + +my $program = "MPtoPDF 1.2" ; my $pattern = $ARGV[0] ; my $done = 0 ; my $report = '' ; -my $texlatexswitch = " --tex=latex --format=latex " ; -my $mplatexswitch = " --tex=latex " ; +my $latexswitch = " --tex=latex --format=latex " ; + +## $dosish = ($Config{'osname'} =~ /dos|mswin/i) ; +my $dosish = ($Config{'osname'} =~ /^(ms)?dos|^os\/2|^(ms|cyg)win/i) ; -my $dosish = ($Config{'osname'} =~ /^(ms)?dos|^os\/2|^(ms|cyg)win/i) ; -my $miktex = ($ENV{"TEXSYSTEM"} =~ /miktex/io); -my $escapeshell = ( ($ENV{'SHELL'}) && ($ENV{'SHELL'} =~ m/sh/i )); +my $miktex = ($ENV{"TEXSYSTEM"} =~ /miktex/io); -my @files ; -my $command = my $mpbin = '' ; +my @files ; +my $command = my $mpbin = '' ; -sub CopyFile # agressive copy, works for open files like in gs - { my ($From,$To) = @_ ; - return unless open(INP,"<$From") ; binmode INP ; - return unless open(OUT,">$To") ; binmode OUT ; - while (<INP>) { print OUT $_ } - close (INP) ; +sub CopyFile # agressive copy, works for open files like in gs + { my ($From,$To) = @_ ; + return unless open(INP,"<$From") ; binmode INP ; + return unless open(OUT,">$To") ; binmode OUT ; + while (<INP>) { print OUT $_ } + close (INP) ; close (OUT) } if (($pattern eq '')||($Help)) { print "\n$program : provide MP output file (or pattern)\n" ; exit } -elsif ($pattern =~ /\.mp$/io) - { shift @ARGV ; my $rest = join(" ", @ARGV) ; +elsif ($pattern =~ /\.mp$/io) + { shift @ARGV ; my $rest = join(" ", @ARGV) ; if (open(INP,$pattern)) - { while (<INP>) - { if (/(documentstyle|documentclass|begin\{document\})/io) - { $Latex = 1 ; last } } - close (INP) } + { while (<INP>) + { if (/(documentstyle|documentclass|begin\{document\})/io) + { $Latex = 1 ; last } } + close (INP) } + if ($Latex) + { $rest .= " $latexswitch" } if ($RawMP) - { if ($Latex) - { $rest .= " $mplatexswitch" } - $mpbin = 'mpost' } + { $mpbin = 'mpost' } else - { if ($Latex) - { $rest .= " $texlatexswitch" } - $mpbin = 'texexec --mptex $PassOn' } + { $mpbin = 'texexec --mptex $PassOn' } my $error = system ("$mpbin $rest $pattern") ; - if ($error) - { print "\n$program : error while processing mp file\n" ; exit } - else - { $pattern =~ s/\.mp$//io ; - @files = glob "$pattern.*" } } + if ($error) + { print "\n$program : error while processing mp file\n" ; exit } + else + { $pattern =~ s/\.mp$//io ; + @files = glob "$pattern.*" } } elsif (-e $pattern) { @files = ($pattern) } elsif ($pattern =~ /.\../o) @@ -92,17 +90,15 @@ else foreach my $file (@files) { $_ = $file ; if (s/\.(\d+|mps)$// && -e $file) - { if ($miktex) - { if ($dosish) - { $command = "pdfetex &mptopdf" } + { if ($miktex) + { if ($dosish) + { $command = "pdfetex &mptopdf" } else { $command = "pdfetex \\&mptopdf" } } - else - { if ($dosish) - { $command = "pdfetex -progname=context &mptopdf" } - else - { $command = "pdfetex -progname=context \\&mptopdf" } } - if ($dosish) + else +# { $command = "pdfetex -progname=pdfetex -efmt=mptopdf" } + { $command = "pdfetex -progname=context -efmt=mptopdf" } + if ($dosish) { system ("$command \\relax $file") } else { system ("$command \\\\relax $file") } @@ -112,8 +108,8 @@ foreach my $file (@files) $report .= " $_-$1.pdf" ; ++$done } } -if ($report eq '') - { $report = '*' } +if ($report eq '') + { $report = '*' } if ($done) { print "\n$program : $pattern is converted to$report\n" } diff --git a/scripts/context/perl/texexec.pl b/scripts/context/perl/texexec.pl index 9a1d31bdc..0e1d4c0ab 100644 --- a/scripts/context/perl/texexec.pl +++ b/scripts/context/perl/texexec.pl @@ -3,7 +3,7 @@ eval '(exit $?0)' && eval 'exec perl -w -S $0 ${1+"$@"}' && eval 'exec perl -w - #D \module #D [ file=texexec.pl, -#D version=2004.08.29, +#D version=2003.09.16, #D title=running \ConTeXt, #D subtitle=\TEXEXEC, #D author=Hans Hagen, @@ -33,7 +33,6 @@ eval '(exit $?0)' && eval 'exec perl -w -S $0 ${1+"$@"}' && eval 'exec perl -w - #D everything. Well, the result is a messy script like this ... Sorry. use strict ; -#~ use warnings ; # strange warnings, todo # todo: second run of checksum of mp file with --nomprun changes # todo: warning if no args @@ -118,7 +117,6 @@ my $FinalMode = 0; my $Format = ''; my $MpDoFormat = ''; my $HelpAsked = 0; -my $Version = 0; my $MainBodyFont = 'standard'; my $MainLanguage = 'standard'; my $MainResponse = 'standard'; @@ -170,7 +168,6 @@ my $PdfCopy = 0; my $LogFile = ""; my $MpyForce = 0; my $InpPath = ""; -my $AutoPath = 0; my $RunPath = ""; my $Arguments = ""; my $Pretty = 0; @@ -185,9 +182,7 @@ my $AllPatterns = 0; my $ForceXML = 0; my $Random = 0; my $Filters = ''; -my $NoMapFiles = 0 ; -my $Foxet = 0 ; -my $TheEnginePath = 0 ; +my $NoMapFiles = 0; my $StartLine = 0 ; my $StartColumn = 0 ; @@ -214,7 +209,6 @@ my $MakeMpy = ''; "format=s" => \$Format, "mpformat=s" => \$MpDoFormat, "help" => \$HelpAsked, - "version" => \$Version, "interface=s" => \$ConTeXtInterface, "language=s" => \$MainLanguage, "bodyfont=s" => \$MainBodyFont, @@ -240,7 +234,6 @@ my $MakeMpy = ''; "paper=s" => \$PaperFormat, "passon=s" => \$PassOn, "path=s" => \$InpPath, - "autopath" => \$AutoPath, "pdf" => \$ProducePdfT, "pdm" => \$ProducePdfM, "pdx" => \$ProducePdfX, @@ -290,8 +283,6 @@ my $MakeMpy = ''; "modefile=s" => \$ModeFile, # additional modes file "globalfile" => \$GlobalFile, "nomapfiles" => \$NoMapFiles, - "foxet" => \$Foxet, - "engine" => \$TheEnginePath, #### exxperiment "startline=s" => \$StartLine, "startcolumn=s" => \$StartColumn, @@ -299,12 +290,6 @@ my $MakeMpy = ''; "endcolumn=s" => \$EndColumn ); # don't check name -if ($Foxet) { - $ProducePdfT = 1 ; - $ForceXML = 1 ; - $Modules = "foxet" ; -} - # a set file (like blabla.bat) can set paths now if ( $SetFile ne "" ) { load_set_file( $SetFile, $Verbose ); $SetFile = "" } @@ -354,7 +339,7 @@ if ( ( $LogFile ne '' ) && ( $LogFile =~ /\w+\.log$/io ) ) { *STDERR = *LOGFILE; } -my $Program = " TeXExec 5.0 - ConTeXt / PRAGMA ADE 1997-2004"; +my $Program = " TeXExec 4.3 - ConTeXt / PRAGMA ADE 1997-2004"; print "\n$Program\n\n"; @@ -652,11 +637,6 @@ if ( open( INI, $IniPath ) ) { sub IniValue { my ( $Key, $Default ) = @_; if ( defined( $Done{$Key} ) ) { $Default = $Done{$Key} } - if ($Default =~ /^(true|yes|on)$/io) { - $Default = 1 ; - } elsif ($Default =~ /^(false|no|off)$/io) { - $Default = 0 ; - } if ($Verbose) { print " used setting : $Key = $Default\n" } return $Default; } @@ -676,10 +656,10 @@ my $TeXScriptsPath = IniValue( 'TeXScriptsPath', '' ); my $TeXHashExecutable = IniValue( 'TeXHashExecutable', '' ); my $TeXExecutable = IniValue( 'TeXExecutable', 'tex' ); my $TeXVirginFlag = IniValue( 'TeXVirginFlag', '-ini' ); -my $TeXBatchFlag = IniValue( 'TeXBatchFlag', '-interaction=batchmode' ); -my $TeXNonStopFlag = IniValue( 'TeXNonStopFlag', '-interaction=nonstopmode' ); -my $MpBatchFlag = IniValue( 'MpBatchFlag', '-interaction=batchmode' ); -my $MpNonStopFlag = IniValue( 'MpNonStopFlag', '-interaction=nonstopmode' ); +my $TeXBatchFlag = IniValue( 'TeXBatchFlag', '-int=batchmode' ); +my $TeXNonStopFlag = IniValue( 'TeXNonStopFlag', '-int=nonstopmode' ); +my $MpBatchFlag = IniValue( 'MpBatchFlag', '-int=batchmode' ); +my $MpNonStopFlag = IniValue( 'MpNonStopFlag', '-int=nonstopmode' ); my $TeXPassString = IniValue( 'TeXPassString', '' ); my $TeXFormatFlag = IniValue( 'TeXFormatFlag', '' ); my $MpFormatFlag = IniValue( 'MpFormatFlag', '' ); @@ -687,14 +667,12 @@ my $MpVirginFlag = IniValue( 'MpVirginFlag', '-ini' ); my $MpPassString = IniValue( 'MpPassString', '' ); my $MpFormat = IniValue( 'MpFormat', $MetaFun ); my $MpFormatPath = IniValue( 'MpFormatPath', $TeXFormatPath ); -my $UseEnginePath = IniValue( 'UseEnginePath', $TheEnginePath); my $FmtLanguage = IniValue( 'FmtLanguage', '' ); my $FmtBodyFont = IniValue( 'FmtBodyFont', '' ); my $FmtResponse = IniValue( 'FmtResponse', '' ); my $TcXPath = IniValue( 'TcXPath', '' ); - $SetFile = IniValue( 'SetFile', $SetFile ); if ( ($Verbose) && ( $kpsewhich ne '' ) ) { @@ -732,29 +710,20 @@ if ( $MpFormatFlag eq "" ) { $MpFormatFlag = "-mem=" ; } -if ($UseEnginePath && (! $MakeFormats)) { - $MpFormatFlag .= $MpExecutable . '/' ; - $TeXFormatFlag .= $TeXExecutable . '/' ; -} - #~ if ( $TeXFormatFlag eq "" ) { $TeXFormatFlag = "&" } #~ if ( $MpFormatFlag eq "" ) { $MpFormatFlag = "&" } -unless ( $dosish && !$escapeshell ) { - if ( $TeXFormatFlag eq "&" ) { $TeXFormatFlag = "\\&" } - if ( $MpFormatFlag eq "&" ) { $MpFormatFlag = "\\&" } -} +#~ unless ( $dosish && !$escapeshell ) { + #~ if ( $TeXFormatFlag eq "&" ) { $TeXFormatFlag = "\\&" } + #~ if ( $MpFormatFlag eq "&" ) { $MpFormatFlag = "\\&" } +#~ } if ($TeXProgram) { $TeXExecutable = $TeXProgram } my $fmtutil = ''; -# for the moment forget about fmtutil, since it does not support $engine subpaths - -$Alone = 1 ; - if ( $MakeFormats || $Verbose ) { - if ($Alone || $UseEnginePath) { + if ($Alone) { if ($Verbose) { print " generating format : not using fmtutil\n" } } elsif ( $TeXShell =~ /tetex|fptex/i ) { foreach (@paths) { @@ -762,7 +731,7 @@ if ( $MakeFormats || $Verbose ) { if ( -e $p ) { $fmtutil = $p; last } elsif ( -e $p . '.exe' ) { $fmtutil = $p . '.exe'; last } } - $fmtutil = ($fmtutil =~ m/^[^\"].* / ? "\"$fmtutil\"" : "$fmtutil") ; + $fmtutil = ($fmtutil =~ m/^[^\"].* / ? "\"$fmtutil\"" : "$fmtutil") ; if ($Verbose) { if ( $fmtutil eq '' ) { print " locating fmtutil : not found in path\n"; @@ -944,14 +913,11 @@ sub print_opt { sub show_help_options { print # "\n" . - " --help overview of all options and their values\n" + " --help overview of all options and their values\n" . " --help all all about all options\n" . " --help short just the main options\n" . " --help mode ... pdf all about a few options\n" - . " --help '*.pdf' all about options containing 'pdf'\n" - . "\n" - . " more info http://www.pragma-ade.com/general/manuals/mtexexec.pdf\n" - . " http://www.ntg.nl/mailman/listinfo/ntg-context\n"; + . " --help '*.pdf' all about options containing 'pdf'\n"; } # determine what user wants to see @@ -1021,10 +987,7 @@ sub RunPerlScript { } else { $cmd = "$ScriptName $Options"; } - unless ( $cmd eq "" ) { - print $cmd if ($Verbose) ; - system($cmd) ; - } + unless ( $cmd eq "" ) { system($cmd) } } my $FullFormat = ''; @@ -1046,7 +1009,7 @@ sub CheckOutputFormat { if ( !$Ok ) { print $Help{'output'}; } elsif ($FullFormat) { - # print OPT "\\setupoutput[$FullFormat]\n"; + print OPT "\\setupoutput[$FullFormat]\n"; } } unless ($FullFormat) { $FullFormat = $OutputFormat } @@ -1057,8 +1020,6 @@ sub MakeOptionFile { open( OPT, ">$JobName.top" ); print OPT "\% $JobName.top\n"; print OPT "\\unprotect\n"; - $ModeFile =~ s/\\/\//gio ; # do this at top of file - $Result =~ s/\\/\//gio ; # do this at top of file if ( $ModeFile ne '' ) { print OPT "\\readlocfile{$ModeFile}{}{}" } if ( $Result ne '' ) { print OPT "\\setupsystem[file=$Result]\n" } elsif ($Suffix) { print OPT "\\setupsystem[file=$JobName$Suffix]\n" } @@ -1083,16 +1044,16 @@ sub MakeOptionFile { } if ($EnterBatchMode) { print OPT "\\batchmode\n" } if ($EnterNonStopMode) { print OPT "\\nonstopmode\n" } - if ($UseColor) { print OPT "\\setupcolors[\\c!state=\\v!start]\n" } + if ($UseColor) { print OPT "\\setupcolors[\\c!status=\\v!start]\n" } if ( $NoMPMode || $NoMPRun || $AutoMPRun ) { print OPT "\\runMPgraphicsfalse\n"; } if ( ($FastMode) && ( !$FastDisabled ) ) { print OPT "\\fastmode\n" } if ($SilentMode) { print OPT "\\silentmode\n" } if ( $Separation ne "" ) { - print OPT "\\setupcolors[\\c!split=$Separation]\n"; + print OPT "\\setupcolors[\\c!splitsen=$Separation]\n"; } - if ($SetupPath) { print OPT "\\setupsystem[\\c!directory=\{$SetupPath\}]\n" } + if ($SetupPath) { print OPT "\\setupsystem[\\c!gebied=\{$SetupPath\}]\n" } print OPT "\\setupsystem[\\c!n=$KindOfRun]\n"; $_ = $PaperFormat; #unless (($PdfArrange)||($PdfSelect)||($PdfCombine)||($PdfCopy)) @@ -1112,41 +1073,41 @@ sub MakeOptionFile { { print " background graphic : $Background\n"; print OPT "\\defineoverlay[whatever][{\\externalfigure[$Background][\\c!factor=\\v!max]}]\n"; - print OPT "\\setupbackgrounds[\\v!page][\\c!background=whatever]\n"; + print OPT "\\setupbackgrounds[\\v!pagina][\\c!achtergrond=whatever]\n"; } if ($CenterPage) { print OPT - "\\setuplayout[\\c!location=\\v!middle,\\c!marking=\\v!on]\n"; + "\\setuplayout[\\c!plaats=\\v!midden,\\c!markering=\\v!aan]\n"; } if ($NoMapFiles) { print OPT "\\disablemapfiles\n"; } - if ($NoArrange) { print OPT "\\setuparranging[\\v!disable]\n" } + if ($NoArrange) { print OPT "\\setuparranging[\\v!blokkeer]\n" } elsif ( $Arrange || $PdfArrange ) { $FinalRunNeeded = 1; if ($FinalRun) { my $DupStr; if ($NoDuplex) { $DupStr = "" } - else { $DupStr = ",\\v!doublesided" } + else { $DupStr = ",\\v!dubbelzijdig" } if ( $PrintFormat eq '' ) { - print OPT "\\setuparranging[\\v!normal]\n"; + print OPT "\\setuparranging[\\v!normaal]\n"; } elsif ( $PrintFormat =~ /.*up/goi ) { - print OPT "\\setuparranging[2UP,\\v!rotated$DupStr]\n"; + print OPT "\\setuparranging[2UP,\\v!geroteerd$DupStr]\n"; } elsif ( $PrintFormat =~ /.*down/goi ) { - print OPT "\\setuparranging[2DOWN,\\v!rotated$DupStr]\n"; + print OPT "\\setuparranging[2DOWN,\\v!geroteerd$DupStr]\n"; } elsif ( $PrintFormat =~ /.*side/goi ) { - print OPT "\\setuparranging[2SIDE,\\v!rotated$DupStr]\n"; + print OPT "\\setuparranging[2SIDE,\\v!geroteerd$DupStr]\n"; } else { print OPT "\\setuparranging[$PrintFormat]\n"; } } else { - print OPT "\\setuparranging[\\v!disable]\n"; + print OPT "\\setuparranging[\\v!blokkeer]\n"; } } if ($Arguments) { print OPT "\\setupenv[$Arguments]\n" } if ($Input) { print OPT "\\setupsystem[inputfile=$Input]\n" } else { print OPT "\\setupsystem[inputfile=$JobName.$JobSuffix]\n" } - if ($Random) { print OPT "\\setupsystem[\\c!random=$RandomSeed]\n" } + if ($Random) { print OPT "\\setupsystem[\\c!willekeur=$RandomSeed]\n" } if ($Mode) { print OPT "\\enablemode[$Mode]\n" } if ($Pages) { if ( lc $Pages eq "odd" ) { @@ -1209,7 +1170,7 @@ sub MakeUserFile { if ( $MainLanguage ne 'standard' ) { @MainLanguages = split( /\,/, $MainLanguage ); foreach (@MainLanguages) { - print USR "\\installlanguage[\\s!$_][\\c!state=\\v!start]\n"; + print USR "\\installlanguage[\\s!$_][\\c!status=\\v!start]\n"; } $MainLanguage = $MainLanguages[0]; print USR "\\setupcurrentlanguage[\\s!$MainLanguage]\n"; @@ -1266,7 +1227,7 @@ sub CheckPositions { } my $ConTeXtVersion = "unknown"; my $ConTeXtModes = ''; -sub ScanTeXPreamble { +sub ScanPreamble { my ($FileName) = @_; open( TEX, $FileName ); while (<TEX>) { @@ -1294,19 +1255,12 @@ sub ScanTeXPreamble { } } close(TEX); - - # handy later on - - $ProducePdfT = ($OutputFormat eq "pdftex") ; - $ProducePdfM = ($OutputFormat eq "dvipdfm") ; - $ProducePdfX = ($OutputFormat eq "dvipdfmx") ; } sub ScanContent { my ($ConTeXtInput) = @_; open( TEX, $ConTeXtInput ); while (<TEX>) { - next if (/^\%/) ; if ( /\\(starttekst|stoptekst|startonderdeel|startdocument|startoverzicht)/ ) @@ -1349,65 +1303,9 @@ if ( $ConTeXtInterfaces{$ConTeXtInterface} ) { my $Problems = my $Ok = 0; -#~ sub RunTeX { - #~ my ( $JobName, $JobSuffix ) = @_; - #~ my $StartTime = time; - #~ my $cmd; - #~ my $TeXProgNameFlag = ''; - #~ if ( !$dosish ) # we assume tetex on linux - #~ { - #~ $TeXProgramPath = ''; - #~ $TeXFormatPath = ''; - #~ if ( !$TeXProgNameFlag - #~ && ( $Format =~ /^cont/ ) - #~ && ( $TeXPassString !~ /progname/io ) ) - #~ { - #~ $TeXProgNameFlag = "-progname=context"; - #~ } - #~ } - #~ $own_quote = ($TeXProgramPath =~ m/^[^\"].* / ? "\"" : "") ; - #~ $cmd = join( ' ', - #~ "$own_quote$TeXProgramPath$TeXExecutable$own_quote", - #~ $TeXProgNameFlag, $TeXPassString, $PassOn, "" ); - #~ if ($EnterBatchMode) { $cmd .= "$TeXBatchFlag " } - #~ if ($EnterNonStopMode) { $cmd .= "$TeXNonStopFlag " } - #~ if ( $TeXTranslation ne '' ) { $cmd .= "-translate-file=$TeXTranslation " } - #~ $cmd .= "$TeXFormatFlag$TeXFormatPath$Format $JobName.$JobSuffix"; - #~ if ($Verbose) { print "\n$cmd\n\n" } - #~ if ($EnterBatchMode) { - #~ $Problems = system("$cmd"); - #~ } else { - #~ $Problems = system("$cmd"); - #~ } - #~ # generate formats if needed and retry - #~ # - #~ # well, this used to work ok, until a engines started to use the same suffix - #~ # and no robust check was possible any more - #~ # - #~ # if ($Problems) { - #~ # my $efmt = `$kpsewhich cont-en.efmt` ; - #~ # chomp $efmt ; - #~ # if ($efmt eq "") { - #~ # print "\n"; - #~ # print " emergency action : generate all formats\n"; - #~ # system("texexec --make --alone --all") ; - #~ # print "\n"; - #~ # print " emergency action : retry processing file\n"; - #~ # if ($EnterBatchMode) { - #~ # $Problems = system("$cmd"); - #~ # } else { - #~ # $Problems = system("$cmd"); - #~ # } - #~ # } - #~ # } - #~ my $StopTime = time - $StartTime; - #~ print "\n return code : $Problems"; - #~ print "\n run time : $StopTime seconds\n"; - #~ return $Problems; -#~ } - -sub PrepRunTeX { - my ( $JobName, $JobSuffix, $PipeString ) = @_; +sub RunTeX { + my ( $JobName, $JobSuffix ) = @_; + my $StartTime = time; my $cmd; my $TeXProgNameFlag = ''; if ( !$dosish ) # we assume tetex on linux @@ -1428,15 +1326,8 @@ sub PrepRunTeX { if ($EnterBatchMode) { $cmd .= "$TeXBatchFlag " } if ($EnterNonStopMode) { $cmd .= "$TeXNonStopFlag " } if ( $TeXTranslation ne '' ) { $cmd .= "-translate-file=$TeXTranslation " } - $cmd .= "$TeXFormatFlag$TeXFormatPath$Format $JobName.$JobSuffix $PipeString"; + $cmd .= "$TeXFormatFlag$TeXFormatPath$Format $JobName.$JobSuffix"; if ($Verbose) { print "\n$cmd\n\n" } - return $cmd; -} - -sub RunTeX { - my ( $JobName, $JobSuffix ) = @_; - my $StartTime = time; - my $cmd = PrepRunTeX($JobName, $JobSuffix, ''); if ($EnterBatchMode) { $Problems = system("$cmd"); } else { @@ -1463,7 +1354,6 @@ sub RunTeX { # } # } # } - my $StopTime = time - $StartTime; print "\n return code : $Problems"; print "\n run time : $StopTime seconds\n"; @@ -1634,7 +1524,7 @@ my $DummyFile = 0; sub isXMLfile { my $Name = shift; - if ( ($ForceXML) || ( $Name =~ /\.(xml|fo|fox)$/io ) ) { return 1 } + if ( ($ForceXML) || ( $Name =~ /\.xml$/io ) ) { return 1 } else { open( XML, $Name ); my $str = <XML>; @@ -1645,23 +1535,9 @@ sub isXMLfile { sub RunConTeXtFile { my ( $JobName, $JobSuffix ) = @_; -if ($AutoPath) { - if ($JobName =~ /^(.*)[\/\\](.*?)$/o) { - $InpPath = $1 ; - $JobName = $2 ; - } -} $JobName =~ s/\\/\//goi; $InpPath =~ s/\\/\//goi; my $OriSuffix = $JobSuffix; -if ($JobSuffix =~ /\_fo$/i) { - if (! -f $JobName) { - print "stripping funny suffix : _fo\n"; - $JobName =~ s/\_fo$//io ; - $JobSuffix =~ s/\_fo$//io ; - $OriSuffix =~ s/\_fo$//io ; - } -} if (($dosish) && ($PdfClose)) { my $ok = system("pdfclose --file $JobName.pdf") if -e "$JobName.pdf" ; if (($Result ne '') && (-e "$Result.pdf")) { @@ -1670,7 +1546,7 @@ if ($JobSuffix =~ /\_fo$/i) { system("pdfclose --all") unless $ok ; } if ( -e "$JobName.$JobSuffix" ) { - $DummyFile = ( ($ForceXML) || ( $JobSuffix =~ /(xml|fo|fox)/io ) ); + $DummyFile = ( ($ForceXML) || ( $JobSuffix =~ /xml/io ) ); } # to be considered : # { $DummyFile = isXMLfile("$JobName.$JobSuffix") } @@ -1682,26 +1558,7 @@ if ($JobSuffix =~ /\_fo$/i) { } if ($DummyFile) { open( TMP, ">$JobName.run" ); - if ( ( $JobSuffix =~ /(xml|fo|fox)/io ) || $ForceXML ) { - # scan xml preamble - open(XML,"<$JobName.$JobSuffix") ; - while (<XML>) { - if (/\<[a-z]+/io) { - last ; - } elsif (/\<\?context\-directive\s+(.+?)\s+(.+?)\s+(.+?)\s*\?\>/o) { - my ($class, $key, $value) = ($1, $2, $3) ; - if ($class eq 'job') { - if ($key eq 'stylefile') { - print TMP "\\environment $value\n" ; - } elsif ($key eq 'module') { - print TMP "\\usemodule[$value]\n" ; - } elsif ($key eq 'interface') { - $ConTeXtInterface = $value ; - } - } - } - } - close(XML) ; + if ( ( $JobSuffix =~ /xml/io ) || $ForceXML ) { if ( $Filters ne "" ) { print " using xml filters : $Filters\n"; } @@ -1717,8 +1574,9 @@ if ($JobSuffix =~ /\_fo$/i) { $JobSuffix = "run"; } if ( ( -e "$JobName.$JobSuffix" ) || ($GlobalFile) ) { - unless ($DummyFile) { # we don't need this for xml - ScanTeXPreamble("$JobName.$JobSuffix"); + unless ($DummyFile) # we don't need this for xml + { + ScanPreamble("$JobName.$JobSuffix"); if ( $ConTeXtInterface eq "unknown" ) { ScanContent("$JobName.$JobSuffix"); } @@ -1823,11 +1681,6 @@ if ($JobSuffix =~ /\_fo$/i) { CopyFile( "$JobName.top", "$JobName.tmp" ); unlink "$JobName.tup"; # previous tuo file unlink "$JobName.top"; # runtime option file - if ($ProducePdfX) { - system("dvipdfmx -f dvipdfmx.map -d 4 $JobName") ; - } elsif ($ProducePdfM) { - system("dvipdfm $JobName") ; - } PopResult($JobName); } if ($Purge) { PurgeFiles($JobName) } @@ -1867,19 +1720,15 @@ my $CombineFile = "texexec"; sub RunModule { my @FileNames = sort @_; - if ($FileNames[0]) { - unless ( -e $FileNames[0] ) { - my $Name = $FileNames[0]; - @FileNames = ( "$Name.tex", "$Name.mp", "$Name.pl", "$Name.pm" ); - } - foreach my $FileName (@FileNames) { - next unless -e $FileName; - my ( $Name, $Suffix ) = split( /\./, $FileName ); - next unless $Suffix =~ /(tex|mp|pl|pm)/io; - DoRunModule( $Name, $Suffix ); - } - } else { - print " module : no modules found\n\n"; + unless ( -e $FileNames[0] ) { + my $Name = $FileNames[0]; + @FileNames = ( "$Name.tex", "$Name.mp", "$Name.pl", "$Name.pm" ); + } + foreach my $FileName (@FileNames) { + next unless -e $FileName; + my ( $Name, $Suffix ) = split( /\./, $FileName ); + next unless $Suffix =~ /(tex|mp|pl|pm)/io; + DoRunModule( $Name, $Suffix ); } } @@ -1895,17 +1744,14 @@ sub DoRunModule { open( TED, "$FileName.ted" ); my $firstline = <TED>; close(TED); - if ( $firstline =~ /interface=/ ) { - print MOD $firstline ; - } else { - print MOD "% interface=en\n" ; - } + if ( $firstline =~ /interface=en/ ) { print MOD $firstline } + else { print MOD "% interface=nl\n" } # so far print MOD "\\usemodule[abr-01,mod-01]\n"; print MOD "\\def\\ModuleNumber{1}\n"; - print MOD "\\starttext\n"; + print MOD "\\starttekst\n"; print MOD "\\readlocfile{$FileName.ted}{}{}\n"; - print MOD "\\stoptext\n"; + print MOD "\\stoptekst\n"; close(MOD); RunConTeXtFile( $ModuleFile, "tex" ); @@ -2176,7 +2022,6 @@ sub RunCombine { sub LocatedFormatPath { my $FormatPath = shift; - my $EnginePath = shift; if ( ( $FormatPath eq '' ) && ( $kpsewhich ne '' ) ) { $FormatPath = `$kpsewhich --show-path=fmt`; chomp $FormatPath; @@ -2192,14 +2037,6 @@ sub LocatedFormatPath { print " located formatpath : $FormatPath\n"; } } - - if ($UseEnginePath && ($FormatPath ne '' && ($FormatPath !~ /$EnginePath\/$/))) { - $FormatPath .= $EnginePath . '/' ; - unless (-d $FormatPath) { - mkdir $FormatPath ; - } - } - return $FormatPath; } @@ -2208,7 +2045,6 @@ sub RunOneFormat { my @TeXFormatPath; my $TeXPrefix = ""; if ( ( $fmtutil ne "" ) && ( $FormatName !~ /metafun|mptopdf/io ) ) { -# could not happen, not supported any more my $cmd = "$fmtutil --byfmt $FormatName"; if ($Verbose) { print "\n$cmd\n\n" } MakeUserFile; # this works only when the path is kept @@ -2221,15 +2057,15 @@ sub RunOneFormat { } if ($Problems) { $Problems = 0; - if ( $TeXExecutable =~ /etex|eetex|pdfetex|pdfeetex|pdfxtex|xpdfetex|eomega|aleph|xetex/io ) { + if ( $TeXExecutable =~ /etex|eetex|pdfetex|pdfeetex|pdfxtex|xpdfetex|eomega|aleph/io ) { $TeXPrefix = "*"; } my $CurrentPath = cwd(); - my $TheTeXFormatPath = LocatedFormatPath($TeXFormatPath, $TeXExecutable); - if ( $TheTeXFormatPath ne '' ) { chdir $TheTeXFormatPath } + $TeXFormatPath = LocatedFormatPath($TeXFormatPath); + if ( $TeXFormatPath ne '' ) { chdir $TeXFormatPath } MakeUserFile; MakeResponseFile; - $own_quote = ($TeXProgramPath =~ m/^[^\"].* / ? "\"" : "") ; + $own_quote = ($TeXProgramPath =~ m/^[^\"].* / ? "\"" : "") ; my $cmd = "$own_quote$TeXProgramPath$TeXExecutable$own_quote $TeXVirginFlag " . "$TeXPassString $PassOn ${TeXPrefix}$FormatName"; @@ -2238,7 +2074,7 @@ sub RunOneFormat { RemoveResponseFile; RestoreUserFile; - if ( ( $TheTeXFormatPath ne '' ) && ( $CurrentPath ne '' ) ) { + if ( ( $TeXFormatPath ne '' ) && ( $CurrentPath ne '' ) ) { chdir $CurrentPath; } } @@ -2283,15 +2119,15 @@ sub RunMpFormat { my $MpFormat = shift; return if ( $MpFormat eq '' ); my $CurrentPath = cwd(); - my $TheMpFormatPath = LocatedFormatPath($MpFormatPath, $MpExecutable); - if ( $TheMpFormatPath ne '' ) { chdir $TheMpFormatPath } + $MpFormatPath = LocatedFormatPath($MpFormatPath); + if ( $MpFormatPath ne '' ) { chdir "$MpFormatPath" } $own_quote = ($MpExecutable =~ m/^[^\"].* / ? "\"" : "") ; my $cmd = "$own_quote$MpExecutable$own_quote $MpVirginFlag $MpPassString $MpFormat"; if ($Verbose) { print "\n$cmd\n\n" } system($cmd ) ; - if ( ( $TheMpFormatPath ne '' ) && ( $CurrentPath ne '' ) ) { + if ( ( $MpFormatPath ne '' ) && ( $CurrentPath ne '' ) ) { chdir $CurrentPath; } } @@ -2448,40 +2284,17 @@ sub checkMPgraphics { # also see makempy sub checkMPlabels { my $MpName = shift; - return 0 unless ((-f "$MpName.mpt") && ((-s "$MpName.mpt")>10) ); + return 0 unless ( -s "$MpName.mpt" > 10 ); return 0 unless open( MP, "$MpName.mpt" ); my $n = 0; - my $t = "" ; while (<MP>) { - if (/% setup : (.*)/o) { - $t = $1 ; - } else { - $t = "" ; - } - if (/% figure (\d+) : (.*)/o) { - if ($t ne "") { - $mpbetex{$1} .= "$t\n" ; - $t = "" ; - } - $mpbetex{$1} .= "$2\n"; - ++$n ; - } + if (/% figure (\d+) : (.*)/o) { $mpbetex{$1} .= "$2\n"; ++$n } } close(MP); print " second MP run needed : $n tex labels found\n" if $n; return $n; } -sub doMergeMP { - # make sure that the verbatimtex ends up before btex etc - my ($n,$str) = @_ ; - if ($str =~ /(.*?)(verbatimtex.*?etex)\s*\;(.*)/mois) { - return "beginfig($n)\;\n$1$2\;\n$mpbetex{$n}\n$3\;endfig\;\n" ; - } else { - return "beginfig($n)\;\n$mpbetex{$n}\n$str\;endfig\;\n" ; - } -} - sub doRunMP { ########### my ( $MpName, $MergeBE ) = @_; my $TexFound = 0; @@ -2513,21 +2326,17 @@ sub doRunMP { ########### s/(\".*?)\@\@\@(.*?\")/$1\;$2/gmois; # added # merge labels if ($MergeBE) { - # i hate this indirect (sub regexp) mess - s/beginfig\s*\((\d+)\)\s*\;(.*?)endfig\s*\;/doMergeMP($1,$2)/gems ; - } - unless (/beginfig\s*\(\s*0\s*\)/gmois) { - if (defined($mpbetex{0})) { # test added, warning - print MP $mpbetex{0} ; - } + s/beginfig\s*\((\d+)\)\s*\;/beginfig($1)\;\n$mpbetex{$1}\n/goims; } + # flush + unless (/beginfig\s*\(\s*0\s*\)/gmois) { print MP $mpbetex{0} } print MP $_; print MP "\n" . "end" . "\n"; close(MP); } if ($TexFound) { print " metapost to tex : $MpName\n"; - $own_quote = ($MpToTeXExecutable =~ m/^[^\"].* / ? "\"" : "") ; + $own_quote = ($MpToTeXExecutable =~ m/^[^\"].* / ? "\"" : "") ; $Problems = system("$own_quote$MpToTeXExecutable$own_quote $MpFile > $MpTex"); if ( -e $MpTex && !$Problems ) { @@ -2569,7 +2378,6 @@ sub doRunMP { ########### print " error in metapost run : $MpName.mp:$1\n"; } } - close(MPL) ; unlink "mptrace.tmp"; rename( $MpFile, "mptrace.tmp" ); if ( -e $MpKep ) { @@ -2592,7 +2400,7 @@ sub RunMPX { local $/ = "\0777"; $_ = <MP>; close(MP); - if (/(btex|etex|verbatimtex)/mos) { + if (/(btex|etex|verbatimtex)/o) { print " generating mpx file : $MpName\n"; $own_quote = ($MpToTeXExecutable =~ m/^[^\"].* / ? "\"" : "") ; $Problems = @@ -2695,92 +2503,10 @@ if ( $SetFile ne "" ) { load_set_file( $SetFile, $Verbose ) } sub check_texmf_root { } sub check_texmf_tree { } -#~ sub AnalyzeVersion - #~ { my ($texengine,$type); - #~ open (LOG, "<texvers.log") ; - #~ while (<LOG>) - #~ { /^\s*This is (.*pdf(|e)TeX.*?) \(format.*$/o and $texengine = $1 ; - #~ /^\s*ConTeXt (.*int: ([a-z]+).*?)\s*$/o and $type = $1; } - #~ $type =~ s/ int: ([a-z]+)//; - #~ $texengine =~ s/ Version//; - #~ close (LOG); - #~ return ($texengine,$type) } - -#~ sub AnalyzeVersion - #~ { my $str = join("\n", @_) ; - #~ my ($texengine,$type); - #~ if ($str =~ /^\s*This is (.*pdf(|e)TeX.*?) \(format.*$/mos) { - #~ $texengine = $1 ; - #~ } - #~ if ($str =~ /^\s*ConTeXt (.*int: ([a-z]+).*?)\s*$/mos) { - #~ $type = $1 ; - #~ } - #~ $type =~ s/ int: ([a-z]+)//; - #~ $texengine =~ s/ Version//; - #~ return ($texengine,$type) } - - -sub AnalyzeVersion - { my $str = join("\n", @_) ; - my ($texengine,$type) = ('unknown', 'unknown'); - open (LOG, "<texvers.log") ; - while (<LOG>) - { /^\s*This is (.*pdf(|e)TeX.*?)$/o and $texengine = $1 ; - /^\s*ConTeXt (.*int: ([a-z]+).*?)\s*$/o and $type = $1; } - $type =~ s/ int: ([a-z]+)//; - $texengine =~ s/ Version//; - $texengine =~ s/ \(format.*$//; - close (LOG); - return ($texengine,$type) } - -sub show_version_info { - my ($texengine,$type); - open (TEX,">texvers.tex") ; - print TEX "\\bye " ; - close (TEX) ; - my $texutil = `$TeXUtil --help`; - $texutil =~ s/.*(TeXUtil[^\n]+)\n.*?$/$1/s; - print " texexec :$Program\n" ; - print " texutil : $texutil" ; - my $contexttext = `$kpsewhich context.tex`; - my $contextversion = "<not found>"; - if ($contexttext) { - chop $contexttext; - { local $/; - open (IN,"<$contexttext"); - $contextversion = <IN>; - close IN; - } - $contextversion =~ s/.*contextversion\{([0-9.]+)\}.*/$1/s; - } - $EnterBatchMode = 1; - $Format = 'cont-en'; - my $cmd = PrepRunTeX("texvers","tex",'') ; - #~ my $ok = system("$cmd"); - ($texengine,$type) = AnalyzeVersion(`$cmd`) ; - print " tex : $texengine\n" ; - print " context : ver: $contextversion\n" ; - print " cont-en : $type\n" ; - foreach my $a (qw(cz de it nl ro uk)) { - my $test = `$kpsewhich -format='fmt' cont-$a`; - if (defined $test && $test) { - $Format = 'cont-' . $a; - $cmd = PrepRunTeX("texvers","tex",''); - #~ my $ok = system("$cmd"); - ($texengine,$type) = AnalyzeVersion(`$cmd`) ; - print " cont-$a : $type\n" ; - } - } - unlink <texvers.*>; -} - # the main thing -if ($HelpAsked) { - show_help_info -} elsif ($Version) { - show_version_info -} elsif ($TypesetListing) { +if ($HelpAsked) { show_help_info } +elsif ($TypesetListing) { check_texmf_root; check_texmf_tree; RunListing(@ARGV); @@ -2799,12 +2525,8 @@ if ($HelpAsked) { } elsif ($MakeFormats) { check_texmf_root; check_texmf_tree; - if ( $MpDoFormat ne '' ) { - RunMpFormat($MpDoFormat) ; - } - else { - RunFormats ; - } + if ( $MpDoFormat ne '' ) { RunMpFormat($MpDoFormat) } + else { RunFormats } } elsif (@ARGV) { check_texmf_root; check_texmf_tree; @@ -3002,6 +2724,4 @@ alone bypass utilities (e.g. fmtutil for non-standard fmt's) ----------- texutil force TeXUtil run ----------- -version display various version information ------------ -setfile load environment (batch) file +setfile load environment (batch) file
\ No newline at end of file diff --git a/scripts/context/perl/texexec.rme b/scripts/context/perl/texexec.rme index 419d1faec..ff3d3ae26 100644 --- a/scripts/context/perl/texexec.rme +++ b/scripts/context/perl/texexec.rme @@ -51,8 +51,6 @@ set TeXShell to tetex % % Here are some general defaults. They can be overruled later. -set UseEnginePath to false - set UsedInterfaces to en nl metafun mptopdf set UserInterface to en @@ -117,12 +115,12 @@ for fptex set MpPassString to -progname=mpost -translate-file=natural for miktex set TeXHashExecutable to initexmf --update-fndb for miktex set TeXExecutable to pdfetex for miktex set TeXVirginFlag to --initialize -for miktex set TeXPassString to --alias=context --translate-file=natural.tcx +for miktex set TeXPassString to --alias=context --8bit for miktex set TeXBatchFlag to --interaction=batchmode for miktex set TeXNonStopFlag to --interaction=nonstopmode for miktex set MpToTeXExecutable to mptotex for miktex set MpVirginFlag to --initialize -for miktex set MpPassString to --alias=mpost --translate-file=natural.tcx +for miktex set MpPassString to --alias=mpost for miktex set MpBatchFlag to --interaction=batchmode for miktex set MpNonStopFlag to --interaction=nonstopmode diff --git a/scripts/context/perl/texfont.pl b/scripts/context/perl/texfont.pl index bebb636f5..bf93ccaf1 100644 --- a/scripts/context/perl/texfont.pl +++ b/scripts/context/perl/texfont.pl @@ -155,6 +155,9 @@ my $variant = "" ; # atl: encoding variant my $extension = "pfb" ; # atl: default font extension my $lcdf = "" ; # atl: trigger for lcdf otftotfm +my $mappath = 'fonts/map/pdftex/context' ; # will be set later +my $encpath = 'fonts/enc/dvips/context' ; # will be set later + my @cleanup = () ; # atl: build list of generated files to delete # todo: parse name for style, take face from command line @@ -492,7 +495,7 @@ if ($sourcepath eq "auto") # todo uppercase root else { $path = `kpsewhich -expand-path=\\\$$root` } chomp $path ; - $path = $ENV{$root} if (($path eq '') && defined($ENV{$root})) ; + $path = $ENV{$root} if (($path == '') && defined($ENV{$root})) ; report ("checking root : $root") ; if ($preproc) { $sourcepath = "$path/fonts/truetype/$vendor/$collection" } @@ -563,7 +566,7 @@ if ($sourcepath eq "auto") # todo uppercase root error ("unknown subpath ../fonts/afm/$vendor/$collection") unless -d $sourcepath } error ("unknown source path $sourcepath") unless -d $sourcepath ; -error ("unknown option $ARGV[0]") if (($ARGV[0]||'') =~ /\-\-/) ; +error ("unknown option $ARGV[0]") if ($ARGV[0] =~ /\-\-/) ; my $afmpath = "$fontroot/fonts/afm/$vendor/$collection" ; my $tfmpath = "$fontroot/fonts/tfm/$vendor/$collection" ; @@ -691,7 +694,7 @@ sub globafmfiles } return @files } -if ($ARGV[0]) +if ($ARGV[0] ne "") { $pattern = $ARGV[0] ; report ("processing files : all in pattern $ARGV[0]") ; @files = globafmfiles($runpath,$pattern) } @@ -757,7 +760,7 @@ if ($map) print MAP "%\n" ; print MAP "% Alternatively in your TeX source you can say:\n" ; print MAP "%\n" ; - print MAP "% \\pdf \{+$mapfile\}\n" ; + print MAP "% \\pdfmapfile\{+$mapfile\}\n" ; print MAP "%\n" ; print MAP "% In ConTeXt you can best use:\n" ; print MAP "%\n" ; @@ -903,7 +906,7 @@ foreach my $file (@files) if ($afmpl) { report " generating pl : $cleanname$fontsuffix (from $cleanname)" ; $encstr = " -p $encfil" ; - my $command = "afm2pl -f afm2tfm $shape $passon $encstr $file $cleanname$fontsuffix.vpl" ; + my $command = "afm2pl $shape $passon $encstr $file $cleanname$fontsuffix.vpl" ; print "$command\n" if $trace ; my $ok = `$command` ; if (open (TMP,"$cleanname$fontsuffix.map")) diff --git a/scripts/context/perl/texutil.pl b/scripts/context/perl/texutil.pl index e7f13ee3e..0886f0e9c 100644 --- a/scripts/context/perl/texutil.pl +++ b/scripts/context/perl/texutil.pl @@ -40,7 +40,7 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' && eval 'exec perl -S $0 $ #D binary version, like scanning illustrations other than \EPS. #D I would suggest to keep an eye on the version number: -$Program = "TeXUtil 9.0 - ConTeXt / PRAGMA ADE 1992-2004" ; +$Program = "TeXUtil 8.2 - ConTeXt / PRAGMA ADE 1992-2004" ; #D By the way, this is my first \PERL\ script, which means #D that it will be improved as soon as I find new and/or more @@ -2023,7 +2023,7 @@ sub SaveFigurePresets { ++$NOfFigures ; $Figures[$NOfFigures] = "\\presetfigure[$FNam][e=$FTyp" ; if ($FUni) - { $Figures[$NOfFigures] .= (sprintf ",w=%5.3fcm,h=%5.3fcm", $FWid, $FHei) } + { $Figures[$NOfFigures] .= (sprintf ",w=%5.3fcm,h=%5.3fcm\n", $FWid, $FHei) } else { $Figures[$NOfFigures] .= ",w=${FWid}bp,h=${FHei}bp" } if (($FXof!=0)||($FYof!=0)) diff --git a/scripts/context/ruby/texmfstart.rb b/scripts/context/ruby/texmfstart.rb index 8d5175325..c1577679c 100644 --- a/scripts/context/ruby/texmfstart.rb +++ b/scripts/context/ruby/texmfstart.rb @@ -286,7 +286,7 @@ def find(filename,program) if suffix =~ /(#{$scriptlist})/ then begin report("using 'kpsewhich' to locate '#{filename}' in suffix space '#{suffix}' (1)") - fullname = `kpsewhich -progname=#{program} -format=texmfscripts #{filename}.#{suffix}`.chomp + fullname = `kpsewhich -progname=#{program} -format=scripts #{filename}.#{suffix}`.chomp rescue report("kpsewhich cannot locate '#{filename}' in suffix space '#{suffix}' (1)") fullname = nil diff --git a/scripts/context/ruby/texsync.rb b/scripts/context/ruby/texsync.rb deleted file mode 100644 index 457e13c05..000000000 --- a/scripts/context/ruby/texsync.rb +++ /dev/null @@ -1,200 +0,0 @@ -#!/usr/bin/env ruby - -# program : texsync -# copyright : PRAGMA Advanced Document Engineering -# version : 1.1 - 2003/2004 -# author : Hans Hagen - -# For the moment this script only handles the 'minimal' context -# distribution. In due time I will add a few more options, like -# synchronization of the iso image. - -banner = ['TeXSync', 'version 1.1', '2002/2004', 'PRAGMA ADE/POD'] - -unless defined? ownpath - ownpath = $0.sub(/[\\\/]\w*?\.rb/i,'') - $: << ownpath -end - -require 'xmpl/switch' -require 'exa/logger' -require 'rbconfig' - -class Commands - - include CommandBase - - @@formats = ['en','nl','de','cz','it','ro'] - @@always = ['metafun','mptopdf','en','nl'] - @@rsync = 'rsync -r -z -c --progress --stats "--exclude=*.fmt" "--exclude=*.efmt" "--exclude=*.mem"' - - @@kpsewhich = Hash.new - - @@kpsewhich['minimal'] = 'SELFAUTOPARENT' - @@kpsewhich['context'] = 'TEXMFLOCAL' - @@kpsewhich['documentation'] = 'TEXMFLOCAL' - @@kpsewhich['unknown'] = 'SELFAUTOPARENT' - - def update - - report - - return unless destination = getdestination - - texpaths = gettexpaths - address = option('address') - user = option('user') - tree = option('tree') - force = option('force') - - ok = true - begin - report("synchronizing '#{tree}' from '#{address}' to '#{destination}'") - report - if texpaths then - texpaths.each do |path| - report("synchronizing path '#{path}' of '#{tree}' from '#{address}' to '#{destination}'") - command = "#{rsync} #{user}@#{address}::#{tree}/#{path} #{destination}/{path}" - ok = ok && system(command) if force - end - else - command = "#{@@rsync} #{user}@#{address}::#{tree} #{destination}" - ok = system(command) if force - end - rescue - report("error in running rsync") - ok = false - ensure - if force then - if ok then - if option('make') then - report("generating tex and metapost formats") - report - formats.delete_if do |f| - begin - `kpsewhich cont-#{f}`.chomp.empty? - rescue - end - end - str = [@@formats,@@always].flatten.uniq.join(' ') - begin - system("texexec --make --alone #{str}") - rescue - report("unable to generate formats '#{str}'") - else - report - end - else - report("regenerate the formats files if needed") - end - else - report("error in synchronizing '#{tree}'") - end - else - report("provide --force to execute '#{command}'") unless force - end - end - - end - - def list - - report - - address = option('address') - user = option('user') - result = nil - - begin - report("fetching list of trees from '#{address}'") - command = "#{@@rsync} #{user}@#{address}::" - if option('force') then - result = `#{command}`.chomp - else - report("provide --force to execute '#{command}'") - end - rescue - result = nil - else - if result then - report("available trees:") - report - reportlines(result) - end - ensure - report("unable to fetch list") unless result - end - - end - - private - - def gettexpaths - if option('full') then - texpaths = ['texmf','texmf-local','texmf-fonts','texmf-mswin','texmf-linux','texmf-macos'] - elsif option('terse') then - texpaths = ['texmf','texmf-local','texmf-fonts'] - case Config::CONFIG['host_os'] - when /mswin/ then texpaths.push('texmf-mswin') - when /linux/ then texpaths.push('texmf-linux') - when /darwin/ then texpaths.push('texmf-macosx') - end - else - texpaths = nil - end - texpaths - end - - def getdestination - if (destination = option('destination')) && ! destination.empty? then - begin - if @@kpsewhich.key?(destination) then - destination = @@kpsewhich[option('tree')] || @@kpsewhich['unknown'] - destination = `kpsewhich --expand-var=$#{destination}`.chomp - elsif ! FileTest.directory?(destination) then - destination = nil - end - rescue - report("unable to determine destination tex root") - else - if ! destination || destination.empty? then - report("no destination is specified") - elsif not FileTest.directory?(destination) then - report("invalid destination '#{destination}'") - elsif not FileTest.writable?(destination) then - report("destination '#{destination}' is not writable") - else - report("using destination '#{destination}'") - return destination - end - end - else - report("unknown destination") - end - return nil - end - -end - -logger = EXA::ExaLogger.new(banner.shift) -commandline = CommandLine.new - -commandline.registeraction('update', 'update installed tree') -commandline.registeraction('list', 'list available trees') - -commandline.registerflag('terse', 'download as less as possible (esp binaries)') -commandline.registerflag('full', 'download everything (all binaries)') -commandline.registerflag('force', 'confirm action') -commandline.registerflag('make', 'remake formats') - -commandline.registervalue('address', 'www.pragma-ade.com', 'adress of repository (www.pragma-ade)') -commandline.registervalue('user', 'guest', 'user account (guest)') -commandline.registervalue('tree', 'tex', 'tree to synchronize (tex)') -commandline.registervalue('destination', nil, 'destination of tree (kpsewhich)') - -commandline.registeraction('help') -commandline.registeraction('version') - -commandline.expand - -Commands.new(commandline,logger,banner).send(commandline.action || 'help')
\ No newline at end of file diff --git a/scripts/context/ruby/textools.rb b/scripts/context/ruby/textools.rb index 24026d4df..379964dde 100644 --- a/scripts/context/ruby/textools.rb +++ b/scripts/context/ruby/textools.rb @@ -11,7 +11,7 @@ banner = ['TeXTools', 'version 1.2', '2002/2004', 'PRAGMA ADE/POD'] unless defined? ownpath - ownpath = $0.sub(/[\\\/][a-z0-9\-]*?\.rb/i,'') + ownpath = $0.sub(/[\\\/]\w*?\.rb/i,'') $: << ownpath end @@ -109,26 +109,18 @@ class Commands def findfile - report('locating file in texmf tree') - - # ! not in tree - # ? fuzzy - # . in tree - # > in tree and used + report('locating file in texmf tree (> used by kpse)') if filename = @commandline.argument('first') then if filename && ! filename.empty? then report - used = kpsefile(filename) || pathfile(filename) + used = kpsefile(filename) if paths = texmfroots then - found, prefered = false, false paths.each do |p| if files = texmffiles(p,filename) then - found = true files.each do |f| # unreadable: report("#{if f == used then '>' else '.' end} #{f}") if f == used then - prefered = true report("> #{f}") else report(". #{f}") @@ -136,11 +128,6 @@ class Commands end end end - if prefered then - report("! #{used}") unless found - else - report("> #{used}") - end elsif used then report("? #{used}") else @@ -410,29 +397,7 @@ class Commands return nil end - def pathfile(filename) - used = nil - begin - if ! filename || filename.empty? then - return nil - else - ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| - if FileTest.file?(File.join(path,filename)) then - used = File.join(path,filename) - break - end - end - end - rescue - used = nil - else - used = nil if used && used.empty? - end - return used - end - def kpsefile(filename) - used = nil begin if ! filename || filename.empty? then return nil @@ -462,79 +427,8 @@ class Commands return used end - def touchcontextfile - maincontextfile = 'context.tex' - unless FileTest.file?(maincontextfile) then - begin - maincontextfile = `kpsewhich -progname=context #{maincontextfile}`.chomp - rescue - maincontextfile = '' - end - end - touchfile(maincontextfile) unless maincontextfile.empty? - end - - def downcasefilenames - if @commandline.option('recurse') then - files = Dir.glob('**/*') - else - files = Dir.glob('*') - end - if files && files.length>0 then - files.each do |oldname| - if FileTest.file?(oldname) then - newname = oldname.downcase - if oldname != newname then - begin - File.rename(oldname,newname) - rescue - report("#{oldname} == #{oldname}\n") - else - report("#{oldname} => #{newname}\n") - end - end - end - end - end - end - private # specific - def touchfile(filename) - - if FileTest.file?(filename) then - if data = IO.read(filename) then - timestamp = Time.now.strftime('%Y.%d.%m') - begin - data.gsub!(/\\contextversion\{(\d+)\.(\d+)\.(\d+)\}/) do - "\\contextversion{#{timestamp}}" - end - rescue - else - begin - File.delete(filename+'.old') - rescue - end - begin - File.copy(filename,filename+'.old') - rescue - end - begin - if f = File.open(filename,'w') then - f.puts(data) - f.close - end - rescue - end - end - report("#{filename} is touched as #{timestamp}") - end - else - report("#{filename} is not found") - end - - end - def movefiles(from_path,to_path,suffix,&block) obsolete = 'obsolete' force = @commandline.option('force') @@ -642,19 +536,16 @@ end logger = EXA::ExaLogger.new(banner.shift) commandline = CommandLine.new -commandline.registeraction('touchcontextfile', '') # private -commandline.registeraction('downcasefilenames', '') # private - -commandline.registeraction('removemapnames' , '[pattern] [--recurse]') -commandline.registeraction('restoremapnames' , '[pattern] [--recurse]') -commandline.registeraction('hidemapnames' , '[pattern] [--recurse]') -commandline.registeraction('videmapnames' , '[pattern] [--recurse]') -commandline.registeraction('findfile' , 'filename [--recurse]') -commandline.registeraction('unzipfiles' , '[pattern] [--recurse]') -commandline.registeraction('fixafmfiles' , '[pattern] [--recurse]') -commandline.registeraction('mactodos' , '[pattern] [--recurse]') -commandline.registeraction('fixtexmftrees' , '[texmfroot] [--force]') -commandline.registeraction('replace' , 'filename [--force]') +commandline.registeraction('removemapnames' , '[pattern] [--recurse]') +commandline.registeraction('restoremapnames', '[pattern] [--recurse]') +commandline.registeraction('hidemapnames' , '[pattern] [--recurse]') +commandline.registeraction('videmapnames' , '[pattern] [--recurse]') +commandline.registeraction('findfile' , 'filename [--recurse]') +commandline.registeraction('unzipfiles' , '[pattern] [--recurse]') +commandline.registeraction('fixafmfiles' , '[pattern] [--recurse]') +commandline.registeraction('mactodos' , '[pattern] [--recurse]') +commandline.registeraction('fixtexmftrees' , '[texmfroot] [--force]') +commandline.registeraction('replace' , 'filename [--force]') commandline.registeraction('help') commandline.registeraction('version') @@ -663,4 +554,4 @@ commandline.registerflag('force') commandline.expand -Commands.new(commandline,logger,banner).send(commandline.action || 'help') +Commands.new(commandline,logger,banner).send(commandline.action || 'help')
\ No newline at end of file diff --git a/scripts/context/ruby/xmltools.rb b/scripts/context/ruby/xmltools.rb index b92f159e3..e1803daf6 100644 --- a/scripts/context/ruby/xmltools.rb +++ b/scripts/context/ruby/xmltools.rb @@ -8,73 +8,46 @@ # This script will harbor some handy manipulations on tex # related files. -banner = ['XMLTools', 'version 1.1', '2002/2004', 'PRAGMA ADE/POD'] +banner = ['XMLTools', 'version 1.0', '2002/2004', 'PRAGMA ADE/POD'] unless defined? ownpath - ownpath = $0.sub(/[\\\/][a-z0-9\-]*?\.rb/i,'') + ownpath = $0.sub(/[\\\/]\w*?\.rb/i,'') $: << ownpath end require 'xmpl/switch' require 'exa/logger' -class String - - def astring(n=10) - gsub(/(\d+)/o) do $1.to_s.rjust(n) end.gsub(/ /o, '0') - end - - def xstring - if self =~ /\'/o then - "\"#{self.gsub(/\"/, '"')}\"" - else - "\'#{self}\'" - end - end - -end - -class Array - - def asort(n=10) - sort {|x,y| x.astring(n) <=> y.astring(n)} - end - -end - class Commands include CommandBase def dir - @xmlns = "xmlns='http://www.pragma-ade.com/rlg/xmldir.rng'" - pattern = @commandline.option('pattern') recurse = @commandline.option('recurse') stripname = @commandline.option('stripname') - longname = @commandline.option('longname') url = @commandline.option('url') outputfile = @commandline.option('output') root = @commandline.option('root') - def generate(output,files,url,root,longname) + def generate(output,files,url,root) class << output def xputs(str,n=0) - puts("#{' '*n}#{str}") + puts("#{' '*n} #{str}") end end dirname = '' - output.xputs("<?xml version='1.0'?>\n\n") + output.xputs("<?xml xmlns='http://www.pragma-ade.com/rlg/xmldir.rng'?>\n\n") if ! root || root.empty? then - rootatt = @xmlns + rootatt = '' else - rootatt = " #{@xmlns} root='#{root}'" + rootatt = " root='#{root}'" end if url.empty? then - output.xputs("<files #{rootatt}>\n") + output.xputs("<files#{rootatt}>\n") else output.xputs("<files url='#{url}'#{rootatt}>\n") end @@ -85,19 +58,10 @@ class Commands output.xputs("<directory name='#{dn}'>\n", 2) dirname = dn end - if longname && dn != '.' then - output.xputs("<file name='#{dn}/#{bn}'>\n", 4) - else - output.xputs("<file name='#{bn}'>\n", 4) - end + output.xputs("<file name='#{bn}'>\n", 4) output.xputs("<base>#{bn.sub(/\..*$/,'')}</base>\n", 6) - if File.stat(f).file? then - bt = bn.sub(/^.*\./,'') - if bt != bn then - output.xputs("<type>#{bt}</type>\n", 6) - end - output.xputs("<size>#{File.stat(f).size}</size>\n", 6) - end + output.xputs("<type>#{bn.sub(/^.*\./,'')}</type>\n", 6) + output.xputs("<size>#{File.stat(f).size}</size>\n", 6) output.xputs("<date>#{File.stat(f).mtime.strftime("%Y-%m-%d %H:%M")}</date>\n", 6) output.xputs("</file>\n", 4) end @@ -142,7 +106,7 @@ class Commands end end - generate(output, globbed(pattern, recurse), url, root, longname) + generate(output, globbed(pattern, recurse), url, root) output.close if output @@ -150,184 +114,18 @@ class Commands alias ls :dir - def mmlpages - - file = @commandline.argument('first') - eps = @commandline.option('eps') - jpg = @commandline.option('jpg') - png = @commandline.option('png') - style = @commandline.option('style') - modes = @commandline.option('modes') - - file = file.sub(/\.xml/io, '') - long = "#{file}-mmlpages" - if FileTest.file?(file+'.xml') then - style = "--arg=\"style=#{style}\"" unless style.empty? - modes = "--mode=#{modes}" unless modes.empty? - if system("texmfstart texexec.pl --batch --pdf --once --result=#{long} --use=mmlpag #{style} #{modes} #{file}.xml") then - if eps then - if f = open("#{file}-mmlpages.txt") then - while line = f.gets do - data = Hash.new - if fields = line.split then - fields.each do |fld| - key, value = fld.split('=') - data[key] = value if key && value - end - if data.key?('p') then - page = data['p'] - name = "#{long}-#{page.to_i-1}" - if eps then - report("generating eps file #{name}") - if system("pdftops -eps -f #{page} -l #{page} #{long}.pdf #{name}.eps") then - if data.key?('d') then - if epsfile = IO.read("#{name}.eps") then - epsfile.sub!(/^(\%\%BoundingBox:.*?$)/i) do - newline = $1 + "\n%%Baseline: #{data['d']}\n" - if data.key?('w') && data.key?('h') then - newline += "%%PositionWidth: #{data['w']}\n" - newline += "%%PositionHeight: #{data['h']}\n" - newline += "%%PositionDepth: #{data['d']}" - end - newline - end - if g = File.open("#{name}.eps",'wb') then - g.write(epsfile) - g.close - end - end - end - else - report("error in generating eps from #{name}") - end - end - end - end - end - f.close - else - report("missing data log file #{file}") - end - end - if png then - report("generating png file for #{long}") - system("imagemagick #{long}.pdf #{long}-%d.png") - end - if jpg then - report("generating jpg files for #{long}") - system("imagemagick #{long}.pdf #{long}-%d.jpg") - end - else - report("error in processing file #{file}") - end - system("texmfstart texutil --purge") - else - report("error in processing file #{file}") - end - - end - - def analyze - - file = @commandline.argument('first') - result = @commandline.option('output') - - if FileTest.file?(file) then - if data = IO.read(file) then - report("xml file #{file} loaded") - elements = Hash.new - attributes = Hash.new - entities = Hash.new - data.scan(/<([^>\s\/\!\?]+)([^>]*?)>/o) do - element, attributelist = $1, $2 - if elements.key?(element) then - elements[element] += 1 - else - elements[element] = 1 - end - attributelist.scan(/\s*([^\=]+)\=([\"\'])(.*?)(\2)/) do - key, value = $1, $3 - attributes[element] = Hash.new unless attributes.key?(element) - attributes[element][key] = Hash.new unless attributes[element].key?(key) - if attributes[element][key].key?(value) then - attributes[element][key][value] += 1 - else - attributes[element][key][value] = 1 - end - end - end - data.scan(/\&([^\;]+)\;/o) do - entity = $1 - if entities.key?(entity) then - entities[entity] += 1 - else - entities[entity] = 1 - end - end - result = file.gsub(/\..*?$/, '') + '.xlg' if result.empty? - if f = File.open(result,'w') then - report("saving report in #{result}") - f.puts "<?xml version='1.0'?>\n" - f.puts "<document>\n" - if entities.length>0 then - f.puts " <entities>\n" - entities.keys.asort.each do |entity| - f.puts " <entity name=#{entity.xstring} n=#{entities[entity].to_s.xstring}/>\n" - end - f.puts " </entities>\n" - end - if elements.length>0 then - f.puts " <elements>\n" - elements.keys.sort.each do |element| - if attributes.key?(element) then - f.puts " <element name=#{element.xstring} n=#{elements[element].to_s.xstring}>\n" - if attributes.key?(element) then - attributes[element].keys.asort.each do |attribute| - f.puts " <attribute name=#{attribute.xstring}>\n" - attributes[element][attribute].keys.asort.each do |value| - f.puts " <instance value=#{value.xstring} n=#{attributes[element][attribute][value].to_s.xstring}/>\n" - end - f.puts " </attribute>\n" - end - end - f.puts " </element>\n" - else - f.puts " <element name=#{element.xstring} n=#{elements[element].to_s.xstring}/>\n" - end - end - f.puts " </elements>\n" - end - f.puts "</document>\n" - else - report("unable to open file '#{result}'") - end - else - report("unable to load file '#{file}'") - end - else - report("unknown file '#{file}'") - end - end - end logger = EXA::ExaLogger.new(banner.shift) commandline = CommandLine.new -commandline.registeraction('dir', 'generate directory listing') -commandline.registeraction('mmlpages','generate graphic from mathml') -commandline.registeraction('analyze', 'report entities and elements') - -# commandline.registeraction('dir', 'filename --pattern= --output= [--recurse --stripname --longname --url --root]') -# commandline.registeraction('mmlpages','filename [--eps --jpg --png --style= --mode=]') - +commandline.registeraction('dir','generate directory listing') commandline.registeraction('ls') commandline.registeraction('help') commandline.registeraction('version') commandline.registerflag('stripname') -commandline.registerflag('longname') commandline.registerflag('recurse') commandline.registervalue('pattern') @@ -335,12 +133,6 @@ commandline.registervalue('url') commandline.registervalue('output') commandline.registervalue('root') -commandline.registerflag('eps') -commandline.registerflag('png') -commandline.registerflag('jpg') -commandline.registervalue('style') -commandline.registervalue('modes') - commandline.expand -Commands.new(commandline,logger,banner).send(commandline.action || 'help') +Commands.new(commandline,logger,banner).send(commandline.action || 'help')
\ No newline at end of file diff --git a/scripts/context/ruby/xmpl/switch.rb b/scripts/context/ruby/xmpl/switch.rb index c0fd1d624..69d2a8644 100644 --- a/scripts/context/ruby/xmpl/switch.rb +++ b/scripts/context/ruby/xmpl/switch.rb @@ -32,46 +32,27 @@ module CommandBase def initialize(commandline,logger,banner) @commandline, @logger, @banner = commandline, logger, banner - @forcenewline, @versiondone = false, false version if @commandline.option('version') end + def report(*str) + @logger.report(str) + end + def reportlines(*str) @logger.reportlines(str) end - # only works in 1.8 - # - # def report(*str) - # @logger.report(str) - # end - # - # def version # just a bit of playing with defs - # report(@banner.join(' - ')) - # def report(*str) - # @logger.report - # @logger.report(str) - # def report(*str) - # @logger.report(str) - # end - # end - # def version - # end - # end - - def report(*str) - if @forcenewline then + def version # just a bit of playing with defs + report(@banner.join(' - ')) + def report(*str) @logger.report - @forcenewline = false + @logger.report(str) + def report(*str) + @logger.report(str) + end end - @logger.report(str) - end - - def version # just a bit of playing with defs - unless @versiondone then - report(@banner.join(' - ')) - @forcenewline = true - @versiondone = true + def version end end @@ -115,14 +96,7 @@ module CommandBase files = Array.new pattern.split(' ').each do |p| - if recurse then - if p =~ /^(.*)(\/.*?)$/i then - p = $1 + '/**' + $2 - else - p = '**/' + p - end - p.gsub!(/[\\\/]+/, '/') - end + p = '**/' + p if recurse files.push(Dir.glob(p)) end files.flatten.sort do |a,b| @@ -470,4 +444,4 @@ end # end # # c.showhelp("you can provide:\n\n") -# c.showmandate("you also need to provide:\n\n") +# c.showmandate("you also need to provide:\n\n")
\ No newline at end of file |