Changeset 486


Ignore:
Timestamp:
10/26/08 06:29:16 (3 years ago)
Author:
szabgab
Message:

move _toggle_numbers to Padre::Wx::Editor

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

Legend:

Unmodified
Added
Removed
  • trunk/lib/Padre/Wx/Editor.pm

    r479 r486  
    179179} 
    180180 
     181# currently if there are 9 lines we set the margin to 1 width and then 
     182# if another line is added it is not seen well. 
     183# actually I added some improvement allowing a 50% growth in the file 
     184# and requireing a min of 2 width 
     185sub _toggle_numbers { 
     186    my ($editor, $on) = @_; 
     187 
     188    $editor->SetMarginWidth(1, 0); 
     189    $editor->SetMarginWidth(2, 0); 
     190    if ($on) { 
     191        my $n = 1 + List::Util::max (2, length ($editor->GetLineCount * 2)); 
     192        my $width = $n * $editor->TextWidth(Wx::wxSTC_STYLE_LINENUMBER, "9"); # width of a single character 
     193        $editor->SetMarginWidth(0, $width); 
     194        $editor->SetMarginType(0, Wx::wxSTC_MARGIN_NUMBER); 
     195    } else { 
     196        $editor->SetMarginWidth(0, 0); 
     197        $editor->SetMarginType(0, Wx::wxSTC_MARGIN_NUMBER); 
     198    } 
     199 
     200    return; 
     201} 
     202 
     203 
    1812041; 
  • trunk/lib/Padre/Wx/MainWindow.pm

    r485 r486  
    745745    my $title = $editor->{Document}->get_title; 
    746746 
    747     $self->_toggle_numbers($editor, $config->{editor_linenumbers}); 
     747    $editor->_toggle_numbers($config->{editor_linenumbers}); 
    748748    $editor->SetViewEOL($config->{editor_eol}); 
    749749    $self->set_preferences($editor, $config); 
     
    11001100 
    11011101    foreach my $page ( $self->pages ) { 
    1102         $self->_toggle_numbers( $page, $config->{editor_linenumbers} ); 
     1102        $page->_toggle_numbers( $config->{editor_linenumbers} ); 
    11031103    } 
    11041104 
     
    11801180} 
    11811181 
    1182  
    1183 # currently if there are 9 lines we set the margin to 1 width and then 
    1184 # if another line is added it is not seen well. 
    1185 # actually I added some improvement allowing a 50% growth in the file 
    1186 # and requireing a min of 2 width 
    1187 sub _toggle_numbers { 
    1188     my ($self, $editor, $on) = @_; 
    1189  
    1190     $editor->SetMarginWidth(1, 0); 
    1191     $editor->SetMarginWidth(2, 0); 
    1192     if ($on) { 
    1193         my $n = 1 + List::Util::max (2, length ($editor->GetLineCount * 2)); 
    1194         my $width = $n * $editor->TextWidth(Wx::wxSTC_STYLE_LINENUMBER, "9"); # width of a single character 
    1195         $editor->SetMarginWidth(0, $width); 
    1196         $editor->SetMarginType(0, Wx::wxSTC_MARGIN_NUMBER); 
    1197     } else { 
    1198         $editor->SetMarginWidth(0, 0); 
    1199         $editor->SetMarginType(0, Wx::wxSTC_MARGIN_NUMBER); 
    1200     } 
    1201  
    1202     return; 
    1203 } 
    12041182 
    12051183sub convert_to { 
Note: See TracChangeset for help on using the changeset viewer.