~ubuntu-branches/ubuntu/saucy/padre/saucy-proposed

« back to all changes in this revision

Viewing changes to lib/Padre/Wx/Dialog/Replace.pm

  • Committer: Package Import Robot
  • Author(s): Dominique Dumont, gregor herrmann, Dominique Dumont
  • Date: 2012-01-04 12:04:20 UTC
  • mfrom: (1.3.3)
  • Revision ID: package-import@ubuntu.com-20120104120420-i5oybqwf91m1d3il
Tags: 0.92.ds1-1
[ gregor herrmann ]
* Remove debian/source/local-options; abort-on-upstream-changes
  and unapply-patches are default in dpkg-source since 1.16.1.
* Swap order of alternative (build) dependencies after the perl
  5.14 transition.

[ Dominique Dumont ]
* Imported Upstream version 0.92.ds1
* removed fix-spelling patch (applied upstream)
* lintian-override: use wildcard to avoid listing a gazillion files
* updated size of some 'not-real-man-page' entries
* rules: remove dekstop cruft (replaced by a file provided in debian
  directory)
* control: removed Breaks statement. Add /me to uploaders. Updated
  dependencies
* rules: make sure that non-DFSG file (i.e. the cute butterfly, sigh)
  is not distributed

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
package Padre::Wx::Dialog::Replace;
2
2
 
3
 
=pod
4
 
 
5
 
=head1 NAME
6
 
 
7
 
Padre::Wx::Dialog::Replace - Find and Replace Widget
8
 
 
9
 
=head1 DESCRIPTION
10
 
 
11
 
C<Padre::Wx:Main> implements Padre's Find and Replace dialog box.
12
 
 
13
 
=head1 METHODS
14
 
 
15
 
=cut
16
 
 
17
3
use 5.008;
18
4
use strict;
19
5
use warnings;
20
 
use Params::Util qw{_STRING};
21
 
use Padre::DB                    ();
22
 
use Padre::Wx                    ();
23
 
use Padre::Wx::Role::Main        ();
24
 
use Padre::Wx::History::ComboBox ();
25
 
our $VERSION = '0.90';
26
 
our @ISA     = qw{
27
 
        Padre::Wx::Role::Main
28
 
        Wx::Dialog
29
 
};
30
 
 
31
 
=pod
32
 
 
33
 
=head2 new
34
 
 
35
 
  my $find = Padre::Wx::Dialog::Replace->new($main);
36
 
 
37
 
Create and return a C<Padre::Wx::Dialog::Replace> search and replace widget.
38
 
 
39
 
=cut
 
6
use Padre::Wx::FBP::Replace ();
 
7
 
 
8
our $VERSION = '0.92';
 
9
our @ISA     = 'Padre::Wx::FBP::Replace';
 
10
 
 
11
 
 
12
 
 
13
 
 
14
 
 
15
######################################################################
 
16
# Constructor
40
17
 
