[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 7/7] minibar: show the line count in the bar (at startup and when
From: |
Benno Schulenberg |
Subject: |
[PATCH 7/7] minibar: show the line count in the bar (at startup and when switching) |
Date: |
Tue, 15 Dec 2020 10:44:09 +0100 |
---
src/files.c | 13 ++++++++++++-
src/global.c | 3 ++-
src/prototypes.h | 2 +-
src/winio.c | 13 +++++++++++--
4 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/src/files.c b/src/files.c
index 97759434..cd709b72 100644
--- a/src/files.c
+++ b/src/files.c
@@ -500,7 +500,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),
@@ -1981,8 +1987,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
index 8b2bb7ac..b2177665 100644
--- 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
index adfb81d1..97e98308 100644
--- 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
index 81947b19..945ffc69 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -2070,7 +2070,7 @@ void minibar(void)
char *thisline = openfile->current->data;
char *hexadecimal = nmalloc(9);
char *location = nmalloc(44);
- char *ranking = NULL, *thename = NULL;
+ char *number_of_lines = NULL, *ranking = NULL, *thename = NULL;
wchar_t widecode;
/* Draw a colored bar over the full width of the screen. */
@@ -2086,8 +2086,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);
@@ -2117,6 +2125,7 @@ void minibar(void)
wattroff(bottomwin, interface_color_pair[TITLE_BAR]);
wrefresh(bottomwin);
+ free(number_of_lines);
free(hexadecimal);
free(location);
free(thename);
--
2.29.2
- [PATCH 1/7] tweaks: move the displaying of the state letters into a separate function, Benno Schulenberg, 2020/12/15
- [PATCH 2/7] display: add code for showing minimal state-information bar at the bottom, Benno Schulenberg, 2020/12/15
- [PATCH 3/7] options: add --minibar and -_ for activating basic state-information bar, Benno Schulenberg, 2020/12/15
- [PATCH 4/7] minibar: show the info bar again some 0.8 seconds after a message, Benno Schulenberg, 2020/12/15
- [PATCH 5/7] feedback: differentiate between remarks, mistakes, and information, Benno Schulenberg, 2020/12/15
- [PATCH 6/7] minibar: add an [x/y] "counter" when multiple files are open, Benno Schulenberg, 2020/12/15
- [PATCH 7/7] minibar: show the line count in the bar (at startup and when switching),
Benno Schulenberg <=