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 | |
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')
-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 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgdlgutils.cpp | 29 |
5 files changed, 58 insertions, 46 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);
}
diff --git a/plugins/TabSRMM/src/msgdlgutils.cpp b/plugins/TabSRMM/src/msgdlgutils.cpp index bda8ca2170..11334d4665 100644 --- a/plugins/TabSRMM/src/msgdlgutils.cpp +++ b/plugins/TabSRMM/src/msgdlgutils.cpp @@ -461,40 +461,35 @@ int TSAPI MsgWindowMenuHandler(TWindowData *dat, int selection, int menuId) void TSAPI UpdateReadChars(const TWindowData *dat)
{
-
if (dat && (dat->pContainer->hwndStatus && dat->pContainer->hwndActive == dat->hwnd)) {
TCHAR buf[128];
int len;
- TCHAR szIndicators[20];
- BOOL fCaps, fNum;
-
- szIndicators[0] = 0;
+
if (dat->bType == SESSIONTYPE_CHAT)
len = GetWindowTextLength(GetDlgItem(dat->hwnd, IDC_CHAT_MESSAGE));
else {
- /*
- * retrieve text length in UTF8 bytes, because this is the relevant length for most protocols
- */
- GETTEXTLENGTHEX gtxl = {0};
+ // retrieve text length in UTF8 bytes, because this is the relevant length for most protocols
+ GETTEXTLENGTHEX gtxl = { 0 };
gtxl.codepage = CP_UTF8;
gtxl.flags = GTL_DEFAULT | GTL_PRECISE | GTL_NUMBYTES;
- len = SendDlgItemMessage(dat->hwnd, IDC_MESSAGE, EM_GETTEXTLENGTHEX, (WPARAM)& gtxl, 0);
+ len = SendDlgItemMessage(dat->hwnd, IDC_MESSAGE, EM_GETTEXTLENGTHEX, (WPARAM)>xl, 0);
}
- fCaps = (GetKeyState(VK_CAPITAL) & 1);
- fNum = (GetKeyState(VK_NUMLOCK) & 1);
+ BOOL fCaps = (GetKeyState(VK_CAPITAL) & 1);
+ BOOL fNum = (GetKeyState(VK_NUMLOCK) & 1);
+ TCHAR szBuf[20]; szBuf[0] = 0;
if (dat->fInsertMode)
- lstrcat(szIndicators, _T("O"));
+ lstrcat(szBuf, _T("O"));
if (fCaps)
- lstrcat(szIndicators, _T("C"));
+ lstrcat(szBuf, _T("C"));
if (fNum)
- lstrcat(szIndicators, _T("N"));
+ lstrcat(szBuf, _T("N"));
if (dat->fInsertMode || fCaps || fNum)
- lstrcat(szIndicators, _T(" | "));
+ lstrcat(szBuf, _T(" | "));
- mir_sntprintf(buf, SIZEOF(buf), _T("%s%s %d/%d"), szIndicators, dat->lcID, dat->iOpenJobs, len);
+ mir_sntprintf(buf, SIZEOF(buf), _T("%s%s %d/%d"), szBuf, dat->lcID, dat->iOpenJobs, len);
SendMessage(dat->pContainer->hwndStatus, SB_SETTEXT, 1, (LPARAM)buf);
if (PluginConfig.m_visualMessageSizeIndicator)
InvalidateRect(dat->pContainer->hwndStatus, NULL, FALSE);
|