mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-12 05:34:01 -04:00
url-mode: use the first *sub* expression as URL
When auto-matching URLs (or custom regular expressions), use the first *subexpression* as URL, rather than the while regex match. This allows us to write custom regular expressions with prefix/suffix strings that should not be included in the presented match.
This commit is contained in:
parent
31f536ff8c
commit
a984531ce5
4 changed files with 51 additions and 28 deletions
|
|
@ -400,13 +400,13 @@ regex_detected(const struct terminal *term, enum url_action action,
|
|||
if (r == REG_NOMATCH)
|
||||
break;
|
||||
|
||||
const size_t mlen = matches[0].rm_eo - matches[0].rm_so;
|
||||
const size_t start = &search_string[matches[0].rm_so] - v->utf8;
|
||||
const size_t mlen = matches[1].rm_eo - matches[1].rm_so;
|
||||
const size_t start = &search_string[matches[1].rm_so] - v->utf8;
|
||||
const size_t end = start + mlen;
|
||||
|
||||
LOG_DBG(
|
||||
"regex match at row %d: %.*srow/col = %dx%d",
|
||||
matches[0].rm_so, (int)mlen, &search_string[matches[0].rm_so],
|
||||
matches[1].rm_so, (int)mlen, &search_string[matches[1].rm_so],
|
||||
v->map[start].row, v->map[start].col);
|
||||
|
||||
tll_push_back(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue