mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-03 01:40:17 -05:00
config: ignore “self” when detecting key binding collisions
Previously, foot would not accept the following: [key-bindings] minimize=Escape minimize=Escape Now it does. I.e. key combos in the action being updated are ignored when detecting collisions. The example above is contrived; a real world example could be to remove certain combos from an action with multiple combos; perhaps to free up a combo for another action. Example: [search-bindings] cancel=Escape This would previously cause an error since `cancel=Control+g Escape` by default. Closes #233
This commit is contained in:
parent
a58557af30
commit
5e46672cf4
2 changed files with 17 additions and 4 deletions
|
|
@ -96,6 +96,11 @@ means foot can be PGO:d in e.g. sandboxed build scripts. See
|
||||||
### Deprecated
|
### Deprecated
|
||||||
### Removed
|
### Removed
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
* Error when re-assigning a default key binding
|
||||||
|
(https://codeberg.org/dnkl/foot/issues/233).
|
||||||
|
|
||||||
|
|
||||||
### Security
|
### Security
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
16
config.c
16
config.c
|
|
@ -1024,10 +1024,14 @@ err:
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
has_key_binding_collisions(struct config *conf, const key_combo_list_t *key_combos,
|
has_key_binding_collisions(struct config *conf, enum bind_action_normal action,
|
||||||
|
const key_combo_list_t *key_combos,
|
||||||
const char *path, unsigned lineno)
|
const char *path, unsigned lineno)
|
||||||
{
|
{
|
||||||
tll_foreach(conf->bindings.key, it) {
|
tll_foreach(conf->bindings.key, it) {
|
||||||
|
if (it->item.action == action)
|
||||||
|
continue;
|
||||||
|
|
||||||
tll_foreach(*key_combos, it2) {
|
tll_foreach(*key_combos, it2) {
|
||||||
const struct config_key_modifiers *mods1 = &it->item.modifiers;
|
const struct config_key_modifiers *mods1 = &it->item.modifiers;
|
||||||
const struct config_key_modifiers *mods2 = &it2->item.modifiers;
|
const struct config_key_modifiers *mods2 = &it2->item.modifiers;
|
||||||
|
|
@ -1055,10 +1059,14 @@ has_key_binding_collisions(struct config *conf, const key_combo_list_t *key_comb
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
has_search_binding_collisions(struct config *conf, const key_combo_list_t *key_combos,
|
has_search_binding_collisions(struct config *conf, enum bind_action_search action,
|
||||||
|
const key_combo_list_t *key_combos,
|
||||||
const char *path, unsigned lineno)
|
const char *path, unsigned lineno)
|
||||||
{
|
{
|
||||||
tll_foreach(conf->bindings.search, it) {
|
tll_foreach(conf->bindings.search, it) {
|
||||||
|
if (it->item.action == action)
|
||||||
|
continue;
|
||||||
|
|
||||||
tll_foreach(*key_combos, it2) {
|
tll_foreach(*key_combos, it2) {
|
||||||
const struct config_key_modifiers *mods1 = &it->item.modifiers;
|
const struct config_key_modifiers *mods1 = &it->item.modifiers;
|
||||||
const struct config_key_modifiers *mods2 = &it2->item.modifiers;
|
const struct config_key_modifiers *mods2 = &it2->item.modifiers;
|
||||||
|
|
@ -1245,7 +1253,7 @@ parse_section_key_bindings(
|
||||||
|
|
||||||
key_combo_list_t key_combos = tll_init();
|
key_combo_list_t key_combos = tll_init();
|
||||||
if (!parse_key_combos(conf, value, &key_combos, path, lineno) ||
|
if (!parse_key_combos(conf, value, &key_combos, path, lineno) ||
|
||||||
has_key_binding_collisions(conf, &key_combos, path, lineno))
|
has_key_binding_collisions(conf, action, &key_combos, path, lineno))
|
||||||
{
|
{
|
||||||
free(pipe_argv);
|
free(pipe_argv);
|
||||||
free(pipe_cmd);
|
free(pipe_cmd);
|
||||||
|
|
@ -1325,7 +1333,7 @@ parse_section_search_bindings(
|
||||||
|
|
||||||
key_combo_list_t key_combos = tll_init();
|
key_combo_list_t key_combos = tll_init();
|
||||||
if (!parse_key_combos(conf, value, &key_combos, path, lineno) ||
|
if (!parse_key_combos(conf, value, &key_combos, path, lineno) ||
|
||||||
has_search_binding_collisions(conf, &key_combos, path, lineno))
|
has_search_binding_collisions(conf, action, &key_combos, path, lineno))
|
||||||
{
|
{
|
||||||
free_key_combo_list(&key_combos);
|
free_key_combo_list(&key_combos);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue