Changeset 5517


Ignore:
Timestamp:
06/23/09 20:36:44 (3 years ago)
Author:
azawawi
Message:

[Perl 6] No more insertion of text; just current line string replacement.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Padre-Plugin-Perl6/lib/Padre/Plugin/Perl6/Perl6Document.pm

    r5510 r5517  
    247247                        my $line_text  = $editor->GetTextRange($line_start, $line_end); 
    248248                        my $indent = ($line_text =~ /(^\s+)/) ? $1 : ''; 
    249                         $editor->InsertText($line_start, "${indent}my $var_name;$nl"); 
     249                        $line_text =  
     250                            "${indent}my $var_name;$nl" . 
     251                            $line_text; 
     252                        $editor->SetSelection( $line_start, $line_end ); 
     253                        $editor->ReplaceSelection( $line_text ); 
    250254                    }, 
    251255                }; 
     
    285289                        my $line_text  = $editor->GetTextRange($line_start, $line_end); 
    286290                        my $indent = ($line_text =~ /(^\s+)/) ? $1 : ''; 
    287                         $editor->InsertText($line_start,  
    288                             "${indent}sub $routine_name {$nl" . 
     291                        $line_text =  "${indent}sub $routine_name {$nl" . 
    289292                            "${indent}\t#XXX-implement$nl" . 
    290                             "${indent}}$nl"); 
     293                            "${indent}}$nl" . 
     294                            $line_text; 
     295                        $editor->SetSelection( $line_start, $line_end ); 
     296                        $editor->ReplaceSelection( $line_text );                             
    291297                    }, 
    292298                }; 
     
    647653                    listener => sub { 
    648654                        # comment current error by putting a hash and a space 
    649                         # since #( is an embedded comment in Perl 6! 
    650                         # see S02:166 
    651                         my $line_start = $editor->PositionFromLine( $current_line_no ); 
    652                         $editor->InsertText($line_start, '# '); 
     655                        # since #( is an embedded comment in Perl 6! see S02:166 
     656                        my $line_start = $editor->PositionFromLine( $current_line_no ); 
     657                        my $line_end   = $editor->GetLineEndPosition( $current_line_no ); 
     658                        my $line_text  = $editor->GetTextRange($line_start, $line_end); 
     659                        $line_text = "# ${line_text}"; 
    653660                    }, 
    654661                }; 
Note: See TracChangeset for help on using the changeset viewer.