Ticket #230: toggle_comment.diff
| File toggle_comment.diff, 2.6 KB (added by claudio, 4 years ago) |
|---|
-
Padre/lib/Padre/Wx/Main.pm
897 897 return; 898 898 } 899 899 900 sub on_comment_toggle_block { 901 my $self = shift; 902 my $current = $self->current; 903 my $editor = $current->editor; 904 my $document = $current->document; 905 my $begin = $editor->LineFromPosition($editor->GetSelectionStart); 906 my $end = $editor->LineFromPosition($editor->GetSelectionEnd); 907 my $string = $document->comment_lines_str; 908 return unless defined $string; 909 $editor->comment_toggle_lines($begin, $end, $string); 910 return; 911 } 912 900 913 sub on_comment_out_block { 901 914 my $self = shift; 902 915 my $current = $self->current; -
Padre/lib/Padre/Wx/Editor.pm
642 642 } 643 643 644 644 $menu->AppendSeparator; 645 645 646 my $commentToggle = $menu->Append( -1, Wx::gettext("&Toggle Comment\tCtrl-Shift-C") ); 647 Wx::Event::EVT_MENU( $main, $commentToggle, 648 \&Padre::Wx::Main::on_comment_toggle_block, 649 ); 646 650 my $comment = $menu->Append( -1, Wx::gettext("&Comment Selected Lines\tCtrl-M") ); 647 651 Wx::Event::EVT_MENU( $main, $comment, 648 652 \&Padre::Wx::Main::on_comment_out_block, … … 837 841 return $text; 838 842 } 839 843 844 # Coment or comment text depending on the first selected line. 845 # This is the most coherent way to handle mixed blocks(commented and 846 # uncommented lines). 847 sub comment_toggle_lines { 848 my ($self, $begin, $end, $str) = @_; 849 if ( _get_line_by_number($self, $begin) =~ /\s*$str/ ) { 850 uncomment_lines(@_); 851 } else { 852 comment_lines(@_); 853 } 854 } 855 840 856 # $editor->comment_lines($begin, $end, $str); 841 857 # $str is either # for perl or // for Javascript, etc. 842 858 # $str might be ['<--', '-->] for html -
Padre/lib/Padre/Wx/Menu/Edit.pm
194 194 195 195 196 196 # Commenting 197 $self->{comment_toggle} = $self->Append( -1, 198 Wx::gettext("&Toggle Comment\tCtrl-Shift-C") 199 ); 200 Wx::Event::EVT_MENU( $main, 201 $self->{comment_toggle}, 202 \&Padre::Wx::Main::on_comment_toggle_block, 203 ); 204 197 205 $self->{comment_out} = $self->Append( -1, 198 206 Wx::gettext("&Comment Selected Lines\tCtrl-M") 199 207 );
