cosmetically refactor statusbar()

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3052 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
David Lawrence Ramsey 2005-10-27 03:35:42 +00:00
parent 3d12f0f53d
commit 874703be5f
1 changed files with 28 additions and 29 deletions

View File

@ -2925,6 +2925,11 @@ void set_modified(void)
void statusbar(const char *msg, ...) void statusbar(const char *msg, ...)
{ {
va_list ap; va_list ap;
char *bar, *foo;
size_t start_x, foo_len;
#if !defined(NANO_SMALL) && defined(ENABLE_NANORC)
bool old_whitespace;
#endif
va_start(ap, msg); va_start(ap, msg);
@ -2939,40 +2944,34 @@ void statusbar(const char *msg, ...)
/* Blank out the line. */ /* Blank out the line. */
blank_statusbar(); blank_statusbar();
{
char *bar, *foo;
size_t start_x = 0, foo_len;
#if !defined(NANO_SMALL) && defined(ENABLE_NANORC) #if !defined(NANO_SMALL) && defined(ENABLE_NANORC)
bool old_whitespace = ISSET(WHITESPACE_DISPLAY); old_whitespace = ISSET(WHITESPACE_DISPLAY);
UNSET(WHITESPACE_DISPLAY);
UNSET(WHITESPACE_DISPLAY);
#endif #endif
bar = charalloc(mb_cur_max() * (COLS - 3)); bar = charalloc(mb_cur_max() * (COLS - 3));
vsnprintf(bar, mb_cur_max() * (COLS - 3), msg, ap); vsnprintf(bar, mb_cur_max() * (COLS - 3), msg, ap);
va_end(ap); va_end(ap);
foo = display_string(bar, 0, COLS - 4, FALSE); foo = display_string(bar, 0, COLS - 4, FALSE);
#if !defined(NANO_SMALL) && defined(ENABLE_NANORC) #if !defined(NANO_SMALL) && defined(ENABLE_NANORC)
if (old_whitespace) if (old_whitespace)
SET(WHITESPACE_DISPLAY); SET(WHITESPACE_DISPLAY);
#endif #endif
free(bar); free(bar);
foo_len = strlenpt(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);
wattron(bottomwin, A_REVERSE); wattron(bottomwin, A_REVERSE);
waddstr(bottomwin, "[ ");
waddstr(bottomwin, "[ "); waddstr(bottomwin, foo);
waddstr(bottomwin, foo); free(foo);
free(foo); waddstr(bottomwin, " ]");
waddstr(bottomwin, " ]"); wattroff(bottomwin, A_REVERSE);
wattroff(bottomwin, A_REVERSE); wnoutrefresh(bottomwin);
wnoutrefresh(bottomwin); reset_cursor();
reset_cursor(); wnoutrefresh(edit);
wnoutrefresh(edit); /* Leave the cursor at its position in the edit window, not in
/* Leave the cursor at its position in the edit window, not * the statusbar. */
* in the statusbar. */
}
disable_cursorpos = TRUE; disable_cursorpos = TRUE;