… | |
… | |
32 | () |
32 | () |
33 | } |
33 | } |
34 | |
34 | |
35 | # "find interesting things"-patterns |
35 | # "find interesting things"-patterns |
36 | my @mark_patterns = ( |
36 | my @mark_patterns = ( |
|
|
37 | # qr{ ([[:word:]]+) }x, |
|
|
38 | qr{ ([^[:space:]]+) }x, |
|
|
39 | |
37 | # common types of "parentheses" |
40 | # common types of "parentheses" |
|
|
41 | qr{ (?<![^[:space:]]) [`'] ([^`']+) [`'] (?![^[:space:]]) }x, |
38 | qr{ (?<![^[:space:]]) ‘ ([^‘’]+) ’ (?![^[:space]]) }x, |
42 | qr{ (?<![^[:space:]]) ‘ ([^‘’]+) ’ (?![^[:space:]]) }x, |
39 | qr{ (?<![^[:space:]]) ` ([^`']+) ' (?![^[:space]]) }x, |
43 | qr{ (?<![^[:space:]]) “ ([^“”]+) ” (?![^[:space:]]) }x, |
|
|
44 | qr{ (?<![^[:space:]]) “ ([^“”]+) ” (?![^[:space:]]) }x, |
|
|
45 | |
|
|
46 | qr{ (?<![^[:space:]]) (' [^[:space:]] [^']* ') }x, |
|
|
47 | qr{ (' [^']* [^[:space:]] ') (?![^[:space:]]) }x, |
40 | qr{ (?<![^[:space:]]) (" [^[:space:]] [^"]* ") }x, |
48 | qr{ (?<![^[:space:]]) (" [^[:space:]] [^"]* ") }x, |
41 | qr{ (" [^"]* [^[:space:]] ") (?![^[:space]]) }x, |
49 | qr{ (" [^"]* [^[:space:]] ") (?![^[:space:]]) }x, |
42 | qr{ \< ([^<>[:space:]]+) \> }x, |
50 | |
43 | qr{ \{ ([^{}[:space:]]+) \} }x, |
51 | qr{ \{ ([^\{\}]+) \} }x, |
44 | qr{ \[ ([^{}[:space:]]+) \] }x, |
|
|
45 | qr{ \( ([^()[:space:]]+) \) }x, |
52 | qr{ \( ([^\(\)]+) \) }x, |
|
|
53 | qr{ \[ ([^\[\]]+) \] }x, |
|
|
54 | qr{ \< ([^\<\>]+) \> }x, |
46 | |
55 | |
47 | # urls, just a heuristic |
56 | # urls, just a heuristic |
48 | qr{( |
57 | qr{( |
49 | (?:https?://|ftp://|news://|mailto:|file://)[ab-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27(),~#]+ |
58 | (?:https?://|ftp://|news://|mailto:|file://|\bwww\.)[ab-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27(),~#]+ |
50 | [ab-zA-Z0-9\-\@;\/?:&=%\$_+!*\x27()~] # exclude some trailing characters (heuristic) |
59 | [ab-zA-Z0-9\-\@;\/?:&=%\$_+*()~] # exclude some trailing characters (heuristic) |
51 | )}x, |
60 | )}x, |
52 | |
61 | |
53 | # shell-like argument quoting, basically always matches |
62 | # shell-like argument quoting, basically always matches |
54 | qr{\G [\ \t|&;<>()]* ( |
63 | qr{\G [\ \t|&;<>()]* ( |
55 | (?: |
64 | (?: |
… | |
… | |
81 | - $line->offset_of ($self->selection_beg); |
90 | - $line->offset_of ($self->selection_beg); |
82 | |
91 | |
83 | my @matches; |
92 | my @matches; |
84 | |
93 | |
85 | if ($markofs < $line->l) { |
94 | if ($markofs < $line->l) { |
86 | # convert markofs form character to UTF-8 offset space |
95 | # convert markofs from character to UTF-8 offset space |
87 | { |
96 | { |
88 | my $prefix = substr $text, 0, $markofs; |
97 | my $prefix = substr $text, 0, $markofs; |
89 | utf8::encode $prefix; |
98 | utf8::encode $prefix; |
90 | $markofs = length $prefix; |
99 | $markofs = length $prefix; |
91 | } |
100 | } |