nano-devel
[Top][All Lists]
Advanced

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

Re: [Nano-devel] status bar buglet


From: David Lawrence Ramsey
Subject: Re: [Nano-devel] status bar buglet
Date: Tue, 21 Jun 2005 19:10:59 -0400
User-agent: Mozilla Thunderbird 1.0.2 (X11/20050317)

> Jordi Mallach wrote:
>
> >On a tiny build with slang2 in Debian, I see the status bar says:
> >
> >GNU nano 1.3.7  Modif        New Buffer                Modified
> >
> >That "Modif" bit is popping up somehow there, and apparently is related
> >to the switch to libslang2 of two days ago in Debian.
>
> After some testing on my machine, I've noticed that the "Save modified
> buffer (answering No will DESTROY CHANGES)?" prompt also has part of the
> getopt string ("h?ABC:E", etc.) displayed after it.  I'll look into it.

It appears that both problems are caused by mvwaddnstr() calls that
treat one character as one byte.  I've fixed this in the attached patch,
which seems to work both on natura and my machine.  (There's also a fix
for a potential displaying of a non-null-terminated string in the file
browser.  I know it doesn't apply to nano-tiny, but I figured that as
long as I was fixing string displays, I might as well deal with it.)

diff -ur nano-1.3.7/src/files.c nano-1.3.7-fixed/src/files.c
--- nano-1.3.7/src/files.c      2005-04-10 23:51:22.000000000 -0400
+++ nano-1.3.7-fixed/src/files.c        2005-06-21 18:55:43.000000000 -0400
@@ -2705,9 +2705,10 @@
                        foo[foo_len] = '\0';
                    } else
                        strcpy(foo, "--");
-               } else if (S_ISDIR(st.st_mode))
+               } else if (S_ISDIR(st.st_mode)) {
                    strncpy(foo, _("(dir)"), foo_len);
-               else if (st.st_size < (1 << 10)) /* less than 1 k. */
+                   foo[foo_len] = '\0';
+               } else if (st.st_size < (1 << 10)) /* less than 1 k. */
                    sprintf(foo, "%4u  B", (unsigned int)st.st_size);
                else if (st.st_size < (1 << 20)) /* less than 1 meg. */
                    sprintf(foo, "%4u KB",
diff -ur nano-1.3.7/src/winio.c nano-1.3.7-fixed/src/winio.c
--- nano-1.3.7/src/winio.c      2005-04-10 23:51:22.000000000 -0400
+++ nano-1.3.7-fixed/src/winio.c        2005-06-21 18:55:25.000000000 -0400
@@ -2749,7 +2749,8 @@
     if (COLS > 4) {
        /* The version message should only take up 1/3 of the screen
         * minus one column. */
-       mvwaddnstr(topwin, 0, 2, VERMSG, (COLS / 3) - 3);
+       mvwaddnstr(topwin, 0, 2, VERMSG, actual_x(VERMSG,
+               (COLS / 3) - 3));
        waddstr(topwin, "  ");
     }
 
@@ -3687,7 +3688,7 @@
     wattron(bottomwin, A_REVERSE);
 
     blank_statusbar();
-    mvwaddnstr(bottomwin, 0, 0, msg, COLS - 1);
+    mvwaddnstr(bottomwin, 0, 0, msg, actual_x(msg, COLS - 1));
 
     wattroff(bottomwin, A_REVERSE);
 

reply via email to

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