static struct gui_args_info conf;
static int loglevel;
-enum gui_select_mode{GETCH_MODE, COMMAND_MODE, EXTERNAL_MODE};
+enum cmd_status {
+ CMDS_IDLE, /* no command running */
+ CMDS_DCMD, /* para or display command running */
+ CMDS_XCMD, /* external command running */
+};
/**
* Codes for various colors.
#define COMMAND_BUF_SIZE 32768
-static enum gui_select_mode get_select_mode(void)
+static enum cmd_status cmd_status(void)
{
if (command_fds[0] >= 0 || command_fds[1] >= 0)
- return COMMAND_MODE;
+ return CMDS_DCMD;
if (cmd_pid > 0)
- return EXTERNAL_MODE;
- return GETCH_MODE;
+ return CMDS_XCMD;
+ return CMDS_IDLE;
}
static void command_pre_select(fd_set *rfds, int *max_fileno)
{
- enum gui_select_mode mode = get_select_mode();
+ enum cmd_status cmds = cmd_status();
- if (mode != COMMAND_MODE)
+ if (cmds != CMDS_DCMD)
return;
if (command_fds[0] >= 0)
para_fd_set(command_fds[0], rfds, max_fileno);
static char command_buf[2][COMMAND_BUF_SIZE];
static int cbo[2]; /* command buf offsets */
static unsigned flags[2]; /* for for_each_line() */
- enum gui_select_mode mode = get_select_mode();
+ enum cmd_status cmds = cmd_status();
- if (mode != COMMAND_MODE)
+ if (cmds != CMDS_DCMD)
return;
for (i = 0; i < 2; i++) {
size_t sz;
static void input_pre_select(fd_set *rfds, int *max_fileno)
{
- enum gui_select_mode mode = get_select_mode();
+ enum cmd_status cmds = cmd_status();
- if (mode == GETCH_MODE || mode == COMMAND_MODE)
+ if (cmds != CMDS_XCMD)
para_fd_set(STDIN_FILENO, rfds, max_fileno);
}
static void input_post_select(void)
{
int ret;
- enum gui_select_mode mode = get_select_mode();
+ enum cmd_status cmds = cmd_status();
- if (mode == EXTERNAL_MODE)
+ if (cmds == CMDS_XCMD)
return;
ret = wgetch(top.win);
if (ret == ERR || ret == KEY_RESIZE)
return;
- if (mode == GETCH_MODE)
+ if (cmds == CMDS_IDLE)
return handle_command(ret);
if (cmd_pid != 0)
kill(cmd_pid, SIGTERM);