summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-09-25 14:22:41 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-09-25 14:22:41 +0300
commit5017c16a40fec1dfb507a2cdc09bc588c324661e (patch)
tree4a7628a6f437147f01d75ad94df272bbe6f27d43
parent45c5789dd34e1cba557c29483d4f897f4f7b2de0 (diff)
SmileyAdd: emoji smile pack to be used in parallel to any other smile pack
-rw-r--r--plugins/SmileyAdd/src/services.cpp2
-rw-r--r--plugins/SmileyAdd/src/smileyroutines.cpp14
-rw-r--r--plugins/SmileyAdd/src/smileyroutines.h6
-rw-r--r--plugins/SmileyAdd/src/smileys.cpp27
-rw-r--r--plugins/SmileyAdd/src/smileys.h5
-rw-r--r--plugins/SmileyAdd/src/stdafx.h2
6 files changed, 35 insertions, 21 deletions
diff --git a/plugins/SmileyAdd/src/services.cpp b/plugins/SmileyAdd/src/services.cpp
index 4a89feff26..fbbc9398a7 100644
--- a/plugins/SmileyAdd/src/services.cpp
+++ b/plugins/SmileyAdd/src/services.cpp
@@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
-LIST<void> menuHandleArray(5);
+static LIST<void> menuHandleArray(5);
/////////////////////////////////////////////////////////////////////////////////////////
// Service functions
diff --git a/plugins/SmileyAdd/src/smileyroutines.cpp b/plugins/SmileyAdd/src/smileyroutines.cpp
index b3b5137712..8e4445796f 100644
--- a/plugins/SmileyAdd/src/smileyroutines.cpp
+++ b/plugins/SmileyAdd/src/smileyroutines.cpp
@@ -30,7 +30,12 @@ bool g_HiddenTextSupported = true;
const GUID IID_ITextDocument =
{ 0x8CC497C0, 0xA1DF, 0x11CE, { 0x80,0x98,0x00,0xAA,0x00,0x47,0xBE,0x5D } };
-void LookupAllSmileys(SmileyPackType *smileyPack, SmileyPackCType *smileyCPack, const wchar_t *lpstrText, SmileysQueueType &smllist, const bool firstOnly)
+static void LookupAllSmileysWorker(
+ SmileyPackType *smileyPack,
+ SmileyPackCType *smileyCPack,
+ const wchar_t *lpstrText,
+ SmileysQueueType &smllist,
+ const bool firstOnly)
{
if (lpstrText == nullptr || *lpstrText == 0) return;
@@ -144,6 +149,13 @@ void LookupAllSmileys(SmileyPackType *smileyPack, SmileyPackCType *smileyCPack,
delete[] smileys;
}
+void LookupAllSmileys(SmileyPackType *smileyPack, SmileyPackCType *smileyCPack, const wchar_t *lpstrText, SmileysQueueType &smllist, const bool firstOnly)
+{
+ LookupAllSmileysWorker(smileyPack, smileyCPack, lpstrText, smllist, firstOnly);
+
+ if (g_pEmoji && smileyPack != g_pEmoji)
+ LookupAllSmileys(g_pEmoji, smileyCPack, lpstrText, smllist, firstOnly);
+}
void FindSmileyInText(SmileyPackType *smp, const wchar_t *str, unsigned &first, unsigned &size, SmileyType **sml)
{
diff --git a/plugins/SmileyAdd/src/smileyroutines.h b/plugins/SmileyAdd/src/smileyroutines.h
index 2507afc11e..3fa846c054 100644
--- a/plugins/SmileyAdd/src/smileyroutines.h
+++ b/plugins/SmileyAdd/src/smileyroutines.h
@@ -20,20 +20,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef _SMILEYROUTINES_
#define _SMILEYROUTINES_
-typedef struct ReplaceSmileyType_tag
+struct ReplaceSmileyType
{
CHARRANGE loc;
SmileyType *sml;
SmileyCType *smlc;
bool ldspace;
bool trspace;
-} ReplaceSmileyType;
+};
// Queue to store smileys found
typedef SMOBJLIST<ReplaceSmileyType> SmileysQueueType;
-
-
void LookupAllSmileys(SmileyPackType *smileyPack, SmileyPackCType *smileyCPack, const wchar_t *lpstrText, SmileysQueueType &smllist, const bool firstOnly);
void ReplaceSmileys(HWND hwnd, SmileyPackType *smp, SmileyPackCType *smcp, const CHARRANGE &sel, bool useHidden, bool ignoreLast, bool unFreeze, bool fireView = 0);
void ReplaceSmileysWithText(HWND hwnd, CHARRANGE &sel, bool keepFrozen);
diff --git a/plugins/SmileyAdd/src/smileys.cpp b/plugins/SmileyAdd/src/smileys.cpp
index 480cc67db0..6b018f0d8e 100644
--- a/plugins/SmileyAdd/src/smileys.cpp
+++ b/plugins/SmileyAdd/src/smileys.cpp
@@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
+SmileyPackType *g_pEmoji = nullptr;
SmileyPackListType g_SmileyPacks;
SmileyCategoryListType g_SmileyCategories;
@@ -700,8 +701,11 @@ void SmileyCategoryListType::ClearAndLoadAll(void)
{
m_pSmileyPackStore->ClearAndFreeAll();
- for (auto &it : m_SmileyCategories)
+ for (auto &it : m_SmileyCategories) {
it->Load();
+ if (it->GetName() == L"Emoji")
+ g_pEmoji = it->GetSmileyPack();
+ }
}
SmileyCategoryType* SmileyCategoryListType::GetSmileyCategory(const wchar_t *pwszName)
@@ -743,20 +747,19 @@ void SmileyCategoryListType::SaveSettings(void)
void SmileyCategoryListType::AddAndLoad(const wchar_t *name, const wchar_t *displayName)
{
- if (GetSmileyCategory(name) != nullptr)
- return;
-
- AddCategory(name, displayName, smcExt);
-
- // Load only if other smileys have been loaded already
- if (m_SmileyCategories.getCount() > 1)
- m_SmileyCategories[m_SmileyCategories.getCount() - 1].Load();
+ if (auto *pCategory = AddCategory(name, displayName, smcExt))
+ pCategory->Load();
}
-void SmileyCategoryListType::AddCategory(const wchar_t *name, const wchar_t *displayName, SmcType typ, const wchar_t *defaultFilename)
+SmileyCategoryType* SmileyCategoryListType::AddCategory(const wchar_t *name, const wchar_t *displayName, SmcType typ, const wchar_t *defaultFilename)
{
- if (GetSmileyCategory(name) == nullptr)
- m_SmileyCategories.insert(new SmileyCategoryType(m_pSmileyPackStore, name, displayName, defaultFilename, typ));
+ auto *pCategory = GetSmileyCategory(name);
+ if (pCategory == nullptr) {
+ pCategory = new SmileyCategoryType(m_pSmileyPackStore, name, displayName, defaultFilename, typ);
+ m_SmileyCategories.insert(pCategory);
+ }
+
+ return pCategory;
}
bool SmileyCategoryListType::DeleteCustomCategory(int index)
diff --git a/plugins/SmileyAdd/src/smileys.h b/plugins/SmileyAdd/src/smileys.h
index e4a45095b7..56a93ab605 100644
--- a/plugins/SmileyAdd/src/smileys.h
+++ b/plugins/SmileyAdd/src/smileys.h
@@ -283,14 +283,15 @@ class SmileyCategoryListType
public:
void SetSmileyPackStore(SmileyPackListType *pSPS) { m_pSmileyPackStore = pSPS; }
+ SmileyCategoryType* AddCategory(const wchar_t *name, const wchar_t *displayName, SmcType typ, const wchar_t *defaultFilename = L"");
SmileyCategoryType* GetSmileyCategory(const wchar_t *pwszName);
SmileyCategoryType* GetSmileyCategory(unsigned index);
- SmileyPackType* GetSmileyPack(const CMStringW &name);
+ SmileyPackType* GetSmileyPack(const CMStringW &name);
+
SmileyCategoryVectorType& GetSmileyCategoryList(void) { return m_SmileyCategories; }
int NumberOfSmileyCategories(void) { return m_SmileyCategories.getCount(); }
- void AddCategory(const wchar_t *name, const wchar_t *displayName, SmcType typ, const wchar_t *defaultFilename = L"");
void AddAndLoad(const wchar_t *name, const wchar_t *displayName);
void AddAllProtocolsAsCategory(void);
void AddAccountAsCategory(PROTOACCOUNT *acc, const CMStringW &defaultFile);
diff --git a/plugins/SmileyAdd/src/stdafx.h b/plugins/SmileyAdd/src/stdafx.h
index e71104068e..909d296f38 100644
--- a/plugins/SmileyAdd/src/stdafx.h
+++ b/plugins/SmileyAdd/src/stdafx.h
@@ -90,7 +90,7 @@ extern HANDLE g_hevOptionsChanged;
extern HGENMENU hContactMenuItem;
extern SmileyCategoryListType g_SmileyCategories;
extern SmileyPackListType g_SmileyPacks;
-extern LIST<void> menuHandleArray;
+extern SmileyPackType *g_pEmoji;
#define MODULENAME "SmileyAdd"