Add option to highlight timestamp added by server.
--- a/mcabber/mcabber/hbuf.h Mon Nov 04 21:48:04 2013 +0100
+++ b/mcabber/mcabber/hbuf.h Thu Apr 03 16:11:16 2014 +0200
@@ -30,6 +30,7 @@
#define HBB_PREFIX_CONT (1U<<13)
#define HBB_PREFIX_RECEIPT (1U<<14)
#define HBB_PREFIX_READMARK (1U<<15)
+#define HBB_PREFIX_DELAYED (1U<<16)
typedef struct {
time_t timestamp;
--- a/mcabber/mcabber/screen.c Mon Nov 04 21:48:04 2013 +0100
+++ b/mcabber/mcabber/screen.c Thu Apr 03 16:11:16 2014 +0200
@@ -440,6 +440,7 @@
"info",
"msgin",
"readmark",
+ "timestamp",
NULL
};
@@ -525,6 +526,10 @@
init_pair(i+1, ((color) ? find_color(color) : COLOR_RED),
find_color(background));
break;
+ case COLOR_TIMESTAMP:
+ init_pair(i+1, ((color) ? find_color(color) : COLOR_WHITE),
+ find_color(background));
+ break;
}
}
for (i = COLOR_max; i < (COLOR_max + COLORS); i++)
@@ -810,6 +815,7 @@
settings_set_guard("color_rostersel", scr_color_guard);
settings_set_guard("color_rosterselmsg", scr_color_guard);
settings_set_guard("color_rosternewmsg", scr_color_guard);
+ settings_set_guard("color_timestamp", scr_color_guard);
getmaxyx(stdscr, maxY, maxX);
Log_Win_Height = DEFAULT_LOG_WIN_HEIGHT;
@@ -1060,13 +1066,14 @@
// scr_line_prefix(line, pref, preflen)
// Use data from the hbb_line structure and write the prefix
// to pref (not exceeding preflen, trailing null byte included).
-void scr_line_prefix(hbb_line *line, char *pref, guint preflen)
+size_t scr_line_prefix(hbb_line *line, char *pref, guint preflen)
{
char date[64];
+ size_t timepreflen = 0;
if (line->timestamp &&
!(line->flags & (HBB_PREFIX_SPECIAL|HBB_PREFIX_CONT))) {
- strftime(date, 30, gettprefix(), localtime(&line->timestamp));
+ timepreflen = strftime(date, 30, gettprefix(), localtime(&line->timestamp));
} else
strcpy(date, " ");
@@ -1108,7 +1115,7 @@
receiptflag = '-';
g_snprintf(pref, preflen, "%s%c%c> ", date, receiptflag, cryptflag);
} else if (line->flags & HBB_PREFIX_SPECIAL) {
- strftime(date, 30, getspectprefix(), localtime(&line->timestamp));
+ timepreflen = strftime(date, 30, getspectprefix(), localtime(&line->timestamp));
g_snprintf(pref, preflen, "%s ", date);
} else {
g_snprintf(pref, preflen, "%s ", date);
@@ -1116,6 +1123,7 @@
} else {
g_snprintf(pref, preflen, " ");
}
+ return timepreflen;
}
// scr_update_window()
@@ -1188,6 +1196,7 @@
// Display the lines
for (n = 0 ; n < CHAT_WIN_HEIGHT; n++) {
+ int timelen;
int winy = n + mark_offset;
wmove(win_entry->win, winy, 0);
line = *(lines+n);
@@ -1210,8 +1219,20 @@
wattrset(win_entry->win, get_color(color));
// Generate the prefix area and display it
- scr_line_prefix(line, pref, prefixwidth);
- wprintw(win_entry->win, pref);
+
+ timelen = scr_line_prefix(line, pref, prefixwidth);
+ if (timelen && line->flags & HBB_PREFIX_DELAYED) {
+ char tmp;
+
+ tmp = pref[timelen];
+ pref[timelen] = '\0';
+ wattrset(win_entry->win, get_color(COLOR_TIMESTAMP));
+ wprintw(win_entry->win, pref);
+ pref[timelen] = tmp;
+ wattrset(win_entry->win, get_color(color));
+ wprintw(win_entry->win, pref+timelen);
+ } else
+ wprintw(win_entry->win, pref);
// Make sure we are at the right position
wmove(win_entry->win, winy, prefixwidth-1);
@@ -2208,7 +2229,10 @@
{
char *xtext;
- if (!timestamp) timestamp = time(NULL);
+ if (!timestamp)
+ timestamp = time(NULL);
+ else
+ prefix_flags |= HBB_PREFIX_DELAYED;
xtext = ut_expand_tabs(text); // Expand tabs and filter out some chars
--- a/mcabber/mcabber/screen.h Mon Nov 04 21:48:04 2013 +0100
+++ b/mcabber/mcabber/screen.h Thu Apr 03 16:11:16 2014 +0200
@@ -51,6 +51,7 @@
COLOR_INFO,
COLOR_MSGIN,
COLOR_READMARK,
+ COLOR_TIMESTAMP,
COLOR_max
};
@@ -129,7 +130,7 @@
guint scr_gettextwidth(void);
guint scr_gettextheight(void);
guint scr_getlogwinheight(void);
-void scr_line_prefix(hbb_line *line, char *prefix, guint preflen);
+size_t scr_line_prefix(hbb_line *line, char *prefix, guint preflen);
void scr_beep(void);
void scr_check_auto_away(int activity);
--- a/mcabber/mcabber/xmpp.c Mon Nov 04 21:48:04 2013 +0100
+++ b/mcabber/mcabber/xmpp.c Thu Apr 03 16:11:16 2014 +0200
@@ -1220,6 +1220,9 @@
res = strchr(bjid, JID_RESOURCE_SEPARATOR);
if (res) *res++ = 0;
+ // Timestamp?
+ timestamp = lm_message_node_get_timestamp(m->node);
+
p = lm_message_node_get_child_value(m->node, "subject");
if (p != NULL) {
if (mstype != LM_MESSAGE_SUB_TYPE_GROUPCHAT) {
@@ -1247,7 +1250,7 @@
else
mbuf = g_strdup_printf("%s has cleared the topic", res);
}
- scr_WriteIncomingMessage(bjid, mbuf, 0,
+ scr_WriteIncomingMessage(bjid, mbuf, timestamp,
HBB_PREFIX_INFO|HBB_PREFIX_NOFLAG, 0);
if (settings_opt_get_int("log_muc_conf"))
hlog_write_message(bjid, 0, -1, mbuf);
@@ -1257,9 +1260,6 @@
}
}
- // Timestamp?
- timestamp = lm_message_node_get_timestamp(m->node);
-
if (mstype == LM_MESSAGE_SUB_TYPE_ERROR) {
x = lm_message_node_get_child(m->node, "error");
display_server_error(x, from);
--- a/mcabber/mcabberrc.example Mon Nov 04 21:48:04 2013 +0100
+++ b/mcabber/mcabberrc.example Thu Apr 03 16:11:16 2014 +0200
@@ -406,6 +406,7 @@
# rosterselmsg:text color of the selected roster item, if there is a new msg
# rosternewmsg: text color of items with unread messages
# readmark: text color of the "read mark" line in buffers
+# timestamp: text color in the chat window for delayed timestamps
#
#set color_background = black
#set color_general = white
@@ -422,6 +423,7 @@
#set color_rosterselmsg = red
#set color_rosternewmsg = red
#set color_readmark = red
+#set color_timestamp = brightblue
# You can color roster items by their status and JID. For example, to have
# all roster items white, just all contacts from jabber.org that are away,