This file is indexed.

/usr/share/perl5/Lire/UI/IntegerWidget.pm is in lire 2:2.1.1-2.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
package Lire::UI::IntegerWidget;

use strict;

use base qw/ Curses::UI::Container Lire::UI::Widget /;

use Curses::UI::Common;
use Curses;

use Carp;
use vars qw/@CARP_NOT/;
use Lire::Utils qw/ check_object_param /;

@CARP_NOT = qw/Curses::UI::Container/;

my %routines = ( 'increase' => \&increase,
                 'decrease' => \&decrease );

sub new {
    my $class = shift;
    my %userargs = @_;
    keys_to_lowercase(\%userargs);

    check_object_param( $userargs{'value'}, 'value',
                        'Lire::Config::Scalar' );

    my $self =  $class->Curses::UI::Container::new( %userargs,
                                                    '-height' => 1,
                                                    '-routines' => \%routines,
                                                    '-releasefocus' => 1,
                                                    '-border' => 0 );
    $self->set_binding( sub { $self->do_routine( 'decrease' ) },
                        '-', KEY_LEFT() );
    $self->set_binding( sub { $self->do_routine( 'increase' ) },
                        '+', KEY_RIGHT() );
    $self->set_binding( sub { $self->do_routine( 'decrease', 10 ) },
                        KEY_DOWN() );
    $self->set_binding( sub { $self->do_routine( 'increase', 10 ) },
                        KEY_UP() );

    $self->add( 'text_entry', 'TextEntry',
                '-sbborder' => 1,
                '-height' => 1,
                '-text' => $userargs{'value'}->get(),
                '-regexp' => '/^[0-9]*$/',
                '-onchange' => \&_on_change_cb );

    $self->add( 'buttons', 'Buttonbox',
                '-width' => 7,
                '-buttons' =>
                [ { '-label' => '[<]',
                    '-onpress' => sub { $self->do_routine( 'decrease' ) },
                  },
                  { '-label' => '[>]',
                    '-onpress' => sub { $self->do_routine( 'increase' ) },
                  }
                ] );

    $self->layout();

    return $self;
}

sub layout {
    my $self = $_[0];

    $self->{'-height'} = 1;

    return $self->SUPER::layout();
}

sub layout_contained_objects {
    my $self = $_[0];

    return $self unless $self->getobj( 'text_entry' );

    my $width = $self->canvaswidth();
    my $entry = $self->getobj( 'text_entry' );
    my $box = $self->getobj( 'buttons' );
    if ( $width < 18 ) {
        $box->hide();
        $entry->{'-width'} = $width;
    } else {
        $box->show();
        $entry->{'-width'} = $width - 8;
        $box->{'-x'} = $entry->{'-width'} + 1;
    }

    return $self->SUPER::layout_contained_objects();
}

sub refresh_view {
    my $self = $_[0];

    my $text_entry = $self->getobj( 'text_entry' );
    $text_entry->text( $self->{'value'}->get() );

    return;
}

# Routines
sub decrease {
    my ( $self, $offset ) = @_;

    $offset ||= 1;
    my $value = $self->{'value'}->get() || 0;
    $self->{'value'}->set( $value - $offset );
    $self->refresh_view();

    return;
}

sub increase {
    my ( $self, $offset ) = @_;

    $offset ||= 1;

    my $value = $self->{'value'}->get() || 0;
    $self->{'value'}->set( $value + $offset );
    $self->refresh_view();

    return;
}

# callbacks
sub _on_change_cb {
    my $text_entry = $_[0];

    my $self = $text_entry->parent();
    $self->{'value'}->set( $text_entry->{'-text'} );
    $self->run_event( 'onvaluechanged' );

    return;
}

1;