config+url: add support for user-defined regex patterns

Users can now define their own regex patterns, and use them via key
bindings:

    [regex:foo]
    regex=foo(bar)?
    launch=path-to-script-or-application {match}

    [key-bindings]
    regex-launch=[foo] Control+Shift+q
    regex-copy=[foo] Control+Mod1+Shift+q

That is, add a section called 'regex:', followed by an
identifier. Define a regex and a launcher command line.

Add a key-binding, regex-launch and/or regex-copy (similar to
show-urls-launch and show-urls-copy), and connect them to the regex
with the "[regex-name]" syntax (similar to how the pipe-* bindings
work).
This commit is contained in:
Daniel Eklöf 2025-02-03 08:55:47 +01:00
parent f718cb3fb0
commit 051cd6ecfc
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
8 changed files with 310 additions and 48 deletions

View file

@ -61,6 +61,7 @@ enum binding_aux_type {
BINDING_AUX_NONE,
BINDING_AUX_PIPE,
BINDING_AUX_TEXT,
BINDING_AUX_REGEX,
};
struct binding_aux {
@ -74,6 +75,8 @@ struct binding_aux {
uint8_t *data;
size_t len;
} text;
char *regex_name;
};
};
@ -121,6 +124,13 @@ struct env_var {
};
typedef tll(struct env_var) env_var_list_t;
struct custom_regex {
char *name;
char *regex;
regex_t preg;
struct config_spawn_template launch;
};
struct config {
char *term;
char *shell;
@ -225,6 +235,8 @@ struct config {
regex_t preg;
} url;
tll(struct custom_regex) custom_regexes;
struct {
uint32_t fg;
uint32_t bg;