summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-02-27 22:22:00 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-02-27 22:22:00 +0300
commitb671f9f84a415206fde423b7dbbe0c15a9ec9b47 (patch)
treec043e1c0fd49be705ab68002f8633e59726ae940 /plugins
parentea5a8c7d51ff9ee1f2abcae19a1a4c29d98a6114 (diff)
SmileyAdd: attempt to fix code insertion
Diffstat (limited to 'plugins')
-rw-r--r--plugins/SmileyAdd/src/smileys.cpp41
1 files changed, 26 insertions, 15 deletions
diff --git a/plugins/SmileyAdd/src/smileys.cpp b/plugins/SmileyAdd/src/smileys.cpp
index 8d6e69845f..16de9ebdf9 100644
--- a/plugins/SmileyAdd/src/smileys.cpp
+++ b/plugins/SmileyAdd/src/smileys.cpp
@@ -294,12 +294,36 @@ void SmileyPackType::AddTriggersToSmileyLookup(void)
}
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static MRegexp16 isCode(L"\\&\\#(\\d*)\\;");
+
+static void replaceCodes(CMStringW &str)
+{
+ if (isCode.match(str) < 0)
+ return;
+
+ str.Delete(isCode.getPos(), isCode.getLength());
+
+ uint32_t iCode = _wtoi(isCode.getGroup(1));
+ wchar_t tmp[3] = { 0, 0, 0 };
+ if (iCode < 0x10000)
+ tmp[0] = LOWORD(iCode), tmp[1] = HIWORD(iCode);
+ else {
+ iCode -= 0x10000;
+ tmp[0] = 0xD800 + (iCode >> 10);
+ tmp[1] = 0xDC00 + (iCode & 0x3FF);
+ }
+ str.Insert(isCode.getPos(), tmp);
+}
+
void SmileyPackType::ReplaceAllSpecials(const CMStringW &Input, CMStringW &Output)
{
Output = Input;
Output.Replace(L"%%_%%", L" ");
Output.Replace(L"%%__%%", L" ");
Output.Replace(L"%%''%%", L"\"");
+ replaceCodes(Output);
}
void SmileyPackType::Clear(void)
@@ -842,8 +866,6 @@ void SmileyCategoryListType::AddAllProtocolsAsCategory(void)
static const CMStringW testString(L"Test String");
-static MRegexp16 isCode(L"\\&\\#(\\d*)\\;");
-
SmileyLookup::SmileyLookup(const CMStringW &str, const bool regexs, const int ind, const CMStringW &smpt)
{
m_ind = ind;
@@ -857,19 +879,8 @@ SmileyLookup::SmileyLookup(const CMStringW &str, const bool regexs, const int in
}
}
else {
- if (isCode.match(str) >= 0) {
- uint32_t iCode = _wtoi(isCode.getGroup(1));
- wchar_t tmp[3] = { 0, 0, 0 };
- if (iCode < 0x10000)
- tmp[0] = LOWORD(iCode), tmp[1] = HIWORD(iCode);
- else {
- iCode -= 0x10000;
- tmp[0] = 0xD800 + (iCode >> 10);
- tmp[1] = 0xDC00 + (iCode & 0x3FF);
- }
- m_text = tmp;
- }
- else m_text = str;
+ m_text = str;
+ replaceCodes(m_text);
m_valid = !str.IsEmpty();
}
}