summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2009-03-15 01:30:49 +0100
committerSebastien Helleu <flashcode@flashtux.org>2009-03-15 01:30:49 +0100
commit31e562467ef7f331244929d17be8889dc29a1abb (patch)
treec4232af36e71f38fcfe47c2617fd631859c4d4f6
parent86ff3f775c19e2df67457fd0b6fa582378a94818 (diff)
downloadweechat-31e562467ef7f331244929d17be8889dc29a1abb.zip
Add property in buffer to hide time for all lines
-rw-r--r--doc/en/dev/plugin_c_api.en.xml39
-rw-r--r--src/core/wee-upgrade.c2
-rw-r--r--src/gui/curses/gui-curses-chat.c4
-rw-r--r--src/gui/gui-buffer.c29
-rw-r--r--src/gui/gui-buffer.h1
-rw-r--r--src/gui/gui-chat.c10
6 files changed, 78 insertions, 7 deletions
diff --git a/doc/en/dev/plugin_c_api.en.xml b/doc/en/dev/plugin_c_api.en.xml
index f7acfd393..2b8a67194 100644
--- a/doc/en/dev/plugin_c_api.en.xml
+++ b/doc/en/dev/plugin_c_api.en.xml
@@ -7016,8 +7016,12 @@ int weechat_buffer_get_integer (struct t_gui_buffer *buffer, const char *propert
<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>
@@ -7287,6 +7316,14 @@ void weechat_buffer_set (struct t_gui_buffer *buffer, const char *property,
<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>
<entry>
diff --git a/src/core/wee-upgrade.c b/src/core/wee-upgrade.c
index 4cc32d722..34f1f7194 100644
--- a/src/core/wee-upgrade.c
+++ b/src/core/wee-upgrade.c
@@ -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 =
diff --git a/src/gui/curses/gui-curses-chat.c b/src/gui/curses/gui-curses-chat.c
index 2091b8ed9..c89f23186 100644
--- a/src/gui/curses/gui-curses-chat.c
+++ b/src/gui/curses/gui-curses-chat.c
@@ -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;
diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c
index 6144f6071..84aeb528e 100644
--- a/src/gui/gui-buffer.c
+++ b/src/gui/gui-buffer.c
@@ -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)
@@ -683,6 +688,18 @@ gui_buffer_set_title (struct t_gui_buffer *buffer, const char *new_title)
}
/*
+ * 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);
diff --git a/src/gui/gui-buffer.h b/src/gui/gui-buffer.h
index 7572ef614..e39799c01 100644
--- a/src/gui/gui-buffer.h
+++ b/src/gui/gui-buffer.h
@@ -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) */
diff --git a/src/gui/gui-chat.c b/src/gui/gui-chat.c
index 7831b1147..29b96b667 100644
--- a/src/gui/gui-chat.c
+++ b/src/gui/gui-chat.c
@@ -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)