| 1 | package Padre::Action::Edit; |
|---|
| 2 | |
|---|
| 3 | # Fully encapsulated Edit menu |
|---|
| 4 | |
|---|
| 5 | use 5.008; |
|---|
| 6 | use strict; |
|---|
| 7 | use warnings; |
|---|
| 8 | use Padre::Current qw{_CURRENT}; |
|---|
| 9 | use Padre::Wx (); |
|---|
| 10 | use Padre::Wx::Menu (); |
|---|
| 11 | |
|---|
| 12 | our $VERSION = '0.58'; |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | ##################################################################### |
|---|
| 16 | # Padre::Wx::Menu Methods |
|---|
| 17 | |
|---|
| 18 | sub new { |
|---|
| 19 | my $class = shift; |
|---|
| 20 | my $main = shift; |
|---|
| 21 | |
|---|
| 22 | my $self = bless {}, $class; |
|---|
| 23 | |
|---|
| 24 | # Add additional properties |
|---|
| 25 | $self->{main} = $main; |
|---|
| 26 | |
|---|
| 27 | # Undo/Redo |
|---|
| 28 | Padre::Action->new( |
|---|
| 29 | name => 'edit.undo', |
|---|
| 30 | id => Wx::wxID_UNDO, |
|---|
| 31 | need_editor => 1, |
|---|
| 32 | |
|---|
| 33 | # need => sub { |
|---|
| 34 | # my %objects = @_; |
|---|
| 35 | # return 0 if !defined( $objects{editor} ); |
|---|
| 36 | # return $objects{editor}->CanUndo; |
|---|
| 37 | # }, |
|---|
| 38 | label => Wx::gettext('&Undo'), |
|---|
| 39 | comment => Wx::gettext('Undo last change in current file'), |
|---|
| 40 | shortcut => 'Ctrl-Z', |
|---|
| 41 | toolbar => 'actions/edit-undo', |
|---|
| 42 | menu_event => sub { |
|---|
| 43 | my $editor = Padre::Current->editor or return; |
|---|
| 44 | $editor->Undo; |
|---|
| 45 | }, |
|---|
| 46 | ); |
|---|
| 47 | |
|---|
| 48 | Padre::Action->new( |
|---|
| 49 | name => 'edit.redo', |
|---|
| 50 | id => Wx::wxID_REDO, |
|---|
| 51 | need_editor => 1, |
|---|
| 52 | |
|---|
| 53 | # need => sub { |
|---|
| 54 | # my %objects = @_; |
|---|
| 55 | # return 0 if !defined( $objects{editor} ); |
|---|
| 56 | # return $objects{editor}->CanRedo; |
|---|
| 57 | # }, |
|---|
| 58 | label => Wx::gettext('&Redo'), |
|---|
| 59 | comment => Wx::gettext('Redo last undo'), |
|---|
| 60 | shortcut => 'Ctrl-Y', |
|---|
| 61 | toolbar => 'actions/edit-redo', |
|---|
| 62 | menu_event => sub { |
|---|
| 63 | my $editor = Padre::Current->editor or return; |
|---|
| 64 | $editor->Redo; |
|---|
| 65 | }, |
|---|
| 66 | ); |
|---|
| 67 | |
|---|
| 68 | Padre::Action->new( |
|---|
| 69 | name => 'edit.select_all', |
|---|
| 70 | id => Wx::wxID_SELECTALL, |
|---|
| 71 | need_editor => 1, |
|---|
| 72 | label => Wx::gettext('Select all'), |
|---|
| 73 | comment => Wx::gettext('Select all the text in the current document'), |
|---|
| 74 | shortcut => 'Ctrl-A', |
|---|
| 75 | toolbar => 'actions/edit-select-all', |
|---|
| 76 | menu_event => sub { |
|---|
| 77 | require Padre::Wx::Editor; |
|---|
| 78 | Padre::Wx::Editor::text_select_all(@_); |
|---|
| 79 | }, |
|---|
| 80 | ); |
|---|
| 81 | |
|---|
| 82 | Padre::Action->new( |
|---|
| 83 | name => 'edit.mark_selection_start', |
|---|
| 84 | need_editor => 1, |
|---|
| 85 | label => Wx::gettext('Mark selection start'), |
|---|
| 86 | comment => Wx::gettext('Mark the place where the selection should start'), |
|---|
| 87 | shortcut => 'Ctrl-[', |
|---|
| 88 | menu_event => sub { |
|---|
| 89 | my $editor = Padre::Current->editor or return; |
|---|
| 90 | $editor->text_selection_mark_start; |
|---|
| 91 | }, |
|---|
| 92 | ); |
|---|
| 93 | |
|---|
| 94 | Padre::Action->new( |
|---|
| 95 | name => 'edit.mark_selection_end', |
|---|
| 96 | need_editor => 1, |
|---|
| 97 | label => Wx::gettext('Mark selection end'), |
|---|
| 98 | comment => Wx::gettext('Mark the place where the selection should end'), |
|---|
| 99 | shortcut => 'Ctrl-]', |
|---|
| 100 | menu_event => sub { |
|---|
| 101 | my $editor = Padre::Current->editor or return; |
|---|
| 102 | $editor->text_selection_mark_end; |
|---|
| 103 | }, |
|---|
| 104 | ); |
|---|
| 105 | |
|---|
| 106 | Padre::Action->new( |
|---|
| 107 | name => 'edit.clear_selection_marks', |
|---|
| 108 | need_editor => 1, |
|---|
| 109 | label => Wx::gettext('Clear selection marks'), |
|---|
| 110 | comment => Wx::gettext('Remove all the selection marks'), |
|---|
| 111 | menu_event => sub { |
|---|
| 112 | require Padre::Wx::Editor; |
|---|
| 113 | Padre::Wx::Editor::text_selection_clear_marks(@_); |
|---|
| 114 | }, |
|---|
| 115 | ); |
|---|
| 116 | |
|---|
| 117 | # Cut and Paste |
|---|
| 118 | Padre::Action->new( |
|---|
| 119 | name => 'edit.cut', |
|---|
| 120 | id => Wx::wxID_CUT, |
|---|
| 121 | need_editor => 1, |
|---|
| 122 | need_selection => 1, |
|---|
| 123 | label => Wx::gettext('Cu&t'), |
|---|
| 124 | comment => Wx::gettext('Remove the current selection and put it in the clipboard'), |
|---|
| 125 | shortcut => 'Ctrl-X', |
|---|
| 126 | toolbar => 'actions/edit-cut', |
|---|
| 127 | menu_event => sub { |
|---|
| 128 | my $editor = Padre::Current->editor or return; |
|---|
| 129 | $editor->Cut; |
|---|
| 130 | }, |
|---|
| 131 | ); |
|---|
| 132 | |
|---|
| 133 | Padre::Action->new( |
|---|
| 134 | name => 'edit.copy', |
|---|
| 135 | id => Wx::wxID_COPY, |
|---|
| 136 | need_editor => 1, |
|---|
| 137 | need_selection => 1, |
|---|
| 138 | label => Wx::gettext('&Copy'), |
|---|
| 139 | comment => Wx::gettext('Put the current selection in the clipboard'), |
|---|
| 140 | shortcut => 'Ctrl-C', |
|---|
| 141 | toolbar => 'actions/edit-copy', |
|---|
| 142 | menu_event => sub { |
|---|
| 143 | my $editor = Padre::Current->editor or return; |
|---|
| 144 | $editor->Copy; |
|---|
| 145 | }, |
|---|
| 146 | ); |
|---|
| 147 | |
|---|
| 148 | # Special copy |
|---|
| 149 | |
|---|
| 150 | Padre::Action->new( |
|---|
| 151 | name => 'edit.copy_filename', |
|---|
| 152 | need_editor => 1, |
|---|
| 153 | need_file => 1, |
|---|
| 154 | label => Wx::gettext('Copy full filename'), |
|---|
| 155 | comment => Wx::gettext('Put the full path of the current file in the clipboard'), |
|---|
| 156 | menu_event => sub { |
|---|
| 157 | my $document = Padre::Current->document; |
|---|
| 158 | return if !defined( $document->{file} ); |
|---|
| 159 | my $editor = Padre::Current->editor; |
|---|
| 160 | $editor->put_text_to_clipboard( $document->{file}->{filename} ); |
|---|
| 161 | }, |
|---|
| 162 | ); |
|---|
| 163 | |
|---|
| 164 | Padre::Action->new( |
|---|
| 165 | name => 'edit.copy_basename', |
|---|
| 166 | need_editor => 1, |
|---|
| 167 | need_file => 1, |
|---|
| 168 | label => Wx::gettext('Copy filename'), |
|---|
| 169 | comment => Wx::gettext('Put the name of the current file in the clipboard'), |
|---|
| 170 | menu_event => sub { |
|---|
| 171 | my $document = Padre::Current->document; |
|---|
| 172 | return if !defined( $document->{file} ); |
|---|
| 173 | my $editor = Padre::Current->editor; |
|---|
| 174 | $editor->put_text_to_clipboard( $document->{file}->basename ); |
|---|
| 175 | }, |
|---|
| 176 | ); |
|---|
| 177 | |
|---|
| 178 | Padre::Action->new( |
|---|
| 179 | name => 'edit.copy_dirname', |
|---|
| 180 | need_file => 1, |
|---|
| 181 | need_editor => 1, |
|---|
| 182 | label => Wx::gettext('Copy directory name'), |
|---|
| 183 | comment => Wx::gettext('Put the full path of the directory of the current file in the clipboard'), |
|---|
| 184 | menu_event => sub { |
|---|
| 185 | my $document = Padre::Current->document; |
|---|
| 186 | return if !defined( $document->{file} ); |
|---|
| 187 | my $editor = Padre::Current->editor; |
|---|
| 188 | $editor->put_text_to_clipboard( $document->{file}->dirname ); |
|---|
| 189 | }, |
|---|
| 190 | ); |
|---|
| 191 | |
|---|
| 192 | Padre::Action->new( |
|---|
| 193 | name => 'edit.copy_content', |
|---|
| 194 | need_editor => 1, |
|---|
| 195 | label => Wx::gettext('Copy editor content'), |
|---|
| 196 | comment => Wx::gettext('Put the content of the current document in the clipboard'), |
|---|
| 197 | menu_event => sub { |
|---|
| 198 | my $document = Padre::Current->document; |
|---|
| 199 | return if !defined( $document->{file} ); |
|---|
| 200 | my $editor = Padre::Current->editor; |
|---|
| 201 | $editor->put_text_to_clipboard( $document->text_get ); |
|---|
| 202 | }, |
|---|
| 203 | ); |
|---|
| 204 | |
|---|
| 205 | # Paste |
|---|
| 206 | Padre::Action->new( |
|---|
| 207 | name => 'edit.paste', |
|---|
| 208 | need_editor => 1, |
|---|
| 209 | id => Wx::wxID_PASTE, |
|---|
| 210 | label => Wx::gettext('&Paste'), |
|---|
| 211 | comment => Wx::gettext('Paste the clipboard to the current location'), |
|---|
| 212 | shortcut => 'Ctrl-V', |
|---|
| 213 | toolbar => 'actions/edit-paste', |
|---|
| 214 | menu_event => sub { |
|---|
| 215 | my $editor = Padre::Current->editor or return; |
|---|
| 216 | $editor->Paste; |
|---|
| 217 | }, |
|---|
| 218 | ); |
|---|
| 219 | |
|---|
| 220 | # Miscellaneous Actions |
|---|
| 221 | Padre::Action->new( |
|---|
| 222 | name => 'edit.goto', |
|---|
| 223 | label => Wx::gettext('&Goto'), |
|---|
| 224 | comment => Wx::gettext('Ask the user for a line number or a character position and jump there'), |
|---|
| 225 | shortcut => 'Ctrl-G', |
|---|
| 226 | menu_event => sub { |
|---|
| 227 | Padre::Wx::Main::on_goto(@_); |
|---|
| 228 | }, |
|---|
| 229 | ); |
|---|
| 230 | |
|---|
| 231 | Padre::Action->new( |
|---|
| 232 | name => 'edit.next_problem', |
|---|
| 233 | need_editor => 1, |
|---|
| 234 | label => Wx::gettext('&Next Problem'), |
|---|
| 235 | comment => Wx::gettext('Jumpt to the code that triggered the next error'), |
|---|
| 236 | shortcut => 'Ctrl-.', |
|---|
| 237 | menu_event => sub { |
|---|
| 238 | $main->{syntax}->select_next_problem if $main->{syntax}; |
|---|
| 239 | }, |
|---|
| 240 | ); |
|---|
| 241 | |
|---|
| 242 | Padre::Action->new( |
|---|
| 243 | name => 'edit.quick_fix', |
|---|
| 244 | need_editor => 1, |
|---|
| 245 | label => Wx::gettext('&Quick Fix'), |
|---|
| 246 | comment => Wx::gettext('Apply one of the quick fixes for the current document'), |
|---|
| 247 | shortcut => 'Ctrl-2', |
|---|
| 248 | menu_event => sub { |
|---|
| 249 | |
|---|
| 250 | my $doc = Padre::Current->document; |
|---|
| 251 | return if not $doc; |
|---|
| 252 | my $editor = $doc->editor; |
|---|
| 253 | $editor->AutoCompSetSeparator( ord '|' ); |
|---|
| 254 | my @list = (); |
|---|
| 255 | my @items = (); |
|---|
| 256 | eval { |
|---|
| 257 | |
|---|
| 258 | # Find available quick fixes from provider |
|---|
| 259 | my $provider = $doc->get_quick_fix_provider; |
|---|
| 260 | @items = $provider->quick_fix_list( $doc, $editor ); |
|---|
| 261 | |
|---|
| 262 | # Add quick list items from document's quick fix provider |
|---|
| 263 | foreach my $item (@items) { |
|---|
| 264 | push @list, $item->{text}; |
|---|
| 265 | } |
|---|
| 266 | }; |
|---|
| 267 | if ($@) { |
|---|
| 268 | warn "Error while calling get_quick_fix_provider: $@\n"; |
|---|
| 269 | } |
|---|
| 270 | my $empty_list = ( scalar @list == 0 ); |
|---|
| 271 | if ($empty_list) { |
|---|
| 272 | @list = ( Wx::gettext('No suggestions') ); |
|---|
| 273 | } |
|---|
| 274 | my $words = join( '|', @list ); |
|---|
| 275 | Wx::Event::EVT_STC_USERLISTSELECTION( |
|---|
| 276 | $main, $editor, |
|---|
| 277 | sub { |
|---|
| 278 | my ( $self, $event ) = @_; |
|---|
| 279 | return if $empty_list; |
|---|
| 280 | my $text = $event->GetText; |
|---|
| 281 | my $selection; |
|---|
| 282 | foreach my $item (@items) { |
|---|
| 283 | if ( $item->{text} eq $text ) { |
|---|
| 284 | $selection = $item; |
|---|
| 285 | last; |
|---|
| 286 | } |
|---|
| 287 | } |
|---|
| 288 | if ($selection) { |
|---|
| 289 | eval { &{ $selection->{listener} }(); }; |
|---|
| 290 | if ($@) { |
|---|
| 291 | warn "Failed while calling Quick fix " . $selection->{text} . "\n"; |
|---|
| 292 | } |
|---|
| 293 | } |
|---|
| 294 | }, |
|---|
| 295 | ); |
|---|
| 296 | $editor->UserListShow( 1, $words ); |
|---|
| 297 | }, |
|---|
| 298 | ); |
|---|
| 299 | |
|---|
| 300 | Padre::Action->new( |
|---|
| 301 | name => 'edit.autocomp', |
|---|
| 302 | need_editor => 1, |
|---|
| 303 | label => Wx::gettext('&AutoComplete'), |
|---|
| 304 | comment => Wx::gettext('Offer completions to the current string. See Preferences'), |
|---|
| 305 | shortcut => 'Ctrl-Space', |
|---|
| 306 | menu_event => sub { |
|---|
| 307 | Padre::Wx::Main::on_autocompletion(@_); |
|---|
| 308 | }, |
|---|
| 309 | ); |
|---|
| 310 | |
|---|
| 311 | Padre::Action->new( |
|---|
| 312 | name => 'edit.brace_match', |
|---|
| 313 | need_editor => 1, |
|---|
| 314 | label => Wx::gettext('&Brace matching'), |
|---|
| 315 | comment => Wx::gettext('Jump to the matching opening or closing brace: { }, ( ), [ ], < >'), |
|---|
| 316 | shortcut => 'Ctrl-1', |
|---|
| 317 | menu_event => sub { |
|---|
| 318 | Padre::Wx::Main::on_brace_matching(@_); |
|---|
| 319 | }, |
|---|
| 320 | ); |
|---|
| 321 | |
|---|
| 322 | Padre::Action->new( |
|---|
| 323 | name => 'edit.brace_match_select', |
|---|
| 324 | need_editor => 1, |
|---|
| 325 | label => Wx::gettext('&Select to matching brace'), |
|---|
| 326 | comment => Wx::gettext('Select to the matching opening or closing brace: { }, ( ), [ ], < >'), |
|---|
| 327 | shortcut => 'Ctrl-4', |
|---|
| 328 | menu_event => sub { |
|---|
| 329 | my $self = shift; |
|---|
| 330 | my $INVALID_POSITION = Wx::wxSTC_INVALID_POSITION; |
|---|
| 331 | my $page = $self->current->editor; |
|---|
| 332 | my $pos1 = $page->GetCurrentPos; |
|---|
| 333 | my $pos2 = $page->BraceMatch($pos1); |
|---|
| 334 | if ( $pos2 == $INVALID_POSITION ) { #Wx::wxSTC_INVALID_POSITION |
|---|
| 335 | if ( $pos1 > 0 ) { |
|---|
| 336 | $pos1--; |
|---|
| 337 | $pos2 = $page->BraceMatch($pos1); |
|---|
| 338 | } |
|---|
| 339 | } |
|---|
| 340 | |
|---|
| 341 | if ( $pos2 != $INVALID_POSITION ) { #Wx::wxSTC_INVALID_POSITION |
|---|
| 342 | my $start = $page->GetSelectionStart(); |
|---|
| 343 | $page->SetSelection($start, $pos2+1); |
|---|
| 344 | } |
|---|
| 345 | |
|---|
| 346 | return; |
|---|
| 347 | }, |
|---|
| 348 | ); |
|---|
| 349 | |
|---|
| 350 | Padre::Action->new( |
|---|
| 351 | name => 'edit.join_lines', |
|---|
| 352 | need_editor => 1, |
|---|
| 353 | need_selection => 1, |
|---|
| 354 | label => Wx::gettext('&Join lines'), |
|---|
| 355 | comment => Wx::gettext('Join the next line to the end of the current line.'), |
|---|
| 356 | shortcut => 'Ctrl-J', |
|---|
| 357 | menu_event => sub { |
|---|
| 358 | Padre::Wx::Main::on_join_lines(@_); |
|---|
| 359 | }, |
|---|
| 360 | ); |
|---|
| 361 | |
|---|
| 362 | Padre::Action->new( |
|---|
| 363 | name => 'edit.insert.insert_special', |
|---|
| 364 | need_editor => 1, |
|---|
| 365 | label => Wx::gettext('Insert Special Value'), |
|---|
| 366 | comment => Wx::gettext('Select a Date, Filename or other value and insert at the current location'), |
|---|
| 367 | shortcut => 'Ctrl-Shift-I', |
|---|
| 368 | menu_event => sub { |
|---|
| 369 | require Padre::Wx::Dialog::SpecialValues; |
|---|
| 370 | Padre::Wx::Dialog::SpecialValues->insert_special(@_); |
|---|
| 371 | }, |
|---|
| 372 | |
|---|
| 373 | ); |
|---|
| 374 | |
|---|
| 375 | Padre::Action->new( |
|---|
| 376 | name => 'edit.insert.snippets', |
|---|
| 377 | need_editor => 1, |
|---|
| 378 | label => Wx::gettext('Snippets'), |
|---|
| 379 | comment => Wx::gettext('Select and insert a snippet at the current location'), |
|---|
| 380 | shortcut => 'Ctrl-Shift-A', |
|---|
| 381 | menu_event => sub { |
|---|
| 382 | require Padre::Wx::Dialog::Snippets; |
|---|
| 383 | Padre::Wx::Dialog::Snippets->snippets(@_); |
|---|
| 384 | }, |
|---|
| 385 | ); |
|---|
| 386 | |
|---|
| 387 | Padre::Action->new( |
|---|
| 388 | name => 'edit.insert.from_file', |
|---|
| 389 | need_editor => 1, |
|---|
| 390 | label => Wx::gettext('Insert From File...'), |
|---|
| 391 | comment => Wx::gettext('Select a file and insert its content at the current location'), |
|---|
| 392 | menu_event => sub { |
|---|
| 393 | Padre::Wx::Main::on_insert_from_file(@_); |
|---|
| 394 | }, |
|---|
| 395 | ); |
|---|
| 396 | |
|---|
| 397 | # Commenting |
|---|
| 398 | Padre::Action->new( |
|---|
| 399 | name => 'edit.comment_toggle', |
|---|
| 400 | need_editor => 1, |
|---|
| 401 | need_selection => 1, |
|---|
| 402 | label => Wx::gettext('&Toggle Comment'), |
|---|
| 403 | comment => Wx::gettext('Comment out or remove comment out of selected lines in the document'), |
|---|
| 404 | shortcut => 'Ctrl-Shift-C', |
|---|
| 405 | toolbar => 'actions/toggle-comments', |
|---|
| 406 | menu_event => sub { |
|---|
| 407 | Padre::Wx::Main::on_comment_block( $_[0], 'TOGGLE' ); |
|---|
| 408 | }, |
|---|
| 409 | ); |
|---|
| 410 | |
|---|
| 411 | Padre::Action->new( |
|---|
| 412 | name => 'edit.comment', |
|---|
| 413 | need_editor => 1, |
|---|
| 414 | need_selection => 1, |
|---|
| 415 | label => Wx::gettext('&Comment Selected Lines'), |
|---|
| 416 | comment => Wx::gettext('Comment out selected lines in the document'), |
|---|
| 417 | shortcut => 'Ctrl-M', |
|---|
| 418 | menu_event => sub { |
|---|
| 419 | Padre::Wx::Main::on_comment_block( $_[0], 'COMMENT' ); |
|---|
| 420 | }, |
|---|
| 421 | ); |
|---|
| 422 | |
|---|
| 423 | Padre::Action->new( |
|---|
| 424 | name => 'edit.uncomment', |
|---|
| 425 | need_editor => 1, |
|---|
| 426 | need_selection => 1, |
|---|
| 427 | label => Wx::gettext('&Uncomment Selected Lines'), |
|---|
| 428 | comment => Wx::gettext('Remove comment out of selected lines in the document'), |
|---|
| 429 | shortcut => 'Ctrl-Shift-M', |
|---|
| 430 | menu_event => sub { |
|---|
| 431 | Padre::Wx::Main::on_comment_block( $_[0], 'UNCOMMENT' ); |
|---|
| 432 | }, |
|---|
| 433 | ); |
|---|
| 434 | |
|---|
| 435 | # Conversions and Transforms |
|---|
| 436 | Padre::Action->new( |
|---|
| 437 | name => 'edit.convert_encoding_system', |
|---|
| 438 | need_editor => 1, |
|---|
| 439 | label => Wx::gettext('Encode document to System Default'), |
|---|
| 440 | comment => Wx::gettext('Change the encoding of the current document to the default of the operating system'), |
|---|
| 441 | menu_event => sub { |
|---|
| 442 | require Padre::Wx::Dialog::Encode; |
|---|
| 443 | Padre::Wx::Dialog::Encode::encode_document_to_system_default(@_); |
|---|
| 444 | }, |
|---|
| 445 | ); |
|---|
| 446 | |
|---|
| 447 | Padre::Action->new( |
|---|
| 448 | name => 'edit.convert_encoding_utf8', |
|---|
| 449 | need_editor => 1, |
|---|
| 450 | label => Wx::gettext('Encode document to utf-8'), |
|---|
| 451 | comment => Wx::gettext('Change the encoding of the current document to utf-8'), |
|---|
| 452 | menu_event => sub { |
|---|
| 453 | require Padre::Wx::Dialog::Encode; |
|---|
| 454 | Padre::Wx::Dialog::Encode::encode_document_to_utf8(@_); |
|---|
| 455 | }, |
|---|
| 456 | ); |
|---|
| 457 | |
|---|
| 458 | Padre::Action->new( |
|---|
| 459 | name => 'edit.convert_encoding_to', |
|---|
| 460 | need_editor => 1, |
|---|
| 461 | label => Wx::gettext('Encode document to...'), |
|---|
| 462 | comment => Wx::gettext('Select an encoding and encode the document to that'), |
|---|
| 463 | menu_event => sub { |
|---|
| 464 | require Padre::Wx::Dialog::Encode; |
|---|
| 465 | Padre::Wx::Dialog::Encode::encode_document_to(@_); |
|---|
| 466 | }, |
|---|
| 467 | ); |
|---|
| 468 | |
|---|
| 469 | Padre::Action->new( |
|---|
| 470 | name => 'edit.convert_nl_windows', |
|---|
| 471 | need_editor => 1, |
|---|
| 472 | label => Wx::gettext('EOL to Windows'), |
|---|
| 473 | comment => Wx::gettext( |
|---|
| 474 | 'Change the end of line character of the current document to those used in files on MS Windows'), |
|---|
| 475 | menu_event => sub { |
|---|
| 476 | $_[0]->convert_to('WIN'); |
|---|
| 477 | }, |
|---|
| 478 | ); |
|---|
| 479 | |
|---|
| 480 | Padre::Action->new( |
|---|
| 481 | name => 'edit.convert_nl_unix', |
|---|
| 482 | need_editor => 1, |
|---|
| 483 | label => Wx::gettext('EOL to Unix'), |
|---|
| 484 | comment => Wx::gettext( |
|---|
| 485 | 'Change the end of line character of the current document to that used on Unix, Linux, Mac OSX'), |
|---|
| 486 | menu_event => sub { |
|---|
| 487 | $_[0]->convert_to('UNIX'); |
|---|
| 488 | }, |
|---|
| 489 | ); |
|---|
| 490 | |
|---|
| 491 | Padre::Action->new( |
|---|
| 492 | name => 'edit.convert_nl_mac', |
|---|
| 493 | need_editor => 1, |
|---|
| 494 | label => Wx::gettext('EOL to Mac Classic'), |
|---|
| 495 | comment => Wx::gettext('Change the end of line character of the current document to that used on Mac Classic'), |
|---|
| 496 | menu_event => sub { |
|---|
| 497 | $_[0]->convert_to('MAC'); |
|---|
| 498 | }, |
|---|
| 499 | ); |
|---|
| 500 | |
|---|
| 501 | # Tabs And Spaces |
|---|
| 502 | Padre::Action->new( |
|---|
| 503 | name => 'edit.tabs_to_spaces', |
|---|
| 504 | need_editor => 1, |
|---|
| 505 | label => Wx::gettext('Tabs to Spaces...'), |
|---|
| 506 | comment => Wx::gettext('Convert all tabs to spaces in the current document'), |
|---|
| 507 | menu_event => sub { |
|---|
| 508 | $_[0]->on_tab_and_space('Tab_to_Space'); |
|---|
| 509 | }, |
|---|
| 510 | ); |
|---|
| 511 | |
|---|
| 512 | Padre::Action->new( |
|---|
| 513 | name => 'edit.spaces_to_tabs', |
|---|
| 514 | need_editor => 1, |
|---|
| 515 | label => Wx::gettext('Spaces to Tabs...'), |
|---|
| 516 | comment => Wx::gettext('Convert all the spaces to tabs in the current document'), |
|---|
| 517 | menu_event => sub { |
|---|
| 518 | $_[0]->on_tab_and_space('Space_to_Tab'); |
|---|
| 519 | }, |
|---|
| 520 | ); |
|---|
| 521 | |
|---|
| 522 | Padre::Action->new( |
|---|
| 523 | name => 'edit.delete_trailing', |
|---|
| 524 | need_editor => 1, |
|---|
| 525 | label => Wx::gettext('Delete Trailing Spaces'), |
|---|
| 526 | comment => Wx::gettext('Remove the spaces from the end of the selected lines'), |
|---|
| 527 | menu_event => sub { |
|---|
| 528 | $_[0]->on_delete_ending_space; |
|---|
| 529 | }, |
|---|
| 530 | ); |
|---|
| 531 | |
|---|
| 532 | Padre::Action->new( |
|---|
| 533 | name => 'edit.delete_leading', |
|---|
| 534 | need_editor => 1, |
|---|
| 535 | label => Wx::gettext('Delete Leading Spaces'), |
|---|
| 536 | comment => Wx::gettext('Remove the spaces from the beginning of the selected lines'), |
|---|
| 537 | menu_event => sub { |
|---|
| 538 | $_[0]->on_delete_leading_space; |
|---|
| 539 | }, |
|---|
| 540 | ); |
|---|
| 541 | |
|---|
| 542 | # Upper and Lower Case |
|---|
| 543 | Padre::Action->new( |
|---|
| 544 | name => 'edit.case_upper', |
|---|
| 545 | need_editor => 1, |
|---|
| 546 | label => Wx::gettext('Upper All'), |
|---|
| 547 | comment => Wx::gettext('Change the current selection to upper case'), |
|---|
| 548 | shortcut => 'Ctrl-Shift-U', |
|---|
| 549 | menu_event => sub { |
|---|
| 550 | $_[0]->current->editor->UpperCase; |
|---|
| 551 | }, |
|---|
| 552 | ); |
|---|
| 553 | |
|---|
| 554 | Padre::Action->new( |
|---|
| 555 | name => 'edit.case_lower', |
|---|
| 556 | need_editor => 1, |
|---|
| 557 | label => Wx::gettext('Lower All'), |
|---|
| 558 | comment => Wx::gettext('Change the current selection to lower case'), |
|---|
| 559 | shortcut => 'Ctrl-U', |
|---|
| 560 | menu_event => sub { |
|---|
| 561 | $_[0]->current->editor->LowerCase; |
|---|
| 562 | }, |
|---|
| 563 | ); |
|---|
| 564 | |
|---|
| 565 | Padre::Action->new( |
|---|
| 566 | name => 'edit.diff2saved', |
|---|
| 567 | need_editor => 1, |
|---|
| 568 | label => Wx::gettext('Diff to Saved Version'), |
|---|
| 569 | comment => |
|---|
| 570 | Wx::gettext('Compare the file in the editor to that on the disk and show the diff in the output window'), |
|---|
| 571 | menu_event => sub { |
|---|
| 572 | Padre::Wx::Main::on_diff(@_); |
|---|
| 573 | }, |
|---|
| 574 | ); |
|---|
| 575 | Padre::Action->new( |
|---|
| 576 | name => 'edit.applydiff2file', |
|---|
| 577 | need_editor => 1, |
|---|
| 578 | label => Wx::gettext('Apply Diff to File'), |
|---|
| 579 | comment => Wx::gettext('Apply a patch file to the current document'), |
|---|
| 580 | menu_event => sub { |
|---|
| 581 | Padre::Wx::Main::on_diff(@_); |
|---|
| 582 | }, |
|---|
| 583 | ); |
|---|
| 584 | Padre::Action->new( |
|---|
| 585 | name => 'edit.applydiff2project', |
|---|
| 586 | need_editor => 1, |
|---|
| 587 | label => Wx::gettext('Apply Diff to Project'), |
|---|
| 588 | comment => Wx::gettext('Apply a patch file to the current project'), |
|---|
| 589 | menu_event => sub { |
|---|
| 590 | Padre::Wx::Main::on_diff(@_); |
|---|
| 591 | }, |
|---|
| 592 | ); |
|---|
| 593 | |
|---|
| 594 | # End diff tools |
|---|
| 595 | |
|---|
| 596 | Padre::Action->new( |
|---|
| 597 | name => 'edit.filter_tool', |
|---|
| 598 | need_editor => 1, |
|---|
| 599 | label => Wx::gettext('Filter through external tool'), |
|---|
| 600 | comment => Wx::gettext('Filters the selection (or the whole document) through any external command.'), |
|---|
| 601 | menu_event => sub { |
|---|
| 602 | Padre::Wx::Main::on_filter_tool(@_); |
|---|
| 603 | }, |
|---|
| 604 | ); |
|---|
| 605 | |
|---|
| 606 | Padre::Action->new( |
|---|
| 607 | name => 'edit.regex', |
|---|
| 608 | label => Wx::gettext('Regex Editor'), |
|---|
| 609 | comment => Wx::gettext('Open the regular expression editing window'), |
|---|
| 610 | |
|---|
| 611 | menu_event => sub { |
|---|
| 612 | Padre::Wx::Main::open_regex_editor(@_); |
|---|
| 613 | }, |
|---|
| 614 | ); |
|---|
| 615 | |
|---|
| 616 | Padre::Action->new( |
|---|
| 617 | name => 'edit.show_as_hex', |
|---|
| 618 | need_editor => 1, |
|---|
| 619 | label => Wx::gettext('Show as hexa'), |
|---|
| 620 | comment => Wx::gettext('Show the ASCII values of the selected text in hexa in the output window'), |
|---|
| 621 | menu_event => sub { |
|---|
| 622 | Padre::Wx::Main::show_as_numbers( @_, 'hex' ); |
|---|
| 623 | }, |
|---|
| 624 | ); |
|---|
| 625 | |
|---|
| 626 | Padre::Action->new( |
|---|
| 627 | name => 'edit.show_as_decimal', |
|---|
| 628 | need_editor => 1, |
|---|
| 629 | label => Wx::gettext('Show as decimal'), |
|---|
| 630 | comment => Wx::gettext('Show the ASCII values of the selected text in decimal numbers in the output window'), |
|---|
| 631 | menu_event => sub { |
|---|
| 632 | Padre::Wx::Main::show_as_numbers( @_, 'decimal' ); |
|---|
| 633 | }, |
|---|
| 634 | ); |
|---|
| 635 | |
|---|
| 636 | # User Preferences |
|---|
| 637 | Padre::Action->new( |
|---|
| 638 | name => 'edit.preferences', |
|---|
| 639 | label => Wx::gettext('Preferences'), |
|---|
| 640 | comment => Wx::gettext('Edit the user preferences'), |
|---|
| 641 | menu_event => sub { |
|---|
| 642 | Padre::Wx::Main::on_preferences(@_); |
|---|
| 643 | }, |
|---|
| 644 | ); |
|---|
| 645 | |
|---|
| 646 | return $self; |
|---|
| 647 | } |
|---|
| 648 | |
|---|
| 649 | 1; |
|---|
| 650 | |
|---|
| 651 | # Copyright 2008-2010 The Padre development team as listed in Padre.pm. |
|---|
| 652 | # LICENSE |
|---|
| 653 | # This program is free software; you can redistribute it and/or |
|---|
| 654 | # modify it under the same terms as Perl 5 itself. |
|---|