summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2005-04-09 11:34:15 +0000
committerSebastien Helleu <flashcode@flashtux.org>2005-04-09 11:34:15 +0000
commit5090689a769658cf8a952db4533fe0c3b5ef3202 (patch)
treef1e0379c7dd574bfca392e0a482599e81bf7343e /src
parenta92ca4961b00f2fca61facec743986e89446841f (diff)
downloadweechat-5090689a769658cf8a952db4533fe0c3b5ef3202.zip
Buffers timestamp can now be changed (new option in config file)
Diffstat (limited to 'src')
-rw-r--r--src/common/weeconfig.c5
-rw-r--r--src/common/weeconfig.h1
-rw-r--r--src/gui/curses/gui-display.c68
3 files changed, 59 insertions, 15 deletions
diff --git a/src/common/weeconfig.c b/src/common/weeconfig.c
index 11445dabf..33d9575f1 100644
--- a/src/common/weeconfig.c
+++ b/src/common/weeconfig.c
@@ -66,6 +66,7 @@ char *cfg_look_weechat_slogan;
char *cfg_look_charset_decode;
char *cfg_look_charset_encode;
char *cfg_look_charset_internal;
+char *cfg_look_buffer_timestamp;
int cfg_look_color_nicks;
int cfg_look_color_actions;
int cfg_look_remove_colors_from_msgs;
@@ -112,6 +113,10 @@ t_config_option weechat_options_look[] =
N_("internal WeeChat charset, should be ISO-xxxx even if locale is UTF-8 (if empty, local charset is used)"),
OPTION_TYPE_STRING, 0, 0, 0,
"ISO-8859-1", NULL, NULL, &cfg_look_charset_internal, config_change_buffer_content },
+ { "look_buffer_timestamp", N_("timestamp for buffers"),
+ N_("timestamp for buffers"),
+ OPTION_TYPE_STRING, 0, 0, 0,
+ "[%H:%M:%S]", NULL, NULL, &cfg_look_buffer_timestamp, config_change_buffer_content },
{ "look_color_nicks", N_("display nick names with different colors"),
N_("display nick names with different colors"),
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
diff --git a/src/common/weeconfig.h b/src/common/weeconfig.h
index 1161d95df..99275b659 100644
--- a/src/common/weeconfig.h
+++ b/src/common/weeconfig.h
@@ -83,6 +83,7 @@ extern char *cfg_look_weechat_slogan;
extern char *cfg_look_charset_decode;
extern char *cfg_look_charset_encode;
extern char *cfg_look_charset_internal;
+extern char *cfg_look_buffer_timestamp;
extern int cfg_look_color_nicks;
extern int cfg_look_color_actions;
extern int cfg_look_remove_colors_from_msgs;
diff --git a/src/gui/curses/gui-display.c b/src/gui/curses/gui-display.c
index 4e41b8f48..d290e3fe5 100644
--- a/src/gui/curses/gui-display.c
+++ b/src/gui/curses/gui-display.c
@@ -30,6 +30,7 @@
#include <string.h>
#include <signal.h>
#include <time.h>
+#include <ctype.h>
#include <ncurses.h>
#include "../../common/weechat.h"
@@ -1314,7 +1315,7 @@ gui_draw_buffer_infobar (t_gui_buffer *buffer, int erase)
t_gui_window *ptr_win;
time_t time_seconds;
struct tm *local_time;
- char text[1024 + 1];
+ char text_time[1024 + 1];
/* make gcc happy */
(void) buffer;
@@ -1339,9 +1340,9 @@ gui_draw_buffer_infobar (t_gui_buffer *buffer, int erase)
local_time = localtime (&time_seconds);
if (local_time)
{
- strftime (text, 1024, cfg_look_infobar_timestamp, local_time);
+ strftime (text_time, 1024, cfg_look_infobar_timestamp, local_time);
gui_window_set_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR);
- wprintw (ptr_win->win_infobar, "%s", text);
+ wprintw (ptr_win->win_infobar, "%s", text_time);
}
if (gui_infobar)
{
@@ -2424,7 +2425,11 @@ void
gui_printf_type_color (t_gui_buffer *buffer, int type, int color, char *message, ...)
{
static char buf[8192];
- char timestamp[16];
+ char text_time[1024 + 1];
+ char text_time_char[2];
+ time_t time_seconds;
+ struct tm *local_time;
+ int time_first_digit, time_last_digit;
char *pos, *buf2, *buf3;
int i, j;
va_list argptr;
@@ -2503,19 +2508,52 @@ gui_printf_type_color (t_gui_buffer *buffer, int type, int color, char *message,
pos = buf3 - 1;
while (pos)
{
- /* TODO: read timestamp format from config! */
if ((!buffer->last_line) || (buffer->line_complete))
{
- gui_add_message (buffer, MSG_TYPE_TIME, COLOR_WIN_CHAT_DARK, "[");
- snprintf (timestamp, 16, "%02d", date_tmp->tm_hour);
- gui_add_message (buffer, MSG_TYPE_TIME, COLOR_WIN_CHAT_TIME, timestamp);
- gui_add_message (buffer, MSG_TYPE_TIME, COLOR_WIN_CHAT_TIME_SEP, ":");
- snprintf (timestamp, 16, "%02d", date_tmp->tm_min);
- gui_add_message (buffer, MSG_TYPE_TIME, COLOR_WIN_CHAT_TIME, timestamp);
- gui_add_message (buffer, MSG_TYPE_TIME, COLOR_WIN_CHAT_TIME_SEP, ":");
- snprintf (timestamp, 16, "%02d", date_tmp->tm_sec);
- gui_add_message (buffer, MSG_TYPE_TIME, COLOR_WIN_CHAT_TIME, timestamp);
- gui_add_message (buffer, MSG_TYPE_TIME, COLOR_WIN_CHAT_DARK, "] ");
+ time_seconds = time (NULL);
+ local_time = localtime (&time_seconds);
+ strftime (text_time, 1024, cfg_look_buffer_timestamp, local_time);
+
+ time_first_digit = -1;
+ time_last_digit = -1;
+ i = 0;
+ while (text_time[i])
+ {
+ if (isdigit (text_time[i]))
+ {
+ if (time_first_digit == -1)
+ time_first_digit = i;
+ time_last_digit = i;
+ }
+ i++;
+ }
+
+ text_time_char[1] = '\0';
+ i = 0;
+ while (text_time[i])
+ {
+ text_time_char[0] = text_time[i];
+ if (time_first_digit < 0)
+ gui_add_message (buffer, MSG_TYPE_TIME, COLOR_WIN_CHAT_TIME,
+ text_time_char);
+ else
+ {
+ if ((i < time_first_digit) || (i > time_last_digit))
+ gui_add_message (buffer, MSG_TYPE_TIME, COLOR_WIN_CHAT_DARK,
+ text_time_char);
+ else
+ {
+ if (isdigit (text_time[i]))
+ gui_add_message (buffer, MSG_TYPE_TIME, COLOR_WIN_CHAT_TIME,
+ text_time_char);
+ else
+ gui_add_message (buffer, MSG_TYPE_TIME, COLOR_WIN_CHAT_TIME_SEP,
+ text_time_char);
+ }
+ }
+ i++;
+ }
+ gui_add_message (buffer, MSG_TYPE_TIME, COLOR_WIN_CHAT_DARK, " ");
}
gui_add_message (buffer, type, color, pos + 1);
pos = strchr (pos + 1, '\n');