diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2009-08-29 10:30:25 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2009-08-29 10:30:25 +0200 |
commit | 88b65fe3c21982c166443203d7c9a5a1727622d5 (patch) | |
tree | 9eb43d5731c863a046d19222fd8579aa72da44b0 /src/gui | |
parent | d0b3d4fffe946158d6cca839f9e8bac2f32aa02e (diff) | |
download | weechat-88b65fe3c21982c166443203d7c9a5a1727622d5.zip |
Add new option weechat.look.prefix_buffer_align_max
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/curses/gui-curses-chat.c | 70 | ||||
-rw-r--r-- | src/gui/gui-line.c | 18 |
2 files changed, 70 insertions, 18 deletions
diff --git a/src/gui/curses/gui-curses-chat.c b/src/gui/curses/gui-curses-chat.c index 2c5328051..966d6020b 100644 --- a/src/gui/curses/gui-curses-chat.c +++ b/src/gui/curses/gui-curses-chat.c @@ -579,8 +579,18 @@ gui_chat_display_time_and_prefix (struct t_gui_window *window, GUI_COLOR_CHAT_PREFIX_BUFFER); } + if ((CONFIG_INTEGER(config_look_prefix_buffer_align_max) > 0) + && (CONFIG_INTEGER(config_look_prefix_buffer_align) != CONFIG_LOOK_PREFIX_BUFFER_ALIGN_NONE)) + { + length_allowed = + (mixed_lines->buffer_max_length <= CONFIG_INTEGER(config_look_prefix_buffer_align_max)) ? + mixed_lines->buffer_max_length : CONFIG_INTEGER(config_look_prefix_buffer_align_max); + } + else + length_allowed = mixed_lines->buffer_max_length; + length = gui_chat_strlen_screen (line->data->buffer->short_name); - num_spaces = mixed_lines->buffer_max_length - length; + num_spaces = length_allowed - length; if (CONFIG_INTEGER(config_look_prefix_buffer_align) == CONFIG_LOOK_PREFIX_BUFFER_ALIGN_RIGHT) { @@ -592,26 +602,58 @@ gui_chat_display_time_and_prefix (struct t_gui_window *window, } } - gui_chat_display_word (window, line, - line->data->buffer->short_name, - NULL, 1, num_lines, count, lines_displayed, - simulate); + /* 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)) + { + gui_chat_display_word (window, line, + line->data->buffer->short_name, + line->data->buffer->short_name + + gui_chat_string_real_pos (line->data->buffer->short_name, + length_allowed), + 1, num_lines, count, lines_displayed, + simulate); + } + else + { + gui_chat_display_word (window, line, + line->data->buffer->short_name, + NULL, 1, num_lines, count, lines_displayed, + simulate); + } - if ((CONFIG_INTEGER(config_look_prefix_buffer_align) == CONFIG_LOOK_PREFIX_BUFFER_ALIGN_LEFT) - || ((CONFIG_INTEGER(config_look_prefix_buffer_align) == CONFIG_LOOK_PREFIX_BUFFER_ALIGN_NONE) - && (CONFIG_INTEGER(config_look_prefix_align) != CONFIG_LOOK_PREFIX_ALIGN_NONE))) + if ((CONFIG_INTEGER(config_look_prefix_buffer_align) != CONFIG_LOOK_PREFIX_BUFFER_ALIGN_NONE) + && (num_spaces < 0)) { - for (i = 0; i < num_spaces; i++) + if (!simulate) + { + gui_window_set_weechat_color (GUI_WINDOW_OBJECTS(window)->win_chat, + GUI_COLOR_CHAT_PREFIX_MORE); + } + gui_chat_display_word (window, line, str_plus, + NULL, 1, num_lines, count, lines_displayed, + simulate); + } + else + { + if ((CONFIG_INTEGER(config_look_prefix_buffer_align) == CONFIG_LOOK_PREFIX_BUFFER_ALIGN_LEFT) + || ((CONFIG_INTEGER(config_look_prefix_buffer_align) == CONFIG_LOOK_PREFIX_BUFFER_ALIGN_NONE) + && (CONFIG_INTEGER(config_look_prefix_align) != CONFIG_LOOK_PREFIX_ALIGN_NONE))) + { + for (i = 0; i < num_spaces; i++) + { + gui_chat_display_word (window, line, str_space, + NULL, 1, num_lines, count, lines_displayed, + simulate); + } + } + if (mixed_lines->buffer_max_length > 0) { gui_chat_display_word (window, line, str_space, NULL, 1, num_lines, count, lines_displayed, simulate); } } - - gui_chat_display_word (window, line, str_space, - NULL, 1, num_lines, count, lines_displayed, - simulate); } /* display prefix */ @@ -657,7 +699,7 @@ gui_chat_display_time_and_prefix (struct t_gui_window *window, } } - /* not enough space to display full prefix ? => truncate it! */ + /* not enough space to display full prefix? => truncate it! */ if ((CONFIG_INTEGER(config_look_prefix_align) != CONFIG_LOOK_PREFIX_ALIGN_NONE) && (num_spaces < 0)) { diff --git a/src/gui/gui-line.c b/src/gui/gui-line.c index c6486a10f..93f6ee76e 100644 --- a/src/gui/gui-line.c +++ b/src/gui/gui-line.c @@ -93,15 +93,25 @@ gui_line_get_align (struct t_gui_buffer *buffer, struct t_gui_line *line, /* length of buffer name (when many buffers are merged) */ if (buffer->mixed_lines) { - length_buffer = ((CONFIG_INTEGER(config_look_prefix_buffer_align) == CONFIG_LOOK_PREFIX_ALIGN_NONE) - && (CONFIG_INTEGER(config_look_prefix_align) == CONFIG_LOOK_PREFIX_ALIGN_NONE)) ? - gui_chat_strlen_screen (buffer->short_name) + 1 : buffer->mixed_lines->buffer_max_length + 1; + if ((CONFIG_INTEGER(config_look_prefix_buffer_align) == CONFIG_LOOK_PREFIX_BUFFER_ALIGN_NONE) + && (CONFIG_INTEGER(config_look_prefix_align) == CONFIG_LOOK_PREFIX_ALIGN_NONE)) + length_buffer = gui_chat_strlen_screen (buffer->short_name) + 1; + else + { + if (CONFIG_INTEGER(config_look_prefix_buffer_align) == CONFIG_LOOK_PREFIX_BUFFER_ALIGN_NONE) + length_buffer = buffer->mixed_lines->buffer_max_length + 1; + else + length_buffer = ((CONFIG_INTEGER(config_look_prefix_buffer_align_max) > 0) + && (buffer->mixed_lines->buffer_max_length > CONFIG_INTEGER(config_look_prefix_buffer_align_max))) ? + CONFIG_INTEGER(config_look_prefix_buffer_align_max) + 1 : buffer->mixed_lines->buffer_max_length + 1; + } } else length_buffer = 0; if (CONFIG_INTEGER(config_look_prefix_align) == CONFIG_LOOK_PREFIX_ALIGN_NONE) - return length_time + 1 + length_buffer + line->data->prefix_length + 2; + return length_time + 1 + length_buffer + line->data->prefix_length + + ((line->data->prefix_length > 0) ? 1 : 0); length_suffix = 0; if (with_suffix) |