mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-26 06:46:45 -04:00
url-mode: support for custom prefix
Allow for the protocol configuration to be: prefix:some_string The url-mode then matches anything starting with this 'some_prefix' prefix. This, combined with a custom launch command able to handle these "URL" allow for opening application specific references (e.g. gitlab short references). Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
This commit is contained in:
parent
4a73828911
commit
eaaf1ad3a4
1 changed files with 17 additions and 4 deletions
21
config.c
21
config.c
|
|
@ -1159,11 +1159,24 @@ parse_section_url(struct context *ctx)
|
||||||
conf->url.prot_count * sizeof(conf->url.protocols[0]));
|
conf->url.prot_count * sizeof(conf->url.protocols[0]));
|
||||||
|
|
||||||
size_t idx = conf->url.prot_count - 1;
|
size_t idx = conf->url.prot_count - 1;
|
||||||
conf->url.protocols[idx] = xmalloc((chars + 1 + 3) * sizeof(char32_t));
|
bool is_custom_prefix = str_has_prefix(prot, "prefix:");
|
||||||
mbsntoc32(conf->url.protocols[idx], prot, len, chars + 1);
|
size_t prot_suffix_len = 3; // the '://'
|
||||||
c32cpy(&conf->url.protocols[idx][chars], U"://");
|
if (is_custom_prefix) {
|
||||||
|
prot += 7;
|
||||||
|
len -= 7;
|
||||||
|
chars -= 7;
|
||||||
|
prot_suffix_len = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
conf->url.protocols[idx] = xmalloc((chars + 1 + prot_suffix_len) * sizeof(char32_t));
|
||||||
|
mbsntoc32(conf->url.protocols[idx], prot, len, chars + 1);
|
||||||
|
if (!is_custom_prefix) {
|
||||||
|
c32cpy(&conf->url.protocols[idx][chars], U"://");
|
||||||
|
} else {
|
||||||
|
c32cpy(&conf->url.protocols[idx][chars], U"");
|
||||||
|
}
|
||||||
|
chars += prot_suffix_len;
|
||||||
|
|
||||||
chars += 3; /* Include the "://" */
|
|
||||||
if (chars > conf->url.max_prot_len)
|
if (chars > conf->url.max_prot_len)
|
||||||
conf->url.max_prot_len = chars;
|
conf->url.max_prot_len = chars;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue