diff options
author | Benjamin Poirier <bpoirier@suse.de> | 2012-08-23 14:55:08 -0400 |
---|---|---|
committer | Michal Marek <mmarek@suse.cz> | 2012-09-27 12:09:24 -0400 |
commit | 95ac9b3b585d20df116c5bea1511d9eb5758ac81 (patch) | |
tree | c106d3003823ecbda997f295c75974385d560b9e /scripts/kconfig/mconf.c | |
parent | 1a374ae6191e9c440f1953a264a94d38173737be (diff) |
menuconfig: Assign jump keys per-page instead of globally
At the moment, keys 1-9 are assigned to the first 9 search results. This patch
makes them assigned to the first 9 results per-page instead. We are much less
likely to run out of keys that way.
Signed-off-by: Benjamin Poirier <bpoirier@suse.de>
Signed-off-by: Michal Marek <mmarek@suse.cz>
Diffstat (limited to 'scripts/kconfig/mconf.c')
-rw-r--r-- | scripts/kconfig/mconf.c | 75 |
1 files changed, 59 insertions, 16 deletions
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 6f409745b373..48f67448af7b 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c | |||
@@ -286,8 +286,9 @@ static void conf_choice(struct menu *menu); | |||
286 | static void conf_string(struct menu *menu); | 286 | static void conf_string(struct menu *menu); |
287 | static void conf_load(void); | 287 | static void conf_load(void); |
288 | static void conf_save(void); | 288 | static void conf_save(void); |
289 | static int show_textbox_ext(const char *title, const char *text, int r, int c, | 289 | static int show_textbox_ext(const char *title, char *text, int r, int c, |
290 | int *keys, int *vscroll, int *hscroll); | 290 | int *keys, int *vscroll, int *hscroll, |
291 | update_text_fn update_text, void *data); | ||
291 | static void show_textbox(const char *title, const char *text, int r, int c); | 292 | static void show_textbox(const char *title, const char *text, int r, int c); |
292 | static void show_helptext(const char *title, const char *text); | 293 | static void show_helptext(const char *title, const char *text); |
293 | static void show_help(struct menu *menu); | 294 | static void show_help(struct menu *menu); |
@@ -310,6 +311,39 @@ static void set_config_filename(const char *config_filename) | |||
310 | } | 311 | } |
311 | 312 | ||
312 | 313 | ||
314 | struct search_data { | ||
315 | struct jk_head *head; | ||
316 | struct menu **targets; | ||
317 | int *keys; | ||
318 | }; | ||
319 | |||
320 | static void update_text(char *buf, size_t start, size_t end, void *_data) | ||
321 | { | ||
322 | struct search_data *data = _data; | ||
323 | struct jump_key *pos; | ||
324 | int k = 0; | ||
325 | |||
326 | CIRCLEQ_FOREACH(pos, data->head, entries) { | ||
327 | if (pos->offset >= start && pos->offset < end) { | ||
328 | char header[4]; | ||
329 | |||
330 | if (k < JUMP_NB) { | ||
331 | int key = '0' + (pos->index % JUMP_NB) + 1; | ||
332 | |||
333 | sprintf(header, "(%c)", key); | ||
334 | data->keys[k] = key; | ||
335 | data->targets[k] = pos->target; | ||
336 | k++; | ||
337 | } else { | ||
338 | sprintf(header, " "); | ||
339 | } | ||
340 | |||
341 | memcpy(buf + pos->offset, header, sizeof(header) - 1); | ||
342 | } | ||
343 | } | ||
344 | data->keys[k] = 0; | ||
345 | } | ||
346 | |||
313 | static void search_conf(void) | 347 | static void search_conf(void) |
314 | { | 348 | { |
315 | struct symbol **sym_arr; | 349 | struct symbol **sym_arr; |
@@ -341,18 +375,24 @@ again: | |||
341 | 375 | ||
342 | sym_arr = sym_re_search(dialog_input); | 376 | sym_arr = sym_re_search(dialog_input); |
343 | do { | 377 | do { |
344 | struct menu *jumps[JUMP_NB] = {0}; | 378 | struct jk_head head = CIRCLEQ_HEAD_INITIALIZER(head); |
345 | int keys[JUMP_NB + 1] = {0}, i; | 379 | struct menu *targets[JUMP_NB]; |
346 | 380 | int keys[JUMP_NB + 1], i; | |
347 | res = get_relations_str(sym_arr, jumps); | 381 | struct search_data data = { |
348 | for (i = 0; i < JUMP_NB && jumps[i]; i++) | 382 | .head = &head, |
349 | keys[i] = '1' + i; | 383 | .targets = targets, |
350 | dres = show_textbox_ext(_("Search Results"), str_get(&res), 0, | 384 | .keys = keys, |
351 | 0, keys, &vscroll, &hscroll); | 385 | }; |
386 | |||
387 | res = get_relations_str(sym_arr, &head); | ||
388 | dres = show_textbox_ext(_("Search Results"), (char *) | ||
389 | str_get(&res), 0, 0, keys, &vscroll, | ||
390 | &hscroll, &update_text, (void *) | ||
391 | &data); | ||
352 | again = false; | 392 | again = false; |
353 | for (i = 0; i < JUMP_NB && jumps[i]; i++) | 393 | for (i = 0; i < JUMP_NB && keys[i]; i++) |
354 | if (dres == keys[i]) { | 394 | if (dres == keys[i]) { |
355 | conf(jumps[i]->parent, jumps[i]); | 395 | conf(targets[i]->parent, targets[i]); |
356 | again = true; | 396 | again = true; |
357 | } | 397 | } |
358 | str_free(&res); | 398 | str_free(&res); |
@@ -642,16 +682,19 @@ static void conf(struct menu *menu, struct menu *active_menu) | |||
642 | } | 682 | } |
643 | } | 683 | } |
644 | 684 | ||
645 | static int show_textbox_ext(const char *title, const char *text, int r, int c, | 685 | static int show_textbox_ext(const char *title, char *text, int r, int c, int |
646 | int *keys, int *vscroll, int *hscroll) | 686 | *keys, int *vscroll, int *hscroll, update_text_fn |
687 | update_text, void *data) | ||
647 | { | 688 | { |
648 | dialog_clear(); | 689 | dialog_clear(); |
649 | return dialog_textbox(title, text, r, c, keys, vscroll, hscroll); | 690 | return dialog_textbox(title, text, r, c, keys, vscroll, hscroll, |
691 | update_text, data); | ||
650 | } | 692 | } |
651 | 693 | ||
652 | static void show_textbox(const char *title, const char *text, int r, int c) | 694 | static void show_textbox(const char *title, const char *text, int r, int c) |
653 | { | 695 | { |
654 | show_textbox_ext(title, text, r, c, (int []) {0}, NULL, NULL); | 696 | show_textbox_ext(title, (char *) text, r, c, (int []) {0}, NULL, NULL, |
697 | NULL, NULL); | ||
655 | } | 698 | } |
656 | 699 | ||
657 | static void show_helptext(const char *title, const char *text) | 700 | static void show_helptext(const char *title, const char *text) |