Commit 297851a6 authored by David Lawrence Ramsey's avatar David Lawrence Ramsey
Browse files

in titlebar(), make sure that the (mv)?waddnstr() calls take the proper

number of bytes when using multibyte characters, so that multibyte
strings aren't prematurely cut off; also allow the "View" state to be
displayed when a filename is passed in, in case we're in multibuffer
mode and inside the file browser


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2424 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
parent cb4f14b8
Showing with 17 additions and 6 deletions
+17 -6
......@@ -40,6 +40,14 @@ CVS code -
regexec_safe()
- Rename to safe_regexec() for consistency. (DLR)
- winio.c:
titlebar()
- Make sure that the (mv)?waddnstr() calls take the proper
number of bytes when using multibyte characters, so that
multibyte strings aren't prematurely cut off. (DLR, found by
Jordi)
- Allow the "View" state to be displayed when a filename is
passed in, in case we're in multibuffer mode and inside the
file browser. (DLR)
help_line_len()
- Make the text display more flexible, and closer to what nano
1.2.x does. (DLR)
......
......@@ -2730,7 +2730,6 @@ void titlebar(const char *path)
assert(COLS >= 0);
wattron(topwin, A_REVERSE);
blank_titlebar();
if (COLS <= 5 || COLS - 5 < verlen)
......@@ -2752,7 +2751,7 @@ void titlebar(const char *path)
if (ISSET(MODIFIED))
state = _("Modified");
else if (path == NULL && ISSET(VIEW_MODE))
else if (ISSET(VIEW_MODE))
state = _("View");
else {
if (space > 0)
......@@ -2760,6 +2759,7 @@ void titlebar(const char *path)
state = &hblank[COLS - statelen];
}
statelen = strnlenpt(state, COLS);
/* We need a space before state. */
if ((ISSET(MODIFIED) || ISSET(VIEW_MODE)) && statelen < COLS)
statelen++;
......@@ -2783,6 +2783,7 @@ void titlebar(const char *path)
assert(statelen < space);
prefixlen = strnlenpt(prefix, space - statelen);
/* If newfie is FALSE, we need a space after prefix. */
if (!newfie && prefixlen + statelen < space)
prefixlen++;
......@@ -2794,6 +2795,7 @@ void titlebar(const char *path)
else
space = 0;
/* space is now the room we have for the file name. */
if (!newfie) {
size_t lenpt = strlenpt(path), start_col;
......@@ -2814,7 +2816,7 @@ void titlebar(const char *path)
/* There is room for the whole filename, so we center it. */
waddnstr(topwin, hblank, (space - exppathlen) / 3);
waddnstr(topwin, prefix, prefixlen);
waddnstr(topwin, prefix, actual_x(prefix, prefixlen));
if (!newfie) {
assert(strlenpt(prefix) + 1 == prefixlen);
......@@ -2823,7 +2825,7 @@ void titlebar(const char *path)
}
} else {
/* We will say something like "File: ...ename". */
waddnstr(topwin, prefix, prefixlen);
waddnstr(topwin, prefix, actual_x(prefix, prefixlen));
if (space <= -3 || newfie)
goto the_end;
waddch(topwin, ' ');
......@@ -2837,12 +2839,13 @@ void titlebar(const char *path)
free(exppath);
if (COLS <= 1 || statelen >= COLS - 1)
mvwaddnstr(topwin, 0, 0, state, COLS);
mvwaddnstr(topwin, 0, 0, state, actual_x(state, COLS));
else {
assert(COLS - statelen - 2 >= 0);
mvwaddch(topwin, 0, COLS - statelen - 2, ' ');
mvwaddnstr(topwin, 0, COLS - statelen - 1, state, statelen);
mvwaddnstr(topwin, 0, COLS - statelen - 1, state,
actual_x(state, statelen));
}
wattroff(topwin, A_REVERSE);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment