From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/8479 Path: main.gmane.org!not-for-mail From: Henning Hraban Ramm Newsgroups: gmane.comp.tex.context Subject: Re: texedit (was: something else) Date: Fri, 28 Jun 2002 23:48:41 +0200 Sender: owner-ntg-context@let.uu.nl Message-ID: <200206282348.41623.angerweit@gmx.net> References: <5.1.0.14.1.20020625174433.02cc6448@remote-1> <5.1.0.14.1.20020627185315.04531a50@remote-1> NNTP-Posting-Host: coloc-standby.netfonds.no Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="------------Boundary-00=_59RF6MI3JPTKIEMUTZNW" X-Trace: main.gmane.org 1035398876 27846 80.91.224.250 (23 Oct 2002 18:47:56 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 23 Oct 2002 18:47:56 +0000 (UTC) Cc: ntg-context@ntg.nl Original-To: Hans Hagen In-Reply-To: <5.1.0.14.1.20020627185315.04531a50@remote-1> Xref: main.gmane.org gmane.comp.tex.context:8479 X-Report-Spam: http://spam.gmane.org/gmane.comp.tex.context:8479 --------------Boundary-00=_59RF6MI3JPTKIEMUTZNW Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Am Donnerstag, 27. Juni 2002 18:54 schrieb Hans Hagen: > >Do you have a own "project tool"? (Part of the IDE?) > >I love my simple "makeproject.pl" for preparing new > >components/products/projects/environments, but I guess a tool of yours > > would be much more sophisticated... > > hm, sounds like a nice option; > but, as with our current editor, texwork *is* aware of the structure an= d > permits you to traverse subfiles. Sounds good. I guess, your editor can create "every" ConTeXt structure from the menu o= r=20 shortcut? That would replace the attached script... (Hey, I never claimed= to=20 be a Perl hacker, just a bloody beginner!) Gr=FC=DFlis vom Hraban! --=20 http://www.fiee.net/texnique/ --- --------------Boundary-00=_59RF6MI3JPTKIEMUTZNW Content-Type: text/x-perl; charset="iso-8859-1"; name="makeproject.pl" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="makeproject.pl" #!/usr/bin/perl -w=0D use warnings;=0D print "Make ConTeXt project -- 2002-05-17\n";=0D print "copyleft 2002 Henning Hraban Ramm\n\n";=0D =0D @Level =3D ("environment","project", "product","component");=0D @Prefix =3D ("env_", "project_","prd_", "c_");=09# file pref= ixes=0D $Suffix =3D ".tex";=09=09=09=09# ending=0D $IniSuffix =3D ".ini";=09=09=09=09# ending for defaults files=0D =0D $Command =3D $ARGV[0];=0D if (!$Command) {$Command=3D".";}=0D $validCommand =3D 0;=0D $ProjectPath =3D ".";=09# default path =3D actual path=0D =0D =0D if ($Command =3D~ m/^--/) { =09=09# if first parameter starts with --=0D =09$Command =3D~ s/^--//; =09=09# delete --=0D =09($Command eq "help") && help();=09# show help, if wanted=0D =09if ($Command =3D~ m/[0-3]/) { $Command =3D $Level[$Command]; } # if --= 0 etc.=0D =09for ($count=3D@Level-1; $count>0; $count--) { # iterate all levels=0D =09=09if ($Command eq $Level[$count]) { # if command matches level=0D =09=09=09unless ($ARGV[1]) { # if no second command line parameter=0D =09=09=09=09my $missname =3D $Level[$count-1];=0D =09=09=09=09if ($missname eq $Level[0]) { $missname =3D $Level[1]; }=0D =09=09=09=09help("$missname name is missing!");=0D =09=09=09} # if no second parameter=0D =09=09=09if (($count>1) and (!$ARGV[2])) { # with level 2 we need 2 param= eters=0D =09=09=09=09help($Level[$count]." name is missing!");=0D =09=09=09} # if no third parameter=0D =09=09=09$validCommand=3D1;=09# ok, print no help=0D =09=09=09print "making ".$Level[$count]."...\n";=0D =09=09=09MakeFile($count, $ARGV[1], $ARGV[2]);=0D =09=09} # if=0D =09} # for=0D =09($Command eq "all") && help("option --all is not yet implemented.\n");= =0D =09($validCommand) && exit(0); # exit without error=0D } # if --parameter=0D =0D help("Don't know what to do!");=09# help function ends with exit=0D =0D ### END=0D =0D ###=0D sub MakeFile { # gets level number and two other args (project/product or= product/component)=0D ###=0D =09my $ActLev =3D $_[0];=0D =09my $ProjectName=3D$_[1];=0D =09my $ProductName=3D$_[2];=0D =09my $InKey=3D"";=0D =09my $ProjectLine=3D"";=0D =09if ($ProjectName =3D~ m/^.*[\/\\:]/) { # look for folder delimiters=0D =09=09$ProjectName =3D $';=09# '=0D =09=09chop($ProjectPath =3D $&);=0D =09=09$ProjectPath =3D~ tr=A7\:\/\\=A7/=A7;=09# change all delimiters to = UNIX slashes=0D =09} # if=0D =09if (ProductName =3D~ m/^.*[\/\\:]/) { # delete other path=0D =09=09$ProductName =3D $';=09# '=0D =09}=0D =09if (!$ProductName) { $ProductName=3D$ProjectName; }=0D =09unless (-d $ProjectPath) { # test path=0D =09=09(-f $ProjectPath) && die "$ProjectPath is a file!\n";=0D =09=09print("making $ProjectPath...");=0D =09=09mkdir($ProjectPath) or die "Cannot make dir $ProjectPath: $!";=0D =09} # if no path=0D =09$FileName =3D $ProjectPath."/".$Prefix[$ActLev].$ProductName.$Suffix;=0D =09(-d $FileName) && die "$FileName is a directory!\n";=0D =0D # Insert entry in next level file=0D =09($ActLev =3D=3D 1) && MakeFile(0,$ProjectPath."/".$ProjectName,$Produc= tName); # project makes environment=0D =09if ($ActLev > 1) { # insert product and component into next level=0D =09=09my @FileList =3D ();=0D =09=09my $Count =3D 0;=0D =09=09$ProjectFileName =3D $ProjectPath."/".$Prefix[$ActLev-1].$ProjectNa= me.$Suffix;=0D =09=09print "Inserting ".$Prefix[$ActLev].$ProductName." into ".$Level[$A= ctLev-1]." ".$ProjectFileName."...\n";=0D =09=09open (myFILE, $ProjectFileName) or warn "Cannot open $ProjectFileNa= me: $!";=0D =09=09while () {=0D =09=09=09$FileList[$Count] =3D $_;=0D =09=09=09if (($ActLev=3D=3D3) && (m/\\project/)) { # if component=0D =09=09=09=09$ProjectLine =3D $_;=0D =09=09=09} # if component and project line in product file=0D =09=09=09if (m/\\stop$Level[$ActLev-1]/) { $StopPos =3D $Count; }=0D =09=09=09if (m/$Prefix[$ActLev]$ProductName/) {=0D =09=09=09=09$Exist =3D 1;=0D =09=09=09=09print "Entry exists already.\n";=0D =09=09=09}=0D =09=09=09$Count++;=0D =09=09} # while myFILE=0D =09=09close (myFILE);=0D =09=09if (!$Exist) {=0D =09=09=09open (myFILE, ">".$ProjectFileName) or warn "Cannot open $Projec= tFileName: $!";=0D =09=09=09for ($Count=3D0; $Count < @FileList; $Count++) {=0D =09=09=09=09if ($Count =3D=3D $StopPos) {=0D =09=09=09=09=09print myFILE "\t\\".$Level[$ActLev]." ".$Prefix[$ActLev].$= ProductName."\n";=0D =09=09=09=09} # if StopPos=0D =09=09=09=09print myFILE $FileList[$Count];=0D =09=09=09} # for=0D =09=09=09close (myFILE);=0D =09=09}=0D =09} # insert product and component into next level=0D =0D # Make this level file=0D =09if (-f $FileName) {=0D =09=09print "$FileName exists. May I overwrite it? (YJ/N, Return)\n";=0D =09=09while ($InKey !~ m/[JYN]/i) {=0D =09=09=09$InKey=3D "";=0D =09=09=09print "?";=0D =09=09=09$InKey =3D getc;=0D =09=09} # while=0D =09} # if file exists=0D =09$IniFile =3D $Level[$ActLev].$IniSuffix; # defaults for every level=0D =0D =09if ($InKey !~ m/N/i) {=0D =09=09print "Making $FileName...\n";=0D =09=09open (myFILE, ">".$FileName) or die "Cannot make $FileName: $!";=0D =0D =09=09($ActLev =3D=3D 1) && print myFILE "% output=3Dpdf interface=3Den\n= ";=0D =09=09print myFILE "\\start".$Level[$ActLev]." ".$Prefix[$ActLev].$Produc= tName."\n";=0D =09=09if (!$ActLev) { $tempLev=3D1; } else { $tempLev=3D$ActLev-1; }=0D =09=09print myFILE "\\$Level[$tempLev] ".$Prefix[$tempLev].$ProjectName."= \n";=0D =09=09($ProjectLine) && print myFILE $ProjectLine;=0D =09=09print myFILE "\n";=0D =09=09if ($ActLev=3D=3D1) {=0D =09=09=09print myFILE "% \\showlayout\n";=0D =09=09=09print myFILE "% \\showgrid\n";=0D =09=09=09print myFILE "% \\showbodyfontenvironment\n";=0D =09=09} # if project=0D =09=09if (-T $IniFile) { # look for .ini file in script dir=0D =09=09=09open (iniFILE, $IniFile) or warn "Cannot open $IniFile: $!";=0D =09=09=09print "inserting $IniFile into $FileName...\n";=0D =09=09=09while () { print myFILE;} # while=0D =09=09=09close (iniFILE) or warn "Cannot close $IniFile: $!";=0D =09=09}=0D =09=09$IniFile =3D $ProjectPath."/".$IniFile;=0D =09=09if ((-T $IniFile) && ($ProjectPath ne ".")) { # look for .ini file = in project dir=0D =09=09=09open (iniFILE, $IniFile) or warn "Cannot open $IniFile: $!";=0D =09=09=09print "inserting $IniFile into $FileName...\n";=0D =09=09=09while () { print myFILE;} # while=0D =09=09=09close (iniFILE) or warn "Cannot close $IniFile: $!";=0D =09=09}=0D =09=09print myFILE "\n";=0D =09=09print myFILE "\\stop$Level[$ActLev]\n";=0D =09=09print myFILE "\n";=0D =0D =09=09close (myFILE) or die "Cannot close $FileName: $!";=0D =0D =09} # if InKey not N=0D =0D } # sub MakeFile=0D =0D =0D =0D ###=0D sub help {=0D ###=0D =09($_[0]) && print "ERROR: $_[0]\n\n";=0D =09print "Syntax: makeproject --help\n";=0D =09print " will give this help\n";=0D =09print "......: makeproject --project \n";=0D =09print " will make $Prefix[1]$Suffix and $Prefix[0]= $Suffix\n";=0D =09print "......: makeproject --product \n";=0D =09print " will make $Prefix[2]$Suffix and add it to = $Prefix[1]$Suffix\n";=0D =09print "......: makeproject --component \n= ";=0D =09print " will make $Prefix[3]$Suffix and add it t= o $Prefix[2]$Suffix\n";=0D #=09print "......: makeproject --all \n";=0D #=09print " will make all of the files, asks after names\n";=0D =09print "Path should be only in first name!\n";=0D =09exit(1);=0D } # sub help=0D --------------Boundary-00=_59RF6MI3JPTKIEMUTZNW--