]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
gui: Rename COMMAND/EXTERNAL/GETCH mode.
authorAndre Noll <maan@systemlinux.org>
Sat, 29 Mar 2014 17:31:41 +0000 (18:31 +0100)
committerAndre Noll <maan@systemlinux.org>
Sun, 4 May 2014 13:48:54 +0000 (15:48 +0200)
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

diff --git a/gui.c b/gui.c
index ef9410cc26dc6a26268a9873202495bd43ffaa7d..40e93b0c392ee9d96a7dbef59869ecfd8ea52898 100644 (file)
--- 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);