Changeset 5381


Ignore:
Timestamp:
06/19/09 22:45:11 (3 years ago)
Author:
azawawi
Message:

[Perl 6] auto coloring is now in preferences and it is enabled by default.

Location:
trunk/Padre-Plugin-Perl6/lib/Padre/Plugin
Files:
2 edited

Legend:

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

    r5380 r5381  
    7474    } 
    7575    if(not defined $config->{p6_highlight}) { 
    76         $config->{p6_highlight} = 0; 
     76        $config->{p6_highlight} = 1; 
    7777    } 
    7878 
     
    135135        sub { $self->_create_from_template('p6_inline_in_p5', 'p5') }, 
    136136    ); 
    137  
    138     # Toggle Auto Perl6 syntax highlighting 
    139     $self->{p6_highlight} = 
    140         $self->{menu}->AppendCheckItem( -1, Wx::gettext("Enable Auto Coloring"),); 
    141     Wx::Event::EVT_MENU( 
    142         $main, 
    143         $self->{p6_highlight}, 
    144         sub { $self->toggle_highlight; } 
    145     ); 
    146     $self->{p6_highlight}->Check($config->{p6_highlight} ? 1 : 0); 
    147137 
    148138    # Export into HTML 
     
    434424} 
    435425 
    436 sub toggle_highlight { 
    437     my $self = shift; 
    438     if(! defined $self->{p6_highlight}) { 
    439         return; 
    440     } 
    441     $config->{p6_highlight} = $self->{p6_highlight}->IsChecked ? 1 : 0; 
    442     $self->config_write($config); 
    443     if($config->{p6_highlight}) { 
    444         $self->highlight; 
    445     } 
    446 } 
    447  
    448426sub highlight { 
    449427    my $self = shift; 
  • trunk/Padre-Plugin-Perl6/lib/Padre/Plugin/Perl6/Preferences.pm

    r5378 r5381  
    55 
    66use Class::XSAccessor accessors => { 
    7     _plugin         => '_plugin',           # plugin to be configured 
    8     _sizer          => '_sizer',            # window sizer 
    9     _colorizer_list => '_colorizer_list'    # colorizer list box 
     7    _plugin           => '_plugin',           # plugin to be configured 
     8    _sizer            => '_sizer',            # window sizer 
     9    _colorizer_cb     => '_colorizer_cb',      # colorizer on/off checkbox 
     10    _colorizer_list   => '_colorizer_list',    # colorizer list box 
    1011}; 
    1112 
     
    5859 
    5960    # update configuration 
    60     my $selection = $self->_colorizer_list->GetSelection(); 
    61     $prefs->{colorizer} = ($selection == 0) ? 'STD' : 'PGE'; 
     61    my $old_p6_highlight = $prefs->{p6_highlight}; 
     62    $prefs->{p6_highlight} = $self->_colorizer_cb->GetValue(); 
     63    $prefs->{colorizer} = ($self->_colorizer_list->GetSelection() == 0) ?  
     64        'STD' : 'PGE'; 
    6265 
    6366    # store plugin preferences 
    6467    $plugin->config_write($prefs); 
     68 
     69    if($old_p6_highlight != $prefs->{p6_highlight}) { 
     70        $plugin->highlight; 
     71    } 
    6572     
    6673    $self->Destroy; 
     
    107114    my $self = shift; 
    108115 
     116    $self->_colorizer_cb( 
     117        Wx::CheckBox->new( $self, -1, Wx::gettext('Enable coloring')) 
     118    ); 
     119     
    109120    my @choices = [ 
    110121        'S:H:P6/STD', 
     
    112123    ]; 
    113124    # syntax highligher selection 
    114     my $selector_label = Wx::StaticText->new( $self, -1, Wx::gettext('Syntax Highlighter:') ); 
     125    my $colorizer_list_label = Wx::StaticText->new( $self, -1, Wx::gettext('Colorizer:') ); 
    115126    $self->_colorizer_list(  
    116127        Wx::ListBox->new( 
     
    123134    ); 
    124135     
    125     # Select based on configuration variable 
    126     $self->_colorizer_list->Select( ($self->_plugin->config->{colorizer} eq 'STD') ? 0 : 1); 
     136    # Select based on configuration parameters 
     137    my $config = $self->_plugin->config; 
     138    $self->_colorizer_cb->SetValue( $config->{p6_highlight} ); 
     139    $self->_colorizer_list->Select( $config->{colorizer} eq 'STD' ? 0 : 1); 
    127140     
    128141    # pack the controls in a box 
    129142    my $box; 
    130143    $box = Wx::BoxSizer->new(Wx::wxHORIZONTAL); 
    131     $box->Add( $selector_label, 0, Wx::wxALL|Wx::wxEXPAND|Wx::wxALIGN_CENTER, 5 ); 
     144    $box->Add( $self->_colorizer_cb, 1, Wx::wxALL|Wx::wxEXPAND|Wx::wxALIGN_CENTER, 5 ); 
     145    $self->_sizer->Add( $box, 0, Wx::wxALL|Wx::wxEXPAND|Wx::wxALIGN_CENTER, 5 ); 
     146 
     147    $box = Wx::BoxSizer->new(Wx::wxHORIZONTAL); 
     148    $box->Add( $colorizer_list_label, 0, Wx::wxALL|Wx::wxEXPAND|Wx::wxALIGN_CENTER, 5 ); 
    132149    $box->Add( $self->_colorizer_list, 1, Wx::wxALL|Wx::wxEXPAND|Wx::wxALIGN_CENTER, 5 ); 
    133150    $self->_sizer->Add( $box, 0, Wx::wxALL|Wx::wxEXPAND|Wx::wxALIGN_CENTER, 5 ); 
Note: See TracChangeset for help on using the changeset viewer.