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 | ||
