Changeset 843


Ignore:
Timestamp:
11/09/08 02:13:20 (3 years ago)
Author:
szabgab
Message:

remove the document statistics from Development::Tools plugin
add filename to integrated document statistics

Location:
trunk/lib/Padre
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Padre/Plugin/Development/Tools.pm

    r786 r843  
    2323my @menu = ( 
    2424    ['About',          sub {about(@_)}          ], 
    25     ['Doc stats',      sub {doc_stats(@_)}      ], 
    2625    ['Show %INC',      sub {show_inc(@_)}       ], 
    2726    ['Reload plugins', sub {reload_plugins(@_)} ], 
     
    5352} 
    5453 
    55 sub doc_stats { 
    56     my ($main) = @_; 
    57      
    58     my $doc = Padre::Documents->current; 
    59      
    60     if (not $doc) { 
    61         Wx::MessageBox( "No file is open", "Stats", Wx::wxOK|Wx::wxCENTRE, $main ); 
    62     } 
    63     my $text = $doc->text_get; 
    64     my $str = sprintf("Number of characters in the current file: %s\n", length($text)); 
    65     my $spaces = () = $text =~ /( )/g; 
    66     $str .= sprintf("Number of spaces: %s\n", $spaces); 
    67      
    68     if (defined $doc->filename) { 
    69         $str .= sprintf("Filename: '%s'\n", $doc->filename); 
    70     } else { 
    71         $str .= "No filename\n"; 
    72     } 
    73  
    74     Wx::MessageBox( $str, "Stats", Wx::wxOK|Wx::wxCENTRE, $main ); 
    75     return; 
    76 } 
    77  
    7854sub reload_plugins { 
    7955    my ($main) = @_; 
  • trunk/lib/Padre/Wx/MainWindow.pm

    r836 r843  
    15001500    my $src = $self->selected_text; 
    15011501    my $doc = $self->selected_document; 
     1502    if (not $doc) { 
     1503        $self->message( 'No file is open', 'Stats' ); 
     1504        return; 
     1505    } 
     1506 
    15021507    if ( $src ) { 
    15031508        $code = $src; 
     
    15201525    $words++ while ( $code =~ /\b\w+\b/g ); 
    15211526    $chars_without_space++ while ( $code =~ /\S/g ); 
    1522  
     1527     
    15231528    my $message = <<MESSAGE; 
    15241529Words: $words 
     
    15281533MESSAGE 
    15291534 
     1535    if (defined $doc->filename) { 
     1536        $message .= sprintf("Filename: '%s'\n", $doc->filename); 
     1537    } else { 
     1538        $message .= "No filename\n"; 
     1539    } 
     1540 
    15301541    if ($is_readonly) { 
    15311542        $message .= "File is read-only.\n"; 
     
    15331544     
    15341545    $self->message( $message, 'Stats' ); 
     1546    return; 
    15351547} 
    15361548 
Note: See TracChangeset for help on using the changeset viewer.