diff --git a/mozilla/extensions/xmlterm/scripts/Makefile.in b/mozilla/extensions/xmlterm/scripts/Makefile.in new file mode 100644 index 00000000000..7e48c3de9a0 --- /dev/null +++ b/mozilla/extensions/xmlterm/scripts/Makefile.in @@ -0,0 +1,63 @@ +#!gmake +# +# The contents of this file are subject to the Mozilla Public +# License Version 1.1 (the "MPL"); you may not use this file +# except in compliance with the MPL. You may obtain a copy of +# the MPL at http://www.mozilla.org/MPL/ +# +# Software distributed under the MPL is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the MPL for the specific language governing +# rights and limitations under the MPL. +# +# The Original Code is lineterm. +# +# The Initial Developer of the Original Code is Ramalingam Saravanan. +# Portions created by Ramalingam Saravanan are +# Copyright (C) 1999 Ramalingam Saravanan. All Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the +# terms of the GNU General Public License (the "GPL"), in which case +# the provisions of the GPL are applicable instead of +# those above. If you wish to allow use of your version of this +# file only under the terms of the GPL and not to allow +# others to use your version of this file under the MPL, indicate +# your decision by deleting the provisions above and replace them +# with the notice and other provisions required by the GPL. +# If you do not delete the provisions above, a recipient +# may use your version of this file under either the MPL or the +# GPL. +# + +# makefile for xmlterm/scripts directory + +ifdef STAND_ALONE +DEPTH = .. +topsrcdir = .. +VPATH = . +srcdir = . +include $(topsrcdir)/config/autoconf.mk +else +DEPTH = ../../.. +topsrcdir = @top_srcdir@ +VPATH = @srcdir@ +srcdir = @srcdir@ +include $(DEPTH)/config/autoconf.mk +endif + +include $(topsrcdir)/config/config.mk + +include ../config/xmlterm_config.mk + +include $(topsrcdir)/config/rules.mk + +XMLTERM_SCRIPTS = \ + $(srcdir)/xmlterm \ + $(srcdir)/xls \ + $(srcdir)/xcat \ + $(NULL) + +install:: + $(INSTALL) -m 555 $(XMLTERM_SCRIPTS) $(DIST)/bin diff --git a/mozilla/extensions/xmlterm/scripts/README b/mozilla/extensions/xmlterm/scripts/README new file mode 100644 index 00000000000..62da913d2d7 --- /dev/null +++ b/mozilla/extensions/xmlterm/scripts/README @@ -0,0 +1,8 @@ +scripts --- Scripts for use under XMLterm + + +xmlterm Helper script to launch XMLTerm chrome using mozilla (sh) + +xcat XMLTerm aware UNIX "cat" command (Perl) + +xls XMLTerm aware UNIX "ls" command (Perl) diff --git a/mozilla/extensions/xmlterm/scripts/xcat b/mozilla/extensions/xmlterm/scripts/xcat new file mode 100755 index 00000000000..a9151b87476 --- /dev/null +++ b/mozilla/extensions/xmlterm/scripts/xcat @@ -0,0 +1,168 @@ +#!/usr/bin/perl +# xcat: an XMLterm wrapper for the UNIX "cat" command +# Usage: xcat [-h|help] + +use Cwd; +use Getopt::Long; + +Getopt::Long::config('bundling'); + +$options = "@ARGV"; + +&GetOptions("help|h!"); + +if ($opt_help) { + print STDERR "Usage: xcat ...\n"; + exit; +} + +my $cookie = $ENV{LTERM_COOKIE}; # XMLTerm cookie + +my $dir = cwd(); + +foreach my $url (@ARGV) { # for each argument + my ($protocol, $slashpair, $username, $host, $port, $pathname); + + if ( $url =~ m%\b # initiator + ([a-zA-Z]\w*)?: # protocol + (//)? # slashpair + (?:([\w.]+)@)? # username + ([\w\-]+(?:\.[\w\-]+)*)? # host + (?::(\d+))? # port + (/\S*?)? # pathname + (?=>|\"|\'|\s|[.,!](?:\s|\Z)|\Z) # terminator (look ahead) + %x ) { + + ($protocol, $slashpair, $username, $host, $port, $pathname) = + ($1, $2, $3, $4, $5, $6); +## print STDERR "URL: protocol=$protocol, slashpair=$slashpair, username=$username, host=$host, port=$port, pathname=$pathname\n"; + + } else { + # Not an URL; assume it is a local file + + # Prepend current working directory, if need be, to make full pathname + $url = $dir . "/" . $url if ($url and !($url =~ m%\A/%)); + +## print STDERR "Not an URL; assume local file $url\n"; + + ($protocol, $slashpair, $username, $host, $port, $pathname) = + ("file", "//", "", "", "", $url); + + } + + if (($protocol ne "http") && ($protocol ne "file")) { + print STDERR "xcat: Cannot handle URI protocol $protocol:\n"; + next; + } + + if ($protocol eq "file") { # Local filename + + if (!(-e $pathname)) { + print STDERR "xcat: File $pathname not found\n"; + next; + } + + if (!(-r $pathname)) { + print STDERR "xcat: Unable to read file $pathname\n"; + next; + } + + if (-d $pathname) { + print STDERR "xcat: Use the 'xls' command to list contents of directory $pathname\n"; + next; + } + } + + $pathname =~ m%\A(.*?) (\.[^/.]*)?\Z%x # Deconstruct pathname + or die "xcat: Internal error; unable to deconstruct pathname\n"; + + ($filename, $extension) = ($1, $2); + +## print STDERR "Filename=$filename, extension=$extension\n"; + + if (($extension eq ".gif") || ($extension eq ".png")) { +## print STDERR "Image file\n"; + + print "\e{S$cookie\a"; # HTML stream escape sequence + print ""; + print "\000"; # Terminate HTML stream + + } elsif (($protocol eq "http") || ($extension eq ".htm") + || ($extension eq ".html")) { + print STDERR "Web/HTML file (unable to display due to IFRAME bug)\n"; + + } elsif (($protocol eq "file") && ($extension eq ".url")) { + # URL + open INFILE, $pathname or next; + $_ = ; + close INFILE; + + my @urlvals; + my $nurl = 0; + while ( m%\b # initiator + (http|file|mailto): # protocol + (//)? # slashpair + (?:([\w.]+)@)? # username + ([\w\-]+(?:\.[\w\-]+)*)? # host + (?::(\d+))? # port + (/\S*?)? # pathname + (?=>|\"|\'|\s|[.,!](?:\s|\Z)|\Z) # terminator (look ahead) + %x ) { + $urlvals[$nurl] = $&; + s%$&%%; + $nurl++; + } + s%\A\s*(\S.*?)?\s*\Z%$1%; + + if ($nurl >= 1) { + my $urldesc = $_; + my $urlstr = $urlvals[0]; + $urldesc = $urlstr if !$urldesc; + + my $clickcmd = + qq%onclick="return clickXMLTerm('textlink',-#,'$urlstr')"%; + + print "\e{S$cookie\a"; # HTML stream escape sequence + if ($nurl >= 2) { + print "
"; + } + print ""; + print "\000"; # Terminate HTML stream + } + + } elsif ((-T $pathname) || ($extension eq "txt")) { # plain text file +## print STDERR "Text file\n"; + + open INFILE, $pathname or next; + print "\e{S$cookie\a"; # HTML stream escape sequence + print "
";
+
+        while () {
+            s/&/&/g;
+            s//">"/g;
+                s%\b                              # initiator
+                 ([a-zA-Z]\w*)?:                  # protocol
+                 (//)?                            # slashpair
+                 (?:([\w.]+)@)?                   # username
+                 ([\w\-]+(?:\.[\w\-]+)*)?         # host
+                 (?::(\d+))?                      # port
+                 (/\S*?)?                         # pathname
+                 (?=>|\"|\'|\s|[.,!](?:\s|\Z)|\Z) # terminator (look ahead)
+                 %$&%xg;
+                s/">"/>/g;
+
+            print $_;
+        }
+
+        print "
"; + print "\000"; # Terminate HTML stream + close INFILE; + + } else { # unknown file type + print STDERR "xcat: File type unknown for $pathname\n"; + next; + } +} + + diff --git a/mozilla/extensions/xmlterm/scripts/xcat.csh b/mozilla/extensions/xmlterm/scripts/xcat.csh new file mode 100755 index 00000000000..27e8e420f3c --- /dev/null +++ b/mozilla/extensions/xmlterm/scripts/xcat.csh @@ -0,0 +1,31 @@ +#!/bin/csh +# xcat.csh: a C-shell XMLterm wrapper for the UNIX "cat" command +# Usage: xcat.csh ... + +##set echocmd="/usr/bin/echo" +set echocmd="/bin/echo -e" + +foreach file ($*) + set ext=${file:e} + set firstchar = `echo $file|cut -c1` + + if ("$firstchar" == "/") then + set url="file:$file" + else + set url="file:$PWD/$file" + endif + + switch ($ext) + case "gif": + case "png": + # Is this a security risk??? Perhaps display using IFRAME? + $echocmd "\033{S${LTERM_COOKIE}\007\c" + cat < +EOF + $echocmd '\000\c' + breaksw + default: + cat $file + endsw +end diff --git a/mozilla/extensions/xmlterm/scripts/xls b/mozilla/extensions/xmlterm/scripts/xls new file mode 100755 index 00000000000..786564c1d0d --- /dev/null +++ b/mozilla/extensions/xmlterm/scripts/xls @@ -0,0 +1,150 @@ +#!/usr/bin/perl +# xls: an XMLterm wrapper for the UNIX "ls" command +# Usage: xls [-c|--cols] [-h|help] [-i||--iconic] [-w|--window] + +use Cwd; +use Getopt::Long; + +Getopt::Long::config('bundling'); + +my $options = "@ARGV"; + +&GetOptions("cols|c=i", "help|h!", "iconic|i!", "window|w!"); + +if ($opt_help) { + print "Usage: xls [-c|--cols] [-i|--iconic] [-w|--window]\n"; + exit; +} + +# Icon details +#my $imgdir="chrome://xmlterm/skin/default/images" +my $imgdir = "file:/usr/share/pixmaps/mc"; + +my %img; +($img{'directory'}, $img{'executable'}, $img{'plainfile'}) = + ('i-directory.png', 'i-executable.png', 'i-regular.png'); + +my $ncols = 5; +$ncols = $opt_cols if ($opt_cols); + +my $cookie = $ENV{LTERM_COOKIE}; # XMLTerm cookie +print "\e{S$cookie\a"; # HTML stream escape sequence +print ""; +print ""; + +my $dir = cwd(); +my $rowimg = ""; +my $rowtxt = ""; +my $nfile = 0; +foreach $file (glob("*")) { # for each file in current directory + $file =~ m%\A(.*?) (\.[^/.]*)?\Z%x # Deconstruct file name + or die "xls: Internal error; unable to deconstruct file name\n"; + + my ($filename, $extension) = ($1, $2); + + my $sendcmd; + if ($opt_window) { + $sendcmd = "createln"; + } else { + $sendcmd = "sendln"; + } + + my ($filetype, $fileimg, $sendtxt1, $sendtxt2); + + if (-d $file) { # directory + $filetype = "directory"; + $fileimg = "$imgdir/$img{$filetype}"; + $sendtxt1 = "cd $dir/$file; xls $options"; + $sendtxt2 = "cd $file; xls $options"; + + } elsif (-x $file) { # executable + $filetype = "executable"; + $fileimg = "$imgdir/$img{$filetype}"; + $sendtxt1 = "$dir/$file"; + $sendtxt2 = "./$file"; + + } elsif (($extension eq ".gif") || ($extension eq ".png")) { # image + $filetype = "imagefile"; + $fileimg = $file; + $sendtxt1 = "xcat $dir/$file"; + $sendtxt2 = "xcat $file"; + + } elsif ($extension eq ".url") { # URL + open INFILE, $file or next; + $_ = ; + close INFILE; + + my @urlvals; + my $nurl = 0; + while ( m%\b # initiator + (http|file|mailto): # scheme + (//)? # slashpair + (?:([\w.]+)@)? # username + ([\w\-]+(?:\.[\w\-]+)*)? # host + (?::(\d+))? # port + (/\S*?)? # pathname + (?=>|\"|\'|\s|[.,!](?:\s|\Z)|\Z) # terminator (look ahead) + %x ) { + $urlvals[$nurl] = $&; + s%$&%%; + $nurl++; + } + s%\A\s*(\S.*?)?\s*\Z%$1%; + + if ($nurl >= 1) { + my $urldesc = $_; + my $urlstr = $urlvals[0]; + $urldesc = $urlstr if !$urldesc; + + $sendcmd = "textlink"; # override send command + + $filetype = "urlfile"; + if ($nurl >= 2) { + $fileimg = "$urlvals[1]"; + } else { + $fileimg = "$imgdir/$img{$filetype}"; + } + $sendtxt1 = "$urlstr"; + $sendtxt2 = "$urlstr"; + } else { + $filetype = "plainfile"; + $fileimg = "$imgdir/$img{$filetype}"; + $sendtxt1 = "xcat $dir/$file"; + $sendtxt2 = "xcat $file"; + } + + } else { # plain file + $filetype = "plainfile"; + $fileimg = "$imgdir/$img{$filetype}"; + $sendtxt1 = "xcat $dir/$file"; + $sendtxt2 = "xcat $file"; + } + + my @comps = split(m./.,$file); + my $tail = $comps[$#comps]; # file name + + my $clickcmd = + qq%onclick="return clickXMLTerm('$sendcmd',-\#,'$sendtxt1','$sendtxt2')"%; + + $rowimg .= "$rowimg" if ($opt_iconic) ; + print "$rowtxt"; + $rowimg = ""; + $rowtxt = ""; + } + +} + +if ($rowtxt) { + print "$rowimg" if ($opt_iconic) ; + print "$rowtxt"; +} + +print "
"; + $rowtxt .= ""; + $rowtxt .= "$tail"; + $nfile++; + + if (($nfile % $ncols) == 0) { # print complete table row + print "
"; +print "\000"; # Terminate HTML stream + diff --git a/mozilla/extensions/xmlterm/scripts/xls.csh b/mozilla/extensions/xmlterm/scripts/xls.csh new file mode 100755 index 00000000000..1cd43bcc240 --- /dev/null +++ b/mozilla/extensions/xmlterm/scripts/xls.csh @@ -0,0 +1,81 @@ +#!/bin/csh +# xls.csh: a C-shell XMLterm wrapper for the UNIX "ls" command +# Usage: xls.csh [-i] [-x] + +set files=(`/bin/ls -d $cwd/*`) +set ncols=4 + +##set echocmd="/usr/bin/echo" +set echocmd="/bin/echo -e" + +set iconic=0 +set create=0 + +set options="" +foreach arg ($*) + switch ($arg) + case "-i": + set iconic=1 + set options=($options $arg) + breaksw + case "-c": + set create=1 + set options=($options $arg) + breaksw + endsw +end + +$echocmd "\033{S${LTERM_COOKIE}\007\c" +$echocmd '' +$echocmd "" + +set rowimg="" +set rowtxt="" +set nfile=0 +foreach file ($files) + if (-d $file) then #directory + set filetype="directory" + set sendtxt="cd $file; xls $options" + set sendimg="file:/usr/share/pixmaps/mc/i-directory.png" +# set sendimg="chrome://xmlterm/skin/default/images/ficon3.gif" + else if (-x $file) then #executable + set filetype="executable" + set sendtxt="$file" + set sendimg="file:/usr/share/pixmaps/mc/i-executable.png" + else #plain file + set filetype="plainfile" + set sendtxt="" + set sendimg="file:/usr/share/pixmaps/mc/i-regular.png" + endif + + set tail=${file:t} + + if ($create) then + set cmd="createln" + else + set cmd="sendln" + endif + set clickcmd="onclick="'"'"return clickXMLTerm('$cmd',-1,'$sendtxt')"'"' + + set rowimg="${rowimg}$rowimg" + $echocmd "$rowtxt" + set rowimg="" + set rowtxt="" + endif + +end + +if ("$rowtxt" != "") then + if ($iconic) $echocmd "$rowimg" + $echocmd "$rowtxt" +endif + +$echocmd '
" + set rowtxt="${rowtxt}" + set rowtxt="${rowtxt}$tail" +@ nfile++ + + if (($nfile % $ncols) == 0) then + if ($iconic) $echocmd "
' +$echocmd '\000\c' + diff --git a/mozilla/extensions/xmlterm/scripts/xmlterm b/mozilla/extensions/xmlterm/scripts/xmlterm new file mode 100755 index 00000000000..8132e398699 --- /dev/null +++ b/mozilla/extensions/xmlterm/scripts/xmlterm @@ -0,0 +1,37 @@ +#!/bin/sh +# Script to invoke XMLterm from mozilla/dist/bin +# (or from anywhere in the mozilla source tree) + +XMLTERM_CHROME="xmlterm.xul" +MOZILLA_BIN="./mozilla-bin" + +MOZILLA_DIR="" + +if [ -d components -a -d res ] +then + # Running from dist/bin + MOZILLA_DIR="./" +else + # Running from source dir + if [ -f Makefile.in ] + then + MOZILLA_DIR=`grep -w DEPTH Makefile.in | grep -e "\.\." | tail -1 | awk -F"=" '{ print $2; }'`/dist/bin + else + # Running from elsewhere + MOZILLA_DIR="${MOZILLA_FIVE_HOME:?}" + fi +fi + +echo cd $MOZILLA_DIR +cd $MOZILLA_DIR + +if [ -f chrome/xmlterm/content/default/$XMLTERM_CHROME ] +then + dummy=0 +else + echo "chrome://xmlterm/content/$XMLTERM_CHROME not found; error in installing XMLterm?" + exit 1 +fi + +echo ./run-mozilla.sh $MOZILLA_BIN -chrome "chrome://xmlterm/content/$XMLTERM_CHROME" +./run-mozilla.sh $MOZILLA_BIN -chrome "chrome://xmlterm/content/$XMLTERM_CHROME"