mirror of
https://github.com/weechat/weechat.git
synced 2026-07-03 00:03:12 +02:00
core: add option weechat.look.day_change_message2
The new option weechat.look.day_change_message2 is used to display day change between two messages, with two dates: the new one, and the old one. Example: -- Mon, 02 Sep 2013 (Thu, 22 Aug 2013) --
This commit is contained in:
+15
-1
@@ -100,6 +100,7 @@ struct t_config_option *config_look_command_chars;
|
||||
struct t_config_option *config_look_confirm_quit;
|
||||
struct t_config_option *config_look_day_change;
|
||||
struct t_config_option *config_look_day_change_message;
|
||||
struct t_config_option *config_look_day_change_message2;
|
||||
struct t_config_option *config_look_eat_newline_glitch;
|
||||
struct t_config_option *config_look_emphasized_attributes;
|
||||
struct t_config_option *config_look_highlight;
|
||||
@@ -2072,10 +2073,23 @@ config_weechat_init_options ()
|
||||
weechat_config_file, ptr_section,
|
||||
"day_change_message", "string",
|
||||
/* TRANSLATORS: string "${color:xxx}" must NOT be translated */
|
||||
N_("message displayed when the day has changed (see man strftime for "
|
||||
N_("message displayed when the day has changed, with one date displayed "
|
||||
"(for example at beginning of buffer) (see man strftime for "
|
||||
"date/time specifiers) (note: content is evaluated, so you can use "
|
||||
"colors with format \"${color:xxx}\", see /help eval)"),
|
||||
NULL, 0, 0, "-- %a, %d %b %Y --", NULL, 0, NULL, NULL, &config_change_buffers, NULL, NULL, NULL);
|
||||
config_look_day_change_message2 = config_file_new_option (
|
||||
weechat_config_file, ptr_section,
|
||||
"day_change_message2", "string",
|
||||
/* TRANSLATORS: string "${color:xxx}" must NOT be translated */
|
||||
N_("message displayed when the day has changed, with two dates displayed "
|
||||
"(between two messages); the second date specifiers must start with "
|
||||
"two \"%\" because strftime is called two times on this string "
|
||||
"(see man strftime for date/time specifiers) (note: content is "
|
||||
"evaluated, so you can use colors with format \"${color:xxx}\", "
|
||||
"see /help eval)"),
|
||||
NULL, 0, 0, "-- %%a, %%d %%b %%Y (%a, %d %b %Y) --", NULL, 0, NULL, NULL,
|
||||
&config_change_buffers, NULL, NULL, NULL);
|
||||
config_look_eat_newline_glitch = config_file_new_option (
|
||||
weechat_config_file, ptr_section,
|
||||
"eat_newline_glitch", "boolean",
|
||||
|
||||
@@ -117,6 +117,7 @@ extern struct t_config_option *config_look_command_chars;
|
||||
extern struct t_config_option *config_look_confirm_quit;
|
||||
extern struct t_config_option *config_look_day_change;
|
||||
extern struct t_config_option *config_look_day_change_message;
|
||||
extern struct t_config_option *config_look_day_change_message2;
|
||||
extern struct t_config_option *config_look_eat_newline_glitch;
|
||||
extern struct t_config_option *config_look_emphasized_attributes;
|
||||
extern struct t_config_option *config_look_highlight;
|
||||
|
||||
@@ -594,21 +594,29 @@ gui_chat_display_word (struct t_gui_window *window,
|
||||
|
||||
void
|
||||
gui_chat_display_day_changed (struct t_gui_window *window,
|
||||
struct tm *date, int simulate)
|
||||
struct tm *date1, struct tm *date2,
|
||||
int simulate)
|
||||
{
|
||||
char message[1024], *message_with_color;
|
||||
char temp_message[1024], message[1024], *message_with_color;
|
||||
|
||||
if (simulate)
|
||||
return;
|
||||
|
||||
message_with_color = NULL;
|
||||
|
||||
/* build the message to display */
|
||||
strftime (message, sizeof (message),
|
||||
CONFIG_STRING(config_look_day_change_message), date);
|
||||
if (date1)
|
||||
{
|
||||
strftime (temp_message, sizeof (temp_message),
|
||||
CONFIG_STRING(config_look_day_change_message2), date1);
|
||||
strftime (message, sizeof (message), temp_message, date2);
|
||||
}
|
||||
else
|
||||
{
|
||||
strftime (message, sizeof (message),
|
||||
CONFIG_STRING(config_look_day_change_message), date2);
|
||||
}
|
||||
|
||||
if (strstr (message, "${"))
|
||||
message_with_color = eval_expression (message, NULL, NULL, NULL);
|
||||
message_with_color = (strstr (message, "${")) ?
|
||||
eval_expression (message, NULL, NULL, NULL) : NULL;
|
||||
|
||||
/* display the message */
|
||||
gui_window_coords_init_line (window, window->win_chat_cursor_y);
|
||||
@@ -1241,7 +1249,8 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
|
||||
|| (local_time.tm_mon != local_time2.tm_mon)
|
||||
|| (local_time.tm_year != local_time2.tm_year))
|
||||
{
|
||||
gui_chat_display_day_changed (window, &local_time2, simulate);
|
||||
gui_chat_display_day_changed (window, NULL, &local_time2,
|
||||
simulate);
|
||||
gui_chat_display_new_line (window, num_lines, count,
|
||||
&lines_displayed, simulate);
|
||||
pre_lines_displayed++;
|
||||
@@ -1438,7 +1447,8 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
|
||||
|| (local_time.tm_mon != local_time2.tm_mon)
|
||||
|| (local_time.tm_year != local_time2.tm_year))
|
||||
{
|
||||
gui_chat_display_day_changed (window, &local_time2, simulate);
|
||||
gui_chat_display_day_changed (window, &local_time, &local_time2,
|
||||
simulate);
|
||||
gui_chat_display_new_line (window, num_lines, count,
|
||||
&lines_displayed, simulate);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user