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)>
lib/App/Codit/Ext/CoditMDI.pm view on Meta::CPAN
[ 'menu_check', 'View::', 'Show ~document status',undef, '-doc_view_status', undef, 0, 1],
[ 'menu_separator', 'View::', 'v2' ],
[ 'menu_check', 'View::', 'Show ~spaces and tabs','show-spaces', '-doc_show_spaces', undef, 0, 1],
[ 'menu', undef, '~Tools'],
[ 'menu_normal', 'Tools::', '~Find', 'doc_find', 'edit-find', '*CTRL+F',],
[ 'menu_normal', 'Tools::', '~Replace', 'doc_replace', 'edit-find-replace','*CTRL+R',],
[ 'menu_separator', 'Tools::', 't1' ],
[ 'menu_check', 'Tools::', 'A~uto indent', undef, '-doc_autoindent', undef, 0, 1],
[ 'menu_check', 'Tools::', 'A~uto brackets', undef, '-doc_autobrackets', undef, 0, 1],
[ 'menu_check', 'Tools::', 'A~uto complete', undef, '-doc_autocomplete', undef, 0, 1],
[ 'menu_radio_s', 'Tools::', '~Wrap', [qw/char word none/], undef, '-doc_wrap'],
[ 'menu_separator', 'Tools::', 't1' ],
[ 'menu_normal', 'Tools::', 'R~emove trailing spaces', 'doc_remove_trailing',],
[ 'menu_normal', 'Tools::', 'F~ix indentation', 'doc_fix_indent',],
);
}
sub navCollapse {
my $self = shift;
my $tree = $self->Subwidget('NAVTREE');
$tree->collapseAll;
}
sub navContextMenu {
my $self = shift;
my $nav = $self->Subwidget('NAVTREE');
my @items = @navcontextmenu;
#checking if Git is loaded;
my $git = $self->extGet('Plugins')->plugGet('Git');
push @items, [ 'menu_normal', 'c1', '~Add to project', 'git_add', 'git-icon',] if defined $git;
my $stack = $self->extGet('MenuBar')->menuStack(@items);
$nav->configure('-contextmenu', $stack);
}
sub navExpand {
my $self = shift;
my $tree = $self->Subwidget('NAVTREE');
$tree->expandAll;
}
sub SettingsPage {
my $self = shift;
my ($first) = $self->docList;
my $doc = $self->docGet($first);
return () unless defined $doc;
my $themefile = $doc->cget('-highlight_themefile');
my $historyfile = $self->extGet('ConfigFolder')->ConfigFolder . '/color_history';
my @opt = (
-applycall => sub {
my $themefile = shift;
my @list = $self->docList;
for (@list) {
my $d = $self->docGet($_);
$d->configure(-highlight_themefile => $themefile);
$d->configureTags;
}
},
-defaultbackground => $doc->cget('-contentbackground'),
-defaultforeground => $doc->cget('-contentforeground'),
-defaultfont => $doc->CWidg->Subwidget('XText')->cget('-font'),
-historyfile => $historyfile,
-extension => $self,
-themefile => $themefile,
);
return (
'Highlighting' => ['CoditTagsEditor', @opt]
)
}
sub ToolItems {
my $self = shift;
my @items = $self->SUPER::ToolItems;
return (@items,
# type label cmd icon help
[ 'tool_separator' ],
[ 'tool_button', 'Copy', '<Control-c>', 'edit-copy', 'Copy selected text to clipboard'],
[ 'tool_button', 'Cut', '<Control-x>', 'edit-cut', 'Move selected text to clipboard'],
[ 'tool_button', 'Paste', '<Control-v>', 'edit-paste', 'Paste clipboard content into document'],
[ 'tool_separator' ],
[ 'tool_button', 'Undo', '<Control-z>', 'edit-undo', 'Undo last action'],
[ 'tool_button', 'Redo', '<Control-Z>', 'edit-redo', 'Cancel undo'],
);
}
=back
=head1 LICENSE
Same as Perl.
=head1 AUTHOR
Hans Jeuken (hanje at cpan dot org)
=head1 BUGS
Unknown. If you find any, please report them here L<https://github.com/haje61/App-Codit/issues>.
=head1 SEE ALSO
=over 4
=item L<App::Codit::Macro>
=item L<Tk::AppWindow::Ext::MDI>
=back
=cut
1;
( run in 0.612 second using v1.01-cache-2.11-cpan-fe3c2283af0 )