From cf40caf28964e665c3391d91c64f9ba2c09605a7 Mon Sep 17 00:00:00 2001
From: George Hazan <george.hazan@gmail.com>
Date: Mon, 25 Mar 2024 17:51:50 +0300
Subject: NewStory: new HTML design for quoting

---
 plugins/NewStory/src/fonts.cpp         |  1 +
 plugins/NewStory/src/fonts.h           |  2 +-
 plugins/NewStory/src/history_array.cpp | 16 ++++++++--------
 plugins/NewStory/src/history_array.h   |  2 +-
 plugins/NewStory/src/templates.cpp     |  8 ++++++++
 5 files changed, 19 insertions(+), 10 deletions(-)

(limited to 'plugins/NewStory')

diff --git a/plugins/NewStory/src/fonts.cpp b/plugins/NewStory/src/fonts.cpp
index a85652fdb1..7345202e67 100644
--- a/plugins/NewStory/src/fonts.cpp
+++ b/plugins/NewStory/src/fonts.cpp
@@ -40,6 +40,7 @@ MyColourID g_colorTable[COLOR_COUNT] =
 
 	{ LPGEN("Highlighted messages"),       "ColorHighlight", RGB(0xf0, 0xf0, 0xf0) },
 	{ LPGEN("Grid background"),            "Background",     RGB(0xff, 0xff, 0xff) },
+	{ LPGEN("Quoting"),                    "Quote",          RGB(0x80, 0x80, 0xff) },
 	{ LPGEN("Separator"),                  "Separator",      RGB(0x60, 0x60, 0x60) },
 	{ LPGEN("Progress indicator"),         "Progress",       RGB(0xff, 0x00, 0x00) },
 };
diff --git a/plugins/NewStory/src/fonts.h b/plugins/NewStory/src/fonts.h
index 08183d0d01..78c048a018 100644
--- a/plugins/NewStory/src/fonts.h
+++ b/plugins/NewStory/src/fonts.h
@@ -11,7 +11,7 @@ enum
 	COLOR_STATUS,
 	COLOR_INOTHER, COLOR_OUTOTHER,
 	COLOR_SELTEXT, COLOR_SELBACK, COLOR_SELFRAME,
-	COLOR_HIGHLIGHT_BACK, COLOR_BACK, COLOR_FRAME, COLOR_PROGRESS,
+	COLOR_HIGHLIGHT_BACK, COLOR_BACK, COLOR_QUOTE, COLOR_FRAME, COLOR_PROGRESS,
 	COLOR_COUNT
 };
 
diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp
index d8a9a36a25..191790475c 100644
--- a/plugins/NewStory/src/history_array.cpp
+++ b/plugins/NewStory/src/history_array.cpp
@@ -76,6 +76,7 @@ ItemData::ItemData()
 
 ItemData::~ItemData()
 {
+	mir_free(qtext);
 	mir_free(wtext);
 	if (dbe.szReplyId)
 		mir_free((char*)dbe.szReplyId);
@@ -428,23 +429,22 @@ void ItemData::load(bool bLoadAlways)
 		if (MEVENT hReply = db_event_getById(dbe.szModule, dbe.szReplyId)) {
 			DB::EventInfo dbei(hReply);
 			if (dbei) {
-				CMStringW str(L"> ");
+				CMStringW str;
+
+				wchar_t wszTime[100];
+				TimeZone_PrintTimeStamp(0, dbe.timestamp, L"D t", wszTime, _countof(wszTime), 0);
 
 				if (dbei.flags & DBEF_SENT) {
 					if (char *szProto = Proto_GetBaseAccountName(hContact))
-						str.AppendFormat(L"%s %s: ", ptrW(Contact::GetInfo(CNF_DISPLAY, 0, szProto)).get(), TranslateT("wrote"));
+						str.AppendFormat(L"%s %s %s:\n", wszTime, ptrW(Contact::GetInfo(CNF_DISPLAY, 0, szProto)).get(), TranslateT("wrote"));
 				}
-				else str.AppendFormat(L"%s %s: ", Clist_GetContactDisplayName(hContact, 0), TranslateT("wrote"));
+				else str.AppendFormat(L"%s %s %s:\n", wszTime, Clist_GetContactDisplayName(hContact, 0), TranslateT("wrote"));
 
 				ptrW wszText(DbEvent_GetTextW(&dbei));
 				if (mir_wstrlen(wszText) > 43)
 					wcscpy(wszText.get() + 40, L"...");
 				str.Append(wszText);
-				str.Append(L"\r\n");
-				str.Append(wtext);
-
-				mir_free(wtext);
-				wtext = str.Detach();
+				qtext = str.Detach();
 			}
 		}
 
diff --git a/plugins/NewStory/src/history_array.h b/plugins/NewStory/src/history_array.h
index b94a38888e..9a5e6f52d2 100644
--- a/plugins/NewStory/src/history_array.h
+++ b/plugins/NewStory/src/history_array.h
@@ -22,7 +22,7 @@ struct ItemData
 	int savedTop, savedHeight, leftOffset;
 
 	DB::EventInfo dbe;
-	wchar_t *wtext;
+	wchar_t *wtext, *qtext;
 	wchar_t *wszNick;
 	struct NewstoryListData *pOwner;
 
diff --git a/plugins/NewStory/src/templates.cpp b/plugins/NewStory/src/templates.cpp
index 471b7d1dfd..26032b2fa1 100644
--- a/plugins/NewStory/src/templates.cpp
+++ b/plugins/NewStory/src/templates.cpp
@@ -146,9 +146,17 @@ CMStringW ItemData::formatHtml(const wchar_t *pwszStr)
 	wchar_t szFont[100];
 	str.AppendFormat(L"body {margin: 0px; text-align: left; %s; color: NSText; overflow: auto;}\n", font2html(F.lf, szFont));
 	str.AppendFormat(L".nick {color: #%06X }\n", color2html(g_colorTable[(dbe.flags & DBEF_SENT) ? COLOR_OUTNICK : COLOR_INNICK].cl));
+	if (qtext)
+		str.AppendFormat(L".quote {border-left: 4px solid #%06X; padding-left: 8px; }\n", color2html(g_colorTable[COLOR_QUOTE].cl));
 
 	str.Append(L"</style></head><body class=\"body\">\n");
 
+	if (qtext) {
+		str.Append(L"<div class=\"quote\">");
+		AppendString(str, qtext);
+		str.Append(L"</div>\n");
+	}
+
 	CMStringW wszOrigText((pwszStr) ? pwszStr : formatString());
 
 	SMADD_BATCHPARSE sp = {};
-- 
cgit v1.2.3