X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=gui.c;h=c335250fee77daccc61868963e6135a220337610;hp=126b40fe6861b8d61ff6524debcb40ebf7c234b3;hb=8d7bdabd22ed7750086ca660754d8d881dae3832;hpb=84f3cda92d0fb3d072b1a2d9bf8c2156c18d6398 diff --git a/gui.c b/gui.c index 126b40fe..c335250f 100644 --- a/gui.c +++ b/gui.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1998-2007 Andre Noll + * Copyright (C) 1998-2008 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -45,7 +45,7 @@ struct rb_entry { size_t len; int color; }; -void *bot_win_rb; +struct ringbuffer *bot_win_rb; #define NUM_LINES(len) (1 + (len) / bot.cols) static unsigned scroll_position; @@ -60,15 +60,15 @@ static struct gui_args_info conf; enum {GETCH_MODE, COMMAND_MODE, EXTERNAL_MODE}; -#define COLOR_STATUSBAR 32 -#define COLOR_COMMAND 33 -#define COLOR_OUTPUT 34 -#define COLOR_MSG 35 -#define COLOR_ERRMSG 36 -#define COLOR_WELCOME 37 -#define COLOR_SEPARATOR 38 -#define COLOR_TOP 39 -#define COLOR_BOT 40 +#define COLOR_STATUSBAR 52 +#define COLOR_COMMAND 53 +#define COLOR_OUTPUT 54 +#define COLOR_MSG 55 +#define COLOR_ERRMSG 56 +#define COLOR_WELCOME 57 +#define COLOR_SEPARATOR 58 +#define COLOR_TOP 59 +#define COLOR_BOT 60 struct gui_command { const char *key; @@ -649,7 +649,6 @@ static void print_stat_item(int i) if (!curses_active || !d.len || !c) return; tmp = make_message("%s%s%s", d.prefix, c, d.postfix); -// PARA_DEBUG_LOG("%s: read: %s\n", __func__, tmp); wmove(top.win, d.y * top.lines / 100, d.x * COLS / 100); wrefresh(top.win); wattron(top.win, COLOR_PAIR(i + 1)); @@ -681,6 +680,7 @@ static void clear_all_items(void) static void init_colors(void) { int i; + if (!has_colors()) msg_n_exit(EXIT_FAILURE, "Error: No color term\n"); start_color(); @@ -749,7 +749,9 @@ static int check_stat_line(char *line, __a_unused void *data) // PARA_INFO_LOG("%s: checking: %s\n", __func__, line); i = stat_line_valid(line); if (i >= 0) { - line += strlen(status_item_list[i]) + 2; + line += strlen(status_item_list[i]) + 1; + if (*line == ' ') + line++; free(stat_content[i]); stat_content[i] = para_strdup(line); print_stat_item(i); @@ -964,8 +966,15 @@ check_return: */ static int send_output(void) { + int ret; + if (command_pipe < 0) return 0; + ret = mark_fd_nonblocking(command_pipe); + if (ret < 0) { + close(command_pipe); + return ret; + } if (do_select(COMMAND_MODE) >= 0) PARA_INFO_LOG("%s", "command complete"); else @@ -977,7 +986,7 @@ static int send_output(void) static int client_cmd_cmdline(char *cmd) { int ret, fds[3] = {0, 1, 0}; - char *c = make_message(BINDIR "/para_client %s", cmd); + char *c = make_message(BINDIR "/para_client -- %s", cmd); outputf(COLOR_COMMAND, "%s", c); print_in_bar(COLOR_MSG, "executing client command, hit any key to abort\n"); @@ -986,7 +995,6 @@ static int client_cmd_cmdline(char *cmd) if (ret < 0) return -1; command_pipe = fds[1]; - mark_fd_nonblock(command_pipe); return send_output(); } @@ -1002,7 +1010,6 @@ static int display_cmd(char *cmd) if (para_exec_cmdline_pid(&cmd_pid, cmd, fds) < 0) return -1; command_pipe = fds[1]; - mark_fd_nonblock(command_pipe); return send_output(); }