summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2009-08-29 10:30:25 +0200
committerSebastien Helleu <flashcode@flashtux.org>2009-08-29 10:30:25 +0200
commit88b65fe3c21982c166443203d7c9a5a1727622d5 (patch)
tree9eb43d5731c863a046d19222fd8579aa72da44b0 /src
parentd0b3d4fffe946158d6cca839f9e8bac2f32aa02e (diff)
downloadweechat-88b65fe3c21982c166443203d7c9a5a1727622d5.zip
Add new option weechat.look.prefix_buffer_align_max
Diffstat (limited to 'src')
-rw-r--r--src/core/wee-config.c9
-rw-r--r--src/core/wee-config.h1
-rw-r--r--src/gui/curses/gui-curses-chat.c70
-rw-r--r--src/gui/gui-line.c18
4 files changed, 79 insertions, 19 deletions
diff --git a/src/core/wee-config.c b/src/core/wee-config.c
index 89ea50291..ede6068c2 100644
--- a/src/core/wee-config.c
+++ b/src/core/wee-config.c
@@ -93,6 +93,7 @@ struct t_config_option *config_look_prefix[GUI_CHAT_NUM_PREFIXES];
struct t_config_option *config_look_prefix_align;
struct t_config_option *config_look_prefix_align_max;
struct t_config_option *config_look_prefix_buffer_align;
+struct t_config_option *config_look_prefix_buffer_align_max;
struct t_config_option *config_look_prefix_suffix;
struct t_config_option *config_look_read_marker;
struct t_config_option *config_look_save_config_on_exit;
@@ -1369,13 +1370,19 @@ config_weechat_init_options ()
weechat_config_file, ptr_section,
"prefix_align_max", "integer",
N_("max size for prefix (0 = no max size)"),
- NULL, 0, 64, "0", NULL, 0, NULL, NULL, &config_change_buffers, NULL, NULL, NULL);
+ NULL, 0, 128, "0", NULL, 0, NULL, NULL, &config_change_buffers, NULL, NULL, NULL);
config_look_prefix_buffer_align = config_file_new_option (
weechat_config_file, ptr_section,
"prefix_buffer_align", "integer",
N_("prefix alignment for buffer name, when many buffers are merged "
"with same number (none, left, right (default))"),
"none|left|right", 0, 0, "right", NULL, 0, NULL, NULL, &config_change_buffers, NULL, NULL, NULL);
+ config_look_prefix_buffer_align_max = config_file_new_option (
+ weechat_config_file, ptr_section,
+ "prefix_buffer_align_max", "integer",
+ N_("max size for buffer name, when many buffers are merged with same "
+ "number (0 = no max size)"),
+ NULL, 0, 128, "0", NULL, 0, NULL, NULL, &config_change_buffers, NULL, NULL, NULL);
config_look_prefix_suffix = config_file_new_option (
weechat_config_file, ptr_section,
"prefix_suffix", "string",
diff --git a/src/core/wee-config.h b/src/core/wee-config.h
index b0f14f99b..c5624fd40 100644
--- a/src/core/wee-config.h
+++ b/src/core/wee-config.h
@@ -108,6 +108,7 @@ extern struct t_config_option *config_look_prefix[];
extern struct t_config_option *config_look_prefix_align;
extern struct t_config_option *config_look_prefix_align_max;
extern struct t_config_option *config_look_prefix_buffer_align;
+extern struct t_config_option *config_look_prefix_buffer_align_max;
extern struct t_config_option *config_look_prefix_suffix;
extern struct t_config_option *config_look_read_marker;
extern struct t_config_option *config_look_save_config_on_exit;
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)