summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/curses/gui-display.c1193
-rw-r--r--src/gui/curses/gui-input.c290
-rw-r--r--src/gui/gui-common.c429
-rw-r--r--src/gui/gui.h106
4 files changed, 1041 insertions, 977 deletions
diff --git a/src/gui/curses/gui-display.c b/src/gui/curses/gui-display.c
index 64ac7e8c3..5d15fdb16 100644
--- a/src/gui/curses/gui-display.c
+++ b/src/gui/curses/gui-display.c
@@ -153,138 +153,138 @@ gui_window_set_color (WINDOW *window, int num_color)
}
/*
- * gui_window_has_nicklist: returns 1 if window has nicklist
+ * gui_view_has_nicklist: returns 1 if view has nicklist
*/
int
-gui_window_has_nicklist (t_gui_window *window)
+gui_view_has_nicklist (t_gui_view *view)
{
- return ((window->win_nick != NULL) ? 1 : 0);
+ return (((CHANNEL(view)) && (CHANNEL(view)->type == CHAT_CHANNEL)) ? 1 : 0);
}
/*
- * gui_calculate_pos_size: calculate position and size for a window & sub-win
+ * gui_calculate_pos_size: calculate position and size for a view & subviews
*/
void
-gui_calculate_pos_size (t_gui_window *window)
+gui_calculate_pos_size (t_gui_view *view)
{
int max_length, lines;
int num_nicks, num_op, num_halfop, num_voice, num_normal;
/* global position & size */
/* TODO: get values from function parameters */
- window->win_x = 0;
- window->win_y = 0;
- window->win_width = COLS;
- window->win_height = LINES;
+ view->window->win_x = 0;
+ view->window->win_y = 0;
+ view->window->win_width = COLS;
+ view->window->win_height = LINES;
/* init chat & nicklist settings */
/* TODO: calculate values from function parameters */
- if (cfg_look_nicklist && WIN_IS_CHANNEL(window))
+ if (cfg_look_nicklist && VIEW_IS_CHANNEL(view))
{
- max_length = nick_get_max_length (CHANNEL(window));
+ max_length = nick_get_max_length (CHANNEL(view));
switch (cfg_look_nicklist_position)
{
case CFG_LOOK_NICKLIST_LEFT:
- window->win_chat_x = max_length + 2;
- window->win_chat_y = 1;
- window->win_chat_width = COLS - max_length - 2;
- window->win_nick_x = 0;
- window->win_nick_y = 1;
- window->win_nick_width = max_length + 2;
+ view->window->win_chat_x = max_length + 2;
+ view->window->win_chat_y = 1;
+ view->window->win_chat_width = COLS - max_length - 2;
+ view->window->win_nick_x = 0;
+ view->window->win_nick_y = 1;
+ view->window->win_nick_width = max_length + 2;
if (cfg_look_infobar)
{
- window->win_chat_height = LINES - 4;
- window->win_nick_height = LINES - 4;
+ view->window->win_chat_height = LINES - 4;
+ view->window->win_nick_height = LINES - 4;
}
else
{
- window->win_chat_height = LINES - 3;
- window->win_nick_height = LINES - 3;
+ view->window->win_chat_height = LINES - 3;
+ view->window->win_nick_height = LINES - 3;
}
break;
case CFG_LOOK_NICKLIST_RIGHT:
- window->win_chat_x = 0;
- window->win_chat_y = 1;
- window->win_chat_width = COLS - max_length - 2;
- window->win_nick_x = COLS - max_length - 2;
- window->win_nick_y = 1;
- window->win_nick_width = max_length + 2;
+ view->window->win_chat_x = 0;
+ view->window->win_chat_y = 1;
+ view->window->win_chat_width = COLS - max_length - 2;
+ view->window->win_nick_x = COLS - max_length - 2;
+ view->window->win_nick_y = 1;
+ view->window->win_nick_width = max_length + 2;
if (cfg_look_infobar)
{
- window->win_chat_height = LINES - 4;
- window->win_nick_height = LINES - 4;
+ view->window->win_chat_height = LINES - 4;
+ view->window->win_nick_height = LINES - 4;
}
else
{
- window->win_chat_height = LINES - 3;
- window->win_nick_height = LINES - 3;
+ view->window->win_chat_height = LINES - 3;
+ view->window->win_nick_height = LINES - 3;
}
break;
case CFG_LOOK_NICKLIST_TOP:
- nick_count (CHANNEL(window), &num_nicks, &num_op, &num_halfop,
+ nick_count (CHANNEL(view), &num_nicks, &num_op, &num_halfop,
&num_voice, &num_normal);
if (((max_length + 2) * num_nicks) % COLS == 0)
lines = ((max_length + 2) * num_nicks) / COLS;
else
lines = (((max_length + 2) * num_nicks) / COLS) + 1;
- window->win_chat_x = 0;
- window->win_chat_y = 1 + (lines + 1);
- window->win_chat_width = COLS;
+ view->window->win_chat_x = 0;
+ view->window->win_chat_y = 1 + (lines + 1);
+ view->window->win_chat_width = COLS;
if (cfg_look_infobar)
- window->win_chat_height = LINES - 3 - (lines + 1) - 1;
+ view->window->win_chat_height = LINES - 3 - (lines + 1) - 1;
else
- window->win_chat_height = LINES - 3 - (lines + 1);
- window->win_nick_x = 0;
- window->win_nick_y = 1;
- window->win_nick_width = COLS;
- window->win_nick_height = lines + 1;
+ view->window->win_chat_height = LINES - 3 - (lines + 1);
+ view->window->win_nick_x = 0;
+ view->window->win_nick_y = 1;
+ view->window->win_nick_width = COLS;
+ view->window->win_nick_height = lines + 1;
break;
case CFG_LOOK_NICKLIST_BOTTOM:
- nick_count (CHANNEL(window), &num_nicks, &num_op, &num_halfop,
+ nick_count (CHANNEL(view), &num_nicks, &num_op, &num_halfop,
&num_voice, &num_normal);
if (((max_length + 2) * num_nicks) % COLS == 0)
lines = ((max_length + 2) * num_nicks) / COLS;
else
lines = (((max_length + 2) * num_nicks) / COLS) + 1;
- window->win_chat_x = 0;
- window->win_chat_y = 1;
- window->win_chat_width = COLS;
+ view->window->win_chat_x = 0;
+ view->window->win_chat_y = 1;
+ view->window->win_chat_width = COLS;
if (cfg_look_infobar)
- window->win_chat_height = LINES - 3 - (lines + 1) - 1;
+ view->window->win_chat_height = LINES - 3 - (lines + 1) - 1;
else
- window->win_chat_height = LINES - 3 - (lines + 1);
- window->win_nick_x = 0;
+ view->window->win_chat_height = LINES - 3 - (lines + 1);
+ view->window->win_nick_x = 0;
if (cfg_look_infobar)
- window->win_nick_y = LINES - 2 - (lines + 1) - 1;
+ view->window->win_nick_y = LINES - 2 - (lines + 1) - 1;
else
- window->win_nick_y = LINES - 2 - (lines + 1);
- window->win_nick_width = COLS;
- window->win_nick_height = lines + 1;
+ view->window->win_nick_y = LINES - 2 - (lines + 1);
+ view->window->win_nick_width = COLS;
+ view->window->win_nick_height = lines + 1;
break;
}
- window->win_chat_cursor_x = 0;
- window->win_chat_cursor_y = 0;
+ view->window->win_chat_cursor_x = 0;
+ view->window->win_chat_cursor_y = 0;
}
else
{
- window->win_chat_x = 0;
- window->win_chat_y = 1;
- window->win_chat_width = COLS;
+ view->window->win_chat_x = 0;
+ view->window->win_chat_y = 1;
+ view->window->win_chat_width = COLS;
if (cfg_look_infobar)
- window->win_chat_height = LINES - 4;
+ view->window->win_chat_height = LINES - 4;
else
- window->win_chat_height = LINES - 3;
- window->win_chat_cursor_x = 0;
- window->win_chat_cursor_y = 0;
- window->win_nick_x = -1;
- window->win_nick_y = -1;
- window->win_nick_width = -1;
- window->win_nick_height = -1;
+ view->window->win_chat_height = LINES - 3;
+ view->window->win_chat_cursor_x = 0;
+ view->window->win_chat_cursor_y = 0;
+ view->window->win_nick_x = -1;
+ view->window->win_nick_y = -1;
+ view->window->win_nick_width = -1;
+ view->window->win_nick_height = -1;
}
}
@@ -300,57 +300,57 @@ gui_curses_window_clear (WINDOW *window)
}
/*
- * gui_draw_window_title: draw title window
+ * gui_draw_view_title: draw title window for a view
*/
void
-gui_draw_window_title (t_gui_window *window)
+gui_draw_view_title (t_gui_view *view)
{
char format[32];
- /* TODO: manage splitted windows! */
- if (window != gui_current_window)
+ /* TODO: manage splited windows! */
+ if (view != gui_current_view)
return;
if (has_colors ())
{
- gui_window_set_color (window->win_title, COLOR_WIN_TITLE);
- wborder (window->win_title, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
- wrefresh (window->win_title);
+ gui_window_set_color (view->window->win_title, COLOR_WIN_TITLE);
+ wborder (view->window->win_title, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
+ wrefresh (view->window->win_title);
refresh ();
}
- if (CHANNEL(window))
+ if (CHANNEL(view))
{
- snprintf (format, 32, "%%-%ds", window->win_width);
- if (CHANNEL(window)->topic)
- mvwprintw (window->win_title, 0, 0, format,
- CHANNEL(window)->topic);
+ snprintf (format, 32, "%%-%ds", view->window->win_width);
+ if (CHANNEL(view)->topic)
+ mvwprintw (view->window->win_title, 0, 0, format,
+ CHANNEL(view)->topic);
}
else
{
/* TODO: change this copyright as title? */
- mvwprintw (window->win_title, 0, 0,
+ mvwprintw (view->window->win_title, 0, 0,
"%s", PACKAGE_STRING " - " WEECHAT_WEBSITE);
- mvwprintw (window->win_title, 0, COLS - strlen (WEECHAT_COPYRIGHT),
+ mvwprintw (view->window->win_title, 0, COLS - strlen (WEECHAT_COPYRIGHT),
"%s", WEECHAT_COPYRIGHT);
}
- wrefresh (window->win_title);
+ wrefresh (view->window->win_title);
refresh ();
}
/*
- * gui_redraw_window_title: redraw title window
+ * gui_redraw_view_title: redraw title window for a view
*/
void
-gui_redraw_window_title (t_gui_window *window)
+gui_redraw_view_title (t_gui_view *view)
{
- /* TODO: manage splitted windows! */
- if (window != gui_current_window)
+ /* TODO: manage splited windows! */
+ if (view != gui_current_view)
return;
- gui_curses_window_clear (window->win_title);
- gui_draw_window_title (window);
+ gui_curses_window_clear (view->window->win_title);
+ gui_draw_view_title (view);
}
/*
@@ -360,20 +360,20 @@ gui_redraw_window_title (t_gui_window *window)
*/
int
-gui_get_line_num_splits (t_gui_window *window, t_gui_line *line)
+gui_get_line_num_splits (t_gui_view *view, t_gui_line *line)
{
int length, width;
/* TODO: modify arbitraty value for non aligning messages on time/nick? */
- if (line->length_align >= window->win_chat_width - 5)
+ if (line->length_align >= view->window->win_chat_width - 5)
{
length = line->length;
- width = window->win_chat_width;
+ width = view->window->win_chat_width;
}
else
{
length = line->length - line->length_align;
- width = window->win_chat_width - line->length_align;
+ width = view->window->win_chat_width - line->length_align;
}
return (length % width == 0) ? (length / width) : ((length / width) + 1);
@@ -384,14 +384,14 @@ gui_get_line_num_splits (t_gui_window *window, t_gui_line *line)
*/
void
-gui_display_end_of_line (t_gui_window *window, t_gui_line *line, int count)
+gui_display_end_of_line (t_gui_view *view, t_gui_line *line, int count)
{
int lines_displayed, num_lines, offset, remainder, num_displayed;
t_gui_message *ptr_message;
char saved_char, format_align[32], format_empty[32];
snprintf (format_align, 32, "%%-%ds", line->length_align);
- num_lines = gui_get_line_num_splits (window, line);
+ num_lines = gui_get_line_num_splits (view, line);
ptr_message = line->messages;
offset = 0;
lines_displayed = 0;
@@ -399,31 +399,31 @@ gui_display_end_of_line (t_gui_window *window, t_gui_line *line, int count)
{
/* set text color if beginning of message */
if (offset == 0)
- gui_window_set_color (window->win_chat, ptr_message->color);
+ gui_window_set_color (view->window->win_chat, ptr_message->color);
/* insert spaces for align text under time/nick */
- if ((lines_displayed > 0) && (window->win_chat_cursor_x == 0))
+ if ((lines_displayed > 0) && (view->window->win_chat_cursor_x == 0))
{
if (lines_displayed >= num_lines - count)
- mvwprintw (window->win_chat,
- window->win_chat_cursor_y,
- window->win_chat_cursor_x,
+ mvwprintw (view->window->win_chat,
+ view->window->win_chat_cursor_y,
+ view->window->win_chat_cursor_x,
format_align, " ");
- window->win_chat_cursor_x += line->length_align;
+ view->window->win_chat_cursor_x += line->length_align;
}
remainder = strlen (ptr_message->message + offset);
- if (window->win_chat_cursor_x + remainder >
- window->win_chat_width - 1)
+ if (view->window->win_chat_cursor_x + remainder >
+ view->window->win_chat_width - 1)
{
- num_displayed = window->win_chat_width -
- window->win_chat_cursor_x;
+ num_displayed = view->window->win_chat_width -
+ view->window->win_chat_cursor_x;
saved_char = ptr_message->message[offset + num_displayed];
ptr_message->message[offset + num_displayed] = '\0';
if (lines_displayed >= num_lines - count)
- mvwprintw (window->win_chat,
- window->win_chat_cursor_y,
- window->win_chat_cursor_x,
+ mvwprintw (view->window->win_chat,
+ view->window->win_chat_cursor_y,
+ view->window->win_chat_cursor_x,
"%s", ptr_message->message + offset);
ptr_message->message[offset + num_displayed] = saved_char;
offset += num_displayed;
@@ -432,28 +432,28 @@ gui_display_end_of_line (t_gui_window *window, t_gui_line *line, int count)
{
num_displayed = remainder;
if (lines_displayed >= num_lines - count)
- mvwprintw (window->win_chat,
- window->win_chat_cursor_y,
- window->win_chat_cursor_x,
+ mvwprintw (view->window->win_chat,
+ view->window->win_chat_cursor_y,
+ view->window->win_chat_cursor_x,
"%s", ptr_message->message + offset);
ptr_message = ptr_message->next_message;
offset = 0;
}
- window->win_chat_cursor_x += num_displayed;
+ view->window->win_chat_cursor_x += num_displayed;
if (!ptr_message ||
- (window->win_chat_cursor_x > (window->win_chat_width - 1)))
+ (view->window->win_chat_cursor_x > (view->window->win_chat_width - 1)))
{
if (lines_displayed >= num_lines - count)
{
- if (window->win_chat_cursor_x <= window->win_chat_width - 1)
+ if (view->window->win_chat_cursor_x <= view->window->win_chat_width - 1)
{
snprintf (format_empty, 32, "%%-%ds",
- window->win_chat_width - window->win_chat_cursor_x);
- wprintw (window->win_chat, format_empty, " ");
+ view->window->win_chat_width - view->window->win_chat_cursor_x);
+ wprintw (view->window->win_chat, format_empty, " ");
}
- window->win_chat_cursor_y++;
+ view->window->win_chat_cursor_y++;
}
- window->win_chat_cursor_x = 0;
+ view->window->win_chat_cursor_x = 0;
lines_displayed++;
}
}
@@ -468,7 +468,7 @@ gui_display_end_of_line (t_gui_window *window, t_gui_line *line, int count)
*/
int
-gui_display_line (t_gui_window *window, t_gui_line *line, int stop_at_end)
+gui_display_line (t_gui_view *view, t_gui_line *line, int stop_at_end)
{
int offset, remainder, num_displayed;
t_gui_message *ptr_message;
@@ -480,46 +480,46 @@ gui_display_line (t_gui_window *window, t_gui_line *line, int stop_at_end)
while (ptr_message)
{
/* cursor is below end line of chat window */
- if (window->win_chat_cursor_y > window->win_chat_height - 1)
+ if (view->window->win_chat_cursor_y > view->window->win_chat_height - 1)
{
/*if (!stop_at_end)
- wscrl (window->win_chat, +1);*/
- window->win_chat_cursor_x = 0;
- window->win_chat_cursor_y = window->win_chat_height - 1;
+ wscrl (view->window->win_chat, +1);*/
+ view->window->win_chat_cursor_x = 0;
+ view->window->win_chat_cursor_y = view->window->win_chat_height - 1;
if (stop_at_end)
return 0;
- window->first_line_displayed = 0;
+ view->first_line_displayed = 0;
}
/* set text color if beginning of message */
if (offset == 0)
- gui_window_set_color (window->win_chat, ptr_message->color);
+ gui_window_set_color (view->window->win_chat, ptr_message->color);
/* insert spaces for align text under time/nick */
- if ((window->win_chat_cursor_x == 0) &&
+ if ((view->window->win_chat_cursor_x == 0) &&
(ptr_message->type != MSG_TYPE_TIME) &&
(ptr_message->type != MSG_TYPE_NICK) &&
(line->length_align > 0) &&
/* TODO: modify arbitraty value for non aligning messages on time/nick? */
- (line->length_align < (window->win_chat_width - 5)))
+ (line->length_align < (view->window->win_chat_width - 5)))
{
- mvwprintw (window->win_chat,
- window->win_chat_cursor_y,
- window->win_chat_cursor_x,
+ mvwprintw (view->window->win_chat,
+ view->window->win_chat_cursor_y,
+ view->window->win_chat_cursor_x,
format_align, " ");
- window->win_chat_cursor_x += line->length_align;
+ view->window->win_chat_cursor_x += line->length_align;
}
remainder = strlen (ptr_message->message + offset);
- if (window->win_chat_cursor_x + remainder > window->win_chat_width)
+ if (view->window->win_chat_cursor_x + remainder > view->window->win_chat_width)
{
- num_displayed = window->win_chat_width -
- window->win_chat_cursor_x;
+ num_displayed = view->window->win_chat_width -
+ view->window->win_chat_cursor_x;
saved_char = ptr_message->message[offset + num_displayed];
ptr_message->message[offset + num_displayed] = '\0';
- mvwprintw (window->win_chat,
- window->win_chat_cursor_y,
- window->win_chat_cursor_x,
+ mvwprintw (view->window->win_chat,
+ view->window->win_chat_cursor_y,
+ view->window->win_chat_cursor_x,
"%s", ptr_message->message + offset);
ptr_message->message[offset + num_displayed] = saved_char;
offset += num_displayed;
@@ -527,166 +527,166 @@ gui_display_line (t_gui_window *window, t_gui_line *line, int stop_at_end)
else
{
num_displayed = remainder;
- mvwprintw (window->win_chat,
- window->win_chat_cursor_y,
- window->win_chat_cursor_x,
+ mvwprintw (view->window->win_chat,
+ view->window->win_chat_cursor_y,
+ view->window->win_chat_cursor_x,
"%s", ptr_message->message + offset);
offset = 0;
ptr_message = ptr_message->next_message;
}
- window->win_chat_cursor_x += num_displayed;
+ view->window->win_chat_cursor_x += num_displayed;
if (!ptr_message ||
- (window->win_chat_cursor_x > (window->win_chat_width - 1)))
+ (view->window->win_chat_cursor_x > (view->window->win_chat_width - 1)))
{
if (!ptr_message ||
- ((window->win_chat_cursor_y <= window->win_chat_height - 1) &&
- (window->win_chat_cursor_x > window->win_chat_width - 1)))
+ ((view->window->win_chat_cursor_y <= view->window->win_chat_height - 1) &&
+ (view->window->win_chat_cursor_x > view->window->win_chat_width - 1)))
{
- if (window->win_chat_cursor_x <= window->win_chat_width - 1)
+ if (view->window->win_chat_cursor_x <= view->window->win_chat_width - 1)
{
snprintf (format_empty, 32, "%%-%ds",
- window->win_chat_width - window->win_chat_cursor_x);
- wprintw (window->win_chat, format_empty, " ");
+ view->window->win_chat_width - view->window->win_chat_cursor_x);
+ wprintw (view->window->win_chat, format_empty, " ");
}
- window->win_chat_cursor_y++;
+ view->window->win_chat_cursor_y++;
}
- window->win_chat_cursor_x = 0;
+ view->window->win_chat_cursor_x = 0;
}
}
return 1;
}
/*
- * gui_draw_window_chat: draw chat window
+ * gui_draw_view_chat: draw chat window for a view
*/
void
-gui_draw_window_chat (t_gui_window *window)
+gui_draw_view_chat (t_gui_view *view)
{
t_gui_line *ptr_line;
int lines_used;
- /* TODO: manage splitted windows! */
- if (window != gui_current_window)
+ /* TODO: manage splited windows! */
+ if (view != gui_current_view)
return;
if (has_colors ())
- gui_window_set_color (window->win_chat, COLOR_WIN_CHAT);
+ gui_window_set_color (view->window->win_chat, COLOR_WIN_CHAT);
- ptr_line = window->last_line;
+ ptr_line = view->last_line;
lines_used = 0;
while (ptr_line
- && (lines_used < (window->win_chat_height + window->sub_lines)))
+ && (lines_used < (view->window->win_chat_height + view->sub_lines)))
{
- lines_used += gui_get_line_num_splits (window, ptr_line);
+ lines_used += gui_get_line_num_splits (view, ptr_line);
ptr_line = ptr_line->prev_line;
}
- window->win_chat_cursor_x = 0;
- window->win_chat_cursor_y = 0;
- if (lines_used > (window->win_chat_height + window->sub_lines))
+ view->window->win_chat_cursor_x = 0;
+ view->window->win_chat_cursor_y = 0;
+ if (lines_used > (view->window->win_chat_height + view->sub_lines))
{
/* screen will be full (we'll display only end of 1st line) */
- ptr_line = (ptr_line) ? ptr_line->next_line : window->lines;
- gui_display_end_of_line (window, ptr_line,
- gui_get_line_num_splits (window, ptr_line) -
- (lines_used - (window->win_chat_height + window->sub_lines)));
+ ptr_line = (ptr_line) ? ptr_line->next_line : view->lines;
+ gui_display_end_of_line (view, ptr_line,
+ gui_get_line_num_splits (view, ptr_line) -
+ (lines_used - (view->window->win_chat_height + view->sub_lines)));
ptr_line = ptr_line->next_line;
- window->first_line_displayed = 0;
+ view->first_line_displayed = 0;
}
else
{
/* all lines are displayed */
if (!ptr_line)
{
- window->first_line_displayed = 1;
- ptr_line = window->lines;
+ view->first_line_displayed = 1;
+ ptr_line = view->lines;
}
else
{
- window->first_line_displayed = 0;
+ view->first_line_displayed = 0;
ptr_line = ptr_line->next_line;
}
}
while (ptr_line)
{
- if (!gui_display_line (window, ptr_line, 1))
+ if (!gui_display_line (view, ptr_line, 1))
break;
ptr_line = ptr_line->next_line;
}
- /*if (window->win_chat_cursor_y <= window->win_chat_height - 1)
- window->sub_lines = 0;*/
- wrefresh (window->win_chat);
+ /*if (view->window->win_chat_cursor_y <= view->window->win_chat_height - 1)
+ view->sub_lines = 0;*/
+ wrefresh (view->window->win_chat);
refresh ();
}
/*
- * gui_redraw_window_chat: redraw chat window
+ * gui_redraw_view_chat: redraw chat window for a view
*/
void
-gui_redraw_window_chat (t_gui_window *window)
+gui_redraw_view_chat (t_gui_view *view)
{
char format_empty[32];
int i;
- /* TODO: manage splitted windows! */
- if (window != gui_current_window)
+ /* TODO: manage splited windows! */
+ if (view != gui_current_view)
return;
if (has_colors ())
- gui_window_set_color (window->win_chat, COLOR_WIN_CHAT);
+ gui_window_set_color (view->window->win_chat, COLOR_WIN_CHAT);
- snprintf (format_empty, 32, "%%-%ds", window->win_chat_width);
- for (i = 0; i < window->win_chat_height; i++)
+ snprintf (format_empty, 32, "%%-%ds", view->window->win_chat_width);
+ for (i = 0; i < view->window->win_chat_height; i++)
{
- mvwprintw (window->win_chat, i, 0, format_empty, " ");
+ mvwprintw (view->window->win_chat, i, 0, format_empty, " ");
}
- gui_draw_window_chat (window);
+ gui_draw_view_chat (view);
}
/*
- * gui_draw_window_nick: draw nick window
+ * gui_draw_view_nick: draw nick window for a view
*/
void
-gui_draw_window_nick (t_gui_window *window)
+gui_draw_view_nick (t_gui_view *view)
{
int i, x, y, column, max_length;
char format[32], format_empty[32];
t_irc_nick *ptr_nick;
- /* TODO: manage splitted windows! */
- if (window != gui_current_window)
+ /* TODO: manage splited windows! */
+ if (view != gui_current_view)
return;
- if (CHANNEL(window) && CHANNEL(window)->nicks)
+ if (CHANNEL(view) && CHANNEL(view)->nicks)
{
- max_length = nick_get_max_length (CHANNEL(window));
- if ((window == gui_current_window) &&
- ((max_length + 2) != window->win_nick_width))
+ max_length = nick_get_max_length (CHANNEL(view));
+ if ((view == gui_current_view) &&
+ ((max_length + 2) != view->window->win_nick_width))
{
- gui_calculate_pos_size (window);
- delwin (window->win_chat);
- delwin (window->win_nick);
- window->win_chat = newwin (window->win_chat_height,
- window->win_chat_width,
- window->win_chat_y,
- window->win_chat_x);
- window->win_nick = newwin (window->win_nick_height,
- window->win_nick_width,
- window->win_nick_y,
- window->win_nick_x);
- gui_redraw_window_chat (window);
+ gui_calculate_pos_size (view);
+ delwin (view->window->win_chat);
+ delwin (view->window->win_nick);
+ view->window->win_chat = newwin (view->window->win_chat_height,
+ view->window->win_chat_width,
+ view->window->win_chat_y,
+ view->window->win_chat_x);
+ view->window->win_nick = newwin (view->window->win_nick_height,
+ view->window->win_nick_width,
+ view->window->win_nick_y,
+ view->window->win_nick_x);
+ gui_redraw_view_chat (view);
if (has_colors ())
- gui_window_set_color (window->win_nick, COLOR_WIN_NICK);
+ gui_window_set_color (view->window->win_nick, COLOR_WIN_NICK);
- snprintf (format_empty, 32, "%%-%ds", window->win_nick_width);
- for (i = 0; i < window->win_nick_height; i++)
+ snprintf (format_empty, 32, "%%-%ds", view->window->win_nick_width);
+ for (i = 0; i < view->window->win_nick_height; i++)
{
- mvwprintw (window->win_nick, i, 0, format_empty, " ");
+ mvwprintw (view->window->win_nick, i, 0, format_empty, " ");
}
}
snprintf (format, 32, "%%-%ds", max_length);
@@ -696,37 +696,37 @@ gui_draw_window_nick (t_gui_window *window)
switch (cfg_look_nicklist_position)
{
case CFG_LOOK_NICKLIST_LEFT:
- gui_window_set_color (window->win_nick, COLOR_WIN_NICK_SEP);
- for (i = 0; i < window->win_chat_height; i++)
- mvwprintw (window->win_nick,
- i, window->win_nick_width - 1, " ");
+ gui_window_set_color (view->window->win_nick, COLOR_WIN_NICK_SEP);
+ for (i = 0; i < view->window->win_chat_height; i++)
+ mvwprintw (view->window->win_nick,
+ i, view->window->win_nick_width - 1, " ");
break;
case CFG_LOOK_NICKLIST_RIGHT:
- gui_window_set_color (window->win_nick, COLOR_WIN_NICK_SEP);
- for (i = 0; i < window->win_chat_height; i++)
- mvwprintw (window->win_nick,
+ gui_window_set_color (view->window->win_nick, COLOR_WIN_NICK_SEP);
+ for (i = 0; i < view->window->win_chat_height; i++)
+ mvwprintw (view->window->win_nick,
i, 0, " ");
break;
case CFG_LOOK_NICKLIST_TOP:
- gui_window_set_color (window->win_nick, COLOR_WIN_NICK);
- for (i = 0; i < window->win_chat_width; i += 2)
- mvwprintw (window->win_nick,
- window->win_nick_height - 1, i, "-");
+ gui_window_set_color (view->window->win_nick, COLOR_WIN_NICK);
+ for (i = 0; i < view->window->win_chat_width; i += 2)
+ mvwprintw (view->window->win_nick,
+ view->window->win_nick_height - 1, i, "-");
break;
case CFG_LOOK_NICKLIST_BOTTOM:
- gui_window_set_color (window->win_nick, COLOR_WIN_NICK);
- for (i = 0; i < window->win_chat_width; i += 2)
- mvwprintw (window->win_nick,
+ gui_window_set_color (view->window->win_nick, COLOR_WIN_NICK);
+ for (i = 0; i < view->window->win_chat_width; i += 2)
+ mvwprintw (view->window->win_nick,
0, i, "-");
break;
}
}
- gui_window_set_color (window->win_nick, COLOR_WIN_NICK);
+ gui_window_set_color (view->window->win_nick, COLOR_WIN_NICK);
x = 0;
y = (cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM) ? 1 : 0;
column = 0;
- for (ptr_nick = CHANNEL(window)->nicks; ptr_nick;
+ for (ptr_nick = CHANNEL(view)->nicks; ptr_nick;
ptr_nick = ptr_nick->next_nick)
{
switch (cfg_look_nicklist_position)
@@ -744,41 +744,41 @@ gui_draw_window_nick (t_gui_window *window)
}
if (ptr_nick->is_op)
{
- gui_window_set_color (window->win_nick, COLOR_WIN_NICK_OP);
- mvwprintw (window->win_nick, y, x, "@");
+ gui_window_set_color (view->window->win_nick, COLOR_WIN_NICK_OP);
+ mvwprintw (view->window->win_nick, y, x, "@");
x++;
}
else
{
if (ptr_nick->is_halfop)
{
- gui_window_set_color (window->win_nick, COLOR_WIN_NICK_HALFOP);
- mvwprintw (window->win_nick, y, x, "%%");
+ gui_window_set_color (view->window->win_nick, COLOR_WIN_NICK_HALFOP);
+ mvwprintw (view->window->win_nick, y, x, "%%");
x++;
}
else
{
if (ptr_nick->has_voice)
{
- gui_window_set_color (window->win_nick, COLOR_WIN_NICK_VOICE);
- mvwprintw (window->win_nick, y, x, "+");
+ gui_window_set_color (view->window->win_nick, COLOR_WIN_NICK_VOICE);
+ mvwprintw (view->window->win_nick, y, x, "+");
x++;
}
else
{
- gui_window_set_color (window->win_nick, COLOR_WIN_NICK);
- mvwprintw (window->win_nick, y, x, " ");
+ gui_window_set_color (view->window->win_nick, COLOR_WIN_NICK);
+ mvwprintw (view->window->win_nick, y, x, " ");
x++;
}
}
}
- gui_window_set_color (window->win_nick, COLOR_WIN_NICK);
- mvwprintw (window->win_nick, y, x, format, ptr_nick->nick);
+ gui_window_set_color (view->window->win_nick, COLOR_WIN_NICK);
+ mvwprintw (view->window->win_nick, y, x, format, ptr_nick->nick);
y++;
if ((cfg_look_nicklist_position == CFG_LOOK_NICKLIST_TOP) ||
(cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM))
{
- if (y - ((cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM) ? 1 : 0) >= window->win_nick_height - 1)
+ if (y - ((cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM) ? 1 : 0) >= view->window->win_nick_height - 1)
{
column += max_length + 2;
y = (cfg_look_nicklist_position == CFG_LOOK_NICKLIST_TOP) ?
@@ -787,255 +787,255 @@ gui_draw_window_nick (t_gui_window *window)
}
}
}
- wrefresh (window->win_nick);
+ wrefresh (view->window->win_nick);
refresh ();
}
/*
- * gui_redraw_window_nick: redraw nick window
+ * gui_redraw_view_nick: redraw nick window for a view
*/
void
-gui_redraw_window_nick (t_gui_window *window)
+gui_redraw_view_nick (t_gui_view *view)
{
char format_empty[32];
int i;
/* TODO: manage splitted windows! */
- if (window != gui_current_window)
+ if (view != gui_current_view)
return;
if (has_colors ())
- gui_window_set_color (window->win_nick, COLOR_WIN_NICK);
+ gui_window_set_color (view->window->win_nick, COLOR_WIN_NICK);
- snprintf (format_empty, 32, "%%-%ds", window->win_nick_width);
- for (i = 0; i < window->win_nick_height; i++)
+ snprintf (format_empty, 32, "%%-%ds", view->window->win_nick_width);
+ for (i = 0; i < view->window->win_nick_height; i++)
{
- mvwprintw (window->win_nick, i, 0, format_empty, " ");
+ mvwprintw (view->window->win_nick, i, 0, format_empty, " ");
}
- gui_draw_window_nick (window);
+ gui_draw_view_nick (view);
}
/*
- * gui_draw_window_status: draw status window
+ * gui_draw_view_status: draw status window for a view
*/
void
-gui_draw_window_status (t_gui_window *window)
+gui_draw_view_status (t_gui_view *view)
{
- t_gui_window *ptr_win;
+ t_gui_view *ptr_view;
char format_more[32];
int i, first_mode;
/* TODO: manage splitted windows! */
- if (window != gui_current_window)
+ if (view != gui_current_view)
return;
if (has_colors ())
{
- gui_window_set_color (window->win_status, COLOR_WIN_STATUS);
- wborder (window->win_status, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
- wrefresh (window->win_status);
+ gui_window_set_color (view->window->win_status, COLOR_WIN_STATUS);
+ wborder (view->window->win_status, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
+ wrefresh (view->window->win_status);
}
- wmove (window->win_status, 0, 0);
- for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
+ wmove (view->window->win_status, 0, 0);
+ for (ptr_view = gui_views; ptr_view; ptr_view = ptr_view->next_view)
{
- if (SERVER(ptr_win) && !CHANNEL(ptr_win))
+ if (SERVER(ptr_view) && !CHANNEL(ptr_view))
{
- if (gui_current_window == SERVER(ptr_win)->window)
+ if (gui_current_view == SERVER(ptr_view)->view)
{
- if (ptr_win->unread_data)
+ if (ptr_view->unread_data)
{
- if (ptr_win->unread_data > 1)
- gui_window_set_color (window->win_status,
+ if (ptr_view->unread_data > 1)
+ gui_window_set_color (view->window->win_status,
COLOR_WIN_STATUS_DATA_MSG);
else
- gui_window_set_color (window->win_status,
+ gui_window_set_color (view->window->win_status,
COLOR_WIN_STATUS_DATA_OTHER);
}
else
- gui_window_set_color (window->win_status,
+ gui_window_set_color (view->window->win_status,
COLOR_WIN_STATUS_ACTIVE);
}
else
{
- if (SERVER(ptr_win)->window &&
- ((SERVER(ptr_win)->window)->unread_data))
+ if (SERVER(ptr_view)->view &&
+ ((SERVER(ptr_view)->view)->unread_data))
{
- if (SERVER(ptr_win)->window->unread_data > 1)
- gui_window_set_color (window->win_status,
+ if (SERVER(ptr_view)->view->unread_data > 1)
+ gui_window_set_color (view->window->win_status,
COLOR_WIN_STATUS_DATA_MSG);
else
- gui_window_set_color (window->win_status,
+ gui_window_set_color (view->window->win_status,
COLOR_WIN_STATUS_DATA_OTHER);
}
else
- gui_window_set_color (window->win_status,
+ gui_window_set_color (view->window->win_status,
COLOR_WIN_STATUS);
}
- if (SERVER(ptr_win)->is_connected)
- wprintw (window->win_status, "[%s] ",
- SERVER(ptr_win)->name);
+ if (SERVER(ptr_view)->is_connected)
+ wprintw (view->window->win_status, "[%s] ",
+ SERVER(ptr_view)->name);
else
- wprintw (window->win_status, "(%s) ",
- SERVER(ptr_win)->name);
+ wprintw (view->window->win_status, "(%s) ",
+ SERVER(ptr_view)->name);
}
- if (SERVER(ptr_win) && CHANNEL(ptr_win))
+ if (SERVER(ptr_view) && CHANNEL(ptr_view))
{
- if (gui_current_window == CHANNEL(ptr_win)->window)
+ if (gui_current_view == CHANNEL(ptr_view)->view)
{
- if ((CHANNEL(ptr_win)->window) &&
- (CHANNEL(ptr_win)->window->unread_data))
+ if ((CHANNEL(ptr_view)->view) &&
+ (CHANNEL(ptr_view)->view->unread_data))
{
- if (CHANNEL(ptr_win)->window->unread_data > 1)
- gui_window_set_color (window->win_status,
+ if (CHANNEL(ptr_view)->view->unread_data > 1)
+ gui_window_set_color (view->window->win_status,
COLOR_WIN_STATUS_DATA_MSG);
else
- gui_window_set_color (window->win_status,
+ gui_window_set_color (view->window->win_status,
COLOR_WIN_STATUS_DATA_OTHER);
}
else
- gui_window_set_color (window->win_status,
+ gui_window_set_color (view->window->win_status,
COLOR_WIN_STATUS_ACTIVE);
}
else
{
- if ((CHANNEL(ptr_win)->window) &&
- (CHANNEL(ptr_win)->window->unread_data))
+ if ((CHANNEL(ptr_view)->view) &&
+ (CHANNEL(ptr_view)->view->unread_data))
{
- if (CHANNEL(ptr_win)->window->unread_data > 1)
- gui_window_set_color (window->win_status,
+ if (CHANNEL(ptr_view)->view->unread_data > 1)
+ gui_window_set_color (view->window->win_status,
COLOR_WIN_STATUS_DATA_MSG);
else
- gui_window_set_color (window->win_status,
+ gui_window_set_color (view->window->win_status,
COLOR_WIN_STATUS_DATA_OTHER);
}
else
- gui_window_set_color (window->win_status,
+ gui_window_set_color (view->window->win_status,
COLOR_WIN_STATUS);
}
- wprintw (window->win_status, "%s", CHANNEL(ptr_win)->name);
- if (gui_current_window == CHANNEL(ptr_win)->window)
+ wprintw (view->window->win_status, "%s", CHANNEL(ptr_view)->name);
+ if (gui_current_view == CHANNEL(ptr_view)->view)
{
/* display channel modes */
- wprintw (window->win_status, "(");
+ wprintw (view->window->win_status, "(");
i = 0;
first_mode = 1;
- while (CHANNEL(ptr_win)->modes[i])
+ while (CHANNEL(ptr_view)->modes[i])
{
- if (CHANNEL(ptr_win)->modes[i] != ' ')
+ if (CHANNEL(ptr_view)->modes[i] != ' ')
{
if (first_mode)
{
- wprintw (window->win_status, "+");
+ wprintw (view->window->win_status, "+");
first_mode = 0;
}
- wprintw (window->win_status, "%c",
- CHANNEL(ptr_win)->modes[i]);
+ wprintw (view->window->win_status, "%c",
+ CHANNEL(ptr_view)->modes[i]);
}
i++;
}
- if (CHANNEL(ptr_win)->modes[CHANNEL_MODE_KEY] != ' ')
- wprintw (window->win_status, ",%s",
- CHANNEL(ptr_win)->key);
- if (CHANNEL(ptr_win)->modes[CHANNEL_MODE_LIMIT] != ' ')
- wprintw (window->win_status, ",%d",
- CHANNEL(ptr_win)->limit);
- wprintw (window->win_status, ")");
+ if (CHANNEL(ptr_view)->modes[CHANNEL_MODE_KEY] != ' ')
+ wprintw (view->window->win_status, ",%s",
+ CHANNEL(ptr_view)->key);
+ if (CHANNEL(ptr_view)->modes[CHANNEL_MODE_LIMIT] != ' ')
+ wprintw (view->window->win_status, ",%d",
+ CHANNEL(ptr_view)->limit);
+ wprintw (view->window->win_status, ")");
}
- wprintw (window->win_status, " ");
+ wprintw (view->window->win_status, " ");
}
- if (!SERVER(ptr_win))
+ if (!SERVER(ptr_view))
{
- gui_window_set_color (window->win_status, COLOR_WIN_STATUS);
- wprintw (window->win_status, _("[not connected] "));
+ gui_window_set_color (view->window->win_status, COLOR_WIN_STATUS);
+ wprintw (view->window->win_status, _("[not connected] "));
}
}
/* display "-MORE-" if last line is not displayed */
- gui_window_set_color (window->win_status, COLOR_WIN_STATUS_MORE);
- if (window->sub_lines > 0)
- mvwprintw (window->win_status, 0, COLS - 7, _("-MORE-"));
+ gui_window_set_color (view->window->win_status, COLOR_WIN_STATUS_MORE);
+ if (view->sub_lines > 0)
+ mvwprintw (view->window->win_status, 0, COLS - 7, _("-MORE-"));
else
{
snprintf (format_more, 32, "%%-%ds", strlen (_("-MORE-")));
- mvwprintw (window->win_status, 0, COLS - 7, format_more, " ");
+ mvwprintw (view->window->win_status, 0, COLS - 7, format_more, " ");
}
- wrefresh (window->win_status);
+ wrefresh (view->window->win_status);
refresh ();
}
/*
- * gui_redraw_window_status: redraw status window
+ * gui_redraw_view_status: redraw status window for a view
*/
void
-gui_redraw_window_status (t_gui_window *window)
+gui_redraw_view_status (t_gui_view *view)
{
- /* TODO: manage splitted windows! */
- if (window != gui_current_window)
+ /* TODO: manage splited windows! */
+ if (view != gui_current_view)
return;
- gui_curses_window_clear (window->win_status);
- gui_draw_window_status (window);
+ gui_curses_window_clear (view->window->win_status);
+ gui_draw_view_status (view);
}
/*
- * gui_draw_window_infobar: draw infobar window
+ * gui_draw_view_infobar: draw infobar window for a view
*/
void
-gui_draw_window_infobar (t_gui_window *window)
+gui_draw_view_infobar (t_gui_view *view)
{
time_t time_seconds;
struct tm *local_time;
char text[1024 + 1];
- /* TODO: manage splitted windows! */
- if (window != gui_current_window)
+ /* TODO: manage splited windows! */
+ if (view != gui_current_view)
return;
if (has_colors ())
{
- gui_window_set_color (window->win_infobar, COLOR_WIN_INFOBAR);
- wborder (window->win_infobar, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
- wrefresh (window->win_infobar);
+ gui_window_set_color (view->window->win_infobar, COLOR_WIN_INFOBAR);
+ wborder (view->window->win_infobar, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
+ wrefresh (view->window->win_infobar);
}
- wmove (window->win_infobar, 0, 0);
+ wmove (view->window->win_infobar, 0, 0);
time_seconds = time (NULL);
local_time = localtime (&time_seconds);
if (local_time)
{
strftime (text, 1024, cfg_look_infobar_timestamp, local_time);
- gui_window_set_color (window->win_infobar, COLOR_WIN_INFOBAR);
- wprintw (window->win_infobar, "%s", text);
+ gui_window_set_color (view->window->win_infobar, COLOR_WIN_INFOBAR);
+ wprintw (view->window->win_infobar, "%s", text);
}
if (gui_infobar)
{
- gui_window_set_color (window->win_infobar, gui_infobar->color);
- wprintw (window->win_infobar, " | %s", gui_infobar->text);
+ gui_window_set_color (view->window->win_infobar, gui_infobar->color);
+ wprintw (view->window->win_infobar, " | %s", gui_infobar->text);
}
- wrefresh (window->win_infobar);
+ wrefresh (view->window->win_infobar);
refresh ();
}
/*
- * gui_redraw_window_infobar: redraw infobar window
+ * gui_redraw_view_infobar: redraw infobar window for a view
*/
void
-gui_redraw_window_infobar (t_gui_window *window)
+gui_redraw_view_infobar (t_gui_view *view)
{
- /* TODO: manage splitted windows! */
- if (window != gui_current_window)
+ /* TODO: manage splited windows! */
+ if (view != gui_current_view)
return;
- gui_curses_window_clear (window->win_infobar);
- gui_draw_window_infobar (window);
+ gui_curses_window_clear (view->window->win_infobar);
+ gui_draw_view_infobar (view);
}
/*
@@ -1043,337 +1043,337 @@ gui_redraw_window_infobar (t_gui_window *window)
*/
int
-gui_get_input_width (t_gui_window *window)
+gui_get_input_width (t_gui_view *view)
{
- if (CHANNEL(window))
- return (COLS - strlen (CHANNEL(window)->name) -
- strlen (SERVER(window)->nick) - 3);
+ if (CHANNEL(view))
+ return (COLS - strlen (CHANNEL(view)->name) -
+ strlen (SERVER(view)->nick) - 3);
else
{
- if (SERVER(window) && (SERVER(window)->is_connected))
- return (COLS - strlen (SERVER(window)->nick) - 2);
+ if (SERVER(view) && (SERVER(view)->is_connected))
+ return (COLS - strlen (SERVER(view)->nick) - 2);
else
return (COLS - strlen (cfg_look_no_nickname) - 2);
}
}
/*
- * gui_draw_window_input: draw input window
+ * gui_draw_view_input: draw input window for a view
*/
void
-gui_draw_window_input (t_gui_window *window)
+gui_draw_view_input (t_gui_view *view)
{
char format[32];
char *ptr_nickname;
int input_width;
- /* TODO: manage splitted windows! */
- if (window != gui_current_window)
+ /* TODO: manage splited windows! */
+ if (view != gui_current_view)
return;
if (has_colors ())
{
- gui_window_set_color (window->win_input, COLOR_WIN_INPUT);
- wborder (window->win_input, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
- wrefresh (window->win_input);
+ gui_window_set_color (view->window->win_input, COLOR_WIN_INPUT);
+ wborder (view->window->win_input, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
+ wrefresh (view->window->win_input);
}
- if (window->input_buffer_size == 0)
- window->input_buffer[0] = '\0';
+ if (view->input_buffer_size == 0)
+ view->input_buffer[0] = '\0';
- input_width = gui_get_input_width (window);
+ input_width = gui_get_input_width (view);
- if (window->input_buffer_pos - window->input_buffer_1st_display + 1 >
+ if (view->input_buffer_pos - view->input_buffer_1st_display + 1 >
input_width)
- window->input_buffer_1st_display = window->input_buffer_pos -
+ view->input_buffer_1st_display = view->input_buffer_pos -
input_width + 1;
else
{
- if (window->input_buffer_pos < window->input_buffer_1st_display)
- window->input_buffer_1st_display = window->input_buffer_pos;
+ if (view->input_buffer_pos < view->input_buffer_1st_display)
+ view->input_buffer_1st_display = view->input_buffer_pos;
else
{
- if ((window->input_buffer_1st_display > 0) &&
- (window->input_buffer_pos -
- window->input_buffer_1st_display + 1) < input_width)
+ if ((view->input_buffer_1st_display > 0) &&
+ (view->input_buffer_pos -
+ view->input_buffer_1st_display + 1) < input_width)
{
- window->input_buffer_1st_display =
- window->input_buffer_pos - input_width + 1;
- if (window->input_buffer_1st_display < 0)
- window->input_buffer_1st_display = 0;
+ view->input_buffer_1st_display =
+ view->input_buffer_pos - input_width + 1;
+ if (view->input_buffer_1st_display < 0)
+ view->input_buffer_1st_display = 0;
}
}
}
- if (CHANNEL(window))
+ if (CHANNEL(view))
{
snprintf (format, 32, "%%s %%s> %%-%ds", input_width);
- mvwprintw (window->win_input, 0, 0, format,
- CHANNEL(window)->name,
- SERVER(window)->nick,
- window->input_buffer + window->input_buffer_1st_display);
- wclrtoeol (window->win_input);
- move (LINES - 1, strlen (CHANNEL(window)->name) +
- strlen (SERVER(window)->nick) + 3 +
- (window->input_buffer_pos - window->input_buffer_1st_display));
+ mvwprintw (view->window->win_input, 0, 0, format,
+ CHANNEL(view)->name,
+ SERVER(view)->nick,
+ view->input_buffer + view->input_buffer_1st_display);
+ wclrtoeol (view->window->win_input);
+ move (LINES - 1, strlen (CHANNEL(view)->name) +
+ strlen (SERVER(view)->nick) + 3 +
+ (view->input_buffer_pos - view->input_buffer_1st_display));
}
else
{
- if (SERVER(window))
+ if (SERVER(view))
{
snprintf (format, 32, "%%s> %%-%ds", input_width);
- if (SERVER(window) && (SERVER(window)->is_connected))
- ptr_nickname = SERVER(window)->nick;
+ if (SERVER(view) && (SERVER(view)->is_connected))
+ ptr_nickname = SERVER(view)->nick;
else
ptr_nickname = cfg_look_no_nickname;
- mvwprintw (window->win_input, 0, 0, format,
+ mvwprintw (view->window->win_input, 0, 0, format,
ptr_nickname,
- window->input_buffer + window->input_buffer_1st_display);
- wclrtoeol (window->win_input);
+ view->input_buffer + view->input_buffer_1st_display);
+ wclrtoeol (view->window->win_input);
move (LINES - 1, strlen (ptr_nickname) + 2 +
- (window->input_buffer_pos - window->input_buffer_1st_display));
+ (view->input_buffer_pos - view->input_buffer_1st_display));
}
else
{
snprintf (format, 32, "%%s> %%-%ds", input_width);
- if (SERVER(window) && (SERVER(window)->is_connected))
- ptr_nickname = SERVER(window)->nick;
+ if (SERVER(view) && (SERVER(view)->is_connected))
+ ptr_nickname = SERVER(view)->nick;
else
ptr_nickname = cfg_look_no_nickname;
- mvwprintw (window->win_input, 0, 0, format,
+ mvwprintw (view->window->win_input, 0, 0, format,
ptr_nickname,
- window->input_buffer + window->input_buffer_1st_display);
- wclrtoeol (window->win_input);
+ view->input_buffer + view->input_buffer_1st_display);
+ wclrtoeol (view->window->win_input);
move (LINES - 1, strlen (ptr_nickname) + 2 +
- (window->input_buffer_pos - window->input_buffer_1st_display));
+ (view->input_buffer_pos - view->input_buffer_1st_display));
}
}
- wrefresh (window->win_input);
+ wrefresh (view->window->win_input);
refresh ();
}
/*
- * gui_redraw_window_input: redraw input window
+ * gui_redraw_view_input: redraw input window for a view
*/
void
-gui_redraw_window_input (t_gui_window *window)
+gui_redraw_view_input (t_gui_view *view)
{
- /* TODO: manage splitted windows! */
- if (window != gui_current_window)
+ /* TODO: manage splited windows! */
+ if (view != gui_current_view)
return;
- gui_curses_window_clear (window->win_input);
- gui_draw_window_input (window);
+ gui_curses_window_clear (view->window->win_input);
+ gui_draw_view_input (view);
}
/*
- * gui_redraw_window: redraw a window
+ * gui_redraw_view: redraw a view
*/
void
-gui_redraw_window (t_gui_window *window)
+gui_redraw_view (t_gui_view *view)
{
- /* TODO: manage splitted windows! */
- if (window != gui_current_window)
+ /* TODO: manage splited windows! */
+ if (view != gui_current_view)
return;
- gui_redraw_window_title (window);
- gui_redraw_window_chat (window);
- if (window->win_nick)
- gui_redraw_window_nick (window);
- gui_redraw_window_status (window);
+ gui_redraw_view_title (view);
+ gui_redraw_view_chat (view);
+ if (view->window->win_nick)
+ gui_redraw_view_nick (view);
+ gui_redraw_view_status (view);
if (cfg_look_infobar)
- gui_redraw_window_infobar (window);
- gui_redraw_window_input (window);
+ gui_redraw_view_infobar (view);
+ gui_redraw_view_input (view);
}
/*
- * gui_switch_to_window: switch to another window
+ * gui_switch_to_view: switch to another view
*/
void
-gui_switch_to_window (t_gui_window *window)
+gui_switch_to_view (t_gui_view *view)
{
- int another_window;
- t_gui_window *ptr_win;
+ int another_view;
+ t_gui_view *ptr_view;
- another_window = 0;
- for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
+ another_view = 0;
+ /*for (ptr_view = gui_views; ptr_view; ptr_view = ptr_view->next_view)
{
- if (ptr_win->is_displayed)
- {
- /* TODO: manage splitted windows */
- another_window = 1;
- window->win_title = ptr_win->win_title;
- window->win_chat = ptr_win->win_chat;
- window->win_nick = ptr_win->win_nick;
- window->win_status = ptr_win->win_status;
- window->win_infobar = ptr_win->win_infobar;
- window->win_input = ptr_win->win_input;
- if (ptr_win != window)
+ if (ptr_view->is_displayed)
+ {*/
+ /* TODO: manage splited windows */
+ /*another_view = 1;
+ view->window->win_title = ptr_view->window->win_title;
+ view->window->win_chat = ptr_view->window->win_chat;
+ view->window->win_nick = ptr_view->window->win_nick;
+ view->window->win_status = ptr_view->window->win_status;
+ view->window->win_infobar = ptr_view->window->win_infobar;
+ view->window->win_input = ptr_view->window->win_input;
+ if (ptr_view != view)
{
- ptr_win->win_title = NULL;
- ptr_win->win_chat = NULL;
- ptr_win->win_nick = NULL;
- ptr_win->win_status = NULL;
- ptr_win->win_infobar = NULL;
- ptr_win->win_input = NULL;
- ptr_win->is_displayed = 0;
+ ptr_view->window->win_title = NULL;
+ ptr_view->window->win_chat = NULL;
+ ptr_view->window->win_nick = NULL;
+ ptr_view->window->win_status = NULL;
+ ptr_view->window->win_infobar = NULL;
+ ptr_view->window->win_input = NULL;
+ ptr_view->is_displayed = 0;
}
break;
}
- }
+ }*/
- gui_calculate_pos_size (window);
+ gui_calculate_pos_size (view);
- /* first time creation for windows */
- if (!another_window)
+ /* first time creation for views */
+ if (!another_view)
{
- /* create new windows */
- window->win_title = newwin (1, COLS, 0, 0);
- window->win_chat = newwin (window->win_chat_height,
- window->win_chat_width,
- window->win_chat_y,
- window->win_chat_x);
- if (cfg_look_nicklist && CHANNEL(window))
- window->win_nick = newwin (window->win_nick_height,
- window->win_nick_width,
- window->win_nick_y,
- window->win_nick_x);
+ /* create new views */
+ view->window->win_title = newwin (1, COLS, 0, 0);
+ view->window->win_chat = newwin (view->window->win_chat_height,
+ view->window->win_chat_width,
+ view->window->win_chat_y,
+ view->window->win_chat_x);
+ if (cfg_look_nicklist && CHANNEL(view))
+ view->window->win_nick = newwin (view->window->win_nick_height,
+ view->window->win_nick_width,
+ view->window->win_nick_y,
+ view->window->win_nick_x);
else
- window->win_nick = NULL;
- window->win_input = newwin (1, COLS, LINES - 1, 0);
+ view->window->win_nick = NULL;
+ view->window->win_input = newwin (1, COLS, LINES - 1, 0);
}
else
{
- /* remove some windows */
- if (window->win_nick)
+ /* remove some views */
+ if (view->window->win_nick)
{
- delwin (window->win_nick);
- window->win_nick = NULL;
+ delwin (view->window->win_nick);
+ view->window->win_nick = NULL;
}
- if (window->win_status)
+ if (view->window->win_status)
{
- delwin (window->win_status);
- window->win_status = NULL;
+ delwin (view->window->win_status);
+ view->window->win_status = NULL;
}
- if (window->win_infobar)
+ if (view->window->win_infobar)
{
- delwin (window->win_infobar);
- window->win_infobar = NULL;
+ delwin (view->window->win_infobar);
+ view->window->win_infobar = NULL;
}
- /* create windows */
- if (WIN_IS_CHANNEL(window))
+ /* create views */
+ if (VIEW_IS_CHANNEL(view))
{
- delwin (window->win_chat);
- window->win_chat = newwin (window->win_chat_height,
- window->win_chat_width,
- window->win_chat_y,
- window->win_chat_x);
+ delwin (view->window->win_chat);
+ view->window->win_chat = newwin (view->window->win_chat_height,
+ view->window->win_chat_width,
+ view->window->win_chat_y,
+ view->window->win_chat_x);
if (cfg_look_nicklist)
- window->win_nick = newwin (window->win_nick_height,
- window->win_nick_width,
- window->win_nick_y,
- window->win_nick_x);
+ view->window->win_nick = newwin (view->window->win_nick_height,
+ view->window->win_nick_width,
+ view->window->win_nick_y,
+ view->window->win_nick_x);
else
- window->win_nick = NULL;
+ view->window->win_nick = NULL;
}
- if (!(WIN_IS_CHANNEL(window)))
+ if (!(VIEW_IS_CHANNEL(view)))
{
- delwin (window->win_chat);
- window->win_chat = newwin (window->win_chat_height,
- window->win_chat_width,
- window->win_chat_y,
- window->win_chat_x);
+ delwin (view->window->win_chat);
+ view->window->win_chat = newwin (view->window->win_chat_height,
+ view->window->win_chat_width,
+ view->window->win_chat_y,
+ view->window->win_chat_x);
}
}
/* create status/infobar windows */
if (cfg_look_infobar)
{
- window->win_infobar = newwin (1, COLS, LINES - 2, 0);
- window->win_status = newwin (1, COLS, LINES - 3, 0);
+ view->window->win_infobar = newwin (1, COLS, LINES - 2, 0);
+ view->window->win_status = newwin (1, COLS, LINES - 3, 0);
}
else
- window->win_status = newwin (1, COLS, LINES - 2, 0);
+ view->window->win_status = newwin (1, COLS, LINES - 2, 0);
- /* change current window to the new window */
- gui_current_window = window;
+ /* change current view to the new view */
+ gui_current_view = view;
- window->is_displayed = 1;
- window->unread_data = 0;
+ view->is_displayed = 1;
+ view->unread_data = 0;
}
/*
- * gui_switch_to_previous_window: switch to previous window
+ * gui_switch_to_previous_view: switch to previous view
*/
void
-gui_switch_to_previous_window ()
+gui_switch_to_previous_view ()
{
- /* if only one windows then return */
- if (gui_windows == last_gui_window)
+ /* if only one view then return */
+ if (gui_views == last_gui_view)
return;
- if (gui_current_window->prev_window)
- gui_switch_to_window (gui_current_window->prev_window);
+ if (gui_current_view->prev_view)
+ gui_switch_to_view (gui_current_view->prev_view);
else
- gui_switch_to_window (last_gui_window);
- gui_redraw_window (gui_current_window);
+ gui_switch_to_view (last_gui_view);
+ gui_redraw_view (gui_current_view);
}
/*
- * gui_switch_to_next_window: switch to next window
+ * gui_switch_to_next_view: switch to next view
*/
void
-gui_switch_to_next_window ()
+gui_switch_to_next_view ()
{
- /* if only one windows then return */
- if (gui_windows == last_gui_window)
+ /* if only one view then return */
+ if (gui_views == last_gui_view)
return;
- if (gui_current_window->next_window)
- gui_switch_to_window (gui_current_window->next_window);
+ if (gui_current_view->next_view)
+ gui_switch_to_view (gui_current_view->next_view);
else
- gui_switch_to_window (gui_windows);
- gui_redraw_window (gui_current_window);
+ gui_switch_to_view (gui_views);
+ gui_redraw_view (gui_current_view);
}
/*
- * gui_move_page_up: display previous page on window
+ * gui_move_page_up: display previous page on view
*/
void
gui_move_page_up ()
{
- if (!gui_current_window->first_line_displayed)
+ if (!gui_current_view->first_line_displayed)
{
- gui_current_window->sub_lines += gui_current_window->win_chat_height - 1;
- gui_draw_window_chat (gui_current_window);
- gui_draw_window_status (gui_current_window);
+ gui_current_view->sub_lines += gui_current_view->window->win_chat_height - 1;
+ gui_draw_view_chat (gui_current_view);
+ gui_draw_view_status (gui_current_view);
}
}
/*
- * gui_move_page_down: display next page on window
+ * gui_move_page_down: display next page on view
*/
void
gui_move_page_down ()
{
- if (gui_current_window->sub_lines > 0)
+ if (gui_current_view->sub_lines > 0)
{
- gui_current_window->sub_lines -= gui_current_window->win_chat_height - 1;
- if (gui_current_window->sub_lines < 0)
- gui_current_window->sub_lines = 0;
- if (gui_current_window->sub_lines == 0)
- gui_current_window->unread_data = 0;
- gui_draw_window_chat (gui_current_window);
- gui_draw_window_status (gui_current_window);
+ gui_current_view->sub_lines -= gui_current_view->window->win_chat_height - 1;
+ if (gui_current_view->sub_lines < 0)
+ gui_current_view->sub_lines = 0;
+ if (gui_current_view->sub_lines == 0)
+ gui_current_view->unread_data = 0;
+ gui_draw_view_chat (gui_current_view);
+ gui_draw_view_status (gui_current_view);
}
}
@@ -1384,7 +1384,7 @@ gui_move_page_down ()
void
gui_curses_resize_handler ()
{
- t_gui_window *ptr_win;
+ t_gui_view *ptr_view;
int width, height;
endwin ();
@@ -1392,48 +1392,48 @@ gui_curses_resize_handler ()
getmaxyx (stdscr, height, width);
- for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
+ for (ptr_view = gui_views; ptr_view; ptr_view = ptr_view->next_view)
{
- // TODO: manage splitted windows!
- if (ptr_win->win_title)
+ // TODO: manage splited windows!
+ if (ptr_view->window->win_title)
{
- ptr_win->is_displayed = 0;
- if (ptr_win->win_title)
- delwin (ptr_win->win_title);
- if (ptr_win->win_chat)
- delwin (ptr_win->win_chat);
- if (ptr_win->win_nick)
- delwin (ptr_win->win_nick);
- if (ptr_win->win_status)
- delwin (ptr_win->win_status);
- if (ptr_win->win_infobar)
- delwin (ptr_win->win_infobar);
- if (ptr_win->win_input)
- delwin (ptr_win->win_input);
- ptr_win->win_title = NULL;
- ptr_win->win_chat = NULL;
- ptr_win->win_nick = NULL;
- ptr_win->win_status = NULL;
- ptr_win->win_infobar = NULL;
- ptr_win->win_input = NULL;
- gui_switch_to_window (ptr_win);
+ ptr_view->is_displayed = 0;
+ if (ptr_view->window->win_title)
+ delwin (ptr_view->window->win_title);
+ if (ptr_view->window->win_chat)
+ delwin (ptr_view->window->win_chat);
+ if (ptr_view->window->win_nick)
+ delwin (ptr_view->window->win_nick);
+ if (ptr_view->window->win_status)
+ delwin (ptr_view->window->win_status);
+ if (ptr_view->window->win_infobar)
+ delwin (ptr_view->window->win_infobar);
+ if (ptr_view->window->win_input)
+ delwin (ptr_view->window->win_input);
+ ptr_view->window->win_title = NULL;
+ ptr_view->window->win_chat = NULL;
+ ptr_view->window->win_nick = NULL;
+ ptr_view->window->win_status = NULL;
+ ptr_view->window->win_infobar = NULL;
+ ptr_view->window->win_input = NULL;
+ gui_switch_to_view (ptr_view);
}
}
}
/*
- * gui_window_init_subwindows: init subwindows for a WeeChat window
+ * gui_view_init_subviews: init subviews for a WeeChat view
*/
void
-gui_window_init_subwindows (t_gui_window *window)
+gui_view_init_subviews (t_gui_view *view)
{
- window->win_title = NULL;
- window->win_chat = NULL;
- window->win_nick = NULL;
- window->win_status = NULL;
- window->win_infobar = NULL;
- window->win_input = NULL;
+ view->window->win_title = NULL;
+ view->window->win_chat = NULL;
+ view->window->win_nick = NULL;
+ view->window->win_status = NULL;
+ view->window->win_infobar = NULL;
+ view->window->win_input = NULL;
}
/*
@@ -1592,15 +1592,18 @@ gui_init ()
gui_infobar = NULL;
- /* create a new window */
- gui_current_window = gui_window_new (NULL, NULL, 1 /*0, 0, COLS, LINES*/);
+ /* create a new view */
+ if ((gui_windows = gui_window_new (0, 0, COLS, LINES)))
+ {
+ gui_current_view = gui_view_new (gui_windows, NULL, NULL, 1 /*0, 0, COLS, LINES*/);
- signal (SIGWINCH, gui_curses_resize_handler);
+ signal (SIGWINCH, gui_curses_resize_handler);
- if (cfg_look_set_title)
- gui_set_window_title ();
+ if (cfg_look_set_title)
+ gui_set_window_title ();
- gui_ready = 1;
+ gui_ready = 1;
+ }
}
/*
@@ -1610,23 +1613,23 @@ gui_init ()
void
gui_end ()
{
- t_gui_window *ptr_win;
+ t_gui_view *ptr_view;
- /* delete all windows */
- for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
+ /* delete all views */
+ for (ptr_view = gui_views; ptr_view; ptr_view = ptr_view->next_view)
{
- if (ptr_win->win_title)
- delwin (ptr_win->win_title);
- if (ptr_win->win_chat)
- delwin (ptr_win->win_chat);
- if (ptr_win->win_nick)
- delwin (ptr_win->win_nick);
- if (ptr_win->win_status)
- delwin (ptr_win->win_status);
- if (ptr_win->win_infobar)
- delwin (ptr_win->win_infobar);
- if (ptr_win->win_input)
- delwin (ptr_win->win_input);
+ if (ptr_view->window->win_title)
+ delwin (ptr_view->window->win_title);
+ if (ptr_view->window->win_chat)
+ delwin (ptr_view->window->win_chat);
+ if (ptr_view->window->win_nick)
+ delwin (ptr_view->window->win_nick);
+ if (ptr_view->window->win_status)
+ delwin (ptr_view->window->win_status);
+ if (ptr_view->window->win_infobar)
+ delwin (ptr_view->window->win_infobar);
+ if (ptr_view->window->win_input)
+ delwin (ptr_view->window->win_input);
/* TODO: free input buffer, lines, messages, completion */
}
@@ -1636,69 +1639,69 @@ gui_end ()
}
/*
- * gui_add_message: add a message to a window
+ * gui_add_message: add a message to a view
*/
void
-gui_add_message (t_gui_window *window, int type, int color, char *message)
+gui_add_message (t_gui_view *view, int type, int color, char *message)
{
char *pos;
int length;
/* create new line if previous was ending by '\n' (or if 1st line) */
- if (window->line_complete)
+ if (view->line_complete)
{
- window->line_complete = 0;
- if (!gui_new_line (window))
+ view->line_complete = 0;
+ if (!gui_new_line (view))
return;
}
- if (!gui_new_message (window))
+ if (!gui_new_message (view))
return;
- window->last_line->last_message->type = type;
- window->last_line->last_message->color = color;
+ view->last_line->last_message->type = type;
+ view->last_line->last_message->color = color;
pos = strchr (message, '\n');
if (pos)
{
pos[0] = '\0';
- window->line_complete = 1;
+ view->line_complete = 1;
}
- window->last_line->last_message->message = strdup (message);
+ view->last_line->last_message->message = strdup (message);
length = strlen (message);
- window->last_line->length += length;
+ view->last_line->length += length;
if (type == MSG_TYPE_MSG)
- window->last_line->line_with_message = 1;
+ view->last_line->line_with_message = 1;
if ((type == MSG_TYPE_TIME) || (type == MSG_TYPE_NICK))
- window->last_line->length_align += length;
+ view->last_line->length_align += length;
if (pos)
{
pos[0] = '\n';
- if ((window == gui_current_window) && (window->sub_lines == 0))
+ if ((view == gui_current_view) && (view->sub_lines == 0))
{
- if ((window->win_chat_cursor_y
- + gui_get_line_num_splits (window, window->last_line)) >
- (window->win_chat_height - 1))
- gui_draw_window_chat (window);
+ if ((view->window->win_chat_cursor_y
+ + gui_get_line_num_splits (view, view->last_line)) >
+ (view->window->win_chat_height - 1))
+ gui_draw_view_chat (view);
else
- gui_display_line (window, window->last_line, 1);
+ gui_display_line (view, view->last_line, 1);
}
- if ((window != gui_current_window) || (window->sub_lines > 0))
+ if ((view != gui_current_view) || (view->sub_lines > 0))
{
- if (window->unread_data < 1 + window->last_line->line_with_message)
+ if (view->unread_data < 1 + view->last_line->line_with_message)
{
- window->unread_data = 1 + window->last_line->line_with_message;
- gui_redraw_window_status (gui_current_window);
+ view->unread_data = 1 + view->last_line->line_with_message;
+ gui_redraw_view_status (gui_current_view);
}
}
}
}
/*
- * gui_printf_color_type: display a message in a window
+ * gui_printf_color_type: display a message in a view
*/
void
-gui_printf_color_type (t_gui_window *window, int type, int color, char *message, ...)
+gui_printf_color_type (t_gui_view *view, int type, int color, char *message, ...)
{
static char buffer[8192];
char timestamp[16];
@@ -1712,17 +1715,17 @@ gui_printf_color_type (t_gui_window *window, int type, int color, char *message,
if (color == -1)
color = COLOR_WIN_CHAT;
- if (window == NULL)
+ if (view == NULL)
{
- if (SERVER(gui_current_window))
- window = SERVER(gui_current_window)->window;
+ if (SERVER(gui_current_view))
+ view = SERVER(gui_current_view)->view;
else
- window = gui_current_window;
+ view = gui_current_view;
}
- if (window == NULL)
+ if (view == NULL)
{
- wee_log_printf ("gui_printf without window! this is a bug, please send to developers - thanks\n");
+ wee_log_printf ("gui_printf without view! this is a bug, please send to developers - thanks\n");
return;
}
}
@@ -1740,26 +1743,26 @@ gui_printf_color_type (t_gui_window *window, int type, int color, char *message,
while (pos)
{
/* TODO: read timestamp format from config! */
- if ((!window->last_line) || (window->line_complete))
+ if ((!view->last_line) || (view->line_complete))
{
- gui_add_message (window, MSG_TYPE_TIME, COLOR_WIN_CHAT_DARK, "[");
+ gui_add_message (view, MSG_TYPE_TIME, COLOR_WIN_CHAT_DARK, "[");
snprintf (timestamp, 16, "%02d", date_tmp->tm_hour);
- gui_add_message (window, MSG_TYPE_TIME, COLOR_WIN_CHAT_TIME, timestamp);
- gui_add_message (window, MSG_TYPE_TIME, COLOR_WIN_CHAT_TIME_SEP, ":");
+ gui_add_message (view, MSG_TYPE_TIME, COLOR_WIN_CHAT_TIME, timestamp);
+ gui_add_message (view, MSG_TYPE_TIME, COLOR_WIN_CHAT_TIME_SEP, ":");
snprintf (timestamp, 16, "%02d", date_tmp->tm_min);
- gui_add_message (window, MSG_TYPE_TIME, COLOR_WIN_CHAT_TIME, timestamp);
- gui_add_message (window, MSG_TYPE_TIME, COLOR_WIN_CHAT_TIME_SEP, ":");
+ gui_add_message (view, MSG_TYPE_TIME, COLOR_WIN_CHAT_TIME, timestamp);
+ gui_add_message (view, MSG_TYPE_TIME, COLOR_WIN_CHAT_TIME_SEP, ":");
snprintf (timestamp, 16, "%02d", date_tmp->tm_sec);
- gui_add_message (window, MSG_TYPE_TIME, COLOR_WIN_CHAT_TIME, timestamp);
- gui_add_message (window, MSG_TYPE_TIME, COLOR_WIN_CHAT_DARK, "] ");
+ gui_add_message (view, MSG_TYPE_TIME, COLOR_WIN_CHAT_TIME, timestamp);
+ gui_add_message (view, MSG_TYPE_TIME, COLOR_WIN_CHAT_DARK, "] ");
}
- gui_add_message (window, type, color, pos + 1);
+ gui_add_message (view, type, color, pos + 1);
pos = strchr (pos + 1, '\n');
if (pos && !pos[1])
pos = NULL;
}
- wrefresh (window->win_chat);
+ wrefresh (view->window->win_chat);
refresh ();
}
else
diff --git a/src/gui/curses/gui-input.c b/src/gui/curses/gui-input.c
index 95b22670c..be601dfa8 100644
--- a/src/gui/curses/gui-input.c
+++ b/src/gui/curses/gui-input.c
@@ -49,7 +49,7 @@ void
gui_read_keyb ()
{
int key, i;
- t_gui_window *ptr_window;
+ t_gui_view *ptr_view;
char new_char[2];
key = getch ();
@@ -59,16 +59,16 @@ gui_read_keyb ()
{
/* resize event */
case KEY_RESIZE:
- gui_calculate_pos_size (gui_current_window);
- gui_redraw_window (gui_current_window);
+ gui_calculate_pos_size (gui_current_view);
+ gui_redraw_view (gui_current_view);
break;
- /* previous window */
+ /* previous view */
case KEY_F(6):
- gui_switch_to_previous_window ();
+ gui_switch_to_previous_view ();
break;
- /* next window */
+ /* next view */
case KEY_F(7):
- gui_switch_to_next_window ();
+ gui_switch_to_next_view ();
break;
/* remove last infobar message */
case KEY_F(10):
@@ -76,82 +76,82 @@ gui_read_keyb ()
break;
/* cursor up */
case KEY_UP:
- if (gui_current_window->ptr_history)
+ if (gui_current_view->ptr_history)
{
- gui_current_window->ptr_history =
- gui_current_window->ptr_history->next_history;
- if (!gui_current_window->ptr_history)
- gui_current_window->ptr_history =
- gui_current_window->history;
+ gui_current_view->ptr_history =
+ gui_current_view->ptr_history->next_history;
+ if (!gui_current_view->ptr_history)
+ gui_current_view->ptr_history =
+ gui_current_view->history;
}
else
- gui_current_window->ptr_history =
- gui_current_window->history;
- if (gui_current_window->ptr_history)
+ gui_current_view->ptr_history =
+ gui_current_view->history;
+ if (gui_current_view->ptr_history)
{
- gui_current_window->input_buffer_size =
- strlen (gui_current_window->ptr_history->text);
- gui_optimize_input_buffer_size (gui_current_window);
- gui_current_window->input_buffer_pos =
- gui_current_window->input_buffer_size;
- strcpy (gui_current_window->input_buffer,
- gui_current_window->ptr_history->text);
- gui_draw_window_input (gui_current_window);
+ gui_current_view->input_buffer_size =
+ strlen (gui_current_view->ptr_history->text);
+ gui_optimize_input_buffer_size (gui_current_view);
+ gui_current_view->input_buffer_pos =
+ gui_current_view->input_buffer_size;
+ strcpy (gui_current_view->input_buffer,
+ gui_current_view->ptr_history->text);
+ gui_draw_view_input (gui_current_view);
}
break;
/* cursor down */
case KEY_DOWN:
- if (gui_current_window->ptr_history)
+ if (gui_current_view->ptr_history)
{
- gui_current_window->ptr_history =
- gui_current_window->ptr_history->prev_history;
- if (gui_current_window->ptr_history)
- gui_current_window->input_buffer_size =
- strlen (gui_current_window->ptr_history->text);
+ gui_current_view->ptr_history =
+ gui_current_view->ptr_history->prev_history;
+ if (gui_current_view->ptr_history)
+ gui_current_view->input_buffer_size =
+ strlen (gui_current_view->ptr_history->text);
else
- gui_current_window->input_buffer_size = 0;
- gui_optimize_input_buffer_size (gui_current_window);
- gui_current_window->input_buffer_pos =
- gui_current_window->input_buffer_size;
- if (gui_current_window->ptr_history)
- strcpy (gui_current_window->input_buffer,
- gui_current_window->ptr_history->text);
- gui_draw_window_input (gui_current_window);
+ gui_current_view->input_buffer_size = 0;
+ gui_optimize_input_buffer_size (gui_current_view);
+ gui_current_view->input_buffer_pos =
+ gui_current_view->input_buffer_size;
+ if (gui_current_view->ptr_history)
+ strcpy (gui_current_view->input_buffer,
+ gui_current_view->ptr_history->text);
+ gui_draw_view_input (gui_current_view);
}
break;
/* cursor left */
case KEY_LEFT:
- if (gui_current_window->input_buffer_pos > 0)
+ if (gui_current_view->input_buffer_pos > 0)
{
- gui_current_window->input_buffer_pos--;
- gui_draw_window_input (gui_current_window);
+ gui_current_view->input_buffer_pos--;
+ gui_draw_view_input (gui_current_view);
}
break;
/* cursor right */
case KEY_RIGHT:
- if (gui_current_window->input_buffer_pos <
- gui_current_window->input_buffer_size)
+ if (gui_current_view->input_buffer_pos <
+ gui_current_view->input_buffer_size)
{
- gui_current_window->input_buffer_pos++;
- gui_draw_window_input (gui_current_window);
+ gui_current_view->input_buffer_pos++;
+ gui_draw_view_input (gui_current_view);
}
break;
/* home key */
case KEY_HOME:
- if (gui_current_window->input_buffer_pos > 0)
+ if (gui_current_view->input_buffer_pos > 0)
{
- gui_current_window->input_buffer_pos = 0;
- gui_draw_window_input (gui_current_window);
+ gui_current_view->input_buffer_pos = 0;
+ gui_draw_view_input (gui_current_view);
}
break;
/* end key */
case KEY_END:
- if (gui_current_window->input_buffer_pos <
- gui_current_window->input_buffer_size)
+ if (gui_current_view->input_buffer_pos <
+ gui_current_view->input_buffer_size)
{
- gui_current_window->input_buffer_pos =
- gui_current_window->input_buffer_size;
- gui_draw_window_input (gui_current_window);
+ gui_current_view->input_buffer_pos =
+ gui_current_view->input_buffer_size;
+ gui_draw_view_input (gui_current_view);
}
break;
/* page up */
@@ -165,21 +165,21 @@ gui_read_keyb ()
/* erase before cursor and move cursor to the left */
case 127:
case KEY_BACKSPACE:
- if (gui_current_window->input_buffer_pos > 0)
+ if (gui_current_view->input_buffer_pos > 0)
{
- i = gui_current_window->input_buffer_pos-1;
- while (gui_current_window->input_buffer[i])
+ i = gui_current_view->input_buffer_pos-1;
+ while (gui_current_view->input_buffer[i])
{
- gui_current_window->input_buffer[i] =
- gui_current_window->input_buffer[i+1];
+ gui_current_view->input_buffer[i] =
+ gui_current_view->input_buffer[i+1];
i++;
}
- gui_current_window->input_buffer_size--;
- gui_current_window->input_buffer_pos--;
- gui_current_window->input_buffer[gui_current_window->input_buffer_size] = '\0';
- gui_draw_window_input (gui_current_window);
- gui_optimize_input_buffer_size (gui_current_window);
- gui_current_window->completion.position = -1;
+ gui_current_view->input_buffer_size--;
+ gui_current_view->input_buffer_pos--;
+ gui_current_view->input_buffer[gui_current_view->input_buffer_size] = '\0';
+ gui_draw_view_input (gui_current_view);
+ gui_optimize_input_buffer_size (gui_current_view);
+ gui_current_view->completion.position = -1;
}
break;
/* Control + Backspace */
@@ -188,93 +188,93 @@ gui_read_keyb ()
break;
/* erase char under cursor */
case KEY_DC:
- if (gui_current_window->input_buffer_pos <
- gui_current_window->input_buffer_size)
+ if (gui_current_view->input_buffer_pos <
+ gui_current_view->input_buffer_size)
{
- i = gui_current_window->input_buffer_pos;
- while (gui_current_window->input_buffer[i])
+ i = gui_current_view->input_buffer_pos;
+ while (gui_current_view->input_buffer[i])
{
- gui_current_window->input_buffer[i] =
- gui_current_window->input_buffer[i+1];
+ gui_current_view->input_buffer[i] =
+ gui_current_view->input_buffer[i+1];
i++;
}
- gui_current_window->input_buffer_size--;
- gui_current_window->input_buffer[gui_current_window->input_buffer_size] = '\0';
- gui_draw_window_input (gui_current_window);
- gui_optimize_input_buffer_size (gui_current_window);
- gui_current_window->completion.position = -1;
+ gui_current_view->input_buffer_size--;
+ gui_current_view->input_buffer[gui_current_view->input_buffer_size] = '\0';
+ gui_draw_view_input (gui_current_view);
+ gui_optimize_input_buffer_size (gui_current_view);
+ gui_current_view->completion.position = -1;
}
break;
/* Tab : completion */
case '\t':
- completion_search (&(gui_current_window->completion),
- CHANNEL(gui_current_window),
- gui_current_window->input_buffer,
- gui_current_window->input_buffer_size,
- gui_current_window->input_buffer_pos);
- if (gui_current_window->completion.word_found)
+ completion_search (&(gui_current_view->completion),
+ CHANNEL(gui_current_view),
+ gui_current_view->input_buffer,
+ gui_current_view->input_buffer_size,
+ gui_current_view->input_buffer_pos);
+ if (gui_current_view->completion.word_found)
{
// replace word with new completed word into input buffer
- gui_current_window->input_buffer_size +=
- gui_current_window->completion.diff_size;
- gui_optimize_input_buffer_size (gui_current_window);
- gui_current_window->input_buffer[gui_current_window->input_buffer_size] = '\0';
+ gui_current_view->input_buffer_size +=
+ gui_current_view->completion.diff_size;
+ gui_optimize_input_buffer_size (gui_current_view);
+ gui_current_view->input_buffer[gui_current_view->input_buffer_size] = '\0';
- if (gui_current_window->completion.diff_size > 0)
+ if (gui_current_view->completion.diff_size > 0)
{
- for (i = gui_current_window->input_buffer_size - 1;
- i >= gui_current_window->completion.position_replace +
- (int)strlen (gui_current_window->completion.word_found); i--)
- gui_current_window->input_buffer[i] =
- gui_current_window->input_buffer[i -
- gui_current_window->completion.diff_size];
+ for (i = gui_current_view->input_buffer_size - 1;
+ i >= gui_current_view->completion.position_replace +
+ (int)strlen (gui_current_view->completion.word_found); i--)
+ gui_current_view->input_buffer[i] =
+ gui_current_view->input_buffer[i -
+ gui_current_view->completion.diff_size];
}
else
{
- for (i = gui_current_window->completion.position_replace +
- strlen (gui_current_window->completion.word_found);
- i < gui_current_window->input_buffer_size; i++)
- gui_current_window->input_buffer[i] =
- gui_current_window->input_buffer[i -
- gui_current_window->completion.diff_size];
+ for (i = gui_current_view->completion.position_replace +
+ strlen (gui_current_view->completion.word_found);
+ i < gui_current_view->input_buffer_size; i++)
+ gui_current_view->input_buffer[i] =
+ gui_current_view->input_buffer[i -
+ gui_current_view->completion.diff_size];
}
- strncpy (gui_current_window->input_buffer + gui_current_window->completion.position_replace,
- gui_current_window->completion.word_found,
- strlen (gui_current_window->completion.word_found));
- gui_current_window->input_buffer_pos =
- gui_current_window->completion.position_replace +
- strlen (gui_current_window->completion.word_found);
- gui_current_window->completion.position =
- gui_current_window->input_buffer_pos;
+ strncpy (gui_current_view->input_buffer + gui_current_view->completion.position_replace,
+ gui_current_view->completion.word_found,
+ strlen (gui_current_view->completion.word_found));
+ gui_current_view->input_buffer_pos =
+ gui_current_view->completion.position_replace +
+ strlen (gui_current_view->completion.word_found);
+ gui_current_view->completion.position =
+ gui_current_view->input_buffer_pos;
/* add space or completor to the end of completion, if needed */
- if (gui_current_window->completion.base_word[0] == '/')
+ if (gui_current_view->completion.base_word[0] == '/')
{
- if (gui_current_window->input_buffer[gui_current_window->input_buffer_pos] != ' ')
+ if (gui_current_view->input_buffer[gui_current_view->input_buffer_pos] != ' ')
gui_buffer_insert_string (" ",
- gui_current_window->input_buffer_pos);
- gui_current_window->completion.position++;
- gui_current_window->input_buffer_pos++;
+ gui_current_view->input_buffer_pos);
+ gui_current_view->completion.position++;
+ gui_current_view->input_buffer_pos++;
}
else
{
- if (gui_current_window->completion.base_word_pos == 0)
+ if (gui_current_view->completion.base_word_pos == 0)
{
- if (strncmp (gui_current_window->input_buffer + gui_current_window->input_buffer_pos,
+ if (strncmp (gui_current_view->input_buffer + gui_current_view->input_buffer_pos,
cfg_look_completor, strlen (cfg_look_completor)) != 0)
gui_buffer_insert_string (cfg_look_completor,
- gui_current_window->input_buffer_pos);
- gui_current_window->completion.position += strlen (cfg_look_completor);
- gui_current_window->input_buffer_pos += strlen (cfg_look_completor);
- if (gui_current_window->input_buffer[gui_current_window->input_buffer_pos] != ' ')
+ gui_current_view->input_buffer_pos);
+ gui_current_view->completion.position += strlen (cfg_look_completor);
+ gui_current_view->input_buffer_pos += strlen (cfg_look_completor);
+ if (gui_current_view->input_buffer[gui_current_view->input_buffer_pos] != ' ')
gui_buffer_insert_string (" ",
- gui_current_window->input_buffer_pos);
- gui_current_window->completion.position++;
- gui_current_window->input_buffer_pos++;
+ gui_current_view->input_buffer_pos);
+ gui_current_view->completion.position++;
+ gui_current_view->input_buffer_pos++;
}
}
- gui_draw_window_input (gui_current_window);
+ gui_draw_view_input (gui_current_view);
}
break;
/* escape code (for control-key) */
@@ -284,10 +284,10 @@ gui_read_keyb ()
switch (key)
{
case KEY_LEFT:
- gui_switch_to_previous_window ();
+ gui_switch_to_previous_view ();
break;
case KEY_RIGHT:
- gui_switch_to_next_window ();
+ gui_switch_to_next_view ();
break;
case 79:
/* TODO: replace 79 by constant name! */
@@ -314,35 +314,35 @@ gui_read_keyb ()
break;
/* send command/message */
case '\n':
- if (gui_current_window->input_buffer_size > 0)
+ if (gui_current_view->input_buffer_size > 0)
{
- gui_current_window->input_buffer[gui_current_window->input_buffer_size] = '\0';
- history_add (gui_current_window, gui_current_window->input_buffer);
- gui_current_window->input_buffer_size = 0;
- gui_current_window->input_buffer_pos = 0;
- gui_current_window->input_buffer_1st_display = 0;
- gui_current_window->completion.position = -1;
- gui_current_window->ptr_history = NULL;
- ptr_window = gui_current_window;
- user_command (SERVER(gui_current_window),
- gui_current_window->input_buffer);
- if (ptr_window == gui_current_window)
- gui_draw_window_input (ptr_window);
- if (ptr_window)
- ptr_window->input_buffer[0] = '\0';
+ gui_current_view->input_buffer[gui_current_view->input_buffer_size] = '\0';
+ history_add (gui_current_view, gui_current_view->input_buffer);
+ gui_current_view->input_buffer_size = 0;
+ gui_current_view->input_buffer_pos = 0;
+ gui_current_view->input_buffer_1st_display = 0;
+ gui_current_view->completion.position = -1;
+ gui_current_view->ptr_history = NULL;
+ ptr_view = gui_current_view;
+ user_command (SERVER(gui_current_view),
+ gui_current_view->input_buffer);
+ if (ptr_view == gui_current_view)
+ gui_draw_view_input (ptr_view);
+ if (ptr_view)
+ ptr_view->input_buffer[0] = '\0';
}
break;
/* other key => add to input buffer */
default:
- /*gui_printf (gui_current_window,
+ /*gui_printf (gui_current_view,
"[Debug] key pressed = %d, as octal: %o\n", key, key);*/
new_char[0] = key;
new_char[1] = '\0';
gui_buffer_insert_string (new_char,
- gui_current_window->input_buffer_pos);
- gui_current_window->input_buffer_pos++;
- gui_draw_window_input (gui_current_window);
- gui_current_window->completion.position = -1;
+ gui_current_view->input_buffer_pos);
+ gui_current_view->input_buffer_pos++;
+ gui_draw_view_input (gui_current_view);
+ gui_current_view->completion.position = -1;
break;
}
}
@@ -374,14 +374,14 @@ gui_main_loop ()
if (local_time->tm_min != old_min)
{
old_min = local_time->tm_min;
- gui_redraw_window_infobar (gui_current_window);
+ gui_redraw_view_infobar (gui_current_view);
}
/* second has changed ? => count down time for infobar, if needed */
if (local_time->tm_sec != old_sec)
{
old_sec = local_time->tm_sec;
- /* TODO: manage splitted windows! */
+ /* TODO: manage splited windows! */
if (gui_infobar && gui_infobar->remaining_time > 0)
{
gui_infobar->remaining_time--;
diff --git a/src/gui/gui-common.c b/src/gui/gui-common.c
index 4da80b9e9..ce7d53d94 100644
--- a/src/gui/gui-common.c
+++ b/src/gui/gui-common.c
@@ -41,151 +41,200 @@
int gui_ready; /* = 1 if GUI is initialized */
t_gui_window *gui_windows = NULL; /* pointer to first window */
-t_gui_window *last_gui_window = NULL; /* pointer to last window */
-t_gui_window *gui_current_window = NULL; /* pointer to current window */
+
+t_gui_view *gui_views = NULL; /* pointer to first view */
+t_gui_view *last_gui_view = NULL; /* pointer to last view */
+t_gui_view *gui_current_view = NULL; /* pointer to current view */
t_gui_infobar *gui_infobar; /* pointer to infobar content */
/*
* gui_window_new: create a new window
- * (TODO: add coordinates and size, for splited windows)
*/
t_gui_window *
-gui_window_new (void *server, void *channel, int switch_to_window
- /*int x, int y, int width, int height*/)
+gui_window_new (int x, int y, int width, int height)
{
- t_gui_window *new_window;
+ t_gui_window *window;
- if (gui_windows)
+ if ((window = (t_gui_window *)(malloc (sizeof (t_gui_window)))))
{
- /* use first window if no server was assigned to this window */
- if (!SERVER(gui_windows))
+ window->win_x = x;
+ window->win_y = y;
+ window->win_width = width;
+ window->win_height = height;
+
+ window->win_chat_x = 0;
+ window->win_chat_y = 0;
+ window->win_chat_width = 0;
+ window->win_chat_height = 0;
+ window->win_chat_cursor_x = 0;
+ window->win_chat_cursor_y = 0;
+
+ window->win_nick_x = 0;
+ window->win_nick_y = 0;
+ window->win_nick_width = 0;
+ window->win_nick_height = 0;
+
+ window->win_title = NULL;
+ window->win_chat = NULL;
+ window->win_nick = NULL;
+ window->win_status = NULL;
+ window->win_infobar = NULL;
+ window->win_input = NULL;
+ window->textview_chat = NULL;
+ window->textbuffer_chat = NULL;
+ window->texttag_chat = NULL;
+ window->textview_nicklist = NULL;
+ window->textbuffer_nicklist = NULL;
+ }
+ else
+ return NULL;
+
+ return window;
+}
+
+/*
+ * gui_view_new: create a new view in current window
+ */
+
+t_gui_view *
+gui_view_new (t_gui_window *window, void *server, void *channel, int switch_to_view)
+{
+ t_gui_view *new_view;
+
+ if (gui_views)
+ {
+ /* use first view if no server was assigned to this view */
+ if (!SERVER(gui_views))
{
if (server)
- ((t_irc_server *)(server))->window = gui_windows;
+ ((t_irc_server *)(server))->view = gui_views;
if (channel)
- ((t_irc_channel *)(channel))->window = gui_windows;
- SERVER(gui_windows) = server;
- CHANNEL(gui_windows) = channel;
- return gui_windows;
+ ((t_irc_channel *)(channel))->view = gui_views;
+ SERVER(gui_views) = server;
+ CHANNEL(gui_views) = channel;
+ return gui_views;
}
}
- if ((new_window = (t_gui_window *)(malloc (sizeof (t_gui_window)))))
+ if ((new_view = (t_gui_view *)(malloc (sizeof (t_gui_view)))))
{
- new_window->is_displayed = 0;
+ new_view->is_displayed = 0;
- /* assign server and channel to window */
- SERVER(new_window) = server;
- CHANNEL(new_window) = channel;
- /* assign window to server and channel */
+ /* assign server and channel to view */
+ SERVER(new_view) = server;
+ CHANNEL(new_view) = channel;
+ /* assign view to server and channel */
if (server && !channel)
- SERVER(new_window)->window = new_window;
+ SERVER(new_view)->view = new_view;
if (channel)
- CHANNEL(new_window)->window = new_window;
+ CHANNEL(new_view)->view = new_view;
- gui_calculate_pos_size (new_window);
+ new_view->window = window;
- /* init windows */
- gui_window_init_subwindows(new_window);
+ gui_calculate_pos_size (new_view);
+
+ /* init views */
+ gui_view_init_subviews(new_view);
/* init lines */
- new_window->lines = NULL;
- new_window->last_line = NULL;
- new_window->num_lines = 0;
- new_window->first_line_displayed = 1;
- new_window->sub_lines = 0;
- new_window->line_complete = 1;
- new_window->unread_data = 0;
+ new_view->lines = NULL;
+ new_view->last_line = NULL;
+ new_view->num_lines = 0;
+ new_view->first_line_displayed = 1;
+ new_view->sub_lines = 0;
+ new_view->line_complete = 1;
+ new_view->unread_data = 0;
/* init input buffer */
- new_window->input_buffer_alloc = INPUT_BUFFER_BLOCK_SIZE;
- new_window->input_buffer = (char *) malloc (INPUT_BUFFER_BLOCK_SIZE);
- new_window->input_buffer[0] = '\0';
- new_window->input_buffer_size = 0;
- new_window->input_buffer_pos = 0;
- new_window->input_buffer_1st_display = 0;
+ new_view->input_buffer_alloc = INPUT_BUFFER_BLOCK_SIZE;
+ new_view->input_buffer = (char *) malloc (INPUT_BUFFER_BLOCK_SIZE);
+ new_view->input_buffer[0] = '\0';
+ new_view->input_buffer_size = 0;
+ new_view->input_buffer_pos = 0;
+ new_view->input_buffer_1st_display = 0;
/* init completion */
- completion_init (&(new_window->completion));
+ completion_init (&(new_view->completion));
/* init history */
- new_window->history = NULL;
- new_window->last_history = NULL;
- new_window->ptr_history = NULL;
- new_window->num_history = 0;
+ new_view->history = NULL;
+ new_view->last_history = NULL;
+ new_view->ptr_history = NULL;
+ new_view->num_history = 0;
- /* switch to new window */
- if (switch_to_window)
- gui_switch_to_window (new_window);
+ /* switch to new view */
+ if (switch_to_view)
+ gui_switch_to_view (new_view);
- /* add window to windows queue */
- new_window->prev_window = last_gui_window;
- if (gui_windows)
- last_gui_window->next_window = new_window;
+ /* add view to views queue */
+ new_view->prev_view = last_gui_view;
+ if (gui_views)
+ last_gui_view->next_view = new_view;
else
- gui_windows = new_window;
- last_gui_window = new_window;
- new_window->next_window = NULL;
+ gui_views = new_view;
+ last_gui_view = new_view;
+ new_view->next_view = NULL;
/* redraw whole screen */
- gui_redraw_window (gui_current_window);
+ /* TODO: manage splited windows */
+ gui_redraw_view (gui_current_view);
}
else
return NULL;
- return new_window;
+ return new_view;
}
/*
- * gui_window_clear: clear window content
+ * gui_view_clear: clear view content
*/
void
-gui_window_clear (t_gui_window *window)
+gui_view_clear (t_gui_view *view)
{
t_gui_line *ptr_line;
t_gui_message *ptr_message;
- while (window->lines)
+ while (view->lines)
{
- ptr_line = window->lines->next_line;
- while (window->lines->messages)
+ ptr_line = view->lines->next_line;
+ while (view->lines->messages)
{
- ptr_message = window->lines->messages->next_message;
- if (window->lines->messages->message)
- free (window->lines->messages->message);
- free (window->lines->messages);
- window->lines->messages = ptr_message;
+ ptr_message = view->lines->messages->next_message;
+ if (view->lines->messages->message)
+ free (view->lines->messages->message);
+ free (view->lines->messages);
+ view->lines->messages = ptr_message;
}
- free (window->lines);
- window->lines = ptr_line;
+ free (view->lines);
+ view->lines = ptr_line;
}
- window->lines = NULL;
- window->last_line = NULL;
- window->num_lines = 0;
- window->first_line_displayed = 1;
- window->sub_lines = 0;
- window->line_complete = 1;
- window->unread_data = 0;
+ view->lines = NULL;
+ view->last_line = NULL;
+ view->num_lines = 0;
+ view->first_line_displayed = 1;
+ view->sub_lines = 0;
+ view->line_complete = 1;
+ view->unread_data = 0;
- if (window == gui_current_window)
- gui_redraw_window_chat (window);
+ if (view == gui_current_view)
+ gui_redraw_view_chat (view);
}
/*
- * gui_window_clear_all: clear all windows content
+ * gui_view_clear_all: clear all views content
*/
void
-gui_window_clear_all ()
+gui_view_clear_all ()
{
- t_gui_window *ptr_win;
+ t_gui_view *ptr_view;
- for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
- gui_window_clear (ptr_win);
+ for (ptr_view = gui_views; ptr_view; ptr_view = ptr_view->next_view)
+ gui_view_clear (ptr_view);
}
/*
@@ -215,8 +264,8 @@ gui_infobar_printf (int time_displayed, int color, char *message, ...)
ptr_infobar->remaining_time = (time_displayed <= 0) ? -1 : time_displayed;
ptr_infobar->next_infobar = gui_infobar;
gui_infobar = ptr_infobar;
- /* TODO: manage splitted windows! */
- gui_redraw_window_infobar (gui_current_window);
+ /* TODO: manage splited windows! */
+ gui_redraw_view_infobar (gui_current_view);
}
else
wee_log_printf (_("%s not enough memory for infobar message\n"),
@@ -239,13 +288,13 @@ gui_infobar_remove ()
free (gui_infobar->text);
free (gui_infobar);
gui_infobar = new_infobar;
- /* TODO: manage splitted windows! */
- gui_redraw_window_infobar (gui_current_window);
+ /* TODO: manage splited windows! */
+ gui_redraw_view_infobar (gui_current_view);
}
}
/*
- * gui_line_free: delete a line from a window
+ * gui_line_free: delete a line from a view
*/
void
@@ -265,57 +314,57 @@ gui_line_free (t_gui_line *line)
}
/*
- * gui_window_free: delete a window
+ * gui_view_free: delete a view
*/
void
-gui_window_free (t_gui_window *window)
+gui_view_free (t_gui_view *view)
{
t_gui_line *ptr_line;
int create_new;
- create_new = (window->server || window->channel);
+ create_new = (view->server || view->channel);
- /* TODO: manage splitted windows! */
- if ((window == gui_current_window) &&
- ((window->next_window) || (window->prev_window)))
- gui_switch_to_previous_window ();
+ /* TODO: manage splited windows! */
+ if ((view == gui_current_view) &&
+ ((view->next_view) || (view->prev_view)))
+ gui_switch_to_previous_view ();
/* free lines and messages */
- while (window->lines)
+ while (view->lines)
{
- ptr_line = window->lines->next_line;
- gui_line_free (window->lines);
- window->lines = ptr_line;
+ ptr_line = view->lines->next_line;
+ gui_line_free (view->lines);
+ view->lines = ptr_line;
}
- if (window->input_buffer)
- free (window->input_buffer);
-
- completion_free (&(window->completion));
-
- /* remove window from windows list */
- if (window->prev_window)
- window->prev_window->next_window = window->next_window;
- if (window->next_window)
- window->next_window->prev_window = window->prev_window;
- if (gui_windows == window)
- gui_windows = window->next_window;
- if (last_gui_window == window)
- last_gui_window = window->prev_window;
-
- free (window);
-
- /* always at least one window */
- if (!gui_windows && create_new)
- (void) gui_window_new (NULL, NULL, 1);
+ if (view->input_buffer)
+ free (view->input_buffer);
+
+ completion_free (&(view->completion));
+
+ /* remove view from views list */
+ if (view->prev_view)
+ view->prev_view->next_view = view->next_view;
+ if (view->next_view)
+ view->next_view->prev_view = view->prev_view;
+ if (gui_views == view)
+ gui_views = view->next_view;
+ if (last_gui_view == view)
+ last_gui_view = view->prev_view;
+
+ free (view);
+
+ /* always at least one view */
+ if (!gui_views && create_new)
+ (void) gui_view_new (gui_windows, NULL, NULL, 1);
}
/*
- * gui_new_line: create new line for a window
+ * gui_new_line: create new line for a view
*/
t_gui_line *
-gui_new_line (t_gui_window *window)
+gui_new_line (t_gui_view *view)
{
t_gui_line *new_line, *ptr_line;
@@ -326,14 +375,14 @@ gui_new_line (t_gui_window *window)
new_line->line_with_message = 0;
new_line->messages = NULL;
new_line->last_message = NULL;
- if (!window->lines)
- window->lines = new_line;
+ if (!view->lines)
+ view->lines = new_line;
else
- window->last_line->next_line = new_line;
- new_line->prev_line = window->last_line;
+ view->last_line->next_line = new_line;
+ new_line->prev_line = view->last_line;
new_line->next_line = NULL;
- window->last_line = new_line;
- window->num_lines++;
+ view->last_line = new_line;
+ view->num_lines++;
}
else
{
@@ -343,40 +392,40 @@ gui_new_line (t_gui_window *window)
/* remove one line if necessary */
if ((cfg_history_max_lines > 0)
- && (window->num_lines > cfg_history_max_lines))
+ && (view->num_lines > cfg_history_max_lines))
{
- if (window->last_line == window->lines)
- window->last_line = NULL;
- ptr_line = window->lines->next_line;
- gui_line_free (window->lines);
- window->lines = ptr_line;
+ if (view->last_line == view->lines)
+ view->last_line = NULL;
+ ptr_line = view->lines->next_line;
+ gui_line_free (view->lines);
+ view->lines = ptr_line;
ptr_line->prev_line = NULL;
- window->num_lines--;
- if (window->first_line_displayed)
- gui_redraw_window_chat (window);
+ view->num_lines--;
+ if (view->first_line_displayed)
+ gui_redraw_view_chat (view);
}
return new_line;
}
/*
- * gui_new_message: create a new message for last line of window
+ * gui_new_message: create a new message for last line of a view
*/
t_gui_message *
-gui_new_message (t_gui_window *window)
+gui_new_message (t_gui_view *view)
{
t_gui_message *new_message;
if ((new_message = (t_gui_message *) malloc (sizeof (struct t_gui_message))))
{
- if (!window->last_line->messages)
- window->last_line->messages = new_message;
+ if (!view->last_line->messages)
+ view->last_line->messages = new_message;
else
- window->last_line->last_message->next_message = new_message;
- new_message->prev_message = window->last_line->last_message;
+ view->last_line->last_message->next_message = new_message;
+ new_message->prev_message = view->last_line->last_message;
new_message->next_message = NULL;
- window->last_line->last_message = new_message;
+ view->last_line->last_message = new_message;
}
else
{
@@ -392,16 +441,16 @@ gui_new_message (t_gui_window *window)
*/
void
-gui_optimize_input_buffer_size (t_gui_window *window)
+gui_optimize_input_buffer_size (t_gui_view *view)
{
int optimal_size;
- optimal_size = ((window->input_buffer_size / INPUT_BUFFER_BLOCK_SIZE) *
+ optimal_size = ((view->input_buffer_size / INPUT_BUFFER_BLOCK_SIZE) *
INPUT_BUFFER_BLOCK_SIZE) + INPUT_BUFFER_BLOCK_SIZE;
- if (window->input_buffer_alloc != optimal_size)
+ if (view->input_buffer_alloc != optimal_size)
{
- window->input_buffer_alloc = optimal_size;
- window->input_buffer = realloc (window->input_buffer, optimal_size);
+ view->input_buffer_alloc = optimal_size;
+ view->input_buffer = realloc (view->input_buffer, optimal_size);
}
}
@@ -414,21 +463,21 @@ gui_delete_previous_word ()
{
int i, j, num_char_deleted, num_char_end;
- if (gui_current_window->input_buffer_pos > 0)
+ if (gui_current_view->input_buffer_pos > 0)
{
- i = gui_current_window->input_buffer_pos - 1;
+ i = gui_current_view->input_buffer_pos - 1;
while ((i >= 0) &&
- (gui_current_window->input_buffer[i] == ' '))
+ (gui_current_view->input_buffer[i] == ' '))
i--;
if (i >= 0)
{
while ((i >= 0) &&
- (gui_current_window->input_buffer[i] != ' '))
+ (gui_current_view->input_buffer[i] != ' '))
i--;
if (i >= 0)
{
while ((i >= 0) &&
- (gui_current_window->input_buffer[i] == ' '))
+ (gui_current_view->input_buffer[i] == ' '))
i--;
}
}
@@ -436,20 +485,20 @@ gui_delete_previous_word ()
if (i >= 0)
i++;
i++;
- num_char_deleted = gui_current_window->input_buffer_pos - i;
- num_char_end = gui_current_window->input_buffer_size -
- gui_current_window->input_buffer_pos;
+ num_char_deleted = gui_current_view->input_buffer_pos - i;
+ num_char_end = gui_current_view->input_buffer_size -
+ gui_current_view->input_buffer_pos;
for (j = 0; j < num_char_end; j++)
- gui_current_window->input_buffer[i + j] =
- gui_current_window->input_buffer[gui_current_window->input_buffer_pos + j];
+ gui_current_view->input_buffer[i + j] =
+ gui_current_view->input_buffer[gui_current_view->input_buffer_pos + j];
- gui_current_window->input_buffer_size -= num_char_deleted;
- gui_current_window->input_buffer[gui_current_window->input_buffer_size] = '\0';
- gui_current_window->input_buffer_pos = i;
- gui_draw_window_input (gui_current_window);
- gui_optimize_input_buffer_size (gui_current_window);
- gui_current_window->completion.position = -1;
+ gui_current_view->input_buffer_size -= num_char_deleted;
+ gui_current_view->input_buffer[gui_current_view->input_buffer_size] = '\0';
+ gui_current_view->input_buffer_pos = i;
+ gui_draw_view_input (gui_current_view);
+ gui_optimize_input_buffer_size (gui_current_view);
+ gui_current_view->completion.position = -1;
}
}
@@ -462,22 +511,22 @@ gui_move_previous_word ()
{
int i;
- if (gui_current_window->input_buffer_pos > 0)
+ if (gui_current_view->input_buffer_pos > 0)
{
- i = gui_current_window->input_buffer_pos - 1;
+ i = gui_current_view->input_buffer_pos - 1;
while ((i >= 0) &&
- (gui_current_window->input_buffer[i] == ' '))
+ (gui_current_view->input_buffer[i] == ' '))
i--;
if (i < 0)
- gui_current_window->input_buffer_pos = 0;
+ gui_current_view->input_buffer_pos = 0;
else
{
while ((i >= 0) &&
- (gui_current_window->input_buffer[i] != ' '))
+ (gui_current_view->input_buffer[i] != ' '))
i--;
- gui_current_window->input_buffer_pos = i + 1;
+ gui_current_view->input_buffer_pos = i + 1;
}
- gui_draw_window_input (gui_current_window);
+ gui_draw_view_input (gui_current_view);
}
}
@@ -490,28 +539,28 @@ gui_move_next_word ()
{
int i;
- if (gui_current_window->input_buffer_pos <
- gui_current_window->input_buffer_size + 1)
+ if (gui_current_view->input_buffer_pos <
+ gui_current_view->input_buffer_size + 1)
{
- i = gui_current_window->input_buffer_pos;
- while ((i <= gui_current_window->input_buffer_size) &&
- (gui_current_window->input_buffer[i] == ' '))
+ i = gui_current_view->input_buffer_pos;
+ while ((i <= gui_current_view->input_buffer_size) &&
+ (gui_current_view->input_buffer[i] == ' '))
i++;
- if (i > gui_current_window->input_buffer_size)
- gui_current_window->input_buffer_pos = i - 1;
+ if (i > gui_current_view->input_buffer_size)
+ gui_current_view->input_buffer_pos = i - 1;
else
{
- while ((i <= gui_current_window->input_buffer_size) &&
- (gui_current_window->input_buffer[i] != ' '))
+ while ((i <= gui_current_view->input_buffer_size) &&
+ (gui_current_view->input_buffer[i] != ' '))
i++;
- if (i > gui_current_window->input_buffer_size)
- gui_current_window->input_buffer_pos =
- gui_current_window->input_buffer_size;
+ if (i > gui_current_view->input_buffer_size)
+ gui_current_view->input_buffer_pos =
+ gui_current_view->input_buffer_size;
else
- gui_current_window->input_buffer_pos = i;
+ gui_current_view->input_buffer_pos = i;
}
- gui_draw_window_input (gui_current_window);
+ gui_draw_view_input (gui_current_view);
}
}
@@ -527,17 +576,17 @@ gui_buffer_insert_string (char *string, int pos)
length = strlen (string);
/* increase buffer size */
- gui_current_window->input_buffer_size += length;
- gui_optimize_input_buffer_size (gui_current_window);
- gui_current_window->input_buffer[gui_current_window->input_buffer_size] = '\0';
+ gui_current_view->input_buffer_size += length;
+ gui_optimize_input_buffer_size (gui_current_view);
+ gui_current_view->input_buffer[gui_current_view->input_buffer_size] = '\0';
/* move end of string to the right */
start = pos + length;
- end = gui_current_window->input_buffer_size - 1;
+ end = gui_current_view->input_buffer_size - 1;
for (i = end; i >= start; i--)
- gui_current_window->input_buffer[i] =
- gui_current_window->input_buffer[i - length];
+ gui_current_view->input_buffer[i] =
+ gui_current_view->input_buffer[i - length];
/* insert new string */
- strncpy (gui_current_window->input_buffer + pos, string, length);
+ strncpy (gui_current_view->input_buffer + pos, string, length);
}
diff --git a/src/gui/gui.h b/src/gui/gui.h
index 478b0f989..df14e3af5 100644
--- a/src/gui/gui.h
+++ b/src/gui/gui.h
@@ -59,23 +59,23 @@
#define COLOR_WIN_NICK_LAST 38
#define COLOR_WIN_NICK_NUMBER (COLOR_WIN_NICK_LAST - COLOR_WIN_NICK_FIRST + 1)
-#define SERVER(window) ((t_irc_server *)(window->server))
-#define CHANNEL(window) ((t_irc_channel *)(window->channel))
+#define SERVER(view) ((t_irc_server *)(view->server))
+#define CHANNEL(view) ((t_irc_channel *)(view->channel))
-#define WIN_IS_SERVER(window) (SERVER(window) && !CHANNEL(window))
-#define WIN_IS_CHANNEL(window) (CHANNEL(window) && (CHANNEL(window)->type == CHAT_CHANNEL))
-#define WIN_IS_PRIVATE(window) (CHANNEL(window) && (CHANNEL(window)->type == CHAT_PRIVATE))
+#define VIEW_IS_SERVER(view) (SERVER(view) && !CHANNEL(view))
+#define VIEW_IS_CHANNEL(view) (CHANNEL(view) && (CHANNEL(view)->type == CHAT_CHANNEL))
+#define VIEW_IS_PRIVATE(view) (CHANNEL(view) && (CHANNEL(view)->type == CHAT_PRIVATE))
#define MSG_TYPE_TIME 0
#define MSG_TYPE_NICK 1
#define MSG_TYPE_INFO 2
#define MSG_TYPE_MSG 3
-#define gui_printf_color(window, color, fmt, argz...) \
- gui_printf_color_type(window, MSG_TYPE_INFO, color, fmt, ##argz)
+#define gui_printf_color(view, color, fmt, argz...) \
+ gui_printf_color_type(view, MSG_TYPE_INFO, color, fmt, ##argz)
-#define gui_printf(window, fmt, argz...) \
- gui_printf_color_type(window, MSG_TYPE_INFO, -1, fmt, ##argz)
+#define gui_printf(view, fmt, argz...) \
+ gui_printf_color_type(view, MSG_TYPE_INFO, -1, fmt, ##argz)
typedef struct t_gui_message t_gui_message;
@@ -125,12 +125,6 @@ typedef struct t_gui_window t_gui_window;
struct t_gui_window
{
- int is_displayed; /* = 1 if window is displayed */
-
- /* server/channel */
- void *server; /* window's server */
- void *channel; /* window's channel */
-
/* global position & size */
int win_x, win_y; /* position of window */
int win_width, win_height; /* window geometry */
@@ -149,7 +143,7 @@ struct t_gui_window
/* windows for Curses GUI */
void *win_title; /* title window */
- void *win_chat; /* chat window (exemple: channel) */
+ void *win_chat; /* chat window (example: channel) */
void *win_nick; /* nick window */
void *win_status; /* status window */
void *win_infobar; /* info bar window */
@@ -165,6 +159,22 @@ struct t_gui_window
/* windows for Qt GUI */
/* TODO: declare Qt window */
+ t_gui_window *prev_window; /* link to previous window */
+ t_gui_window *next_window; /* link to next window */
+};
+
+typedef struct t_gui_view t_gui_view;
+
+struct t_gui_view
+{
+ int is_displayed; /* = 1 if view is displayed */
+
+ /* server/channel */
+ void *server; /* view's server */
+ void *channel; /* view's channel */
+
+ t_gui_window *window; /* Curses or Gtk window */
+
/* chat content (lines, line is composed by many messages) */
t_gui_line *lines; /* lines of chat window */
t_gui_line *last_line; /* last line of chat window */
@@ -191,29 +201,31 @@ struct t_gui_window
int num_history; /* number of commands in history */
/* link to next window */
- t_gui_window *prev_window; /* link to previous window */
- t_gui_window *next_window; /* link to next window */
+ t_gui_view *prev_view; /* link to previous view */
+ t_gui_view *next_view; /* link to next view */
};
/* variables */
extern int gui_ready;
extern t_gui_window *gui_windows;
-extern t_gui_window *last_gui_window;
-extern t_gui_window *gui_current_window;
+extern t_gui_view *gui_views;
+extern t_gui_view *last_gui_view;
+extern t_gui_view *gui_current_view;
extern t_gui_infobar *gui_infobar;
/* prototypes */
/* GUI independent functions */
-extern t_gui_window *gui_window_new (/*@null@*/ void *, /*@null@*/ void *, int /*int, int, int, int*/); /* TODO: add coordinates and size */
-extern void gui_window_clear (t_gui_window *);
-extern void gui_window_clear_all ();
+extern t_gui_window *gui_window_new (int, int, int, int);
+extern t_gui_view *gui_view_new (t_gui_window *, void *, void *, int);
+extern void gui_view_clear (t_gui_view *);
+extern void gui_view_clear_all ();
extern void gui_infobar_printf (int, int, char *, ...);
extern void gui_infobar_remove ();
-extern t_gui_line *gui_new_line (t_gui_window *);
-extern t_gui_message *gui_new_message (t_gui_window *);
-extern void gui_optimize_input_buffer_size (t_gui_window *);
+extern t_gui_line *gui_new_line (t_gui_view *);
+extern t_gui_message *gui_new_message (t_gui_view *);
+extern void gui_optimize_input_buffer_size (t_gui_view *);
extern void gui_delete_previous_word ();
extern void gui_move_previous_word ();
extern void gui_move_next_word ();
@@ -222,34 +234,34 @@ extern void gui_buffer_insert_string (char *, int);
extern int gui_assign_color (int *, char *);
extern int gui_get_color_by_name (char *);
extern char *gui_get_color_by_value (int);
-extern int gui_window_has_nicklist (t_gui_window *);
-extern void gui_calculate_pos_size (t_gui_window *);
-extern void gui_draw_window_title (t_gui_window *);
-extern void gui_redraw_window_title (t_gui_window *);
-extern void gui_draw_window_chat (t_gui_window *);
-extern void gui_redraw_window_chat (t_gui_window *);
-extern void gui_draw_window_nick (t_gui_window *);
-extern void gui_redraw_window_nick (t_gui_window *);
-extern void gui_draw_window_status (t_gui_window *);
-extern void gui_redraw_window_status (t_gui_window *);
-extern void gui_draw_window_infobar (t_gui_window *);
-extern void gui_redraw_window_infobar (t_gui_window *);
-extern void gui_draw_window_input (t_gui_window *);
-extern void gui_redraw_window_input (t_gui_window *);
-extern void gui_redraw_window (t_gui_window *);
-extern void gui_switch_to_window (t_gui_window *);
-extern void gui_switch_to_previous_window ();
-extern void gui_switch_to_next_window ();
+extern int gui_view_has_nicklist (t_gui_view *);
+extern void gui_calculate_pos_size (t_gui_view *);
+extern void gui_draw_view_title (t_gui_view *);
+extern void gui_redraw_view_title (t_gui_view *);
+extern void gui_draw_view_chat (t_gui_view *);
+extern void gui_redraw_view_chat (t_gui_view *);
+extern void gui_draw_view_nick (t_gui_view *);
+extern void gui_redraw_view_nick (t_gui_view *);
+extern void gui_draw_view_status (t_gui_view *);
+extern void gui_redraw_view_status (t_gui_view *);
+extern void gui_draw_view_infobar (t_gui_view *);
+extern void gui_redraw_view_infobar (t_gui_view *);
+extern void gui_draw_view_input (t_gui_view *);
+extern void gui_redraw_view_input (t_gui_view *);
+extern void gui_redraw_view (t_gui_view *);
+extern void gui_switch_to_view (t_gui_view *);
+extern void gui_switch_to_previous_view ();
+extern void gui_switch_to_next_view ();
extern void gui_move_page_up ();
extern void gui_move_page_down ();
-extern void gui_window_init_subwindows (t_gui_window *);
+extern void gui_view_init_subviews (t_gui_view *);
extern void gui_pre_init (int *, char **[]);
extern void gui_init_colors ();
extern void gui_set_window_title ();
extern void gui_init ();
-extern void gui_window_free (t_gui_window *);
+extern void gui_view_free (t_gui_view *);
extern void gui_end ();
-extern void gui_printf_color_type (/*@null@*/ t_gui_window *, int, int, char *, ...);
+extern void gui_printf_color_type (/*@null@*/ t_gui_view *, int, int, char *, ...);
extern void gui_main_loop ();
#endif /* gui.h */