App-Codit

 view release on metacpan or  search on metacpan

lib/App/Codit/Ext/CoditMDI.pm  view on Meta::CPAN

sub docWidget {
	my $self = shift;
	my $name = $self->docSelected;
	return undef unless defined $name;
	my $doc = $self->docGet($name);
	return undef unless defined $doc;
	return $doc->CWidg;
}

sub docWrap {
	my $self = shift;
	return $self->docOption('-contentwrap', @_);
}

=item B<editDelete>I<($begin, $end)>

Deletes text in the currently selected document. It takes two indices as parameters.

=cut

sub editDelete {
	my $self = shift;
	my $doc = $self->docSelected;
	return unless defined $doc;
	$self->docGet($doc)->delete(@_);
}


=item B<editInsert>I<($index, $text)>

Inserts text in the currently selected document. It takes an index and the text as parameters.

=cut

sub editInsert {
	my $self = shift;
	my $doc = $self->docSelected;
	return unless defined $doc;
	$self->docGet($doc)->insert(@_);
}

=item B<editReplace>I<($begin, $end, $text)>

Inserts text in the currently selected document. It takes indices $begin and $end and the text as parameters.

=cut

sub editReplace {
	my $self = shift;
	my $doc = $self->docSelected;
	return unless defined $doc;
	$self->docGet($doc)->replace(@_);
}

sub keyReleased {
#	my ($self, $name, $key) = @_;
}

=back

Macros are callbacks executed in the background. For each line in the document the macro is linked to,
the callback is executed with a reference to the text widget and the line number as parameter.
the macro ends after the last line has been processed. Codit uses macro callback to do tasks like show
leading and trailing tabs and spaces and reparing indentation.

=over 4

=item B<macroGet>I<($doc, $name)>

Returns a reference to the macro object $name belonging to $doc.

=cut

sub macroGet {
	my ($self, $doc, $name) = @_;
	my $mcr = $self->_mcr;
	return unless exists $mcr->{$doc};
	my $l = $mcr->{$doc};
	for (@$l) {
		my $n = $_->name;
		return $_ if $_->name eq $name
	}
	return undef
}

=item B<macroInit>I<($doc, $name, $call)>

Creates a new macro object $name for $doc with $call as callback.

=cut

sub macroInit {
	my ($self, $doc, $name, $call) = @_;
	unless (defined $self->macroGet($doc, $name)) {
		my $macro = App::Codit::Macro->new($self, $name, $doc, $call);
		my $mcr = $self->_mcr;
		$mcr->{$doc} = [] unless exists $mcr->{$doc};
		my $l = $mcr->{$doc};
		push @$l, $macro;
		return $macro;
	}
	warn "macro $name for $doc already exists";
	return undef
}

=item B<macroList>I<($doc)>

Returns a list with the objects of loaded macros for $doc.

=cut

sub macroList {
	my ($self, $doc) = @_;
	my $mcr = $self->_mcr;
	return unless exists $mcr->{$doc};
	my $l = $mcr->{$doc};
	return @$l;
}

=item B<macroRemove>I<($doc, $name)>



( run in 1.235 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )