package funcJumper ;
#!perl
=head1 Copyright
*****************************************
* *
* Copyright (c) 2006, CloinkSoft *
* *
* mailto:Cloink_Friggson@ntlworld.com *
* *
*****************************************
=head1 LineNos - What it does
Interrogates passed filename (appropriately qualified) for it's sub-routine word,
and list each with line-number, especially useful if called from TextPad as a tool
with a "Regexp to match output" of "1", as this allows you to quickly
navigate to a particular function / sub / procedure / whatever match you desire,
by double-clicking the line shown in the Command Results window.
It expects the keyword to be at the beginning of the line, with optional leading spaces,
and it does a case-insensitive match to cater for as many languages as possible.
Note that JavaScript gets special treatment and finds both named functions, and
further methods of those functions, sorting the methods into alphabetical order.
e.g.
function JS_Func(){ null; } // possibly a constructor func for an object
JS_Func.meth1 = function(){ null; } // static meth but caters for .prototyped meths too
lists JS_Func AND JS_Func.method - the latter indented, and a new constructor gets a blank line
before it to help separate one from the next when you have a lot of methods.
I don't program in Java, but I imagine the JS special treatment will apply to that
and many other OO languages too.
=cut
$, = "" ; # between each argument to print ("field" separator)
$\ = "" ; # between each call to print ("record" separator)
my ( $f, $prt, $l, $i, $nuc, $fl, $srch, $js, $t );
@meths; # methods for JS
%mlnos;
format STDOUT =
@>>> @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$l, $prt
.
$f = $ARGV[0];
=head2 Specify your file types and search strings here
The search-string is bracketed so you can give a list of possible words
e.g. Oracle PL/SQL
PROCEDURE|FUNCTION
The sub-routine name can be quoted - for me, this allows me to use the perl-script
against my Oracle table-scripts which call a sub-script prior to each table-definition
e.g. Ora script
@TabIni "TABLE_NAME"
=cut
if( $f =~ /\.js$/ ){ # JavaScript
$js = 1;
$srch = 'function' ;
}
elsif( $f =~ /\.p[lm]||cgi$/ ){ # perl
$srch = 'sub';
}
elsif( $f =~ /\.pk[gbdhs]$/ ){ # Oracle packages
$srch = 'PROCEDURE|FUNCTION';
}
elsif( $f =~ /\.tab$/ ){ # Oracle table script
$srch = 'START ~UD.TabIni';
}
else{
die "Unknown file type.";
}
open IN, $f || die "Can't open $f" ;
while( <IN> ){
if( $_ =~ /^\s*($srch)\s+['"]?(\w+)['"]?/i ){ # " # case-insensitive, optional quotes round word, which will rarely be required but doesn't harm to have 'em, and my tab scripts need it
if( $js && $t ){ # switching from major func to another, but not first major func
$i=-1;
map { $l = $mlnos{$_}; $prt = " $_"; write; }
sort { return( uc $a lt uc $b ? -1 : 1 ) } @meths ;
@meths = ();
@mlnos = ();
print "\n" ; # so don't put a blank line at v top
}
$t = $2;
$l = $.;
$prt = $t;
write;
}
if( $js && $_ =~ /^ *$t\.(prototype\.)?(\w+) *= *function/ ){
push @meths, $2;
$mlnos{$2} = $.;
}
}
close IN;
1;
Getting the Current TabItem when the Tab is not selected in WPF
-
[image: Banner]
This is a quick reminder to self on how to retrieve a TabItem from a WPF
TabControl *when the tab is not currently selected* because I ru...
2 weeks ago
No comments:
Post a Comment
- the first minus - Comments have to be moderated because of the spammers
- the second minus - I am very lazy at moderating comments ... hardly find time ...
- the third minus - Short links are no good for security ...
- The REAL PLUS : Any critic and positive feedback is better than none, so your comments will be published sooner or later !!!!