Changeset 11053


Ignore:
Timestamp:
03/10/10 15:16:14 (2 years ago)
Author:
karl.forner
Message:

Ticket #484:
Select a complete block from one brace to another

Made a quick implementation of the requested feature. I could not bind it to CTRL+SHIFT+1 because on my French keyboard it is the combination I have to type to produce the CTRL+1 shortcut, so I bound it to CTRL+4

Location:
trunk/Padre/lib/Padre
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Padre/lib/Padre/Action/Edit.pm

    r10997 r11053  
    319319        }, 
    320320    ); 
     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    ); 
    321349 
    322350    Padre::Action->new( 
  • trunk/Padre/lib/Padre/Wx/Menu/Edit.pm

    r10997 r11053  
    144144        $self, 
    145145        'edit.brace_match', 
     146    ); 
     147     
     148    $self->{brace_match_select} = $self->add_menu_action( 
     149        $self, 
     150        'edit.brace_match_select', 
    146151    ); 
    147152 
     
    362367    $self->{autocomp}->Enable($hasdoc); 
    363368    $self->{brace_match}->Enable($hasdoc); 
     369    $self->{brace_match_select}->Enable($hasdoc); 
    364370    $self->{join_lines}->Enable($hasdoc); 
    365371 
Note: See TracChangeset for help on using the changeset viewer.