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 | |
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')
-rw-r--r-- | scripts/kconfig/expr.h | 9 | ||||
-rw-r--r-- | scripts/kconfig/lkc_proto.h | 8 | ||||
-rw-r--r-- | scripts/kconfig/lxdialog/dialog.h | 9 | ||||
-rw-r--r-- | scripts/kconfig/lxdialog/textbox.c | 67 | ||||
-rw-r--r-- | scripts/kconfig/mconf.c | 75 | ||||
-rw-r--r-- | scripts/kconfig/menu.c | 54 |
6 files changed, 149 insertions, 73 deletions
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 52f4246bd34d..bd2e09895553 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h | |||
@@ -12,6 +12,7 @@ extern "C" { | |||
12 | 12 | ||
13 | #include <assert.h> | 13 | #include <assert.h> |
14 | #include <stdio.h> | 14 | #include <stdio.h> |
15 | #include <sys/queue.h> | ||
15 | #ifndef __cplusplus | 16 | #ifndef __cplusplus |
16 | #include <stdbool.h> | 17 | #include <stdbool.h> |
17 | #endif | 18 | #endif |
@@ -173,6 +174,14 @@ struct menu { | |||
173 | #define MENU_CHANGED 0x0001 | 174 | #define MENU_CHANGED 0x0001 |
174 | #define MENU_ROOT 0x0002 | 175 | #define MENU_ROOT 0x0002 |
175 | 176 | ||
177 | struct jump_key { | ||
178 | CIRCLEQ_ENTRY(jump_key) entries; | ||
179 | size_t offset; | ||
180 | struct menu *target; | ||
181 | int index; | ||
182 | }; | ||
183 | CIRCLEQ_HEAD(jk_head, jump_key); | ||
184 | |||
176 | #define JUMP_NB 9 | 185 | #define JUMP_NB 9 |
177 | 186 | ||
178 | extern struct file *file_list; | 187 | extern struct file *file_list; |
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h index 946c2cb367f9..1d1c08537f1e 100644 --- a/scripts/kconfig/lkc_proto.h +++ b/scripts/kconfig/lkc_proto.h | |||
@@ -21,10 +21,10 @@ P(menu_get_root_menu,struct menu *,(struct menu *menu)); | |||
21 | P(menu_get_parent_menu,struct menu *,(struct menu *menu)); | 21 | P(menu_get_parent_menu,struct menu *,(struct menu *menu)); |
22 | P(menu_has_help,bool,(struct menu *menu)); | 22 | P(menu_has_help,bool,(struct menu *menu)); |
23 | P(menu_get_help,const char *,(struct menu *menu)); | 23 | P(menu_get_help,const char *,(struct menu *menu)); |
24 | P(get_symbol_str, int, (struct gstr *r, struct symbol *sym, struct menu | 24 | P(get_symbol_str, void, (struct gstr *r, struct symbol *sym, struct jk_head |
25 | **jumps, int jump_nb)); | 25 | *head)); |
26 | P(get_relations_str, struct gstr, (struct symbol **sym_arr, struct menu | 26 | P(get_relations_str, struct gstr, (struct symbol **sym_arr, struct jk_head |
27 | **jumps)); | 27 | *head)); |
28 | P(menu_get_ext_help,void,(struct menu *menu, struct gstr *help)); | 28 | P(menu_get_ext_help,void,(struct menu *menu, struct gstr *help)); |
29 | 29 | ||
30 | /* symbol.c */ | 30 | /* symbol.c */ |
diff --git a/scripts/kconfig/lxdialog/dialog.h b/scripts/kconfig/lxdialog/dialog.h index 2a01cdfae5a8..ee17a5264d5b 100644 --- a/scripts/kconfig/lxdialog/dialog.h +++ b/scripts/kconfig/lxdialog/dialog.h | |||
@@ -210,8 +210,13 @@ int first_alpha(const char *string, const char *exempt); | |||
210 | int dialog_yesno(const char *title, const char *prompt, int height, int width); | 210 | int dialog_yesno(const char *title, const char *prompt, int height, int width); |
211 | int dialog_msgbox(const char *title, const char *prompt, int height, | 211 | int dialog_msgbox(const char *title, const char *prompt, int height, |
212 | int width, int pause); | 212 | int width, int pause); |
213 | int dialog_textbox(const char *title, const char *file, int height, int width, | 213 | |
214 | int *keys, int *_vscroll, int *_hscroll); | 214 | |
215 | typedef void (*update_text_fn)(char *buf, size_t start, size_t end, void | ||
216 | *_data); | ||
217 | int dialog_textbox(const char *title, char *tbuf, int initial_height, | ||
218 | int initial_width, int *keys, int *_vscroll, int *_hscroll, | ||
219 | update_text_fn update_text, void *data); | ||
215 | int dialog_menu(const char *title, const char *prompt, | 220 | int dialog_menu(const char *title, const char *prompt, |
216 | const void *selected, int *s_scroll); | 221 | const void *selected, int *s_scroll); |
217 | int dialog_checklist(const char *title, const char *prompt, int height, | 222 | int dialog_checklist(const char *title, const char *prompt, int height, |
diff --git a/scripts/kconfig/lxdialog/textbox.c b/scripts/kconfig/lxdialog/textbox.c index 3b3c5c470bf8..a48bb93e0907 100644 --- a/scripts/kconfig/lxdialog/textbox.c +++ b/scripts/kconfig/lxdialog/textbox.c | |||
@@ -22,23 +22,25 @@ | |||
22 | #include "dialog.h" | 22 | #include "dialog.h" |
23 | 23 | ||
24 | static void back_lines(int n); | 24 | static void back_lines(int n); |
25 | static void print_page(WINDOW * win, int height, int width); | 25 | static void print_page(WINDOW *win, int height, int width, update_text_fn |
26 | static void print_line(WINDOW * win, int row, int width); | 26 | update_text, void *data); |
27 | static void print_line(WINDOW *win, int row, int width); | ||
27 | static char *get_line(void); | 28 | static char *get_line(void); |
28 | static void print_position(WINDOW * win); | 29 | static void print_position(WINDOW * win); |
29 | 30 | ||
30 | static int hscroll; | 31 | static int hscroll; |
31 | static int begin_reached, end_reached, page_length; | 32 | static int begin_reached, end_reached, page_length; |
32 | static const char *buf; | 33 | static char *buf; |
33 | static const char *page; | 34 | static char *page; |
34 | 35 | ||
35 | /* | 36 | /* |
36 | * refresh window content | 37 | * refresh window content |
37 | */ | 38 | */ |
38 | static void refresh_text_box(WINDOW *dialog, WINDOW *box, int boxh, int boxw, | 39 | static void refresh_text_box(WINDOW *dialog, WINDOW *box, int boxh, int boxw, |
39 | int cur_y, int cur_x) | 40 | int cur_y, int cur_x, update_text_fn update_text, |
41 | void *data) | ||
40 | { | 42 | { |
41 | print_page(box, boxh, boxw); | 43 | print_page(box, boxh, boxw, update_text, data); |
42 | print_position(dialog); | 44 | print_position(dialog); |
43 | wmove(dialog, cur_y, cur_x); /* Restore cursor position */ | 45 | wmove(dialog, cur_y, cur_x); /* Restore cursor position */ |
44 | wrefresh(dialog); | 46 | wrefresh(dialog); |
@@ -49,9 +51,11 @@ static void refresh_text_box(WINDOW *dialog, WINDOW *box, int boxh, int boxw, | |||
49 | * Display text from a file in a dialog box. | 51 | * Display text from a file in a dialog box. |
50 | * | 52 | * |
51 | * keys is a null-terminated array | 53 | * keys is a null-terminated array |
54 | * update_text() may not add or remove any '\n' or '\0' in tbuf | ||
52 | */ | 55 | */ |
53 | int dialog_textbox(const char *title, const char *tbuf, int initial_height, | 56 | int dialog_textbox(const char *title, char *tbuf, int initial_height, |
54 | int initial_width, int *keys, int *_vscroll, int *_hscroll) | 57 | int initial_width, int *keys, int *_vscroll, int *_hscroll, |
58 | update_text_fn update_text, void *data) | ||
55 | { | 59 | { |
56 | int i, x, y, cur_x, cur_y, key = 0; | 60 | int i, x, y, cur_x, cur_y, key = 0; |
57 | int height, width, boxh, boxw; | 61 | int height, width, boxh, boxw; |
@@ -131,7 +135,8 @@ do_resize: | |||
131 | 135 | ||
132 | /* Print first page of text */ | 136 | /* Print first page of text */ |
133 | attr_clear(box, boxh, boxw, dlg.dialog.atr); | 137 | attr_clear(box, boxh, boxw, dlg.dialog.atr); |
134 | refresh_text_box(dialog, box, boxh, boxw, cur_y, cur_x); | 138 | refresh_text_box(dialog, box, boxh, boxw, cur_y, cur_x, update_text, |
139 | data); | ||
135 | 140 | ||
136 | while (!done) { | 141 | while (!done) { |
137 | key = wgetch(dialog); | 142 | key = wgetch(dialog); |
@@ -150,7 +155,8 @@ do_resize: | |||
150 | begin_reached = 1; | 155 | begin_reached = 1; |
151 | page = buf; | 156 | page = buf; |
152 | refresh_text_box(dialog, box, boxh, boxw, | 157 | refresh_text_box(dialog, box, boxh, boxw, |
153 | cur_y, cur_x); | 158 | cur_y, cur_x, update_text, |
159 | data); | ||
154 | } | 160 | } |
155 | break; | 161 | break; |
156 | case 'G': /* Last page */ | 162 | case 'G': /* Last page */ |
@@ -160,8 +166,8 @@ do_resize: | |||
160 | /* point to last char in buf */ | 166 | /* point to last char in buf */ |
161 | page = buf + strlen(buf); | 167 | page = buf + strlen(buf); |
162 | back_lines(boxh); | 168 | back_lines(boxh); |
163 | refresh_text_box(dialog, box, boxh, boxw, | 169 | refresh_text_box(dialog, box, boxh, boxw, cur_y, |
164 | cur_y, cur_x); | 170 | cur_x, update_text, data); |
165 | break; | 171 | break; |
166 | case 'K': /* Previous line */ | 172 | case 'K': /* Previous line */ |
167 | case 'k': | 173 | case 'k': |
@@ -171,7 +177,7 @@ do_resize: | |||
171 | 177 | ||
172 | back_lines(page_length + 1); | 178 | back_lines(page_length + 1); |
173 | refresh_text_box(dialog, box, boxh, boxw, cur_y, | 179 | refresh_text_box(dialog, box, boxh, boxw, cur_y, |
174 | cur_x); | 180 | cur_x, update_text, data); |
175 | break; | 181 | break; |
176 | case 'B': /* Previous page */ | 182 | case 'B': /* Previous page */ |
177 | case 'b': | 183 | case 'b': |
@@ -180,8 +186,8 @@ do_resize: | |||
180 | if (begin_reached) | 186 | if (begin_reached) |
181 | break; | 187 | break; |
182 | back_lines(page_length + boxh); | 188 | back_lines(page_length + boxh); |
183 | refresh_text_box(dialog, box, boxh, boxw, | 189 | refresh_text_box(dialog, box, boxh, boxw, cur_y, |
184 | cur_y, cur_x); | 190 | cur_x, update_text, data); |
185 | break; | 191 | break; |
186 | case 'J': /* Next line */ | 192 | case 'J': /* Next line */ |
187 | case 'j': | 193 | case 'j': |
@@ -191,7 +197,7 @@ do_resize: | |||
191 | 197 | ||
192 | back_lines(page_length - 1); | 198 | back_lines(page_length - 1); |
193 | refresh_text_box(dialog, box, boxh, boxw, cur_y, | 199 | refresh_text_box(dialog, box, boxh, boxw, cur_y, |
194 | cur_x); | 200 | cur_x, update_text, data); |
195 | break; | 201 | break; |
196 | case KEY_NPAGE: /* Next page */ | 202 | case KEY_NPAGE: /* Next page */ |
197 | case ' ': | 203 | case ' ': |
@@ -200,8 +206,8 @@ do_resize: | |||
200 | break; | 206 | break; |
201 | 207 | ||
202 | begin_reached = 0; | 208 | begin_reached = 0; |
203 | refresh_text_box(dialog, box, boxh, boxw, | 209 | refresh_text_box(dialog, box, boxh, boxw, cur_y, |
204 | cur_y, cur_x); | 210 | cur_x, update_text, data); |
205 | break; | 211 | break; |
206 | case '0': /* Beginning of line */ | 212 | case '0': /* Beginning of line */ |
207 | case 'H': /* Scroll left */ | 213 | case 'H': /* Scroll left */ |
@@ -216,8 +222,8 @@ do_resize: | |||
216 | hscroll--; | 222 | hscroll--; |
217 | /* Reprint current page to scroll horizontally */ | 223 | /* Reprint current page to scroll horizontally */ |
218 | back_lines(page_length); | 224 | back_lines(page_length); |
219 | refresh_text_box(dialog, box, boxh, boxw, | 225 | refresh_text_box(dialog, box, boxh, boxw, cur_y, |
220 | cur_y, cur_x); | 226 | cur_x, update_text, data); |
221 | break; | 227 | break; |
222 | case 'L': /* Scroll right */ | 228 | case 'L': /* Scroll right */ |
223 | case 'l': | 229 | case 'l': |
@@ -227,8 +233,8 @@ do_resize: | |||
227 | hscroll++; | 233 | hscroll++; |
228 | /* Reprint current page to scroll horizontally */ | 234 | /* Reprint current page to scroll horizontally */ |
229 | back_lines(page_length); | 235 | back_lines(page_length); |
230 | refresh_text_box(dialog, box, boxh, boxw, | 236 | refresh_text_box(dialog, box, boxh, boxw, cur_y, |
231 | cur_y, cur_x); | 237 | cur_x, update_text, data); |
232 | break; | 238 | break; |
233 | case KEY_ESC: | 239 | case KEY_ESC: |
234 | if (on_key_esc(dialog) == KEY_ESC) | 240 | if (on_key_esc(dialog) == KEY_ESC) |
@@ -301,12 +307,23 @@ static void back_lines(int n) | |||
301 | } | 307 | } |
302 | 308 | ||
303 | /* | 309 | /* |
304 | * Print a new page of text. Called by dialog_textbox(). | 310 | * Print a new page of text. |
305 | */ | 311 | */ |
306 | static void print_page(WINDOW * win, int height, int width) | 312 | static void print_page(WINDOW *win, int height, int width, update_text_fn |
313 | update_text, void *data) | ||
307 | { | 314 | { |
308 | int i, passed_end = 0; | 315 | int i, passed_end = 0; |
309 | 316 | ||
317 | if (update_text) { | ||
318 | char *end; | ||
319 | |||
320 | for (i = 0; i < height; i++) | ||
321 | get_line(); | ||
322 | end = page; | ||
323 | back_lines(height); | ||
324 | update_text(buf, page - buf, end - buf, data); | ||
325 | } | ||
326 | |||
310 | page_length = 0; | 327 | page_length = 0; |
311 | for (i = 0; i < height; i++) { | 328 | for (i = 0; i < height; i++) { |
312 | print_line(win, i, width); | 329 | print_line(win, i, width); |
@@ -319,7 +336,7 @@ static void print_page(WINDOW * win, int height, int width) | |||
319 | } | 336 | } |
320 | 337 | ||
321 | /* | 338 | /* |
322 | * Print a new line of text. Called by dialog_textbox() and print_page(). | 339 | * Print a new line of text. |
323 | */ | 340 | */ |
324 | static void print_line(WINDOW * win, int row, int width) | 341 | static void print_line(WINDOW * win, int row, int width) |
325 | { | 342 | { |
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) |
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index a5241859326a..a3cade659f89 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c | |||
@@ -507,12 +507,12 @@ const char *menu_get_help(struct menu *menu) | |||
507 | return ""; | 507 | return ""; |
508 | } | 508 | } |
509 | 509 | ||
510 | static int get_prompt_str(struct gstr *r, struct property *prop, struct menu | 510 | static void get_prompt_str(struct gstr *r, struct property *prop, |
511 | **jumps, int jump_nb) | 511 | struct jk_head *head) |
512 | { | 512 | { |
513 | int i, j; | 513 | int i, j; |
514 | char header[4]; | ||
515 | struct menu *submenu[8], *menu, *location = NULL; | 514 | struct menu *submenu[8], *menu, *location = NULL; |
515 | struct jump_key *jump; | ||
516 | 516 | ||
517 | str_printf(r, _("Prompt: %s\n"), _(prop->text)); | 517 | str_printf(r, _("Prompt: %s\n"), _(prop->text)); |
518 | str_printf(r, _(" Defined at %s:%d\n"), prop->menu->file->name, | 518 | str_printf(r, _(" Defined at %s:%d\n"), prop->menu->file->name, |
@@ -530,7 +530,9 @@ static int get_prompt_str(struct gstr *r, struct property *prop, struct menu | |||
530 | if (location == NULL && accessible) | 530 | if (location == NULL && accessible) |
531 | location = menu; | 531 | location = menu; |
532 | } | 532 | } |
533 | if (jumps && jump_nb < JUMP_NB && location) { | 533 | if (head && location) { |
534 | jump = malloc(sizeof(struct jump_key)); | ||
535 | |||
534 | if (menu_is_visible(prop->menu)) { | 536 | if (menu_is_visible(prop->menu)) { |
535 | /* | 537 | /* |
536 | * There is not enough room to put the hint at the | 538 | * There is not enough room to put the hint at the |
@@ -538,19 +540,26 @@ static int get_prompt_str(struct gstr *r, struct property *prop, struct menu | |||
538 | * last "Location" line even when it would belong on | 540 | * last "Location" line even when it would belong on |
539 | * the former. | 541 | * the former. |
540 | */ | 542 | */ |
541 | jumps[jump_nb] = prop->menu; | 543 | jump->target = prop->menu; |
542 | } else | 544 | } else |
543 | jumps[jump_nb] = location; | 545 | jump->target = location; |
544 | snprintf(header, 4, "(%d)", jump_nb + 1); | 546 | |
545 | } else | 547 | if (CIRCLEQ_EMPTY(head)) |
546 | location = NULL; | 548 | jump->index = 0; |
549 | else | ||
550 | jump->index = CIRCLEQ_LAST(head)->index + 1; | ||
551 | |||
552 | CIRCLEQ_INSERT_TAIL(head, jump, entries); | ||
553 | } | ||
547 | 554 | ||
548 | if (i > 0) { | 555 | if (i > 0) { |
549 | str_printf(r, _(" Location:\n")); | 556 | str_printf(r, _(" Location:\n")); |
550 | for (j = 1; --i >= 0; j += 2) { | 557 | for (j = 4; --i >= 0; j += 2) { |
551 | menu = submenu[i]; | 558 | menu = submenu[i]; |
552 | str_printf(r, "%s%*c-> %s", menu == location ? header | 559 | if (head && location && menu == location) |
553 | : " ", j, ' ', _(menu_get_prompt(menu))); | 560 | jump->offset = r->len - 1; |
561 | str_printf(r, "%*c-> %s", j, ' ', | ||
562 | _(menu_get_prompt(menu))); | ||
554 | if (menu->sym) { | 563 | if (menu->sym) { |
555 | str_printf(r, " (%s [=%s])", menu->sym->name ? | 564 | str_printf(r, " (%s [=%s])", menu->sym->name ? |
556 | menu->sym->name : _("<choice>"), | 565 | menu->sym->name : _("<choice>"), |
@@ -559,20 +568,15 @@ static int get_prompt_str(struct gstr *r, struct property *prop, struct menu | |||
559 | str_append(r, "\n"); | 568 | str_append(r, "\n"); |
560 | } | 569 | } |
561 | } | 570 | } |
562 | |||
563 | return location ? 1 : 0; | ||
564 | } | 571 | } |
565 | 572 | ||
566 | /* | 573 | /* |
567 | * jumps is optional and may be NULL | 574 | * head is optional and may be NULL |
568 | * returns the number of jumps inserted | ||
569 | */ | 575 | */ |
570 | int get_symbol_str(struct gstr *r, struct symbol *sym, struct menu **jumps, | 576 | void get_symbol_str(struct gstr *r, struct symbol *sym, struct jk_head *head) |
571 | int jump_nb) | ||
572 | { | 577 | { |
573 | bool hit; | 578 | bool hit; |
574 | struct property *prop; | 579 | struct property *prop; |
575 | int i = 0; | ||
576 | 580 | ||
577 | if (sym && sym->name) { | 581 | if (sym && sym->name) { |
578 | str_printf(r, "Symbol: %s [=%s]\n", sym->name, | 582 | str_printf(r, "Symbol: %s [=%s]\n", sym->name, |
@@ -588,7 +592,7 @@ int get_symbol_str(struct gstr *r, struct symbol *sym, struct menu **jumps, | |||
588 | } | 592 | } |
589 | } | 593 | } |
590 | for_all_prompts(sym, prop) | 594 | for_all_prompts(sym, prop) |
591 | i += get_prompt_str(r, prop, jumps, jump_nb + i); | 595 | get_prompt_str(r, prop, head); |
592 | hit = false; | 596 | hit = false; |
593 | for_all_properties(sym, prop, P_SELECT) { | 597 | for_all_properties(sym, prop, P_SELECT) { |
594 | if (!hit) { | 598 | if (!hit) { |
@@ -606,18 +610,16 @@ int get_symbol_str(struct gstr *r, struct symbol *sym, struct menu **jumps, | |||
606 | str_append(r, "\n"); | 610 | str_append(r, "\n"); |
607 | } | 611 | } |
608 | str_append(r, "\n\n"); | 612 | str_append(r, "\n\n"); |
609 | |||
610 | return i; | ||
611 | } | 613 | } |
612 | 614 | ||
613 | struct gstr get_relations_str(struct symbol **sym_arr, struct menu **jumps) | 615 | struct gstr get_relations_str(struct symbol **sym_arr, struct jk_head *head) |
614 | { | 616 | { |
615 | struct symbol *sym; | 617 | struct symbol *sym; |
616 | struct gstr res = str_new(); | 618 | struct gstr res = str_new(); |
617 | int i, jump_nb = 0; | 619 | int i; |
618 | 620 | ||
619 | for (i = 0; sym_arr && (sym = sym_arr[i]); i++) | 621 | for (i = 0; sym_arr && (sym = sym_arr[i]); i++) |
620 | jump_nb += get_symbol_str(&res, sym, jumps, jump_nb); | 622 | get_symbol_str(&res, sym, head); |
621 | if (!i) | 623 | if (!i) |
622 | str_append(&res, _("No matches found.\n")); | 624 | str_append(&res, _("No matches found.\n")); |
623 | return res; | 625 | return res; |
@@ -636,5 +638,5 @@ void menu_get_ext_help(struct menu *menu, struct gstr *help) | |||
636 | } | 638 | } |
637 | str_printf(help, "%s\n", _(help_text)); | 639 | str_printf(help, "%s\n", _(help_text)); |
638 | if (sym) | 640 | if (sym) |
639 | get_symbol_str(help, sym, NULL, 0); | 641 | get_symbol_str(help, sym, NULL); |
640 | } | 642 | } |