зеркало из https://github.com/mozilla/pjs.git
xmlterm changes only (not part of the default build).
Added directory "scripts" to hold XMLterm-aware commands like "xls" and "xcat".
This commit is contained in:
Родитель
2d408fcbfa
Коммит
2296215fbf
|
@ -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 <svn@xmlterm.org> 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
|
|
@ -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 <URL1> <URL2> ...\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 "<IMG SRC='$protocol://${host}$pathname'>";
|
||||
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;
|
||||
$_ = <INFILE>;
|
||||
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 "<img src='$urlvals[1]' $clickcmd><br>";
|
||||
}
|
||||
print "<div class='textlink' $clickcmd')\">$urldesc</div>";
|
||||
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 "<pre>";
|
||||
|
||||
while (<INFILE>) {
|
||||
s/&/&/g;
|
||||
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)
|
||||
%<span class="textlink" onClick="return clickXMLTerm('textlink',-1,'$&')">$&</span>%xg;
|
||||
s/">"/>/g;
|
||||
|
||||
print $_;
|
||||
}
|
||||
|
||||
print "</pre>";
|
||||
print "\000"; # Terminate HTML stream
|
||||
close INFILE;
|
||||
|
||||
} else { # unknown file type
|
||||
print STDERR "xcat: File type unknown for $pathname\n";
|
||||
next;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -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 "<TABLE FRAME=none BORDER=0>";
|
||||
print "<COLGROUP COLSPAN=$ncols WIDTH=1*>";
|
||||
|
||||
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;
|
||||
$_ = <INFILE>;
|
||||
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 .= "<TD><IMG HEIGHT=48 WIDTH=48 SRC='$fileimg' $clickcmd>";
|
||||
$rowtxt .= "<TD><SPAN CLASS='$filetype' $clickcmd>";
|
||||
$rowtxt .= "$tail</SPAN>";
|
||||
$nfile++;
|
||||
|
||||
if (($nfile % $ncols) == 0) { # print complete table row
|
||||
print "<TR>$rowimg" if ($opt_iconic) ;
|
||||
print "<TR>$rowtxt";
|
||||
$rowimg = "";
|
||||
$rowtxt = "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($rowtxt) {
|
||||
print "<TR>$rowimg" if ($opt_iconic) ;
|
||||
print "<TR>$rowtxt";
|
||||
}
|
||||
|
||||
print "</TABLE>";
|
||||
print "\000"; # Terminate HTML stream
|
||||
|
|
@ -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 '<TABLE FRAME=none BORDER=0>'
|
||||
$echocmd "<COLGROUP COLSPAN=$ncols WIDTH=1*>"
|
||||
|
||||
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}<TD><IMG SRC='$sendimg' $clickcmd>"
|
||||
set rowtxt="${rowtxt}<TD><SPAN CLASS='$filetype' $clickcmd>"
|
||||
set rowtxt="${rowtxt}$tail<SPAN/>"
|
||||
@ nfile++
|
||||
|
||||
if (($nfile % $ncols) == 0) then
|
||||
if ($iconic) $echocmd "<TR>$rowimg"
|
||||
$echocmd "<TR>$rowtxt"
|
||||
set rowimg=""
|
||||
set rowtxt=""
|
||||
endif
|
||||
|
||||
end
|
||||
|
||||
if ("$rowtxt" != "") then
|
||||
if ($iconic) $echocmd "<TR>$rowimg"
|
||||
$echocmd "<TR>$rowtxt"
|
||||
endif
|
||||
|
||||
$echocmd '</TABLE>'
|
||||
$echocmd '\000\c'
|
||||
|
|
@ -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"
|
Загрузка…
Ссылка в новой задаче