ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/perl/urxvt-popup
(Generate patch)

Comparing rxvt-unicode/src/perl/urxvt-popup (file contents):
Revision 1.3 by root, Sat Jan 7 20:50:43 2006 UTC vs.
Revision 1.8 by root, Sun Jan 8 00:34:57 2006 UTC

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
6use List::Util;
7 5
8sub refresh { 6sub 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);
28 28
29sub on_motion_notify { 29sub on_motion_notify {
30 my ($self, $event) = @_; 30 my ($self, $event) = @_;
31 31
32 $self->{hover} = $event->{row} + 1; 32 $self->{hover} = $event->{row} + 1;
33 refresh $self; 33 $self->refresh;
34 34
35 1 35 1
36} 36}
37 37
38sub on_button_press { 38sub on_button_press {
39 my ($self, $event) = @_; 39 my ($self, $event) = @_;
40 40
41 $self->{press}[$event->{button}] = 1; 41 $self->{press}[$event->{button}] = 1;
42 refresh $self; 42 $self->refresh;
43 43
44 1 44 1
45} 45}
46 46
47sub on_button_release { 47sub on_button_release {
55 $self->destroy; 55 $self->destroy;
56 } 56 }
57 57
58 $self->{press}[$event->{button}] = 0; 58 $self->{press}[$event->{button}] = 0;
59 59
60 if ($event->{button} == 1) { 60 if ($col >= 0 && $col < $self->ncol
61 refresh $self; 61 && $row >= 0 && $row < @{ $self->{data}{item} }) {
62 $self->{data}{item}[$row]{activate}->($event);
63 }
62 64
63 warn "$event->{row} $event->{col}\n";#d# 65 $self->refresh;
64
65 if ($col >= 0 && $col < $self->ncol
66 && $row >= 0 && $row < @{ $self->{data}{item} }) {
67 $self->{data}{item}[$row]{activate}->($event);
68 print "ok\n";
69 }
70 }
71 66
72 1 67 1
73} 68}
74 69
75sub on_focus_out { 70sub on_focus_out {
76 my ($self) = @_; 71 my ($self) = @_;
77 72
78 delete $self->{hover}; 73 delete $self->{hover};
79 refresh $self; 74 $self->refresh;
80 75
81 () 76 ()
82} 77}
83 78
84sub on_init { 79sub on_init {
130 # should definitely not fail 125 # should definitely not fail
131 $self->grab ($self->{data}{event}{time}, 1) 126 $self->grab ($self->{data}{event}{time}, 1)
132 and $self->allow_events_async; 127 and $self->allow_events_async;
133} 128}
134 129
135sub on_destroy {
136}
137 130
138 131
139 132
140 133
141 134

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines