diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/curses/gui-display.c | 34 | ||||
-rw-r--r-- | src/gui/curses/gui-input.c | 49 | ||||
-rw-r--r-- | src/gui/gui-common.c | 4 | ||||
-rw-r--r-- | src/gui/gui.h | 22 |
4 files changed, 92 insertions, 17 deletions
diff --git a/src/gui/curses/gui-display.c b/src/gui/curses/gui-display.c index b978bb38d..15b229040 100644 --- a/src/gui/curses/gui-display.c +++ b/src/gui/curses/gui-display.c @@ -562,7 +562,7 @@ gui_draw_buffer_chat (t_gui_buffer *buffer, int erase) { t_gui_window *ptr_win; t_gui_line *ptr_line; - t_dcc *ptr_dcc; + t_dcc *dcc_first, *dcc_selected, *ptr_dcc; char format_empty[32]; int i, j, lines_used, num_bars; char *unit_name[] = { N_("bytes"), N_("Kb"), N_("Mb"), N_("Gb") }; @@ -594,28 +594,38 @@ gui_draw_buffer_chat (t_gui_buffer *buffer, int erase) if (buffer->dcc) { i = 0; - for (ptr_dcc = dcc_list; ptr_dcc; ptr_dcc = ptr_dcc->next_dcc) + dcc_first = (ptr_win->dcc_first) ? (t_dcc *) ptr_win->dcc_first : dcc_list; + dcc_selected = (ptr_win->dcc_selected) ? (t_dcc *) ptr_win->dcc_selected : dcc_list; + for (ptr_dcc = dcc_first; ptr_dcc; ptr_dcc = ptr_dcc->next_dcc) { if (i >= ptr_win->win_chat_height - 1) break; if ((ptr_dcc->type == DCC_FILE_RECV) || (ptr_dcc->type == DCC_FILE_SEND)) { - gui_window_set_color (ptr_win->win_chat, COLOR_WIN_CHAT); - mvwprintw (ptr_win->win_chat, i, 0, " %-16s %s", + gui_window_set_color (ptr_win->win_chat, + (ptr_dcc == dcc_selected) ? + COLOR_DCC_SELECTED : COLOR_WIN_CHAT); + mvwprintw (ptr_win->win_chat, i, 0, "%s %-16s %s", + (ptr_dcc == dcc_selected) ? ">>" : " ", ptr_dcc->nick, ptr_dcc->filename); if (ptr_dcc->filename_suffix > 0) wprintw (ptr_win->win_chat, " (.%d)", ptr_dcc->filename_suffix); - gui_window_set_color (ptr_win->win_chat, COLOR_WIN_CHAT); - mvwprintw (ptr_win->win_chat, i + 1, 0, " %s ", + gui_window_set_color (ptr_win->win_chat, + (ptr_dcc == dcc_selected) ? + COLOR_DCC_SELECTED : COLOR_WIN_CHAT); + mvwprintw (ptr_win->win_chat, i + 1, 0, "%s %s ", + (ptr_dcc == dcc_selected) ? ">>" : " ", (ptr_dcc->type == DCC_FILE_RECV) ? "--->" : "<---"); gui_window_set_color (ptr_win->win_chat, COLOR_DCC_WAITING + ptr_dcc->status); wprintw (ptr_win->win_chat, "%-10s", dcc_status_string[ptr_dcc->status]); - gui_window_set_color (ptr_win->win_chat, COLOR_WIN_CHAT); + gui_window_set_color (ptr_win->win_chat, + (ptr_dcc == dcc_selected) ? + COLOR_DCC_SELECTED : COLOR_WIN_CHAT); wprintw (ptr_win->win_chat, " [", dcc_status_string[ptr_dcc->status]); if (ptr_dcc->size == 0) @@ -647,10 +657,10 @@ gui_draw_buffer_chat (t_gui_buffer *buffer, int erase) unit_name[num_unit], ((long double) ptr_dcc->size) / ((long double)(unit_divide[num_unit])), unit_name[num_unit]); + ptr_win->dcc_last_displayed = ptr_dcc; i += 2; } } - move (ptr_win->win_y + 1, ptr_win->win_x); } else { @@ -1195,6 +1205,9 @@ gui_draw_buffer_input (t_gui_buffer *buffer, int erase) snprintf (format, 32, "%%-%ds", input_width); mvwprintw (ptr_win->win_input, 0, 0, format, ""); wclrtoeol (ptr_win->win_input); + if (ptr_win == gui_current_window) + move (ptr_win->win_y + ptr_win->win_height - 1, + ptr_win->win_x); } else { @@ -1519,6 +1532,8 @@ gui_curses_resize_handler () /* TODO: manage when some windows are outside new term size */ for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window) { + ptr_win->dcc_first = NULL; + ptr_win->dcc_selected = NULL; if (ptr_win->win_x + ptr_win->win_width == old_width) ptr_win->win_width = new_width - ptr_win->win_x; if (ptr_win->win_y + ptr_win->win_height == old_height) @@ -1720,6 +1735,8 @@ gui_init_colors () (color & A_BOLD) ? A_BOLD : 0; } + init_pair (COLOR_DCC_SELECTED, + cfg_col_dcc_selected & A_CHARTEXT, cfg_col_chat_bg); init_pair (COLOR_DCC_WAITING, cfg_col_dcc_waiting & A_CHARTEXT, cfg_col_chat_bg); init_pair (COLOR_DCC_CONNECTING, @@ -1763,6 +1780,7 @@ gui_init_colors () color_attr[COLOR_WIN_NICK_SEP - 1] = 0; color_attr[COLOR_WIN_NICK_SELF - 1] = cfg_col_nick_self & A_BOLD; color_attr[COLOR_WIN_NICK_PRIVATE - 1] = cfg_col_nick_private & A_BOLD; + color_attr[COLOR_DCC_SELECTED - 1] = cfg_col_dcc_selected & A_BOLD; color_attr[COLOR_DCC_WAITING - 1] = cfg_col_dcc_waiting & A_BOLD; color_attr[COLOR_DCC_CONNECTING - 1] = cfg_col_dcc_connecting & A_BOLD; color_attr[COLOR_DCC_ACTIVE - 1] = cfg_col_dcc_active & A_BOLD; diff --git a/src/gui/curses/gui-input.c b/src/gui/curses/gui-input.c index 25c436dd4..b37d6c816 100644 --- a/src/gui/curses/gui-input.c +++ b/src/gui/curses/gui-input.c @@ -90,7 +90,24 @@ gui_read_keyb () break; /* cursor up */ case KEY_UP: - if (!gui_current_window->buffer->dcc) + if (gui_current_window->buffer->dcc) + { + if (dcc_list) + { + if (gui_current_window->dcc_selected + && ((t_dcc *)(gui_current_window->dcc_selected))->prev_dcc) + { + if (gui_current_window->dcc_selected == + gui_current_window->dcc_first) + gui_current_window->dcc_first = + ((t_dcc *)(gui_current_window->dcc_first))->prev_dcc; + gui_current_window->dcc_selected = + ((t_dcc *)(gui_current_window->dcc_selected))->prev_dcc; + gui_draw_buffer_chat (gui_current_window->buffer, 1); + } + } + } + else { if (gui_current_window->buffer->ptr_history) { @@ -118,7 +135,35 @@ gui_read_keyb () break; /* cursor down */ case KEY_DOWN: - if (!gui_current_window->buffer->dcc) + if (gui_current_window->buffer->dcc) + { + if (dcc_list) + { + if (!gui_current_window->dcc_selected + || ((t_dcc *)(gui_current_window->dcc_selected))->next_dcc) + { + if (gui_current_window->dcc_last_displayed + && (gui_current_window->dcc_selected == + gui_current_window->dcc_last_displayed)) + { + if (gui_current_window->dcc_first) + gui_current_window->dcc_first = + ((t_dcc *)(gui_current_window->dcc_first))->next_dcc; + else + gui_current_window->dcc_first = + dcc_list->next_dcc; + } + if (gui_current_window->dcc_selected) + gui_current_window->dcc_selected = + ((t_dcc *)(gui_current_window->dcc_selected))->next_dcc; + else + gui_current_window->dcc_selected = + dcc_list->next_dcc; + gui_draw_buffer_chat (gui_current_window->buffer, 1); + } + } + } + else { if (gui_current_window->buffer->ptr_history) { diff --git a/src/gui/gui-common.c b/src/gui/gui-common.c index 04ff320c2..454dd02b6 100644 --- a/src/gui/gui-common.c +++ b/src/gui/gui-common.c @@ -99,6 +99,10 @@ gui_window_new (int x, int y, int width, int height) new_window->textview_nicklist = NULL; new_window->textbuffer_nicklist = NULL; + new_window->dcc_first = NULL; + new_window->dcc_selected = NULL; + new_window->dcc_last_displayed = NULL; + new_window->buffer = NULL; new_window->first_line_displayed = 0; diff --git a/src/gui/gui.h b/src/gui/gui.h index aca1d2620..8d9286a3a 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -26,7 +26,7 @@ #define INPUT_BUFFER_BLOCK_SIZE 256 -#define NUM_COLORS 45 +#define NUM_COLORS 46 #define COLOR_WIN_TITLE 1 #define COLOR_WIN_CHAT 2 #define COLOR_WIN_CHAT_TIME 3 @@ -59,12 +59,13 @@ #define COLOR_WIN_NICK_FIRST 30 #define COLOR_WIN_NICK_LAST 39 #define COLOR_WIN_NICK_NUMBER (COLOR_WIN_NICK_LAST - COLOR_WIN_NICK_FIRST + 1) -#define COLOR_DCC_WAITING 40 -#define COLOR_DCC_CONNECTING 41 -#define COLOR_DCC_ACTIVE 42 -#define COLOR_DCC_DONE 43 -#define COLOR_DCC_FAILED 44 -#define COLOR_DCC_ABORTED 45 +#define COLOR_DCC_SELECTED 40 +#define COLOR_DCC_WAITING 41 +#define COLOR_DCC_CONNECTING 42 +#define COLOR_DCC_ACTIVE 43 +#define COLOR_DCC_DONE 44 +#define COLOR_DCC_FAILED 45 +#define COLOR_DCC_ABORTED 46 #define SERVER(buffer) ((t_irc_server *)(buffer->server)) #define CHANNEL(buffer) ((t_irc_channel *)(buffer->channel)) @@ -142,6 +143,8 @@ struct t_gui_buffer /* server/channel */ void *server; /* buffer's server */ void *channel; /* buffer's channel */ + + /* dcc buffer */ int dcc; /* buffer is dcc status */ /* chat content (lines, line is composed by many messages) */ @@ -210,6 +213,11 @@ struct t_gui_window /* windows for Qt GUI */ /* TODO: declare Qt window */ + /* DCC */ + void *dcc_first; /* first dcc displayed */ + void *dcc_selected; /* selected dcc */ + void *dcc_last_displayed; /* last dcc displayed (for scroll) */ + t_gui_buffer *buffer; /* buffer currently displayed in window */ int first_line_displayed; /* = 1 if first line is displayed */ |