Padre

 view release on metacpan or  search on metacpan

lib/Padre/Wx/ActionLibrary.pm  view on Meta::CPAN

		},
	);

	Padre::Wx::Action->new(
		name        => 'edit.select_all',
		id          => Wx::ID_SELECTALL,
		need_editor => 1,
		label       => _T('Select &All'),
		comment     => _T('Select all the text in the current document'),
		shortcut    => 'Ctrl-A',
		toolbar     => 'actions/edit-select-all',
		menu_event  => sub {
			my $editor = $_[0]->current->editor or return;
			$editor->SelectAll;
		},
	);

	Padre::Wx::Action->new(
		name        => 'edit.mark_selection_start',
		need_editor => 1,
		label       => _T('Mark Selection &Start'),
		comment     => _T('Mark the place where the selection should start'),
		shortcut    => 'Ctrl-[',
		menu_event  => sub {
			my $editor = $_[0]->current->editor or return;
			$editor->text_selection_mark_start;
		},
	);

	Padre::Wx::Action->new(
		name        => 'edit.mark_selection_end',
		need_editor => 1,
		label       => _T('Mark Selection &End'),
		comment     => _T('Mark the place where the selection should end'),
		shortcut    => 'Ctrl-]',
		menu_event  => sub {
			my $editor = $_[0]->current->editor or return;
			$editor->text_selection_mark_end;
		},
	);

	Padre::Wx::Action->new(
		name        => 'edit.clear_selection_marks',
		need_editor => 1,
		label       => _T('&Clear Selection Marks'),
		comment     => _T('Remove all the selection marks'),
		menu_event  => sub {
			my $editor = $_[0]->current->editor or return;
			$editor->text_selection_clear;
		},
	);

	# Cut and Paste

	Padre::Wx::Action->new(
		name           => 'edit.cut',
		id             => Wx::ID_CUT,
		need_editor    => 1,
		need_selection => 1,
		label          => _T('Cu&t'),
		comment        => _T('Remove the current selection and put it in the clipboard'),
		shortcut       => 'Ctrl-X',
		toolbar        => 'actions/edit-cut',
		menu_event     => sub {
			my $editor = $_[0]->current->editor or return;
			$editor->Cut;
		},
	);

	Padre::Wx::Action->new(
		name           => 'edit.copy',
		id             => Wx::ID_COPY,
		need_editor    => 1,
		need_selection => 1,
		label          => _T('&Copy'),
		comment        => _T('Put the current selection in the clipboard'),
		shortcut       => 'Ctrl-C',
		toolbar        => 'actions/edit-copy',
		menu_event     => sub {
			my $editor = $_[0]->current->editor or return;
			$editor->Copy;
		},
	);

	# Special copy

	Padre::Wx::Action->new(
		name        => 'edit.copy_filename',
		need_editor => 1,
		need_file   => 1,
		label       => _T('Copy Full &Filename'),
		comment     => _T('Put the full path of the current file in the clipboard'),
		menu_event  => sub {
			my $current  = $_[0]->current;
			my $editor   = $current->editor or return;
			my $document = $current->document;
			return unless defined $document->{file};
			$editor->put_text_to_clipboard( $document->{file}->{filename} );
		},
	);

	Padre::Wx::Action->new(
		name        => 'edit.copy_basename',
		need_editor => 1,
		need_file   => 1,
		label       => _T('Copy F&ilename'),
		comment     => _T('Put the name of the current file in the clipboard'),
		menu_event  => sub {
			my $current  = $_[0]->current;
			my $editor   = $current->editor or return;
			my $document = $current->document;
			return unless defined $document->{file};
			$editor->put_text_to_clipboard( $document->{file}->basename );
		},
	);

	Padre::Wx::Action->new(
		name        => 'edit.copy_dirname',
		need_file   => 1,
		need_editor => 1,
		label       => _T('Copy &Directory Name'),
		comment     => _T('Put the full path of the directory of the current file in the clipboard'),
		menu_event  => sub {
			my $current  = $_[0]->current;
			my $editor   = $current->editor or return;
			my $document = $current->document;
			return unless defined $document->{file};
			$editor->put_text_to_clipboard( $document->{file}->dirname );
		},
	);

	Padre::Wx::Action->new(
		name        => 'edit.copy_content',
		need_editor => 1,
		label       => _T('Copy Editor &Content'),
		comment     => _T('Put the content of the current document in the clipboard'),
		menu_event  => sub {
			my $current  = $_[0]->current;
			my $editor   = $current->editor or return;
			my $document = $current->document;
			return unless defined $document->{file};
			$editor->put_text_to_clipboard( $document->text_get );
		},
	);

	# Paste

	Padre::Wx::Action->new(
		name        => 'edit.paste',
		need_editor => 1,
		id          => Wx::ID_PASTE,
		label       => _T('&Paste'),
		comment     => _T('Paste the clipboard to the current location'),
		shortcut    => 'Ctrl-V',
		toolbar     => 'actions/edit-paste',
		menu_event  => sub {
			my $editor = $_[0]->current->editor or return;
			$editor->Paste;
		},
	);

	# Miscellaneous Actions

	Padre::Wx::Action->new(
		name        => 'edit.next_problem',
		need_editor => 1,
		label       => _T('&Next Problem'),
		comment     => _T('Jump to the code that triggered the next error'),
		shortcut    => 'Ctrl-.',
		menu_event  => sub {
			$_[0]->{syntax}->select_next_problem if $_[0]->{syntax};
		},
	);

	Padre::Wx::Action->new(
		name        => 'edit.next_difference',
		need_editor => 1,
		label       => _T('&Next Difference'),
		comment     => _T('Jump to the code that has been changed'),
		shortcut    => 'Ctrl-,',
		menu_event  => sub {
			$_[0]->{diff}->select_next_difference if $_[0]->{diff};
		},
	) if Padre::Feature::DIFF_DOCUMENT;

	if (Padre::Feature::QUICK_FIX) {
		Padre::Wx::Action->new(
			name        => 'edit.quick_fix',
			need_editor => 1,
			label       => _T('&Quick Fix'),
			comment     => _T('Apply one of the quick fixes for the current document'),
			shortcut    => 'Ctrl-2',
			menu_event  => sub {
				my $main     = shift;
				my $current  = $main->current;
				my $document = $current->document or return;
				return unless $document->can('get_quick_fix_provider');

				my $editor = $current->editor;
				$editor->AutoCompSetSeparator( ord '|' );
				my @list  = ();
				my @items = ();
				eval {

					# Find available quick fixes from provider
					my $provider = $document->get_quick_fix_provider;
					@items = $provider->quick_fix_list( $document, $editor );

					# Add quick list items from document's quick fix provider
					foreach my $item (@items) {
						push @list, $item->{text};
					}
				};



( run in 2.731 seconds using v1.01-cache-2.11-cpan-84e82930d8c )