summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2004-08-30 00:00:00 +0200
committerHans Hagen <pragma@wxs.nl>2004-08-30 00:00:00 +0200
commit334f3edd2304915fc8b50a722a56765f41b1a7d5 (patch)
tree0d62c2871118f4971fa7b0b6bb1e87b12f647bff /scripts
parent08a4bcc9bff26007ca9b5d14d6beaacab74c9ce4 (diff)
downloadcontext-334f3edd2304915fc8b50a722a56765f41b1a7d5.tar.gz
stable 2004.08.30
Diffstat (limited to 'scripts')
-rw-r--r--scripts/context/perl/cont_set.pm498
-rw-r--r--scripts/context/perl/texexec.pl264
-rw-r--r--scripts/context/perl/texutil.pl2
-rw-r--r--scripts/context/ruby/textools.rb36
4 files changed, 498 insertions, 302 deletions
diff --git a/scripts/context/perl/cont_set.pm b/scripts/context/perl/cont_set.pm
index 9c6d2cbcd..c14cc679c 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 ;
-#D The main window is not resizable, but the text area and
-#D command list will have scrollbars.
+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.
-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 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 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/texexec.pl b/scripts/context/perl/texexec.pl
index 00e336ea5..01355b6a6 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=2003.09.16,
+#D version=2004.08.29,
#D title=running \ConTeXt,
#D subtitle=\TEXEXEC,
#D author=Hans Hagen,
@@ -33,6 +33,7 @@ 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 ;
# todo: second run of checksum of mp file with --nomprun changes
# todo: warning if no args
@@ -117,6 +118,7 @@ my $FinalMode = 0;
my $Format = '';
my $MpDoFormat = '';
my $HelpAsked = 0;
+my $Version = 0;
my $MainBodyFont = 'standard';
my $MainLanguage = 'standard';
my $MainResponse = 'standard';
@@ -184,7 +186,7 @@ my $Random = 0;
my $Filters = '';
my $NoMapFiles = 0 ;
my $Foxet = 0 ;
-my $UseEnginePath = 0 ;
+my $TheEnginePath = 0 ;
my $StartLine = 0 ;
my $StartColumn = 0 ;
@@ -211,6 +213,7 @@ my $MakeMpy = '';
"format=s" => \$Format,
"mpformat=s" => \$MpDoFormat,
"help" => \$HelpAsked,
+ "version" => \$Version,
"interface=s" => \$ConTeXtInterface,
"language=s" => \$MainLanguage,
"bodyfont=s" => \$MainBodyFont,
@@ -286,7 +289,7 @@ my $MakeMpy = '';
"globalfile" => \$GlobalFile,
"nomapfiles" => \$NoMapFiles,
"foxet" => \$Foxet,
- "engine" => \$UseEnginePath,
+ "engine" => \$TheEnginePath,
#### exxperiment
"startline=s" => \$StartLine,
"startcolumn=s" => \$StartColumn,
@@ -349,7 +352,7 @@ if ( ( $LogFile ne '' ) && ( $LogFile =~ /\w+\.log$/io ) ) {
*STDERR = *LOGFILE;
}
-my $Program = " TeXExec 4.4 - ConTeXt / PRAGMA ADE 1997-2004";
+my $Program = " TeXExec 5.0 - ConTeXt / PRAGMA ADE 1997-2004";
print "\n$Program\n\n";
@@ -671,10 +674,10 @@ my $TeXScriptsPath = IniValue( 'TeXScriptsPath', '' );
my $TeXHashExecutable = IniValue( 'TeXHashExecutable', '' );
my $TeXExecutable = IniValue( 'TeXExecutable', 'tex' );
my $TeXVirginFlag = IniValue( 'TeXVirginFlag', '-ini' );
-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 $TeXBatchFlag = IniValue( 'TeXBatchFlag', '-interaction=batchmode' );
+my $TeXNonStopFlag = IniValue( 'TeXNonStopFlag', '-interaction=nonstopmode' );
+my $MpBatchFlag = IniValue( 'MpBatchFlag', '-interaction=batchmode' );
+my $MpNonStopFlag = IniValue( 'MpNonStopFlag', '-interaction=nonstopmode' );
my $TeXPassString = IniValue( 'TeXPassString', '' );
my $TeXFormatFlag = IniValue( 'TeXFormatFlag', '' );
my $MpFormatFlag = IniValue( 'MpFormatFlag', '' );
@@ -682,8 +685,7 @@ my $MpVirginFlag = IniValue( 'MpVirginFlag', '-ini' );
my $MpPassString = IniValue( 'MpPassString', '' );
my $MpFormat = IniValue( 'MpFormat', $MetaFun );
my $MpFormatPath = IniValue( 'MpFormatPath', $TeXFormatPath );
-
-my $UseEnginePath = IniValue( 'UseEnginePath', $UseEnginePath);
+my $UseEnginePath = IniValue( 'UseEnginePath', $TheEnginePath);
my $FmtLanguage = IniValue( 'FmtLanguage', '' );
my $FmtBodyFont = IniValue( 'FmtBodyFont', '' );
@@ -1042,7 +1044,7 @@ sub CheckOutputFormat {
if ( !$Ok ) {
print $Help{'output'};
} elsif ($FullFormat) {
- print OPT "\\setupoutput[$FullFormat]\n";
+ # print OPT "\\setupoutput[$FullFormat]\n";
}
}
unless ($FullFormat) { $FullFormat = $OutputFormat }
@@ -1077,16 +1079,16 @@ sub MakeOptionFile {
}
if ($EnterBatchMode) { print OPT "\\batchmode\n" }
if ($EnterNonStopMode) { print OPT "\\nonstopmode\n" }
- if ($UseColor) { print OPT "\\setupcolors[\\c!status=\\v!start]\n" }
+ if ($UseColor) { print OPT "\\setupcolors[\\c!state=\\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!splitsen=$Separation]\n";
+ print OPT "\\setupcolors[\\c!split=$Separation]\n";
}
- if ($SetupPath) { print OPT "\\setupsystem[\\c!gebied=\{$SetupPath\}]\n" }
+ if ($SetupPath) { print OPT "\\setupsystem[\\c!directory=\{$SetupPath\}]\n" }
print OPT "\\setupsystem[\\c!n=$KindOfRun]\n";
$_ = $PaperFormat;
#unless (($PdfArrange)||($PdfSelect)||($PdfCombine)||($PdfCopy))
@@ -1106,41 +1108,41 @@ sub MakeOptionFile {
{
print " background graphic : $Background\n";
print OPT "\\defineoverlay[whatever][{\\externalfigure[$Background][\\c!factor=\\v!max]}]\n";
- print OPT "\\setupbackgrounds[\\v!pagina][\\c!achtergrond=whatever]\n";
+ print OPT "\\setupbackgrounds[\\v!page][\\c!background=whatever]\n";
}
if ($CenterPage) {
print OPT
- "\\setuplayout[\\c!plaats=\\v!midden,\\c!markering=\\v!aan]\n";
+ "\\setuplayout[\\c!location=\\v!middle,\\c!marking=\\v!on]\n";
}
if ($NoMapFiles) {
print OPT "\\disablemapfiles\n";
}
- if ($NoArrange) { print OPT "\\setuparranging[\\v!blokkeer]\n" }
+ if ($NoArrange) { print OPT "\\setuparranging[\\v!disable]\n" }
elsif ( $Arrange || $PdfArrange ) {
$FinalRunNeeded = 1;
if ($FinalRun) {
my $DupStr;
if ($NoDuplex) { $DupStr = "" }
- else { $DupStr = ",\\v!dubbelzijdig" }
+ else { $DupStr = ",\\v!doublesided" }
if ( $PrintFormat eq '' ) {
- print OPT "\\setuparranging[\\v!normaal]\n";
+ print OPT "\\setuparranging[\\v!normal]\n";
} elsif ( $PrintFormat =~ /.*up/goi ) {
- print OPT "\\setuparranging[2UP,\\v!geroteerd$DupStr]\n";
+ print OPT "\\setuparranging[2UP,\\v!rotated$DupStr]\n";
} elsif ( $PrintFormat =~ /.*down/goi ) {
- print OPT "\\setuparranging[2DOWN,\\v!geroteerd$DupStr]\n";
+ print OPT "\\setuparranging[2DOWN,\\v!rotated$DupStr]\n";
} elsif ( $PrintFormat =~ /.*side/goi ) {
- print OPT "\\setuparranging[2SIDE,\\v!geroteerd$DupStr]\n";
+ print OPT "\\setuparranging[2SIDE,\\v!rotated$DupStr]\n";
} else {
print OPT "\\setuparranging[$PrintFormat]\n";
}
} else {
- print OPT "\\setuparranging[\\v!blokkeer]\n";
+ print OPT "\\setuparranging[\\v!disable]\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!willekeur=$RandomSeed]\n" }
+ if ($Random) { print OPT "\\setupsystem[\\c!random=$RandomSeed]\n" }
if ($Mode) { print OPT "\\enablemode[$Mode]\n" }
if ($Pages) {
if ( lc $Pages eq "odd" ) {
@@ -1203,7 +1205,7 @@ sub MakeUserFile {
if ( $MainLanguage ne 'standard' ) {
@MainLanguages = split( /\,/, $MainLanguage );
foreach (@MainLanguages) {
- print USR "\\installlanguage[\\s!$_][\\c!status=\\v!start]\n";
+ print USR "\\installlanguage[\\s!$_][\\c!state=\\v!start]\n";
}
$MainLanguage = $MainLanguages[0];
print USR "\\setupcurrentlanguage[\\s!$MainLanguage]\n";
@@ -1342,9 +1344,65 @@ if ( $ConTeXtInterfaces{$ConTeXtInterface} ) {
my $Problems = my $Ok = 0;
-sub RunTeX {
- my ( $JobName, $JobSuffix ) = @_;
- my $StartTime = time;
+#~ 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 ) = @_;
my $cmd;
my $TeXProgNameFlag = '';
if ( !$dosish ) # we assume tetex on linux
@@ -1365,8 +1423,15 @@ sub RunTeX {
if ($EnterBatchMode) { $cmd .= "$TeXBatchFlag " }
if ($EnterNonStopMode) { $cmd .= "$TeXNonStopFlag " }
if ( $TeXTranslation ne '' ) { $cmd .= "-translate-file=$TeXTranslation " }
- $cmd .= "$TeXFormatFlag$TeXFormatPath$Format $JobName.$JobSuffix";
+ $cmd .= "$TeXFormatFlag$TeXFormatPath$Format $JobName.$JobSuffix $PipeString";
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 {
@@ -1393,6 +1458,7 @@ sub RunTeX {
# }
# }
# }
+
my $StopTime = time - $StartTime;
print "\n return code : $Problems";
print "\n run time : $StopTime seconds\n";
@@ -1780,15 +1846,19 @@ my $CombineFile = "texexec";
sub RunModule {
my @FileNames = sort @_;
- 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 );
+ 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";
}
}
@@ -1804,14 +1874,17 @@ sub DoRunModule {
open( TED, "$FileName.ted" );
my $firstline = <TED>;
close(TED);
- if ( $firstline =~ /interface=en/ ) { print MOD $firstline }
- else { print MOD "% interface=nl\n" }
+ if ( $firstline =~ /interface=/ ) {
+ print MOD $firstline ;
+ } else {
+ print MOD "% interface=en\n" ;
+ }
# so far
print MOD "\\usemodule[abr-01,mod-01]\n";
print MOD "\\def\\ModuleNumber{1}\n";
- print MOD "\\starttekst\n";
+ print MOD "\\starttext\n";
print MOD "\\readlocfile{$FileName.ted}{}{}\n";
- print MOD "\\stoptekst\n";
+ print MOD "\\stoptext\n";
close(MOD);
RunConTeXtFile( $ModuleFile, "tex" );
@@ -2354,7 +2427,7 @@ sub checkMPgraphics { # also see makempy
sub checkMPlabels {
my $MpName = shift;
- return 0 unless ( -s "$MpName.mpt" > 10 );
+ return 0 unless ((-f "$MpName.mpt") && ((-s "$MpName.mpt")>10) );
return 0 unless open( MP, "$MpName.mpt" );
my $n = 0;
my $t = "" ;
@@ -2422,7 +2495,11 @@ sub doRunMP { ###########
# 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) { print MP $mpbetex{0} }
+ unless (/beginfig\s*\(\s*0\s*\)/gmois) {
+ if (defined($mpbetex{0})) { # test added, warning
+ print MP $mpbetex{0} ;
+ }
+ }
print MP $_;
print MP "\n" . "end" . "\n";
close(MP);
@@ -2471,6 +2548,7 @@ sub doRunMP { ###########
print " error in metapost run : $MpName.mp:$1\n";
}
}
+ close(MPL) ;
unlink "mptrace.tmp";
rename( $MpFile, "mptrace.tmp" );
if ( -e $MpKep ) {
@@ -2596,10 +2674,92 @@ 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 ($TypesetListing) {
+if ($HelpAsked) {
+ show_help_info
+} elsif ($Version) {
+ show_version_info
+} elsif ($TypesetListing) {
check_texmf_root;
check_texmf_tree;
RunListing(@ARGV);
@@ -2618,8 +2778,12 @@ elsif ($TypesetListing) {
} 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;
@@ -2817,4 +2981,6 @@ alone bypass utilities (e.g. fmtutil for non-standard fmt's)
-----------
texutil force TeXUtil run
-----------
-setfile load environment (batch) file \ No newline at end of file
+version display various version information
+-----------
+setfile load environment (batch) file
diff --git a/scripts/context/perl/texutil.pl b/scripts/context/perl/texutil.pl
index 06bccb82f..e7f13ee3e 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 8.2 - ConTeXt / PRAGMA ADE 1992-2004" ;
+$Program = "TeXUtil 9.0 - 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
diff --git a/scripts/context/ruby/textools.rb b/scripts/context/ruby/textools.rb
index fec093cf3..1c7e4c926 100644
--- a/scripts/context/ruby/textools.rb
+++ b/scripts/context/ruby/textools.rb
@@ -109,15 +109,22 @@ class Commands
def findfile
- report('locating file in texmf tree (> used by kpse)')
+ report('locating file in texmf tree')
+
+ # ! not in tree
+ # ? fuzzy
+ # . in tree
+ # > in tree and used
if filename = @commandline.argument('first') then
if filename && ! filename.empty? then
report
- used = kpsefile(filename)
+ used = kpsefile(filename) || pathfile(filename)
if paths = texmfroots then
+ found = 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
@@ -128,6 +135,7 @@ class Commands
end
end
end
+ report("! #{used}") unless found
elsif used then
report("? #{used}")
else
@@ -397,7 +405,29 @@ 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
@@ -554,4 +584,4 @@ commandline.registerflag('force')
commandline.expand
-Commands.new(commandline,logger,banner).send(commandline.action || 'help') \ No newline at end of file
+Commands.new(commandline,logger,banner).send(commandline.action || 'help')