From c4a78207dc0894af21809cb3c848eeda1bb73e58 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 7 Jan 2006 21:43:17 +0000 Subject: [PATCH] *** empty log message *** --- src/perl/urxvt-popup | 4 +++- src/urxvt.pm | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/perl/urxvt-popup b/src/perl/urxvt-popup index cd902fdb..8a385bfd 100644 --- a/src/perl/urxvt-popup +++ b/src/perl/urxvt-popup @@ -18,7 +18,9 @@ sub refresh { $rend = $self->{press} ? "\x1b[m" : "\x1b[30;46m"; } - $cmd .= "$rend\x1b[K" . $self->locale_encode ($item->{text}) . "\015\012"; + $cmd .= "$rend\x1b[K"; + $cmd .= $self->locale_encode ($item->{render}->($item)); + $cmd .= "\015\012"; $row++; } diff --git a/src/urxvt.pm b/src/urxvt.pm index 36ed839a..bf22500b 100644 --- a/src/urxvt.pm +++ b/src/urxvt.pm @@ -399,8 +399,10 @@ Change the custom value. package urxvt; +use utf8; use strict; use Scalar::Util (); +use List::Util (); our $TERM; our @HOOKNAME; @@ -1002,7 +1004,18 @@ sub add_item { sub add_button { my ($self, $text, $cb) = @_; - $self->add_item ({ type => "button", text => "[ $text ]", activate => $cb }); + $self->add_item ({ type => "button", text => "[ $text ]", activate => $cb, + render => sub { $_[0]{text} }, + }); +} + +sub add_toggle { + my ($self, $text, $cb, $value) = @_; + + $self->add_item ({ type => "button", text => " $text", value => $value, + render => sub { ($_[0]{value} ? "✔" : " ") . substr $_[0]{text}, 1 }, + activate => sub { $cb->($_[0]{value} = !$_[0]{value}); }, + }); } sub show { -- 2.34.1