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.1 by root, Sat Jan 7 20:23:53 2006 UTC vs.
Revision 1.7 by root, Sun Jan 8 00:29:38 2006 UTC

1#! perl 1#! perl
2 2
3use List::Util; 3# this extension implements popup-menu functionality for urxvt. it works
4# together with the urxvt::popup class.
4 5
5sub refresh { 6sub refresh {
6 my ($self) = @_; 7 my ($self) = @_;
7 8
8 my $cmd = "\x1b[H"; 9 my $cmd = "\x1b[H";
13 14
14 if ($row == $self->{hover}) { 15 if ($row == $self->{hover}) {
15 $rend = $self->{press} ? "\x1b[m" : "\x1b[30;46m"; 16 $rend = $self->{press} ? "\x1b[m" : "\x1b[30;46m";
16 } 17 }
17 18
18 $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";
19 22
20 $row++; 23 $row++;
21 } 24 }
22 25
23 $self->cmd_parse (substr $cmd, 0, -2); 26 $self->cmd_parse (substr $cmd, 0, -2);
50 if ($event->{button} == $self->{data}{event}{button}) { 53 if ($event->{button} == $self->{data}{event}{button}) {
51 $self->ungrab; 54 $self->ungrab;
52 $self->destroy; 55 $self->destroy;
53 } 56 }
54 57
55 if ($event->{button} == 1) {
56 $self->{press}[$event->{button}] = 0; 58 $self->{press}[$event->{button}] = 0;
57 refresh $self;
58 59
59 warn "$event->{row} $event->{col}\n";#d# 60 refresh $self;
60 61
61 if ($col >= 0 && $col < $self->ncol 62 if ($col >= 0 && $col < $self->ncol
62 && $row >= 0 && $row < @{ $self->{data}{item} }) { 63 && $row >= 0 && $row < @{ $self->{data}{item} }) {
63 $self->{data}{item}[$row]{activate}->($event); 64 $self->{data}{item}[$row]{activate}->($event);
64 print "ok\n";
65 }
66 } 65 }
67 66
68 1 67 1
69} 68}
70 69
108sub on_start { 107sub on_start {
109 my ($self) = @_; 108 my ($self) = @_;
110 109
111 # might fail, but try anyways 110 # might fail, but try anyways
112 $self->grab ($self->{data}{event}{time}, 1) 111 $self->grab ($self->{data}{event}{time}, 1)
113 and $self->allow_events_sync; 112 and $self->allow_events_async;
114 113
115 on_button_press $self, $self->{data}{event} if $self->{data}{event}{button}; 114 on_button_press $self, $self->{data}{event} if $self->{data}{event}{button};
116 115
117 $self->cmd_parse ("\x1b[?25l\x1b[?7l"); 116 $self->cmd_parse ("\x1b[?25l\x1b[?7l");
118 refresh $self; 117 refresh $self;
123sub on_map_notify { 122sub on_map_notify {
124 my ($self, $event) = @_; 123 my ($self, $event) = @_;
125 124
126 # should definitely not fail 125 # should definitely not fail
127 $self->grab ($self->{data}{event}{time}, 1) 126 $self->grab ($self->{data}{event}{time}, 1)
128 and $self->allow_events_sync; 127 and $self->allow_events_async;
129}
130
131sub on_destroy {
132} 128}
133 129
134 130
135 131
136 132
137 133
134

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines