Changeset 11125
- Timestamp:
- 03/15/10 10:40:29 (2 years ago)
- File:
-
- 1 edited
-
trunk/Padre/lib/Padre/Document.pm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Padre/lib/Padre/Document.pm
r11008 r11125 1305 1305 1306 1306 my $editor = $self->editor; 1307 my $src = $editor->GetSelectedText; 1308 my $code; 1309 if ($src) { 1310 $code = $src; 1311 1312 my $code2 = $code; # it's ugly, need improvement 1313 $code2 =~ s/\r\n/\n/g; 1314 $lines = 1; # by default 1315 $lines++ while ( $code2 =~ /[\r\n]/g ); 1316 $chars_with_space = length($code); 1317 } else { 1318 $code = $self->text_get; 1319 1320 # I trust editor more 1321 $lines = $editor->GetLineCount(); 1322 $chars_with_space = $editor->GetTextLength(); 1323 $is_readonly = $editor->GetReadOnly(); 1324 } 1307 my $code = $self->text_get; 1308 1309 $lines = $editor->GetLineCount(); 1310 $chars_with_space = $editor->GetTextLength(); 1311 $is_readonly = $editor->GetReadOnly(); 1325 1312 1326 1313 # avoid slow calculation on large files 1327 # TO DO or improve them ? 1328 if ( length($code) < 100_000 ) { 1314 # TODO or improve them? 1315 if ( length($code) < 500_000 ) { 1316 my $whitespace_chars = 0; 1329 1317 $words++ while ( $code =~ /\b\w+\b/g ); 1330 $chars_without_space++ while ( $code =~ /\S/g ); 1318 $chars_without_space = $chars_with_space; 1319 $chars_without_space-- while ( $code =~ /\s/g ); 1331 1320 } else { 1332 1321 $words = Wx::gettext("Skipped for large files"); … … 1340 1329 require Padre::Locale; 1341 1330 if ( not $self->{encoding} or $self->{encoding} eq 'ascii' ) { 1342 $self->{encoding} = Padre::Locale::encoding_from_string($ src);1331 $self->{encoding} = Padre::Locale::encoding_from_string($code); 1343 1332 } 1344 1333 return (
Note: See TracChangeset
for help on using the changeset viewer.
