/usr/bin/stag-view is in libdata-stag-perl 0.11-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | #!/usr/bin/perl -w
eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}'
if 0; # not running under some shell
# POD docs at end
use strict;
use Data::Stag qw(:all);
use Getopt::Long;
use FileHandle;
use Tk;
use Tk::Tree;
use Tk::Label;
my $sep = "\t";
my $parser;
my $help;
GetOptions(
"parser|format|p=s" => \$parser,
"help|h"=>\$help,
);
if ($help) {
system("perldoc $0");
exit 0;
}
my $fn = shift @ARGV;
my $fh;
if ($fn eq '-') {
$fh = \*STDIN;
}
else {
$fh = FileHandle->new($fn) || die $fn;
}
my $stag = Data::Stag->parse(-file=>$fn, -format=>$parser);
my @list = $stag->dlist;
#print join("\n", @list), "\n";
# Create a new main window.
#
my $top = new MainWindow( -title => "Tree" );
# stolen from DBIx::Tree
my $tree = $top->Scrolled( 'Tree',
-separator => '/',
-exportselection => 1,
-scrollbars => 'oe',
-height => 40,
-width => -1);
# Pack the tree.
#
$tree->pack( -expand => 'yes',
-fill => 'both',
-padx => 10,
-pady => 10,
-side => 'top' );
# When we ran $dbtree->tree earlier, the @list array was populated.
# It doesn't have a top element, so we need to pre-pend one to the
# list ('/' below).
#
unshift(@list, '/');
foreach ( @list ) {
my $text = (split( /[^\\]\//, $_ ))[-1];
# If we're on /, let's make its label blank.
#
if ($_ eq '/') {
$text = "";
}
$text =~ s[\\\/][\/]g;
s[\\\/][\\]g;
# Add the item (in $_) with $text as the label.
#
# print "ADD $_ $text\n";
$text =~ s/\[\d+\]$//;
$tree->add( $_, -text => $text );
}
$tree->autosetmode();
MainLoop;
exit 0;
__END__
=head1 NAME
stag-view - draws an expandable Tk tree diagram showing stag data
=head1 SYNOPSIS
stag-view file1.xml
=head1 DESCRIPTION
Draws a Tk tree, with expandable/convertable nodes
=head1 ARGUMENTS
=over
=item -p|parser FORMAT
FORMAT is one of xml, sxpr or itext
xml assumed as default
=back
=head1 SEE ALSO
L<Data::Stag>
L<Tk>
=cut
|