Ignore:
Timestamp:
03/13/10 10:45:22 (2 years ago)
Author:
karl.forner
Message:

Development related to the braces highlighting and matching.

Added some methods to enforce a uniform definition of what is a brace (so currently it is {}[](). All features using braces share this same definition :

  • highlighting
  • goto matching brace
  • select to matching brace

Moved all related code into Editor.pm.

Modified goto matching brace (CTRL+1) and select to matching brace in order to:

  • use the defined braces
  • respect the inside/outsideness of starting point, meaning that is the cursor is inside the braces; its detination point is also inside
  • the select to matching brace should also now work properly if there is an existing selection to the right of a closing brace
File:
1 edited

Legend:

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

    r11097 r11105  
    324324        need_editor => 1, 
    325325        label       => Wx::gettext('&Select to matching brace'), 
    326         comment     => Wx::gettext('Select to the matching opening or closing brace: { }, ( ), [ ], < >'), 
     326        comment     => Wx::gettext('Select to the matching opening or closing brace'), 
    327327        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         }, 
     328        menu_event  => sub { shift->current->editor->select_to_matching_brace } 
    348329    ); 
    349330 
Note: See TracChangeset for help on using the changeset viewer.