diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/curses/gui-curses-bar-window.c | 365 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-chat.c | 1 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-window.c | 15 | ||||
-rw-r--r-- | src/gui/curses/gui-curses.h | 2 | ||||
-rw-r--r-- | src/gui/gui-bar-item.c | 262 | ||||
-rw-r--r-- | src/gui/gui-bar-item.h | 11 | ||||
-rw-r--r-- | src/gui/gui-bar-window.c | 294 | ||||
-rw-r--r-- | src/gui/gui-bar-window.h | 3 | ||||
-rw-r--r-- | src/gui/gui-bar.c | 34 | ||||
-rw-r--r-- | src/gui/gui-bar.h | 4 | ||||
-rw-r--r-- | src/gui/gui-color.h | 2 |
11 files changed, 531 insertions, 462 deletions
diff --git a/src/gui/curses/gui-curses-bar-window.c b/src/gui/curses/gui-curses-bar-window.c index dc95050e1..ea5c3ef92 100644 --- a/src/gui/curses/gui-curses-bar-window.c +++ b/src/gui/curses/gui-curses-bar-window.c @@ -237,6 +237,9 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window, CONFIG_INTEGER(bar_window->bar->color_bg)); string += 2; break; + case GUI_COLOR_BAR_START_INPUT_CHAR: + string += 2; + break; case GUI_COLOR_BAR_MOVE_CURSOR_CHAR: /* move cursor to current position on screen */ getyx (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, @@ -298,7 +301,7 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window, { if (*x + size_on_screen > bar_window->width) { - if (CONFIG_INTEGER(gui_bar_get_option_filling (bar_window->bar)) == GUI_BAR_FILLING_VERTICAL) + if (gui_bar_get_filling (bar_window->bar) == GUI_BAR_FILLING_VERTICAL) return 0; if (*y >= bar_window->height - 1) return 0; @@ -335,11 +338,14 @@ void gui_bar_window_draw (struct t_gui_bar_window *bar_window, struct t_gui_window *window) { - int x, y, i, items_count, num_lines, line; - char *content, *item_value, *item_value2, **items; - char space_with_reinit_color[32]; - int length_reinit_color, content_length, length, length_on_screen; - int max_length, optimal_number_of_lines, chars_available; + int x, y, items_count, num_lines, line; + enum t_gui_bar_filling filling; + char *content, **items; + char space_with_reinit_color[32], str_start_input[16], str_cursor[16]; + char *pos_start_input, *pos_cursor, *buf, *new_start_input; + int length_reinit_color, length_on_screen, chars_available; + int length_screen_before_cursor, length_screen_after_cursor; + int total_length_screen, diff, max_length, optimal_number_of_lines; int some_data_not_displayed; if (!gui_init_ok) @@ -354,66 +360,38 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window, CONFIG_COLOR(bar_window->bar->color_bg)); length_reinit_color = strlen (space_with_reinit_color); + snprintf (str_start_input, sizeof (str_start_input), "%c%c%c", + GUI_COLOR_COLOR_CHAR, + GUI_COLOR_BAR_CHAR, + GUI_COLOR_BAR_START_INPUT_CHAR); + + 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; - if (CONFIG_INTEGER(bar_window->bar->size) == 0) + filling = gui_bar_get_filling (bar_window->bar); + + content = gui_bar_window_content_get_with_filling (bar_window); + if (content) { - content = NULL; - content_length = 1; - for (i = 0; i < bar_window->bar->items_count; i++) + items = string_explode (content, "\n", 0, 0, &items_count); + if (items_count == 0) { - item_value = gui_bar_item_get_value (bar_window->bar->items_array[i], - bar_window->bar, window, - 0, 0, 0); - if (item_value) - { - if (item_value[0]) - { - if (CONFIG_INTEGER(gui_bar_get_option_filling (bar_window->bar)) == GUI_BAR_FILLING_HORIZONTAL) - { - item_value2 = string_replace (item_value, "\n", - space_with_reinit_color); - } - else - item_value2 = NULL; - if (!content) - { - content_length += strlen ((item_value2) ? - item_value2 : item_value); - content = strdup ((item_value2) ? - item_value2 : item_value); - } - else - { - content_length += length_reinit_color + - strlen ((item_value2) ? item_value2 : item_value); - content = realloc (content, content_length); - if (CONFIG_INTEGER(gui_bar_get_option_filling (bar_window->bar)) == GUI_BAR_FILLING_HORIZONTAL) - strcat (content, space_with_reinit_color); - else - strcat (content, "\n"); - strcat (content, - (item_value2) ? item_value2 : item_value); - } - if (item_value2) - free (item_value2); - } - free (item_value); - } + if (CONFIG_INTEGER(bar_window->bar->size) == 0) + gui_bar_window_set_current_size (bar_window->bar, 1); + gui_window_clear (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, + CONFIG_COLOR(bar_window->bar->color_bg)); } - if (content) + else { - items = string_explode (content, "\n", 0, 0, &items_count); - if (items_count == 0) - { - gui_bar_window_set_current_size (bar_window->bar, 1); - gui_window_clear (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, - CONFIG_COLOR(bar_window->bar->color_bg)); - } - else + /* bar with auto size ? then compute new size, according to content */ + if (CONFIG_INTEGER(bar_window->bar->size) == 0) { /* search longer line and optimal number of lines */ max_length = 0; @@ -422,11 +400,8 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window, { length_on_screen = gui_chat_strlen_screen (items[line]); - length = strlen (items[line]); - if ((length >= 3) - && (items[line][length - 3] == GUI_COLOR_COLOR_CHAR) - && (items[line][length - 2] == GUI_COLOR_BAR_CHAR) - && (items[line][length - 1] == GUI_COLOR_BAR_MOVE_CURSOR_CHAR)) + 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) @@ -447,7 +422,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window, { case GUI_BAR_POSITION_BOTTOM: case GUI_BAR_POSITION_TOP: - if (CONFIG_INTEGER(gui_bar_get_option_filling (bar_window->bar)) == GUI_BAR_FILLING_HORIZONTAL) + if (filling == GUI_BAR_FILLING_HORIZONTAL) num_lines = optimal_number_of_lines; else num_lines = items_count; @@ -462,190 +437,132 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window, case GUI_BAR_NUM_POSITIONS: break; } - gui_window_clear (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, - CONFIG_COLOR(bar_window->bar->color_bg)); - x = 0; - y = 0; - some_data_not_displayed = 0; - if ((bar_window->scroll_y > 0) - && (bar_window->scroll_y >= items_count)) - { - bar_window->scroll_y = items_count - bar_window->height; - if (bar_window->scroll_y < 0) - bar_window->scroll_y = 0; - } - for (line = 0; - (line < items_count) && (y < bar_window->height); - line++) + } + + gui_window_clear (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, + CONFIG_COLOR(bar_window->bar->color_bg)); + x = 0; + y = 0; + some_data_not_displayed = 0; + if ((bar_window->scroll_y > 0) + && (bar_window->scroll_y >= items_count)) + { + bar_window->scroll_y = items_count - bar_window->height; + if (bar_window->scroll_y < 0) + bar_window->scroll_y = 0; + } + for (line = 0; + (line < items_count) && (y < bar_window->height); + line++) + { + pos_start_input = strstr (items[line], str_start_input); + if (pos_start_input) { - if ((bar_window->scroll_y == 0) - || (line >= bar_window->scroll_y)) + pos_cursor = strstr (items[line], str_cursor); + if (pos_cursor && (pos_cursor > pos_start_input)) { - if (!gui_bar_window_print_string (bar_window, &x, &y, - items[line], 1)) - { - some_data_not_displayed = 1; - } - if (CONFIG_INTEGER(gui_bar_get_option_filling (bar_window->bar)) == GUI_BAR_FILLING_VERTICAL) + pos_start_input += strlen (str_start_input); + + 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; + if (pos_cursor && (pos_cursor > items[line])) { - while (x < bar_window->width) + buf = string_strndup (items[line], pos_cursor - items[line]); + if (buf) { - gui_bar_window_print_string (bar_window, - &x, &y, - " ", 0); + length_screen_before_cursor = gui_chat_strlen_screen (buf); + length_screen_after_cursor = gui_chat_strlen_screen (pos_cursor); + free (buf); } - x = 0; - y++; } - else + if ((length_screen_before_cursor < 0) || (length_screen_after_cursor < 0)) { - gui_bar_window_print_string (bar_window, &x, &y, - space_with_reinit_color, 0); + length_screen_before_cursor = gui_chat_strlen_screen (items[line]); + length_screen_after_cursor = 0; + } + + total_length_screen = length_screen_before_cursor + length_screen_after_cursor; + + diff = length_screen_before_cursor - chars_available; + if (diff > 0) + { + new_start_input = gui_chat_string_add_offset (pos_start_input, diff); + if (pos_cursor && (new_start_input > pos_cursor)) + new_start_input = pos_cursor; + memmove (pos_start_input, new_start_input, strlen (new_start_input) + 1); } } } - if ((bar_window->cursor_x < 0) && (bar_window->cursor_y < 0) - && ((bar_window->scroll_x > 0) || (bar_window->scroll_y > 0))) - { - x = (bar_window->height > 1) ? bar_window->width - 2 : 0; - if (x < 0) - x = 0; - y = 0; - gui_window_set_custom_color_fg_bg (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, - CONFIG_COLOR(config_color_bar_more), - CONFIG_INTEGER(bar_window->bar->color_bg)); - mvwprintw (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, y, x, "--"); - } - if ((bar_window->cursor_x < 0) && (bar_window->cursor_y < 0) - && (some_data_not_displayed || (line < items_count))) - { - x = bar_window->width - 2; - if (x < 0) - x = 0; - y = (bar_window->height > 1) ? bar_window->height - 1 : 0; - gui_window_set_custom_color_fg_bg (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, - CONFIG_COLOR(config_color_bar_more), - CONFIG_INTEGER(bar_window->bar->color_bg)); - mvwprintw (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, y, x, "++"); - } - } - if (items) - string_free_exploded (items); - free (content); - } - else - { - gui_bar_window_set_current_size (bar_window->bar, 1); - gui_window_clear (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, - CONFIG_COLOR(bar_window->bar->color_bg)); - } - } - else - { - gui_window_clear (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, - CONFIG_COLOR(bar_window->bar->color_bg)); - - x = 0; - y = 0; - - for (i = 0; i < bar_window->bar->items_count; i++) - { - chars_available = - ((bar_window->height - y - 1) * bar_window->width) + /* next lines */ - (bar_window->width - x - 1); /* chars on current line */ - - item_value = gui_bar_item_get_value (bar_window->bar->items_array[i], - bar_window->bar, window, - bar_window->width, - bar_window->height, - chars_available); - if (item_value) - { - if (item_value[0]) + + if ((bar_window->scroll_y == 0) + || (line >= bar_window->scroll_y)) { - if (CONFIG_INTEGER(gui_bar_get_option_filling (bar_window->bar)) == GUI_BAR_FILLING_HORIZONTAL) - { - item_value2 = string_replace (item_value, "\n", - space_with_reinit_color); - } - else - item_value2 = NULL; - items = string_explode ((item_value2) ? - item_value2 : item_value, - "\n", 0, 0, - &items_count); - some_data_not_displayed = 0; - if ((bar_window->scroll_y > 0) - && (bar_window->scroll_y >= items_count)) + if (!gui_bar_window_print_string (bar_window, &x, &y, + items[line], 1)) { - bar_window->scroll_y = items_count - bar_window->height; - if (bar_window->scroll_y < 0) - bar_window->scroll_y = 0; + some_data_not_displayed = 1; } - for (line = 0; - (line < items_count) && (y < bar_window->height); - line++) + if (filling != GUI_BAR_FILLING_HORIZONTAL) { - if ((bar_window->scroll_y == 0) - || (line >= bar_window->scroll_y)) + while (x < bar_window->width) { - if (!gui_bar_window_print_string (bar_window, &x, &y, - items[line], 1)) - { - some_data_not_displayed = 1; - } - if (CONFIG_INTEGER(gui_bar_get_option_filling (bar_window->bar)) == GUI_BAR_FILLING_VERTICAL) - { - while (x < bar_window->width) - { - gui_bar_window_print_string (bar_window, - &x, &y, - " ", 0); - } - x = 0; - y++; - } - else - { - gui_bar_window_print_string (bar_window, &x, &y, - space_with_reinit_color, 0); - } + gui_bar_window_print_string (bar_window, + &x, &y, + " ", 0); } + x = 0; + y++; } - if ((bar_window->cursor_x < 0) && (bar_window->cursor_y < 0) - && ((bar_window->scroll_x > 0) || (bar_window->scroll_y > 0))) - { - x = (bar_window->height > 1) ? bar_window->width - 2 : 0; - if (x < 0) - x = 0; - y = 0; - gui_window_set_custom_color_fg_bg (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, - CONFIG_COLOR(config_color_bar_more), - CONFIG_INTEGER(bar_window->bar->color_bg)); - mvwprintw (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, y, x, "--"); - } - if ((bar_window->cursor_x < 0) && (bar_window->cursor_y < 0) - && (some_data_not_displayed || (line < items_count))) + else { - x = bar_window->width - 2; - if (x < 0) - x = 0; - y = (bar_window->height > 1) ? bar_window->height - 1 : 0; - gui_window_set_custom_color_fg_bg (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, - CONFIG_COLOR(config_color_bar_more), - CONFIG_INTEGER(bar_window->bar->color_bg)); - mvwprintw (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, y, x, "++"); + gui_bar_window_print_string (bar_window, &x, &y, + space_with_reinit_color, 0); } - if (item_value2) - free (item_value2); - if (items) - string_free_exploded (items); } - free (item_value); + } + if ((bar_window->cursor_x < 0) && (bar_window->cursor_y < 0) + && ((bar_window->scroll_x > 0) || (bar_window->scroll_y > 0))) + { + x = (bar_window->height > 1) ? bar_window->width - 2 : 0; + if (x < 0) + x = 0; + y = 0; + gui_window_set_custom_color_fg_bg (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, + CONFIG_COLOR(config_color_bar_more), + CONFIG_INTEGER(bar_window->bar->color_bg)); + mvwprintw (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, + y, x, "--"); + } + if ((bar_window->cursor_x < 0) && (bar_window->cursor_y < 0) + && (some_data_not_displayed || (line < items_count))) + { + x = bar_window->width - 2; + if (x < 0) + x = 0; + y = (bar_window->height > 1) ? bar_window->height - 1 : 0; + gui_window_set_custom_color_fg_bg (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, + CONFIG_COLOR(config_color_bar_more), + CONFIG_INTEGER(bar_window->bar->color_bg)); + mvwprintw (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, + y, x, "++"); } } + if (items) + string_free_exploded (items); + free (content); } - + else + { + if (CONFIG_INTEGER(bar_window->bar->size) == 0) + gui_bar_window_set_current_size (bar_window->bar, 1); + gui_window_clear (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, + CONFIG_COLOR(bar_window->bar->color_bg)); + } + /* move cursor if it was asked in an item content (input_text does that to move cursor in user input text) */ if (window && (gui_current_window == window) diff --git a/src/gui/curses/gui-curses-chat.c b/src/gui/curses/gui-curses-chat.c index c1fbae67a..a1a2ad225 100644 --- a/src/gui/curses/gui-curses-chat.c +++ b/src/gui/curses/gui-curses-chat.c @@ -234,6 +234,7 @@ gui_chat_string_next_char (struct t_gui_window *window, case GUI_COLOR_BAR_FG_CHAR: case GUI_COLOR_BAR_DELIM_CHAR: case GUI_COLOR_BAR_BG_CHAR: + case GUI_COLOR_BAR_START_INPUT_CHAR: case GUI_COLOR_BAR_MOVE_CURSOR_CHAR: string += 2; break; diff --git a/src/gui/curses/gui-curses-window.c b/src/gui/curses/gui-curses-window.c index 6c19c206b..19a6f96aa 100644 --- a/src/gui/curses/gui-curses-window.c +++ b/src/gui/curses/gui-curses-window.c @@ -451,7 +451,7 @@ gui_window_switch_to_buffer (struct t_gui_window *window, struct t_gui_buffer *buffer, int set_last_read) { - struct t_gui_bar_window *ptr_bar_win; + struct t_gui_bar_window *ptr_bar_window; struct t_gui_buffer *old_buffer; if (!gui_ok) @@ -489,10 +489,10 @@ gui_window_switch_to_buffer (struct t_gui_window *window, if (gui_ok) { /* create bar windows */ - for (ptr_bar_win = window->bar_windows; ptr_bar_win; - ptr_bar_win = ptr_bar_win->next_bar_window) + for (ptr_bar_window = window->bar_windows; ptr_bar_window; + ptr_bar_window = ptr_bar_window->next_bar_window) { - gui_bar_window_create_win (ptr_bar_win); + gui_bar_window_create_win (ptr_bar_window); } /* destroy Curses windows */ @@ -518,10 +518,11 @@ gui_window_switch_to_buffer (struct t_gui_window *window, } /* redraw bars in window */ - for (ptr_bar_win = window->bar_windows; ptr_bar_win; - ptr_bar_win = ptr_bar_win->next_bar_window) + for (ptr_bar_window = window->bar_windows; ptr_bar_window; + ptr_bar_window = ptr_bar_window->next_bar_window) { - ptr_bar_win->bar->bar_refresh_needed = 1; + gui_bar_window_content_build (ptr_bar_window, window); + ptr_bar_window->bar->bar_refresh_needed = 1; } if (window->buffer->type == GUI_BUFFER_TYPE_FREE) diff --git a/src/gui/curses/gui-curses.h b/src/gui/curses/gui-curses.h index 91923f1b5..da8021eb3 100644 --- a/src/gui/curses/gui-curses.h +++ b/src/gui/curses/gui-curses.h @@ -42,7 +42,7 @@ struct t_gui_bar_window; struct t_gui_window_curses_objects { WINDOW *win_chat; /* chat window (example: channel) */ - WINDOW *win_separator; /* separation between 2 splited (V) win */ + WINDOW *win_separator; /* separation between 2 splitted (V) win*/ }; struct t_gui_bar_window_curses_objects diff --git a/src/gui/gui-bar-item.c b/src/gui/gui-bar-item.c index 9d75c523b..2ed9d6589 100644 --- a/src/gui/gui-bar-item.c +++ b/src/gui/gui-bar-item.c @@ -254,96 +254,6 @@ gui_bar_item_used_in_a_bar (const char *item_name, int partial_name) } /* - * gui_bar_item_input_text_update_for_display: update input text item for - * display: - * - scroll if needed, to see only - * the end of input - * - insert "move cursor" id to - * move cursor to good position - */ - -char * -gui_bar_item_input_text_update_for_display (const char *item_content, - struct t_gui_window *window, - int chars_available) -{ - char *buf, str_cursor[16]; - const char *pos_cursor, *ptr_start; - int diff, buf_pos; - int length, length_screen_before_cursor, length_screen_after_cursor; - int total_length_screen; - - snprintf (str_cursor, sizeof (str_cursor), "%c%c%c", - GUI_COLOR_COLOR_CHAR, - GUI_COLOR_BAR_CHAR, - GUI_COLOR_BAR_MOVE_CURSOR_CHAR); - - ptr_start = item_content; - - pos_cursor = gui_chat_string_add_offset (item_content, - window->buffer->input_buffer_pos); - - /* if bar size is fixed (chars_available > 0), then truncate it at - beginning if needed */ - if (chars_available > 0) - { - length_screen_before_cursor = -1; - length_screen_after_cursor = -1; - if (pos_cursor && (pos_cursor > item_content)) - { - buf = string_strndup (item_content, pos_cursor - item_content); - if (buf) - { - length_screen_before_cursor = gui_chat_strlen_screen (buf); - 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 (item_content); - length_screen_after_cursor = 0; - } - - total_length_screen = length_screen_before_cursor + length_screen_after_cursor; - - diff = length_screen_before_cursor - chars_available; - if (diff > 0) - { - ptr_start = gui_chat_string_add_offset (item_content, diff); - if (pos_cursor && (ptr_start > pos_cursor)) - ptr_start = pos_cursor; - } - } - - /* insert "move cursor" id in string and return it */ - length = 16 + strlen (ptr_start); - buf = malloc (length); - if (buf) - { - buf[0] = '\0'; - buf_pos = 0; - - if (!pos_cursor) - pos_cursor = ptr_start; - - /* add beginning of buffer */ - if (pos_cursor != ptr_start) - { - memmove (buf, ptr_start, pos_cursor - ptr_start); - buf_pos = buf_pos + (pos_cursor - ptr_start); - } - /* add "move cursor here" identifier in string */ - snprintf (buf + buf_pos, length - buf_pos, "%s", - str_cursor); - /* add end of buffer */ - strcat (buf, pos_cursor); - } - - return buf; -} - -/* * gui_bar_item_get_value: return value of a bar item * first look for prefix/suffix in name, then run item * callback (if found) and concatene strings @@ -355,13 +265,11 @@ gui_bar_item_input_text_update_for_display (const char *item_content, char * gui_bar_item_get_value (const char *name, struct t_gui_bar *bar, - struct t_gui_window *window, - int width, int height, - int chars_available) + struct t_gui_window *window) { const char *ptr, *start, *end; char *prefix, *item_name, *suffix; - char *item_value, *item_value2, delimiter_color[32], bar_color[32]; + char *item_value, delimiter_color[32], bar_color[32]; char *result; int valid_char, length; struct t_gui_bar_item *ptr_item; @@ -404,35 +312,10 @@ gui_bar_item_get_value (const char *name, struct t_gui_bar *bar, window->buffer->plugin : NULL, 0, item_name); - if (ptr_item) + if (ptr_item && ptr_item->build_callback) { - if (ptr_item->build_callback) - { - item_value = (ptr_item->build_callback) (ptr_item->build_callback_data, - ptr_item, window, - width, - height); - if (window - && (strncmp (item_name, - gui_bar_item_names[GUI_BAR_ITEM_INPUT_TEXT], - strlen (gui_bar_item_names[GUI_BAR_ITEM_INPUT_TEXT])) == 0)) - { - if (prefix) - chars_available -= gui_chat_strlen_screen (prefix); - - item_value2 = gui_bar_item_input_text_update_for_display ( - (item_value) ? item_value : "", - window, - chars_available); - - if (item_value2) - { - if (item_value) - free (item_value); - item_value = item_value2; - } - } - } + item_value = (ptr_item->build_callback) (ptr_item->build_callback_data, + ptr_item, window); } if (!item_value || !item_value[0]) { @@ -509,8 +392,7 @@ struct t_gui_bar_item * gui_bar_item_new (struct t_weechat_plugin *plugin, const char *name, char *(*build_callback)(void *data, struct t_gui_bar_item *item, - struct t_gui_window *window, - int max_width, int max_height), + struct t_gui_window *window), void *build_callback_data) { struct t_gui_bar_item *new_bar_item; @@ -660,8 +542,7 @@ gui_bar_item_free_all_plugin (struct t_weechat_plugin *plugin) char * gui_bar_item_default_input_paste (void *data, struct t_gui_bar_item *item, - struct t_gui_window *window, - int max_width, int max_height) + struct t_gui_window *window) { char *text_paste_pending = N_("%sPaste %d lines ? [ctrl-Y] Yes [ctrl-N] No"); char *ptr_message, *buf; @@ -670,8 +551,6 @@ gui_bar_item_default_input_paste (void *data, struct t_gui_bar_item *item, /* make C compiler happy */ (void) data; (void) item; - (void) max_width; - (void) max_height; if (!window) return NULL; @@ -699,15 +578,12 @@ gui_bar_item_default_input_paste (void *data, struct t_gui_bar_item *item, char * gui_bar_item_default_input_prompt (void *data, struct t_gui_bar_item *item, - struct t_gui_window *window, - int max_width, int max_height) + struct t_gui_window *window) { /* make C compiler happy */ (void) data; (void) item; (void) window; - (void) max_width; - (void) max_height; return NULL; } @@ -718,8 +594,7 @@ gui_bar_item_default_input_prompt (void *data, struct t_gui_bar_item *item, char * gui_bar_item_default_input_search (void *data, struct t_gui_bar_item *item, - struct t_gui_window *window, - int max_width, int max_height) + struct t_gui_window *window) { char *text_search = N_("Text search"); char *text_search_exact = N_("Text search (exact)"); @@ -729,8 +604,6 @@ gui_bar_item_default_input_search (void *data, struct t_gui_bar_item *item, /* make C compiler happy */ (void) data; (void) item; - (void) max_width; - (void) max_height; if (!window) window = gui_current_window; @@ -762,16 +635,15 @@ gui_bar_item_default_input_search (void *data, struct t_gui_bar_item *item, char * gui_bar_item_default_input_text (void *data, struct t_gui_bar_item *item, - struct t_gui_window *window, - int max_width, int max_height) + struct t_gui_window *window) { - char *new_input, str_buffer[128]; + char *ptr_input, str_buffer[128], str_start_input[16], str_cursor[16], *buf; + const char *pos_cursor; + int length, buf_pos; /* make C compiler happy */ (void) data; (void) item; - (void) max_width; - (void) max_height; if (!window) window = gui_current_window; @@ -779,16 +651,59 @@ gui_bar_item_default_input_text (void *data, struct t_gui_bar_item *item, snprintf (str_buffer, sizeof (str_buffer), "0x%lx", (long unsigned int)(window->buffer)); - new_input = hook_modifier_exec (NULL, + ptr_input = hook_modifier_exec (NULL, "weechat_input_text_display", str_buffer, (window->buffer->input_buffer) ? window->buffer->input_buffer : ""); - if (new_input) - return new_input; + if (!ptr_input) + { + ptr_input = (window->buffer->input_buffer) ? + strdup (window->buffer->input_buffer) : NULL; + } + + if (!ptr_input) + return NULL; + + /* insert "move cursor" id in string */ + snprintf (str_start_input, sizeof (str_start_input), "%c%c%c", + GUI_COLOR_COLOR_CHAR, + GUI_COLOR_BAR_CHAR, + GUI_COLOR_BAR_START_INPUT_CHAR); + snprintf (str_cursor, sizeof (str_cursor), "%c%c%c", + GUI_COLOR_COLOR_CHAR, + GUI_COLOR_BAR_CHAR, + GUI_COLOR_BAR_MOVE_CURSOR_CHAR); + pos_cursor = gui_chat_string_add_offset (ptr_input, + window->buffer->input_buffer_pos); + length = strlen (str_start_input)+ strlen (ptr_input) + + strlen (str_cursor) + 1; + buf = malloc (length); + if (buf) + { + snprintf (buf, length, "%s", str_start_input); + buf_pos = strlen (buf); + + if (!pos_cursor) + pos_cursor = ptr_input; + + /* add beginning of buffer */ + if (pos_cursor != ptr_input) + { + memmove (buf + buf_pos, ptr_input, pos_cursor - ptr_input); + buf_pos += (pos_cursor - ptr_input); + } + /* add "move cursor here" identifier in string */ + snprintf (buf + buf_pos, length - buf_pos, "%s", + str_cursor); + /* add end of buffer */ + strcat (buf, pos_cursor); + + free (ptr_input); + ptr_input = buf; + } - return (window->buffer->input_buffer) ? - strdup (window->buffer->input_buffer) : NULL; + return ptr_input; } /* @@ -797,8 +712,7 @@ gui_bar_item_default_input_text (void *data, struct t_gui_bar_item *item, char * gui_bar_item_default_time (void *data, struct t_gui_bar_item *item, - struct t_gui_window *window, - int max_width, int max_height) + struct t_gui_window *window) { time_t date; struct tm *local_time; @@ -808,8 +722,6 @@ gui_bar_item_default_time (void *data, struct t_gui_bar_item *item, (void) data; (void) item; (void) window; - (void) max_width; - (void) max_height; date = time (NULL); local_time = localtime (&date); @@ -827,8 +739,7 @@ gui_bar_item_default_time (void *data, struct t_gui_bar_item *item, char * gui_bar_item_default_buffer_count (void *data, struct t_gui_bar_item *item, - struct t_gui_window *window, - int max_width, int max_height) + struct t_gui_window *window) { char buf[32]; @@ -836,8 +747,6 @@ gui_bar_item_default_buffer_count (void *data, struct t_gui_bar_item *item, (void) data; (void) item; (void) window; - (void) max_width; - (void) max_height; snprintf (buf, sizeof (buf), "%d", (last_gui_buffer) ? last_gui_buffer->number : 0); @@ -851,16 +760,13 @@ gui_bar_item_default_buffer_count (void *data, struct t_gui_bar_item *item, char * gui_bar_item_default_buffer_plugin (void *data, struct t_gui_bar_item *item, - struct t_gui_window *window, - int max_width, int max_height) + struct t_gui_window *window) { const char *plugin_name; /* make C compiler happy */ (void) data; (void) item; - (void) max_width; - (void) max_height; if (!window) window = gui_current_window; @@ -875,16 +781,13 @@ gui_bar_item_default_buffer_plugin (void *data, struct t_gui_bar_item *item, char * gui_bar_item_default_buffer_name (void *data, struct t_gui_bar_item *item, - struct t_gui_window *window, - int max_width, int max_height) + struct t_gui_window *window) { char buf[256]; /* make C compiler happy */ (void) data; (void) item; - (void) max_width; - (void) max_height; if (!window) window = gui_current_window; @@ -905,16 +808,13 @@ gui_bar_item_default_buffer_name (void *data, struct t_gui_bar_item *item, char * gui_bar_item_default_buffer_filter (void *data, struct t_gui_bar_item *item, - struct t_gui_window *window, - int max_width, int max_height) + struct t_gui_window *window) { char buf[256]; /* make C compiler happy */ (void) data; (void) item; - (void) max_width; - (void) max_height; if (!window) window = gui_current_window; @@ -938,16 +838,13 @@ gui_bar_item_default_buffer_filter (void *data, struct t_gui_bar_item *item, char * gui_bar_item_default_buffer_nicklist_count (void *data, struct t_gui_bar_item *item, - struct t_gui_window *window, - int max_width, int max_height) + struct t_gui_window *window) { char buf[32]; /* make C compiler happy */ (void) data; (void) item; - (void) max_width; - (void) max_height; if (!window) window = gui_current_window; @@ -967,16 +864,13 @@ gui_bar_item_default_buffer_nicklist_count (void *data, char * gui_bar_item_default_scroll (void *data, struct t_gui_bar_item *item, - struct t_gui_window *window, - int max_width, int max_height) + struct t_gui_window *window) { char buf[64]; /* make C compiler happy */ (void) data; (void) item; - (void) max_width; - (void) max_height; if (!window) window = gui_current_window; @@ -997,8 +891,7 @@ gui_bar_item_default_scroll (void *data, struct t_gui_bar_item *item, char * gui_bar_item_default_hotlist (void *data, struct t_gui_bar_item *item, - struct t_gui_window *window, - int max_width, int max_height) + struct t_gui_window *window) { char buf[1024], format[32]; struct t_gui_hotlist *ptr_hotlist; @@ -1008,8 +901,6 @@ gui_bar_item_default_hotlist (void *data, struct t_gui_bar_item *item, (void) data; (void) item; (void) window; - (void) max_width; - (void) max_height; if (!gui_hotlist) return NULL; @@ -1083,8 +974,7 @@ gui_bar_item_default_hotlist (void *data, struct t_gui_bar_item *item, char * gui_bar_item_default_completion (void *data, struct t_gui_bar_item *item, - struct t_gui_window *window, - int max_width, int max_height) + struct t_gui_window *window) { int length; char *buf, number_str[16]; @@ -1094,8 +984,6 @@ gui_bar_item_default_completion (void *data, struct t_gui_bar_item *item, (void) data; (void) item; (void) window; - (void) max_width; - (void) max_height; length = 1; for (ptr_item = gui_completion_partial_list; ptr_item; @@ -1136,14 +1024,11 @@ gui_bar_item_default_completion (void *data, struct t_gui_bar_item *item, char * gui_bar_item_default_buffer_title (void *data, struct t_gui_bar_item *item, - struct t_gui_window *window, - int max_width, int max_height) + struct t_gui_window *window) { /* make C compiler happy */ (void) data; (void) item; - (void) max_width; - (void) max_height; if (!window) window = gui_current_window; @@ -1158,8 +1043,7 @@ gui_bar_item_default_buffer_title (void *data, struct t_gui_bar_item *item, char * gui_bar_item_default_buffer_nicklist (void *data, struct t_gui_bar_item *item, - struct t_gui_window *window, - int max_width, int max_height) + struct t_gui_window *window) { struct t_gui_nick_group *ptr_group; struct t_gui_nick *ptr_nick; @@ -1170,8 +1054,6 @@ gui_bar_item_default_buffer_nicklist (void *data, struct t_gui_bar_item *item, /* make C compiler happy */ (void) data; (void) item; - (void) max_width; - (void) max_height; if (!window) window = gui_current_window; diff --git a/src/gui/gui-bar-item.h b/src/gui/gui-bar-item.h index 007257779..69193eb66 100644 --- a/src/gui/gui-bar-item.h +++ b/src/gui/gui-bar-item.h @@ -49,8 +49,7 @@ struct t_gui_bar_item char *name; /* bar item name */ char *(*build_callback)(void *data, struct t_gui_bar_item *item, - struct t_gui_window *window, - int max_width, int max_height); + struct t_gui_window *window); /* callback called for building item */ void *build_callback_data; /* data for callback */ struct t_gui_bar_item *prev_item; /* link to previous bar item */ @@ -79,16 +78,12 @@ extern int gui_bar_item_used_in_a_bar (const char *item_name, int partial_name); extern char *gui_bar_item_get_value (const char *name, struct t_gui_bar *bar, - struct t_gui_window *window, - int width, int height, - int chars_available); + struct t_gui_window *window); extern struct t_gui_bar_item *gui_bar_item_new (struct t_weechat_plugin *plugin, const char *name, char *(*build_callback)(void *data, struct t_gui_bar_item *item, - struct t_gui_window *window, - int max_width, - int max_height), + struct t_gui_window *window), void *build_callback_data); extern void gui_bar_item_update (const char *name); extern void gui_bar_item_free (struct t_gui_bar_item *item); diff --git a/src/gui/gui-bar-window.c b/src/gui/gui-bar-window.c index df2ca046d..4b09c0cec 100644 --- a/src/gui/gui-bar-window.c +++ b/src/gui/gui-bar-window.c @@ -35,6 +35,7 @@ #include "gui-bar-window.h" #include "gui-bar.h" #include "gui-bar-item.h" +#include "gui-chat.h" #include "gui-color.h" #include "gui-window.h" @@ -288,12 +289,19 @@ gui_bar_window_content_build_item (struct t_gui_bar_window *bar_window, int item_index) { if (bar_window->items_content[item_index]) + { free (bar_window->items_content[item_index]); + bar_window->items_content[item_index] = NULL; + } - bar_window->items_content[item_index] = - gui_bar_item_get_value (bar_window->bar->items_array[item_index], - bar_window->bar, window, - 0, 0, 0); + /* build item, but only if there's a buffer in window */ + if ((window && window->buffer) + || (gui_current_window && gui_current_window->buffer)) + { + bar_window->items_content[item_index] = + gui_bar_item_get_value (bar_window->bar->items_array[item_index], + bar_window->bar, window); + } } /* @@ -322,6 +330,189 @@ gui_bar_window_content_build (struct t_gui_bar_window *bar_window, } /* + * gui_bar_window_content_get_with_filling: get content of a bar window, + * formated for display, according + * to filling for bar position + */ + +char * +gui_bar_window_content_get_with_filling (struct t_gui_bar_window *bar_window) +{ + enum t_gui_bar_filling filling; + char *content, space_with_reinit_color[32], *item_value; + int index_content, content_length, length_reinit_color, i, j, k, index; + int length, max_length, max_length_screen, total_items, columns, lines; + char ***splitted_items, **linear_items; + + snprintf (space_with_reinit_color, + sizeof (space_with_reinit_color), + "%c%c%02d,%02d ", + GUI_COLOR_COLOR_CHAR, + GUI_COLOR_FG_BG_CHAR, + CONFIG_COLOR(bar_window->bar->color_fg), + CONFIG_COLOR(bar_window->bar->color_bg)); + length_reinit_color = strlen (space_with_reinit_color); + + content = NULL; + content_length = 1; + filling = gui_bar_get_filling (bar_window->bar); + switch (filling) + { + case GUI_BAR_FILLING_HORIZONTAL: /* items separated by space */ + case GUI_BAR_FILLING_VERTICAL: /* items separated by \n */ + for (i = 0; i < bar_window->items_count; i++) + { + if (bar_window->items_content[i] + && bar_window->items_content[i][0]) + { + if (gui_bar_get_filling (bar_window->bar) == GUI_BAR_FILLING_HORIZONTAL) + { + item_value = string_replace (bar_window->items_content[i], + "\n", + space_with_reinit_color); + } + else + item_value = NULL; + if (!content) + { + content_length += strlen ((item_value) ? + item_value : bar_window->items_content[i]); + content = strdup ((item_value) ? + item_value : bar_window->items_content[i]); + } + else + { + content_length += length_reinit_color + + strlen ((item_value) ? item_value : bar_window->items_content[i]); + content = realloc (content, content_length); + if (gui_bar_get_filling (bar_window->bar) == GUI_BAR_FILLING_HORIZONTAL) + strcat (content, space_with_reinit_color); + else + strcat (content, "\n"); + strcat (content, + (item_value) ? item_value : bar_window->items_content[i]); + } + if (item_value) + free (item_value); + } + } + break; + case GUI_BAR_FILLING_COLUMNS_HORIZONTAL: /* items in columns, with horizontal filling */ + case GUI_BAR_FILLING_COLUMNS_VERTICAL: /* items in columns, with vertical filling */ + total_items = 0; + max_length = 1; + max_length_screen = 1; + splitted_items = malloc(bar_window->items_count * sizeof(*splitted_items)); + for (i = 0; i < bar_window->items_count; i++) + { + if (bar_window->items_content[i] + && bar_window->items_content[i][0]) + { + splitted_items[i] = string_explode (bar_window->items_content[i], + "\n", 0, 0, NULL); + for (j = 0; splitted_items[i][j]; j++) + { + total_items++; + + length = strlen (splitted_items[i][j]); + if (length > max_length) + max_length = length; + + length = gui_chat_strlen_screen (splitted_items[i][j]); + if (length > max_length_screen) + max_length_screen = length; + } + } + else + splitted_items[i] = NULL; + } + if ((CONFIG_INTEGER(bar_window->bar->position) == GUI_BAR_POSITION_BOTTOM) + || (CONFIG_INTEGER(bar_window->bar->position) == GUI_BAR_POSITION_TOP)) + { + columns = bar_window->width / (max_length_screen + 1); + if (columns == 0) + columns = 1; + lines = total_items / columns; + if (total_items % columns != 0) + lines++; + } + else + { + columns = total_items / bar_window->height; + if (total_items % bar_window->height != 0) + columns++; + lines = bar_window->height; + } + + /* build array with pointers to splitted items */ + linear_items = malloc (total_items * sizeof (*linear_items)); + index = 0; + for (i = 0; i < bar_window->items_count; i++) + { + if (splitted_items[i]) + { + for (j = 0; splitted_items[i][j]; j++) + { + linear_items[index++] = splitted_items[i][j]; + } + } + } + + /* build content with lines and columns */ + content = malloc (1 + (lines * + ((columns * (max_length + length_reinit_color)) + 1))); + content[0] = '\0'; + index_content = 0; + for (i = 0; i < lines; i++) + { + for (j = 0; j < columns; j++) + { + if (filling == GUI_BAR_FILLING_COLUMNS_HORIZONTAL) + index = (i * columns) + j; + else + index = (j * lines) + i; + + if (index >= total_items) + { + for (k = 0; k < max_length_screen; k++) + { + content[index_content++] = ' '; + } + } + else + { + strcpy (content + index_content, linear_items[index]); + index_content += strlen (linear_items[index]); + length = max_length_screen - + gui_chat_strlen_screen (linear_items[index]); + for (k = 0; k < length; k++) + { + content[index_content++] = ' '; + } + } + strcpy (content + index_content, space_with_reinit_color); + index_content += length_reinit_color; + } + content[index_content++] = '\n'; + } + content[index_content] = '\0'; + + free (linear_items); + for (i = 0; i < bar_window->items_count; i++) + { + if (splitted_items[i]) + string_free_exploded (splitted_items[i]); + } + free (splitted_items); + break; + case GUI_BAR_NUM_FILLING: + break; + } + + return content; +} + +/* * gui_bar_window_new: create a new "window bar" for a bar, in screen or a window * if window is not NULL, bar window will be in this window * return 1 if ok, 0 if error @@ -464,15 +655,84 @@ gui_bar_window_get_current_size (struct t_gui_bar_window *bar_window) } /* + * gui_bar_window_get_max_size_in_window: return max size for bar window + * in a window + */ + +int +gui_bar_window_get_max_size_in_window (struct t_gui_bar_window *bar_window, + struct t_gui_window *window) +{ + int max_size; + + max_size = 1; + + if (bar_window && window) + { + switch (CONFIG_INTEGER(bar_window->bar->position)) + { + case GUI_BAR_POSITION_BOTTOM: + case GUI_BAR_POSITION_TOP: + max_size = (window->win_chat_height + bar_window->height) - + GUI_WINDOW_CHAT_MIN_HEIGHT; + break; + case GUI_BAR_POSITION_LEFT: + case GUI_BAR_POSITION_RIGHT: + max_size = (window->win_chat_width + bar_window->width) - + GUI_WINDOW_CHAT_MIN_HEIGHT; + break; + case GUI_BAR_NUM_POSITIONS: + break; + } + } + + return max_size; +} + +/* + * gui_bar_window_get_max_size: return max size for bar window + */ + +int +gui_bar_window_get_max_size (struct t_gui_bar_window *bar_window, + struct t_gui_window *window) +{ + int max_size_found, max_size; + struct t_gui_window *ptr_window; + + if (window) + { + max_size_found = gui_bar_window_get_max_size_in_window (bar_window, + window); + } + else + { + max_size_found = INT_MAX; + for (ptr_window = gui_windows; ptr_window; + ptr_window = ptr_window->next_window) + { + max_size = gui_bar_window_get_max_size_in_window (bar_window, + ptr_window); + if (max_size < max_size_found) + max_size_found = max_size; + } + if (max_size_found == INT_MAX) + max_size_found = 1; + } + + return max_size_found; +} + +/* * gui_bar_window_set_current_size: set current size of all bar windows for a bar */ void gui_bar_window_set_current_size (struct t_gui_bar *bar, int size) { - struct t_gui_window *ptr_win; - struct t_gui_bar_window *ptr_bar_win; - int new_size; + struct t_gui_window *ptr_window; + struct t_gui_bar_window *ptr_bar_window; + int new_size, max_size; if (size == 0) new_size = 1; @@ -492,21 +752,27 @@ gui_bar_window_set_current_size (struct t_gui_bar *bar, int size) { if (bar->bar_window->current_size != new_size) { - bar->bar_window->current_size = new_size; + max_size = gui_bar_window_get_max_size (bar->bar_window, NULL); + bar->bar_window->current_size = (max_size < new_size) ? + max_size : new_size; gui_bar_window_recreate_bar_windows (bar); } } else { - for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window) + for (ptr_window = gui_windows; ptr_window; + ptr_window = ptr_window->next_window) { - for (ptr_bar_win = ptr_win->bar_windows; ptr_bar_win; - ptr_bar_win = ptr_bar_win->next_bar_window) + for (ptr_bar_window = ptr_window->bar_windows; ptr_bar_window; + ptr_bar_window = ptr_bar_window->next_bar_window) { - if ((ptr_bar_win->bar == bar) - && (ptr_bar_win->current_size != new_size)) + if ((ptr_bar_window->bar == bar) + && (ptr_bar_window->current_size != new_size)) { - ptr_bar_win->current_size = new_size; + max_size = gui_bar_window_get_max_size (ptr_bar_window, + ptr_window); + ptr_bar_window->current_size = (max_size < new_size) ? + max_size : new_size; gui_bar_window_recreate_bar_windows (bar); } } diff --git a/src/gui/gui-bar-window.h b/src/gui/gui-bar-window.h index 2b716dfc4..989eedee6 100644 --- a/src/gui/gui-bar-window.h +++ b/src/gui/gui-bar-window.h @@ -49,6 +49,9 @@ extern void gui_bar_window_calculate_pos_size (struct t_gui_bar_window *bar_wind extern void gui_bar_window_content_build_item (struct t_gui_bar_window *bar_window, struct t_gui_window *window, int item_index); +extern void gui_bar_window_content_build (struct t_gui_bar_window *bar_window, + struct t_gui_window *window); +extern char *gui_bar_window_content_get_with_filling (struct t_gui_bar_window *bar_window); extern struct t_gui_bar_window *gui_bar_window_search_bar (struct t_gui_window *window, struct t_gui_bar *bar); extern int gui_bar_window_get_current_size (struct t_gui_bar_window *bar_window); diff --git a/src/gui/gui-bar.c b/src/gui/gui-bar.c index 129fabe35..98720ba9a 100644 --- a/src/gui/gui-bar.c +++ b/src/gui/gui-bar.c @@ -51,7 +51,7 @@ char *gui_bar_type_string[GUI_BAR_NUM_TYPES] = char *gui_bar_position_string[GUI_BAR_NUM_POSITIONS] = { "bottom", "top", "left", "right" }; char *gui_bar_filling_string[GUI_BAR_NUM_FILLING] = -{ "horizontal", "vertical" }; +{ "horizontal", "vertical", "columns_horizontal", "columns_vertical" }; struct t_gui_bar *gui_bars = NULL; /* first bar */ struct t_gui_bar *last_gui_bar = NULL; /* last bar */ @@ -237,7 +237,7 @@ gui_bar_get_min_height (struct t_gui_bar *bar) int gui_bar_check_size_add (struct t_gui_bar *bar, int add_size) { - struct t_gui_window *ptr_win; + struct t_gui_window *ptr_window; int sub_width, sub_height; sub_width = 0; @@ -257,13 +257,14 @@ gui_bar_check_size_add (struct t_gui_bar *bar, int add_size) break; } - for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window) + for (ptr_window = gui_windows; ptr_window; + ptr_window = ptr_window->next_window) { if ((CONFIG_INTEGER(bar->type) == GUI_BAR_TYPE_ROOT) - || (gui_bar_window_search_bar (ptr_win, bar))) + || (gui_bar_window_search_bar (ptr_window, bar))) { - if ((ptr_win->win_chat_width - sub_width < GUI_WINDOW_CHAT_MIN_WIDTH) - || (ptr_win->win_chat_height - sub_height < GUI_WINDOW_CHAT_MIN_HEIGHT)) + if ((ptr_window->win_chat_width - sub_width < GUI_WINDOW_CHAT_MIN_WIDTH) + || (ptr_window->win_chat_height - sub_height < GUI_WINDOW_CHAT_MIN_HEIGHT)) return 0; } } @@ -273,21 +274,18 @@ gui_bar_check_size_add (struct t_gui_bar *bar, int add_size) } /* - * gui_bar_get_option_filling: return pointer to filling option - * if position is top/bottom, then return pointer - * on option "filling_top_bottom" - * if position is left/right, then return pointer - * on option "filling_left_right" + * gui_bar_get_filling: return filling option for bar, according to filling + * for current bar position */ -struct t_config_option * -gui_bar_get_option_filling (struct t_gui_bar *bar) +enum t_gui_bar_filling +gui_bar_get_filling (struct t_gui_bar *bar) { if ((CONFIG_INTEGER(bar->position) == GUI_BAR_POSITION_BOTTOM) || (CONFIG_INTEGER(bar->position) == GUI_BAR_POSITION_TOP)) - return bar->filling_top_bottom; + return CONFIG_INTEGER(bar->filling_top_bottom); - return bar->filling_left_right; + return CONFIG_INTEGER(bar->filling_left_right); } /* @@ -1253,7 +1251,8 @@ gui_bar_create_option (const char *bar_name, int index_option, const char *value N_("bar filling direction (\"horizontal\" (from left to " "right) or \"vertical\" (from top to bottom)) when bar " "position is top or bottom"), - "horizontal|vertical", 0, 0, value, NULL, + "horizontal|vertical|columns_horizontal|columns_vertical", + 0, 0, value, NULL, NULL, NULL, &gui_bar_config_change_filling, NULL, NULL, NULL); break; case GUI_BAR_OPTION_FILLING_LEFT_RIGHT: @@ -1263,7 +1262,8 @@ gui_bar_create_option (const char *bar_name, int index_option, const char *value N_("bar filling direction (\"horizontal\" (from left to " "right) or \"vertical\" (from top to bottom)) when bar " "position is left or right"), - "horizontal|vertical", 0, 0, value, NULL, + "horizontal|vertical|columns_horizontal|columns_vertical", + 0, 0, value, NULL, NULL, NULL, &gui_bar_config_change_filling, NULL, NULL, NULL); break; case GUI_BAR_OPTION_SIZE: diff --git a/src/gui/gui-bar.h b/src/gui/gui-bar.h index 38fe5865f..deac4c038 100644 --- a/src/gui/gui-bar.h +++ b/src/gui/gui-bar.h @@ -71,6 +71,8 @@ enum t_gui_bar_filling { GUI_BAR_FILLING_HORIZONTAL = 0, GUI_BAR_FILLING_VERTICAL, + GUI_BAR_FILLING_COLUMNS_HORIZONTAL, + GUI_BAR_FILLING_COLUMNS_VERTICAL, /* number of bar positions */ GUI_BAR_NUM_FILLING, }; @@ -124,7 +126,7 @@ extern int gui_bar_valid (struct t_gui_bar *bar); extern int gui_bar_search_option (const char *option_name); extern int gui_bar_search_type (const char *type); extern int gui_bar_search_position (const char *position); -extern struct t_config_option *gui_bar_get_option_filling (struct t_gui_bar *bar); +extern enum t_gui_bar_filling gui_bar_get_filling (struct t_gui_bar *bar); extern int gui_bar_get_item_index (struct t_gui_bar *bar, const char *item_name); extern int gui_bar_check_conditions_for_window (struct t_gui_bar *bar, diff --git a/src/gui/gui-color.h b/src/gui/gui-color.h index 45f571dd9..03cb93a36 100644 --- a/src/gui/gui-color.h +++ b/src/gui/gui-color.h @@ -103,6 +103,8 @@ enum t_gui_color_enum #define GUI_COLOR_BAR_DELIM_STR "D" #define GUI_COLOR_BAR_BG_CHAR 'B' #define GUI_COLOR_BAR_BG_STR "B" +#define GUI_COLOR_BAR_START_INPUT_CHAR '_' +#define GUI_COLOR_BAR_START_INPUT_STR "_" #define GUI_COLOR_BAR_MOVE_CURSOR_CHAR '#' #define GUI_COLOR_BAR_MOVE_CURSOR_STR "#" |