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.12 by root, Sun Jan 8 22:58:13 2006 UTC vs.
Revision 1.16 by root, Sun Jun 10 17:31:53 2012 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 - "no user servicable parts inside".
5 5
6sub refresh { 6sub refresh {
7 my ($self) = @_; 7 my ($self) = @_;
8 8
9 my $cmd = "\x1b[H"; 9 my $cmd = "\x1b[H";
51} 51}
52 52
53sub on_button_release { 53sub on_button_release {
54 my ($self, $event) = @_; 54 my ($self, $event) = @_;
55 55
56 if ($event->{button} == $self->{data}{event}{button}) {
57 $self->ungrab;
58 $self->destroy;
59 }
60
61 $self->{press}[$event->{button}] = 0; 56 $self->{press}[$event->{button}] = 0;
62 57
63 my ($row, $col) = ($event->{row}, $event->{col}); 58 my ($row, $col) = ($event->{row}, $event->{col});
64 if ($col >= 0 && $col < $self->ncol 59 if ($col >= 0 && $col < $self->ncol
65 && $row >= 0 && $row < @{ $self->{data}{item} }) { 60 && $row >= 0 && $row < @{ $self->{data}{item} }) {
66 my $item = $self->{data}{item}[$row]; 61 my $item = $self->{data}{item}[$row];
67 $item->{activate}->($event, $item); 62 $item->{activate}->($event, $item);
68 } 63 }
69 64
70 $self->refresh; 65 $self->refresh;
66
67 if ($event->{button} == $self->{data}{event}{button}) {
68 $self->ungrab;
69 $self->destroy;
70 }
71 71
72 1 72 1
73} 73}
74 74
75sub on_focus_out { 75sub on_focus_out {
87 my $data = $self->{data} = $urxvt::popup::self; 87 my $data = $self->{data} = $urxvt::popup::self;
88 88
89 $_->{width} = $self->strwidth ($_->{text}) 89 $_->{width} = $self->strwidth ($_->{text})
90 for @{ $data->{item} }; 90 for @{ $data->{item} };
91 91
92 $self->resource (title => "URxvt Popup Menu");
93 $self->resource (name => "URxvt.popup");
94
92 $self->resource ($_ => $data->{term}->resource ($_)) 95 $self->resource ($_ => $data->{term}->resource ($_))
93 for qw(font boldFont italicFont boldItalicFont color+0 color+1); 96 for qw(font boldFont italicFont boldItalicFont color+0 color+1);
94 97
95 my $width = List::Util::max map $_->{width}, @{ $data->{item} }; 98 my $width = List::Util::max map $_->{width}, @{ $data->{item} };
96 my $height = @{ $data->{item} }; 99 my $height = @{ $data->{item} };
102 my $y = int List::Util::max 0, $data->{event}{y_root} - $data->{term}->fheight * 0.5; 105 my $y = int List::Util::max 0, $data->{event}{y_root} - $data->{term}->fheight * 0.5;
103 $pos = "+$x+$y"; 106 $pos = "+$x+$y";
104 } 107 }
105 108
106 $self->resource (geometry => "${width}x${height}$pos"); 109 $self->resource (geometry => "${width}x${height}$pos");
110
111 $self->{term}{urxvt_popup_init_done} = 1;
107 112
108 () 113 ()
109} 114}
110 115
111sub on_start { 116sub on_start {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines