url-select: catch button presses, fixes issue #54

This commit is contained in:
Bert Münnich 2014-11-05 22:13:23 +01:00
parent 4dec629b36
commit e68375c3d4

View File

@ -167,9 +167,25 @@ sub on_button_press {
urxvt::ShiftMask | urxvt::ControlMask;
if ($event->{button} == $self->{button} && ($event->{state} & $mask) == $self->{state}) {
my $col = $event->{col};
my $row = $event->{row};
my $line = $self->line($row);
my $text = $line->t;
for my $pattern (@{$self->{pattern}}) {
while ($text =~ /$pattern/g) {
my ($url, $beg, $end) = ($&, $-[0], $+[0]);
--$end if $url =~ s/["')]$//;
if ($col >= $beg && $col <= $end) {
$self->{button_pressed} = 1;
$self->{button_col} = $event->{col};
$self->{button_row} = $event->{row};
$self->{button_col} = $col;
$self->{button_row} = $row;
$self->{button_url} = $url;
return 1;
}
}
}
}
()
@ -185,22 +201,10 @@ sub on_button_release {
$self->{button_pressed} = 0;
if ($col == $self->{button_col} && $row == $self->{button_row}) {
my $line = $self->line($row);
my $text = $line->t;
for my $pattern (@{$self->{pattern}}) {
while ($text =~ /$pattern/g) {
my ($url, $beg, $end) = ($&, $-[0], $+[0]);
--$end if $url =~ s/["')]$//;
if ($col >= $beg && $col <= $end) {
$self->exec_async(@{$self->{browser}}, $url);
$self->exec_async(@{$self->{browser}}, $self->{button_url});
return 1;
}
}
}
}
}
()
}