summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/curses/gui-curses-chat.c4
-rw-r--r--src/gui/curses/gui-curses-input.c30
-rw-r--r--src/gui/curses/gui-curses-keyboard.c15
-rw-r--r--src/gui/curses/gui-curses-main.c6
-rw-r--r--src/gui/curses/gui-curses-nicklist.c4
-rw-r--r--src/gui/curses/gui-curses-panel.c23
-rw-r--r--src/gui/curses/gui-curses-status.c4
-rw-r--r--src/gui/curses/gui-curses-window.c241
-rw-r--r--src/gui/curses/gui-curses.h5
-rw-r--r--src/gui/gtk/gui-gtk-nicklist.c3
-rw-r--r--src/gui/gtk/gui-gtk-window.c16
-rw-r--r--src/gui/gui-action.c2
-rw-r--r--src/gui/gui-panel.c65
-rw-r--r--src/gui/gui-panel.h11
-rw-r--r--src/gui/gui-window.c20
-rw-r--r--src/gui/gui-window.h29
-rw-r--r--src/gui/gui.h4
17 files changed, 330 insertions, 152 deletions
diff --git a/src/gui/curses/gui-curses-chat.c b/src/gui/curses/gui-curses-chat.c
index ce99f71d9..c0e1c1d49 100644
--- a/src/gui/curses/gui-curses-chat.c
+++ b/src/gui/curses/gui-curses-chat.c
@@ -174,13 +174,13 @@ gui_chat_draw_title (t_gui_buffer *buffer, int erase)
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
- if (ptr_win->buffer == buffer)
+ if ((ptr_win->buffer == buffer) && (buffer->num_displayed > 0))
{
if (erase)
gui_window_curses_clear (GUI_CURSES(ptr_win)->win_title, COLOR_WIN_TITLE);
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_title, COLOR_WIN_TITLE);
- snprintf (format, 32, "%%-%ds", ptr_win->win_width);
+ snprintf (format, 32, "%%-%ds", ptr_win->win_title_width);
if (CHANNEL(buffer))
{
if (CHANNEL(buffer)->topic)
diff --git a/src/gui/curses/gui-curses-input.c b/src/gui/curses/gui-curses-input.c
index 54aaa4c2b..a3408d7ad 100644
--- a/src/gui/curses/gui-curses-input.c
+++ b/src/gui/curses/gui-curses-input.c
@@ -349,7 +349,7 @@ gui_input_draw (t_gui_buffer *buffer, int erase)
prompt_length = gui_input_get_prompt_length (ptr_win, ptr_nickname);
- if (ptr_win->win_width - prompt_length < 3)
+ if (ptr_win->win_input_width - prompt_length < 3)
{
prompt_length = 0;
display_prompt = 0;
@@ -358,9 +358,9 @@ gui_input_draw (t_gui_buffer *buffer, int erase)
display_prompt = 1;
if (buffer->input_buffer_pos - buffer->input_buffer_1st_display + 1 >
- ptr_win->win_width - prompt_length)
+ ptr_win->win_input_width - prompt_length)
buffer->input_buffer_1st_display = buffer->input_buffer_pos -
- (ptr_win->win_width - prompt_length) + 1;
+ (ptr_win->win_input_width - prompt_length) + 1;
else
{
if (buffer->input_buffer_pos < buffer->input_buffer_1st_display)
@@ -370,11 +370,11 @@ gui_input_draw (t_gui_buffer *buffer, int erase)
if ((buffer->input_buffer_1st_display > 0) &&
(buffer->input_buffer_pos -
buffer->input_buffer_1st_display + 1)
- < ptr_win->win_width - prompt_length)
+ < ptr_win->win_input_width - prompt_length)
{
buffer->input_buffer_1st_display =
buffer->input_buffer_pos -
- (ptr_win->win_width - prompt_length) + 1;
+ (ptr_win->win_input_width - prompt_length) + 1;
if (buffer->input_buffer_1st_display < 0)
buffer->input_buffer_1st_display = 0;
}
@@ -384,18 +384,18 @@ gui_input_draw (t_gui_buffer *buffer, int erase)
gui_input_draw_prompt (ptr_win, ptr_nickname);
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_input, COLOR_WIN_INPUT);
- snprintf (format, 32, "%%-%ds", ptr_win->win_width - prompt_length);
+ snprintf (format, 32, "%%-%ds", ptr_win->win_input_width - prompt_length);
offset_cursor = 0;
if (ptr_win == gui_current_window)
offset_cursor = gui_input_draw_text (ptr_win,
- ptr_win->win_width - prompt_length);
+ ptr_win->win_input_width - prompt_length);
else
wprintw (GUI_CURSES(ptr_win)->win_input, format, "");
wclrtoeol (GUI_CURSES(ptr_win)->win_input);
- ptr_win->win_input_x = prompt_length + offset_cursor;
+ ptr_win->win_input_cursor_x = prompt_length + offset_cursor;
if (ptr_win == gui_current_window)
- move (ptr_win->win_y + ptr_win->win_height - 1,
- ptr_win->win_x + ptr_win->win_input_x);
+ move (ptr_win->win_input_y,
+ ptr_win->win_input_x + ptr_win->win_input_cursor_x);
}
break;
case BUFFER_TYPE_DCC:
@@ -424,18 +424,16 @@ gui_input_draw (t_gui_buffer *buffer, int erase)
wprintw (GUI_CURSES(ptr_win)->win_input, _(" [P] Purge old DCC"));
wprintw (GUI_CURSES(ptr_win)->win_input, _(" [Q] Close DCC view"));
wclrtoeol (GUI_CURSES(ptr_win)->win_input);
- ptr_win->win_input_x = 0;
+ ptr_win->win_input_cursor_x = 0;
if (ptr_win == gui_current_window)
- move (ptr_win->win_y + ptr_win->win_height - 1,
- ptr_win->win_x);
+ move (ptr_win->win_input_y, ptr_win->win_input_x);
break;
case BUFFER_TYPE_RAW_DATA:
mvwprintw (GUI_CURSES(ptr_win)->win_input, 0, 0, _(" [Q] Close raw data view"));
wclrtoeol (GUI_CURSES(ptr_win)->win_input);
- ptr_win->win_input_x = 0;
+ ptr_win->win_input_cursor_x = 0;
if (ptr_win == gui_current_window)
- move (ptr_win->win_y + ptr_win->win_height - 1,
- ptr_win->win_x);
+ move (ptr_win->win_input_y, ptr_win->win_input_x);
break;
}
doupdate ();
diff --git a/src/gui/curses/gui-curses-keyboard.c b/src/gui/curses/gui-curses-keyboard.c
index fcf134c80..db9f563bd 100644
--- a/src/gui/curses/gui-curses-keyboard.c
+++ b/src/gui/curses/gui-curses-keyboard.c
@@ -143,9 +143,12 @@ gui_keyboard_default_bindings ()
void
gui_keyboard_grab_end ()
{
- char *expanded_key, *expanded_key2;
- int length;
+ char *expanded_key;
char *buffer_before_key;
+#ifdef PLUGINS
+ char *expanded_key2;
+ int length;
+#endif
/* get expanded name (for example: ^U => ctrl-u) */
expanded_key = gui_keyboard_get_expanded_name (gui_key_buffer);
@@ -193,8 +196,11 @@ void
gui_keyboard_read ()
{
int key, i, insert_ok;
- char key_str[32], key_str2[33];
+ char key_str[32];
char *buffer_before_key;
+#ifdef PLUGINS
+ char key_str2[33];
+#endif
i = 0;
/* do not loop too much here (for example when big paste was made),
@@ -215,10 +221,7 @@ gui_keyboard_read ()
}
if (key == KEY_RESIZE)
- {
- gui_window_refresh_screen ();
continue;
- }
gui_last_activity_time = time (NULL);
diff --git a/src/gui/curses/gui-curses-main.c b/src/gui/curses/gui-curses-main.c
index 6ce58d631..2c863fe54 100644
--- a/src/gui/curses/gui-curses-main.c
+++ b/src/gui/curses/gui-curses-main.c
@@ -73,7 +73,7 @@ gui_main_loop ()
{
/* refresh needed ? */
if (gui_refresh_screen_needed)
- gui_window_refresh_screen ();
+ gui_window_refresh_screen (0);
new_time = time (NULL);
local_time = localtime (&new_time);
@@ -112,7 +112,7 @@ gui_main_loop ()
{
gui_infobar_draw_time (gui_current_window->buffer);
wmove (GUI_CURSES(gui_current_window)->win_input,
- 0, gui_current_window->win_input_x);
+ 0, gui_current_window->win_input_cursor_x);
wrefresh (GUI_CURSES(gui_current_window)->win_input);
}
@@ -291,7 +291,7 @@ gui_main_init ()
gui_infobar = NULL;
- gui_ok = ((COLS > 5) && (LINES > 5));
+ gui_ok = ((COLS > WINDOW_MIN_WIDTH) && (LINES > WINDOW_MIN_HEIGHT));
refresh ();
diff --git a/src/gui/curses/gui-curses-nicklist.c b/src/gui/curses/gui-curses-nicklist.c
index 4bfa95de0..5aa5a8b6d 100644
--- a/src/gui/curses/gui-curses-nicklist.c
+++ b/src/gui/curses/gui-curses-nicklist.c
@@ -36,7 +36,7 @@
*/
void
-gui_nicklist_draw (t_gui_buffer *buffer, int erase)
+gui_nicklist_draw (t_gui_buffer *buffer, int erase, int calculate_size)
{
t_gui_window *ptr_win;
int i, j, x, y, x2, column, max_length, nicks_displayed;
@@ -52,7 +52,7 @@ gui_nicklist_draw (t_gui_buffer *buffer, int erase)
{
max_length = nick_get_max_length (CHANNEL(buffer));
- if (gui_window_calculate_pos_size (ptr_win, 0))
+ if (calculate_size && (gui_window_calculate_pos_size (ptr_win, 0)))
{
delwin (GUI_CURSES(ptr_win)->win_chat);
delwin (GUI_CURSES(ptr_win)->win_nick);
diff --git a/src/gui/curses/gui-curses-panel.c b/src/gui/curses/gui-curses-panel.c
index 9e5f6b7f4..8dbb5f85e 100644
--- a/src/gui/curses/gui-curses-panel.c
+++ b/src/gui/curses/gui-curses-panel.c
@@ -33,11 +33,13 @@
/*
- * gui_panel_get_size: get total panel size for a position
+ * gui_panel_windows_get_size: get total panel size (window panels) for a position
+ * panel is optional, if not NULL, size is computed
+ * from panel 1 to panel # - 1
*/
int
-gui_panel_get_size (t_gui_window *window, int position)
+gui_panel_window_get_size (t_gui_panel *panel, t_gui_window *window, int position)
{
t_gui_panel_window *ptr_panel_win;
int total_size;
@@ -46,6 +48,10 @@ gui_panel_get_size (t_gui_window *window, int position)
for (ptr_panel_win = GUI_CURSES(window)->panel_windows; ptr_panel_win;
ptr_panel_win = ptr_panel_win->next_panel_window)
{
+ /* stop before panel */
+ if ((panel) && (ptr_panel_win->panel == panel))
+ return total_size;
+
if (ptr_panel_win->panel->position == position)
{
switch (position)
@@ -76,6 +82,7 @@ gui_panel_window_new (t_gui_panel *panel, t_gui_window *window)
{
t_gui_panel_window *new_panel_win;
int x1, y1, x2, y2;
+ int add_top, add_bottom, add_left, add_right;
if (window)
{
@@ -83,6 +90,10 @@ gui_panel_window_new (t_gui_panel *panel, t_gui_window *window)
y1 = window->win_y + 1;
x2 = x1 + window->win_width - 1;
y2 = y1 + window->win_height - 1 - 4;
+ add_left = gui_panel_window_get_size (panel, window, GUI_PANEL_LEFT);
+ add_right = gui_panel_window_get_size (panel, window, GUI_PANEL_RIGHT);
+ add_top = gui_panel_window_get_size (panel, window, GUI_PANEL_TOP);
+ add_bottom = gui_panel_window_get_size (panel, window, GUI_PANEL_BOTTOM);
}
else
{
@@ -90,6 +101,10 @@ gui_panel_window_new (t_gui_panel *panel, t_gui_window *window)
y1 = 0;
x2 = gui_window_get_width () - 1;
y2 = gui_window_get_height () - 1;
+ add_left = gui_panel_global_get_size (panel, GUI_PANEL_LEFT);
+ add_right = gui_panel_global_get_size (panel, GUI_PANEL_RIGHT);
+ add_top = gui_panel_global_get_size (panel, GUI_PANEL_TOP);
+ add_bottom = gui_panel_global_get_size (panel, GUI_PANEL_BOTTOM);
}
if ((new_panel_win = (t_gui_panel_window *) malloc (sizeof (t_gui_panel_window))))
@@ -109,8 +124,8 @@ gui_panel_window_new (t_gui_panel *panel, t_gui_window *window)
switch (panel->position)
{
case GUI_PANEL_TOP:
- new_panel_win->x = x1;
- new_panel_win->y = y1;
+ new_panel_win->x = x1 + add_left;
+ new_panel_win->y = y1 + add_top;
new_panel_win->width = x2 - x1 + 1;
new_panel_win->height = panel->size;
break;
diff --git a/src/gui/curses/gui-curses-status.c b/src/gui/curses/gui-curses-status.c
index a8cd59a4d..3d7317c9a 100644
--- a/src/gui/curses/gui-curses-status.c
+++ b/src/gui/curses/gui-curses-status.c
@@ -361,10 +361,10 @@ gui_status_draw (t_gui_buffer *buffer, int erase)
if (BUFFER_HAS_NICKLIST(ptr_win->buffer))
{
snprintf (str_nicks, sizeof (str_nicks) - 1, "%d", CHANNEL(ptr_win->buffer)->nicks_count);
- x = ptr_win->win_width - strlen (str_nicks) - 4;
+ x = ptr_win->win_status_width - strlen (str_nicks) - 4;
}
else
- x = ptr_win->win_width - 2;
+ x = ptr_win->win_status_width - 2;
more = strdup (_("-MORE-"));
x -= strlen (more) - 1;
if (x < 0)
diff --git a/src/gui/curses/gui-curses-window.c b/src/gui/curses/gui-curses-window.c
index f450a65c0..3ee03a2f5 100644
--- a/src/gui/curses/gui-curses-window.c
+++ b/src/gui/curses/gui-curses-window.c
@@ -175,10 +175,10 @@ gui_window_calculate_pos_size (t_gui_window *window, int force_calculate)
if (!gui_ok)
return 0;
- add_left = gui_panel_get_size (window, GUI_PANEL_LEFT);
- add_right = gui_panel_get_size (window, GUI_PANEL_RIGHT);
- add_top = gui_panel_get_size (window, GUI_PANEL_TOP);
- add_bottom = gui_panel_get_size (window, GUI_PANEL_BOTTOM);
+ add_left = gui_panel_window_get_size (NULL, window, GUI_PANEL_LEFT);
+ add_right = gui_panel_window_get_size (NULL, window, GUI_PANEL_RIGHT);
+ add_top = gui_panel_window_get_size (NULL, window, GUI_PANEL_TOP);
+ add_bottom = gui_panel_window_get_size (NULL, window, GUI_PANEL_BOTTOM);
/* init chat & nicklist settings */
if (cfg_look_nicklist && BUFFER_IS_CHANNEL(window->buffer))
@@ -203,16 +203,17 @@ gui_window_calculate_pos_size (t_gui_window *window, int force_calculate)
{
nick_count (CHANNEL(window->buffer), &num_nicks, &num_op,
&num_halfop, &num_voice, &num_normal);
- if (((max_length + 2) * num_nicks) % window->win_width == 0)
- lines = ((max_length + 2) * num_nicks) / window->win_width;
+ if (((max_length + 2) * num_nicks) % (window->win_width - add_left - add_right) == 0)
+ lines = ((max_length + 2) * num_nicks) / (window->win_width - add_left - add_right);
else
- lines = (((max_length + 2) * num_nicks) / window->win_width) + 1;
+ lines = (((max_length + 2) * num_nicks) / (window->win_width - add_left - add_right)) + 1;
if ((cfg_look_nicklist_max_size > 0) && (lines > cfg_look_nicklist_max_size))
lines = cfg_look_nicklist_max_size;
if ((cfg_look_nicklist_min_size > 0) && (lines < cfg_look_nicklist_min_size))
lines = cfg_look_nicklist_min_size;
max_height = (cfg_look_infobar) ?
- window->win_height - 3 - 4 : window->win_height - 2 - 4;
+ window->win_height - add_top - add_bottom - 3 - 4 :
+ window->win_height - add_top - add_bottom - 2 - 4;
if (lines > max_height)
lines = max_height;
if (!force_calculate && (window->win_nick_height == lines + 1))
@@ -223,95 +224,132 @@ gui_window_calculate_pos_size (t_gui_window *window, int force_calculate)
{
case CFG_LOOK_NICKLIST_LEFT:
window->win_chat_x = window->win_x + add_left + max_length + 2;
- window->win_chat_y = window->win_y + 1;
- window->win_chat_width = window->win_width - add_left - max_length - 2;
- window->win_nick_x = window->win_x + 0;
- window->win_nick_y = window->win_y + 1;
+ window->win_chat_y = window->win_y + add_top + 1;
+ window->win_chat_width = window->win_width - add_left - add_right - max_length - 2;
+ window->win_nick_x = window->win_x + add_left + 0;
+ window->win_nick_y = window->win_y + add_top + 1;
window->win_nick_width = max_length + 2;
if (cfg_look_infobar)
{
- window->win_chat_height = window->win_height - 4;
- window->win_nick_height = window->win_height - 4;
+ window->win_chat_height = window->win_height - add_top - add_bottom - 4;
+ window->win_nick_height = window->win_height - add_top - add_bottom - 4;
}
else
{
- window->win_chat_height = window->win_height - 3;
- window->win_nick_height = window->win_height - 3;
+ window->win_chat_height = window->win_height - add_top - add_bottom - 3;
+ window->win_nick_height = window->win_height - add_top - add_bottom - 3;
}
window->win_nick_num_max = window->win_nick_height;
break;
case CFG_LOOK_NICKLIST_RIGHT:
window->win_chat_x = window->win_x + add_left;
- window->win_chat_y = window->win_y + 1;
- window->win_chat_width = window->win_width - add_left - max_length - 2;
- window->win_nick_x = window->win_x + window->win_width - max_length - 2;
- window->win_nick_y = window->win_y + 1;
+ window->win_chat_y = window->win_y + add_top + 1;
+ window->win_chat_width = window->win_width - add_left - add_right - max_length - 2;
+ window->win_nick_x = window->win_x + window->win_width - add_right - max_length - 2;
+ window->win_nick_y = window->win_y + add_top + 1;
window->win_nick_width = max_length + 2;
if (cfg_look_infobar)
{
- window->win_chat_height = window->win_height - 4;
- window->win_nick_height = window->win_height - 4;
+ window->win_chat_height = window->win_height - add_top - add_bottom - 4;
+ window->win_nick_height = window->win_height - add_top - add_bottom - 4;
}
else
{
- window->win_chat_height = window->win_height - 3;
- window->win_nick_height = window->win_height - 3;
+ window->win_chat_height = window->win_height - add_top - add_bottom - 3;
+ window->win_nick_height = window->win_height - add_top - add_bottom - 3;
}
window->win_nick_num_max = window->win_nick_height;
break;
case CFG_LOOK_NICKLIST_TOP:
window->win_chat_x = window->win_x + add_left;
- window->win_chat_y = window->win_y + 1 + (lines + 1);
- window->win_chat_width = window->win_width - add_left;
+ window->win_chat_y = window->win_y + add_top + 1 + (lines + 1);
+ window->win_chat_width = window->win_width - add_left - add_right;
if (cfg_look_infobar)
- window->win_chat_height = window->win_height - 3 - (lines + 1) - 1;
+ window->win_chat_height = window->win_height - add_top - add_bottom - 3 - (lines + 1) - 1;
else
- window->win_chat_height = window->win_height - 3 - (lines + 1);
- window->win_nick_x = window->win_x;
- window->win_nick_y = window->win_y + 1;
- window->win_nick_width = window->win_width;
+ window->win_chat_height = window->win_height - add_top - add_bottom - 3 - (lines + 1);
+ window->win_nick_x = window->win_x + add_left;
+ window->win_nick_y = window->win_y + add_top + 1;
+ window->win_nick_width = window->win_width - add_left - add_right;
window->win_nick_height = lines + 1;
window->win_nick_num_max = lines * (window->win_nick_width / (max_length + 2));
break;
case CFG_LOOK_NICKLIST_BOTTOM:
window->win_chat_x = window->win_x + add_left;
- window->win_chat_y = window->win_y + 1;
- window->win_chat_width = window->win_width - add_left;
+ window->win_chat_y = window->win_y + add_top + 1;
+ window->win_chat_width = window->win_width - add_left - add_right;
if (cfg_look_infobar)
- window->win_chat_height = window->win_height - 3 - (lines + 1) - 1;
+ window->win_chat_height = window->win_height - add_top - add_bottom - 3 - (lines + 1) - 1;
else
- window->win_chat_height = window->win_height - 3 - (lines + 1);
- window->win_nick_x = window->win_x;
+ window->win_chat_height = window->win_height - add_top - add_bottom - 3 - (lines + 1);
+ window->win_nick_x = window->win_x + add_left;
if (cfg_look_infobar)
- window->win_nick_y = window->win_y + window->win_height - 2 - (lines + 1) - 1;
+ window->win_nick_y = window->win_y + window->win_height - add_bottom - 2 - (lines + 1) - 1;
else
- window->win_nick_y = window->win_y + window->win_height - 2 - (lines + 1);
- window->win_nick_width = window->win_width;
+ window->win_nick_y = window->win_y + window->win_height - add_bottom - 2 - (lines + 1);
+ window->win_nick_width = window->win_width - add_left - add_right;
window->win_nick_height = lines + 1;
window->win_nick_num_max = lines * (window->win_nick_width / (max_length + 2));
break;
}
- window->win_chat_cursor_x = window->win_x;
- window->win_chat_cursor_y = window->win_y;
+ window->win_chat_cursor_x = window->win_x + add_left;
+ window->win_chat_cursor_y = window->win_y + add_top;
}
else
{
window->win_chat_x = window->win_x + add_left;
- window->win_chat_y = window->win_y + 1;
- window->win_chat_width = window->win_width - add_left;
+ window->win_chat_y = window->win_y + add_top + 1;
+ window->win_chat_width = window->win_width - add_left - add_right;
if (cfg_look_infobar)
- window->win_chat_height = window->win_height - 4;
+ window->win_chat_height = window->win_height - add_top - add_bottom - 4;
else
- window->win_chat_height = window->win_height - 3;
+ window->win_chat_height = window->win_height - add_top - add_bottom - 3;
window->win_chat_cursor_x = window->win_x + add_left;
- window->win_chat_cursor_y = window->win_y;
+ window->win_chat_cursor_y = window->win_y + add_top;
window->win_nick_x = -1;
window->win_nick_y = -1;
window->win_nick_width = -1;
window->win_nick_height = -1;
window->win_nick_num_max = -1;
}
+
+ /* title window */
+ window->win_title_x = window->win_x;
+ window->win_title_y = window->win_y;
+ window->win_title_width = window->win_width;
+ window->win_title_height = 1;
+
+ /* status window */
+ window->win_status_x = window->win_x;
+ if (cfg_look_infobar)
+ window->win_status_y = window->win_y + window->win_height - 3;
+ else
+ window->win_status_y = window->win_y + window->win_height - 2;
+ window->win_status_width = window->win_width;
+ window->win_status_height = 1;
+
+ /* infobar window */
+ if (cfg_look_infobar)
+ {
+ window->win_infobar_x = window->win_x;
+ window->win_infobar_y = window->win_y + window->win_height - 2;
+ window->win_infobar_width = window->win_width;
+ window->win_infobar_height = 1;
+ }
+ else
+ {
+ window->win_infobar_x = -1;
+ window->win_infobar_y = -1;
+ window->win_infobar_width = -1;
+ window->win_infobar_height = -1;
+ }
+
+ /* input window */
+ window->win_input_x = window->win_x;
+ window->win_input_y = window->win_y + window->win_height - 1;
+ window->win_input_width = window->win_width;
+ window->win_input_height = 1;
return 1;
}
@@ -358,7 +396,7 @@ gui_window_redraw_buffer (t_gui_buffer *buffer)
gui_chat_draw_title (buffer, 1);
gui_chat_draw (buffer, 1);
if (GUI_CURSES(ptr_win)->win_nick)
- gui_nicklist_draw (buffer, 1);
+ gui_nicklist_draw (buffer, 1, 0);
gui_status_draw (buffer, 1);
if (cfg_look_infobar)
gui_infobar_draw (buffer, 1);
@@ -377,7 +415,7 @@ gui_window_switch_to_buffer (t_gui_window *window, t_gui_buffer *buffer)
{
if (!gui_ok)
return;
-
+
if (window->buffer->num_displayed > 0)
window->buffer->num_displayed--;
@@ -390,20 +428,21 @@ gui_window_switch_to_buffer (t_gui_window *window, t_gui_buffer *buffer)
window->buffer = buffer;
window->win_nick_start = 0;
+
gui_window_calculate_pos_size (window, 1);
/* destroy Curses windows */
gui_window_objects_free (window, 0);
/* create Curses windows */
- GUI_CURSES(window)->win_title = newwin (1,
- window->win_width,
- window->win_y,
- window->win_x);
- GUI_CURSES(window)->win_input = newwin (1,
- window->win_width,
- window->win_y + window->win_height - 1,
- window->win_x);
+ GUI_CURSES(window)->win_title = newwin (window->win_title_height,
+ window->win_title_width,
+ window->win_title_y,
+ window->win_title_x);
+ GUI_CURSES(window)->win_input = newwin (window->win_input_height,
+ window->win_input_width,
+ window->win_input_y,
+ window->win_input_x);
if (BUFFER_IS_CHANNEL(buffer))
{
if (GUI_CURSES(window)->win_chat)
@@ -432,22 +471,19 @@ gui_window_switch_to_buffer (t_gui_window *window, t_gui_buffer *buffer)
/* create status/infobar windows */
if (cfg_look_infobar)
- {
- GUI_CURSES(window)->win_infobar = newwin (1, window->win_width,
- window->win_y + window->win_height - 2,
- window->win_x);
- GUI_CURSES(window)->win_status = newwin (1, window->win_width,
- window->win_y + window->win_height - 3,
- window->win_x);
- }
- else
- GUI_CURSES(window)->win_status = newwin (1, window->win_width,
- window->win_y + window->win_height - 2,
- window->win_x);
+ GUI_CURSES(window)->win_infobar = newwin (window->win_infobar_height,
+ window->win_infobar_width,
+ window->win_infobar_y,
+ window->win_infobar_x);
+
+ GUI_CURSES(window)->win_status = newwin (window->win_status_height,
+ window->win_status_width,
+ window->win_status_y,
+ window->win_status_x);
window->start_line = NULL;
window->start_line_pos = 0;
-
+
buffer->num_displayed++;
hotlist_remove_buffer (buffer);
@@ -623,7 +659,7 @@ gui_window_nick_beginning (t_gui_window *window)
if (window->win_nick_start > 0)
{
window->win_nick_start = 0;
- gui_nicklist_draw (window->buffer, 1);
+ gui_nicklist_draw (window->buffer, 1, 0);
}
}
}
@@ -652,7 +688,7 @@ gui_window_nick_end (t_gui_window *window)
if (new_start != window->win_nick_start)
{
window->win_nick_start = new_start;
- gui_nicklist_draw (window->buffer, 1);
+ gui_nicklist_draw (window->buffer, 1, 0);
}
}
}
@@ -674,7 +710,7 @@ gui_window_nick_page_up (t_gui_window *window)
window->win_nick_start -= (window->win_nick_num_max - 1);
if (window->win_nick_start <= 1)
window->win_nick_start = 0;
- gui_nicklist_draw (window->buffer, 1);
+ gui_nicklist_draw (window->buffer, 1, 0);
}
}
}
@@ -699,7 +735,7 @@ gui_window_nick_page_down (t_gui_window *window)
window->win_nick_start += (window->win_nick_num_max - 1);
else
window->win_nick_start += (window->win_nick_num_max - 2);
- gui_nicklist_draw (window->buffer, 1);
+ gui_nicklist_draw (window->buffer, 1, 0);
}
}
}
@@ -778,17 +814,19 @@ gui_window_refresh_windows ()
gui_window_get_width (),
gui_window_get_height (), 0) < 0)
gui_window_merge_all (gui_current_window);
-
+
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
gui_window_switch_to_buffer (ptr_win, ptr_win->buffer);
+ }
+
+ for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
+ {
gui_window_redraw_buffer (ptr_win->buffer);
gui_window_draw_separator (ptr_win);
}
gui_current_window = old_current_window;
- gui_window_switch_to_buffer (gui_current_window, gui_current_window->buffer);
- gui_window_redraw_buffer (gui_current_window->buffer);
}
}
@@ -1133,24 +1171,32 @@ gui_window_switch_right (t_gui_window *window)
/*
* gui_window_refresh_screen: called when term size is modified
+ * force == 1 when Ctrl+L is pressed
*/
void
-gui_window_refresh_screen ()
+gui_window_refresh_screen (int force)
{
int new_height, new_width;
-
- endwin ();
- refresh ();
-
- getmaxyx (stdscr, new_height, new_width);
-
- gui_ok = ((new_width > WINDOW_MIN_WIDTH) && (new_height > WINDOW_MIN_HEIGHT));
-
- if (gui_ok)
- gui_window_refresh_windows ();
- gui_refresh_screen_needed = 0;
+ if (force || (gui_refresh_screen_needed == 1))
+ {
+ endwin ();
+ refresh ();
+
+ getmaxyx (stdscr, new_height, new_width);
+
+ gui_ok = ((new_width > WINDOW_MIN_WIDTH) && (new_height > WINDOW_MIN_HEIGHT));
+
+ if (gui_ok)
+ {
+ refresh ();
+ gui_window_refresh_windows ();
+ }
+ }
+
+ if (!force && (gui_refresh_screen_needed > 0))
+ gui_refresh_screen_needed--;
}
/*
@@ -1160,7 +1206,8 @@ gui_window_refresh_screen ()
void
gui_window_refresh_screen_sigwinch ()
{
- gui_refresh_screen_needed = 1;
+ if (gui_refresh_screen_needed < 2)
+ gui_refresh_screen_needed++;
signal (SIGWINCH, gui_window_refresh_screen_sigwinch);
}
@@ -1253,6 +1300,8 @@ gui_window_reset_title ()
void
gui_window_objects_print_log (t_gui_window *window)
{
+ t_gui_panel_window *ptr_panel_win;
+
weechat_log_printf (" win_title . . . . . : 0x%X\n", GUI_CURSES(window)->win_title);
weechat_log_printf (" win_chat. . . . . . : 0x%X\n", GUI_CURSES(window)->win_chat);
weechat_log_printf (" win_nick. . . . . . : 0x%X\n", GUI_CURSES(window)->win_nick);
@@ -1260,4 +1309,18 @@ gui_window_objects_print_log (t_gui_window *window)
weechat_log_printf (" win_infobar . . . . : 0x%X\n", GUI_CURSES(window)->win_infobar);
weechat_log_printf (" win_input . . . . . : 0x%X\n", GUI_CURSES(window)->win_input);
weechat_log_printf (" win_separator . . . : 0x%X\n", GUI_CURSES(window)->win_separator);
+ for (ptr_panel_win = GUI_CURSES(window)->panel_windows;
+ ptr_panel_win; ptr_panel_win = ptr_panel_win->next_panel_window)
+ {
+ weechat_log_printf ("\n");
+ weechat_log_printf (" [window panel (addr:0x%X)]\n", ptr_panel_win);
+ weechat_log_printf (" panel . . . . . . : 0x%X\n", ptr_panel_win->panel);
+ weechat_log_printf (" x . . . . . . . . : %d\n", ptr_panel_win->x);
+ weechat_log_printf (" y . . . . . . . . : %d\n", ptr_panel_win->y);
+ weechat_log_printf (" width . . . . . . : %d\n", ptr_panel_win->width);
+ weechat_log_printf (" height. . . . . . : %d\n", ptr_panel_win->height);
+ weechat_log_printf (" win_panel . . . . : 0x%X\n", ptr_panel_win->win_panel);
+ weechat_log_printf (" win_separator . . : 0x%X\n", ptr_panel_win->win_separator);
+ weechat_log_printf (" next_panel_window : 0x%X\n", ptr_panel_win->next_panel_window);
+ }
}
diff --git a/src/gui/curses/gui-curses.h b/src/gui/curses/gui-curses.h
index 1e7eee7da..804b3bb0f 100644
--- a/src/gui/curses/gui-curses.h
+++ b/src/gui/curses/gui-curses.h
@@ -39,6 +39,9 @@
#define WEECHAT_COLOR_CYAN COLOR_YELLOW
#define WEECHAT_COLOR_WHITE COLOR_WHITE
+#define WINDOW_MIN_WIDTH 10
+#define WINDOW_MIN_HEIGHT 5
+
#define GUI_CURSES(window) ((t_gui_curses_objects *)(window->gui_objects))
typedef struct t_gui_panel_window t_gui_panel_window;
@@ -92,7 +95,7 @@ extern void gui_window_set_title ();
extern void gui_window_reset_title ();
/* panel functions */
-extern int gui_panel_get_size (t_gui_window *, int);
+extern int gui_panel_window_get_size (t_gui_panel *, t_gui_window *, int);
extern void gui_panel_redraw_buffer (t_gui_buffer *);
#endif /* gui-curses.h */
diff --git a/src/gui/gtk/gui-gtk-nicklist.c b/src/gui/gtk/gui-gtk-nicklist.c
index 494ef2b46..7fef1d73c 100644
--- a/src/gui/gtk/gui-gtk-nicklist.c
+++ b/src/gui/gtk/gui-gtk-nicklist.c
@@ -36,7 +36,7 @@
*/
void
-gui_nicklist_draw (t_gui_buffer *buffer, int erase)
+gui_nicklist_draw (t_gui_buffer *buffer, int erase, int calculate_size)
{
/*t_gui_window *ptr_win;
int i, j, x, y, column, max_length, nicks_displayed;
@@ -49,4 +49,5 @@ gui_nicklist_draw (t_gui_buffer *buffer, int erase)
/* TODO: write this function for Gtk */
(void) buffer;
(void) erase;
+ (void) calculate_size;
}
diff --git a/src/gui/gtk/gui-gtk-window.c b/src/gui/gtk/gui-gtk-window.c
index 7107cd660..58b500c89 100644
--- a/src/gui/gtk/gui-gtk-window.c
+++ b/src/gui/gtk/gui-gtk-window.c
@@ -386,7 +386,7 @@ gui_window_nick_beginning (t_gui_window *window)
if (window->win_nick_start > 0)
{
window->win_nick_start = 0;
- gui_nicklist_draw (window->buffer, 1);
+ gui_nicklist_draw (window->buffer, 1, 0);
}
}
}
@@ -415,7 +415,7 @@ gui_window_nick_end (t_gui_window *window)
if (new_start != window->win_nick_start)
{
window->win_nick_start = new_start;
- gui_nicklist_draw (window->buffer, 1);
+ gui_nicklist_draw (window->buffer, 1, 0);
}
}
}
@@ -437,7 +437,7 @@ gui_window_nick_page_up (t_gui_window *window)
window->win_nick_start -= (window->win_nick_height - 1);
if (window->win_nick_start <= 1)
window->win_nick_start = 0;
- gui_nicklist_draw (window->buffer, 1);
+ gui_nicklist_draw (window->buffer, 1, 0);
}
}
}
@@ -462,7 +462,7 @@ gui_window_nick_page_down (t_gui_window *window)
window->win_nick_start += (window->win_nick_height - 1);
else
window->win_nick_start += (window->win_nick_height - 2);
- gui_nicklist_draw (window->buffer, 1);
+ gui_nicklist_draw (window->buffer, 1, 0);
}
}
}
@@ -485,8 +485,6 @@ gui_window_auto_resize (t_gui_window_tree *tree,
{
if (tree->window)
{
- if ((width < WINDOW_MIN_WIDTH) || (height < WINDOW_MIN_HEIGHT))
- return -1;
if (!simulate)
{
tree->window->win_x = x;
@@ -555,8 +553,7 @@ gui_window_split_horiz (t_gui_window *window, int pourcentage)
height1 = (window->win_height * pourcentage) / 100;
height2 = window->win_height - height1;
- if ((height1 >= WINDOW_MIN_HEIGHT) && (height2 >= WINDOW_MIN_HEIGHT)
- && (pourcentage > 0) && (pourcentage <= 100))
+ if ((pourcentage > 0) && (pourcentage <= 100))
{
if ((new_window = gui_window_new (window,
window->win_x, window->win_y,
@@ -597,8 +594,7 @@ gui_window_split_vertic (t_gui_window *window, int pourcentage)
width1 = (window->win_width * pourcentage) / 100;
width2 = window->win_width - width1 - 1;
- if ((width1 >= WINDOW_MIN_WIDTH) && (width2 >= WINDOW_MIN_WIDTH)
- && (pourcentage > 0) && (pourcentage <= 100))
+ if ((pourcentage > 0) && (pourcentage <= 100))
{
if ((new_window = gui_window_new (window,
window->win_x + width1 + 1, window->win_y,
diff --git a/src/gui/gui-action.c b/src/gui/gui-action.c
index 75784c39d..6529e1054 100644
--- a/src/gui/gui-action.c
+++ b/src/gui/gui-action.c
@@ -1200,7 +1200,7 @@ gui_action_refresh_screen (t_gui_window *window)
/* make gcc happy */
(void) window;
- gui_window_refresh_screen ();
+ gui_window_refresh_screen (1);
}
/*
diff --git a/src/gui/gui-panel.c b/src/gui/gui-panel.c
index 9b5f76519..e1168ca4a 100644
--- a/src/gui/gui-panel.c
+++ b/src/gui/gui-panel.c
@@ -35,6 +35,7 @@
#include "../common/weechat.h"
#include "gui.h"
+#include "../common/log.h"
t_gui_panel *gui_panels = NULL; /* pointer to first panel */
@@ -42,11 +43,47 @@ t_gui_panel *last_gui_panel = NULL; /* pointer to last panel */
/*
+ * gui_panel_global_get_size: get total panel size (global panels) for a position
+ */
+
+int
+gui_panel_global_get_size (t_gui_panel *panel, int position)
+{
+ t_gui_panel *ptr_panel;
+ int total_size;
+
+ total_size = 0;
+ for (ptr_panel = gui_panels; ptr_panel; ptr_panel = ptr_panel->next_panel)
+ {
+ if ((panel) && (ptr_panel == panel))
+ return total_size;
+
+ if (ptr_panel->position == position)
+ {
+ switch (position)
+ {
+ case GUI_PANEL_TOP:
+ case GUI_PANEL_BOTTOM:
+ total_size += ptr_panel->size;
+ break;
+ case GUI_PANEL_LEFT:
+ case GUI_PANEL_RIGHT:
+ total_size += ptr_panel->size;
+ break;
+ }
+ if (ptr_panel->separator)
+ total_size++;
+ }
+ }
+ return total_size;
+}
+
+/*
* gui_panel_new: create a new panel
*/
t_gui_panel *
-gui_panel_new (char *name, int position, int type, int size, int separator)
+gui_panel_new (char *name, int type, int position, int size, int separator)
{
t_gui_panel *new_panel;
t_gui_window *ptr_win;
@@ -56,8 +93,9 @@ gui_panel_new (char *name, int position, int type, int size, int separator)
if ((new_panel = (t_gui_panel *) malloc (sizeof (t_gui_panel))))
{
- new_panel->position = position;
+ new_panel->number = (last_gui_panel) ? last_gui_panel->number + 1 : 1;
new_panel->name = strdup (name);
+ new_panel->position = position;
new_panel->separator = separator;
new_panel->size = size;
if (type == GUI_PANEL_WINDOWS)
@@ -111,3 +149,26 @@ gui_panel_free (t_gui_panel *panel)
free (panel);
}
+
+/*
+ * gui_panel_print_log: print panel infos in log (usually for crash dump)
+ */
+
+void
+gui_panel_print_log ()
+{
+ t_gui_panel *ptr_panel;
+
+ for (ptr_panel = gui_panels; ptr_panel; ptr_panel = ptr_panel->next_panel)
+ {
+ weechat_log_printf ("\n");
+ weechat_log_printf ("[panel (addr:0x%X)]\n", ptr_panel);
+ weechat_log_printf (" position. . . . . . : %d\n", ptr_panel->position);
+ weechat_log_printf (" name. . . . . . . . : '%s'\n", ptr_panel->name);
+ weechat_log_printf (" panel_window. . . . : 0x%X\n", ptr_panel->panel_window);
+ weechat_log_printf (" separator . . . . . : %d\n", ptr_panel->separator);
+ weechat_log_printf (" size. . . . . . . . : %d\n", ptr_panel->size);
+ weechat_log_printf (" prev_panel . .. . . : 0x%X\n", ptr_panel->prev_panel);
+ weechat_log_printf (" next_panel . .. . . : 0x%X\n", ptr_panel->next_panel);
+ }
+}
diff --git a/src/gui/gui-panel.h b/src/gui/gui-panel.h
index a4a8cac14..85a0eb73b 100644
--- a/src/gui/gui-panel.h
+++ b/src/gui/gui-panel.h
@@ -23,11 +23,11 @@
#define GUI_PANEL_TOP 1
#define GUI_PANEL_BOTTOM 2
-#define GUI_PANEL_LEFT 3
-#define GUI_PANEL_RIGHT 4
+#define GUI_PANEL_LEFT 4
+#define GUI_PANEL_RIGHT 8
-#define GUI_PANEL_GLOBAL 0
-#define GUI_PANEL_WINDOWS 1
+#define GUI_PANEL_GLOBAL 1
+#define GUI_PANEL_WINDOWS 2
/* panel structure */
@@ -36,8 +36,9 @@ typedef struct t_gui_panel t_gui_panel;
struct t_gui_panel
{
- int position; /* position (top, bottom, left, right) */
+ int number; /* panel number */
char *name; /* panel name */
+ int position; /* position (top, bottom, left, right) */
void *panel_window; /* pointer to panel window, NULL if */
/* displayed on each window (in this */
/* case, pointers are in windows) */
diff --git a/src/gui/gui-window.c b/src/gui/gui-window.c
index e6247149d..6d13907e7 100644
--- a/src/gui/gui-window.c
+++ b/src/gui/gui-window.c
@@ -213,7 +213,7 @@ gui_window_new (t_gui_window *parent, int x, int y, int width, int height,
new_window->win_nick_num_max = 0;
new_window->win_nick_start = 0;
- new_window->win_input_x = 0;
+ new_window->win_input_cursor_x = 0;
new_window->dcc_first = NULL;
new_window->dcc_selected = NULL;
@@ -409,6 +409,23 @@ gui_window_print_log (t_gui_window *window)
weechat_log_printf (" win_nick_width. . . : %d\n", window->win_nick_width);
weechat_log_printf (" win_nick_height . . : %d\n", window->win_nick_height);
weechat_log_printf (" win_nick_start. . . : %d\n", window->win_nick_start);
+ weechat_log_printf (" win_title_x . . . . : %d\n", window->win_title_x);
+ weechat_log_printf (" win_title_y . . . . : %d\n", window->win_title_y);
+ weechat_log_printf (" win_title_width . . : %d\n", window->win_title_width);
+ weechat_log_printf (" win_title_height. . : %d\n", window->win_title_height);
+ weechat_log_printf (" win_status_x. . . . : %d\n", window->win_status_x);
+ weechat_log_printf (" win_status_y. . . . : %d\n", window->win_status_y);
+ weechat_log_printf (" win_status_width. . : %d\n", window->win_status_width);
+ weechat_log_printf (" win_status_height . : %d\n", window->win_status_height);
+ weechat_log_printf (" win_infobar_x . . . : %d\n", window->win_infobar_x);
+ weechat_log_printf (" win_infobar_y . . . : %d\n", window->win_infobar_y);
+ weechat_log_printf (" win_infobar_width . : %d\n", window->win_infobar_width);
+ weechat_log_printf (" win_infobar_height. : %d\n", window->win_infobar_height);
+ weechat_log_printf (" win_input_x . . . . : %d\n", window->win_input_x);
+ weechat_log_printf (" win_input_y . . . . : %d\n", window->win_input_y);
+ weechat_log_printf (" win_input_width . . : %d\n", window->win_input_width);
+ weechat_log_printf (" win_input_height. . : %d\n", window->win_input_height);
+ weechat_log_printf (" win_input_cursor_x. : %d\n", window->win_input_cursor_x);
gui_window_objects_print_log (window);
weechat_log_printf (" dcc_first . . . . . : 0x%X\n", window->dcc_first);
weechat_log_printf (" dcc_selected. . . . : 0x%X\n", window->dcc_selected);
@@ -419,5 +436,4 @@ gui_window_print_log (t_gui_window *window)
weechat_log_printf (" start_line_pos. . . : %d\n", window->start_line_pos);
weechat_log_printf (" prev_window . . . . : 0x%X\n", window->prev_window);
weechat_log_printf (" next_window . . . . : 0x%X\n", window->next_window);
-
}
diff --git a/src/gui/gui-window.h b/src/gui/gui-window.h
index 63e796980..bf109d571 100644
--- a/src/gui/gui-window.h
+++ b/src/gui/gui-window.h
@@ -21,9 +21,6 @@
#ifndef __WEECHAT_GUI_WINDOW_H
#define __WEECHAT_GUI_WINDOW_H 1
-#define WINDOW_MIN_WIDTH 10
-#define WINDOW_MIN_HEIGHT 5
-
/* window structures */
typedef struct t_gui_window_tree t_gui_window_tree;
@@ -54,9 +51,31 @@ struct t_gui_window
int win_nick_num_max; /* maximum number of nicks displayed */
int win_nick_start; /* # of 1st nick for display (scroll) */
+ /* title window settings */
+ int win_title_x; /* title window position */
+ int win_title_y; /* title window position */
+ int win_title_width; /* width of title window */
+ int win_title_height; /* height of title window */
+
+ /* status bar settings */
+ int win_status_x; /* status window position */
+ int win_status_y; /* status window position */
+ int win_status_width; /* width of status window */
+ int win_status_height; /* height of status window */
+
+ /* infobar bar settings */
+ int win_infobar_x; /* infobar window position */
+ int win_infobar_y; /* infobar window position */
+ int win_infobar_width; /* width of infobar window */
+ int win_infobar_height; /* height of infobar window */
+
/* input window settings */
- int win_input_x; /* position of cursor in input window */
-
+ int win_input_x; /* input window position */
+ int win_input_y; /* input window position */
+ int win_input_width; /* width of input window */
+ int win_input_height; /* height of input window */
+ int win_input_cursor_x; /* position of cursor in input window */
+
/* GUI specific objects */
void *gui_objects; /* pointer to a GUI specific struct */
diff --git a/src/gui/gui.h b/src/gui/gui.h
index fa544939d..9de39f1e5 100644
--- a/src/gui/gui.h
+++ b/src/gui/gui.h
@@ -100,8 +100,10 @@ extern void gui_buffer_move_to_number (t_gui_buffer *, int);
extern void gui_buffer_print_log (t_gui_buffer *);
/* panel */
+extern int gui_panel_global_get_size (t_gui_panel *, int);
extern t_gui_panel *gui_panel_new (char *, int, int, int, int);
extern void gui_panel_free (t_gui_panel *);
+extern void gui_panel_print_log ();
/* action */
extern void gui_action_clipboard_copy (char *, int);
@@ -220,7 +222,7 @@ extern void gui_status_draw (t_gui_buffer *, int);
extern void gui_input_draw (t_gui_buffer *, int);
/* nicklist */
-extern void gui_nicklist_draw (t_gui_buffer *, int);
+extern void gui_nicklist_draw (t_gui_buffer *, int, int);
/* window */
extern int gui_window_get_width ();