mirror of
https://codeberg.org/adnano/wmenu.git
synced 2025-10-29 05:40:20 -04:00
parent
9f6a36d73f
commit
bbfbf8f36c
1 changed files with 17 additions and 6 deletions
23
menu.c
23
menu.c
|
|
@ -337,12 +337,23 @@ static size_t nextrune(struct menu *menu, int incr) {
|
||||||
|
|
||||||
// Move the cursor to the beginning or end of the word, skipping over any preceding whitespace.
|
// Move the cursor to the beginning or end of the word, skipping over any preceding whitespace.
|
||||||
static void movewordedge(struct menu *menu, int dir) {
|
static void movewordedge(struct menu *menu, int dir) {
|
||||||
size_t len = strlen(menu->input);
|
if (dir < 0) {
|
||||||
while (menu->cursor > 0 && menu->cursor < len && menu->input[nextrune(menu, dir)] == ' ') {
|
// Move to beginning of word
|
||||||
menu->cursor = nextrune(menu, dir);
|
while (menu->cursor > 0 && menu->input[nextrune(menu, -1)] == ' ') {
|
||||||
}
|
menu->cursor = nextrune(menu, -1);
|
||||||
while (menu->cursor > 0 && menu->cursor < len && menu->input[nextrune(menu, dir)] != ' ') {
|
}
|
||||||
menu->cursor = nextrune(menu, dir);
|
while (menu->cursor > 0 && menu->input[nextrune(menu, -1)] != ' ') {
|
||||||
|
menu->cursor = nextrune(menu, -1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Move to end of word
|
||||||
|
size_t len = strlen(menu->input);
|
||||||
|
while (menu->cursor < len && menu->input[menu->cursor] == ' ') {
|
||||||
|
menu->cursor = nextrune(menu, +1);
|
||||||
|
}
|
||||||
|
while (menu->cursor < len && menu->input[menu->cursor] != ' ') {
|
||||||
|
menu->cursor = nextrune(menu, +1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue