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

Show the line count too when switching between buffers.
This commit is contained in:
Benno Schulenberg 2020-11-09 13:39:36 +01:00
parent 2b6c08b955
commit ba4f4bdc64
4 changed files with 26 additions and 5 deletions

View File

@ -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;

View File

@ -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. */

View File

@ -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;

View File

@ -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);