1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-29 14:26:39 +02:00

Add property in buffer to hide time for all lines

This commit is contained in:
Sebastien Helleu
2009-03-15 01:30:49 +01:00
parent 86ff3f775c
commit 31e562467e
6 changed files with 78 additions and 7 deletions
+38 -1
View File
@@ -7015,9 +7015,13 @@ int weechat_buffer_get_integer (struct t_gui_buffer *buffer, const char *propert
<entry>number</entry>
<entry>number of buffer (1 to # open buffers)</entry>
</row>
<row>
<entry>num_displayed</entry>
<entry>number of windows displaying buffer</entry>
</row>
<row>
<entry>notify</entry>
<entry>notify level on buffer</entry>
<entry>notify level for buffer</entry>
</row>
<row>
<entry>lines_hidden</entry>
@@ -7026,6 +7030,31 @@ int weechat_buffer_get_integer (struct t_gui_buffer *buffer, const char *propert
(filtered), or 0 if all lines are displayed
</entry>
</row>
<row>
<entry>prefix_max_length</entry>
<entry>max length for prefix in this buffer</entry>
</row>
<row>
<entry>time_for_each_line</entry>
<entry>
1 if time is displayed for each line in buffer
(default), 0 otherwise
</entry>
</row>
<row>
<entry>text_search</entry>
<entry>
text search type: 0 = disabled, 1 = backward, 2 = forward
</entry>
</row>
<row>
<entry>text_search_exact</entry>
<entry>1 if text search is exact (case sensitive)</entry>
</row>
<row>
<entry>text_search_found</entry>
<entry>1 if text found, 0 otherwise</entry>
</row>
</tbody>
</tgroup>
</informaltable>
@@ -7286,6 +7315,14 @@ void weechat_buffer_set (struct t_gui_buffer *buffer, const char *property,
<entry>any string</entry>
<entry>set new title for buffer</entry>
</row>
<row>
<entry>time_for_each_line</entry>
<entry>"0" or "1"</entry>
<entry>
"0" to hide time for all lines in buffer, "1" to
see time for all lines (default for a new buffer)
</entry>
</row>
<row>
<entry>nicklist</entry>
<entry>"0" or "1"</entry>
+2
View File
@@ -351,6 +351,8 @@ upgrade_weechat_read_cb (void *data,
strdup (infolist_string (infolist, "title")) : NULL;
upgrade_current_buffer->first_line_not_read =
infolist_integer (infolist, "first_line_not_read");
upgrade_current_buffer->time_for_each_line =
infolist_integer (infolist, "time_for_each_line");
upgrade_current_buffer->input =
infolist_integer (infolist, "input");
upgrade_current_buffer->input_get_unknown_commands =
+2 -2
View File
@@ -543,7 +543,7 @@ gui_chat_display_time_and_prefix (struct t_gui_window *window,
int i, length_allowed, num_spaces;
/* display time */
if (line->str_time && line->str_time[0])
if (window->buffer->time_for_each_line && (line->str_time && line->str_time[0]))
{
if (!simulate)
gui_window_reset_style (GUI_WINDOW_OBJECTS(window)->win_chat, GUI_COLOR_CHAT);
@@ -728,7 +728,7 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
}
/* calculate marker position (maybe not used for this line!) */
if (line->str_time)
if (window->buffer->time_for_each_line && line->str_time)
read_marker_x = x + gui_chat_strlen_screen (line->str_time);
else
read_marker_x = x;
+29
View File
@@ -316,6 +316,7 @@ gui_buffer_new (struct t_weechat_plugin *plugin,
new_buffer->lines_count = 0;
new_buffer->lines_hidden = 0;
new_buffer->prefix_max_length = 0;
new_buffer->time_for_each_line = 1;
new_buffer->chat_refresh_needed = 2;
/* nicklist */
@@ -540,6 +541,10 @@ gui_buffer_get_integer (struct t_gui_buffer *buffer, const char *property)
return buffer->notify;
else if (string_strcasecmp (property, "lines_hidden") == 0)
return buffer->lines_hidden;
else if (string_strcasecmp (property, "prefix_max_length") == 0)
return buffer->prefix_max_length;
else if (string_strcasecmp (property, "time_for_each_line") == 0)
return buffer->time_for_each_line;
else if (string_strcasecmp (property, "text_search") == 0)
return buffer->text_search;
else if (string_strcasecmp (property, "text_search_exact") == 0)
@@ -682,6 +687,18 @@ gui_buffer_set_title (struct t_gui_buffer *buffer, const char *new_title)
WEECHAT_HOOK_SIGNAL_POINTER, buffer);
}
/*
* gui_buffer_set_time_for_each_line: set flag "time for each line" for a buffer
*/
void
gui_buffer_set_time_for_each_line (struct t_gui_buffer *buffer,
int time_for_each_line)
{
buffer->time_for_each_line = (time_for_each_line) ? 1 : 0;
gui_buffer_ask_chat_refresh (buffer, 2);
}
/*
* gui_buffer_set_nicklist: set nicklist for a buffer
*/
@@ -876,6 +893,13 @@ gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
{
gui_buffer_set_title (buffer, value);
}
else if (string_strcasecmp (property, "time_for_each_line") == 0)
{
error = NULL;
number = strtol (value, &error, 10);
if (error && !error[0])
gui_buffer_set_time_for_each_line (buffer, number);
}
else if (string_strcasecmp (property, "nicklist") == 0)
{
error = NULL;
@@ -1517,6 +1541,10 @@ gui_buffer_add_to_infolist (struct t_infolist *infolist,
return 0;
if (!infolist_new_var_integer (ptr_item, "lines_hidden", buffer->lines_hidden))
return 0;
if (!infolist_new_var_integer (ptr_item, "prefix_max_length", buffer->prefix_max_length))
return 0;
if (!infolist_new_var_integer (ptr_item, "time_for_each_line", buffer->time_for_each_line))
return 0;
if (!infolist_new_var_integer (ptr_item, "nicklist_case_sensitive", buffer->nicklist_case_sensitive))
return 0;
if (!infolist_new_var_integer (ptr_item, "nicklist_display_groups", buffer->nicklist_display_groups))
@@ -1757,6 +1785,7 @@ gui_buffer_print_log ()
log_printf (" lines_count. . . . . . : %d", ptr_buffer->lines_count);
log_printf (" lines_hidden . . . . . : %d", ptr_buffer->lines_hidden);
log_printf (" prefix_max_length. . . : %d", ptr_buffer->prefix_max_length);
log_printf (" time_for_each_line . . : %d", ptr_buffer->time_for_each_line);
log_printf (" chat_refresh_needed. . : %d", ptr_buffer->chat_refresh_needed);
log_printf (" nicklist . . . . . . . : %d", ptr_buffer->nicklist);
log_printf (" nicklist_case_sensitive: %d", ptr_buffer->nicklist_case_sensitive);
+1
View File
@@ -112,6 +112,7 @@ struct t_gui_buffer
int lines_count; /* number of lines in the buffer */
int lines_hidden; /* 1 if at least one line is hidden */
int prefix_max_length; /* length for prefix align */
int time_for_each_line; /* time is displayed for each line? */
int chat_refresh_needed; /* refresh for chat is needed ? */
/* (1=refresh, 2=erase+refresh) */
+6 -4
View File
@@ -380,11 +380,13 @@ int
gui_chat_get_line_align (struct t_gui_buffer *buffer, struct t_gui_line *line,
int with_suffix)
{
int length_suffix;
int time_length, length_suffix;
time_length = (buffer->time_for_each_line) ? gui_chat_time_length : 0;
if (CONFIG_INTEGER(config_look_prefix_align) == CONFIG_LOOK_PREFIX_ALIGN_NONE)
return gui_chat_time_length + 1 + line->prefix_length + 2;
return time_length + 1 + line->prefix_length + 2;
length_suffix = 0;
if (with_suffix)
{
@@ -392,7 +394,7 @@ gui_chat_get_line_align (struct t_gui_buffer *buffer, struct t_gui_line *line,
&& CONFIG_STRING(config_look_prefix_suffix)[0])
length_suffix = gui_chat_strlen_screen (CONFIG_STRING(config_look_prefix_suffix)) + 1;
}
return gui_chat_time_length + ((buffer->prefix_max_length > 0) ? 1 : 0) +
return time_length + ((buffer->prefix_max_length > 0) ? 1 : 0) +
+ (((CONFIG_INTEGER(config_look_prefix_align_max) > 0)
&& (buffer->prefix_max_length > CONFIG_INTEGER(config_look_prefix_align_max))) ?
CONFIG_INTEGER(config_look_prefix_align_max) : buffer->prefix_max_length)