static unsigned scroll_position;
-static bool curses_active;
static pid_t cmd_pid;
static int command_fds[2] = {-1, -1};
return -1;
}
+/* isendwin() returns false before initscr() was called */
+static bool curses_active(void)
+{
+ return top.win && !isendwin();
+}
+
/* taken from mutt */
static char *km_keyname(int c)
{
char *msg;
va_list ap;
- if (!curses_active)
+ if (!curses_active())
return;
wattron(in.win, COLOR_PAIR(color));
va_start(ap, fmt);
char *msg;
va_list ap;
- if (!curses_active)
+ if (!curses_active())
return;
va_start(ap, fmt);
xvasprintf(&msg, fmt, ap);
{
int color = *(int *)data? COLOR_ERRMSG : COLOR_OUTPUT;
- if (!curses_active)
+ if (!curses_active())
return 1;
rb_add_entry(color, para_strdup(line));
return 1;
va_list ap;
unsigned bytes;
- if (ll < loglevel || !curses_active)
+ if (ll < loglevel || !curses_active())
return;
switch (ll) {
case LL_DEBUG:
static void shutdown_curses(void)
{
- if (!curses_active)
- return;
def_prog_mode();
- curses_active = false;
endwin();
}
struct stat_item_data d = theme.data[i];
char *c = stat_content[i];
- if (!curses_active || !d.len || !c)
+ if (!curses_active() || !d.len || !c)
return;
tmp = make_message("%s%s%s", d.prefix, c, d.postfix);
wmove(top.win, d.y * top.lines / 100, d.x * COLS / 100);
{
int i;
- if (!curses_active)
+ if (!curses_active())
return;
FOR_EACH_STATUS_ITEM(i)
print_stat_item(i);
/* (Re-)initialize the curses library. */
static void init_curses(void)
{
- curses_active = true;
+ if (curses_active())
+ return;
if (top.win && refresh() == ERR) /* refresh is really needed */
msg_n_exit(EXIT_FAILURE, "refresh() failed\n");
if (LINES < theme.lines_min || COLS < theme.cols_min)
"only the good die young (caught SIGTERM))\n");
return;
case SIGWINCH:
- if (curses_active) {
+ if (curses_active()) {
shutdown_curses();
init_curses();
redraw_bot_win();