1
0
mirror of https://github.com/irssi/irssi.git synced 2024-10-27 05:20:20 -04:00

Added customization possibility for the lastlog date format, lastlog_date

This commit is contained in:
Vesa Pirila 2015-02-08 16:58:30 +02:00
parent 466166010b
commit cd5a571fd8
4 changed files with 18 additions and 8 deletions

View File

@ -14,7 +14,7 @@
-clear: Removes the previous results from the active window. -clear: Removes the previous results from the active window.
-count: Displays how many lines match. -count: Displays how many lines match.
-case: Performs a case-sensitive matching. -case: Performs a case-sensitive matching.
-date: Prepends each row with the message's date (YYYY-MM-DD). -date: Prepends each row with the message's date
-regexp: The given text pattern is a regular expression. -regexp: The given text pattern is a regular expression.
-word: The text must match full words. -word: The text must match full words.
-force: Forces to display the lastlog, even if it exceeds 1000 lines. -force: Forces to display the lastlog, even if it exceeds 1000 lines.

View File

@ -74,15 +74,23 @@ int cmd_options_get_level(const char *cmd, GHashTable *optlist)
return retlevel; return retlevel;
} }
static void prepend_date(LINE_REC *rec, GString *line) static void prepend_date(WINDOW_REC *window, LINE_REC *rec, GString *line)
{ {
THEME_REC *theme = NULL;
TEXT_DEST_REC dest = {0};
char *format = NULL, datestamp[20] = {0};
struct tm *tm = localtime(&rec->info.time); struct tm *tm = localtime(&rec->info.time);
char timestamp[12]; int ret = 0;
g_snprintf(timestamp, sizeof(timestamp), theme = window->theme != NULL ? window->theme : current_theme;
"%04d-%02d-%02d ", format_create_dest(&dest, NULL, NULL, MSGLEVEL_LASTLOG, window);
tm->tm_year+1900, tm->tm_mon, tm->tm_mday); format = format_get_text_theme(theme, MODULE_NAME, &dest, TXT_LASTLOG_DATE);
g_string_prepend(line, timestamp);
ret = strftime(datestamp, sizeof(datestamp), format, tm);
g_free(format);
if (ret <= 0) return;
g_string_prepend(line, datestamp);
} }
static void show_lastlog(const char *searchtext, GHashTable *optlist, static void show_lastlog(const char *searchtext, GHashTable *optlist,
@ -214,7 +222,7 @@ static void show_lastlog(const char *searchtext, GHashTable *optlist,
} }
if (date == TRUE) if (date == TRUE)
prepend_date(rec, line); prepend_date(window, rec, line);
/* write to file/window */ /* write to file/window */
if (fhandle != NULL) { if (fhandle != NULL) {

View File

@ -33,6 +33,7 @@ FORMAT_REC gui_text_formats[] =
{ "lastlog_start", "{hilight Lastlog}:", 0 }, { "lastlog_start", "{hilight Lastlog}:", 0 },
{ "lastlog_end", "{hilight End of Lastlog}", 0 }, { "lastlog_end", "{hilight End of Lastlog}", 0 },
{ "lastlog_separator", "--", 0 }, { "lastlog_separator", "--", 0 },
{ "lastlog_date", "%%F ", 0 },
/* ---- */ /* ---- */
{ NULL, "Windows", 0 }, { NULL, "Windows", 0 },

View File

@ -10,6 +10,7 @@ enum {
TXT_LASTLOG_START, TXT_LASTLOG_START,
TXT_LASTLOG_END, TXT_LASTLOG_END,
TXT_LASTLOG_SEPARATOR, TXT_LASTLOG_SEPARATOR,
TXT_LASTLOG_DATE,
TXT_FILL_2, TXT_FILL_2,