Config-Model-CursesUI

 view release on metacpan or  search on metacpan

lib/Config/Model/CursesUI.pm  view on Meta::CPAN

                     {
                         -label => "< overall tabular view >",
                         '-onpress'
                         => sub{$self->display_view_list($root,
                                                         'std',
                                                         'tabular') ;}, 
                     },
                     {
                         -label => "< overall tabular audit >",
                         -onpress => sub{$self->display_view_list($root,
                                                                  'audit',
                                                                  'tabular') ;}, 
                     },
                     {
                         -label => "< overall view >",
                         -onpress => sub{$self->display_view_list($root,
                                                                  'std',
                                                                  'tree') ;}, 
                     },
                     {
                         -label => "< overall audit >",
                         -onpress => sub{$self->display_view_list($root,
                                                                  'audit',
                                                                  'tree') ;}, 
                     },
                     {
                         -label => "< look for errors >",
                         -onpress => sub{$self->wizard($root,0) ;}, 
                     },
                 ]
            );

    $self->{displayed_object} = $_[0] ;

    push @{$self->{stack}} , $self->{start_config};

    $self->{cui}->getobj('center')->focus ;

    # must add:
    # button to access a view style list
}

# update the location label with config element path
# add the current screen on user's call stack
sub wrap_screen {
    my ($self,$node,$element,$idx) = @_ ;

    $self->{displayed_object} = $node ;

    $self->update_location($node,$element,$idx) ;

    my $scan_type = defined $idx     ? 'hash'
        : defined $element ? 'element' 
        :                    'node' ;

    push @{$self->{stack}} , sub{$self->scan($scan_type,$node,$element,$idx)};

    $self->{cui}->getobj('center')->focus ;
}

sub update_location {
    my ($self,$node,$element,$idx) = @_ ;

    my $loc = $node->location ;
    $loc   .= ' '        if $loc ;
    $loc   .= $element   if defined $element ;
    $loc   .= ":$idx"    if defined $idx ;

    $self->{loc_label}->text($loc) ;
}

sub scan {
    my ($self,$what,@args) = @_ ;

    my $meth = 'scan_'.$what ;

    eval {$self->{scan}->$meth($self,@args) ; };

    # we may want to handle differently the exception
    $self->{cui}->fatalerror("Error in $meth:\n$@")
        if $@ ;
}

sub display_node_content {
    my ($self,$node,@element) = @_ ;

    my $win = $self->set_center_window("Node ".$node->name) ;

    $self->add_debug_label($win) ;

    $win->add(undef, 'Label', '-y' => 0,
              -text => "Choose one of the elements:");

    my $valuew = $win->add(undef, 'Label', -bg => 'yellow',
                           '-y' => 2, '-x' => 40, -width => 38 );
    my $permw  = $win->add(undef, 'Label', 
                           '-y' => 3, '-x' => 40, -width => 38 );
    my $selw   = $win->add(undef, 'Label', 
                           '-y' => 4, '-x' => 40, -width => 38 );
    my $helpw  = $win->add(undef, 'TextViewer', 
                           '-y' => 5, '-x' => 40, -width => 38,
                           '-title' => 'Help on element',
                           @help_settings);

    my $listbox ;
    my $buttons ;
    my $lb_change = sub {
        my $sel = ($listbox->get)[0];
        $selw->text("selected $sel ");
        $buttons -> focus ;
    } ;

    my $lb_sel_change = sub {
        my $sel = ($listbox->get_active_value)[0];
        return unless defined $sel ; # may happen with empty node
        my $help = $node->get_help_as_text($sel) ;
        $help = "no help for $sel" unless $help ;
        $helpw->text($help)  ;
        my $type = $node->element_type($sel) ;
        my $elt = $node->fetch_element($sel) ;
        my $v_str = '' ;



( run in 0.761 second using v1.01-cache-2.11-cpan-39bf76dae61 )