menuconfig: Add "breadcrumbs" navigation aid
[firefly-linux-kernel-4.4.55.git] / scripts / kconfig / lxdialog / util.c
index 109d53117d223682254502b51b6414d7404852e2..a0e97c29941023a36ad05708610e62853818255a 100644 (file)
@@ -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.
  */