* print aligned string to curses window. This function always prints
* exactly len chars.
*/
-static int align_str(WINDOW* win, const char *string, unsigned int len,
+static int align_str(WINDOW* win, char *str, unsigned int len,
unsigned int align)
{
- int num; /* of spaces */
- char *str;
+ int i, num; /* of spaces */
- if (!win || !string)
+ if (!win || !str)
return -1;
- num = len - strlen(string);
- str = para_strdup(string);
+ num = len - strlen(str);
if (num < 0) {
str[len] = '\0';
num = 0;
}
+ /* replace newlines by spaces */
+ for (i = 0; i < len; i++) {
+ if (str[i] == '\n')
+ str[i] = ' ';
+ }
if (align == LEFT) {
waddstr(win, str);
add_spaces(win, num);
waddstr(win, str[0]? str: "");
add_spaces(win, num - num / 2);
}
- free(str);
return 1;
}
*/
static void print_status_bar(void)
{
+ char *tmp;
+
if (!curses_active)
return;
+ tmp = para_strdup(STANDARD_STATUS_BAR);
wmove(sb.win, 0, 0);
- align_str(sb.win, STANDARD_STATUS_BAR, sb.cols, CENTER);
+ align_str(sb.win, tmp, sb.cols, CENTER);
+ free(tmp);
wrefresh(sb.win);
}
wrefresh(top.win);
}
-/*
- * print status line if line starts with known command.
- */
static int update_item(int item_num, char *buf)
{
free(stat_content[item_num]);