… | |
… | |
21 | $res = $self->locale_decode ($res); |
21 | $res = $self->locale_decode ($res); |
22 | utf8::encode $res; |
22 | utf8::encode $res; |
23 | push @{ $self->{patterns} }, qr/$res/; |
23 | push @{ $self->{patterns} }, qr/$res/; |
24 | } |
24 | } |
25 | |
25 | |
|
|
26 | $self->{enabled} = 1; |
|
|
27 | |
|
|
28 | push @{ $self->{term}{option_popup_hook} }, sub { |
|
|
29 | ("new selection" => $self->{enabled}, sub { $self->{enabled} = shift }) |
|
|
30 | }; |
|
|
31 | |
26 | () |
32 | () |
27 | } |
33 | } |
28 | |
34 | |
29 | # "find interesting things"-patterns |
35 | # "find interesting things"-patterns |
30 | my @mark_patterns = ( |
36 | my @mark_patterns = ( |
… | |
… | |
38 | qr{ \[ ([^{}[:space:]]+) \] }x, |
44 | qr{ \[ ([^{}[:space:]]+) \] }x, |
39 | qr{ \( ([^()[:space:]]+) \) }x, |
45 | qr{ \( ([^()[:space:]]+) \) }x, |
40 | |
46 | |
41 | # urls, just a heuristic |
47 | # urls, just a heuristic |
42 | qr{( |
48 | qr{( |
43 | (?:https?|ftp|news|mailto|file)://[ab-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27(),~]+ |
49 | (?:https?://|ftp://|news://|mailto:|file://)[ab-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27(),~]+ |
44 | [ab-zA-Z0-9\-\@;\/?:&=%\$_+!*\x27()~] # exclude some trailing characters (heuristic) |
50 | [ab-zA-Z0-9\-\@;\/?:&=%\$_+!*\x27()~] # exclude some trailing characters (heuristic) |
45 | )}x, |
51 | )}x, |
46 | |
52 | |
47 | # shell-like argument quoting, basically always matches |
53 | # shell-like argument quoting, basically always matches |
48 | qr{\G [\ \t|&;<>()]* ( |
54 | qr{\G [\ \t|&;<>()]* ( |
… | |
… | |
61 | qr{^(.*)[,\-]$}, # strip off trailing , and - |
67 | qr{^(.*)[,\-]$}, # strip off trailing , and - |
62 | ); |
68 | ); |
63 | |
69 | |
64 | sub on_sel_extend { |
70 | sub on_sel_extend { |
65 | my ($self, $time) = @_; |
71 | my ($self, $time) = @_; |
|
|
72 | |
|
|
73 | $self->{enabled} |
|
|
74 | or return; |
66 | |
75 | |
67 | my ($row, $col) = $self->selection_mark; |
76 | my ($row, $col) = $self->selection_mark; |
68 | my $line = $self->line ($row); |
77 | my $line = $self->line ($row); |
69 | my $text = $line->t; |
78 | my $text = $line->t; |
70 | my $markofs = $line->offset_of ($row, $col); |
79 | my $markofs = $line->offset_of ($row, $col); |