… | |
… | |
397 | |
397 | |
398 | =cut |
398 | =cut |
399 | |
399 | |
400 | package urxvt; |
400 | package urxvt; |
401 | |
401 | |
|
|
402 | use utf8; |
402 | use strict; |
403 | use strict; |
403 | use Scalar::Util (); |
404 | use Scalar::Util (); |
|
|
405 | use List::Util (); |
404 | |
406 | |
405 | our $TERM; |
407 | our $TERM; |
406 | our @HOOKNAME; |
408 | our @HOOKNAME; |
407 | our $LIBDIR; |
409 | our $LIBDIR; |
408 | |
410 | |
… | |
… | |
1000 | } |
1002 | } |
1001 | |
1003 | |
1002 | sub add_button { |
1004 | sub add_button { |
1003 | my ($self, $text, $cb) = @_; |
1005 | my ($self, $text, $cb) = @_; |
1004 | |
1006 | |
1005 | $self->add_item ({ type => "button", text => "[ $text ]", activate => $cb }); |
1007 | $self->add_item ({ type => "button", text => "[ $text ]", activate => $cb, |
|
|
1008 | render => sub { $_[0]{text} }, |
|
|
1009 | }); |
|
|
1010 | } |
|
|
1011 | |
|
|
1012 | sub add_toggle { |
|
|
1013 | my ($self, $text, $cb, $value) = @_; |
|
|
1014 | |
|
|
1015 | $self->add_item ({ type => "button", text => " $text", value => $value, |
|
|
1016 | render => sub { ($_[0]{value} ? "✔" : " ") . substr $_[0]{text}, 1 }, |
|
|
1017 | activate => sub { $cb->($_[0]{value} = !$_[0]{value}); }, |
|
|
1018 | }); |
1006 | } |
1019 | } |
1007 | |
1020 | |
1008 | sub show { |
1021 | sub show { |
1009 | my ($self) = @_; |
1022 | my ($self) = @_; |
1010 | |
1023 | |