summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2004-09-08 16:41:15 +0000
committerSebastien Helleu <flashcode@flashtux.org>2004-09-08 16:41:15 +0000
commit1425ee40f48630dd5e040b1123760b3aa903245c (patch)
treeb159dff3f2e695898a24f6683f7e9522e8c56a76
parentc8eae742b96622c8655502d2e896a43938b562ff (diff)
downloadweechat-1425ee40f48630dd5e040b1123760b3aa903245c.zip
Fixed crash when resizing terminal to very small size, "-MORE-" message is now erased when switching to another buffer
-rw-r--r--ChangeLog4
-rw-r--r--src/common/weechat.c4
-rw-r--r--src/gui/curses/gui-display.c76
-rw-r--r--src/gui/curses/gui-input.c3
-rw-r--r--src/gui/gui-common.c4
-rw-r--r--src/gui/gui.h3
-rw-r--r--weechat/ChangeLog4
-rw-r--r--weechat/src/common/weechat.c4
-rw-r--r--weechat/src/gui/curses/gui-display.c76
-rw-r--r--weechat/src/gui/curses/gui-input.c3
-rw-r--r--weechat/src/gui/gui-common.c4
-rw-r--r--weechat/src/gui/gui.h3
12 files changed, 164 insertions, 24 deletions
diff --git a/ChangeLog b/ChangeLog
index a39e1eb59..a10929beb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,12 @@
WeeChat - Wee Enhanced Environment for Chat
===========================================
-ChangeLog - 2004-09-01
+ChangeLog - 2004-09-08
Version 0.0.8 (under dev!):
+ * Fixed crash when resizing terminal to very small size
+ * "-MORE-" message is now erased when switching to another buffer
* DCC window with Alt-D
* /query command now reopens private buffer if already opened
* added key for redrawing terminal (Ctrl-L)
diff --git a/src/common/weechat.c b/src/common/weechat.c
index d7515ce23..dc6eb9026 100644
--- a/src/common/weechat.c
+++ b/src/common/weechat.c
@@ -364,9 +364,6 @@ wee_create_home_dirs ()
void
wee_init_vars ()
{
- /* GUI not yet initialized */
- gui_ready = 0;
-
/* init received messages queue */
recv_msgq = NULL;
msgq_last_msg = NULL;
@@ -440,6 +437,7 @@ weechat_welcome_message ()
void
wee_shutdown ()
{
+ dcc_end ();
server_free_all ();
gui_end ();
if (log_file)
diff --git a/src/gui/curses/gui-display.c b/src/gui/curses/gui-display.c
index 2f8f2c2f4..0c1fdcab5 100644
--- a/src/gui/curses/gui-display.c
+++ b/src/gui/curses/gui-display.c
@@ -174,6 +174,9 @@ gui_calculate_pos_size (t_gui_window *window)
int max_length, lines;
int num_nicks, num_op, num_halfop, num_voice, num_normal;
+ if (!gui_ok)
+ return;
+
/* init chat & nicklist settings */
if (cfg_look_nicklist && BUFFER_IS_CHANNEL(window->buffer))
{
@@ -288,6 +291,9 @@ gui_calculate_pos_size (t_gui_window *window)
void
gui_curses_window_clear (WINDOW *window)
{
+ if (!gui_ok)
+ return;
+
werase (window);
wmove (window, 0, 0);
}
@@ -302,6 +308,9 @@ gui_draw_buffer_title (t_gui_buffer *buffer, int erase)
t_gui_window *ptr_win;
char format[32];
+ if (!gui_ok)
+ return;
+
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
if (ptr_win->buffer == buffer)
@@ -562,6 +571,9 @@ gui_draw_buffer_chat (t_gui_buffer *buffer, int erase)
int num_unit;
char format[32];
+ if (!gui_ok)
+ return;
+
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
if (ptr_win->buffer == buffer)
@@ -701,6 +713,9 @@ gui_draw_buffer_nick (t_gui_buffer *buffer, int erase)
char format[32], format_empty[32];
t_irc_nick *ptr_nick;
+ if (!gui_ok)
+ return;
+
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
if (ptr_win->buffer == buffer)
@@ -859,6 +874,9 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase)
char format_more[32];
int i, first_mode;
+ if (!gui_ok)
+ return;
+
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
if (erase)
@@ -1031,6 +1049,9 @@ gui_draw_buffer_infobar (t_gui_buffer *buffer, int erase)
struct tm *local_time;
char text[1024 + 1];
+ if (!gui_ok)
+ return;
+
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
if (ptr_win->buffer == buffer)
@@ -1097,6 +1118,9 @@ gui_draw_buffer_input (t_gui_buffer *buffer, int erase)
char *ptr_nickname;
int input_width;
+ if (!gui_ok)
+ return;
+
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
if (ptr_win->buffer == buffer)
@@ -1203,6 +1227,9 @@ gui_redraw_buffer (t_gui_buffer *buffer)
{
t_gui_window *ptr_win;
+ if (!gui_ok)
+ return;
+
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
if (ptr_win->buffer == buffer)
@@ -1226,6 +1253,9 @@ gui_redraw_buffer (t_gui_buffer *buffer)
void
gui_switch_to_buffer (t_gui_window *window, t_gui_buffer *buffer)
{
+ if (!gui_ok)
+ return;
+
if (gui_current_window->buffer->num_displayed > 0)
gui_current_window->buffer->num_displayed--;
@@ -1303,6 +1333,8 @@ gui_switch_to_buffer (t_gui_window *window, t_gui_buffer *buffer)
else
window->win_status = newwin (1, window->win_width, window->win_y + window->win_height - 2, window->win_x);
+ window->sub_lines = 0;
+
buffer->num_displayed++;
hotlist_remove_buffer (buffer);
@@ -1317,6 +1349,9 @@ gui_switch_to_dcc_buffer ()
{
t_gui_buffer *ptr_buffer;
+ if (!gui_ok)
+ return;
+
/* check if dcc buffer exists */
for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer)
{
@@ -1339,6 +1374,9 @@ gui_switch_to_dcc_buffer ()
void
gui_switch_to_previous_buffer (t_gui_window *window)
{
+ if (!gui_ok)
+ return;
+
/* if only one buffer then return */
if (gui_buffers == last_gui_buffer)
return;
@@ -1358,6 +1396,9 @@ gui_switch_to_previous_buffer (t_gui_window *window)
void
gui_switch_to_next_buffer (t_gui_window *window)
{
+ if (!gui_ok)
+ return;
+
/* if only one buffer then return */
if (gui_buffers == last_gui_buffer)
return;
@@ -1377,6 +1418,9 @@ gui_switch_to_next_buffer (t_gui_window *window)
void
gui_switch_to_next_window (t_gui_window *window)
{
+ if (!gui_ok)
+ return;
+
/* if only one window then return */
if (gui_windows == last_gui_window)
return;
@@ -1393,6 +1437,9 @@ gui_switch_to_next_window (t_gui_window *window)
void
gui_move_page_up (t_gui_window *window)
{
+ if (!gui_ok)
+ return;
+
if (!window->first_line_displayed)
{
window->sub_lines += window->win_chat_height - 1;
@@ -1408,6 +1455,9 @@ gui_move_page_up (t_gui_window *window)
void
gui_move_page_down (t_gui_window *window)
{
+ if (!gui_ok)
+ return;
+
if (window->sub_lines > 0)
{
window->sub_lines -= window->win_chat_height - 1;
@@ -1449,8 +1499,14 @@ gui_curses_resize_handler ()
}
gui_current_window = old_current_window;
- gui_calculate_pos_size (gui_current_window);
- gui_redraw_buffer (gui_current_window->buffer);
+ if ((new_width > 5) && (new_height > 5))
+ {
+ gui_ok = 1;
+ gui_calculate_pos_size (gui_current_window);
+ gui_redraw_buffer (gui_current_window->buffer);
+ }
+ else
+ gui_ok = 0;
}
/*
@@ -1478,6 +1534,9 @@ gui_window_split_horiz (t_gui_window *window)
t_gui_window *new_window;
int height1, height2;
+ if (!gui_ok)
+ return;
+
height1 = window->win_height / 2;
height2 = window->win_height - height1;
if ((new_window = gui_window_new (window->win_x, window->win_y,
@@ -1508,6 +1567,9 @@ gui_window_split_vertic (t_gui_window *window)
t_gui_window *new_window;
int width1, width2;
+ if (!gui_ok)
+ return;
+
width1 = window->win_width / 2;
width2 = window->win_width - width1 - 1;
if ((new_window = gui_window_new (window->win_x + width1 + 1, window->win_y,
@@ -1715,7 +1777,9 @@ gui_init ()
gui_infobar = NULL;
- /* create a new buffer */
+ gui_ok = ((COLS > 5) && (LINES > 5));
+
+ /* create new window/buffer */
if (gui_window_new (0, 0, COLS, LINES))
{
gui_current_window = gui_windows;
@@ -1726,7 +1790,7 @@ gui_init ()
if (cfg_look_set_title)
gui_set_window_title ();
- gui_ready = 1;
+ gui_init_ok = 1;
}
}
@@ -1840,7 +1904,7 @@ gui_printf_color_type (t_gui_buffer *buffer, int type, int color, char *message,
static time_t seconds;
struct tm *date_tmp;
- if (gui_ready)
+ if (gui_init_ok)
{
if (color == -1)
color = COLOR_WIN_CHAT;
@@ -1864,7 +1928,7 @@ gui_printf_color_type (t_gui_buffer *buffer, int type, int color, char *message,
vsnprintf (buf, sizeof (buf) - 1, message, argptr);
va_end (argptr);
- if (gui_ready)
+ if (gui_init_ok)
{
seconds = time (NULL);
date_tmp = localtime (&seconds);
diff --git a/src/gui/curses/gui-input.c b/src/gui/curses/gui-input.c
index 83cf74630..25c436dd4 100644
--- a/src/gui/curses/gui-input.c
+++ b/src/gui/curses/gui-input.c
@@ -541,5 +541,8 @@ gui_main_loop ()
}
}
}
+
+ /* manages active DCC */
+ dcc_handle ();
}
}
diff --git a/src/gui/gui-common.c b/src/gui/gui-common.c
index 7dc7fbdb4..04ff320c2 100644
--- a/src/gui/gui-common.c
+++ b/src/gui/gui-common.c
@@ -39,7 +39,9 @@
#include "../irc/irc.h"
-int gui_ready; /* = 1 if GUI is initialized */
+int gui_init_ok = 0; /* = 1 if GUI is initialized */
+int gui_ok = 0; /* = 1 if GUI is ok */
+ /* (0 when term size too small) */
t_gui_window *gui_windows = NULL; /* pointer to first window */
t_gui_window *last_gui_window = NULL; /* pointer to last window */
diff --git a/src/gui/gui.h b/src/gui/gui.h
index bed1707cf..4f44ba8d8 100644
--- a/src/gui/gui.h
+++ b/src/gui/gui.h
@@ -221,7 +221,8 @@ struct t_gui_window
/* variables */
-extern int gui_ready;
+extern int gui_init_ok;
+extern int gui_ok;
extern t_gui_window *gui_windows;
extern t_gui_window *last_gui_window;
extern t_gui_window *gui_current_window;
diff --git a/weechat/ChangeLog b/weechat/ChangeLog
index a39e1eb59..a10929beb 100644
--- a/weechat/ChangeLog
+++ b/weechat/ChangeLog
@@ -1,10 +1,12 @@
WeeChat - Wee Enhanced Environment for Chat
===========================================
-ChangeLog - 2004-09-01
+ChangeLog - 2004-09-08
Version 0.0.8 (under dev!):
+ * Fixed crash when resizing terminal to very small size
+ * "-MORE-" message is now erased when switching to another buffer
* DCC window with Alt-D
* /query command now reopens private buffer if already opened
* added key for redrawing terminal (Ctrl-L)
diff --git a/weechat/src/common/weechat.c b/weechat/src/common/weechat.c
index d7515ce23..dc6eb9026 100644
--- a/weechat/src/common/weechat.c
+++ b/weechat/src/common/weechat.c
@@ -364,9 +364,6 @@ wee_create_home_dirs ()
void
wee_init_vars ()
{
- /* GUI not yet initialized */
- gui_ready = 0;
-
/* init received messages queue */
recv_msgq = NULL;
msgq_last_msg = NULL;
@@ -440,6 +437,7 @@ weechat_welcome_message ()
void
wee_shutdown ()
{
+ dcc_end ();
server_free_all ();
gui_end ();
if (log_file)
diff --git a/weechat/src/gui/curses/gui-display.c b/weechat/src/gui/curses/gui-display.c
index 2f8f2c2f4..0c1fdcab5 100644
--- a/weechat/src/gui/curses/gui-display.c
+++ b/weechat/src/gui/curses/gui-display.c
@@ -174,6 +174,9 @@ gui_calculate_pos_size (t_gui_window *window)
int max_length, lines;
int num_nicks, num_op, num_halfop, num_voice, num_normal;
+ if (!gui_ok)
+ return;
+
/* init chat & nicklist settings */
if (cfg_look_nicklist && BUFFER_IS_CHANNEL(window->buffer))
{
@@ -288,6 +291,9 @@ gui_calculate_pos_size (t_gui_window *window)
void
gui_curses_window_clear (WINDOW *window)
{
+ if (!gui_ok)
+ return;
+
werase (window);
wmove (window, 0, 0);
}
@@ -302,6 +308,9 @@ gui_draw_buffer_title (t_gui_buffer *buffer, int erase)
t_gui_window *ptr_win;
char format[32];
+ if (!gui_ok)
+ return;
+
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
if (ptr_win->buffer == buffer)
@@ -562,6 +571,9 @@ gui_draw_buffer_chat (t_gui_buffer *buffer, int erase)
int num_unit;
char format[32];
+ if (!gui_ok)
+ return;
+
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
if (ptr_win->buffer == buffer)
@@ -701,6 +713,9 @@ gui_draw_buffer_nick (t_gui_buffer *buffer, int erase)
char format[32], format_empty[32];
t_irc_nick *ptr_nick;
+ if (!gui_ok)
+ return;
+
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
if (ptr_win->buffer == buffer)
@@ -859,6 +874,9 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase)
char format_more[32];
int i, first_mode;
+ if (!gui_ok)
+ return;
+
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
if (erase)
@@ -1031,6 +1049,9 @@ gui_draw_buffer_infobar (t_gui_buffer *buffer, int erase)
struct tm *local_time;
char text[1024 + 1];
+ if (!gui_ok)
+ return;
+
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
if (ptr_win->buffer == buffer)
@@ -1097,6 +1118,9 @@ gui_draw_buffer_input (t_gui_buffer *buffer, int erase)
char *ptr_nickname;
int input_width;
+ if (!gui_ok)
+ return;
+
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
if (ptr_win->buffer == buffer)
@@ -1203,6 +1227,9 @@ gui_redraw_buffer (t_gui_buffer *buffer)
{
t_gui_window *ptr_win;
+ if (!gui_ok)
+ return;
+
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
if (ptr_win->buffer == buffer)
@@ -1226,6 +1253,9 @@ gui_redraw_buffer (t_gui_buffer *buffer)
void
gui_switch_to_buffer (t_gui_window *window, t_gui_buffer *buffer)
{
+ if (!gui_ok)
+ return;
+
if (gui_current_window->buffer->num_displayed > 0)
gui_current_window->buffer->num_displayed--;
@@ -1303,6 +1333,8 @@ gui_switch_to_buffer (t_gui_window *window, t_gui_buffer *buffer)
else
window->win_status = newwin (1, window->win_width, window->win_y + window->win_height - 2, window->win_x);
+ window->sub_lines = 0;
+
buffer->num_displayed++;
hotlist_remove_buffer (buffer);
@@ -1317,6 +1349,9 @@ gui_switch_to_dcc_buffer ()
{
t_gui_buffer *ptr_buffer;
+ if (!gui_ok)
+ return;
+
/* check if dcc buffer exists */
for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer)
{
@@ -1339,6 +1374,9 @@ gui_switch_to_dcc_buffer ()
void
gui_switch_to_previous_buffer (t_gui_window *window)
{
+ if (!gui_ok)
+ return;
+
/* if only one buffer then return */
if (gui_buffers == last_gui_buffer)
return;
@@ -1358,6 +1396,9 @@ gui_switch_to_previous_buffer (t_gui_window *window)
void
gui_switch_to_next_buffer (t_gui_window *window)
{
+ if (!gui_ok)
+ return;
+
/* if only one buffer then return */
if (gui_buffers == last_gui_buffer)
return;
@@ -1377,6 +1418,9 @@ gui_switch_to_next_buffer (t_gui_window *window)
void
gui_switch_to_next_window (t_gui_window *window)
{
+ if (!gui_ok)
+ return;
+
/* if only one window then return */
if (gui_windows == last_gui_window)
return;
@@ -1393,6 +1437,9 @@ gui_switch_to_next_window (t_gui_window *window)
void
gui_move_page_up (t_gui_window *window)
{
+ if (!gui_ok)
+ return;
+
if (!window->first_line_displayed)
{
window->sub_lines += window->win_chat_height - 1;
@@ -1408,6 +1455,9 @@ gui_move_page_up (t_gui_window *window)
void
gui_move_page_down (t_gui_window *window)
{
+ if (!gui_ok)
+ return;
+
if (window->sub_lines > 0)
{
window->sub_lines -= window->win_chat_height - 1;
@@ -1449,8 +1499,14 @@ gui_curses_resize_handler ()
}
gui_current_window = old_current_window;
- gui_calculate_pos_size (gui_current_window);
- gui_redraw_buffer (gui_current_window->buffer);
+ if ((new_width > 5) && (new_height > 5))
+ {
+ gui_ok = 1;
+ gui_calculate_pos_size (gui_current_window);
+ gui_redraw_buffer (gui_current_window->buffer);
+ }
+ else
+ gui_ok = 0;
}
/*
@@ -1478,6 +1534,9 @@ gui_window_split_horiz (t_gui_window *window)
t_gui_window *new_window;
int height1, height2;
+ if (!gui_ok)
+ return;
+
height1 = window->win_height / 2;
height2 = window->win_height - height1;
if ((new_window = gui_window_new (window->win_x, window->win_y,
@@ -1508,6 +1567,9 @@ gui_window_split_vertic (t_gui_window *window)
t_gui_window *new_window;
int width1, width2;
+ if (!gui_ok)
+ return;
+
width1 = window->win_width / 2;
width2 = window->win_width - width1 - 1;
if ((new_window = gui_window_new (window->win_x + width1 + 1, window->win_y,
@@ -1715,7 +1777,9 @@ gui_init ()
gui_infobar = NULL;
- /* create a new buffer */
+ gui_ok = ((COLS > 5) && (LINES > 5));
+
+ /* create new window/buffer */
if (gui_window_new (0, 0, COLS, LINES))
{
gui_current_window = gui_windows;
@@ -1726,7 +1790,7 @@ gui_init ()
if (cfg_look_set_title)
gui_set_window_title ();
- gui_ready = 1;
+ gui_init_ok = 1;
}
}
@@ -1840,7 +1904,7 @@ gui_printf_color_type (t_gui_buffer *buffer, int type, int color, char *message,
static time_t seconds;
struct tm *date_tmp;
- if (gui_ready)
+ if (gui_init_ok)
{
if (color == -1)
color = COLOR_WIN_CHAT;
@@ -1864,7 +1928,7 @@ gui_printf_color_type (t_gui_buffer *buffer, int type, int color, char *message,
vsnprintf (buf, sizeof (buf) - 1, message, argptr);
va_end (argptr);
- if (gui_ready)
+ if (gui_init_ok)
{
seconds = time (NULL);
date_tmp = localtime (&seconds);
diff --git a/weechat/src/gui/curses/gui-input.c b/weechat/src/gui/curses/gui-input.c
index 83cf74630..25c436dd4 100644
--- a/weechat/src/gui/curses/gui-input.c
+++ b/weechat/src/gui/curses/gui-input.c
@@ -541,5 +541,8 @@ gui_main_loop ()
}
}
}
+
+ /* manages active DCC */
+ dcc_handle ();
}
}
diff --git a/weechat/src/gui/gui-common.c b/weechat/src/gui/gui-common.c
index 7dc7fbdb4..04ff320c2 100644
--- a/weechat/src/gui/gui-common.c
+++ b/weechat/src/gui/gui-common.c
@@ -39,7 +39,9 @@
#include "../irc/irc.h"
-int gui_ready; /* = 1 if GUI is initialized */
+int gui_init_ok = 0; /* = 1 if GUI is initialized */
+int gui_ok = 0; /* = 1 if GUI is ok */
+ /* (0 when term size too small) */
t_gui_window *gui_windows = NULL; /* pointer to first window */
t_gui_window *last_gui_window = NULL; /* pointer to last window */
diff --git a/weechat/src/gui/gui.h b/weechat/src/gui/gui.h
index bed1707cf..4f44ba8d8 100644
--- a/weechat/src/gui/gui.h
+++ b/weechat/src/gui/gui.h
@@ -221,7 +221,8 @@ struct t_gui_window
/* variables */
-extern int gui_ready;
+extern int gui_init_ok;
+extern int gui_ok;
extern t_gui_window *gui_windows;
extern t_gui_window *last_gui_window;
extern t_gui_window *gui_current_window;