diff options
author | Benjamin Poirier | 2013-04-16 10:07:23 -0400 |
---|---|---|
committer | Yann E. MORIN | 2013-04-16 22:00:31 +0200 |
commit | 9a69abf80edf2ea0dac058cab156879d29362788 (patch) | |
tree | b94e9a202805b4de9afce670e17ba720592d2cc5 /scripts/kconfig/lxdialog/util.c | |
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/kconfig/lxdialog/util.c')
-rw-r--r-- | scripts/kconfig/lxdialog/util.c | 45 |
1 files changed, 43 insertions, 2 deletions
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) attr_clear(stdscr, LINES, COLS, dlg.screen.atr); /* Display background title if it exists ... - SLH */ if (dlg.backtitle != NULL) { - int i; + int i, len = 0, skip = 0; + struct subtitle_list *pos; wattrset(stdscr, dlg.screen.atr); mvwaddstr(stdscr, 0, 1, (char *)dlg.backtitle); + + for (pos = dlg.subtitles; pos != NULL; pos = pos->next) { + /* 3 is for the arrow and spaces */ + len += strlen(pos->text) + 3; + } + wmove(stdscr, 1, 1); - for (i = 1; i < COLS - 1; i++) + if (len > COLS - 2) { + const char *ellipsis = "[...] "; + waddstr(stdscr, ellipsis); + skip = len - (COLS - 2 - strlen(ellipsis)); + } + + for (pos = dlg.subtitles; pos != NULL; pos = pos->next) { + if (skip == 0) + waddch(stdscr, ACS_RARROW); + else + skip--; + + if (skip == 0) + waddch(stdscr, ' '); + else + skip--; + + if (skip < strlen(pos->text)) { + waddstr(stdscr, pos->text + skip); + skip = 0; + } else + skip -= strlen(pos->text); + + if (skip == 0) + waddch(stdscr, ' '); + else + skip--; + } + + for (i = len + 1; i < COLS - 1; i++) waddch(stdscr, ACS_HLINE); } wnoutrefresh(stdscr); @@ -302,6 +338,11 @@ void set_dialog_backtitle(const char *backtitle) dlg.backtitle = backtitle; } +void set_dialog_subtitles(struct subtitle_list *subtitles) +{ + dlg.subtitles = subtitles; +} + /* * End using dialog functions. */ |