diff options
author | George Hazan <george.hazan@gmail.com> | 2014-01-17 20:55:43 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-01-17 20:55:43 +0000 |
commit | 5a2906aae51a358bd3bdbcad336629e9d4449405 (patch) | |
tree | d45b0a39210557a8123531feb05ce84cbb3b2630 /src | |
parent | f6c842738792940ed5b91a5d8977b9e8d20337c0 (diff) |
highlight api unification
git-svn-id: http://svn.miranda-ng.org/main/trunk@7699 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/chat/chat.h | 2 | ||||
-rw-r--r-- | src/modules/chat/chat_svc.cpp | 8 | ||||
-rw-r--r-- | src/modules/chat/manager.cpp | 1 | ||||
-rw-r--r-- | src/modules/chat/tools.cpp | 122 |
4 files changed, 71 insertions, 62 deletions
diff --git a/src/modules/chat/chat.h b/src/modules/chat/chat.h index f4027e4e6b..458926df89 100644 --- a/src/modules/chat/chat.h +++ b/src/modules/chat/chat.h @@ -84,7 +84,7 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlig int GetColorIndex(const char *pszModule, COLORREF cr);
void CheckColorsInModule(const char *pszModule);
int GetRichTextLength(HWND hwnd);
-BOOL IsHighlighted(SESSION_INFO *si, const TCHAR* pszText);
+BOOL IsHighlighted(SESSION_INFO *si, GCEVENT *pszText);
UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *si, TCHAR* pszUID, TCHAR* pszWordText);
void DestroyGCMenu(HMENU *hMenu, int iIndex);
BOOL DoEventHookAsync(HWND hwnd, const TCHAR *pszID, const char *pszModule, int iType, TCHAR* pszUID, TCHAR* pszText, INT_PTR dwItem);
diff --git a/src/modules/chat/chat_svc.cpp b/src/modules/chat/chat_svc.cpp index 514345a7a0..b27525400e 100644 --- a/src/modules/chat/chat_svc.cpp +++ b/src/modules/chat/chat_svc.cpp @@ -431,33 +431,37 @@ static INT_PTR Service_AddEvent(WPARAM wParam, LPARAM lParam) case GC_EVENT_ADDSTATUS:
ci.SM_GiveStatus(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID, gce->ptszStatus);
+ bIsHighlighted = ci.IsHighlighted(NULL, gce);
break;
case GC_EVENT_REMOVESTATUS:
ci.SM_TakeStatus(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID, gce->ptszStatus);
+ bIsHighlighted = ci.IsHighlighted(NULL, gce);
break;
case GC_EVENT_MESSAGE:
case GC_EVENT_ACTION:
if (!gce->bIsMe && gce->pDest->ptszID && gce->ptszText) {
si = ci.SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule);
- if (si && IsHighlighted(si, gce->ptszText))
- bIsHighlighted = TRUE;
+ bIsHighlighted = ci.IsHighlighted(si, gce);
}
break;
case GC_EVENT_NICK:
ci.SM_ChangeNick(gce->pDest->ptszID, gce->pDest->pszModule, gce);
+ bIsHighlighted = ci.IsHighlighted(NULL, gce);
break;
case GC_EVENT_JOIN:
AddUser(gce);
+ bIsHighlighted = ci.IsHighlighted(NULL, gce);
break;
case GC_EVENT_PART:
case GC_EVENT_QUIT:
case GC_EVENT_KICK:
bRemoveFlag = TRUE;
+ bIsHighlighted = ci.IsHighlighted(NULL, gce);
break;
}
diff --git a/src/modules/chat/manager.cpp b/src/modules/chat/manager.cpp index ed081db43a..cdd4cf52d2 100644 --- a/src/modules/chat/manager.cpp +++ b/src/modules/chat/manager.cpp @@ -1475,6 +1475,7 @@ CHAT_MANAGER ci = ShowPopup,
LogToFile,
+ IsHighlighted,
RemoveFormatting,
LoadGlobalSettings
};
diff --git a/src/modules/chat/tools.cpp b/src/modules/chat/tools.cpp index 182861b422..ba036031ca 100644 --- a/src/modules/chat/tools.cpp +++ b/src/modules/chat/tools.cpp @@ -423,77 +423,81 @@ const TCHAR* my_strstri(const TCHAR* s1, const TCHAR* s2) return NULL;
}
-BOOL IsHighlighted(SESSION_INFO *si, const TCHAR* pszText)
+BOOL IsHighlighted(SESSION_INFO *si, GCEVENT *gce)
{
- if (g_Settings->HighlightEnabled && g_Settings->pszHighlightWords && pszText && si->pMe) {
- TCHAR* p1 = g_Settings->pszHighlightWords;
- TCHAR* p2 = NULL;
- const TCHAR* p3 = pszText;
- static TCHAR szWord1[1000];
- static TCHAR szWord2[1000];
- static TCHAR szTrimString[] = _T(":,.!?;\'>)");
-
- // compare word for word
- while (*p1 != '\0') {
- // find the next/first word in the highlight word string
+ if (!g_Settings->HighlightEnabled || !g_Settings->pszHighlightWords || !gce || !si || !si->pMe)
+ return FALSE;
+
+ TCHAR *p1 = g_Settings->pszHighlightWords;
+ TCHAR *p2 = NULL;
+ const TCHAR* p3 = gce->ptszText;
+ if (p3 == NULL)
+ return FALSE;
+
+ static TCHAR szWord1[1000];
+ static TCHAR szWord2[1000];
+ static TCHAR szTrimString[] = _T(":,.!?;\'>)");
+
+ // compare word for word
+ while (*p1 != '\0') {
+ // find the next/first word in the highlight word string
+ // skip 'spaces' be4 the word
+ while (*p1 == ' ' && *p1 != '\0')
+ p1 += 1;
+
+ //find the end of the word
+ p2 = _tcschr(p1, ' ');
+ if (!p2)
+ p2 = _tcschr(p1, '\0');
+ if (p1 == p2)
+ return FALSE;
+
+ // copy the word into szWord1
+ lstrcpyn(szWord1, p1, p2 - p1 > 998 ? 999 : p2 - p1 + 1);
+ p1 = p2;
+
+ // replace %m with the users nickname
+ p2 = _tcschr(szWord1, '%');
+ if (p2 && p2[1] == 'm') {
+ TCHAR szTemp[50];
+
+ p2[1] = 's';
+ lstrcpyn(szTemp, szWord1, 999);
+ mir_sntprintf(szWord1, SIZEOF(szWord1), szTemp, si->pMe->pszNick);
+ }
+
+ // time to get the next/first word in the incoming text string
+ while (*p3 != '\0') {
// skip 'spaces' be4 the word
- while (*p1 == ' ' && *p1 != '\0')
- p1 += 1;
+ while (*p3 == ' ' && *p3 != '\0')
+ p3 += 1;
//find the end of the word
- p2 = _tcschr(p1, ' ');
+ p2 = (TCHAR *)_tcschr(p3, ' ');
if (!p2)
- p2 = _tcschr(p1, '\0');
- if (p1 == p2)
- return FALSE;
-
- // copy the word into szWord1
- lstrcpyn(szWord1, p1, p2 - p1 > 998 ? 999 : p2 - p1 + 1);
- p1 = p2;
-
- // replace %m with the users nickname
- p2 = _tcschr(szWord1, '%');
- if (p2 && p2[1] == 'm') {
- TCHAR szTemp[50];
-
- p2[1] = 's';
- lstrcpyn(szTemp, szWord1, 999);
- mir_sntprintf(szWord1, SIZEOF(szWord1), szTemp, si->pMe->pszNick);
- }
-
- // time to get the next/first word in the incoming text string
- while (*p3 != '\0') {
- // skip 'spaces' be4 the word
- while (*p3 == ' ' && *p3 != '\0')
- p3 += 1;
-
- //find the end of the word
- p2 = (TCHAR *)_tcschr(p3, ' ');
- if (!p2)
- p2 = (TCHAR *)_tcschr(p3, '\0');
+ p2 = (TCHAR *)_tcschr(p3, '\0');
- if (p3 != p2) {
- // eliminate ending character if needed
- if (p2 - p3 > 1 && _tcschr(szTrimString, p2[-1]))
- p2 -= 1;
+ if (p3 != p2) {
+ // eliminate ending character if needed
+ if (p2 - p3 > 1 && _tcschr(szTrimString, p2[-1]))
+ p2 -= 1;
- // copy the word into szWord2 and remove formatting
- lstrcpyn(szWord2, p3, p2 - p3 > 998 ? 999 : p2 - p3 + 1);
+ // copy the word into szWord2 and remove formatting
+ lstrcpyn(szWord2, p3, p2 - p3 > 998 ? 999 : p2 - p3 + 1);
- // reset the pointer if it was touched because of an ending character
- if (*p2 != '\0' && *p2 != ' ')
- p2 += 1;
- p3 = p2;
+ // reset the pointer if it was touched because of an ending character
+ if (*p2 != '\0' && *p2 != ' ')
+ p2 += 1;
+ p3 = p2;
- // compare the words, using wildcards
- if (wildcmpit(szWord1, RemoveFormatting(szWord2)))
- return TRUE;
- }
+ // compare the words, using wildcards
+ if (wildcmpit(szWord1, RemoveFormatting(szWord2)))
+ return TRUE;
}
-
- p3 = pszText;
}
+
+ p3 = gce->ptszText;
}
return FALSE;
|