1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-05 01:03:14 +02:00

core: remove unneeded whitespace

This commit is contained in:
Sebastien Helleu
2011-10-26 20:37:03 +02:00
parent 2a83aae85e
commit dfdf42e27b
176 changed files with 13151 additions and 13151 deletions
+1 -1
View File
@@ -47,7 +47,7 @@ IF(NCURSES_FOUND)
ADD_DEFINITIONS(-DHAVE_NCURSES_H)
ENDIF(NCURSES_HEADERS)
ENDIF(NCURSESW_HEADERS)
LIST(APPEND EXTRA_LIBS ${NCURSES_LIBRARY})
ENDIF(NCURSES_FOUND)
+38 -38
View File
@@ -52,7 +52,7 @@ int
gui_bar_window_objects_init (struct t_gui_bar_window *bar_window)
{
struct t_gui_bar_window_curses_objects *new_objects;
new_objects = malloc (sizeof (*new_objects));
if (new_objects)
{
@@ -92,7 +92,7 @@ gui_bar_window_create_win (struct t_gui_bar_window *bar_window)
{
if (CONFIG_BOOLEAN(bar_window->bar->options[GUI_BAR_OPTION_HIDDEN]))
return;
if (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar)
{
delwin (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar);
@@ -103,12 +103,12 @@ gui_bar_window_create_win (struct t_gui_bar_window *bar_window)
delwin (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_separator);
GUI_BAR_WINDOW_OBJECTS(bar_window)->win_separator = NULL;
}
GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar = newwin (bar_window->height,
bar_window->width,
bar_window->y,
bar_window->x);
if (CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_SEPARATOR]))
{
switch (CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_POSITION]))
@@ -161,7 +161,7 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
{
int x_with_hidden, size_on_screen, low_char, hidden;
char utf_char[16], *next_char, *output;
if (!string || !string[0])
return 1;
@@ -173,11 +173,11 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_FG]),
CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG]));
}
x_with_hidden = *x;
hidden = 0;
while (string && string[0])
{
switch (string[0])
@@ -317,10 +317,10 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
next_char = utf8_next_char (string);
if (!next_char)
break;
memcpy (utf_char, string, next_char - string);
utf_char[next_char - string] = '\0';
if ((((unsigned char)utf_char[0]) < 32) && (!utf_char[1]))
{
low_char = 1;
@@ -333,7 +333,7 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
if (!gui_chat_utf_char_valid (utf_char))
snprintf (utf_char, sizeof (utf_char), " ");
}
size_on_screen = utf8_char_size_screen (utf_char);
if (size_on_screen > 0)
{
@@ -355,7 +355,7 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
(*y)++;
wmove (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, *y, *x);
}
output = string_iconv_from_internal (NULL, utf_char);
if (low_char)
wattron (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, A_REVERSE);
@@ -365,7 +365,7 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
wattroff (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, A_REVERSE);
if (output)
free (output);
*x += size_on_screen;
}
}
@@ -399,10 +399,10 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
int diff, max_length, optimal_number_of_lines;
int some_data_not_displayed, separator_horizontal, separator_vertical;
int index_item, index_subitem, index_line;
if (!gui_init_ok)
return;
if (!str_start_input[0])
{
snprintf (str_start_input, sizeof (str_start_input), "%c%c%c",
@@ -410,34 +410,34 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
GUI_COLOR_BAR_CHAR,
GUI_COLOR_BAR_START_INPUT_CHAR);
length_start_input = strlen (str_start_input);
snprintf (str_start_input_hidden, sizeof (str_start_input_hidden), "%c%c%c",
GUI_COLOR_COLOR_CHAR,
GUI_COLOR_BAR_CHAR,
GUI_COLOR_BAR_START_INPUT_HIDDEN_CHAR);
length_start_input_hidden = strlen (str_start_input_hidden);
snprintf (str_cursor, sizeof (str_cursor), "%c%c%c",
GUI_COLOR_COLOR_CHAR,
GUI_COLOR_BAR_CHAR,
GUI_COLOR_BAR_MOVE_CURSOR_CHAR);
}
/*
* these values will be overwritten later (by gui_bar_window_print_string)
* if cursor has to move somewhere in bar window
*/
bar_window->cursor_x = -1;
bar_window->cursor_y = -1;
/* remove coords */
gui_bar_window_coords_free (bar_window);
index_item = -1;
index_subitem = -1;
index_line = 0;
filling = gui_bar_get_filling (bar_window->bar);
content = gui_bar_window_content_get_with_filling (bar_window, window);
if (content)
{
@@ -452,7 +452,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
bar_window->scroll_x = 0;
}
}
items = string_split (content, "\n", 0, 0, &items_count);
if (items_count == 0)
{
@@ -473,14 +473,14 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
for (line = 0; line < items_count; line++)
{
length_on_screen = gui_chat_strlen_screen (items[line]);
pos_cursor = strstr (items[line], str_cursor);
if (pos_cursor && (gui_chat_strlen_screen (pos_cursor) == 0))
length_on_screen++;
if (length_on_screen > max_length)
max_length = length_on_screen;
if (length_on_screen % bar_window->width == 0)
num_lines = length_on_screen / bar_window->width;
else
@@ -491,7 +491,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
}
if (max_length == 0)
max_length = 1;
switch (CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_POSITION]))
{
case GUI_BAR_POSITION_BOTTOM:
@@ -512,7 +512,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
break;
}
}
gui_window_clear (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar,
CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_FG]),
CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG]));
@@ -540,7 +540,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
chars_available =
((bar_window->height - y - 1) * bar_window->width) + /* next lines */
(bar_window->width - x - 1); /* chars on current line */
length_screen_before_cursor = -1;
length_screen_after_cursor = -1;
@@ -551,13 +551,13 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
length_screen_after_cursor = gui_chat_strlen_screen (pos_cursor);
free (buf);
}
if ((length_screen_before_cursor < 0) || (length_screen_after_cursor < 0))
{
length_screen_before_cursor = gui_chat_strlen_screen (items[line]);
length_screen_after_cursor = 0;
}
diff = length_screen_before_cursor - chars_available;
if (diff > 0)
{
@@ -567,12 +567,12 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
- 1
- (diff % CONFIG_INTEGER(config_look_input_cursor_scroll)));
}
/* compute new start for displaying input */
new_start_input = pos_after_start_input + gui_chat_string_real_pos (pos_after_start_input, diff);
if (new_start_input > pos_cursor)
new_start_input = pos_cursor;
buf = malloc (strlen (items[line]) + length_start_input_hidden + 1);
if (buf)
{
@@ -597,7 +597,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
/* add input (will be displayed) */
size = strlen (new_start_input) + 1;
memmove (buf + index, new_start_input, size);
free (items[line]);
items[line] = buf;
}
@@ -605,7 +605,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
}
}
if ((bar_window->scroll_y == 0)
|| (line >= bar_window->scroll_y))
{
@@ -618,7 +618,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
{
some_data_not_displayed = 1;
}
if (x < bar_window->width)
{
if (filling == GUI_BAR_FILLING_HORIZONTAL)
@@ -644,7 +644,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
&index_line);
}
}
x = 0;
y++;
}
@@ -706,7 +706,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_FG]),
CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG]));
}
/*
* move cursor if it was asked in an item content (input_text does that
* to move cursor in user input text)
@@ -729,7 +729,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
}
else
wnoutrefresh (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar);
if (CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_SEPARATOR]))
{
separator_horizontal = ACS_HLINE;
@@ -779,7 +779,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window,
}
wnoutrefresh (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_separator);
}
refresh ();
}
+98 -98
View File
@@ -67,22 +67,22 @@ int
gui_chat_marker_for_line (struct t_gui_buffer *buffer, struct t_gui_line *line)
{
struct t_gui_line *last_read_line;
/* marker is disabled in config? */
if (CONFIG_INTEGER(config_look_read_marker) != CONFIG_LOOK_READ_MARKER_LINE)
return 0;
/* marker is not set for buffer? */
if (!buffer->lines->last_read_line)
return 0;
last_read_line = buffer->lines->last_read_line;
if (!last_read_line->data->displayed)
last_read_line = gui_line_get_prev_displayed (last_read_line);
if (!last_read_line)
return 0;
while (line)
{
if (last_read_line == line)
@@ -91,10 +91,10 @@ gui_chat_marker_for_line (struct t_gui_buffer *buffer, struct t_gui_line *line)
return 1;
return (gui_line_get_next_displayed (line) != NULL) ? 1 : 0;
}
if (line->data->displayed)
break;
line = line->next_line;
}
return 0;
@@ -112,7 +112,7 @@ gui_chat_reset_style (struct t_gui_window *window, struct t_gui_line *line,
int color_default)
{
int color;
color = color_default;
if ((window != gui_current_window) &&
CONFIG_BOOLEAN(config_look_color_inactive_window))
@@ -124,7 +124,7 @@ gui_chat_reset_style (struct t_gui_window *window, struct t_gui_line *line,
{
color = color_inactive_buffer;
}
if (reset_attributes)
gui_window_reset_style (GUI_WINDOW_OBJECTS(window)->win_chat, color);
else
@@ -166,7 +166,7 @@ gui_chat_display_horizontal_line (struct t_gui_window *window, int simulate)
{
int x, size_on_screen;
char *read_marker_string, *default_string = "- ";
if (!simulate)
{
gui_window_coords_init_line (window, window->win_chat_cursor_y);
@@ -218,7 +218,7 @@ gui_chat_string_next_char (struct t_gui_window *window, struct t_gui_line *line,
apply_style = 0;
}
}
while (string[0])
{
switch (string[0])
@@ -320,7 +320,7 @@ gui_chat_string_next_char (struct t_gui_window *window, struct t_gui_line *line,
break;
}
}
/* nothing found except color/attrib codes, so return NULL */
return NULL;
}
@@ -339,17 +339,17 @@ gui_chat_display_word_raw (struct t_gui_window *window, struct t_gui_line *line,
{
char *next_char, *output, utf_char[16];
int x, chars_displayed, display_char, size_on_screen;
if (display)
{
wmove (GUI_WINDOW_OBJECTS(window)->win_chat,
window->win_chat_cursor_y,
window->win_chat_cursor_x);
}
chars_displayed = 0;
x = window->win_chat_cursor_x;
while (string && string[0])
{
string = gui_chat_string_next_char (window, line,
@@ -357,7 +357,7 @@ gui_chat_display_word_raw (struct t_gui_window *window, struct t_gui_line *line,
apply_style_inactive);
if (!string)
return chars_displayed;
next_char = utf8_next_char (string);
if (display && next_char)
{
@@ -365,10 +365,10 @@ gui_chat_display_word_raw (struct t_gui_window *window, struct t_gui_line *line,
utf_char[next_char - string] = '\0';
if (!gui_chat_utf_char_valid (utf_char))
snprintf (utf_char, sizeof (utf_char), " ");
display_char = (window->buffer->type != GUI_BUFFER_TYPE_FREE)
|| (x >= window->scroll->start_col);
size_on_screen = utf8_strlen_screen (utf_char);
if ((max_chars_on_screen > 0)
&& (chars_displayed + size_on_screen > max_chars_on_screen))
@@ -386,10 +386,10 @@ gui_chat_display_word_raw (struct t_gui_window *window, struct t_gui_line *line,
}
x += size_on_screen;
}
string = next_char;
}
return chars_displayed;
}
@@ -412,25 +412,25 @@ gui_chat_display_word (struct t_gui_window *window,
attr_t *ptr_attrs;
short pair;
short *ptr_pair;
if (!word ||
((!simulate) && (window->win_chat_cursor_y >= window->win_chat_height)))
return;
if (!simulate && (window->win_chat_cursor_y < window->coords_size))
window->coords[window->win_chat_cursor_y].line = line;
data = strdup (word);
if (!data)
return;
end_line = data + strlen (data);
if (word_end && word_end[0])
data[word_end - word] = '\0';
else
word_end = NULL;
ptr_data = data;
while (ptr_data && ptr_data[0])
{
@@ -483,7 +483,7 @@ gui_chat_display_word (struct t_gui_window *window,
if (window->win_chat_cursor_y < window->coords_size)
window->coords[window->win_chat_cursor_y].data = (char *)word + (ptr_data - data);
}
chars_to_display = gui_chat_strlen_screen (ptr_data);
/* too long for current line */
@@ -527,9 +527,9 @@ gui_chat_display_word (struct t_gui_window *window,
}
ptr_data += strlen (ptr_data);
}
window->win_chat_cursor_x += num_displayed;
/* display new line? */
if ((!prefix && (ptr_data >= end_line)) ||
(((simulate) ||
@@ -537,12 +537,12 @@ gui_chat_display_word (struct t_gui_window *window,
(window->win_chat_cursor_x > (gui_chat_get_real_width (window) - 1))))
gui_chat_display_new_line (window, num_lines, count,
lines_displayed, simulate);
if ((!prefix && (ptr_data >= end_line)) ||
((!simulate) && (window->win_chat_cursor_y >= window->win_chat_height)))
ptr_data = NULL;
}
free (data);
}
@@ -563,7 +563,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
const char *short_name;
int i, length, length_allowed, num_spaces;
struct t_gui_lines *mixed_lines;
if (!simulate)
{
if (window->win_chat_cursor_y < window->coords_size)
@@ -573,7 +573,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
GUI_COLOR_CHAT_INACTIVE_BUFFER,
GUI_COLOR_CHAT);
}
/* display time */
if (window->buffer->time_for_each_line
&& (line->data->str_time && line->data->str_time[0]))
@@ -586,7 +586,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
CONFIG_BOOLEAN(config_look_color_inactive_time));
if (window->win_chat_cursor_y < window->coords_size)
window->coords[window->win_chat_cursor_y].time_x2 = window->win_chat_cursor_x - 1;
if (!simulate)
{
gui_chat_reset_style (window, line, 1,
@@ -599,7 +599,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
simulate,
CONFIG_BOOLEAN(config_look_color_inactive_time));
}
/* display buffer name (if many buffers are merged) */
mixed_lines = line->data->buffer->mixed_lines;
if (mixed_lines)
@@ -617,7 +617,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
short_name = gui_buffer_get_short_name (line->data->buffer);
length = gui_chat_strlen_screen (short_name);
num_spaces = length_allowed - length;
if (CONFIG_INTEGER(config_look_prefix_buffer_align) == CONFIG_LOOK_PREFIX_BUFFER_ALIGN_RIGHT)
{
if (!simulate)
@@ -635,7 +635,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
CONFIG_BOOLEAN(config_look_color_inactive_prefix_buffer));
}
}
if (!simulate)
{
gui_chat_reset_style (window, line, 1,
@@ -647,10 +647,10 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
GUI_COLOR_CHAT_PREFIX_BUFFER,
GUI_COLOR_CHAT_PREFIX_BUFFER);
}
if (window->win_chat_cursor_y < window->coords_size)
window->coords[window->win_chat_cursor_y].buffer_x1 = window->win_chat_cursor_x;
/* not enough space to display full buffer name? => truncate it! */
if ((CONFIG_INTEGER(config_look_prefix_buffer_align) != CONFIG_LOOK_PREFIX_BUFFER_ALIGN_NONE)
&& (num_spaces < 0))
@@ -671,10 +671,10 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
lines_displayed, simulate,
CONFIG_BOOLEAN(config_look_color_inactive_prefix_buffer));
}
if (window->win_chat_cursor_y < window->coords_size)
window->coords[window->win_chat_cursor_y].buffer_x2 = window->win_chat_cursor_x - 1;
if ((CONFIG_INTEGER(config_look_prefix_buffer_align) != CONFIG_LOOK_PREFIX_BUFFER_ALIGN_NONE)
&& (num_spaces < 0))
{
@@ -720,7 +720,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
}
}
}
/* display prefix */
if (line->data->prefix
&& (line->data->prefix[0]
@@ -733,7 +733,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
GUI_COLOR_CHAT_INACTIVE_BUFFER,
GUI_COLOR_CHAT);
}
if (CONFIG_INTEGER(config_look_prefix_align_max) > 0)
{
length_allowed =
@@ -742,9 +742,9 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
}
else
length_allowed = window->buffer->lines->prefix_max_length;
num_spaces = length_allowed - line->data->prefix_length;
if (CONFIG_INTEGER(config_look_prefix_align) == CONFIG_LOOK_PREFIX_ALIGN_RIGHT)
{
for (i = 0; i < num_spaces; i++)
@@ -755,7 +755,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
CONFIG_BOOLEAN(config_look_color_inactive_prefix));
}
}
prefix_highlighted = NULL;
if (line->data->highlight)
{
@@ -798,10 +798,10 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
GUI_COLOR_CHAT);
}
}
if (window->win_chat_cursor_y < window->coords_size)
window->coords[window->win_chat_cursor_y].prefix_x1 = window->win_chat_cursor_x;
/* not enough space to display full prefix? => truncate it! */
if ((CONFIG_INTEGER(config_look_prefix_align) != CONFIG_LOOK_PREFIX_ALIGN_NONE)
&& (num_spaces < 0))
@@ -825,13 +825,13 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
simulate,
CONFIG_BOOLEAN(config_look_color_inactive_prefix));
}
if (window->win_chat_cursor_y < window->coords_size)
window->coords[window->win_chat_cursor_y].prefix_x2 = window->win_chat_cursor_x - 1;
if (prefix_highlighted)
free (prefix_highlighted);
if (!simulate)
{
gui_chat_reset_style (window, line, 1,
@@ -839,7 +839,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
GUI_COLOR_CHAT_INACTIVE_BUFFER,
GUI_COLOR_CHAT);
}
if (CONFIG_INTEGER(config_look_prefix_align) == CONFIG_LOOK_PREFIX_ALIGN_LEFT)
{
for (i = 0; i < num_spaces; i++)
@@ -916,10 +916,10 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
int word_length_with_spaces, word_length;
char *ptr_data, *ptr_end_offset, *next_char;
char *ptr_style, *message_with_tags;
if (!line)
return 0;
if (simulate)
{
x = window->win_chat_cursor_x;
@@ -938,18 +938,18 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
window->win_chat_cursor_x = x;
window->win_chat_cursor_y = y;
}
/* calculate marker position (maybe not used for this line!) */
if (window->buffer->time_for_each_line && line->data->str_time)
read_marker_x = x + gui_chat_strlen_screen (line->data->str_time);
else
read_marker_x = x;
read_marker_y = y;
lines_displayed = 0;
marker_line = gui_chat_marker_for_line (window->buffer, line);
/* display time and prefix */
gui_chat_display_time_to_prefix (window, line, num_lines, count,
&lines_displayed, simulate);
@@ -959,7 +959,7 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
window->coords[window->win_chat_cursor_y].data = line->data->message;
window->coords_x_message = window->win_chat_cursor_x;
}
/* reset color & style for a new line */
if (!simulate)
{
@@ -978,7 +978,7 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
GUI_COLOR_CHAT);
}
}
if (!line->data->message || !line->data->message[0])
{
gui_chat_display_new_line (window, num_lines, count,
@@ -997,9 +997,9 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
&word_start_offset,
&word_end_offset,
&word_length_with_spaces, &word_length);
ptr_end_offset = ptr_data + word_end_offset;
if (word_length > 0)
{
/* spaces + word too long for current line but ok for next line */
@@ -1029,14 +1029,14 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
/* jump to start of word */
ptr_data += word_start_offset;
}
/* display word */
gui_chat_display_word (window, line, ptr_data,
ptr_end_offset + 1,
0, num_lines, count, &lines_displayed,
simulate,
CONFIG_BOOLEAN(config_look_color_inactive_message));
if ((!simulate) && (window->win_chat_cursor_y >= window->win_chat_height))
ptr_data = NULL;
else
@@ -1045,7 +1045,7 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
ptr_data = ptr_end_offset + 1;
if (*(ptr_data - 1) == '\0')
ptr_data = NULL;
if (window->win_chat_cursor_x == 0)
{
while (ptr_data && (ptr_data[0] == ' '))
@@ -1071,14 +1071,14 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
if (message_with_tags)
free (message_with_tags);
}
if (marker_line)
{
gui_chat_display_horizontal_line (window, simulate);
gui_chat_display_new_line (window, num_lines, count,
&lines_displayed, simulate);
}
if (simulate)
{
window->win_chat_cursor_x = x;
@@ -1114,7 +1114,7 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
}
}
}
return lines_displayed;
}
@@ -1132,15 +1132,15 @@ gui_chat_display_line_y (struct t_gui_window *window, struct t_gui_line *line,
GUI_COLOR_CHAT_INACTIVE_WINDOW,
GUI_COLOR_CHAT_INACTIVE_BUFFER,
GUI_COLOR_CHAT);
window->win_chat_cursor_x = 0;
window->win_chat_cursor_y = y;
wmove (GUI_WINDOW_OBJECTS(window)->win_chat,
window->win_chat_cursor_y,
window->win_chat_cursor_x);
wclrtoeol (GUI_WINDOW_OBJECTS(window)->win_chat);
if (gui_chat_display_word_raw (window, line, line->data->message,
window->win_chat_width, 1,
CONFIG_BOOLEAN(config_look_color_inactive_message)) < window->win_chat_width)
@@ -1160,12 +1160,12 @@ gui_chat_calculate_line_diff (struct t_gui_window *window,
int difference)
{
int backward, current_size;
if (!line || !line_pos)
return;
backward = (difference < 0);
if (!(*line))
{
/* if looking backward, start at last line of buffer */
@@ -1191,7 +1191,7 @@ gui_chat_calculate_line_diff (struct t_gui_window *window,
}
else
current_size = gui_chat_display_line (window, *line, 0, 1);
while ((*line) && (difference != 0))
{
/* looking backward */
@@ -1231,7 +1231,7 @@ gui_chat_calculate_line_diff (struct t_gui_window *window,
difference--;
}
}
/* first or last line reached */
if (!(*line))
{
@@ -1261,21 +1261,21 @@ gui_chat_draw (struct t_gui_buffer *buffer, int erase)
char format_empty[32];
int i, line_pos, count, old_scrolling, old_lines_after;
int y_start, y_end, y;
if (!gui_ok)
return;
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
if (ptr_win->buffer->number == buffer->number)
{
gui_window_coords_alloc (ptr_win);
gui_chat_reset_style (ptr_win, NULL, 1,
GUI_COLOR_CHAT_INACTIVE_WINDOW,
GUI_COLOR_CHAT_INACTIVE_BUFFER,
GUI_COLOR_CHAT);
if (erase)
{
snprintf (format_empty, 32, "%%-%ds", ptr_win->win_chat_width);
@@ -1285,10 +1285,10 @@ gui_chat_draw (struct t_gui_buffer *buffer, int erase)
format_empty, " ");
}
}
ptr_win->win_chat_cursor_x = 0;
ptr_win->win_chat_cursor_y = 0;
switch (ptr_win->buffer->type)
{
case GUI_BUFFER_TYPE_FORMATTED:
@@ -1306,9 +1306,9 @@ gui_chat_draw (struct t_gui_buffer *buffer, int erase)
gui_chat_calculate_line_diff (ptr_win, &ptr_line, &line_pos,
(-1) * (ptr_win->win_chat_height - 1));
}
count = 0;
if (line_pos > 0)
{
/* display end of first line at top of screen */
@@ -1323,19 +1323,19 @@ gui_chat_draw (struct t_gui_buffer *buffer, int erase)
else
ptr_win->scroll->first_line_displayed =
(ptr_line == gui_line_get_first_displayed (ptr_win->buffer));
/* display lines */
while (ptr_line && (ptr_win->win_chat_cursor_y <= ptr_win->win_chat_height - 1))
{
count = gui_chat_display_line (ptr_win, ptr_line, 0, 0);
ptr_line = gui_line_get_next_displayed (ptr_line);
}
old_scrolling = ptr_win->scroll->scrolling;
old_lines_after = ptr_win->scroll->lines_after;
ptr_win->scroll->scrolling = (ptr_win->win_chat_cursor_y > ptr_win->win_chat_height - 1);
/* check if last line of buffer is entirely displayed and scrolling */
/* if so, disable scroll indicator */
if (!ptr_line && ptr_win->scroll->scrolling)
@@ -1344,14 +1344,14 @@ gui_chat_draw (struct t_gui_buffer *buffer, int erase)
|| (count == ptr_win->win_chat_height))
ptr_win->scroll->scrolling = 0;
}
if (!ptr_win->scroll->scrolling
&& (ptr_win->scroll->start_line == gui_line_get_first_displayed (ptr_win->buffer)))
{
ptr_win->scroll->start_line = NULL;
ptr_win->scroll->start_line_pos = 0;
}
ptr_win->scroll->lines_after = 0;
if (ptr_win->scroll->scrolling && ptr_line)
{
@@ -1364,30 +1364,30 @@ gui_chat_draw (struct t_gui_buffer *buffer, int erase)
}
ptr_win->scroll->lines_after++;
}
if ((ptr_win->scroll->scrolling != old_scrolling)
|| (ptr_win->scroll->lines_after != old_lines_after))
{
hook_signal_send ("window_scrolled",
WEECHAT_HOOK_SIGNAL_POINTER, ptr_win);
}
if (!ptr_win->scroll->scrolling
&& ptr_win->scroll->reset_allowed)
{
ptr_win->scroll->start_line = NULL;
ptr_win->scroll->start_line_pos = 0;
}
/* cursor is below end line of chat window? */
if (ptr_win->win_chat_cursor_y > ptr_win->win_chat_height - 1)
{
ptr_win->win_chat_cursor_x = 0;
ptr_win->win_chat_cursor_y = ptr_win->win_chat_height - 1;
}
ptr_win->scroll->reset_allowed = 0;
break;
case GUI_BUFFER_TYPE_FREE:
/* display at position of scrolling */
@@ -1425,9 +1425,9 @@ gui_chat_draw (struct t_gui_buffer *buffer, int erase)
wnoutrefresh (GUI_WINDOW_OBJECTS(ptr_win)->win_chat);
}
}
refresh ();
if (buffer->type == GUI_BUFFER_TYPE_FREE)
{
for (ptr_line = buffer->lines->first_line; ptr_line;
@@ -1436,7 +1436,7 @@ gui_chat_draw (struct t_gui_buffer *buffer, int erase)
ptr_line->data->refresh_needed = 0;
}
}
buffer->chat_refresh_needed = 0;
}
+84 -84
View File
@@ -144,7 +144,7 @@ gui_color_assign (int *color, const char *color_name)
{
int flag, extra_attr, color_index, number;
char *error;
/* read extended attributes */
extra_attr = 0;
while ((flag = gui_color_attr_get_flag (color_name[0])) > 0)
@@ -152,7 +152,7 @@ gui_color_assign (int *color, const char *color_name)
extra_attr |= flag;
color_name++;
}
/* is it a color alias? */
number = gui_color_palette_get_alias (color_name);
if (number >= 0)
@@ -160,7 +160,7 @@ gui_color_assign (int *color, const char *color_name)
*color = number | GUI_COLOR_EXTENDED_FLAG | extra_attr;
return 1;
}
/* is it a color number? */
error = NULL;
number = (int)strtol (color_name, &error, 10);
@@ -182,7 +182,7 @@ gui_color_assign (int *color, const char *color_name)
return 1;
}
}
/* color not found */
return 0;
}
@@ -202,15 +202,15 @@ gui_color_assign_by_diff (int *color, const char *color_name, int diff)
int index, list_size;
struct t_weelist_item *ptr_item;
const char *name;
index = weelist_search_pos (gui_color_list_with_alias, color_name);
if (index < 0)
index = 0;
list_size = weelist_size (gui_color_list_with_alias);
diff = diff % (list_size + 1);
if (diff > 0)
{
index = (index + diff) % (list_size + 1);
@@ -227,14 +227,14 @@ gui_color_assign_by_diff (int *color, const char *color_name, int diff)
index += list_size;
}
}
ptr_item = weelist_get (gui_color_list_with_alias, index);
if (!ptr_item)
return 0;
name = weelist_string (ptr_item);
if (name)
return gui_color_assign (color, name);
return 0;
}
@@ -269,26 +269,26 @@ void
gui_color_get_pairs_arrays (short **foregrounds, short **backgrounds)
{
int i, fg, bg, index;
if (!foregrounds || !backgrounds)
return;
*foregrounds = NULL;
*backgrounds = NULL;
*foregrounds = malloc (sizeof (*foregrounds[0]) * (gui_color_num_pairs + 1));
if (!*foregrounds)
goto error;
*backgrounds = malloc (sizeof (*backgrounds[0]) * (gui_color_num_pairs + 1));
if (!*backgrounds)
goto error;
for (i = 0; i <= gui_color_num_pairs; i++)
{
(*foregrounds)[i] = -2;
(*backgrounds)[i] = -2;
}
for (bg = -1; bg <= gui_color_term_colors; bg++)
{
for (fg = -1; fg <= gui_color_term_colors; fg++)
@@ -302,7 +302,7 @@ gui_color_get_pairs_arrays (short **foregrounds, short **backgrounds)
}
}
}
return;
error:
@@ -329,12 +329,12 @@ gui_color_timer_warning_pairs_full (void *data, int remaining_calls)
/* make C compiler happy */
(void) data;
(void) remaining_calls;
gui_chat_printf (NULL,
_("Warning: the %d color pairs are used, do "
"\"/color reset\" to remove unused pairs"),
gui_color_num_pairs);
return WEECHAT_RC_OK;
}
@@ -348,20 +348,20 @@ int
gui_color_get_pair (int fg, int bg)
{
int index;
/* only one color when displaying terminal colors */
if (gui_color_use_term_colors)
return COLOR_WHITE;
/* if invalid color, use default fg/bg */
if (fg > gui_color_term_colors)
fg = -1;
if (bg > gui_color_term_colors)
bg = -1;
/* compute index for gui_color_pairs with foreground and background */
index = ((bg + 1) * (gui_color_term_colors + 2)) + (fg + 1);
/* pair not allocated for this fg/bg? */
if (gui_color_pairs[index] == 0)
{
@@ -378,7 +378,7 @@ gui_color_get_pair (int fg, int bg)
}
return 1;
}
/* create a new pair if no pair exists for this fg/bg */
gui_color_pairs_used++;
gui_color_pairs[index] = gui_color_pairs_used;
@@ -391,7 +391,7 @@ gui_color_get_pair (int fg, int bg)
}
gui_color_buffer_refresh_needed = 1;
}
return gui_color_pairs[index];
}
@@ -403,7 +403,7 @@ int
gui_color_weechat_get_pair (int weechat_color)
{
int fg, bg;
if ((weechat_color < 0) || (weechat_color > GUI_COLOR_NUM_COLORS - 1))
{
fg = -1;
@@ -413,13 +413,13 @@ gui_color_weechat_get_pair (int weechat_color)
{
fg = gui_color[weechat_color]->foreground;
bg = gui_color[weechat_color]->background;
if ((fg > 0) && (fg & GUI_COLOR_EXTENDED_FLAG))
fg &= GUI_COLOR_EXTENDED_MASK;
if ((bg > 0) && (bg & GUI_COLOR_EXTENDED_FLAG))
bg &= GUI_COLOR_EXTENDED_MASK;
}
return gui_color_get_pair (fg, bg);
}
@@ -434,14 +434,14 @@ gui_color_get_name (int num_color)
static int index_color = 0;
char str_attr[8];
struct t_gui_color_palette *ptr_color_palette;
/* init color string */
index_color = (index_color + 1) % 16;
color[index_color][0] = '\0';
/* build string with extra-attributes */
gui_color_attr_build_string (num_color, str_attr);
if (num_color & GUI_COLOR_EXTENDED_FLAG)
{
/* search alias */
@@ -466,7 +466,7 @@ gui_color_get_name (int num_color)
str_attr,
gui_weechat_colors[num_color & GUI_COLOR_EXTENDED_MASK].string);
}
return color[index_color];
}
@@ -484,7 +484,7 @@ gui_color_build (int number, int foreground, int background)
foreground = 0;
if (background < 0)
background = 0;
/* allocate color */
if (!gui_color[number])
{
@@ -493,7 +493,7 @@ gui_color_build (int number, int foreground, int background)
return;
gui_color[number]->string = malloc (4);
}
/* set foreground and attributes */
if (foreground & GUI_COLOR_EXTENDED_FLAG)
{
@@ -511,13 +511,13 @@ gui_color_build (int number, int foreground, int background)
gui_color[number]->attributes |= A_REVERSE;
if (foreground & GUI_COLOR_EXTENDED_UNDERLINE_FLAG)
gui_color[number]->attributes |= A_UNDERLINE;
/* set background */
if (background & GUI_COLOR_EXTENDED_FLAG)
gui_color[number]->background = background & GUI_COLOR_EXTENDED_MASK;
else
gui_color[number]->background = gui_weechat_colors[background & GUI_COLOR_EXTENDED_MASK].background;
/* set string */
if (gui_color[number]->string)
{
@@ -535,7 +535,7 @@ void
gui_color_init_vars ()
{
int size;
gui_color_term_has_colors = (has_colors ()) ? 1 : 0;
gui_color_term_colors = 0;
gui_color_term_color_pairs = 0;
@@ -547,13 +547,13 @@ gui_color_init_vars ()
gui_color_pairs = NULL;
}
gui_color_pairs_used = 0;
if (gui_color_term_has_colors)
{
gui_color_term_colors = COLORS;
gui_color_term_color_pairs = COLOR_PAIRS;
gui_color_term_can_change_color = (can_change_color ()) ? 1 : 0;
gui_color_num_pairs = (gui_color_term_color_pairs >= 256) ?
255 : gui_color_term_color_pairs - 1;
size = (gui_color_term_colors + 2)
@@ -563,7 +563,7 @@ gui_color_init_vars ()
if (gui_color_pairs)
memset (gui_color_pairs, 0, size);
gui_color_pairs_used = 0;
/* reserved for future usage */
/*
gui_color_term_color_content = malloc (sizeof (gui_color_term_color_content[0]) *
@@ -621,7 +621,7 @@ void
gui_color_init_pairs_terminal ()
{
int i;
if (gui_color_term_has_colors)
{
for (i = 1; i <= gui_color_num_pairs; i++)
@@ -644,7 +644,7 @@ gui_color_init_pairs_weechat ()
{
int i;
short *foregrounds, *backgrounds;
if (gui_color_term_has_colors)
{
gui_color_get_pairs_arrays (&foregrounds, &backgrounds);
@@ -676,7 +676,7 @@ gui_color_display_terminal_colors ()
{
int lines, line, col, color;
char str_line[1024], str_color[64];
initscr ();
if (has_colors ())
{
@@ -754,12 +754,12 @@ gui_color_buffer_display ()
int y, i, lines, line, col, color, max_color, num_items;
char str_line[1024], str_color[64], str_rgb[64], **items;
struct t_gui_color_palette *color_palette;
if (!gui_color_buffer)
return;
gui_buffer_clear (gui_color_buffer);
/* set title buffer */
gui_buffer_set_title (gui_color_buffer,
_("WeeChat colors | Actions: "
@@ -767,7 +767,7 @@ gui_color_buffer_display ()
"[z] Reset colors [q] Close buffer | "
"Keys: [alt-c] Temporarily switch to terminal "
"colors"));
/* display terminal/colors infos */
y = 0;
gui_chat_printf_y (gui_color_buffer, y++,
@@ -777,7 +777,7 @@ gui_color_buffer_display ()
gui_color_term_colors,
gui_color_term_color_pairs,
(gui_color_term_can_change_color) ? "yes" : "no");
/* display palette of colors */
y++;
if (gui_color_use_term_colors)
@@ -851,7 +851,7 @@ gui_color_buffer_display ()
_("Last auto reset of pairs: %s"),
(gui_color_pairs_auto_reset_last == 0) ?
"-" : ctime (&gui_color_pairs_auto_reset_last));
/* display WeeChat basic colors */
y++;
gui_chat_printf_y (gui_color_buffer, y++,
@@ -887,7 +887,7 @@ gui_color_buffer_display ()
gui_chat_printf_y (gui_color_buffer, y++,
" %s", str_line);
}
/* display nick colors */
y++;
gui_chat_printf_y (gui_color_buffer, y++,
@@ -927,7 +927,7 @@ gui_color_buffer_display ()
}
string_free_split (items);
}
/* display palette colors */
if (hashtable_get_integer (gui_color_hash_palette_color,
"items_count") > 0)
@@ -969,7 +969,7 @@ gui_color_buffer_display ()
}
}
}
/* display content of colors */
if (gui_color_term_color_content)
{
@@ -999,9 +999,9 @@ gui_color_timer_cb (void *data, int remaining_calls)
/* make C compiler happy */
(void) data;
(void) remaining_calls;
gui_color_timer--;
if (gui_color_timer <= 0)
{
if (gui_color_use_term_colors)
@@ -1014,7 +1014,7 @@ gui_color_timer_cb (void *data, int remaining_calls)
gui_color_buffer_display_timer ();
}
}
return WEECHAT_RC_OK;
}
@@ -1030,7 +1030,7 @@ gui_color_switch_colors ()
unhook (gui_color_hook_timer);
gui_color_hook_timer = NULL;
}
/*
* when we press alt-c many times quickly, this just adds some time for
* display of terminal colors
@@ -1045,19 +1045,19 @@ gui_color_switch_colors ()
else
{
gui_color_use_term_colors ^= 1;
if (gui_color_use_term_colors)
gui_color_init_pairs_terminal ();
else
gui_color_init_pairs_weechat ();
gui_color_buffer_refresh_needed = 1;
gui_window_ask_refresh (1);
if (gui_color_use_term_colors)
gui_color_timer = GUI_COLOR_TIMER_TERM_COLORS;
}
if (gui_color_use_term_colors)
{
gui_color_hook_timer = hook_timer (NULL, 1000, 0, 0,
@@ -1116,7 +1116,7 @@ gui_color_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
{
gui_color_reset_pairs ();
}
return WEECHAT_RC_OK;
}
@@ -1130,9 +1130,9 @@ gui_color_buffer_close_cb (void *data, struct t_gui_buffer *buffer)
/* make C compiler happy */
(void) data;
(void) buffer;
gui_color_buffer = NULL;
return WEECHAT_RC_OK;
}
@@ -1175,12 +1175,12 @@ gui_color_buffer_open ()
gui_buffer_set (gui_color_buffer, "key_bind_meta-c", "/color switch");
}
}
if (!gui_color_buffer)
return;
gui_window_switch_to_buffer (gui_current_window, gui_color_buffer, 1);
gui_color_buffer_display ();
}
@@ -1196,13 +1196,13 @@ gui_color_palette_add_alias_cb (void *data,
struct t_gui_color_palette *color_palette;
char *error;
int number;
/* make C compiler happy */
(void) data;
(void) hashtable;
color_palette = (struct t_gui_color_palette *)value;
if (color_palette && color_palette->alias)
{
error = NULL;
@@ -1226,13 +1226,13 @@ gui_color_palette_build_aliases ()
int i;
struct t_gui_color_palette *color_palette;
char str_number[64];
if (!gui_color_hash_palette_alias || !gui_color_list_with_alias
|| !gui_color_hash_palette_color)
{
gui_color_palette_alloc_structs ();
}
hashtable_remove_all (gui_color_hash_palette_alias);
weelist_remove_all (gui_color_list_with_alias);
for (i = 0; i < GUI_CURSES_NUM_WEECHAT_COLORS; i++)
@@ -1277,10 +1277,10 @@ gui_color_palette_new (int number, const char *value)
char **items, *pos, *pos2, *error1, *error2, *error3;
char *str_alias, *str_rgb, str_number[64];
int num_items, i, r, g, b;
if (!value)
return NULL;
new_color_palette = malloc (sizeof (*new_color_palette));
if (new_color_palette)
{
@@ -1288,10 +1288,10 @@ gui_color_palette_new (int number, const char *value)
new_color_palette->r = -1;
new_color_palette->g = -1;
new_color_palette->b = -1;
str_alias = NULL;
str_rgb = NULL;
items = string_split (value, ";", 0, 0, &num_items);
if (items)
{
@@ -1307,12 +1307,12 @@ gui_color_palette_new (int number, const char *value)
str_alias = items[i];
}
}
if (str_alias)
{
new_color_palette->alias = strdup (str_alias);
}
if (str_rgb)
{
pos = strchr (str_rgb, '/');
@@ -1350,7 +1350,7 @@ gui_color_palette_new (int number, const char *value)
new_color_palette->alias = strdup (str_number);
}
}
return new_color_palette;
}
@@ -1363,10 +1363,10 @@ gui_color_palette_free (struct t_gui_color_palette *color_palette)
{
if (!color_palette)
return;
if (color_palette->alias)
free (color_palette->alias);
free (color_palette);
}
@@ -1386,9 +1386,9 @@ gui_color_init_weechat ()
{
gui_weechat_colors = gui_weechat_colors_no_bold;
}
gui_color_build (GUI_COLOR_SEPARATOR, CONFIG_COLOR(config_color_separator), CONFIG_COLOR(config_color_chat_bg));
gui_color_build (GUI_COLOR_CHAT, CONFIG_COLOR(config_color_chat), CONFIG_COLOR(config_color_chat_bg));
gui_color_build (GUI_COLOR_CHAT_TIME, CONFIG_COLOR(config_color_chat_time), CONFIG_COLOR(config_color_chat_bg));
gui_color_build (GUI_COLOR_CHAT_TIME_DELIMITERS, CONFIG_COLOR(config_color_chat_time_delimiters), CONFIG_COLOR(config_color_chat_bg));
@@ -1416,7 +1416,7 @@ gui_color_init_weechat ()
gui_color_build (GUI_COLOR_CHAT_INACTIVE_WINDOW, CONFIG_COLOR(config_color_chat_inactive_window), CONFIG_COLOR(config_color_chat_bg));
gui_color_build (GUI_COLOR_CHAT_INACTIVE_BUFFER, CONFIG_COLOR(config_color_chat_inactive_buffer), CONFIG_COLOR(config_color_chat_bg));
gui_color_build (GUI_COLOR_CHAT_PREFIX_BUFFER_INACTIVE_BUFFER, CONFIG_COLOR(config_color_chat_prefix_buffer_inactive_buffer), CONFIG_COLOR(config_color_chat_bg));
/*
* define old nick colors for compatibility on /upgrade with previous
* versions: these colors have been removed in version 0.3.4 and replaced
@@ -1443,7 +1443,7 @@ void
gui_color_pre_init ()
{
int i;
for (i = 0; i < GUI_COLOR_NUM_COLORS; i++)
{
gui_color[i] = NULL;
@@ -1476,7 +1476,7 @@ void
gui_color_dump ()
{
int fg, bg, index, used;
gui_chat_printf (NULL, "");
gui_chat_printf (NULL,
_("WeeChat colors (in use: %d, left: %d):"),
@@ -1510,7 +1510,7 @@ void
gui_color_end ()
{
int i;
for (i = 0; i < GUI_COLOR_NUM_COLORS; i++)
{
gui_color_free (gui_color[i]);
+23 -23
View File
@@ -59,14 +59,14 @@ gui_key_default_bind (int context, const char *key, const char *command)
{
struct t_gui_key *ptr_key;
char *internal_code;
internal_code = gui_key_get_internal_code (key);
ptr_key = gui_key_search (gui_keys[context],
(internal_code) ? internal_code : key);
if (!ptr_key)
gui_key_new (NULL, context, key, command);
if (internal_code)
free (internal_code);
}
@@ -205,7 +205,7 @@ gui_key_default_bindings (int context)
BIND(/* m-< */ "meta-<", "/input jump_previously_visited_buffer");
BIND(/* m-> */ "meta->", "/input jump_next_visited_buffer");
BIND(/* m-m */ "meta-m", "/mouse toggle");
/* bind meta-j + {01..99} to switch to buffers # > 10 */
for (i = 1; i < 100; i++)
{
@@ -292,7 +292,7 @@ gui_key_flush ()
static int length_key_str = 0;
char key_temp[2], *key_utf, *input_old, *ptr_char, *next_char, *ptr_error;
char utf_partial_char[16];
/*
* if there's no paste pending, then we use buffer and do actions
* according to keys
@@ -301,13 +301,13 @@ gui_key_flush ()
{
if (gui_key_buffer_size > 0)
gui_key_last_activity_time = time (NULL);
for (i = 0; i < gui_key_buffer_size; i++)
{
key = gui_key_buffer[i];
insert_ok = 1;
utf_partial_char[0] = '\0';
if (gui_mouse_event_pending || (key < 32) || (key == 127))
{
if (gui_mouse_event_pending)
@@ -340,7 +340,7 @@ gui_key_flush ()
key_str[length_key_str] = (char)key;
key_str[length_key_str + 1] = '\0';
length_key_str++;
/*
* replace invalid chars by "?", but NOT last char of
* string, if it is incomplete UTF-8 char (another char
@@ -385,13 +385,13 @@ gui_key_flush ()
{
hook_signal_send ("key_pressed",
WEECHAT_HOOK_SIGNAL_STRING, key_str);
if (gui_current_window->buffer->text_search != GUI_TEXT_SEARCH_DISABLED)
input_old = (gui_current_window->buffer->input_buffer) ?
strdup (gui_current_window->buffer->input_buffer) : strdup ("");
else
input_old = NULL;
if ((gui_key_pressed (key_str) != 0) && (insert_ok)
&& (!gui_cursor_mode))
{
@@ -402,7 +402,7 @@ gui_key_flush ()
gui_completion_stop (gui_current_window->buffer->completion, 0);
gui_input_text_changed_modifier_and_signal (gui_current_window->buffer, 1);
}
/* incremental text search in buffer */
if ((gui_current_window->buffer->text_search != GUI_TEXT_SEARCH_DISABLED)
&& ((input_old == NULL)
@@ -436,11 +436,11 @@ gui_key_flush ()
gui_window_search_restart (gui_current_window);
}
}
if (input_old)
free (input_old);
}
/* prepare incomplete UTF-8 char for next iteration */
if (utf_partial_char[0])
strcpy (key_str, utf_partial_char);
@@ -448,7 +448,7 @@ gui_key_flush ()
key_str[0] = '\0';
length_key_str = strlen (key_str);
}
gui_key_buffer_reset ();
}
}
@@ -462,11 +462,11 @@ gui_key_read_cb (void *data, int fd)
{
int ret, i, accept_paste, cancel_paste, text_added_to_buffer, paste_lines;
unsigned char buffer[4096];
/* make C compiler happy */
(void) data;
(void) fd;
accept_paste = 0;
cancel_paste = 0;
text_added_to_buffer = 0;
@@ -484,11 +484,11 @@ gui_key_read_cb (void *data, int fd)
}
if (ret <= 0)
return WEECHAT_RC_OK;
/* ctrl-Y: accept paste */
if (buffer[0] == 25)
accept_paste = 1;
/* ctrl-N: cancel paste */
if (buffer[0] == 14)
cancel_paste = 1;
@@ -506,7 +506,7 @@ gui_key_read_cb (void *data, int fd)
}
if (ret < 0)
return WEECHAT_RC_OK;
for (i = 0; i < ret; i++)
{
/* add all chars (ignore a '\n' after a '\r') */
@@ -517,10 +517,10 @@ gui_key_read_cb (void *data, int fd)
gui_key_buffer_add (buffer[i]);
}
}
text_added_to_buffer = 1;
}
if (gui_key_paste_pending)
{
/* user is ok for pasting text, let's paste! */
@@ -548,8 +548,8 @@ gui_key_read_cb (void *data, int fd)
}
}
}
gui_key_flush ();
return WEECHAT_RC_OK;
}
+54 -54
View File
@@ -73,10 +73,10 @@ gui_main_pre_init (int *argc, char **argv[])
/* make C compiler happy */
(void) argc;
(void) argv;
/* pre-init colors */
gui_color_pre_init ();
/* init some variables for chat area */
gui_chat_init ();
}
@@ -91,68 +91,68 @@ gui_main_init ()
struct t_gui_buffer *ptr_buffer;
struct t_gui_bar *ptr_bar;
struct t_gui_bar_window *ptr_bar_win;
initscr ();
if (CONFIG_BOOLEAN(config_look_eat_newline_glitch))
gui_term_set_eat_newline_glitch (0);
curs_set (1);
noecho ();
nodelay (stdscr, TRUE);
raw ();
gui_color_init ();
/* build prefixes according to config */
gui_chat_prefix_build ();
refresh ();
gui_term_cols = COLS;
gui_term_lines = LINES;
gui_window_read_terminal_size ();
/* init clipboard buffer */
gui_input_clipboard = NULL;
/* get time length */
gui_chat_time_length = gui_chat_get_time_length ();
/* init bar items */
gui_bar_item_init ();
gui_init_ok = 0;
/* create core buffer */
ptr_buffer = gui_buffer_new (NULL, GUI_BUFFER_MAIN,
NULL, NULL, NULL, NULL);
if (ptr_buffer)
{
gui_init_ok = 1;
ptr_buffer->num_displayed = 1;
/* set short name */
if (!ptr_buffer->short_name)
ptr_buffer->short_name = strdup (GUI_BUFFER_MAIN);
/* set title for core buffer */
gui_buffer_set_title (ptr_buffer,
"WeeChat " PACKAGE_VERSION " "
WEECHAT_COPYRIGHT_DATE " - " WEECHAT_WEBSITE);
/* create main window (using full space) */
if (gui_window_new (NULL, ptr_buffer, 0, 0,
gui_term_cols, gui_term_lines, 100, 100))
{
gui_current_window = gui_windows;
if (CONFIG_BOOLEAN(config_look_set_title))
gui_window_set_title (PACKAGE_NAME " " PACKAGE_VERSION);
}
/*
* create bar windows for root bars (they were read from config,
* but no window was created, GUI was not initialized)
@@ -172,7 +172,7 @@ gui_main_init ()
gui_bar_window_create_win (ptr_bar_win);
}
}
if (CONFIG_BOOLEAN(config_look_mouse))
gui_mouse_enable ();
else
@@ -241,21 +241,21 @@ gui_main_refreshs ()
struct t_gui_window *ptr_win;
struct t_gui_buffer *ptr_buffer;
struct t_gui_bar *ptr_bar;
/* refresh color buffer if needed */
if (gui_color_buffer_refresh_needed)
{
gui_color_buffer_display ();
gui_color_buffer_refresh_needed = 0;
}
/* refresh window if needed */
if (gui_window_refresh_needed)
{
gui_window_refresh_screen ((gui_window_refresh_needed > 1) ? 1 : 0);
gui_window_refresh_needed = 0;
}
/* refresh bars if needed */
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
{
@@ -264,7 +264,7 @@ gui_main_refreshs ()
gui_bar_draw (ptr_bar);
}
}
/* refresh windows if needed */
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
@@ -275,7 +275,7 @@ gui_main_refreshs ()
ptr_win->refresh_needed = 0;
}
}
/* refresh chat buffers if needed */
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
@@ -286,7 +286,7 @@ gui_main_refreshs ()
(ptr_buffer->chat_refresh_needed) > 1 ? 1 : 0);
}
}
/* refresh bars if needed */
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
{
@@ -295,7 +295,7 @@ gui_main_refreshs ()
gui_bar_draw (ptr_bar);
}
}
/* move cursor (for cursor mode) */
if (gui_cursor_mode)
gui_window_move_cursor ();
@@ -313,25 +313,25 @@ gui_main_loop ()
fd_set read_fds, write_fds, except_fds;
int max_fd;
int ready;
weechat_quit = 0;
/* catch SIGTERM signal: quit program */
util_catch_signal (SIGTERM, &gui_main_signal_sigterm);
util_catch_signal (SIGQUIT, &gui_main_signal_sigquit);
/* catch SIGHUP signal: reload configuration */
util_catch_signal (SIGHUP, &gui_main_signal_sighup);
/* catch SIGWINCH signal: redraw screen */
util_catch_signal (SIGWINCH, &gui_main_signal_sigwinch);
/* hook stdin (read keyboard) */
hook_fd_keyboard = hook_fd (NULL, STDIN_FILENO, 1, 0, 0,
&gui_key_read_cb, NULL);
gui_window_ask_refresh (1);
while (!weechat_quit)
{
/* reload config, if SIGHUP reveived */
@@ -342,7 +342,7 @@ gui_main_loop ()
"files"));
command_reload (NULL, NULL, 0, NULL, NULL);
}
/* execute hook timers */
hook_timer_exec ();
@@ -354,13 +354,13 @@ gui_main_loop ()
gui_color_pairs_auto_reset = 0;
gui_color_pairs_auto_reset_pending = 1;
}
gui_main_refreshs ();
if (gui_window_refresh_needed)
gui_main_refreshs ();
gui_color_pairs_auto_reset_pending = 0;
/* wait for keyboard or network activity */
FD_ZERO (&read_fds);
FD_ZERO (&write_fds);
@@ -374,7 +374,7 @@ gui_main_loop ()
hook_fd_exec (&read_fds, &write_fds, &except_fds);
}
}
/* remove keyboard hook */
unhook (hook_fd_keyboard);
}
@@ -400,55 +400,55 @@ gui_main_end (int clean_exit)
if (gui_window_refresh_needed)
gui_main_refreshs ();
}
/* disable mouse */
gui_mouse_disable ();
/* remove bar items and bars */
gui_bar_item_end ();
gui_bar_free_all ();
/* remove filters */
gui_filter_free_all ();
/* free clipboard buffer */
if (gui_input_clipboard)
free (gui_input_clipboard);
/* delete layout saved */
gui_layout_window_remove_all (&gui_layout_windows);
gui_layout_buffer_remove_all (&gui_layout_buffers, &last_gui_layout_buffer);
/* delete all windows */
while (gui_windows)
{
gui_window_free (gui_windows);
}
gui_window_tree_free (&gui_windows_tree);
/* delete all buffers */
while (gui_buffers)
{
gui_buffer_close (gui_buffers);
}
gui_ok = 0;
gui_init_ok = 0;
/* delete global history */
gui_history_global_free ();
/* reset title */
if (CONFIG_BOOLEAN(config_look_set_title))
gui_window_set_title (NULL);
/* end color */
gui_color_end ();
/* free some variables used for chat area */
gui_chat_end ();
}
/* end of Curses output */
refresh ();
endwin ();
+27 -27
View File
@@ -139,9 +139,9 @@ gui_mouse_grab_event2input ()
{
struct t_gui_focus_info *focus_info;
static char area[256];
area[0] = '\0';
focus_info = gui_focus_get_info (gui_mouse_event_x[0],
gui_mouse_event_y[0]);
if (focus_info)
@@ -166,7 +166,7 @@ gui_mouse_grab_event2input ()
}
gui_focus_free_info (focus_info);
}
return area;
}
@@ -178,7 +178,7 @@ void
gui_mouse_grab_end (const char *mouse_key)
{
char mouse_key_input[256];
/* insert mouse key in input */
if (gui_current_window->buffer->input)
{
@@ -202,7 +202,7 @@ gui_mouse_grab_end (const char *mouse_key)
gui_completion_stop (gui_current_window->buffer->completion, 1);
gui_input_text_changed_modifier_and_signal (gui_current_window->buffer, 1);
}
gui_mouse_grab = 0;
}
@@ -216,9 +216,9 @@ gui_mouse_event_timer_cb (void *data, int remaining_calls)
/* make C compiler happy */
(void) data;
(void) remaining_calls;
gui_mouse_event_end ();
return WEECHAT_RC_OK;
}
@@ -230,10 +230,10 @@ void
gui_mouse_event_init ()
{
gui_mouse_event_pending = 1;
if (gui_mouse_event_timer)
unhook (gui_mouse_event_timer);
gui_mouse_event_timer = hook_timer (NULL,
CONFIG_INTEGER(config_look_mouse_timer_delay),
0, 1,
@@ -251,9 +251,9 @@ gui_mouse_event_code2key (const char *code)
double diff_x, diff_y, distance, angle, pi4;
static char key[128];
char *ptr_code;
key[0] = '\0';
/*
* mouse code must have at least:
* one code (for event) + X + Y == 3 bytes or 3 UTF-8 chars
@@ -262,7 +262,7 @@ gui_mouse_event_code2key (const char *code)
length = (code_utf8) ? utf8_strlen (code) : (int)strlen (code);
if (length < 3)
return NULL;
/* get coordinates and button */
if (code_utf8)
{
@@ -283,23 +283,23 @@ gui_mouse_event_code2key (const char *code)
x = 0;
if (y < 0)
y = 0;
/* ignore code if it's motion/end code received as first event */
if ((gui_mouse_event_index == 0)
&& (MOUSE_CODE_MOTION(code[0]) || MOUSE_CODE_END(code[0])))
{
return NULL;
}
/* set data in "gui_mouse_event_xxx" */
gui_mouse_event_x[gui_mouse_event_index] = x;
gui_mouse_event_y[gui_mouse_event_index] = y;
if (gui_mouse_event_index == 0)
gui_mouse_event_button = code[0];
if (gui_mouse_event_index == 0)
gui_mouse_event_index = 1;
/*
* browse wheel codes, if one code is found, return event name immediately
*/
@@ -313,10 +313,10 @@ gui_mouse_event_code2key (const char *code)
return key;
}
}
if (!MOUSE_CODE_END(code[0]))
return NULL;
/* add name of button event */
for (i = 0; gui_mouse_button_codes[i][0]; i++)
{
@@ -326,16 +326,16 @@ gui_mouse_event_code2key (const char *code)
break;
}
}
/*
* Mouse gesture: if (x,y) on release is different from (x,y) on click,
* compute distance and angle between 2 points.
*
* Distance: sqrt((x2-x1)²+(y2-y1)²)
* Angle : atan2(x1-x1, y2-y1)
*
*
* Angle:
*
*
* 3.14 pi
* /\
* -2.35 || 2.35 3/4 * pi
@@ -360,7 +360,7 @@ gui_mouse_event_code2key (const char *code)
* buttonX-gesture-right | 3..39 | 0.78..2.35
* buttonX-gesture-right-long | >= 40 |
*/
distance = 0;
if (key[0]
&& ((gui_mouse_event_x[0] != gui_mouse_event_x[1])
@@ -400,7 +400,7 @@ gui_mouse_event_code2key (const char *code)
}
}
}
return key;
}
@@ -412,16 +412,16 @@ void
gui_mouse_event_end ()
{
const char *mouse_key;
gui_mouse_event_pending = 0;
/* end mouse event timer */
if (gui_mouse_event_timer)
{
unhook (gui_mouse_event_timer);
gui_mouse_event_timer = NULL;
}
/* get key from mouse code */
mouse_key = gui_mouse_event_code2key (gui_key_combo_buffer);
if (mouse_key && mouse_key[0])
@@ -438,6 +438,6 @@ gui_mouse_event_end ()
}
gui_mouse_event_reset ();
}
gui_key_combo_buffer[0] = '\0';
}
+149 -149
View File
@@ -93,7 +93,7 @@ gui_window_read_terminal_size ()
{
struct winsize size;
int new_width, new_height;
if (ioctl (fileno (stdout), TIOCGWINSZ, &size) == 0)
{
resizeterm (size.ws_row, size.ws_col);
@@ -106,7 +106,7 @@ gui_window_read_terminal_size ()
gui_term_cols = new_width;
gui_term_lines = new_height;
}
gui_ok = ((gui_term_cols >= GUI_WINDOW_MIN_WIDTH)
&& (gui_term_lines >= GUI_WINDOW_MIN_HEIGHT));
}
@@ -119,7 +119,7 @@ int
gui_window_objects_init (struct t_gui_window *window)
{
struct t_gui_window_curses_objects *new_objects;
new_objects = malloc (sizeof (*new_objects));
if (new_objects)
{
@@ -159,7 +159,7 @@ gui_window_clear_weechat (WINDOW *window, int weechat_color)
{
if (!gui_ok)
return;
wbkgdset (window, ' ' | COLOR_PAIR (gui_color_weechat_get_pair (weechat_color)));
werase (window);
wmove (window, 0, 0);
@@ -174,17 +174,17 @@ gui_window_clear (WINDOW *window, int fg, int bg)
{
if (!gui_ok)
return;
if ((fg > 0) && (fg & GUI_COLOR_EXTENDED_FLAG))
fg &= GUI_COLOR_EXTENDED_MASK;
else
fg = gui_weechat_colors[fg & GUI_COLOR_EXTENDED_MASK].foreground;
if ((bg > 0) && (bg & GUI_COLOR_EXTENDED_FLAG))
bg &= GUI_COLOR_EXTENDED_MASK;
else
bg = gui_weechat_colors[bg & GUI_COLOR_EXTENDED_MASK].background;
wbkgdset (window, ' ' | COLOR_PAIR (gui_color_get_pair (fg, bg)));
werase (window);
wmove (window, 0, 0);
@@ -241,7 +241,7 @@ gui_window_reset_style (WINDOW *window, int weechat_color)
gui_window_current_style_bg = -1;
gui_window_current_style_attr = 0;
gui_window_current_color_attr = 0;
wattroff (window, A_BOLD | A_UNDERLINE | A_REVERSE);
wattron (window, COLOR_PAIR(gui_color_weechat_get_pair (weechat_color)) |
gui_color[weechat_color]->attributes);
@@ -289,7 +289,7 @@ gui_window_set_color (WINDOW *window, int fg, int bg)
{
gui_window_current_style_fg = fg;
gui_window_current_style_bg = bg;
wattron (window, COLOR_PAIR(gui_color_get_pair (fg, bg)));
}
@@ -301,13 +301,13 @@ void
gui_window_set_weechat_color (WINDOW *window, int num_color)
{
int fg, bg;
if ((num_color >= 0) && (num_color < GUI_COLOR_NUM_COLORS))
{
gui_window_reset_style (window, num_color);
fg = gui_color[num_color]->foreground;
bg = gui_color[num_color]->background;
/*
* if not real white, we use default terminal foreground instead of
* white if bold attribute is set
@@ -317,7 +317,7 @@ gui_window_set_weechat_color (WINDOW *window, int num_color)
{
fg = -1;
}
if ((fg > 0) && (fg & GUI_COLOR_EXTENDED_FLAG))
fg &= GUI_COLOR_EXTENDED_MASK;
if ((bg > 0) && (bg & GUI_COLOR_EXTENDED_FLAG))
@@ -335,11 +335,11 @@ void
gui_window_set_custom_color_fg (WINDOW *window, int fg)
{
int current_bg, attributes;
if (fg >= 0)
{
current_bg = gui_window_current_style_bg;
if ((fg > 0) && (fg & GUI_COLOR_EXTENDED_FLAG))
{
if (fg & GUI_COLOR_EXTENDED_BOLD_FLAG)
@@ -375,7 +375,7 @@ gui_window_set_custom_color_fg (WINDOW *window, int fg)
attributes |= gui_weechat_colors[fg & GUI_COLOR_EXTENDED_MASK].attributes;
gui_window_set_color_style (window, attributes);
fg = gui_weechat_colors[fg & GUI_COLOR_EXTENDED_MASK].foreground;
/*
* if not real white, we use default terminal foreground instead of
* white if bold attribute is set
@@ -385,7 +385,7 @@ gui_window_set_custom_color_fg (WINDOW *window, int fg)
{
fg = -1;
}
gui_window_set_color (window, fg, current_bg);
}
}
@@ -400,12 +400,12 @@ void
gui_window_set_custom_color_bg (WINDOW *window, int bg)
{
int current_attr, current_fg;
if (bg >= 0)
{
current_attr = gui_window_current_style_attr;
current_fg = gui_window_current_style_fg;
if ((bg > 0) && (bg & GUI_COLOR_EXTENDED_FLAG))
{
gui_window_set_color (window,
@@ -432,7 +432,7 @@ void
gui_window_set_custom_color_fg_bg (WINDOW *window, int fg, int bg)
{
int attributes;
if ((fg >= 0) && (bg >= 0))
{
if ((fg > 0) && (fg & GUI_COLOR_EXTENDED_FLAG))
@@ -468,7 +468,7 @@ gui_window_set_custom_color_fg_bg (WINDOW *window, int fg, int bg)
attributes |= gui_weechat_colors[fg & GUI_COLOR_EXTENDED_MASK].attributes;
gui_window_set_color_style (window, attributes);
fg = gui_weechat_colors[fg & GUI_COLOR_EXTENDED_MASK].foreground;
/*
* if not real white, we use default terminal foreground instead of
* white if bold attribute is set
@@ -479,7 +479,7 @@ gui_window_set_custom_color_fg_bg (WINDOW *window, int fg, int bg)
fg = -1;
}
}
if ((bg > 0) && (bg & GUI_COLOR_EXTENDED_FLAG))
bg &= GUI_COLOR_EXTENDED_MASK;
else
@@ -488,7 +488,7 @@ gui_window_set_custom_color_fg_bg (WINDOW *window, int fg, int bg)
bg = (gui_color_term_colors >= 16) ?
gui_weechat_colors[bg].background : gui_weechat_colors[bg].foreground;
}
gui_window_set_color (window, fg, bg);
}
}
@@ -522,9 +522,9 @@ gui_window_string_apply_color_fg (unsigned char **string, WINDOW *window)
unsigned char *ptr_string;
char str_fg[6], *error;
int fg, extra_attr, flag;
ptr_string = *string;
if (ptr_string[0] == GUI_COLOR_EXTENDED_CHAR)
{
ptr_string++;
@@ -577,7 +577,7 @@ gui_window_string_apply_color_fg (unsigned char **string, WINDOW *window)
ptr_string += 2;
}
}
*string = ptr_string;
}
@@ -594,9 +594,9 @@ gui_window_string_apply_color_bg (unsigned char **string, WINDOW *window)
unsigned char *ptr_string;
char str_bg[6], *error;
int bg;
ptr_string = *string;
if (ptr_string[0] == GUI_COLOR_EXTENDED_CHAR)
{
if (ptr_string[1] && ptr_string[2] && ptr_string[3]
@@ -636,7 +636,7 @@ gui_window_string_apply_color_bg (unsigned char **string, WINDOW *window)
ptr_string += 2;
}
}
*string = ptr_string;
}
@@ -654,9 +654,9 @@ gui_window_string_apply_color_fg_bg (unsigned char **string, WINDOW *window)
unsigned char *ptr_string;
char str_fg[6], str_bg[6], *error;
int fg, bg, extra_attr, flag;
ptr_string = *string;
str_fg[0] = '\0';
str_bg[0] = '\0';
fg = -1;
@@ -756,7 +756,7 @@ gui_window_string_apply_color_fg_bg (unsigned char **string, WINDOW *window)
{
gui_window_set_custom_color_fg_bg (window, fg, bg);
}
*string = ptr_string;
}
@@ -774,9 +774,9 @@ gui_window_string_apply_color_pair (unsigned char **string, WINDOW *window)
unsigned char *ptr_string;
char str_pair[6], *error;
int pair;
ptr_string = *string;
if ((isdigit (ptr_string[0])) && (isdigit (ptr_string[1]))
&& (isdigit (ptr_string[2])) && (isdigit (ptr_string[3]))
&& (isdigit (ptr_string[4])))
@@ -794,7 +794,7 @@ gui_window_string_apply_color_pair (unsigned char **string, WINDOW *window)
}
ptr_string += 5;
}
*string = ptr_string;
}
@@ -813,9 +813,9 @@ gui_window_string_apply_color_weechat (unsigned char **string, WINDOW *window)
unsigned char *ptr_string;
char str_number[3], *error;
int weechat_color;
ptr_string = *string;
if (isdigit (ptr_string[0]) && isdigit (ptr_string[1]))
{
if (window)
@@ -833,7 +833,7 @@ gui_window_string_apply_color_weechat (unsigned char **string, WINDOW *window)
}
ptr_string += 2;
}
*string = ptr_string;
}
@@ -850,9 +850,9 @@ void
gui_window_string_apply_color_set_attr (unsigned char **string, WINDOW *window)
{
unsigned char *ptr_string;
ptr_string = *string;
switch (ptr_string[0])
{
case GUI_COLOR_ATTR_BOLD_CHAR:
@@ -875,7 +875,7 @@ gui_window_string_apply_color_set_attr (unsigned char **string, WINDOW *window)
gui_window_set_color_style (window, A_UNDERLINE);
break;
}
*string = ptr_string;
}
@@ -892,9 +892,9 @@ void
gui_window_string_apply_color_remove_attr (unsigned char **string, WINDOW *window)
{
unsigned char *ptr_string;
ptr_string = *string;
switch (ptr_string[0])
{
case GUI_COLOR_ATTR_BOLD_CHAR:
@@ -917,7 +917,7 @@ gui_window_string_apply_color_remove_attr (unsigned char **string, WINDOW *windo
gui_window_remove_color_style (window, A_UNDERLINE);
break;
}
*string = ptr_string;
}
@@ -938,18 +938,18 @@ gui_window_calculate_pos_size (struct t_gui_window *window)
gui_ok = 0;
return;
}
for (ptr_bar_win = window->bar_windows; ptr_bar_win;
ptr_bar_win = ptr_bar_win->next_bar_window)
{
gui_bar_window_calculate_pos_size (ptr_bar_win, window);
}
add_bottom = gui_bar_window_get_size (NULL, window, GUI_BAR_POSITION_BOTTOM);
add_top = gui_bar_window_get_size (NULL, window, GUI_BAR_POSITION_TOP);
add_left = gui_bar_window_get_size (NULL, window, GUI_BAR_POSITION_LEFT);
add_right = gui_bar_window_get_size (NULL, window, GUI_BAR_POSITION_RIGHT);
window->win_chat_x = window->win_x + add_left;
window->win_chat_y = window->win_y + add_top;
window->win_chat_width = window->win_width - add_left - add_right;
@@ -969,13 +969,13 @@ void
gui_window_draw_separator (struct t_gui_window *window)
{
int separator_vertical;
if (GUI_WINDOW_OBJECTS(window)->win_separator)
{
delwin (GUI_WINDOW_OBJECTS(window)->win_separator);
GUI_WINDOW_OBJECTS(window)->win_separator = NULL;
}
if (window->win_x > gui_bar_root_get_size (NULL, GUI_BAR_POSITION_LEFT))
{
GUI_WINDOW_OBJECTS(window)->win_separator = newwin (window->win_height,
@@ -1007,7 +1007,7 @@ gui_window_redraw_buffer (struct t_gui_buffer *buffer)
{
if (!gui_ok)
return;
gui_chat_draw (buffer, 1);
}
@@ -1022,7 +1022,7 @@ gui_window_redraw_all_buffers ()
if (!gui_ok)
return;
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
{
@@ -1041,14 +1041,14 @@ gui_window_switch_to_buffer (struct t_gui_window *window,
{
struct t_gui_bar_window *ptr_bar_window;
struct t_gui_buffer *old_buffer;
if (!gui_ok)
return;
gui_buffer_add_value_num_displayed (window->buffer, -1);
old_buffer = window->buffer;
if (window->buffer->number != buffer->number)
{
gui_window_scroll_switch (window, buffer);
@@ -1071,18 +1071,18 @@ gui_window_switch_to_buffer (struct t_gui_window *window,
}
}
}
window->buffer = buffer;
gui_buffer_add_value_num_displayed (buffer, 1);
if (!weechat_upgrading && (old_buffer != buffer))
gui_hotlist_remove_buffer (buffer);
if (gui_ok)
{
gui_bar_window_remove_unused_bars (window);
gui_bar_window_add_missing_bars (window);
/* create bar windows */
for (ptr_bar_window = window->bar_windows; ptr_bar_window;
ptr_bar_window = ptr_bar_window->next_bar_window)
@@ -1091,12 +1091,12 @@ gui_window_switch_to_buffer (struct t_gui_window *window,
gui_bar_window_calculate_pos_size (ptr_bar_window, window);
gui_bar_window_create_win (ptr_bar_window);
}
gui_window_calculate_pos_size (window);
/* destroy Curses windows */
gui_window_objects_free (window, 0);
/* create Curses windows */
if (GUI_WINDOW_OBJECTS(window)->win_chat)
delwin (GUI_WINDOW_OBJECTS(window)->win_chat);
@@ -1107,29 +1107,29 @@ gui_window_switch_to_buffer (struct t_gui_window *window,
gui_window_draw_separator (window);
gui_buffer_ask_chat_refresh (window->buffer, 2);
}
if (window->buffer->type == GUI_BUFFER_TYPE_FREE)
{
window->scroll->scrolling = 0;
window->scroll->lines_after = 0;
}
gui_buffer_set_active_buffer (buffer);
for (ptr_bar_window = window->bar_windows; ptr_bar_window;
ptr_bar_window = ptr_bar_window->next_bar_window)
{
ptr_bar_window->bar->bar_refresh_needed = 1;
}
if (CONFIG_BOOLEAN(config_look_read_marker_always_show)
&& set_last_read && !window->buffer->lines->last_read_line)
{
window->buffer->lines->last_read_line = window->buffer->lines->last_line;
}
gui_input_move_to_buffer (old_buffer, window->buffer);
hook_signal_send ("buffer_switch",
WEECHAT_HOOK_SIGNAL_POINTER, buffer);
}
@@ -1143,12 +1143,12 @@ gui_window_switch (struct t_gui_window *window)
{
struct t_gui_window *old_window;
int changes;
if (gui_current_window == window)
return;
old_window = gui_current_window;
gui_current_window = window;
changes = gui_bar_window_remove_unused_bars (old_window)
|| gui_bar_window_add_missing_bars (old_window);
@@ -1159,12 +1159,12 @@ gui_window_switch (struct t_gui_window *window)
gui_current_window->buffer, 1);
gui_current_window = window;
}
gui_window_switch_to_buffer (gui_current_window,
gui_current_window->buffer, 1);
old_window->refresh_needed = 1;
gui_input_move_to_buffer (old_window->buffer, window->buffer);
}
@@ -1177,17 +1177,17 @@ gui_window_page_up (struct t_gui_window *window)
{
char scroll[32];
int num_lines;
if (!gui_ok)
return;
num_lines = ((window->win_chat_height - 1) *
CONFIG_INTEGER(config_look_scroll_page_percent)) / 100;
if (num_lines < 1)
num_lines = 1;
else if (num_lines > window->win_chat_height - 1)
num_lines = window->win_chat_height - 1;
switch (window->buffer->type)
{
case GUI_BUFFER_TYPE_FORMATTED:
@@ -1227,17 +1227,17 @@ gui_window_page_down (struct t_gui_window *window)
struct t_gui_line *ptr_line;
int line_pos, num_lines;
char scroll[32];
if (!gui_ok)
return;
num_lines = ((window->win_chat_height - 1) *
CONFIG_INTEGER(config_look_scroll_page_percent)) / 100;
if (num_lines < 1)
num_lines = 1;
else if (num_lines > window->win_chat_height - 1)
num_lines = window->win_chat_height - 1;
switch (window->buffer->type)
{
case GUI_BUFFER_TYPE_FORMATTED:
@@ -1246,7 +1246,7 @@ gui_window_page_down (struct t_gui_window *window)
gui_chat_calculate_line_diff (window, &window->scroll->start_line,
&window->scroll->start_line_pos,
num_lines);
/* check if we can display all */
ptr_line = window->scroll->start_line;
line_pos = window->scroll->start_line_pos;
@@ -1282,7 +1282,7 @@ void
gui_window_scroll_up (struct t_gui_window *window)
{
char scroll[32];
if (!gui_ok)
return;
@@ -1326,10 +1326,10 @@ gui_window_scroll_down (struct t_gui_window *window)
struct t_gui_line *ptr_line;
int line_pos;
char scroll[32];
if (!gui_ok)
return;
switch (window->buffer->type)
{
case GUI_BUFFER_TYPE_FORMATTED:
@@ -1338,14 +1338,14 @@ gui_window_scroll_down (struct t_gui_window *window)
gui_chat_calculate_line_diff (window, &window->scroll->start_line,
&window->scroll->start_line_pos,
CONFIG_INTEGER(config_look_scroll_amount));
/* check if we can display all */
ptr_line = window->scroll->start_line;
line_pos = window->scroll->start_line_pos;
gui_chat_calculate_line_diff (window, &ptr_line,
&line_pos,
window->win_chat_height - 1);
if (!ptr_line)
{
window->scroll->start_line = NULL;
@@ -1376,7 +1376,7 @@ gui_window_scroll_top (struct t_gui_window *window)
{
if (!gui_ok)
return;
switch (window->buffer->type)
{
case GUI_BUFFER_TYPE_FORMATTED:
@@ -1410,7 +1410,7 @@ void
gui_window_scroll_bottom (struct t_gui_window *window)
{
char scroll[32];
if (!gui_ok)
return;
@@ -1459,10 +1459,10 @@ gui_window_auto_resize (struct t_gui_window_tree *tree,
{
int size1, size2;
struct t_gui_window_tree *parent;
if (!gui_ok)
return 0;
if (tree)
{
if (tree->window)
@@ -1533,10 +1533,10 @@ gui_window_refresh_windows ()
struct t_gui_bar_window *ptr_bar_win;
struct t_gui_bar *ptr_bar;
int add_bottom, add_top, add_left, add_right;
if (!gui_ok)
return;
old_current_window = gui_current_window;
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
@@ -1549,12 +1549,12 @@ gui_window_refresh_windows ()
gui_bar_ask_refresh (ptr_bar);
}
}
add_bottom = gui_bar_root_get_size (NULL, GUI_BAR_POSITION_BOTTOM);
add_top = gui_bar_root_get_size (NULL, GUI_BAR_POSITION_TOP);
add_left = gui_bar_root_get_size (NULL, GUI_BAR_POSITION_LEFT);
add_right = gui_bar_root_get_size (NULL, GUI_BAR_POSITION_RIGHT);
if (gui_window_auto_resize (gui_windows_tree, add_left, add_top,
gui_window_get_width () - add_left - add_right,
gui_window_get_height () - add_top - add_bottom,
@@ -1568,7 +1568,7 @@ gui_window_refresh_windows ()
}
gui_window_zoom (gui_current_window);
}
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
gui_window_calculate_pos_size (ptr_win);
@@ -1579,7 +1579,7 @@ gui_window_refresh_windows ()
}
ptr_win->refresh_needed = 1;
}
gui_current_window = old_current_window;
}
@@ -1592,15 +1592,15 @@ gui_window_split_horizontal (struct t_gui_window *window, int percentage)
{
struct t_gui_window *new_window;
int height1, height2;
if (!gui_ok)
return NULL;
new_window = NULL;
height1 = (window->win_height * percentage) / 100;
height2 = window->win_height - height1;
if ((height1 >= GUI_WINDOW_MIN_HEIGHT) && (height2 >= GUI_WINDOW_MIN_HEIGHT)
&& (percentage > 0) && (percentage < 100))
{
@@ -1614,17 +1614,17 @@ gui_window_split_horizontal (struct t_gui_window *window, int percentage)
window->win_y = new_window->win_y + new_window->win_height;
window->win_height = height2;
window->win_height_pct = 100 - percentage;
/* assign same buffer for new window (top window) */
gui_buffer_add_value_num_displayed (new_window->buffer, 1);
window->refresh_needed = 1;
new_window->refresh_needed = 1;
gui_window_switch (new_window);
}
}
return new_window;
}
@@ -1637,15 +1637,15 @@ gui_window_split_vertical (struct t_gui_window *window, int percentage)
{
struct t_gui_window *new_window;
int width1, width2;
if (!gui_ok)
return NULL;
new_window = NULL;
width1 = (window->win_width * percentage) / 100;
width2 = window->win_width - width1 - 1;
if ((width1 >= GUI_WINDOW_MIN_WIDTH) && (width2 >= GUI_WINDOW_MIN_WIDTH)
&& (percentage > 0) && (percentage < 100))
{
@@ -1658,20 +1658,20 @@ gui_window_split_vertical (struct t_gui_window *window, int percentage)
/* reduce old window height (left window) */
window->win_width = width1;
window->win_width_pct = 100 - percentage;
/* assign same buffer for new window (right window) */
gui_buffer_add_value_num_displayed (new_window->buffer, 1);
window->refresh_needed = 1;
new_window->refresh_needed = 1;
gui_window_switch (new_window);
/* create & draw separator */
gui_window_draw_separator (gui_current_window);
}
}
return new_window;
}
@@ -1684,10 +1684,10 @@ gui_window_resize (struct t_gui_window *window, int percentage)
{
struct t_gui_window_tree *parent;
int old_split_pct, add_bottom, add_top, add_left, add_right;
if (!gui_ok)
return;
parent = window->ptr_tree->parent_node;
if (parent)
{
@@ -1701,12 +1701,12 @@ gui_window_resize (struct t_gui_window *window, int percentage)
{
parent->split_pct = 100 - percentage;
}
add_bottom = gui_bar_root_get_size (NULL, GUI_BAR_POSITION_BOTTOM);
add_top = gui_bar_root_get_size (NULL, GUI_BAR_POSITION_TOP);
add_left = gui_bar_root_get_size (NULL, GUI_BAR_POSITION_LEFT);
add_right = gui_bar_root_get_size (NULL, GUI_BAR_POSITION_RIGHT);
if (gui_window_auto_resize (gui_windows_tree, add_left, add_top,
gui_window_get_width () - add_left - add_right,
gui_window_get_height () - add_top - add_bottom,
@@ -1726,10 +1726,10 @@ gui_window_resize_delta (struct t_gui_window *window, int delta_percentage)
{
struct t_gui_window_tree *parent;
int old_split_pct, add_bottom, add_top, add_left, add_right;
if (!gui_ok)
return;
parent = window->ptr_tree->parent_node;
if (parent)
{
@@ -1747,12 +1747,12 @@ gui_window_resize_delta (struct t_gui_window *window, int delta_percentage)
parent->split_pct = 1;
else if (parent->split_pct > 99)
parent->split_pct = 99;
add_bottom = gui_bar_root_get_size (NULL, GUI_BAR_POSITION_BOTTOM);
add_top = gui_bar_root_get_size (NULL, GUI_BAR_POSITION_TOP);
add_left = gui_bar_root_get_size (NULL, GUI_BAR_POSITION_LEFT);
add_right = gui_bar_root_get_size (NULL, GUI_BAR_POSITION_RIGHT);
if (gui_window_auto_resize (gui_windows_tree, add_left, add_top,
gui_window_get_width () - add_left - add_right,
gui_window_get_height () - add_top - add_bottom,
@@ -1771,19 +1771,19 @@ int
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)
{
sister = (parent->child1->window == window) ?
parent->child2 : parent->child1;
if (!(sister->window))
return 0;
if (window->win_y == sister->window->win_y)
{
/* horizontal merge */
@@ -1800,10 +1800,10 @@ gui_window_merge (struct t_gui_window *window)
window->win_x = sister->window->win_x;
if (sister->window->win_y < window->win_y)
window->win_y = sister->window->win_y;
gui_window_free (sister->window);
gui_window_tree_node_to_leaf (parent, window);
gui_window_switch_to_buffer (window, window->buffer, 1);
return 1;
}
@@ -1818,17 +1818,17 @@ void
gui_window_merge_all (struct t_gui_window *window)
{
int num_deleted, add_bottom, add_top, add_left, add_right;
if (!gui_ok)
return;
num_deleted = 0;
while (gui_windows->next_window)
{
gui_window_free ((gui_windows == window) ? gui_windows->next_window : gui_windows);
num_deleted++;
}
if (num_deleted > 0)
{
gui_window_tree_free (&gui_windows_tree);
@@ -1843,10 +1843,10 @@ gui_window_merge_all (struct t_gui_window *window)
window->win_y = add_top;
window->win_width = gui_window_get_width () - add_left - add_right;
window->win_height = gui_window_get_height () - add_top - add_bottom;
window->win_width_pct = 100;
window->win_height_pct = 100;
gui_current_window = window;
gui_window_switch_to_buffer (window, window->buffer, 1);
}
@@ -1866,7 +1866,7 @@ 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)
{
@@ -1896,7 +1896,7 @@ gui_window_side_by_side (struct t_gui_window *win1, struct t_gui_window *win2)
return 0;
return 3;
}
/* win2 on the left ? */
if (win2->win_x + win2->win_width + 1 == win1->win_x)
{
@@ -1918,10 +1918,10 @@ void
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)
{
@@ -1942,10 +1942,10 @@ void
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)
{
@@ -1966,10 +1966,10 @@ void
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)
{
@@ -1990,10 +1990,10 @@ void
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)
{
@@ -2015,7 +2015,7 @@ int
gui_window_balance_count (struct t_gui_window_tree *tree, int split_horizontal)
{
int count;
count = 0;
if (tree)
{
@@ -2043,7 +2043,7 @@ int
gui_window_balance (struct t_gui_window_tree *tree)
{
int balanced, count_left, count_right, new_split_pct;
balanced = 0;
if (tree && tree->child1 && tree->child2)
{
@@ -2086,12 +2086,12 @@ gui_window_swap (struct t_gui_window *window, int direction)
struct t_gui_window_tree *parent, *sister;
struct t_gui_window *window2, *ptr_win;
struct t_gui_buffer *buffer1;
if (!window || !gui_ok)
return;
window2 = NULL;
if (direction == 0)
{
/* search sister window */
@@ -2118,7 +2118,7 @@ gui_window_swap (struct t_gui_window *window, int direction)
}
}
}
/* let's swap! */
if (window2 && (window->buffer != window2->buffer))
{
@@ -2144,7 +2144,7 @@ gui_window_refresh_screen (int full_refresh)
gui_window_read_terminal_size ();
refresh ();
}
gui_window_refresh_windows ();
}
@@ -2158,7 +2158,7 @@ gui_window_set_title (const char *title)
char *shell, *shellname;
char *envterm = getenv ("TERM");
char *envshell = getenv ("SHELL");
if (envterm)
{
if (title && title[0])