url-select: catch button presses, fixes issue #54
This commit is contained in:
parent
4dec629b36
commit
e68375c3d4
34
url-select
34
url-select
@ -167,9 +167,25 @@ sub on_button_press {
|
|||||||
urxvt::ShiftMask | urxvt::ControlMask;
|
urxvt::ShiftMask | urxvt::ControlMask;
|
||||||
|
|
||||||
if ($event->{button} == $self->{button} && ($event->{state} & $mask) == $self->{state}) {
|
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_pressed} = 1;
|
||||||
$self->{button_col} = $event->{col};
|
$self->{button_col} = $col;
|
||||||
$self->{button_row} = $event->{row};
|
$self->{button_row} = $row;
|
||||||
|
$self->{button_url} = $url;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
()
|
()
|
||||||
@ -185,22 +201,10 @@ sub on_button_release {
|
|||||||
$self->{button_pressed} = 0;
|
$self->{button_pressed} = 0;
|
||||||
|
|
||||||
if ($col == $self->{button_col} && $row == $self->{button_row}) {
|
if ($col == $self->{button_col} && $row == $self->{button_row}) {
|
||||||
my $line = $self->line($row);
|
$self->exec_async(@{$self->{browser}}, $self->{button_url});
|
||||||
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);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
()
|
()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user