mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-04 07:15:29 -04:00
config: mouse bindings: add support for click count
Specified by appending "-X", where X is a number.
This commit is contained in:
parent
593cad3680
commit
d74e583089
1 changed files with 26 additions and 2 deletions
28
config.c
28
config.c
|
|
@ -1007,17 +1007,41 @@ parse_mouse_combos(struct config *conf, const char *combos, key_combo_list_t *ke
|
||||||
combo = strtok_r(NULL, " ", &tok_ctx))
|
combo = strtok_r(NULL, " ", &tok_ctx))
|
||||||
{
|
{
|
||||||
struct config_key_modifiers modifiers = {};
|
struct config_key_modifiers modifiers = {};
|
||||||
const char *key = strrchr(combo, '+');
|
char *key = strrchr(combo, '+');
|
||||||
|
|
||||||
if (key == NULL) {
|
if (key == NULL) {
|
||||||
/* No modifiers */
|
/* No modifiers */
|
||||||
key = combo;
|
key = combo;
|
||||||
} else {
|
} else {
|
||||||
|
*key = '\0';
|
||||||
if (!parse_modifiers(conf, combo, key - combo, &modifiers, path, lineno))
|
if (!parse_modifiers(conf, combo, key - combo, &modifiers, path, lineno))
|
||||||
goto err;
|
goto err;
|
||||||
key++; /* Skip past the '+' */
|
key++; /* Skip past the '+' */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t count = 0;
|
||||||
|
{
|
||||||
|
char *_count = strrchr(key, '-');
|
||||||
|
if (_count != NULL) {
|
||||||
|
*_count = '\0';
|
||||||
|
_count++;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
char *end;
|
||||||
|
unsigned long value = strtoul(_count, &end, 10);
|
||||||
|
if (_count[0] == '\0' || *end != '\0' || errno != 0) {
|
||||||
|
if (errno != 0)
|
||||||
|
LOG_AND_NOTIFY_ERRNO(
|
||||||
|
"%s:%d: %s: invalid click count", path, lineno, _count);
|
||||||
|
else
|
||||||
|
LOG_AND_NOTIFY_ERR(
|
||||||
|
"%s:%d: %s: invalid click count", path, lineno, _count);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
count = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static const struct {
|
static const struct {
|
||||||
const char *name;
|
const char *name;
|
||||||
int code;
|
int code;
|
||||||
|
|
@ -1050,7 +1074,7 @@ parse_mouse_combos(struct config *conf, const char *combos, key_combo_list_t *ke
|
||||||
.modifiers = modifiers,
|
.modifiers = modifiers,
|
||||||
.m = {
|
.m = {
|
||||||
.button = button,
|
.button = button,
|
||||||
.count = 1,
|
.count = count,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
tll_push_back(*key_combos, new);
|
tll_push_back(*key_combos, new);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue