From 6f08bb41283e02bc35e25fc9f769fb950e9ee957 Mon Sep 17 00:00:00 2001 From: Phil Jones Date: Wed, 29 Jun 2022 18:21:56 +0100 Subject: Add Ctrl-j and Ctrl-k keybindings. --- doc/tofi.1.md | 6 +++--- doc/tofi.1.scd | 6 +++--- src/main.c | 18 ++++++++++++++++-- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/doc/tofi.1.md b/doc/tofi.1.md index ce3289f..6d2d83f 100644 --- a/doc/tofi.1.md +++ b/doc/tofi.1.md @@ -50,13 +50,13 @@ the form **--key=value**. # KEYS -\ \| \ +\ \| \ \| \-k > Move the selection back one entry. -\ \| \ \| \ +\ \| \ \| \-j \| \ -> Move the selection back forward entry. +> Move the selection forward one entry. \ diff --git a/doc/tofi.1.scd b/doc/tofi.1.scd index 87740c1..0e48639 100644 --- a/doc/tofi.1.scd +++ b/doc/tofi.1.scd @@ -45,11 +45,11 @@ All config file options described in *tofi*(5) are also accepted, in the form # KEYS - | + | | -k Move the selection back one entry. - | | - Move the selection back forward entry. + | | -j | + Move the selection forward one entry. Confirm the current selection and quit. diff --git a/src/main.c b/src/main.c index 12e89a2..8f974f0 100644 --- a/src/main.c +++ b/src/main.c @@ -205,12 +205,26 @@ static void wl_keyboard_key( return; } - if (sym == XKB_KEY_Up || sym == XKB_KEY_Left) { + if (sym == XKB_KEY_Up || sym == XKB_KEY_Left + || (sym == XKB_KEY_k + && xkb_state_mod_name_is_active( + tofi->xkb_state, + XKB_MOD_NAME_CTRL, + XKB_STATE_MODS_EFFECTIVE) + ) + ) { uint32_t nsel = MAX(MIN(tofi->window.entry.num_results, tofi->window.entry.results.count), 1); tofi->window.entry.selection += nsel; tofi->window.entry.selection--; tofi->window.entry.selection %= nsel; - } else if (sym == XKB_KEY_Down || sym == XKB_KEY_Right || sym == XKB_KEY_Tab) { + } else if (sym == XKB_KEY_Down || sym == XKB_KEY_Right || sym == XKB_KEY_Tab + || (sym == XKB_KEY_j + && xkb_state_mod_name_is_active( + tofi->xkb_state, + XKB_MOD_NAME_CTRL, + XKB_STATE_MODS_EFFECTIVE) + ) + ) { uint32_t nsel = MAX(MIN(tofi->window.entry.num_results, tofi->window.entry.results.count), 1); tofi->window.entry.selection++; tofi->window.entry.selection %= nsel; -- cgit v1.2.3