App-Codit
view release on metacpan or search on metacpan
lib/App/Codit/Macro.pm view on Meta::CPAN
package App::Codit::Macro;
=head1 NAME
App::Codit::Macro - Little applets for line to line text tasks.
=cut
use strict;
use warnings;
use vars qw ($VERSION);
$VERSION = '0.19';
use Tk;
=head1 SYNOPSIS
my $macro = $app->mdi->macroInit($docname, 'macroname', ['Some method', $obj]);
$macro->start;
=head1 DESCRIPTION
B<App::Codit::Macro> creates a task that calls the callback on a line to line basis.
It comes in handy for scanning and or modifying a document.
The callback receives the document textmanagers object and the line number as parameters.
The extension CoditMDI uses it for showing tabs and spaces, removing trailing spaces and fix indentation.
=head1 METHODS
=over 4
=cut
sub new {
my ($class, $mdi, $name, $doc, $call) = @_;
my $self = {
CALL => $mdi->CreateCallback(@$call),
DOC => $doc,
COUNTREF => undef,
INTERVAL => 1,
LAST => undef,
LINE => 1,
MDI => $mdi,
NAME => $name,
REMAIN => 0,
WIDG => $mdi->docGet($doc),
};
bless $self, $class;
return $self
}
=item B<busy>
Returns true when the macro is running.
=cut
sub busy {
my $self = shift;
return $self->dem->jobExists($self->jobname)
}
sub call { return $_[0]->{CALL} }
sub countref {
my $self = shift;
$self->{COUNTREF} = shift if @_;
return $self->{COUNTREF}
}
sub cycle {
my $self = shift;
my $line = $self->line;
$self->call->execute($self->widg, $line);
$line ++;
if ($line > $self->lastline) {
$self->stop;
} else {
$self->line($line);
}
my $c = $self->countref;
( run in 0.567 second using v1.01-cache-2.11-cpan-df04353d9ac )