fix statusbar() and onekey() to properly handle multibyte strings too
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2196 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
93c4a5656b
commit
1903ace275
|
@ -56,8 +56,8 @@ CVS code -
|
||||||
move_right(), and display_string_len(); changes to do_left(),
|
move_right(), and display_string_len(); changes to do_left(),
|
||||||
do_right(), do_delete(), breakable(), break_line(),
|
do_right(), do_delete(), breakable(), break_line(),
|
||||||
do_output(), get_buffer(), unget_input(), actual_x(),
|
do_output(), get_buffer(), unget_input(), actual_x(),
|
||||||
strnlenpt(), display_string(), titlebar(), and do_credits().
|
strnlenpt(), display_string(), titlebar(), statusbar(),
|
||||||
(David Benbennick and DLR)
|
onekey(), and do_credits(). (David Benbennick and DLR)
|
||||||
- cut.c:
|
- cut.c:
|
||||||
do_cut_text()
|
do_cut_text()
|
||||||
- If keep_cutbuffer is FALSE, only blow away the text in the
|
- If keep_cutbuffer is FALSE, only blow away the text in the
|
||||||
|
|
18
src/winio.c
18
src/winio.c
|
@ -2637,7 +2637,7 @@ void statusbar(const char *msg, ...)
|
||||||
SET(WHITESPACE_DISPLAY);
|
SET(WHITESPACE_DISPLAY);
|
||||||
#endif
|
#endif
|
||||||
free(bar);
|
free(bar);
|
||||||
foo_len = strlen(foo);
|
foo_len = strlenpt(foo);
|
||||||
start_x = (COLS - foo_len - 4) / 2;
|
start_x = (COLS - foo_len - 4) / 2;
|
||||||
|
|
||||||
wmove(bottomwin, 0, start_x);
|
wmove(bottomwin, 0, start_x);
|
||||||
|
@ -2726,14 +2726,22 @@ void bottombars(const shortcut *s)
|
||||||
* the whole string! We do not bother padding the entry with blanks. */
|
* the whole string! We do not bother padding the entry with blanks. */
|
||||||
void onekey(const char *keystroke, const char *desc, size_t len)
|
void onekey(const char *keystroke, const char *desc, size_t len)
|
||||||
{
|
{
|
||||||
assert(keystroke != NULL && desc != NULL && len >= 0);
|
assert(keystroke != NULL && desc != NULL);
|
||||||
|
|
||||||
|
size_t keystroke_len = strlenpt(keystroke) + 1;
|
||||||
|
|
||||||
wattron(bottomwin, A_REVERSE);
|
wattron(bottomwin, A_REVERSE);
|
||||||
waddnstr(bottomwin, keystroke, len);
|
waddnstr(bottomwin, keystroke, actual_x(keystroke, len));
|
||||||
wattroff(bottomwin, A_REVERSE);
|
wattroff(bottomwin, A_REVERSE);
|
||||||
len -= strlen(keystroke) + 1;
|
|
||||||
|
if (len > keystroke_len)
|
||||||
|
len -= keystroke_len;
|
||||||
|
else
|
||||||
|
len = 0;
|
||||||
|
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
waddch(bottomwin, ' ');
|
waddch(bottomwin, ' ');
|
||||||
waddnstr(bottomwin, desc, len);
|
waddnstr(bottomwin, desc, actual_x(desc, len));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue