From 5da58d5849f313d7c4596745cb792296428ea225 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Fri, 30 Jun 2000 19:49:12 +0000 Subject: Added "servertag" format - it's displayed before the message if it comes from a server different than the one active in window, or in all empty windows if you're connected to multiple servers. In "daychange" format you can use $3 to print the current month name. Changed the default to "dd mon yyyy" style. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@397 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/fe-common/core/module-formats.c | 3 ++- src/fe-common/core/module-formats.h | 1 + src/fe-common/core/printtext.c | 16 +++++++++++----- 3 files changed, 14 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/fe-common/core/module-formats.c b/src/fe-common/core/module-formats.c index f7ff757f..45a31ae5 100644 --- a/src/fe-common/core/module-formats.c +++ b/src/fe-common/core/module-formats.c @@ -30,7 +30,8 @@ FORMAT_REC fecommon_core_formats[] = { { "line_start", "%B-%W!%B-%n ", 0 }, { "line_start_irssi", "%B-%W!%B- %WIrssi:%n ", 0 }, { "timestamp", "[$[-2.0]3:$[-2.0]4] ", 6, { 1, 1, 1, 1, 1, 1 } }, - { "daychange", "Day changed to $[-2.0]{0}-$[-2.0]1 $2", 3, { 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 %_$0%_", 1, { 0 } }, { "refnum_too_low", "Window number must be greater than 1", 0 }, { "windowlist_header", "Ref Name Active item Server Level", 0 }, diff --git a/src/fe-common/core/module-formats.h b/src/fe-common/core/module-formats.h index f8249d33..416cb1cf 100644 --- a/src/fe-common/core/module-formats.h +++ b/src/fe-common/core/module-formats.h @@ -8,6 +8,7 @@ enum { IRCTXT_LINE_START, IRCTXT_LINE_START_IRSSI, IRCTXT_TIMESTAMP, + IRCTXT_SERVERTAG, IRCTXT_DAYCHANGE, IRCTXT_TALKING_WITH, IRCTXT_REFNUM_TOO_LOW, diff --git a/src/fe-common/core/printtext.c b/src/fe-common/core/printtext.c index 3b9518bb..40da44e7 100644 --- a/src/fe-common/core/printtext.c +++ b/src/fe-common/core/printtext.c @@ -645,6 +645,7 @@ static void newline(WINDOW_REC *window) static char *get_timestamp(TEXT_DEST_REC *dest) { struct tm *tm; + char month[10]; time_t t; int diff; @@ -661,18 +662,23 @@ static char *get_timestamp(TEXT_DEST_REC *dest) } tm = localtime(&t); + strftime(month, sizeof(month)-1, "%b", tm); return output_format_text(dest, IRCTXT_TIMESTAMP, tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, - tm->tm_hour, tm->tm_min, tm->tm_sec); + tm->tm_hour, tm->tm_min, tm->tm_sec, month); } -static char *get_server_tag(WINDOW_REC *window, SERVER_REC *server) +static char *get_server_tag(TEXT_DEST_REC *dest) { + SERVER_REC *server; + + server = dest->server; + if (server == NULL || servers == NULL || servers->next == NULL || - (window->active != NULL && window->active->server == server)) + (dest->window->active != NULL && dest->window->active->server == server)) return NULL; - return g_strdup_printf("[%s] ", server->tag); + return output_format_text(dest, IRCTXT_SERVERTAG, server->tag); } static void sig_print_text(WINDOW_REC *window, SERVER_REC *server, const char *target, gpointer level, const char *text) @@ -695,7 +701,7 @@ static void sig_print_text(WINDOW_REC *window, SERVER_REC *server, const char *t newline(window); timestamp = get_timestamp(&dest); - servertag = get_server_tag(window, server); + servertag = get_server_tag(&dest); str = g_strconcat(timestamp != NULL ? timestamp : "", servertag != NULL ? servertag : "", text, NULL); -- cgit v1.2.3