41
18
sub new {
42
19
        my $class = shift;
43
 
        my $main  = shift;
44
 
 
45
 
        # Create the Wx dialog
46
 
        my $self = $class->SUPER::new(
47
 
                $main,
48
 
                -1,
49
 
                Wx::gettext('Find and Replace'),
50
 
                Wx::wxDefaultPosition,
51
 
                Wx::wxDefaultSize,
52
 
                Wx::wxCAPTION | Wx::wxCLOSE_BOX | Wx::wxSYSTEM_MENU | Wx::wxRESIZE_BORDER
53
 
        );
54
 
 
55
 
        # The text to search for
56
 
        $self->{find_text} = Padre::Wx::History::ComboBox->new(
57
 
                $self,
58
 
                -1,
59
 
                '',
60
 
                Wx::wxDefaultPosition,
61
 
                Wx::wxDefaultSize,
62
 
                ['search'],
63
 
        );
64
 
 
65
 
        # The text to replace with
66
 
        $self->{replace_text} = Padre::Wx::History::ComboBox->new(
67
 
                $self,
68
 
                -1,
69
 
                '',
70
 
                Wx::wxDefaultPosition,
71
 
                Wx::wxDefaultSize,
72
 
                ['replace'],
73
 
        );
74
 
 
75
 
        # "Case Sensitive" option
76
 
        $self->{find_case} = Wx::CheckBox->new(
77
 
                $self,
78
 
                -1,
79
 
                Wx::gettext('Case &sensitive'),
80
 
        );
81
 
        Wx::Event::EVT_CHECKBOX(
82
 
                $self,
83
 
                $self->{find_case},
84
 
                sub {
85
 
                        $_[0]->{find_text}->SetFocus;
86
 
                }
87
 
        );
88
 
 
89
 
        # "Find as Regex" option
90
 
        $self->{find_regex} = Wx::CheckBox->new(
91
 
                $self,
92
 
                -1,
93
 
                Wx::gettext('Regular &Expression'),
94
 
        );
95
 
        Wx::Event::EVT_CHECKBOX(
96
 
                $self,
97
 
                $self->{find_regex},
98
 
                sub {
99
 
                        $_[0]->{find_text}->SetFocus;
100
 
                }
101
 
        );
102
 
 
103
 
        # "Find First and Close" option
104
 
        $self->{find_first} = Wx::CheckBox->new(
105
 
                $self,
106
 
                -1,
107
 
                Wx::gettext('Close Window on &Hit'),
108
 
        );
109
 
        Wx::Event::EVT_CHECKBOX(
110
 
                $self,
111
 
                $self->{find_first},
112
 
                sub {
113
 
                        $_[0]->{find_text}->SetFocus;
114
 
                }
115
 
        );
116
 
 
117
 
        # "Find in Reverse" option
118
 
        $self->{find_reverse} = Wx::CheckBox->new(
119
 
                $self,
120
 
                -1,
121
 
                Wx::gettext('Search &Backwards'),
122
 
        );
123
 
        Wx::Event::EVT_CHECKBOX(
124
 
                $self,
125
 
                $self->{find_reverse},
126
 
                sub {
127
 
                        $_[0]->{find_text}->SetFocus;
128
 
                }
129
 
        );
130
 
 
131
 
        # The "Replace All" option
132
 
        $self->{replace_all} = Wx::CheckBox->new(
133
 
                $self,
134
 
                -1,
135
 
                Wx::gettext('Replace &All'),
136
 
        );
137
 
        Wx::Event::EVT_CHECKBOX(
138
 
                $self,
139
 
                $self->{replace_all},
140
 
                sub {
141
 
                        $_[0]->{find_text}->SetFocus;
142
 
                }
143
 
        );
144
 
 
145
 
        # The "Find" button
146
 
        $self->{find_button} = Wx::Button->new(
147
 
                $self,
148
 
                Wx::wxID_FIND,
149
 
                Wx::gettext('&Find'),
150
 
        );
151
 
        Wx::Event::EVT_BUTTON(
152
 
                $self,
153
 
                $self->{find_button},
154
 
                sub {
155
 
                        $_[0]->find_button;
156
 
                }
157
 
        );
158
 
        Wx::Event::EVT_KEY_DOWN(
159
 
                $self->{find_button},
160
 
                sub {
161
 
                        $self->hotkey( $_[1], $self->{find_button} );
162
 
                }
163
 
        );
164
 
 
165
 
        # The "Replace" button
166
 
        $self->{replace_button} = Wx::Button->new(
167
 
                $self,
168
 
                Wx::wxID_REPLACE,
169
 
                Wx::gettext('&Replace'),
170
 
        );
171
 
        Wx::Event::EVT_BUTTON(
172
 
                $self,
173
 
                $self->{replace_button},
174
 
                sub {
175
 
                        $_[0]->replace_button;
176
 
                }
177
 
        );
178
 
        Wx::Event::EVT_KEY_DOWN(
179
 
                $self->{replace_button},
180
 
                sub {
181
 
                        $self->hotkey( $_[1], $self->{replace_button} );
182
 
                }
183
 
        );
184
 
        $self->{replace_button}->SetDefault;
185
 
 
186
 
        # The "Close" button
187
 
        $self->{close_button} = Wx::Button->new(
188
 
                $self,
189
 
                Wx::wxID_CANCEL,
190
 
                Wx::gettext('&Close'),
191
 
        );
192
 
        Wx::Event::EVT_BUTTON(
193
 
                $self,
194
 
                $self->{close_button},
195
 
                sub {
196
 
                        $_[0]->close;
197
 
                }
198
 
        );
199
 
 
200
 
        # Tab order
201
 
        $self->{find_regex}->MoveAfterInTabOrder( $self->{find_text} );
202
 
        $self->{replace_text}->MoveAfterInTabOrder( $self->{find_regex} );
203
 
        $self->{find_case}->MoveAfterInTabOrder( $self->{replace_regex} );
204
 
        $self->{find_reverse}->MoveAfterInTabOrder( $self->{find_case} );
205
 
        $self->{find_first}->MoveAfterInTabOrder( $self->{find_reverse} );
206
 
        $self->{replace_all}->MoveAfterInTabOrder( $self->{find_first} );
207
 
        $self->{find_button}->MoveAfterInTabOrder( $self->{replace_all} );
208
 
        $self->{replace_button}->MoveAfterInTabOrder( $self->{find_button} );
209
 
        $self->{close_button}->MoveAfterInTabOrder( $self->{replace_button} );
210
 
 
211
 
        # Form Layout
212
 
        # Find sizer begins here
213
 
        my $find = Wx::StaticBoxSizer->new(
214
 
                Wx::StaticBox->new(
215
 
                        $self,
216
 
                        -1,
217
 
                        Wx::gettext('Find'),
218
 
                ),
219
 
                Wx::wxVERTICAL,
220
 
        );
221
 
        $find->Add(
222
 
                Wx::StaticText->new(
223
 
                        $self,
224
 
                        Wx::wxID_STATIC,
225
 
                        Wx::gettext('Find Text:'),
226
 
                ),
227
 
                0,
228
 
                Wx::wxALIGN_LEFT | Wx::wxALIGN_CENTER_VERTICAL | Wx::wxALL,
229
 
                5,
230
 
        );
231
 
        $find->Add(
232
 
                $self->{find_text},
233
 
                3,
234
 
                Wx::wxGROW | Wx::wxALIGN_CENTER_VERTICAL | Wx::wxALL,
235
 
                5,
236
 
        );
237
 
        $find->Add(
238
 
                $self->{find_regex},
239
 
                0,
240
 
                Wx::wxALIGN_LEFT | Wx::wxLEFT | Wx::wxRIGHT | Wx::wxTOP,
241
 
                5,
242
 
        );
243
 
 
244
 
        # Replace sizer begins here
245
 
        my $replace = Wx::StaticBoxSizer->new(
246
 
                Wx::StaticBox->new(
247
 
                        $self,
248
 
                        -1,
249
 
                        Wx::gettext('Replace'),
250
 
                ),
251
 
                Wx::wxVERTICAL,
252
 
        );
253
 
        $replace->Add(
254
 
                Wx::StaticText->new(
255
 
                        $self,
256
 
                        Wx::wxID_STATIC,
257
 
                        Wx::gettext('Replace Text:'),
258
 
                ),
259
 
                0,
260
 
                Wx::wxALIGN_LEFT | Wx::wxALIGN_CENTER_VERTICAL | Wx::wxALL,
261
 
                5,
262
 
        );
263
 
        $replace->Add(
264
 
                $self->{replace_text},
265
 
                3,
266
 
                Wx::wxGROW | Wx::wxALIGN_CENTER_VERTICAL | Wx::wxALL,
267
 
                5,
268
 
        );
269
 
 
270
 
        # The layout grid for the options
271
 
        my $grid = Wx::FlexGridSizer->new( 2, 2, 0, 0 );
272
 
        $grid->AddGrowableCol(1);
273
 
        $grid->Add(
274
 
                $self->{find_case},
275
 
                0,
276
 
                Wx::wxALIGN_LEFT | Wx::wxLEFT | Wx::wxRIGHT | Wx::wxTOP,
277
 
                5,
278
 
        );
279
 
        $grid->Add(
280
 
                $self->{find_reverse},
281
 
                0,
282
 
                Wx::wxALIGN_LEFT | Wx::wxLEFT | Wx::wxRIGHT | Wx::wxTOP,
283
 
                5,
284
 
        );
285
 
        $grid->Add(
286
 
                $self->{find_first},
287
 
                0,
288
 
                Wx::wxALIGN_LEFT | Wx::wxLEFT | Wx::wxRIGHT | Wx::wxTOP,
289
 
                5,
290
 
        );
291
 
        $grid->Add(
292
 
                $self->{replace_all},
293
 
                0,
294
 
                Wx::wxALIGN_LEFT | Wx::wxLEFT | Wx::wxRIGHT | Wx::wxTOP,
295
 
                5,
296
 
        );
297
 
 
298
 
        # Options sizer begins here
299
 
        my $options = Wx::StaticBoxSizer->new(
300
 
                Wx::StaticBox->new(
301
 
                        $self,
302
 
                        -1,
303
 
                        Wx::gettext('Options')
304
 
                ),
305
 
                Wx::wxVERTICAL,
306
 
        );
307
 
        $options->Add(
308
 
                $grid,
309
 
                2,
310
 
                Wx::wxALIGN_CENTER_HORIZONTAL | Wx::wxGROW | Wx::wxALL,
311
 
                0,
312
 
        );
313
 
 
314
 
        # Sizer for the buttons
315
 
        my $bottom = Wx::BoxSizer->new(Wx::wxHORIZONTAL);
316
 
        $bottom->Add(
317
 
                $self->{find_button},
318
 
                0,
319
 
                Wx::wxGROW | Wx::wxRIGHT,
320
 
                5,
321
 
        );
322
 
        $bottom->Add(
323
 
                $self->{replace_button},
324
 
                0,
325
 
                Wx::wxGROW | Wx::wxLEFT | Wx::wxRIGHT,
326
 
                5,
327
 
        );
328
 
        $bottom->Add(
329
 
                $self->{close_button},
330
 
                0,
331
 
                Wx::wxGROW | Wx::wxLEFT,
332
 
                5,
333
 
        );
334
 
 
335
 
        # Fill the sizer for the overall dialog
336
 
        my $sizer = Wx::FlexGridSizer->new( 1, 1, 0, 0 );
337
 
        $sizer->AddGrowableCol(0);
338
 
        $sizer->Add(
339
 
                $find,
340
 
                2,
341
 
                Wx::wxALIGN_CENTER_HORIZONTAL | Wx::wxGROW | Wx::wxALL,
342
 
                5,
343
 
        );
344
 
        $sizer->Add(
345
 
                $replace,
346
 
                2,
347
 
                Wx::wxALIGN_CENTER_HORIZONTAL | Wx::wxGROW | Wx::wxALL,
348
 
                5,
349
 
        );
350
 
        $sizer->Add(
351
 
                $options,
352
 
                2,
353
 
                Wx::wxALIGN_CENTER_HORIZONTAL | Wx::wxGROW | Wx::wxALL,
354
 
                5,
355
 
        );
356
 
        $sizer->Add(
357
 
                $bottom,
358
 
                0,
359
 
                Wx::wxALIGN_RIGHT | Wx::wxALL,
360
 
                5,
361
 
        );
362
 
 
363
 
        # Let the widgets control the dialog size
364
 
        $self->SetSizer($sizer);
365
 
        $sizer->SetSizeHints($self);
 
20
        my $self  = $class->SUPER::new(@_);
 
21
 
 
22
        # Prepare to be shown
 
23
        $self->CenterOnParent;
366
24
 
367
25
        return $self;
368
26
}
369
27
 
