diff options
author | George Hazan <george.hazan@gmail.com> | 2014-01-20 19:41:41 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-01-20 19:41:41 +0000 |
commit | 7df5b961c9a40259a5766b88b9acc8f0e9a67799 (patch) | |
tree | ad1469b56637ddfde0110190cf57e5c974774c0e /plugins/TabSRMM/src/chat | |
parent | 1c8d1e0b8ec71f7a28db457cf77a99614ccfc758 (diff) |
fixes $531 (ability to highlight messages by a role)
git-svn-id: http://svn.miranda-ng.org/main/trunk@7803 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/TabSRMM/src/chat')
-rw-r--r-- | plugins/TabSRMM/src/chat/chat.h | 1 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/log.cpp | 17 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/services.cpp | 19 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/tools.cpp | 38 |
4 files changed, 46 insertions, 29 deletions
diff --git a/plugins/TabSRMM/src/chat/chat.h b/plugins/TabSRMM/src/chat/chat.h index 8c52c06a2e..9d790b55a3 100644 --- a/plugins/TabSRMM/src/chat/chat.h +++ b/plugins/TabSRMM/src/chat/chat.h @@ -166,6 +166,7 @@ int Chat_GetColorIndex(const char* pszModule, COLORREF cr); TCHAR* my_strstri(const TCHAR* s1, const TCHAR* s2);
int GetRichTextLength(HWND hwnd);
BOOL IsHighlighted(SESSION_INFO *si, GCEVENT *pszText);
+char GetIndicator(SESSION_INFO *si, LPCTSTR ptszNick, int *iNickIndex);
UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *si, TCHAR* pszUID, TCHAR* pszWordText);
void DestroyGCMenu(HMENU *hMenu, int iIndex);
void Chat_SetFilters(SESSION_INFO *si);
diff --git a/plugins/TabSRMM/src/chat/log.cpp b/plugins/TabSRMM/src/chat/log.cpp index 45dd01be43..be94f1a5c3 100644 --- a/plugins/TabSRMM/src/chat/log.cpp +++ b/plugins/TabSRMM/src/chat/log.cpp @@ -909,21 +909,8 @@ static char* Log_CreateRTF(LOGSTREAMDATA *streamData) char pszIndicator[3] = "\0\0";
int crNickIndex = 0;
- if (g_Settings.bLogClassicIndicators || g_Settings.bColorizeNicksInLog) {
- USERINFO *ui = streamData->si->pUsers;
- while (ui) {
- if (!lstrcmp(ui->pszNick, lin->ptszNick)) {
- STATUSINFO *ti = pci->TM_FindStatus(streamData->si->pStatuses, pci->TM_WordToString(streamData->si->pStatuses, ui->Status));
- if (ti && (int)ti->hIcon < streamData->si->iStatusCount) {
- pszIndicator[0] = szIndicators[(int)ti->hIcon];
- crNickIndex = streamData->si->iStatusCount - (int)ti->hIcon; // color table's index is not zero-based
- }
- else pszIndicator[0] = 0;
- break;
- }
- ui = ui->next;
- }
- }
+ if (g_Settings.bLogClassicIndicators || g_Settings.bColorizeNicksInLog)
+ pszIndicator[0] = GetIndicator(streamData->si, lin->ptszNick, &crNickIndex);
Log_Append(&buffer, &bufferEnd, &bufferAlloced, "%s ", Log_SetStyle(lin->bIsMe ? 2 : 1, lin->bIsMe ? 2 : 1));
diff --git a/plugins/TabSRMM/src/chat/services.cpp b/plugins/TabSRMM/src/chat/services.cpp index fc0aa1549b..61beccc984 100644 --- a/plugins/TabSRMM/src/chat/services.cpp +++ b/plugins/TabSRMM/src/chat/services.cpp @@ -39,7 +39,7 @@ HWND CreateNewRoom(TContainerData *pContainer, SESSION_INFO *si, BOOL bActivateT if (M.FindWindow(hContact) != 0)
return 0;
- if (hContact != 0 && M.GetByte("limittabs", 0) && !_tcsncmp(pContainer->szName, _T("default"), 6)) {
+ if (hContact != 0 && M.GetByte("limittabs", 0) && !_tcsncmp(pContainer->szName, _T("default"), 6)) {
if ((pContainer = FindMatchingContainer(_T("default"), hContact)) == NULL) {
TCHAR szName[CONTAINER_NAMELEN + 1];
@@ -57,12 +57,9 @@ HWND CreateNewRoom(TContainerData *pContainer, SESSION_INFO *si, BOOL bActivateT TCHAR *contactName = pcli->pfnGetContactDisplayName(newData.hContact, 0);
- /*
- * cut nickname if larger than x chars...
- */
-
+ // cut nickname if larger than x chars...
TCHAR newcontactname[128];
- if ( lstrlen(contactName) > 0) {
+ if (lstrlen(contactName) > 0) {
if (M.GetByte("cuttitle", 0))
CutContactName(contactName, newcontactname, SIZEOF(newcontactname));
else {
@@ -87,7 +84,7 @@ HWND CreateNewRoom(TContainerData *pContainer, SESSION_INFO *si, BOOL bActivateT pContainer->iTabIndex = iCount;
if (iCount > 0) {
- TCITEM item = {0};
+ TCITEM item = { 0 };
for (int i = iCount - 1; i >= 0; i--) {
item.mask = TCIF_PARAM;
TabCtrl_GetItem(hwndTab, i, &item);
@@ -134,7 +131,7 @@ HWND CreateNewRoom(TContainerData *pContainer, SESSION_INFO *si, BOOL bActivateT }
if (bActivateTab) {
if (PluginConfig.m_HideOnClose && !IsWindowVisible(pContainer->hwnd)) {
- WINDOWPLACEMENT wp={0};
+ WINDOWPLACEMENT wp = { 0 };
wp.length = sizeof(wp);
GetWindowPlacement(pContainer->hwnd, &wp);
@@ -158,9 +155,9 @@ HWND CreateNewRoom(TContainerData *pContainer, SESSION_INFO *si, BOOL bActivateT SetForegroundWindow(pContainer->hwnd);
}
}
-
+
if (PluginConfig.m_bIsWin7 && PluginConfig.m_useAeroPeek && CSkin::m_skinEnabled && !M.GetByte("forceAeroPeek", 0))
- CWarning::show(CWarning::WARN_AEROPEEK_SKIN, MB_ICONWARNING|MB_OK);
+ CWarning::show(CWarning::WARN_AEROPEEK_SKIN, MB_ICONWARNING | MB_OK);
return hwndNew; // return handle of the new dialog
}
@@ -173,7 +170,7 @@ void ShowRoom(SESSION_INFO *si, WPARAM wp, BOOL bSetForeground) ActivateExistingTab(si->pContainer, si->hWnd);
return;
}
-
+
TCHAR szName[CONTAINER_NAMELEN + 2]; szName[0] = 0;
TContainerData *pContainer = si->pContainer;
if (pContainer == NULL) {
diff --git a/plugins/TabSRMM/src/chat/tools.cpp b/plugins/TabSRMM/src/chat/tools.cpp index 77a5a4d70d..a70018736a 100644 --- a/plugins/TabSRMM/src/chat/tools.cpp +++ b/plugins/TabSRMM/src/chat/tools.cpp @@ -666,13 +666,45 @@ void Chat_SetFilters(SESSION_INFO *si) si->bFilterEnabled = 0;
}
+char GetIndicator(SESSION_INFO *si, LPCTSTR ptszNick, int *iNickIndex)
+{
+ if (iNickIndex)
+ *iNickIndex = 0;
+
+ for (USERINFO *ui = si->pUsers; ui; ui = ui->next) {
+ if (!lstrcmp(ui->pszNick, ptszNick)) {
+ STATUSINFO *ti = pci->TM_FindStatus(si->pStatuses, pci->TM_WordToString(si->pStatuses, ui->Status));
+ if (ti && (int)ti->hIcon < si->iStatusCount) {
+ if (iNickIndex)
+ *iNickIndex = si->iStatusCount - (int)ti->hIcon; // color table's index is not zero-based
+ return szIndicators[(int)ti->hIcon];
+ }
+ break;
+ }
+ }
+ return 0;
+}
+
BOOL IsHighlighted(SESSION_INFO *si, GCEVENT *gce)
{
if (!g_Settings.bHighlightEnabled || !gce || gce->bIsMe)
return FALSE;
+ GCEVENT evTmp = *gce;
+
int dwMask = 0;
- if (gce->ptszText != NULL) dwMask |= CMUCHighlight::MATCH_TEXT;
- if (gce->ptszNick != NULL) dwMask |= CMUCHighlight::MATCH_NICKNAME;
- return g_Settings.Highlight->match(gce, si, dwMask);
+ if (gce->ptszText != NULL)
+ dwMask |= CMUCHighlight::MATCH_TEXT;
+
+ if (gce->ptszNick != NULL) {
+ dwMask |= CMUCHighlight::MATCH_NICKNAME;
+ if (si && g_Settings.bLogClassicIndicators) {
+ size_t len = _tcslen(gce->ptszNick) + 1;
+ TCHAR *tmp = (TCHAR*)_alloca(sizeof(TCHAR)*(len + 1));
+ *tmp = GetIndicator(si, gce->ptszNick, 0);
+ _tcscpy(tmp + 1, gce->ptszNick);
+ evTmp.ptszNick = tmp;
+ }
+ }
+ return g_Settings.Highlight->match(&evTmp, si, dwMask);
}
|