From dbd982ace13078dc6615fa66ccb5dc8134f6ec35 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sat, 29 Mar 2014 18:31:41 +0100 Subject: [PATCH] gui: Rename COMMAND/EXTERNAL/GETCH mode. This value tells if there is a command executing, and if so, whether it is an external command or a display command. Hence "cmd_status" is to be more to the point. --- gui.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/gui.c b/gui.c index ef9410cc..40e93b0c 100644 --- a/gui.c +++ b/gui.c @@ -53,7 +53,11 @@ static int stat_pipe = -1; 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. @@ -981,20 +985,20 @@ success: #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); @@ -1008,9 +1012,9 @@ static void command_post_select(fd_set *rfds) 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; @@ -1048,9 +1052,9 @@ static void command_post_select(fd_set *rfds) 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); } @@ -1152,14 +1156,14 @@ static void handle_command(int c) 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); -- 2.39.5