line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TiddlyWeb::Wikrad::Listbox; |
2
|
1
|
|
|
1
|
|
1208
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
4
|
1
|
|
|
1
|
|
5
|
use base 'Curses::UI::Listbox'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
642
|
|
5
|
|
|
|
|
|
|
use Curses qw/KEY_ENTER/; |
6
|
|
|
|
|
|
|
use TiddlyWeb::Wikrad qw/$App/; # XXX cyclic? |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
|
|
|
|
|
|
my $class = shift; |
10
|
|
|
|
|
|
|
my %args = ( |
11
|
|
|
|
|
|
|
-border => 1, |
12
|
|
|
|
|
|
|
-wraparound => 1, |
13
|
|
|
|
|
|
|
-x => 5, |
14
|
|
|
|
|
|
|
-y => 2, |
15
|
|
|
|
|
|
|
-width => 50, |
16
|
|
|
|
|
|
|
@_, |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
die 'must be a title' unless $args{-title}; |
19
|
|
|
|
|
|
|
die 'must be values' unless $args{-values}; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $cb = delete $args{change_cb}; |
22
|
|
|
|
|
|
|
$args{-onchange} = sub { |
23
|
|
|
|
|
|
|
my $w = shift; |
24
|
|
|
|
|
|
|
my $link = $w->get; |
25
|
|
|
|
|
|
|
$App->{win}->delete('listbox'); |
26
|
|
|
|
|
|
|
$App->{win}->draw; |
27
|
|
|
|
|
|
|
$cb->($link) if $cb; |
28
|
|
|
|
|
|
|
}; |
29
|
|
|
|
|
|
|
my $self = $class->SUPER::new(%args); |
30
|
|
|
|
|
|
|
$self->set_binding( sub { |
31
|
|
|
|
|
|
|
$App->{win}->delete('listbox'); |
32
|
|
|
|
|
|
|
$App->{win}->draw; |
33
|
|
|
|
|
|
|
}, 'q' ); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
return $self; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |