1 | #! perl |
1 | #! perl |
2 | |
2 | |
3 | # this extension implements popup-menu functionality for urxvt. it works |
3 | # this extension implements popup-menu functionality for urxvt. it works |
4 | # together with the urxvt::popup class. |
4 | # together with the urxvt::popup class. |
5 | |
|
|
6 | use List::Util; |
|
|
7 | |
5 | |
8 | sub refresh { |
6 | sub refresh { |
9 | my ($self) = @_; |
7 | my ($self) = @_; |
10 | |
8 | |
11 | my $cmd = "\x1b[H"; |
9 | my $cmd = "\x1b[H"; |
… | |
… | |
16 | |
14 | |
17 | if ($row == $self->{hover}) { |
15 | if ($row == $self->{hover}) { |
18 | $rend = $self->{press} ? "\x1b[m" : "\x1b[30;46m"; |
16 | $rend = $self->{press} ? "\x1b[m" : "\x1b[30;46m"; |
19 | } |
17 | } |
20 | |
18 | |
21 | $cmd .= "$rend\x1b[K" . $self->locale_encode ($item->{text}) . "\015\012"; |
19 | $cmd .= "$rend\x1b[K"; |
|
|
20 | $cmd .= $self->locale_encode ($item->{render}->($item)); |
|
|
21 | $cmd .= "\015\012"; |
22 | |
22 | |
23 | $row++; |
23 | $row++; |
24 | } |
24 | } |
25 | |
25 | |
26 | $self->cmd_parse (substr $cmd, 0, -2); |
26 | $self->cmd_parse (substr $cmd, 0, -2); |
… | |
… | |
130 | # should definitely not fail |
130 | # should definitely not fail |
131 | $self->grab ($self->{data}{event}{time}, 1) |
131 | $self->grab ($self->{data}{event}{time}, 1) |
132 | and $self->allow_events_async; |
132 | and $self->allow_events_async; |
133 | } |
133 | } |
134 | |
134 | |
135 | sub on_destroy { |
|
|
136 | } |
|
|
137 | |
135 | |
138 | |
136 | |
139 | |
137 | |
140 | |
138 | |
141 | |
139 | |