diff options
| author | Benjamin Poirier <bpoirier@suse.de> | 2013-04-16 10:07:23 -0400 |
|---|---|---|
| committer | Yann E. MORIN <yann.morin.1998@free.fr> | 2013-04-16 16:00:31 -0400 |
| commit | 9a69abf80edf2ea0dac058cab156879d29362788 (patch) | |
| tree | b94e9a202805b4de9afce670e17ba720592d2cc5 /scripts | |
| parent | edb749f4390b3c1604233dc7c4fb0361f472e712 (diff) | |
menuconfig: Add "breadcrumbs" navigation aid
Displays a trail of the menu entries used to get to the current menu.
Signed-off-by: Benjamin Poirier <bpoirier@suse.de>
Tested-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
[yann.morin.1998@free.fr: small, trivial code re-ordering]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/kconfig/list.h | 27 | ||||
| -rw-r--r-- | scripts/kconfig/lxdialog/dialog.h | 7 | ||||
| -rw-r--r-- | scripts/kconfig/lxdialog/util.c | 45 | ||||
| -rw-r--r-- | scripts/kconfig/mconf.c | 71 |
4 files changed, 147 insertions, 3 deletions
diff --git a/scripts/kconfig/list.h b/scripts/kconfig/list.h index b87206cc92f4..ea1d58119d20 100644 --- a/scripts/kconfig/list.h +++ b/scripts/kconfig/list.h | |||
| @@ -101,4 +101,31 @@ static inline void list_add_tail(struct list_head *_new, struct list_head *head) | |||
| 101 | __list_add(_new, head->prev, head); | 101 | __list_add(_new, head->prev, head); |
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | /* | ||
| 105 | * Delete a list entry by making the prev/next entries | ||
| 106 | * point to each other. | ||
| 107 | * | ||
| 108 | * This is only for internal list manipulation where we know | ||
| 109 | * the prev/next entries already! | ||
| 110 | */ | ||
| 111 | static inline void __list_del(struct list_head *prev, struct list_head *next) | ||
| 112 | { | ||
| 113 | next->prev = prev; | ||
| 114 | prev->next = next; | ||
| 115 | } | ||
| 116 | |||
| 117 | #define LIST_POISON1 ((void *) 0x00100100) | ||
| 118 | #define LIST_POISON2 ((void *) 0x00200200) | ||
| 119 | /** | ||
| 120 | * list_del - deletes entry from list. | ||
| 121 | * @entry: the element to delete from the list. | ||
| 122 | * Note: list_empty() on entry does not return true after this, the entry is | ||
| 123 | * in an undefined state. | ||
| 124 | */ | ||
| 125 | static inline void list_del(struct list_head *entry) | ||
| 126 | { | ||
| 127 | __list_del(entry->prev, entry->next); | ||
| 128 | entry->next = LIST_POISON1; | ||
| 129 | entry->prev = LIST_POISON2; | ||
| 130 | } | ||
| 104 | #endif | 131 | #endif |
diff --git a/scripts/kconfig/lxdialog/dialog.h b/scripts/kconfig/lxdialog/dialog.h index 307022a8beef..1099337079b6 100644 --- a/scripts/kconfig/lxdialog/dialog.h +++ b/scripts/kconfig/lxdialog/dialog.h | |||
| @@ -106,8 +106,14 @@ struct dialog_color { | |||
| 106 | int hl; /* highlight this item */ | 106 | int hl; /* highlight this item */ |
| 107 | }; | 107 | }; |
| 108 | 108 | ||
| 109 | struct subtitle_list { | ||
| 110 | struct subtitle_list *next; | ||
| 111 | const char *text; | ||
| 112 | }; | ||
| 113 | |||
| 109 | struct dialog_info { | 114 | struct dialog_info { |
| 110 | const char *backtitle; | 115 | const char *backtitle; |
| 116 | struct subtitle_list *subtitles; | ||
| 111 | struct dialog_color screen; | 117 | struct dialog_color screen; |
| 112 | struct dialog_color shadow; | 118 | struct dialog_color shadow; |
| 113 | struct dialog_color dialog; | 119 | struct dialog_color dialog; |
| @@ -196,6 +202,7 @@ int on_key_resize(void); | |||
| 196 | 202 | ||
| 197 | int init_dialog(const char *backtitle); | 203 | int init_dialog(const char *backtitle); |
| 198 | void set_dialog_backtitle(const char *backtitle); | 204 | void set_dialog_backtitle(const char *backtitle); |
| 205 | void set_dialog_subtitles(struct subtitle_list *subtitles); | ||
| 199 | void end_dialog(int x, int y); | 206 | void end_dialog(int x, int y); |
| 200 | void attr_clear(WINDOW * win, int height, int width, chtype attr); | 207 | void attr_clear(WINDOW * win, int height, int width, chtype attr); |
| 201 | void dialog_clear(void); | 208 | void dialog_clear(void); |
diff --git a/scripts/kconfig/lxdialog/util.c b/scripts/kconfig/lxdialog/util.c index 109d53117d22..a0e97c299410 100644 --- a/scripts/kconfig/lxdialog/util.c +++ b/scripts/kconfig/lxdialog/util.c | |||
| @@ -257,12 +257,48 @@ void dialog_clear(void) | |||
| 257 | attr_clear(stdscr, LINES, COLS, dlg.screen.atr); | 257 | attr_clear(stdscr, LINES, COLS, dlg.screen.atr); |
| 258 | /* Display background title if it exists ... - SLH */ | 258 | /* Display background title if it exists ... - SLH */ |
| 259 | if (dlg.backtitle != NULL) { | 259 | if (dlg.backtitle != NULL) { |
| 260 | int i; | 260 | int i, len = 0, skip = 0; |
| 261 | struct subtitle_list *pos; | ||
| 261 | 262 | ||
| 262 | wattrset(stdscr, dlg.screen.atr); | 263 | wattrset(stdscr, dlg.screen.atr); |
| 263 | mvwaddstr(stdscr, 0, 1, (char *)dlg.backtitle); | 264 | mvwaddstr(stdscr, 0, 1, (char *)dlg.backtitle); |
| 265 | |||
| 266 | for (pos = dlg.subtitles; pos != NULL; pos = pos->next) { | ||
| 267 | /* 3 is for the arrow and spaces */ | ||
| 268 | len += strlen(pos->text) + 3; | ||
| 269 | } | ||
| 270 | |||
| 264 | wmove(stdscr, 1, 1); | 271 | wmove(stdscr, 1, 1); |
| 265 | for (i = 1; i < COLS - 1; i++) | 272 | if (len > COLS - 2) { |
| 273 | const char *ellipsis = "[...] "; | ||
| 274 | waddstr(stdscr, ellipsis); | ||
| 275 | skip = len - (COLS - 2 - strlen(ellipsis)); | ||
| 276 | } | ||
| 277 | |||
| 278 | for (pos = dlg.subtitles; pos != NULL; pos = pos->next) { | ||
| 279 | if (skip == 0) | ||
| 280 | waddch(stdscr, ACS_RARROW); | ||
| 281 | else | ||
| 282 | skip--; | ||
| 283 | |||
| 284 | if (skip == 0) | ||
| 285 | waddch(stdscr, ' '); | ||
| 286 | else | ||
| 287 | skip--; | ||
| 288 | |||
| 289 | if (skip < strlen(pos->text)) { | ||
| 290 | waddstr(stdscr, pos->text + skip); | ||
| 291 | skip = 0; | ||
| 292 | } else | ||
| 293 | skip -= strlen(pos->text); | ||
| 294 | |||
| 295 | if (skip == 0) | ||
| 296 | waddch(stdscr, ' '); | ||
| 297 | else | ||
| 298 | skip--; | ||
| 299 | } | ||
| 300 | |||
| 301 | for (i = len + 1; i < COLS - 1; i++) | ||
| 266 | waddch(stdscr, ACS_HLINE); | 302 | waddch(stdscr, ACS_HLINE); |
| 267 | } | 303 | } |
| 268 | wnoutrefresh(stdscr); | 304 | wnoutrefresh(stdscr); |
| @@ -302,6 +338,11 @@ void set_dialog_backtitle(const char *backtitle) | |||
| 302 | dlg.backtitle = backtitle; | 338 | dlg.backtitle = backtitle; |
| 303 | } | 339 | } |
| 304 | 340 | ||
| 341 | void set_dialog_subtitles(struct subtitle_list *subtitles) | ||
| 342 | { | ||
| 343 | dlg.subtitles = subtitles; | ||
| 344 | } | ||
| 345 | |||
| 305 | /* | 346 | /* |
| 306 | * End using dialog functions. | 347 | * End using dialog functions. |
| 307 | */ | 348 | */ |
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index c5418d622a05..387dc8daf7b2 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c | |||
| @@ -311,6 +311,50 @@ static void set_config_filename(const char *config_filename) | |||
| 311 | filename[sizeof(filename)-1] = '\0'; | 311 | filename[sizeof(filename)-1] = '\0'; |
| 312 | } | 312 | } |
| 313 | 313 | ||
| 314 | struct subtitle_part { | ||
| 315 | struct list_head entries; | ||
| 316 | const char *text; | ||
| 317 | }; | ||
| 318 | static LIST_HEAD(trail); | ||
| 319 | |||
| 320 | static struct subtitle_list *subtitles; | ||
| 321 | static void set_subtitle(void) | ||
| 322 | { | ||
| 323 | struct subtitle_part *sp; | ||
| 324 | struct subtitle_list *pos, *tmp; | ||
| 325 | |||
| 326 | for (pos = subtitles; pos != NULL; pos = tmp) { | ||
| 327 | tmp = pos->next; | ||
| 328 | free(pos); | ||
| 329 | } | ||
| 330 | |||
| 331 | subtitles = NULL; | ||
| 332 | list_for_each_entry(sp, &trail, entries) { | ||
| 333 | if (sp->text) { | ||
| 334 | if (pos) { | ||
| 335 | pos->next = xcalloc(sizeof(*pos), 1); | ||
| 336 | pos = pos->next; | ||
| 337 | } else { | ||
| 338 | subtitles = pos = xcalloc(sizeof(*pos), 1); | ||
| 339 | } | ||
| 340 | pos->text = sp->text; | ||
| 341 | } | ||
| 342 | } | ||
| 343 | |||
| 344 | set_dialog_subtitles(subtitles); | ||
| 345 | } | ||
| 346 | |||
| 347 | static void reset_subtitle(void) | ||
| 348 | { | ||
| 349 | struct subtitle_list *pos, *tmp; | ||
| 350 | |||
| 351 | for (pos = subtitles; pos != NULL; pos = tmp) { | ||
| 352 | tmp = pos->next; | ||
| 353 | free(pos); | ||
| 354 | } | ||
| 355 | subtitles = NULL; | ||
| 356 | set_dialog_subtitles(subtitles); | ||
| 357 | } | ||
| 314 | 358 | ||
