gui: Kill pointless initialization of top.lines in main().
[paraslash.git] / gui.c
diff --git a/gui.c b/gui.c
index 18375d9b75cca9a6ceee2c8f1af1949e34169311..e854294ece0a4db3667480c80ed06160dd980f13 100644 (file)
--- a/gui.c
+++ b/gui.c
@@ -34,7 +34,7 @@ static char *stat_content[NUM_STAT_ITEMS];
 
 static int signal_pipe;
 
-static struct win_data {
+static struct gui_window {
        WINDOW *win;
        size_t begx;
        size_t begy;
@@ -53,7 +53,7 @@ static struct ringbuffer *bot_win_rb;
 
 static unsigned scroll_position;
 
-static int curses_active;
+static bool curses_active;
 static pid_t cmd_pid;
 
 static int command_fds[2] = {-1, -1};
@@ -564,7 +564,7 @@ static void shutdown_curses(void)
        if (!curses_active)
                return;
        def_prog_mode();
-       curses_active = 0;
+       curses_active = false;
        endwin();
 }
 
@@ -823,7 +823,7 @@ static void init_colors_or_die(void)
 /* (Re-)initialize the curses library. */
 static void init_curses(void)
 {
-       curses_active = 1;
+       curses_active = true;
        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)
@@ -887,25 +887,25 @@ static int check_key_map_args(void)
        for (i = 0; i < conf.key_map_given; ++i) {
                s = conf.key_map_arg[i];
                if (!(*s))
-                       goto err_out;
+                       goto out;
                free(tmp);
                tmp = para_strdup(s);
                if (!split_key_map(tmp, &handler, &arg))
-                       goto err_out;
+                       goto out;
                if (strlen(handler) != 1)
-                       goto err_out;
+                       goto out;
                if (*handler != 'x'
                        && *handler != 'd'
                        && *handler != 'i'
                        && *handler != 'p')
-                       goto err_out;
+                       goto out;
                if (*handler != 'i')
                        continue;
                if (find_cmd_byname(arg) < 0)
-                       goto err_out;
+                       goto out;
        }
        ret = 0;
-err_out:
+out:
        free(tmp);
        return ret;
 }
@@ -928,13 +928,13 @@ static void handle_signal(int sig)
                }
                return;
        case SIGINT:
-               PARA_WARNING_LOG("caught SIGINT, reset");
+               PARA_WARNING_LOG("caught SIGINT, reset\n");
                /* Nothing to do. SIGINT killed our child which gets noticed
                 * by do_select and resets everything.
                 */
                return;
        case SIGUSR1:
-               PARA_NOTICE_LOG("got SIGUSR1, rereading configuration");
+               PARA_NOTICE_LOG("got SIGUSR1, rereading configuration\n");
                com_reread_conf();
                return;
        case SIGCHLD:
@@ -1039,7 +1039,7 @@ repeat:
                                flags[i] = 0;
                        }
                        if (ret < 0) {
-                               PARA_NOTICE_LOG("closing command fd %d: %s",
+                               PARA_NOTICE_LOG("closing command fd %d: %s\n",
                                        i, para_strerror(-ret));
                                close(command_fds[i]);
                                command_fds[i] = -1;
@@ -1049,7 +1049,7 @@ repeat:
                                        return 0;
                        }
                        if (cbo[i] == COMMAND_BUF_SIZE - 1) {
-                               PARA_NOTICE_LOG("discarding overlong line");
+                               PARA_NOTICE_LOG("discarding overlong line\n");
                                cbo[i] = 0;
                                flags[i] = FELF_DISCARD_FIRST;
                        }
@@ -1110,9 +1110,9 @@ static void send_output(void)
        if (ret < 0)
                goto fail;
        if (do_select(COMMAND_MODE) >= 0)
-               PARA_INFO_LOG("command complete");
+               PARA_INFO_LOG("command complete\n");
        else
-               PARA_NOTICE_LOG("command aborted");
+               PARA_NOTICE_LOG("command aborted\n");
        print_in_bar(COLOR_MSG, " ");
        return;
 fail:
@@ -1350,10 +1350,10 @@ static void com_reread_conf(void)
        };
 
        if (!cf) {
-               PARA_WARNING_LOG("there is no configuration to read");
+               PARA_WARNING_LOG("there is no configuration to read\n");
                return;
        }
-       PARA_INFO_LOG("rereading command line options and config file");
+       PARA_INFO_LOG("rereading command line options and config file\n");
        gui_cmdline_parser_ext(_argc, _argv, &conf, &params);
        /*
         * Despite .print_errors is set to 0, gengetopt will print to stderr
@@ -1362,7 +1362,7 @@ static void com_reread_conf(void)
        shutdown_curses();
        gui_cmdline_parser_config_file(cf, &conf, &params);
        init_curses();
-       PARA_NOTICE_LOG("config file reloaded");
+       PARA_NOTICE_LOG("config file reloaded\n");
        if (check_key_map_args() < 0)
                finish(EXIT_FAILURE);
 }
@@ -1407,7 +1407,7 @@ static void com_help(void)
 static void com_shrink_top_win(void)
 {
        if (top.lines <= theme.top_lines_min) {
-               PARA_WARNING_LOG("can not decrease top window");
+               PARA_WARNING_LOG("can not decrease top window\n");
                return;
        }
        init_wins(top.lines - 1);
@@ -1419,7 +1419,7 @@ static void com_shrink_top_win(void)
 static void com_enlarge_top_win(void)
 {
        if (bot.lines < 3) {
-               PARA_WARNING_LOG("can not increase top window");
+               PARA_WARNING_LOG("can not increase top window\n");
                return;
        }
        init_wins(top.lines + 1);
@@ -1453,7 +1453,7 @@ static void change_theme(int next)
        /* This seems to be needed twice, why? */
        com_refresh();
        com_refresh();
-       PARA_NOTICE_LOG("new theme: %s", theme.name);
+       PARA_NOTICE_LOG("new theme: %s\n", theme.name);
 }
 
 static void com_next_theme(void)
@@ -1553,7 +1553,6 @@ int main(int argc, char *argv[])
                exit(EXIT_FAILURE);
        }
        init_theme_or_die(conf.theme_arg, &theme);
-       top.lines = theme.top_lines_default;
        setup_signal_handling();
        bot_win_rb = ringbuffer_new(RINGBUFFER_SIZE);
        setlocale(LC_CTYPE, "");