diff options
author | George Hazan <george.hazan@gmail.com> | 2024-03-02 12:23:13 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-03-02 12:23:13 +0300 |
commit | 93d4fb72168a48d7c6120a2ae31c7964b8631afa (patch) | |
tree | cb32792511bb46611669379482fd9ff644482f13 /plugins | |
parent | c03b642c19a73559520b3ff3b0bd44c009b36709 (diff) |
NewStory: to copy coloured RTF along with Unicode text
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/NewStory/src/history_control.cpp | 2 | ||||
-rw-r--r-- | plugins/NewStory/src/history_control.h | 1 | ||||
-rw-r--r-- | plugins/NewStory/src/templates.cpp | 36 |
3 files changed, 38 insertions, 1 deletions
diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp index a9c543a9f8..c31c0a0e0d 100644 --- a/plugins/NewStory/src/history_control.cpp +++ b/plugins/NewStory/src/history_control.cpp @@ -284,7 +284,7 @@ void NewstoryListData::ClearSelection(int iFirst, int iLast) void NewstoryListData::Copy(bool bTextOnly)
{
- Utils_ClipboardCopy(MClipUnicode(GatherSelected(bTextOnly)));
+ Utils_ClipboardCopy(MClipUnicode(GatherSelected(bTextOnly)) + MClipRtf(GatherSelectedRtf()));
}
void NewstoryListData::CopyPath()
diff --git a/plugins/NewStory/src/history_control.h b/plugins/NewStory/src/history_control.h index 34821bd1e4..9563827aa5 100644 --- a/plugins/NewStory/src/history_control.h +++ b/plugins/NewStory/src/history_control.h @@ -62,6 +62,7 @@ struct NewstoryListData : public MZeroedObject int FindPrev(const wchar_t *pwszText);
void FixScrollPosition(bool bForce = false);
CMStringW GatherSelected(bool bTextOnly);
+ CMStringA GatherSelectedRtf();
ItemData* GetItem(int idx) const;
int GetItemFromPixel(int yPos);
int GetItemHeight(int index);
diff --git a/plugins/NewStory/src/templates.cpp b/plugins/NewStory/src/templates.cpp index d598d9ce99..f55cc5234c 100644 --- a/plugins/NewStory/src/templates.cpp +++ b/plugins/NewStory/src/templates.cpp @@ -121,6 +121,42 @@ CMStringA ItemData::formatRtf(const wchar_t *pwszStr) return buf;
}
+CMStringA NewstoryListData::GatherSelectedRtf()
+{
+ CMStringA buf;
+ buf.Append("{\\rtf1\\ansi\\deff0");
+
+ int eventCount = totalCount;
+ for (int i = 0; i < eventCount; i++) {
+ ItemData *p = GetItem(i);
+ if (!p->m_bSelected)
+ continue;
+
+ buf.Append("{");
+ int fontID, colorID;
+ p->getFontColor(fontID, colorID);
+ auto &F = g_fontTable[fontID];
+ buf.AppendFormat("{\\fonttbl{\\f0\\fnil\\fcharset0 %s;}}", F.lf.lfFaceName);
+
+ COLORREF cr = F.cl;
+ buf.AppendFormat("{\\colortbl \\red%u\\green%u\\blue%u;", GetRValue(cr), GetGValue(cr), GetBValue(cr));
+ cr = g_colorTable[(p->dbe.flags & DBEF_SENT) ? COLOR_OUTNICK : COLOR_INNICK].cl;
+ buf.AppendFormat("\\red%u\\green%u\\blue%u;", GetRValue(cr), GetGValue(cr), GetBValue(cr));
+
+ for (auto cl : g_plugin.clCustom) {
+ cr = (cl == -1) ? 0 : cl;
+ buf.AppendFormat("\\red%u\\green%u\\blue%u;", GetRValue(cr), GetGValue(cr), GetBValue(cr));
+ }
+
+ buf.AppendFormat("}\\uc1\\pard \\cf0\\f0\\b0\\i0\\fs%d ", GetFontHeight(F.lf));
+ AppendUnicodeToBuffer(buf, p->formatString());
+ buf.Append("} \\par");
+ }
+
+ buf.Append("}");
+ return buf;
+}
+
///////////////////////////////////////////////////////////////////////////////
// Template formatting for the control
|