mirror of
https://github.com/weechat/weechat.git
synced 2026-06-29 14:26:39 +02:00
Reduced number of screen refreshs, fixed display bug with title bar
This commit is contained in:
@@ -170,33 +170,37 @@ void
|
||||
gui_chat_draw_title (struct t_gui_buffer *buffer, int erase)
|
||||
{
|
||||
struct t_gui_window *ptr_win;
|
||||
char format[32], *buf, *buf2, *ptr_title;
|
||||
char format[32], *buf, *title_decoded, *ptr_title;
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
title_decoded = (buffer->title) ?
|
||||
(char *)gui_color_decode ((unsigned char *)buffer->title) : NULL;
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
if ((ptr_win->buffer == buffer) && (buffer->num_displayed > 0))
|
||||
if (ptr_win->buffer == buffer)
|
||||
{
|
||||
if (erase)
|
||||
gui_window_curses_clear (GUI_CURSES(ptr_win)->win_title, GUI_COLOR_TITLE);
|
||||
|
||||
snprintf (format, 32, "%%-%ds", ptr_win->win_title_width);
|
||||
snprintf (format, sizeof (format), "%%-%ds", ptr_win->win_title_width);
|
||||
wmove (GUI_CURSES(ptr_win)->win_title, 0, 0);
|
||||
|
||||
if (buffer->title)
|
||||
if (title_decoded)
|
||||
{
|
||||
buf = (char *)gui_color_decode ((unsigned char *)buffer->title);
|
||||
ptr_title = utf8_add_offset ((buf) ? buf : buffer->title,
|
||||
ptr_title = utf8_add_offset (title_decoded,
|
||||
ptr_win->win_title_start);
|
||||
if (!ptr_title || !ptr_title[0])
|
||||
{
|
||||
ptr_win->win_title_start = 0;
|
||||
ptr_title = (buf) ? buf : buffer->title;
|
||||
ptr_title = title_decoded;
|
||||
}
|
||||
buf2 = string_iconv_from_internal (NULL,
|
||||
ptr_title);
|
||||
buf = string_iconv_from_internal (NULL,
|
||||
ptr_title);
|
||||
if (buf)
|
||||
ptr_title = buf;
|
||||
|
||||
if (ptr_win->win_title_start > 0)
|
||||
{
|
||||
@@ -209,8 +213,7 @@ gui_chat_draw_title (struct t_gui_buffer *buffer, int erase)
|
||||
{
|
||||
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_title,
|
||||
GUI_COLOR_TITLE);
|
||||
wprintw (GUI_CURSES(ptr_win)->win_title, "%s",
|
||||
(buf2) ? buf2 : ptr_title);
|
||||
wprintw (GUI_CURSES(ptr_win)->win_title, "%s", ptr_title);
|
||||
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_title,
|
||||
GUI_COLOR_TITLE_MORE);
|
||||
mvwprintw (GUI_CURSES(ptr_win)->win_title, 0,
|
||||
@@ -221,24 +224,24 @@ gui_chat_draw_title (struct t_gui_buffer *buffer, int erase)
|
||||
{
|
||||
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_title,
|
||||
GUI_COLOR_TITLE);
|
||||
wprintw (GUI_CURSES(ptr_win)->win_title, "%s",
|
||||
(buf2) ? buf2 : ptr_title);
|
||||
wprintw (GUI_CURSES(ptr_win)->win_title, "%s", ptr_title);
|
||||
}
|
||||
if (buf)
|
||||
free (buf);
|
||||
if (buf2)
|
||||
free (buf2);
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_title,
|
||||
GUI_COLOR_TITLE);
|
||||
wprintw (GUI_CURSES(ptr_win)->win_title, format, " ");
|
||||
}
|
||||
wnoutrefresh (GUI_CURSES(ptr_win)->win_title);
|
||||
refresh ();
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_title,
|
||||
GUI_COLOR_TITLE);
|
||||
wprintw (GUI_CURSES(ptr_win)->win_title, format, " ");
|
||||
}
|
||||
wnoutrefresh (GUI_CURSES(ptr_win)->win_title);
|
||||
refresh ();
|
||||
}
|
||||
|
||||
if (title_decoded)
|
||||
free (title_decoded);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -351,14 +351,14 @@ gui_input_draw (struct t_gui_buffer *buffer, int erase)
|
||||
|
||||
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_input,
|
||||
GUI_COLOR_INPUT);
|
||||
snprintf (format, 32, "%%-%ds",
|
||||
snprintf (format, sizeof (format), "%%-%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_input_width - prompt_length);
|
||||
else
|
||||
wprintw (GUI_CURSES(ptr_win)->win_input, format, "");
|
||||
wprintw (GUI_CURSES(ptr_win)->win_input, format, " ");
|
||||
wclrtoeol (GUI_CURSES(ptr_win)->win_input);
|
||||
ptr_win->win_input_cursor_x = prompt_length + offset_cursor;
|
||||
if (ptr_win == gui_current_window)
|
||||
|
||||
@@ -425,25 +425,17 @@ gui_window_draw_separator (struct t_gui_window *window)
|
||||
void
|
||||
gui_window_redraw_buffer (struct t_gui_buffer *buffer)
|
||||
{
|
||||
struct 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)
|
||||
{
|
||||
gui_chat_draw_title (buffer, 1);
|
||||
gui_chat_draw (buffer, 1);
|
||||
if (GUI_CURSES(ptr_win)->win_nick)
|
||||
gui_nicklist_draw (buffer, 1);
|
||||
gui_status_draw (1);
|
||||
if (CONFIG_BOOLEAN(config_look_infobar))
|
||||
gui_infobar_draw (buffer, 1);
|
||||
gui_input_draw (buffer, 1);
|
||||
}
|
||||
}
|
||||
gui_chat_draw_title (buffer, 1);
|
||||
gui_chat_draw (buffer, 1);
|
||||
if (buffer->nicklist)
|
||||
gui_nicklist_draw (buffer, 1);
|
||||
gui_status_draw (1);
|
||||
if (CONFIG_BOOLEAN(config_look_infobar))
|
||||
gui_infobar_draw (buffer, 1);
|
||||
gui_input_draw (buffer, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -453,11 +445,15 @@ gui_window_redraw_buffer (struct t_gui_buffer *buffer)
|
||||
void
|
||||
gui_window_redraw_all_buffers ()
|
||||
{
|
||||
struct t_gui_window *ptr_win;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer;
|
||||
ptr_buffer = ptr_buffer->next_buffer)
|
||||
{
|
||||
gui_window_redraw_buffer (ptr_win->buffer);
|
||||
gui_window_redraw_buffer (ptr_buffer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -877,6 +873,9 @@ gui_window_auto_resize (struct t_gui_window_tree *tree,
|
||||
{
|
||||
int size1, size2;
|
||||
|
||||
if (!gui_ok)
|
||||
return 0;
|
||||
|
||||
if (tree)
|
||||
{
|
||||
if (tree->window)
|
||||
@@ -928,29 +927,31 @@ void
|
||||
gui_window_refresh_windows ()
|
||||
{
|
||||
struct t_gui_window *ptr_win, *old_current_window;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
if (gui_ok)
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
old_current_window = gui_current_window;
|
||||
|
||||
if (gui_window_auto_resize (gui_windows_tree, 0, 0,
|
||||
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)
|
||||
{
|
||||
old_current_window = gui_current_window;
|
||||
|
||||
if (gui_window_auto_resize (gui_windows_tree, 0, 0,
|
||||
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 (ptr_win, ptr_win->buffer);
|
||||
gui_window_draw_separator (ptr_win);
|
||||
}
|
||||
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer;
|
||||
ptr_buffer = ptr_buffer->next_buffer)
|
||||
{
|
||||
gui_window_redraw_buffer (ptr_buffer);
|
||||
}
|
||||
|
||||
gui_current_window = old_current_window;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1049,6 +1050,9 @@ gui_window_resize (struct t_gui_window *window, int pourcentage)
|
||||
struct t_gui_window_tree *parent;
|
||||
int old_split_pct;
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
parent = window->ptr_tree->parent_node;
|
||||
if (parent)
|
||||
{
|
||||
@@ -1076,6 +1080,9 @@ gui_window_merge (struct t_gui_window *window)
|
||||
{
|
||||
struct t_gui_window_tree *parent, *sister;
|
||||
|
||||
if (!gui_ok)
|
||||
return 0;
|
||||
|
||||
parent = window->ptr_tree->parent_node;
|
||||
if (parent)
|
||||
{
|
||||
@@ -1120,7 +1127,10 @@ void
|
||||
gui_window_merge_all (struct t_gui_window *window)
|
||||
{
|
||||
int num_deleted;
|
||||
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
num_deleted = 0;
|
||||
while (gui_windows->next_window)
|
||||
{
|
||||
@@ -1157,6 +1167,9 @@ gui_window_merge_all (struct t_gui_window *window)
|
||||
int
|
||||
gui_window_side_by_side (struct t_gui_window *win1, struct t_gui_window *win2)
|
||||
{
|
||||
if (!gui_ok)
|
||||
return 0;
|
||||
|
||||
/* win2 over win1 ? */
|
||||
if (win2->win_y + win2->win_height == win1->win_y)
|
||||
{
|
||||
@@ -1209,6 +1222,9 @@ gui_window_switch_up (struct t_gui_window *window)
|
||||
{
|
||||
struct t_gui_window *ptr_win;
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win;
|
||||
ptr_win = ptr_win->next_window)
|
||||
{
|
||||
@@ -1232,6 +1248,9 @@ gui_window_switch_down (struct t_gui_window *window)
|
||||
{
|
||||
struct t_gui_window *ptr_win;
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win;
|
||||
ptr_win = ptr_win->next_window)
|
||||
{
|
||||
@@ -1255,6 +1274,9 @@ gui_window_switch_left (struct t_gui_window *window)
|
||||
{
|
||||
struct t_gui_window *ptr_win;
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win;
|
||||
ptr_win = ptr_win->next_window)
|
||||
{
|
||||
@@ -1278,6 +1300,9 @@ gui_window_switch_right (struct t_gui_window *window)
|
||||
{
|
||||
struct t_gui_window *ptr_win;
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win;
|
||||
ptr_win = ptr_win->next_window)
|
||||
{
|
||||
@@ -1301,14 +1326,17 @@ void
|
||||
gui_window_refresh_screen (int force)
|
||||
{
|
||||
int new_height, new_width;
|
||||
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
if (force || (gui_window_refresh_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)
|
||||
@@ -1317,9 +1345,9 @@ gui_window_refresh_screen (int force)
|
||||
gui_window_refresh_windows ();
|
||||
}
|
||||
}
|
||||
|
||||
if (!force && (gui_window_refresh_needed > 0))
|
||||
gui_window_refresh_needed--;
|
||||
|
||||
if (gui_window_refresh_needed > 0)
|
||||
gui_window_refresh_needed = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -805,18 +805,18 @@ gui_buffer_switch_raw_data (struct t_gui_window *window)
|
||||
* gui_buffer_switch_by_number: switch to another buffer with number
|
||||
*/
|
||||
|
||||
struct t_gui_buffer *
|
||||
void
|
||||
gui_buffer_switch_by_number (struct t_gui_window *window, int number)
|
||||
{
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
/* invalid buffer */
|
||||
if (number < 0)
|
||||
return NULL;
|
||||
return;
|
||||
|
||||
/* buffer is currently displayed ? */
|
||||
if (number == window->buffer->number)
|
||||
return window->buffer;
|
||||
return;
|
||||
|
||||
/* search for buffer in the list */
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer)
|
||||
@@ -825,12 +825,9 @@ gui_buffer_switch_by_number (struct t_gui_window *window, int number)
|
||||
{
|
||||
gui_window_switch_to_buffer (window, ptr_buffer);
|
||||
gui_window_redraw_buffer (window->buffer);
|
||||
return ptr_buffer;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* buffer not found */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -145,8 +145,10 @@ extern void *gui_buffer_get (struct t_gui_buffer *buffer, char *property);
|
||||
extern void gui_buffer_set_category (struct t_gui_buffer *buffer,
|
||||
char *category);
|
||||
extern void gui_buffer_set_name (struct t_gui_buffer *buffer, char *name);
|
||||
extern void gui_buffer_set_title (struct t_gui_buffer *buffer, char *new_title);
|
||||
extern void gui_buffer_set_nicklist (struct t_gui_buffer *buffer, int nicklist);
|
||||
extern void gui_buffer_set_title (struct t_gui_buffer *buffer,
|
||||
char *new_title);
|
||||
extern void gui_buffer_set_nicklist (struct t_gui_buffer *buffer,
|
||||
int nicklist);
|
||||
extern void gui_buffer_set_nicklist_case_sensitive (struct t_gui_buffer * buffer,
|
||||
int case_sensitive);
|
||||
extern void gui_buffer_set_nick (struct t_gui_buffer *buffer, char *new_nick);
|
||||
@@ -161,13 +163,14 @@ extern int gui_buffer_is_scrolled (struct t_gui_buffer *buffer);
|
||||
extern struct t_gui_buffer *gui_buffer_get_dcc (struct t_gui_window *window);
|
||||
extern void gui_buffer_clear (struct t_gui_buffer *buffer);
|
||||
extern void gui_buffer_clear_all ();
|
||||
extern void gui_buffer_close (struct t_gui_buffer *buffer, int switch_to_another);
|
||||
extern void gui_buffer_close (struct t_gui_buffer *buffer,
|
||||
int switch_to_another);
|
||||
extern void gui_buffer_switch_previous (struct t_gui_window *window);
|
||||
extern void gui_buffer_switch_next (struct t_gui_window *window);
|
||||
extern void gui_buffer_switch_dcc (struct t_gui_window *window);
|
||||
extern void gui_buffer_switch_raw_data (struct t_gui_window *window);
|
||||
extern struct t_gui_buffer *gui_buffer_switch_by_number (struct t_gui_window *window,
|
||||
int number);
|
||||
extern void gui_buffer_switch_by_number (struct t_gui_window *window,
|
||||
int number);
|
||||
extern void gui_buffer_move_to_number (struct t_gui_buffer *buffer, int number);
|
||||
extern void gui_buffer_dump_hexa (struct t_gui_buffer *buffer);
|
||||
extern void gui_buffer_print_log ();
|
||||
|
||||
Reference in New Issue
Block a user