summaryrefslogtreecommitdiff
path: root/plugins/TabSRMM/src/utils.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-02-21 19:50:54 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-02-21 19:50:54 +0000
commit4ba2455da24ecbe9f0c623945e7add2696cdc81b (patch)
tree5de62cb2007f877683f2bec30e4e56c0e6fb7f23 /plugins/TabSRMM/src/utils.cpp
parent09572e85a32464ee117b675e39e3ffa09429a971 (diff)
tabSRMM chats to use the same rtf formatter both for chats & groupchats
git-svn-id: http://svn.miranda-ng.org/main/trunk@12235 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/TabSRMM/src/utils.cpp')
-rw-r--r--plugins/TabSRMM/src/utils.cpp59
1 files changed, 14 insertions, 45 deletions
diff --git a/plugins/TabSRMM/src/utils.cpp b/plugins/TabSRMM/src/utils.cpp
index 5edd2a38b9..84d96a5fbe 100644
--- a/plugins/TabSRMM/src/utils.cpp
+++ b/plugins/TabSRMM/src/utils.cpp
@@ -36,6 +36,19 @@ typedef std::basic_string<TCHAR> tstring;
#define MWF_LOG_TEXTFORMAT 0x2000000
#define MSGDLGFONTCOUNT 22
+static TRTFColorTable _rtf_ctable[] =
+{
+ { _T("red"), RGB(255, 0, 0), ID_FONT_RED },
+ { _T("blue"), RGB(0, 0, 255), ID_FONT_BLUE },
+ { _T("green"), RGB(0, 255, 0), ID_FONT_GREEN },
+ { _T("magenta"), RGB(255, 0, 255), ID_FONT_MAGENTA },
+ { _T("yellow"), RGB(255, 255, 0), ID_FONT_YELLOW },
+ { _T("cyan"), RGB(0, 255, 255), ID_FONT_CYAN },
+ { _T("black"), 0, ID_FONT_BLACK },
+ { _T("white"), RGB(255, 255, 255), ID_FONT_WHITE },
+ { _T(""), 0, 0 }
+};
+
int Utils::rtf_ctable_size = 0;
TRTFColorTable* Utils::rtf_ctable = 0;
@@ -538,56 +551,12 @@ void Utils::RTF_ColorAdd(const TCHAR *tszColname, size_t length)
rtf_ctable = (TRTFColorTable *)mir_realloc(rtf_ctable, sizeof(TRTFColorTable) * rtf_ctable_size);
COLORREF clr = _tcstol(tszColname, &stopped, 16);
mir_sntprintf(rtf_ctable[rtf_ctable_size - 1].szName, length + 1, _T("%06x"), clr);
- rtf_ctable[rtf_ctable_size - 1].menuid = rtf_ctable[rtf_ctable_size - 1].index = 0;
+ rtf_ctable[rtf_ctable_size - 1].menuid = 0;
clr = _tcstol(tszColname, &stopped, 16);
rtf_ctable[rtf_ctable_size - 1].clr = (RGB(GetBValue(clr), GetGValue(clr), GetRValue(clr)));
}
-void Utils::CreateColorMap(CMString &Text)
-{
- const TCHAR *pszText = Text;
- int iIndex = 1, i = 0;
-
- static const TCHAR *lpszFmt = _T("\\red%[^ \x5b\\]\\green%[^ \x5b\\]\\blue%[^ \x5b;];");
- TCHAR szRed[10], szGreen[10], szBlue[10];
-
- const TCHAR *p1 = _tcsstr(pszText, _T("\\colortbl"));
- if (!p1)
- return;
-
- const TCHAR *pEnd = _tcschr(p1, '}');
-
- const TCHAR *p2 = _tcsstr(p1, _T("\\red"));
-
- for (i=0; i < RTF_CTABLE_DEFSIZE; i++)
- rtf_ctable[i].index = 0;
-
- while (p2 && p2 < pEnd) {
- if (_stscanf(p2, lpszFmt, &szRed, &szGreen, &szBlue) > 0) {
- int i;
- for (i=0; i < RTF_CTABLE_DEFSIZE; i++) {
- if (rtf_ctable[i].clr == RGB(_ttoi(szRed), _ttoi(szGreen), _ttoi(szBlue)))
- rtf_ctable[i].index = iIndex;
- }
- }
- iIndex++;
- p1 = p2;
- p1 ++;
-
- p2 = _tcsstr(p1, _T("\\red"));
- }
-}
-
-int Utils::RTFColorToIndex(int iCol)
-{
- for (int i=0; i < RTF_CTABLE_DEFSIZE; i++)
- if (rtf_ctable[i].index == iCol)
- return i + 1;
-
- return 0;
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
// generic error popup dialog procedure