370
 
=pod
371
 
 
372
 
=head2 find
373
 
 
374
 
  $self->find
375
 
 
376
 
Grab currently selected text, if any, and place it in find combo box.
377
 
Bring up the dialog or perform search for string's next occurrence
378
 
if dialog is already displayed.
379
 
 
380
 
TO DO: if selection is more than one line then consider it as the limit
381
 
of the search and not as the string to be used.
382
 
 
383
 
=cut
384
 
 
385
 
sub find {
386
 
        my $self = shift;
387
 
        my $text = $self->current->text;
388
 
 
389
 
        # No search if no file is open (TO DO ??)
390
 
        return unless $self->current->editor;
391
 
 
392
 
        # TO DO: if selection is more than one lines then consider it as the
393
 
        # limit of the search and not as the string to be used.
394
 
        $text = '' if $text =~ /\n/;
395
 
 
396
 
        # Clear out and reset the dialog, then prepare the new find
397
 
        $self->{find_text}->refresh($text);
398
 
        $self->{replace_text}->refresh;
399
 
        if ( $self->IsShown ) {
400
 
                $self->find_button;
 
28
 
 
29
 
 
30
 
 
31
 
 
32
######################################################################
 
33
# Main Methods
 
34
 
 
35
sub run {
 
36
        my $self    = shift;
 
37
        my $main    = $self->main;
 
38
        my $current = $self->current;
 
39
        my $config  = $current->config;
 
40
 
 
41
        # Do they have a specific search term in mind?
 
42
        my $text = $current->text;
 
43
        unless ( defined $text ) {
 
44
                $text = '';
 
45
        }
 
46
        unless ( length $text ) {
 
47
                if ( $main->has_findfast ) {
 
48
                        my $fast = $main->findfast->find_term;
 
49
                        $text = $fast if length $fast;  
 
50
                }
 
51
        }
 
52
        if ( $text =~ /\n/ ) {
 
53
                $text = '';
 
54
        }
 
55
 
 
56
        # Clear out and reset the search term box
 
57
        $self->{find_term}->refresh($text);
 
58
        if ( length $text ) {
 
59
                $self->{replace_term}->SetFocus;
401
60
        } else {
402
 
                if ( length $text ) {
403
 
 
404
 
                        # Go straight to the replace field
405
 
                        $self->{replace_text}->SetFocus;
406
 
                } else {
407
 
                        $self->{find_text}->SetFocus;
408
 
                }
409
 
                $self->Show(1);
410
 
        }
411
 
        return;
412
 
}
413
 
 
414
 
 
415
 
 
416
 
 
417
 
 
418
 
######################################################################
419
 
# Button Events
420
 
 
421
 
=pod
422
 
 
423
 
=head2 find_button
424
 
 
425
 
  $self->find_button
426
 
 
427
 
Executed when Find button is clicked.
428
 
 
429
 
Performs search on the term specified in the dialog.
430
 
 
431
 
=cut
432
 
 
433
 
sub find_button {
434
 
        my $self = shift;
435
 
        my $main = $self->main;
436
 
 
437
 
        # Generate the search object
438
 
        my $search = $self->as_search;
439
 
        unless ($search) {
440
 
                $main->error('Not a valid search');
441
 
 
442
 
                # Move the focus back to the search text
443
 
                # so they can tweak their search.
444
 
                $self->{find_text}->SetFocus;
445
 
                return;
446
 
        }
447
 
 
448
 
        # Apply the search to the current editor
449
 
        $main->search_next($search);
450
 
 
451
 
        # If we're only searching once, we won't need the dialog any more
452
 
        if ( $self->{find_first}->GetValue ) {
453
 
                $self->Hide;
454
 
        }
455
 
 
456
 
        return;
457
 
}
458
 
 
459
 
=pod
460
 
 
461
 
=head2 close
462
 
 
463
 
  $self->close
464
 
 
465
 
Hide dialog.
466
 
 
467
 
=cut
468
 
 
469
 
sub close {
470
 
        my $self = shift;
471
 
        $self->Hide;
 
61
                $self->{find_term}->SetFocus;
 
62
        }
 
63
 
 
64
        # Hide the Fast Find if visible
 
65
        $main->show_findfast(0);
 
66
 
 
67
        # Show the dialog
 
68
        my $result = $self->ShowModal;
472
69
 
473
70
        # As we leave the Find dialog, return the user to the current editor
474
71
        # window so they don't need to click it.
478
75
        return;
479
76
}
480
77
 
481
 
=pod
482
 
 
483
 
=head2 replace_button
484
 
 
485
 
  $self->replace_button;
486
 
 
487
 
Executed when the Replace button is clicked.
488
 
 
489
 
Replaces one appearance of the Find Text with the Replace Text.
490
 
 
491
 
If search window is still open, run C<search> on the whole text,
492
 
again.
493
 
 
494
 
=cut
495
 
 
496
 
# TO DO: The change to this function that turned it into a dual-purpose function
497
 
#       unintentionally transfered responsibility for the implementation of
498
 
#       "Replace All" from the main class to a dialog class.
499
 
#       This was a mistake, the dialog should not be where this is implemented.
500
 
#       Revert this change and restore the independent "Replace All" code, so
501
 
#       that the dialog goes back to acting only as controller.
502
 
sub replace_button {
503
 
        my $self = shift;
504
 
        my $main = $self->main;
505
 
 
506
 
        # Generate the search object
507
 
        my $search = $self->as_search;
508
 
        unless ($search) {
509
 
                $main->error('Not a valid search');
510
 
 
511
 
                # Move the focus back to the search text
512
 
                # so they can tweak their search.
513
 
                $self->{find_text}->SetFocus;
514
 
                return;
515
 
        }
516
 
 
517
 
        # If we are replacing everything, hand off to the other method
518
 
        if ( $self->{replace_all}->GetValue ) {
519
 
                return $self->replace_all;
520
 
        }
521
 
 
522
 
        # Just replace once
523
 
        my $changed = $main->replace_next($search);
524
 
        unless ($changed) {
525
 
                $main->message(
526
 
                        sprintf( Wx::gettext('No matches found for "%s".'), $self->{find_text}->GetValue ),
527
 
                        Wx::gettext('Search and Replace'),
528
 
                );
529
 
        }
530
 
 
531
 
        # Move the focus back to the search text
532
 
        # so they can change it if they want.
533
 
        $self->{find_text}->SetFocus;
534
 
        return;
535
 
}
536
 
 
537
 
=pod
538
 
 
539
 
=head2 replace_all
540
 
 
541
 
  $self->replace_all;
542
 
 
543
 
Executed when Replace All button is clicked.
544
 
 
545
 
Replace all appearances of given string in the current document.
546
 
 
547
 
=cut
548
 
 
549
 
sub replace_all {
550
 
        my $self = shift;
551
 
        my $main = $self->main;
552
 
 
553
 
        # Generate the search object
554
 
        my $search = $self->as_search;
555
 
        unless ($search) {
556
 
                $main->error('Not a valid search');
557
 
                return;
558
 
        }
559
 
 
560
 
        # Apply the search to the current editor
561
 
        my $number_of_changes = $main->replace_all($search);
562
 
        if ($number_of_changes) {
563
 
                my $message_text =
564
 
                        $number_of_changes == 1 ? Wx::gettext('Replaced %d match') : Wx::gettext('Replaced %d matches');
565
 
 
566
 
                # remark: It would be better to use gettext for plural handling, but wxperl does not seem to support this at the moment.
567
 
                $main->info(
568
 
                        sprintf( $message_text, $number_of_changes ),
569
 
                        Wx::gettext('Search and Replace')
570
 
                );
571
 
        } else {
572
 
                $main->info(
573
 
                        sprintf( Wx::gettext('No matches found for "%s".'), $self->{find_text}->GetValue ),
574
 
                        Wx::gettext('Search and Replace'),
575
 
                );
576
 
        }
577
 
 
578
 
        # Move the focus back to the search text
579
 
        # so they can change it if they want.
580
 
        $self->{find_text}->SetFocus;
581
 
        return;
582
 
}
583
 
 
584
 
 
585
 
 
586
 
 
587
 
 
588
 
#####################################################################
589
 
# Support Methods
590
 
 
591
 
=pod
592
 
 
593
 
=head2 as_search
594
 
 
595
 
Integration with L<Padre::Search>. Generates a search instance for the
596
 
currently configured information in the Find dialog.
597
 
 
598
 
Returns a L<Padre::Search> object, or C<undef> if current state of the
599
 
dialog does not result in a valid search.
600
 
 
601
 
=cut
602
 
 
 
78
# Makes sure the find button is only enabled when the field
 
79
# values are valid
 
80
sub refresh {
 
81
        my $self = shift;
 
82
        my $show = $self->{find_term}->GetValue ne '';
 
83
        $self->{find_term}->Enable($show);
 
84
        $self->{replace_term}->Enable($show);
 
85
}
 
86
 
 
87
# Generate a search object for the current dialog state
603
88
sub as_search {
604
89
        my $self = shift;
605
90
        require Padre::Search;
606
91
        Padre::Search->new(
607
 
                find_term    => $self->{find_text}->GetValue,
 
92
                find_term    => $self->{find_term}->SaveValue,
608
93
                find_case    => $self->{find_case}->GetValue,
609
94
                find_regex   => $self->{find_regex}->GetValue,
610
 
                find_reverse => $self->{find_reverse}->GetValue,
611
 
                replace_term => $self->{replace_text}->GetValue,
 
95
                replace_term => $self->{replace_term}->GetValue,
612
96
        );
613
97
}
614
98
 
615
 
# Adds Ultraedit-like hotkeys for quick find/replace triggering
616
 
sub hotkey {
617
 
        my $self   = shift;
618
 
        my $event  = shift;
619
 
        my $sender = shift;
620
 
 
621
 
        $self->find_button    if $event->GetKeyCode == ord 'F';
622
 
        $self->replace_button if $event->GetKeyCode == ord 'R';
623
 
        $self->close          if $event->GetKeyCode == Wx::WXK_ESCAPE;
624
 
 
625
 
        if ( $event->GetKeyCode == Wx::WXK_TAB ) {
626
 
                my $index;
627
 
                $index = 1 if $sender->GetId == $self->{find_button}->GetId;
628
 
                $index = 2 if $sender->GetId == $self->{replace_button}->GetId;
629
 
                $index = 3 if $sender->GetId == $self->{close_button}->GetId;
630
 
 
631
 
                if ( $event->ShiftDown ) {
632
 
                        $index--;
633
 
                } else {
634
 
                        $index++;
635
 
                }
636
 
 
637
 
                my @elements = qw(replace_all find_button replace_button close_button find_regex);
638
 
                $self->{ $elements[$index] }->SetFocus;
639
 
        }
640
 
 
641
 
        return;
642
 
}
643
 
 
644
99
1;
645
100
 
646
 
=pod
647
 
 
648
 
=head1 COPYRIGHT & LICENSE
649
 
 
650
 
Copyright 2008-2011 The Padre development team as listed in Padre.pm.
651
 
This program is free software; you can redistribute
652
 
it and/or modify it under the same terms as Perl itself.
653
 
The full text of the license can be found in the
654
 
LICENSE file included with this module.
655
 
 
656
 
=cut
 
101
 
657
102
 
658
103
# Copyright 2008-2011 The Padre development team as listed in Padre.pm.
659
104
# LICENSE
660
105
# This program is free software; you can redistribute it and/or
661
106
# modify it under the same terms as Perl 5 itself.
 
107