| 1 |
|
| 2 |
|
| 3 |
=head1 NAME |
| 4 |
|
| 5 |
Tk::PathparamEntry - perl/Tk Entry widget with redefined word boundaries |
| 6 |
|
| 7 |
=for pm Tk/PathparamEntry.pm |
| 8 |
|
| 9 |
=for category Derived Widgets |
| 10 |
|
| 11 |
=head1 SYNOPSIS |
| 12 |
|
| 13 |
use Tk::PathparamEntry; |
| 14 |
... |
| 15 |
$ppe = $mw->PathparamEntry(?options,...?); |
| 16 |
|
| 17 |
=head1 DESCRIPTION |
| 18 |
|
| 19 |
This "I<IS A>" entry widget with all bindings identical to the normal |
| 20 |
entry widget, except that word boundaries have been redefined to be |
| 21 |
appropriate to those of an Ifeffit math expression, i.e. whitespace |
| 22 |
plus parens, commas, and binary math operators. |
| 23 |
|
| 24 |
=head1 KEYS |
| 25 |
|
| 26 |
widget, entry |
| 27 |
|
| 28 |
=head1 SEE ALSO |
| 29 |
|
| 30 |
L<Tk::Entry> |
| 31 |
|
| 32 |
=cut |
| 33 |
|
| 34 |
|
| 35 |
package Tk::PathparamEntry; |
| 36 |
|
| 37 |
use Tk::Entry; |
| 38 |
use base qw(Tk::Entry); |
| 39 |
|
| 40 |
Construct Tk::Widget 'PathparamEntry'; |
| 41 |
|
| 42 |
sub wordstart |
| 43 |
{my ($w,$pos) = @_; |
| 44 |
my $string = $w->get; |
| 45 |
$pos = $w->index('insert')-1 unless(defined $pos); |
| 46 |
$string = substr($string,0,$pos); |
| 47 |
$string =~ s/[^- \t\n\r\f(),^+*\/]*$//; |
| 48 |
length $string; |
| 49 |
} |
| 50 |
|
| 51 |
sub wordend |
| 52 |
{my ($w,$pos) = @_; |
| 53 |
my $string = $w->get; |
| 54 |
my $anc = length $string; |
| 55 |
$pos = $w->index('insert') unless(defined $pos); |
| 56 |
$string = substr($string,$pos); |
| 57 |
$string =~ s/^(?:((?=[- \t\n\r\f(),^+*\/])[- \t\n\r\f(),+*\/]*|(?=[^- \t\n\r\f(),^+*\/])[^- \t\n\r\f(),^+*\/]*))//x; |
| 58 |
$anc - length($string); |
| 59 |
} |
| 60 |
|
| 61 |
1; |