… | |
… | |
8 | |
8 | |
9 | my $cmd = "\x1b[H"; |
9 | my $cmd = "\x1b[H"; |
10 | |
10 | |
11 | my $row = 1; |
11 | my $row = 1; |
12 | for my $item (@{ $self->{data}{item} }) { |
12 | for my $item (@{ $self->{data}{item} }) { |
13 | my $rend = "\x1b[30;47m"; |
13 | my $rend = "normal"; |
14 | |
14 | |
15 | if ($row == $self->{hover}) { |
15 | if ($row == $self->{hover}) { |
16 | $rend = $self->{press} ? "\x1b[m" : "\x1b[30;46m"; |
16 | $rend = $self->{press} ? "active" : "hover"; |
17 | } |
17 | } |
18 | |
18 | |
19 | $cmd .= "$rend\x1b[K"; |
19 | $cmd .= "$item->{rend}{$rend}\x1b[K"; |
20 | $cmd .= $self->locale_encode ($item->{render}->($item)); |
20 | $cmd .= $self->locale_encode ($item->{render}->($item)); |
21 | $cmd .= "\015\012"; |
21 | $cmd .= "\015\012"; |
22 | |
22 | |
23 | $row++; |
23 | $row++; |
24 | } |
24 | } |
… | |
… | |
61 | $self->{press}[$event->{button}] = 0; |
61 | $self->{press}[$event->{button}] = 0; |
62 | |
62 | |
63 | my ($row, $col) = ($event->{row}, $event->{col}); |
63 | my ($row, $col) = ($event->{row}, $event->{col}); |
64 | if ($col >= 0 && $col < $self->ncol |
64 | if ($col >= 0 && $col < $self->ncol |
65 | && $row >= 0 && $row < @{ $self->{data}{item} }) { |
65 | && $row >= 0 && $row < @{ $self->{data}{item} }) { |
66 | $self->{data}{item}[$row]{activate}->($event); |
66 | my $item = $self->{data}{item}[$row]; |
|
|
67 | $item->{activate}->($event, $item); |
67 | } |
68 | } |
68 | |
69 | |
69 | $self->refresh; |
70 | $self->refresh; |
70 | |
71 | |
71 | 1 |
72 | 1 |
… | |
… | |
97 | my $pos = ""; |
98 | my $pos = ""; |
98 | |
99 | |
99 | if ($data->{event}) { |
100 | if ($data->{event}) { |
100 | my $x = int List::Util::max 0, $data->{event}{x_root} - $width * $data->{term}->fwidth * 0.5; |
101 | my $x = int List::Util::max 0, $data->{event}{x_root} - $width * $data->{term}->fwidth * 0.5; |
101 | my $y = int List::Util::max 0, $data->{event}{y_root} - $data->{term}->fheight * 0.5; |
102 | my $y = int List::Util::max 0, $data->{event}{y_root} - $data->{term}->fheight * 0.5; |
102 | |
|
|
103 | $pos = "+$x+$y"; |
103 | $pos = "+$x+$y"; |
104 | } |
104 | } |
105 | |
105 | |
106 | $self->resource (geometry => "${width}x${height}$pos"); |
106 | $self->resource (geometry => "${width}x${height}$pos"); |
107 | |
107 | |
… | |
… | |
109 | } |
109 | } |
110 | |
110 | |
111 | sub on_start { |
111 | sub on_start { |
112 | my ($self) = @_; |
112 | my ($self) = @_; |
113 | |
113 | |
|
|
114 | $self->cmd_parse ("\x1b[?25l\x1b[?7l"); |
|
|
115 | $self->refresh; |
|
|
116 | |
114 | # might fail, but try anyways |
117 | # might fail, but try anyways |
115 | $self->grab ($self->{data}{event}{time}, 1) |
118 | $self->grab ($self->{data}{event}{time}, 1) |
116 | and $self->allow_events_async; |
119 | and $self->allow_events_async; |
117 | |
120 | |
118 | on_button_press $self, $self->{data}{event} if $self->{data}{event}{button}; |
121 | on_button_press $self, $self->{data}{event} if $self->{data}{event}{button}; |
119 | |
|
|
120 | $self->cmd_parse ("\x1b[?25l\x1b[?7l"); |
|
|
121 | refresh $self; |
|
|
122 | |
122 | |
123 | () |
123 | () |
124 | } |
124 | } |
125 | |
125 | |
126 | sub on_map_notify { |
126 | sub on_map_notify { |
… | |
… | |
130 | $self->grab ($self->{data}{event}{time}, 1) |
130 | $self->grab ($self->{data}{event}{time}, 1) |
131 | and $self->allow_events_async; |
131 | and $self->allow_events_async; |
132 | } |
132 | } |
133 | |
133 | |
134 | |
134 | |
135 | |
|
|
136 | |
|
|
137 | |
|
|
138 | |
|
|