static struct gui_window {
WINDOW *win;
+ bool needs_update;
} top, bot, sb, in, sep;
#define RINGBUFFER_SIZE 512
return 1;
}
+static void refresh_window(struct gui_window *gw)
+{
+ gw->needs_update = true;
+}
+
+static bool window_update_needed(void)
+{
+ return top.needs_update || bot.needs_update || sb.needs_update ||
+ in.needs_update || sep.needs_update;
+}
+
__printf_2_3 static void print_in_bar(int color, const char *fmt,...)
{
char *msg;
wmove(in.win, 0, 0);
align_str(in.win, msg, get_num_cols(&in), LEFT);
free(msg);
- wrefresh(in.win);
+ refresh_window(&in);
}
static void print_status_bar(void)
waddstr(bot.win, rbe->msg);
}
out:
- wrefresh(bot.win);
+ refresh_window(&bot);
}
static void rb_add_entry(int color, char *msg)
xvasprintf(&msg, fmt, ap);
va_end(ap);
rb_add_entry(color, msg);
- wrefresh(bot.win);
+ refresh_window(&bot);
}
static int add_output_line(char *line, void *data)
if (bytes > 0 && msg[bytes - 1] == '\n')
msg[bytes - 1] = '\0'; /* cut trailing newline */
rb_add_entry(color, msg);
- wrefresh(bot.win);
+ refresh_window(&bot);
} else if (exec_pid <= 0) /* no external command running */
vfprintf(stderr, fmt, ap);
va_end(ap);
return;
tmp = make_message("%s%s%s", d.prefix, c, d.postfix);
wmove(top.win, d.y * top_lines / 100, d.x * COLS / 100);
- wrefresh(top.win);
wattron(top.win, COLOR_PAIR(i + 1));
align_str(top.win, tmp, d.len * COLS / 100, d.align);
free(tmp);
- wrefresh(top.win);
+ refresh_window(&top);
}
static int update_item(int item_num, char *buf)
ct->cbo[i] = for_each_line(ct->flags[i], ct->command_buf[i],
ct->cbo[i], add_output_line, &i);
if (sz != ct->cbo[i]) { /* at least one line found */
- wrefresh(bot.win);
+ refresh_window(&bot);
ct->flags[i] = 0;
}
if (ret < 0 || exec_pid == 0) {
{
if (exec_status() != EXEC_XCMD)
para_fd_set(STDIN_FILENO, &s->rfds, &s->max_fileno);
+ if (window_update_needed())
+ sched_min_delay(s);
}
/* read from command pipe and print data to bot window */
if (exs == EXEC_XCMD)
return 0;
+ if (window_update_needed()) {
+ if (top.needs_update)
+ assert(wnoutrefresh(top.win) == OK);
+ if (bot.needs_update)
+ assert(wnoutrefresh(bot.win) == OK);
+ if (sep.needs_update)
+ assert(wnoutrefresh(sep.win) == OK);
+ if (sb.needs_update)
+ assert(wnoutrefresh(sb.win) == OK);
+ if (in.needs_update)
+ assert(wnoutrefresh(in.win) == OK);
+ doupdate();
+ top.needs_update = bot.needs_update = sb.needs_update =
+ in.needs_update = sep.needs_update = false;
+ }
ret = wgetch(top.win);
if (ret == ERR || ret == KEY_RESIZE)
return 0;
wmove(bot.win, bot_lines - rbe_lines, 0);
wattron(bot.win, COLOR_PAIR(rbe->color));
waddstr(bot.win, rbe->msg);
- wrefresh(bot.win);
+ refresh_window(&bot);
print_scroll_msg();
}
break;
i--;
}
- wrefresh(bot.win);
+ refresh_window(&bot);
print_scroll_msg();
return;
err_out: