diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/wee-command.c | 113 | ||||
-rw-r--r-- | src/core/wee-command.h | 3 | ||||
-rw-r--r-- | src/core/wee-config.c | 9 | ||||
-rw-r--r-- | src/core/wee-config.h | 1 | ||||
-rw-r--r-- | src/core/wee-util.c | 18 | ||||
-rw-r--r-- | src/core/wee-util.h | 1 | ||||
-rw-r--r-- | src/core/weechat.c | 2 |
7 files changed, 115 insertions, 32 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c index 2e2c48fd1..c862ce858 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -38,12 +38,13 @@ #include "wee-debug.h" #include "wee-hook.h" #include "wee-input.h" +#include "wee-list.h" #include "wee-log.h" #include "wee-proxy.h" #include "wee-string.h" #include "wee-upgrade.h" #include "wee-utf8.h" -#include "wee-list.h" +#include "wee-util.h" #include "../gui/gui-bar.h" #include "../gui/gui-bar-item.h" #include "../gui/gui-buffer.h" @@ -3514,7 +3515,7 @@ command_uptime (void *data, struct t_gui_buffer *buffer, if ((argc >= 2) && (string_strcasecmp (argv[1], "-o") == 0)) { snprintf (string, sizeof (string), - _("WeeChat uptime: %d %s %02d:%02d:%02d, started on %s"), + "WeeChat uptime: %d %s %02d:%02d:%02d, started on %s", day, NG_("day", "days", day), hour, @@ -3524,6 +3525,18 @@ command_uptime (void *data, struct t_gui_buffer *buffer, string[strlen (string) - 1] = '\0'; input_data (buffer, string); } + else if ((argc >= 2) && (string_strcasecmp (argv[1], "-ol") == 0)) + { + snprintf (string, sizeof (string), + _("WeeChat uptime: %d %s %02d:%02d:%02d, started on %s"), + day, + NG_("day", "days", day), + hour, + min, + sec, + util_get_time_string (&weechat_start_time)); + input_data (buffer, string); + } else { gui_chat_printf (NULL, @@ -3544,7 +3557,7 @@ command_uptime (void *data, struct t_gui_buffer *buffer, sec, GUI_COLOR(GUI_COLOR_CHAT), GUI_COLOR(GUI_COLOR_CHAT_BUFFER), - ctime (&weechat_start_time)); + util_get_time_string (&weechat_start_time)); } return WEECHAT_RC_OK; @@ -3556,28 +3569,52 @@ command_uptime (void *data, struct t_gui_buffer *buffer, void command_version_display (struct t_gui_buffer *buffer, - int send_to_buffer_as_input) + int send_to_buffer_as_input, + int translated_string) { char string[512]; if (send_to_buffer_as_input) { - snprintf (string, sizeof (string), - "WeeChat %s [%s %s %s]", - PACKAGE_VERSION, - _("compiled on"), - __DATE__, - __TIME__); - input_data (buffer, string); - if (weechat_upgrade_count > 0) + if (translated_string) { snprintf (string, sizeof (string), - _("Upgraded %d %s, first start: %s"), - weechat_upgrade_count, - NG_("time", "times", weechat_upgrade_count), - ctime (&weechat_start_time)); - string[strlen (string) - 1] = '\0'; + "WeeChat %s [%s %s %s]", + PACKAGE_VERSION, + _("compiled on"), + __DATE__, + __TIME__); input_data (buffer, string); + if (weechat_upgrade_count > 0) + { + snprintf (string, sizeof (string), + _("Upgraded %d %s, first start: %s"), + weechat_upgrade_count, + /* TRANSLATORS: text is: "upgraded xx times" */ + NG_("time", "times", weechat_upgrade_count), + util_get_time_string (&weechat_start_time)); + input_data (buffer, string); + } + } + else + { + snprintf (string, sizeof (string), + "WeeChat %s [%s %s %s]", + PACKAGE_VERSION, + "compiled on", + __DATE__, + __TIME__); + input_data (buffer, string); + if (weechat_upgrade_count > 0) + { + snprintf (string, sizeof (string), + "Upgraded %d %s, first start: %s", + weechat_upgrade_count, + (weechat_upgrade_count > 1) ? "times" : "time", + ctime (&weechat_start_time)); + string[strlen (string) - 1] = '\0'; + input_data (buffer, string); + } } } else @@ -3598,7 +3635,7 @@ command_version_display (struct t_gui_buffer *buffer, weechat_upgrade_count, /* TRANSLATORS: text is: "upgraded xx times" */ NG_("time", "times", weechat_upgrade_count), - ctime (&weechat_start_time)); + util_get_time_string (&weechat_start_time)); } } } @@ -3611,16 +3648,28 @@ int command_version (void *data, struct t_gui_buffer *buffer, int argc, char **argv, char **argv_eol) { - int send_to_buffer_as_input; + int send_to_buffer_as_input, translated_string; /* make C compiler happy */ (void) data; (void) argv_eol; + + send_to_buffer_as_input = 0; + translated_string = 0; + + if (argc >= 2) + { + if (string_strcasecmp (argv[1], "-o") == 0) + send_to_buffer_as_input = 1; + else if (string_strcasecmp (argv[1], "-ol") == 0) + { + send_to_buffer_as_input = 1; + translated_string = 1; + } + } - send_to_buffer_as_input = ((argc >= 2) - && (string_strcasecmp (argv[1], "-o") == 0)); - - command_version_display (buffer, send_to_buffer_as_input); + command_version_display (buffer, send_to_buffer_as_input, + translated_string); return WEECHAT_RC_OK; } @@ -4424,15 +4473,21 @@ command_init () &command_upgrade, NULL); hook_command (NULL, "uptime", N_("show WeeChat uptime"), - N_("[-o]"), - N_("-o: send uptime to current buffer as input"), - "-o", + "[-o | -ol]", + N_(" -o: send uptime to current buffer as input (english " + "string)\n" + "-ol: send uptime to current buffer as input (translated " + "string)"), + "-o|-ol", &command_uptime, NULL); hook_command (NULL, "version", N_("show WeeChat version and compilation date"), - N_("[-o]"), - N_("-o: send version to current buffer as input"), - "-o", + "[-o | -ol]", + N_(" -o: send version to current buffer as input (english " + "string)\n" + "-ol: send version to current buffer as input (translated " + "string)"), + "-o|-ol", &command_version, NULL); hook_command (NULL, "wait", N_("schedule a command execution in future"), diff --git a/src/core/wee-command.h b/src/core/wee-command.h index fab7d1e14..b689add38 100644 --- a/src/core/wee-command.h +++ b/src/core/wee-command.h @@ -27,6 +27,7 @@ extern int command_reload (void *data, struct t_gui_buffer *buffer, extern void command_init (); extern void command_startup (int plugins_looaded); extern void command_version_display (struct t_gui_buffer *buffer, - int send_to_buffer_as_input); + int send_to_buffer_as_input, + int translated_string); #endif /* wee-command.h */ diff --git a/src/core/wee-config.c b/src/core/wee-config.c index 4436a9526..fa8f4a5b7 100644 --- a/src/core/wee-config.c +++ b/src/core/wee-config.c @@ -105,6 +105,7 @@ struct t_config_option *config_look_scroll_amount; struct t_config_option *config_look_scroll_page_percent; struct t_config_option *config_look_search_text_not_found_alert; struct t_config_option *config_look_set_title; +struct t_config_option *config_look_time_format; /* config, colors section */ @@ -1217,7 +1218,7 @@ config_weechat_init_options () config_look_buffer_time_format = config_file_new_option ( weechat_config_file, ptr_section, "buffer_time_format", "string", - N_("time format for buffers"), + N_("time format for each line displayed in buffers"), NULL, 0, 0, "%H:%M:%S", NULL, 0, NULL, NULL, &config_change_buffer_time_format, NULL, NULL, NULL); config_look_color_nicks_number = config_file_new_option ( weechat_config_file, ptr_section, @@ -1430,6 +1431,12 @@ config_weechat_init_options () N_("set title for window (terminal for Curses GUI) with " "name and version"), NULL, 0, 0, "on", NULL, 0, NULL, NULL, &config_change_title, NULL, NULL, NULL); + config_look_time_format = config_file_new_option ( + weechat_config_file, ptr_section, + "time_format", "string", + N_("time format for dates converted to strings and displayed in " + "messages"), + NULL, 0, 0, "%a, %d %b %Y %T", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); /* colors */ ptr_section = config_file_new_section (weechat_config_file, "color", diff --git a/src/core/wee-config.h b/src/core/wee-config.h index 6165f188f..b9337f051 100644 --- a/src/core/wee-config.h +++ b/src/core/wee-config.h @@ -120,6 +120,7 @@ extern struct t_config_option *config_look_scroll_amount; extern struct t_config_option *config_look_scroll_page_percent; extern struct t_config_option *config_look_search_text_not_found_alert; extern struct t_config_option *config_look_set_title; +extern struct t_config_option *config_look_time_format; extern struct t_config_option *config_color_separator; extern struct t_config_option *config_color_bar_more; diff --git a/src/core/wee-util.c b/src/core/wee-util.c index 9918e6d6d..82f565c13 100644 --- a/src/core/wee-util.c +++ b/src/core/wee-util.c @@ -124,6 +124,24 @@ util_get_time_length (const char *time_format) } /* + * util_get_time_string: converts date to a string, using format of option + * weechat.look.time_format (can be localized) + */ + +char * +util_get_time_string (const time_t *date) +{ + struct tm *local_time; + static char text_time[128]; + + local_time = localtime (date); + strftime (text_time, sizeof (text_time), + CONFIG_STRING(config_look_time_format), local_time); + + return text_time; +} + +/* * util_catch_signal: catch a signal */ diff --git a/src/core/wee-util.h b/src/core/wee-util.h index 8a41eb551..5f74e15eb 100644 --- a/src/core/wee-util.h +++ b/src/core/wee-util.h @@ -24,6 +24,7 @@ extern int util_timeval_cmp (struct timeval *tv1, struct timeval *tv2); extern long util_timeval_diff (struct timeval *tv1, struct timeval *tv2); extern void util_timeval_add (struct timeval *tv, long interval); extern int util_get_time_length (const char *time_format); +extern char *util_get_time_string (const time_t *date); extern void util_catch_signal (int signum, void (*handler)(int)); extern int util_mkdir_home (const char *directory, int mode); extern int util_mkdir (const char *directory, int mode); diff --git a/src/core/weechat.c b/src/core/weechat.c index b8eee115f..177b2fc42 100644 --- a/src/core/weechat.c +++ b/src/core/weechat.c @@ -323,7 +323,7 @@ weechat_welcome_message () } if (CONFIG_BOOLEAN(config_startup_display_version)) { - command_version_display (NULL, 0); + command_version_display (NULL, 0, 0); } if (CONFIG_BOOLEAN(config_startup_display_logo) || (CONFIG_STRING(config_startup_weechat_slogan) |