mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
/SET timestamp_format now specifies format of $Z. timestamp msg format
now uses $Z instead of that horrible $[-2.0]3:$[-2.0]4 that no-one understood :) It's still possible to use the old method too. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1153 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
90e0d79d2a
commit
a4cdb86128
@ -76,7 +76,7 @@ $A .. $Z is important.
|
||||
$W current working directory
|
||||
$X your /userhost $N address (user@host)
|
||||
$Y value of REALNAME
|
||||
$Z time of day (hh:mm)
|
||||
$Z time of day (hh:mm, can be changed with /SET timestamp_format)
|
||||
$$ a literal '$'
|
||||
|
||||
$sysname system name (eg. Linux)
|
||||
|
@ -54,6 +54,7 @@ static time_t client_start_time;
|
||||
static char *last_sent_msg, *last_sent_msg_body;
|
||||
static char *last_privmsg_from, *last_public_from;
|
||||
static char *sysname, *sysrelease;
|
||||
static const char *timestamp_format;
|
||||
|
||||
#define CHAR_EXPANDOS_COUNT \
|
||||
((int) (sizeof(char_expandos) / sizeof(char_expandos[0])))
|
||||
@ -348,12 +349,18 @@ static char *expando_realname(SERVER_REC *server, void *item, int *free_ret)
|
||||
/* time of day (hh:mm) */
|
||||
static char *expando_time(SERVER_REC *server, void *item, int *free_ret)
|
||||
{
|
||||
time_t now = time(NULL);
|
||||
time_t now;
|
||||
struct tm *tm;
|
||||
char str[256];
|
||||
|
||||
now = time(NULL);
|
||||
tm = localtime(&now);
|
||||
|
||||
if (strftime(str, sizeof(str), timestamp_format, tm) == 0)
|
||||
return "";
|
||||
|
||||
*free_ret = TRUE;
|
||||
return g_strdup_printf("%02d:%02d", tm->tm_hour, tm->tm_min);
|
||||
return g_strdup(str);
|
||||
}
|
||||
|
||||
/* a literal '$' */
|
||||
@ -430,12 +437,18 @@ static int sig_timer(void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void read_settings(void)
|
||||
{
|
||||
timestamp_format = settings_get_str("timestamp_format");
|
||||
}
|
||||
|
||||
void expandos_init(void)
|
||||
{
|
||||
#ifdef HAVE_SYS_UTSNAME_H
|
||||
struct utsname un;
|
||||
#endif
|
||||
settings_add_str("misc", "STATUS_OPER", "*");
|
||||
settings_add_str("misc", "timestamp_format", "%H:%M");
|
||||
|
||||
client_start_time = time(NULL);
|
||||
last_sent_msg = NULL; last_sent_msg_body = NULL;
|
||||
@ -525,10 +538,13 @@ void expandos_init(void)
|
||||
"window changed", EXPANDO_ARG_NONE,
|
||||
"window server changed", EXPANDO_ARG_WINDOW, NULL);
|
||||
|
||||
read_settings();
|
||||
|
||||
timer_tag = g_timeout_add(1000, (GSourceFunc) sig_timer, NULL);
|
||||
signal_add("message public", (SIGNAL_FUNC) sig_message_public);
|
||||
signal_add("message private", (SIGNAL_FUNC) sig_message_private);
|
||||
signal_add("message own_private", (SIGNAL_FUNC) sig_message_own_private);
|
||||
signal_add("setup changed", (SIGNAL_FUNC) read_settings);
|
||||
}
|
||||
|
||||
void expandos_deinit(void)
|
||||
@ -554,4 +570,5 @@ void expandos_deinit(void)
|
||||
signal_remove("message public", (SIGNAL_FUNC) sig_message_public);
|
||||
signal_remove("message private", (SIGNAL_FUNC) sig_message_private);
|
||||
signal_remove("message own_private", (SIGNAL_FUNC) sig_message_own_private);
|
||||
signal_remove("setup changed", (SIGNAL_FUNC) read_settings);
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ FORMAT_REC fecommon_core_formats[] = {
|
||||
|
||||
{ "line_start", "{line_start}", 0 },
|
||||
{ "line_start_irssi", "{line_start}{hilight Irssi:} ", 0 },
|
||||
{ "timestamp", "{timestamp $[-2.0]3:$[-2.0]4} ", 6, { 1, 1, 1, 1, 1, 1 } },
|
||||
{ "timestamp", "{timestamp $Z} ", 6, { 1, 1, 1, 1, 1, 1 } },
|
||||
{ "servertag", "[$0] ", 1, { 0 } },
|
||||
{ "daychange", "Day changed to $[-2.0]{0} $3 $2", 4, { 1, 1, 1, 0 } },
|
||||
{ "talking_with", "You are now talking with {nick $0}", 1, { 0 } },
|
||||
|
Loading…
Reference in New Issue
Block a user