aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoradnano <me@adnano.co>2024-02-26 10:43:52 -0500
committeradnano <me@adnano.co>2024-02-26 10:43:52 -0500
commit906b55019e50558e7d2ee0b26b9732b64b6306e1 (patch)
treef2685182315469272a72ba072f3ce238ec97a9c0
parent542c307ef23a97f6f0ed255df51fcbe9b23ed07c (diff)
downloadwmenu-906b55019e50558e7d2ee0b26b9732b64b6306e1.tar.gz
Keep track of end of match list
-rw-r--r--main.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/main.c b/main.c
index 22a1e52..7be3762 100644
--- a/main.c
+++ b/main.c
@@ -90,6 +90,7 @@ struct menu_state {
struct menu_item *items;
struct menu_item *matches;
+ struct menu_item *matchend;
struct menu_item *selection;
struct menu_item *leftmost, *rightmost;
};
@@ -726,14 +727,9 @@ void keypress(struct menu_state *state, enum wl_keyboard_key_state key_state,
state->cursor = len;
render_frame(state);
} else {
- if (!state->selection || !state->selection->right) {
- return;
- }
- while (state->selection && state->selection->right) {
- state->selection = state->selection->right;
- }
+ state->selection = state->matchend;
+ state->rightmost = state->matchend;
state->leftmost = NULL;
- state->rightmost = state->selection;
scroll_matches(state);
render_frame(state);
}
@@ -932,6 +928,7 @@ void match(struct menu_state *state) {
struct menu_item *item, *itemend, *lexact, *lprefix, *lsubstr, *exactend, *prefixend, *substrend;
state->matches = NULL;
+ state->matchend = NULL;
state->leftmost = NULL;
size_t len = strlen(state->text);
state->matches = lexact = lprefix = lsubstr = itemend = exactend = prefixend = substrend = NULL;
@@ -962,11 +959,12 @@ void match(struct menu_state *state) {
if (itemend) {
itemend->right = lsubstr;
lsubstr->left = itemend;
- itemend = substrend;
} else {
state->matches = lsubstr;
}
+ itemend = substrend;
}
+ state->matchend = itemend;
state->selection = state->matches;
state->leftmost = state->matches;
state->rightmost = NULL;