nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] display: make the output of --constantshow less jittery


From: Benno Schulenberg
Subject: [PATCH] display: make the output of --constantshow less jittery
Date: Sun, 14 Mar 2021 16:24:21 +0100

That is: reserve for the current line and current character the number
of positions needed for the total number of lines and characters, and
reserve two positions for both the current column and the total number
of columns.  This will keep all nine numbers in the output in the same
place -- as long as there are no lines with more than 99 columns.  In
this latter case there will still be some jitter, but all-in-all the
output is much stabler than it was.

Suggested-by: Mike Frysinger <vapier@gentoo.org>
---
 src/winio.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/winio.c b/src/winio.c
index f7eaf1d0..9ece36a3 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -3478,9 +3478,11 @@ void report_cursor_position(void)
        charpct = (openfile->totsize == 0) ? 0 : 100 * sum / openfile->totsize;
 
        statusline(INFO,
-                       _("line %zd/%zd (%d%%), col %zu/%zu (%d%%), char 
%zu/%zu (%d%%)"),
+                       _("line %*zd/%zd (%2d%%), col %2zu/%2zu (%3d%%), char 
%*zu/%zu (%2d%%)"),
+                       digits(openfile->filebot->lineno),
                        openfile->current->lineno, openfile->filebot->lineno, 
linepct,
-                       column, fullwidth, colpct, sum, openfile->totsize, 
charpct);
+                       column, fullwidth, colpct,
+                       digits(openfile->totsize), sum, openfile->totsize, 
charpct);
 }
 
 /* Highlight the text between the given two columns on the current line. */
-- 
2.29.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]