~ubuntu-branches/ubuntu/maverick/padre/maverick

« back to all changes in this revision

Viewing changes to lib/Padre/Wx/Menu/Search.pm

  • Committer: Bazaar Package Importer
  • Author(s): Damyan Ivanov
  • Date: 2009-10-29 17:40:10 UTC
  • mto: (10.1.1 sid) (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20091029174010-v9ryrnscjm4gg0x2
Tags: upstream-0.48.ds2
ImportĀ upstreamĀ versionĀ 0.48.ds2

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
use 5.008;
6
6
use strict;
7
7
use warnings;
 
8
use Padre::Search ();
 
9
use Padre::Current qw{_CURRENT};
8
10
use Padre::Wx       ();
9
11
use Padre::Wx::Menu ();
10
 
use Padre::Current qw{_CURRENT};
11
12
 
12
 
our $VERSION = '0.42';
 
13
our $VERSION = '0.48';
13
14
our @ISA     = 'Padre::Wx::Menu';
14
15
 
 
16
 
 
17
 
 
18
 
 
19
 
15
20
#####################################################################
16
21
# Padre::Wx::Menu Methods
17
22
 
43
48
                label      => Wx::gettext('Find Next'),
44
49
                shortcut   => 'F3',
45
50
                menu_event => sub {
46
 
                        $_[0]->find->find_next;
 
51
                        my $editor = $_[0]->current->editor;
 
52
 
 
53
                        # Handle the obvious case with nothing selected
 
54
                        my ( $position1, $position2 ) = $editor->GetSelection;
 
55
                        if ( $position1 == $position2 ) {
 
56
                                return $_[0]->search_next;
 
57
                        }
 
58
 
 
59
                        # Multiple lines are also done the obvious way
 
60
                        my $line1 = $editor->LineFromPosition($position1);
 
61
                        my $line2 = $editor->LineFromPosition($position2);
 
62
                        unless ( $line1 == $line2 ) {
 
63
                                return $_[0]->search_next;
 
64
                        }
 
65
 
 
66
                        # Special case. Make and save a non-regex
 
67
                        # case-insensitive search and advance to the next hit.
 
68
                        my $search = Padre::Search->new(
 
69
                                find_case    => 0,
 
70
                                find_regex   => 0,
 
71
                                find_reverse => 0,
 
72
                                find_term    => $editor->GetTextRange(
 
73
                                        $position1, $position2,
 
74
                                ),
 
75
                        );
 
76
                        $_[0]->search_next($search);
 
77
 
 
78
                        # If we can't find another match, show a message
 
79
                        if ( ( $editor->GetSelection )[0] == $position1 ) {
 
80
                                $_[0]->error( Wx::gettext("Failed to find any matches") );
 
81
                        }
47
82
                },
48
83
        );
49
84
 
53
88
                label      => Wx::gettext('&Find Previous'),
54
89
                shortcut   => 'Shift-F3',
55
90
                menu_event => sub {
56
 
                        $_[0]->find->find_previous;
 
91
                        $_[0]->search_previous;
57
92
                },
58
93
        );
59
94
 
65
100
                name       => 'search.quick_find',
66
101
                label      => Wx::gettext('Quick Find'),
67
102
                menu_event => sub {
68
 
                        Padre->ide->config->set(
 
103
                        $_[0]->config->set(
69
104
                                'find_quick',
70
105
                                $_[1]->IsChecked ? 1 : 0,
71
106
                        );
72
107
                        return;
73
108
                },
74
109
        );
75
 
        $self->{quick_find}->Check( Padre->ide->config->find_quick );
 
110
        $self->{quick_find}->Check( $main->config->find_quick );
76
111
 
77
112
        # We should be able to remove F4 and shift-F4 and hook this functionality
78
113
        # to F3 and shift-F3 Incremental find (#60)
122
157
                },
123
158
        );
124
159
 
 
160
        $self->AppendSeparator;
 
161
 
 
162
        $self->add_menu_item(
 
163
                $self,
 
164
                name       => 'search.open_resource',
 
165
                label      => Wx::gettext('Open Resource'),
 
166
                shortcut   => 'Ctrl-Shift-R',
 
167
                menu_event => sub {
 
168
 
 
169
                        #Create and show the dialog
 
170
                        my $open_resource_dialog = $_[0]->open_resource;
 
171
                        $open_resource_dialog->showIt;
 
172
                },
 
173
        );
 
174
 
 
175
        $self->add_menu_item(
 
176
                $self,
 
177
                name       => 'search.quick_menu_access',
 
178
                label      => Wx::gettext('Quick Menu Access'),
 
179
                shortcut   => 'Ctrl-3',
 
180
                menu_event => sub {
 
181
 
 
182
                        #Create and show the dialog
 
183
                        require Padre::Wx::Dialog::QuickMenuAccess;
 
184
                        Padre::Wx::Dialog::QuickMenuAccess->new($main)->ShowModal;
 
185
                },
 
186
        );
 
187
 
125
188
        return $self;
126
189
}
127
190