1 | #! perl |
1 | #! perl |
|
|
2 | |
|
|
3 | # this extension implements popup-menu functionality for urxvt. it works |
|
|
4 | # together with the urxvt::popup class. |
2 | |
5 | |
3 | use List::Util; |
6 | use List::Util; |
4 | |
7 | |
5 | sub refresh { |
8 | sub refresh { |
6 | my ($self) = @_; |
9 | my ($self) = @_; |
… | |
… | |
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 | |
|
|
58 | $self->{press}[$event->{button}] = 0; |
|
|
59 | |
55 | if ($event->{button} == 1) { |
60 | if ($event->{button} == 1) { |
56 | $self->{press}[$event->{button}] = 0; |
|
|
57 | refresh $self; |
61 | refresh $self; |
58 | |
62 | |
59 | warn "$event->{row} $event->{col}\n";#d# |
63 | warn "$event->{row} $event->{col}\n";#d# |
60 | |
64 | |
61 | if ($col >= 0 && $col < $self->ncol |
65 | if ($col >= 0 && $col < $self->ncol |
… | |
… | |
108 | sub on_start { |
112 | sub on_start { |
109 | my ($self) = @_; |
113 | my ($self) = @_; |
110 | |
114 | |
111 | # might fail, but try anyways |
115 | # might fail, but try anyways |
112 | $self->grab ($self->{data}{event}{time}, 1) |
116 | $self->grab ($self->{data}{event}{time}, 1) |
113 | and $self->allow_events_sync; |
117 | and $self->allow_events_async; |
114 | |
118 | |
115 | on_button_press $self, $self->{data}{event} if $self->{data}{event}{button}; |
119 | on_button_press $self, $self->{data}{event} if $self->{data}{event}{button}; |
116 | |
120 | |
117 | $self->cmd_parse ("\x1b[?25l\x1b[?7l"); |
121 | $self->cmd_parse ("\x1b[?25l\x1b[?7l"); |
118 | refresh $self; |
122 | refresh $self; |
… | |
… | |
123 | sub on_map_notify { |
127 | sub on_map_notify { |
124 | my ($self, $event) = @_; |
128 | my ($self, $event) = @_; |
125 | |
129 | |
126 | # should definitely not fail |
130 | # should definitely not fail |
127 | $self->grab ($self->{data}{event}{time}, 1) |
131 | $self->grab ($self->{data}{event}{time}, 1) |
128 | and $self->allow_events_sync; |
132 | and $self->allow_events_async; |
129 | } |
|
|
130 | |
|
|
131 | sub on_destroy { |
|
|
132 | } |
133 | } |
133 | |
134 | |
134 | |
135 | |
135 | |
136 | |
136 | |
137 | |
137 | |
138 | |
|
|
139 | |