From 8565030cc6947bbc596d5b097797ce3df35d49b7 Mon Sep 17 00:00:00 2001 From: OIX Date: Tue, 19 Jan 2021 17:46:41 +0100 Subject: [PATCH] minibar: show current path in browser mode Signed-off-by: OIX --- src/nano.c | 2 +- src/prototypes.h | 2 +- src/winio.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/src/nano.c b/src/nano.c index da195ed..9a732bc 100644 --- a/src/nano.c +++ b/src/nano.c @@ -2520,7 +2520,7 @@ int main(int argc, char **argv) #ifndef NANO_TINY if (ISSET(MINIBAR) && lastmessage < REMARK) - minibar(); + minibar(NULL); else #endif /* Update the displayed current cursor position only when there diff --git a/src/prototypes.h b/src/prototypes.h index 86d4684..9c5e5d8 100644 --- a/src/prototypes.h +++ b/src/prototypes.h @@ -595,7 +595,7 @@ void set_blankdelay_to_one(void); char *display_string(const char *buf, size_t column, size_t span, bool isdata, bool isprompt); void titlebar(const char *path); -void minibar(void); +void minibar(const char *path); void statusline(message_type importance, const char *msg, ...); void statusbar(const char *msg); void warn_and_briefly_pause(const char *msg); diff --git a/src/winio.c b/src/winio.c index 3a3103e..a1463b2 100644 --- a/src/winio.c +++ b/src/winio.c @@ -208,7 +208,7 @@ void read_keys_from(WINDOW *win) raw(); if (input == ERR) { - minibar(); + minibar(NULL); as_an_at = TRUE; place_the_cursor(); doupdate(); @@ -1913,6 +1913,11 @@ void show_states_at(WINDOW *window) * directory or the title of help text, that is: whatever is in path. */ void titlebar(const char *path) { +#ifdef ENABLE_BROWSER + if (ISSET(MINIBAR)) + return minibar(path); +#endif + size_t verlen, prefixlen, pathlen, statelen; /* The width of the different title-bar elements, in columns. */ size_t pluglen = 0; @@ -2067,8 +2072,44 @@ void titlebar(const char *path) #ifndef NANO_TINY /* Draw a bar at the bottom with some minimal state information. */ -void minibar(void) +void minibar(const char *path) { +#ifdef ENABLE_BROWSER + /* Show present browser path on minibar. */ + if (path != NULL || currmenu == MBROWSER) { + statusblank = 0; // disable pending blanking as statusline gets overwritten now + /* Draw a colored bar over the full width of the screen. */ + wattron(bottomwin, interface_color_pair[TITLE_BAR]); + mvwprintw(bottomwin, 0, 0, "%*s", COLS, " "); + + if (path != NULL) { + const char *prefix = _("DIR:"); + size_t prefixlen = breadth(prefix) + 1; + size_t pathlen=breadth(path); + if (prefixlen + pathlen > COLS) prefixlen = 0; + + size_t offset = (pathlen + prefixlen > COLS) ? COLS : (COLS - pathlen - prefixlen) / 2; + if (offset < COLS) { + if (prefixlen) { + mvwaddstr(bottomwin, 0, offset, prefix); + waddstr(bottomwin, " "); + } else + wmove(bottomwin, 0, offset); + waddstr(bottomwin, path); + } else + if (8 <= COLS) { + mvwaddstr(bottomwin, 0, 0, "..."); + char *dottify = display_string(path, 3 + pathlen - COLS, COLS, FALSE, FALSE); + waddstr(bottomwin, dottify); + free(dottify); + } + } + + wattroff(bottomwin, interface_color_pair[TITLE_BAR]); + return; + } +#endif + char *thename = NULL, *number_of_lines = NULL, *ranking = NULL; char *location = nmalloc(44); char *hexadecimal = nmalloc(9); -- 2.7.4