From 2b6c08b955f90f9d3c2a31a7c3471797c3cfb353 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sun, 16 Aug 2020 11:24:13 +0200 Subject: [PATCH] minibar: add an [x/y] "counter" when multiple files are open --- src/winio.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/winio.c b/src/winio.c index 53a61843..f6a64322 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2072,7 +2072,7 @@ void minibar(void) char *thisline = openfile->current->data; char *hexadecimal = nmalloc(9); char *location = nmalloc(44); - char *thename; + char *thename = NULL, *ranking = NULL; wchar_t widecode; /* Draw a colored bar over the full width of the screen. */ @@ -2088,6 +2088,14 @@ void minibar(void) mvwaddstr(bottomwin, 0, 2, thename); waddstr(bottomwin, openfile->modified ? " *" : " "); +#ifdef ENABLE_MULTIBUFFER + if (openfile->next != openfile) { + ranking = nmalloc(24); + sprintf(ranking, " [%i/%i]", buffer_number(openfile), buffer_number(startfile->prev)); + waddstr(bottomwin, ranking); + } +#endif + /* Display the line/column position of the cursor. */ sprintf(location, "%zi,%lu", openfile->current->lineno, xplustabs() + 1); mvwaddstr(bottomwin, 0, COLS - 21 - strlen(location), location); @@ -2114,6 +2122,7 @@ void minibar(void) free(hexadecimal); free(location); free(thename); + free(ranking); } #endif /* NANO_TINY */