nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit ba4f4bdc6406d7a747f35ea204f0ee8b43508f90
parent 2b6c08b955f90f9d3c2a31a7c3471797c3cfb353
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Mon,  9 Nov 2020 13:39:36 +0100

minibar: show the line count in the bar (at startup and when saving)

Show the line count too when switching between buffers.

Diffstat:
Msrc/files.c | 13++++++++++++-
Msrc/global.c | 3++-
Msrc/prototypes.h | 2+-
Msrc/winio.c | 13+++++++++++--
4 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/src/files.c b/src/files.c @@ -501,7 +501,13 @@ void mention_name_and_linecount(void) { size_t count = openfile->filebot->lineno - (openfile->filebot->data[0] == '\0' ? 1 : 0); + #ifndef NANO_TINY + if (ISSET(MINIBAR)) { + report_size = TRUE; + return; + } + if (openfile->fmt != NIX_FILE) /* TRANSLATORS: First %s is file name, second %s is file format. */ statusline(HUSH, P_("%s -- %zu line (%s)", "%s -- %zu lines (%s)", count), @@ -1982,8 +1988,13 @@ bool write_file(const char *name, FILE *thefile, bool tmp, titlebar(NULL); } +#ifndef NANO_TINY + if (ISSET(MINIBAR) && fullbuffer && !tmp) + report_size = TRUE; + else +#endif if (!tmp) - statusline(HUSH, P_("Wrote %zu line", "Wrote %zu lines", + statusline(REMARK, P_("Wrote %zu line", "Wrote %zu lines", lineswritten), lineswritten); retval = TRUE; diff --git a/src/global.c b/src/global.c @@ -49,7 +49,8 @@ bool we_are_running = FALSE; /* Becomes TRUE as soon as all options and files have been read. */ bool more_than_one = FALSE; /* Whether more than one buffer is or has been open. */ - +bool report_size = TRUE; + /* Whether to show the number of lines when the minibar is used. */ bool ran_a_tool = FALSE; /* Whether a tool has been run at the Execute-Command prompt. */ diff --git a/src/prototypes.h b/src/prototypes.h @@ -36,7 +36,7 @@ extern bool bracketed_paste; extern bool we_are_running; extern bool more_than_one; - +extern bool report_size; extern bool ran_a_tool; extern bool inhelp; diff --git 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 = NULL, *ranking = NULL; + char *thename = NULL, *number_of_lines = NULL, *ranking = NULL; wchar_t widecode; /* Draw a colored bar over the full width of the screen. */ @@ -2088,8 +2088,16 @@ void minibar(void) mvwaddstr(bottomwin, 0, 2, thename); waddstr(bottomwin, openfile->modified ? " *" : " "); + if (report_size) { + size_t count = openfile->filebot->lineno - (openfile->filebot->data[0] == '\0'); + + number_of_lines = nmalloc(44); + sprintf(number_of_lines, P_(" (%zu line)", " (%zu lines)", count), count); + waddstr(bottomwin, number_of_lines); + report_size = FALSE; + } #ifdef ENABLE_MULTIBUFFER - if (openfile->next != openfile) { + else if (openfile->next != openfile) { ranking = nmalloc(24); sprintf(ranking, " [%i/%i]", buffer_number(openfile), buffer_number(startfile->prev)); waddstr(bottomwin, ranking); @@ -2119,6 +2127,7 @@ void minibar(void) wattroff(bottomwin, interface_color_pair[TITLE_BAR]); wrefresh(bottomwin); + free(number_of_lines); free(hexadecimal); free(location); free(thename);