mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-04 04:06:06 -05:00
search: add support for user configurable key bindings
No default bindings defined yet, though.
This commit is contained in:
parent
fcf4832775
commit
0d188895c3
5 changed files with 31 additions and 9 deletions
19
input.c
19
input.c
|
|
@ -31,9 +31,9 @@
|
|||
#include "terminal.h"
|
||||
#include "vt.h"
|
||||
|
||||
static void
|
||||
execute_binding(struct terminal *term, enum binding_action action,
|
||||
uint32_t serial)
|
||||
void
|
||||
input_execute_binding(struct terminal *term, enum binding_action action,
|
||||
uint32_t serial)
|
||||
{
|
||||
switch (action) {
|
||||
case BIND_ACTION_SCROLLBACK_UP:
|
||||
|
|
@ -196,8 +196,13 @@ keyboard_keymap(void *data, struct wl_keyboard *wl_keyboard,
|
|||
close(fd);
|
||||
|
||||
for (size_t i = 0; i < BIND_ACTION_COUNT; i++) {
|
||||
const char *combos = wayl->conf->bindings.key[i];
|
||||
parse_key_binding_for_action(wayl->kbd.xkb_keymap, i, combos, &wayl->kbd.bindings.key);
|
||||
parse_key_binding_for_action(
|
||||
wayl->kbd.xkb_keymap, i,
|
||||
wayl->conf->bindings.key[i], &wayl->kbd.bindings.key);
|
||||
|
||||
parse_key_binding_for_action(
|
||||
wayl->kbd.xkb_keymap, i,
|
||||
wayl->conf->bindings.search[i], &wayl->kbd.bindings.search);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -476,7 +481,7 @@ keyboard_key(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial,
|
|||
if (term->is_searching) {
|
||||
if (should_repeat)
|
||||
start_repeater(wayl, key - 8);
|
||||
search_input(term, key, sym, effective_mods);
|
||||
search_input(term, key, sym, effective_mods, serial);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -497,7 +502,7 @@ keyboard_key(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial,
|
|||
*/
|
||||
tll_foreach(wayl->kbd.bindings.key, it) {
|
||||
if (it->item.mods == effective_mods && it->item.sym == sym) {
|
||||
execute_binding(term, it->item.action, serial);
|
||||
input_execute_binding(term, it->item.action, serial);
|
||||
goto maybe_repeat;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
3
input.h
3
input.h
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <wayland-client.h>
|
||||
|
||||
#include "wayland.h"
|
||||
|
|
@ -8,3 +9,5 @@ extern const struct wl_keyboard_listener keyboard_listener;
|
|||
extern const struct wl_pointer_listener pointer_listener;
|
||||
|
||||
void input_repeat(struct wayland *wayl, uint32_t key);
|
||||
void input_execute_binding(
|
||||
struct terminal *term, enum binding_action action, uint32_t serial);
|
||||
|
|
|
|||
14
search.c
14
search.c
|
|
@ -11,6 +11,7 @@
|
|||
#define LOG_ENABLE_DBG 0
|
||||
#include "log.h"
|
||||
#include "grid.h"
|
||||
#include "input.h"
|
||||
#include "misc.h"
|
||||
#include "render.h"
|
||||
#include "selection.h"
|
||||
|
|
@ -412,7 +413,8 @@ distance_prev_word(const struct terminal *term)
|
|||
}
|
||||
|
||||
void
|
||||
search_input(struct terminal *term, uint32_t key, xkb_keysym_t sym, xkb_mod_mask_t mods)
|
||||
search_input(struct terminal *term, uint32_t key, xkb_keysym_t sym,
|
||||
xkb_mod_mask_t mods, uint32_t serial)
|
||||
{
|
||||
LOG_DBG("search: input: sym=%d/0x%x, mods=0x%08x", sym, sym, mods);
|
||||
|
||||
|
|
@ -424,6 +426,16 @@ search_input(struct terminal *term, uint32_t key, xkb_keysym_t sym, xkb_mod_mask
|
|||
enum xkb_compose_status compose_status = xkb_compose_state_get_status(
|
||||
term->wl->kbd.xkb_compose_state);
|
||||
|
||||
/*
|
||||
* User configurable bindings
|
||||
*/
|
||||
tll_foreach(term->wl->kbd.bindings.search, it) {
|
||||
if (it->item.mods == mods && it->item.sym == sym) {
|
||||
input_execute_binding(term, it->item.action, serial);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Cancel search */
|
||||
if ((mods == 0 && sym == XKB_KEY_Escape) ||
|
||||
(mods == ctrl && sym == XKB_KEY_g))
|
||||
|
|
|
|||
3
search.h
3
search.h
|
|
@ -5,4 +5,5 @@
|
|||
|
||||
void search_begin(struct terminal *term);
|
||||
void search_cancel(struct terminal *term);
|
||||
void search_input(struct terminal *term, uint32_t key, xkb_keysym_t sym, xkb_mod_mask_t mods);
|
||||
void search_input(struct terminal *term, uint32_t key, xkb_keysym_t sym, xkb_mod_mask_t mods,
|
||||
uint32_t serial);
|
||||
|
|
|
|||
|
|
@ -90,6 +90,7 @@ struct kbd {
|
|||
|
||||
struct {
|
||||
key_binding_list_t key;
|
||||
key_binding_list_t search;
|
||||
} bindings;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue