Fix move to end of word - wmenu - 🔧 fork of wmenu
(HTM) git clone git@git.drkhsh.at/wmenu.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 38b4bae4bd4b2f96c3ddfa69880dc50c0affb8d9
(DIR) parent 972277a5e0a4d92810c84afe3a6b278b3f8bbd54
(HTM) Author: adnano <me@adnano.co>
Date: Fri, 2 Dec 2022 11:35:30 -0500
Fix move to end of word
Diffstat:
M main.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
---
(DIR) diff --git a/main.c b/main.c
@@ -501,6 +501,8 @@ void keypress(struct menu_state *state, enum wl_keyboard_key_state key_state,
XKB_MOD_NAME_SHIFT,
XKB_STATE_MODS_DEPRESSED | XKB_STATE_MODS_LATCHED);
+ size_t len = strlen(state->text);
+
if (ctrl) {
// Emacs-style line editing bindings
switch (sym) {
@@ -580,11 +582,11 @@ void keypress(struct menu_state *state, enum wl_keyboard_key_state key_state,
case XKB_KEY_Right:
case XKB_KEY_KP_Right:
// Move to end of word
- while (state->cursor > 0 && state->text[nextrune(state, -1)] == ' ') {
- state->cursor = nextrune(state, -1);
+ while (state->cursor < len && state->text[state->cursor] == ' ') {
+ state->cursor = nextrune(state, +1);
}
- while (state->cursor > 0 && state->text[nextrune(state, -1)] != ' ') {
- state->cursor = nextrune(state, -1);
+ while (state->cursor < len && state->text[state->cursor] != ' ') {
+ state->cursor = nextrune(state, +1);
}
render_frame(state);
return;
@@ -592,7 +594,6 @@ void keypress(struct menu_state *state, enum wl_keyboard_key_state key_state,
}
char buf[8];
- size_t len = strlen(state->text);
switch (sym) {
case XKB_KEY_Return:
case XKB_KEY_KP_Enter: