summaryrefslogtreecommitdiff
path: root/src/gui/curses
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/curses')
-rw-r--r--src/gui/curses/CMakeLists.txt2
-rw-r--r--src/gui/curses/gui-curses-main.c84
-rw-r--r--src/gui/curses/gui-curses-nicklist.c21
-rw-r--r--src/gui/curses/gui-curses-window.c51
-rw-r--r--src/gui/curses/gui-curses.h3
5 files changed, 93 insertions, 68 deletions
diff --git a/src/gui/curses/CMakeLists.txt b/src/gui/curses/CMakeLists.txt
index 7be285854..bdfd9d256 100644
--- a/src/gui/curses/CMakeLists.txt
+++ b/src/gui/curses/CMakeLists.txt
@@ -48,6 +48,6 @@ ADD_EXECUTABLE(${EXECUTABLE} ${WEECHAT_CURSES_SRC})
INCLUDE_DIRECTORIES(.. ../../core ../../plugins)
# Because of a linker bug, we have to link 2 times with libweechat_core.a
-TARGET_LINK_LIBRARIES(${EXECUTABLE} ${STATIC_LIBS} ${EXTRA_LIBS})
+TARGET_LINK_LIBRARIES(${EXECUTABLE} ${STATIC_LIBS} ${EXTRA_LIBS} ${STATIC_LIBS})
INSTALL(TARGETS ${EXECUTABLE} RUNTIME DESTINATION bin)
diff --git a/src/gui/curses/gui-curses-main.c b/src/gui/curses/gui-curses-main.c
index 8c3a69da7..8226011f0 100644
--- a/src/gui/curses/gui-curses-main.c
+++ b/src/gui/curses/gui-curses-main.c
@@ -122,7 +122,6 @@ gui_main_init ()
gui_buffer_set_title (ptr_buffer,
"WeeChat " WEECHAT_COPYRIGHT_DATE
" - " WEECHAT_WEBSITE);
- gui_window_redraw_buffer (ptr_buffer);
}
else
gui_init_ok = 0;
@@ -246,57 +245,56 @@ gui_main_loop ()
/* execute hook timers */
hook_timer_exec ();
- /* refresh status bar if needed */
- if (gui_status_refresh_needed)
- gui_status_draw (1);
-
- for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
+ /* refresh window if needed */
+ if (gui_window_refresh_needed)
{
- if (ptr_bar->bar_refresh_needed)
- {
- gui_bar_draw (ptr_bar);
- ptr_bar->bar_refresh_needed = 0;
- }
+ gui_window_refresh_screen ();
+ gui_window_refresh_needed = 0;
}
-
- for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
+ else
{
- if (ptr_win->refresh_needed)
+ /* refresh status bar if needed */
+ if (gui_status_refresh_needed)
+ gui_status_draw (1);
+
+ for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
{
- gui_window_switch_to_buffer (ptr_win, ptr_win->buffer);
- gui_window_redraw_buffer (ptr_win->buffer);
- ptr_win->refresh_needed = 0;
+ if (ptr_bar->bar_refresh_needed)
+ gui_bar_draw (ptr_bar);
}
- }
-
- for (ptr_buffer = gui_buffers; ptr_buffer;
- ptr_buffer = ptr_buffer->next_buffer)
- {
- /* refresh title if needed */
- if (ptr_buffer->title_refresh_needed)
- gui_chat_draw_title (ptr_buffer, 1);
- /* refresh chat if needed */
- if (ptr_buffer->chat_refresh_needed)
+ for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
- gui_chat_draw (ptr_buffer,
- (ptr_buffer->chat_refresh_needed) > 1 ? 1 : 0);
+ if (ptr_win->refresh_needed)
+ {
+ gui_window_switch_to_buffer (ptr_win, ptr_win->buffer);
+ gui_window_redraw_buffer (ptr_win->buffer);
+ ptr_win->refresh_needed = 0;
+ }
}
- /* refresh nicklist if needed */
- if (ptr_buffer->nicklist_refresh_needed)
- gui_nicklist_draw (ptr_buffer, 1);
-
- /* refresh input if needed */
- if (ptr_buffer->input_refresh_needed)
- gui_input_draw (ptr_buffer, 1);
- }
-
- /* refresh window if needed */
- if (gui_window_refresh_needed)
- {
- gui_window_refresh_screen ();
- gui_window_refresh_needed = 0;
+ for (ptr_buffer = gui_buffers; ptr_buffer;
+ ptr_buffer = ptr_buffer->next_buffer)
+ {
+ /* refresh title if needed */
+ if (ptr_buffer->title_refresh_needed)
+ gui_chat_draw_title (ptr_buffer, 1);
+
+ /* refresh nicklist if needed */
+ if (ptr_buffer->nicklist_refresh_needed)
+ gui_nicklist_draw (ptr_buffer, 1);
+
+ /* refresh chat if needed */
+ if (ptr_buffer->chat_refresh_needed)
+ {
+ gui_chat_draw (ptr_buffer,
+ (ptr_buffer->chat_refresh_needed) > 1 ? 1 : 0);
+ }
+
+ /* refresh input if needed */
+ if (ptr_buffer->input_refresh_needed)
+ gui_input_draw (ptr_buffer, 1);
+ }
}
/* wait for keyboard or network activity */
diff --git a/src/gui/curses/gui-curses-nicklist.c b/src/gui/curses/gui-curses-nicklist.c
index 8b189099f..4882363a5 100644
--- a/src/gui/curses/gui-curses-nicklist.c
+++ b/src/gui/curses/gui-curses-nicklist.c
@@ -40,21 +40,31 @@
/*
* gui_nicklist_draw: draw nick window for a buffer
+ * return 1 if chat window has been refreshed, 0 if only
+ * nicklist has been refreshed
*/
-void
+int
gui_nicklist_draw (struct t_gui_buffer *buffer, int erase)
{
struct t_gui_window *ptr_win;
struct t_gui_nick_group *ptr_group, *save_ptr_group;
struct t_gui_nick *ptr_nick, *save_ptr_nick;
struct t_config_option *ptr_option;
- int i, j, k, x, y, x2, max_y, column, max_length, max_chars;
+ int rc, i, j, k, x, y, x2, max_y, column, max_length, max_chars;
int nicks_displayed, num_to_display, chars_left;
char format_empty[32], *buf, *ptr_buf, *ptr_next, saved_char;
- if (!gui_ok || (!buffer->nicklist))
- return;
+ rc = 0;
+
+ if (!gui_ok)
+ return 0;
+
+ if (!buffer->nicklist)
+ {
+ buffer->nicklist_refresh_needed = 0;
+ return 0;
+ }
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
@@ -80,6 +90,7 @@ gui_nicklist_draw (struct t_gui_buffer *buffer, int erase)
ptr_win->win_nick_x);
gui_chat_draw (buffer, 1);
erase = 1;
+ rc = 1;
}
}
@@ -334,4 +345,6 @@ gui_nicklist_draw (struct t_gui_buffer *buffer, int erase)
}
buffer->nicklist_refresh_needed = 0;
+
+ return rc;
}
diff --git a/src/gui/curses/gui-curses-window.c b/src/gui/curses/gui-curses-window.c
index da177a941..dcdfe4a4f 100644
--- a/src/gui/curses/gui-curses-window.c
+++ b/src/gui/curses/gui-curses-window.c
@@ -585,9 +585,8 @@ gui_window_redraw_buffer (struct t_gui_buffer *buffer)
return;
gui_chat_draw_title (buffer, 1);
- gui_chat_draw (buffer, 1);
- if (buffer->nicklist)
- gui_nicklist_draw (buffer, 1);
+ if (!gui_nicklist_draw (buffer, 1))
+ gui_chat_draw (buffer, 1);
gui_status_draw (1);
gui_input_draw (buffer, 1);
}
@@ -714,9 +713,11 @@ gui_window_switch_to_buffer (struct t_gui_window *window,
for (ptr_bar_win = GUI_CURSES(window)->bar_windows; ptr_bar_win;
ptr_bar_win = ptr_bar_win->next_bar_window)
{
- gui_bar_draw (ptr_bar_win->bar);
+ ptr_bar_win->bar->bar_refresh_needed = 1;
}
+ window->refresh_needed = 1;
+
hook_signal_send ("buffer_switch",
WEECHAT_HOOK_SIGNAL_POINTER, buffer);
}
@@ -750,7 +751,7 @@ gui_window_switch (struct t_gui_window *window)
gui_window_switch_to_buffer (gui_current_window,
gui_current_window->buffer);
- gui_window_redraw_buffer (gui_current_window->buffer);
+ gui_current_window->refresh_needed = 1;
}
/*
@@ -1298,14 +1299,16 @@ gui_window_refresh_windows ()
* gui_window_split_horiz: split a window horizontally
*/
-void
+struct t_gui_window *
gui_window_split_horiz (struct t_gui_window *window, int percentage)
{
struct t_gui_window *new_window;
int height1, height2;
if (!gui_ok)
- return;
+ return NULL;
+
+ new_window = NULL;
height1 = (window->win_height * percentage) / 100;
height2 = window->win_height - height1;
@@ -1313,10 +1316,11 @@ gui_window_split_horiz (struct t_gui_window *window, int percentage)
if ((height1 >= GUI_WINDOW_MIN_HEIGHT) && (height2 >= GUI_WINDOW_MIN_HEIGHT)
&& (percentage > 0) && (percentage <= 100))
{
- if ((new_window = gui_window_new (window,
- window->win_x, window->win_y,
- window->win_width, height1,
- 100, percentage)))
+ new_window = gui_window_new (window,
+ window->win_x, window->win_y,
+ window->win_width, height1,
+ 100, percentage);
+ if (new_window)
{
/* reduce old window height (bottom window) */
window->win_y = new_window->win_y + new_window->win_height;
@@ -1332,20 +1336,24 @@ gui_window_split_horiz (struct t_gui_window *window, int percentage)
gui_window_switch (new_window);
}
}
+
+ return new_window;
}
/*
* gui_window_split_vertic: split a window vertically
*/
-void
+struct t_gui_window *
gui_window_split_vertic (struct t_gui_window *window, int percentage)
{
struct t_gui_window *new_window;
int width1, width2;
if (!gui_ok)
- return;
+ return NULL;
+
+ new_window = NULL;
width1 = (window->win_width * percentage) / 100;
width2 = window->win_width - width1 - 1;
@@ -1353,10 +1361,11 @@ gui_window_split_vertic (struct t_gui_window *window, int percentage)
if ((width1 >= GUI_WINDOW_MIN_WIDTH) && (width2 >= GUI_WINDOW_MIN_WIDTH)
&& (percentage > 0) && (percentage <= 100))
{
- if ((new_window = gui_window_new (window,
- window->win_x + width1 + 1, window->win_y,
- width2, window->win_height,
- percentage, 100)))
+ new_window = gui_window_new (window,
+ window->win_x + width1 + 1, window->win_y,
+ width2, window->win_height,
+ percentage, 100);
+ if (new_window)
{
/* reduce old window height (left window) */
window->win_width = width1;
@@ -1374,6 +1383,8 @@ gui_window_split_vertic (struct t_gui_window *window, int percentage)
gui_window_draw_separator (gui_current_window);
}
}
+
+ return new_window;
}
/*
@@ -1410,7 +1421,7 @@ gui_window_resize (struct t_gui_window *window, int percentage)
1) < 0)
parent->split_pct = old_split_pct;
else
- gui_window_refresh_windows ();
+ gui_window_refresh_needed = 1;
}
}
@@ -1456,7 +1467,7 @@ gui_window_merge (struct t_gui_window *window)
gui_window_tree_node_to_leaf (parent, window);
gui_window_switch_to_buffer (window, window->buffer);
- gui_window_redraw_buffer (window->buffer);
+ window->refresh_needed = 1;
return 1;
}
return 0;
@@ -1501,7 +1512,7 @@ gui_window_merge_all (struct t_gui_window *window)
gui_current_window = window;
gui_window_switch_to_buffer (window, window->buffer);
- gui_window_redraw_buffer (window->buffer);
+ window->refresh_needed = 1;
}
}
diff --git a/src/gui/curses/gui-curses.h b/src/gui/curses/gui-curses.h
index ac48ff02e..bd817c873 100644
--- a/src/gui/curses/gui-curses.h
+++ b/src/gui/curses/gui-curses.h
@@ -28,6 +28,8 @@
#include <curses.h>
#endif
+struct t_gui_buffer;
+
#define GUI_WINDOW_MIN_WIDTH 10
#define GUI_WINDOW_MIN_HEIGHT 5
@@ -92,6 +94,7 @@ extern void gui_keyboard_default_bindings ();
extern int gui_keyboard_read_cb (void *data);
/* window functions */
+extern void gui_window_redraw_buffer (struct t_gui_buffer *buffer);
extern int gui_window_utf_char_valid (const char *utf_char);
extern void gui_window_wprintw (WINDOW *window, const char *data, ...);
extern void gui_window_clear_weechat (WINDOW *window, int num_color);