Re: [PATCH 2/2] menuconfig: Add "breadcrumbs" navigation aid
From: Yann E. MORIN
Date: Mon Apr 15 2013 - 17:40:11 EST
Benjamin, All,
On Mon, Apr 15, 2013 at 10:13:51AM -0400, Benjamin Poirier wrote:
> Displays a trail of the menu entries used to get to the current menu.
Very good idea, indeed! :-)
> diff --git a/scripts/kconfig/lxdialog/util.c b/scripts/kconfig/lxdialog/util.c
> index 109d531..9a41d78 100644
> --- a/scripts/kconfig/lxdialog/util.c
> +++ b/scripts/kconfig/lxdialog/util.c
> @@ -257,13 +257,54 @@ 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;
> + struct subtitle_list *pos;
>
> wattrset(stdscr, dlg.screen.atr);
> mvwaddstr(stdscr, 0, 1, (char *)dlg.backtitle);
> wmove(stdscr, 1, 1);
> for (i = 1; i < COLS - 1; i++)
> waddch(stdscr, ACS_HLINE);
This means you'll be re-writing over this line with the following
code... (follow at [*], below)
> + for (pos = dlg.subtitles; pos != NULL; pos = pos->next) {
> + /* 3 is for the arrow and spaces */
> + len += strlen(pos->text) + 3;
> + }
> +
> + if (len) {
> + int skip = 0;
> +
> + wmove(stdscr, 1, 1);
> + 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--;
> + }
> + }
[*] ... when you could have drawn only the needed part here:
+ wmove(stdscr, 1, len+1);
+ for (i = len + 1; i < COLS - 1; i++)
+ waddch(stdscr, ACS_HLINE);
[--SNIP--]
Queued (with that change) into:
https://git.gitorious.org/linux-kconfig/linux-kconfig.git yem-kconfig-for-next
Regards,
Yann E. MORIN.
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/