summaryrefslogtreecommitdiff
path: root/plugins/TabSRMM/src/chat
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/TabSRMM/src/chat')
-rw-r--r--plugins/TabSRMM/src/chat/chat.h4
-rw-r--r--plugins/TabSRMM/src/chat/message.cpp349
-rw-r--r--plugins/TabSRMM/src/chat/tools.cpp4
-rw-r--r--plugins/TabSRMM/src/chat/window.cpp196
4 files changed, 89 insertions, 464 deletions
diff --git a/plugins/TabSRMM/src/chat/chat.h b/plugins/TabSRMM/src/chat/chat.h
index c9427e56d0..01e2481700 100644
--- a/plugins/TabSRMM/src/chat/chat.h
+++ b/plugins/TabSRMM/src/chat/chat.h
@@ -156,10 +156,6 @@ BOOL DoPopup(SESSION_INFO *si, GCEVENT* gce);
int ShowPopup(MCONTACT hContact, SESSION_INFO *si, HICON hIcon, char* pszProtoName, TCHAR* pszRoomName, COLORREF crBkg, const TCHAR* fmt, ...);
BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce);
-// message.c
-char* Chat_Message_GetFromStream(HWND hwndDlg, SESSION_INFO *si);
-TCHAR* Chat_DoRtfToTags(char* pszRtfText, SESSION_INFO *si);
-
#include "chat_resource.h"
extern char szIndicators[];
diff --git a/plugins/TabSRMM/src/chat/message.cpp b/plugins/TabSRMM/src/chat/message.cpp
deleted file mode 100644
index 1aec8c0a66..0000000000
--- a/plugins/TabSRMM/src/chat/message.cpp
+++ /dev/null
@@ -1,349 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////////////////
-// Miranda NG: the free IM client for Microsoft* Windows*
-//
-// Copyright (ñ) 2012-15 Miranda NG project,
-// Copyright (c) 2000-09 Miranda ICQ/IM project,
-// all portions of this codebase are copyrighted to the people
-// listed in contributors.txt.
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// you should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-//
-// part of tabSRMM messaging plugin for Miranda.
-//
-// (C) 2005-2010 by silvercircle _at_ gmail _dot_ com and contributors
-
-#include "..\commonheaders.h"
-
-static int RTFColorToIndex(int *pIndex, int iCol, SESSION_INFO *si)
-{
- int i;
- MODULEINFO *pMod = pci->MM_FindModule(si->pszModule);
-
- for (i=0; i < pMod->nColorCount ; i++)
- if (pIndex[i] == iCol)
- return i;
-
- return -1;
-}
-
-static void CreateColorMap(char* Text, int *pIndex, SESSION_INFO *si)
-{
- char *p1, *p2, *pEnd;
- int iIndex = 1;
-
- static const char* lpszFmt = "\\red%[^ \x5b\\]\\green%[^ \x5b\\]\\blue%[^ \x5b;];";
- char szRed[10], szGreen[10], szBlue[10];
-
- p1 = strstr(Text, "\\colortbl");
- if (!p1)
- return;
-
- pEnd = strchr(p1, '}');
- p2 = strstr(p1, "\\red");
-
- while (p2 && p2 < pEnd) {
- if (sscanf(p2, lpszFmt, &szRed, &szGreen, &szBlue) > 0) {
- MODULEINFO * pMod = pci->MM_FindModule(si->pszModule);
- for (int i=0; i < pMod->nColorCount ; i ++)
- if (pMod->crColors[i] == RGB(atoi(szRed), atoi(szGreen), atoi(szBlue)))
- pIndex[i] = iIndex;
- }
- iIndex++;
- p1 = p2;
- p1 ++;
- p2 = strstr(p1, "\\red");
- }
-}
-
-static int ReadInteger(const char* p, int* result)
-{
- char temp[10];
- int i=0;
- while (isdigit(*p) && i < 9)
- temp[i++] = *p++;
- temp[i] = 0;
-
- if (result != NULL)
- *result = atoi(temp);
-
- return i;
-}
-
-TCHAR* Chat_DoRtfToTags(char* pszText, SESSION_INFO *si)
-{
- int i, iRemoveChars;
- char InsertThis[50];
- BOOL bJustRemovedRTF = TRUE;
- BOOL bTextHasStarted = FALSE;
- int iUcMode = 0;
-
- if (!pszText)
- return FALSE;
-
- // create an index of colors in the module and map them to
- // corresponding colors in the RTF color table
- MODULEINFO *mi = pci->MM_FindModule(si->pszModule);
- mir_ptr<int> pIndex((int*)mir_alloc(sizeof(int)*mi->nColorCount));
- for (i = 0; i < mi->nColorCount; i++)
- pIndex[i] = -1;
-
- CreateColorMap(pszText, pIndex, si);
-
- // scan the file for rtf commands and remove or parse them
- char *p1 = strstr(pszText, "\\ltrpar");
- if (p1 == NULL) {
- if ((p1 = strstr(pszText, "\\pard")) == NULL)
- return FALSE;
- p1 += 5;
- }
- else p1 += 7;
-
- memmove(pszText, p1, mir_strlen(p1) + 1);
- p1 = pszText;
-
- // iterate through all characters, if rtf control character found then take action
- while (*p1 != '\0') {
- InsertThis[0] = 0;
- iRemoveChars = 0;
-
- switch (*p1) {
- case '\\':
- if (!memcmp(p1, "\\cf", 3)) { // foreground color
- int iCol, iInd;
- iRemoveChars = 3 + ReadInteger(p1 + 3, &iCol);
- iInd = RTFColorToIndex(pIndex, iCol, si);
- bJustRemovedRTF = TRUE;
-
- // if (bTextHasStarted || iInd >= 0)
- // mir_snprintf(InsertThis, SIZEOF(InsertThis), (iInd >= 0) ? "%%c%02u" : "%%C", iInd);
- }
- else if (!memcmp(p1, "\\highlight", 10)) { //background color
- int iCol, iInd;
- iRemoveChars = 10 + ReadInteger(p1 + 10, &iCol);
- iInd = RTFColorToIndex(pIndex, iCol, si);
- bJustRemovedRTF = TRUE;
-
- // if (bTextHasStarted || iInd >= 0)
- // mir_snprintf(InsertThis, SIZEOF(InsertThis), (iInd >= 0) ? "%%f%02u" : "%%F", iInd);
- }
- else if (!memcmp(p1, "\\lang", 5)) { // language id
- bTextHasStarted = bJustRemovedRTF = TRUE;
- iRemoveChars = 5 + ReadInteger(p1 + 5, NULL);
- }
- else if (!memcmp(p1, "\\par", 4)) { // newline
- bTextHasStarted = bJustRemovedRTF = TRUE;
- iRemoveChars = 4;
- strcpy(InsertThis, "\n");
- }
- else if (!memcmp(p1, "\\endash", 7)) {
- bTextHasStarted = bJustRemovedRTF = TRUE;
- iRemoveChars = 7;
- strcpy(InsertThis, "\xE2\x80\x93");
- }
- else if (!memcmp(p1, "\\emdash", 7)) {
- bTextHasStarted = bJustRemovedRTF = TRUE;
- iRemoveChars = 7;
- strcpy(InsertThis, "\xE2\x80\x94");
- }
- else if (!memcmp(p1, "\\bullet", 7)) {
- bTextHasStarted = bJustRemovedRTF = TRUE;
- iRemoveChars = 7;
- strcpy(InsertThis, "\xE2\x80\xA2");
- }
- else if (!memcmp(p1, "\\line", 5)) { // newline
- bTextHasStarted = bJustRemovedRTF = TRUE;
- iRemoveChars = 5;
- strcpy(InsertThis, "\n");
- }
- else if (!memcmp(p1, "\\b", 2)) { //bold
- bTextHasStarted = bJustRemovedRTF = TRUE;
- iRemoveChars = (p1[2] != '0') ? 2 : 3;
- strcpy(InsertThis, (p1[2] != '0') ? "%b" : "%B");
- }
- else if (!memcmp(p1, "\\i", 2)) { // italics
- bTextHasStarted = bJustRemovedRTF = TRUE;
- iRemoveChars = (p1[2] != '0') ? 2 : 3;
- strcpy(InsertThis, (p1[2] != '0') ? "%i" : "%I");
- }
- else if (!memcmp(p1, "\\uc", 3)) { // number of Unicode chars
- bTextHasStarted = bJustRemovedRTF = TRUE;
- iUcMode = p1[3] - '0';
- iRemoveChars = 4;
- }
- else if (!memcmp(p1, "\\ul", 3)) { // underlined
- bTextHasStarted = bJustRemovedRTF = TRUE;
- if (p1[3] == 'n')
- iRemoveChars = 7;
- else if (p1[3] == '0')
- iRemoveChars = 4;
- else
- iRemoveChars = 3;
- mir_snprintf(InsertThis, SIZEOF(InsertThis), (p1[3] != '0' && p1[3] != 'n') ? "%%u" : "%%U");
- }
- else if (p1[1] == 'f' && isdigit(p1[2])) { // unicode char
- bTextHasStarted = bJustRemovedRTF = TRUE;
- iRemoveChars = 2 + ReadInteger(p1 + 2, NULL);
- }
- else if (p1[1] == '\\' || p1[1] == '{' || p1[1] == '}') { // escaped characters
- bTextHasStarted = TRUE;
- bJustRemovedRTF = FALSE;
- iRemoveChars = 2;
- mir_snprintf(InsertThis, SIZEOF(InsertThis), "%c", p1[1]);
- }
- else if (p1[1] == '~') { // non-breaking space
- bTextHasStarted = TRUE;
- bJustRemovedRTF = FALSE;
- iRemoveChars = 2;
- strcpy(InsertThis, "\xC2\xA0");
- }
- else if (!memcmp(p1, "\\tab",4)) { // tab
- bTextHasStarted = TRUE;
- bJustRemovedRTF = TRUE;
- iRemoveChars = 4;
- strcpy(InsertThis, "\x09");
- }
- else if (!memcmp(p1, "\\ldblquote",10)) {
- bTextHasStarted = TRUE;
- bJustRemovedRTF = TRUE;
- iRemoveChars = 10;
- strcpy(InsertThis, "\xe2\x80\x9c");
- }
- else if (!memcmp(p1, "\\rdblquote",10)) {
- bTextHasStarted = TRUE;
- bJustRemovedRTF = TRUE;
- iRemoveChars = 10;
- strcpy(InsertThis, "\xe2\x80\x9d");
- }
- else if (!memcmp(p1, "\\lquote",7)) {
- bTextHasStarted = TRUE;
- bJustRemovedRTF = TRUE;
- iRemoveChars = 7;
- strcpy(InsertThis, "\xE2\x80\x98");
- }
- else if (!memcmp(p1, "\\rquote",7)) {
- bTextHasStarted = TRUE;
- bJustRemovedRTF = TRUE;
- iRemoveChars = 7;
- strcpy(InsertThis, "\xE2\x80\x99");
- }
- else if (p1[1] == '\'') { // special character
- char tmp[4], *p3 = tmp;
- bTextHasStarted = TRUE;
- bJustRemovedRTF = FALSE;
- if (p1[2] != ' ' && p1[2] != '\\') {
- *p3++ = p1[2];
- iRemoveChars = 3;
- if (p1[3] != ' ' && p1[3] != '\\') {
- *p3++ = p1[3];
- iRemoveChars++;
- }
- *p3 = 0;
- sscanf(tmp, "%x", InsertThis);
-
- InsertThis[1] = 0;
- }
- else iRemoveChars = 2;
- }
- else if (bJustRemovedRTF) { // remove unknown RTF command
- int j = 1;
- bJustRemovedRTF = TRUE;
- while (p1[j] != ' ' && p1[j] != '\\' && p1[j] != '\0')
- j++;
- iRemoveChars = j;
- }
- break;
-
- case '{': // other RTF control characters
- case '}':
- iRemoveChars = 1;
- break;
-
- case '\r': case '\n':
- bTextHasStarted = TRUE;
- bJustRemovedRTF = FALSE;
- iRemoveChars = 1;
- break;
-
- case '%': // escape chat -> protocol control character
- bTextHasStarted = TRUE;
- bJustRemovedRTF = FALSE;
- iRemoveChars = 1;
- strcpy(InsertThis, "%%");
- break;
-
- case ' ': // remove spaces following a RTF command
- if (bJustRemovedRTF)
- iRemoveChars = 1;
- bJustRemovedRTF = FALSE;
- bTextHasStarted = TRUE;
- break;
-
- default: // other text that should not be touched
- bTextHasStarted = TRUE;
- bJustRemovedRTF = FALSE;
- break;
- }
-
- // move the memory and paste in new commands instead of the old RTF
- if (InsertThis[0] || iRemoveChars) {
- memmove(p1 + mir_strlen(InsertThis) , p1 + iRemoveChars, mir_strlen(p1) - iRemoveChars + 1);
- memcpy(p1, InsertThis, mir_strlen(InsertThis));
- p1 += mir_strlen(InsertThis);
- }
- else p1++;
- }
-
- return mir_utf8decodeW(pszText);
-}
-
-static DWORD CALLBACK Chat_Message_StreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
-{
- static DWORD dwRead;
- char **ppText = (char**)dwCookie;
- if (*ppText == NULL) {
- *ppText = (char *)mir_alloc(cb + 1);
- memcpy(*ppText, pbBuff, cb);
- (*ppText)[cb] = 0;
- *pcb = cb;
- dwRead = cb;
- }
- else {
- char *p = (char*)mir_alloc(dwRead + cb + 1);
- memcpy(p, *ppText, dwRead);
- memcpy(p + dwRead, pbBuff, cb);
- p[dwRead + cb] = 0;
- mir_free(*ppText);
- *ppText = p;
- *pcb = cb;
- dwRead += cb;
- }
- return 0;
-}
-
-char* Chat_Message_GetFromStream(HWND hwndDlg, SESSION_INFO *si)
-{
- if (hwndDlg == 0 || si == 0)
- return NULL;
-
- char* pszText = NULL;
- EDITSTREAM stream;
- memset(&stream, 0, sizeof(stream));
- stream.pfnCallback = Chat_Message_StreamCallback;
- stream.dwCookie = (DWORD_PTR)&pszText; // pass pointer to pointer
-
- DWORD dwFlags = SF_RTFNOOBJS | SFF_PLAINRTF | SF_USECODEPAGE | (CP_UTF8 << 16);
- SendDlgItemMessage(hwndDlg, IDC_CHAT_MESSAGE, EM_STREAMOUT, dwFlags, (LPARAM)&stream);
- return pszText; // pszText contains the text
-}
diff --git a/plugins/TabSRMM/src/chat/tools.cpp b/plugins/TabSRMM/src/chat/tools.cpp
index 1f3ddf7f1b..35d55d78c2 100644
--- a/plugins/TabSRMM/src/chat/tools.cpp
+++ b/plugins/TabSRMM/src/chat/tools.cpp
@@ -266,9 +266,7 @@ void TSAPI DoFlashAndSoundWorker(FLASH_PARAMS* p)
}
}
- /*
- * flash window if it is not focused
- */
+ // flash window if it is not focused
if (p->bMustFlash && p->bInactive)
if (!(dat->pContainer->dwFlags & CNT_NOFLASH))
FlashContainer(dat->pContainer, 1, 0);
diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp
index 7b16eae570..310e5ecfc6 100644
--- a/plugins/TabSRMM/src/chat/window.cpp
+++ b/plugins/TabSRMM/src/chat/window.cpp
@@ -52,12 +52,11 @@ struct MESSAGESUBDATA
const CLSID IID_ITextDocument = { 0x8CC497C0, 0xA1DF, 0x11CE, { 0x80, 0x98, 0x00, 0xAA, 0x00, 0x47, 0xBE, 0x5D } };
-/*
- * checking if theres's protected text at the point
- * emulates EN_LINK WM_NOTIFY to parent to process links
- */
+/////////////////////////////////////////////////////////////////////////////////////////
+// checking if theres's protected text at the point
+// emulates EN_LINK WM_NOTIFY to parent to process links
-static BOOL CheckCustomLink(HWND hwndDlg, POINT* ptClient, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL bUrlNeeded)
+static BOOL CheckCustomLink(HWND hwndDlg, POINT *ptClient, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL bUrlNeeded)
{
long res = 0, cnt = 0;
long cpMin = 0, cpMax = 0;
@@ -131,7 +130,7 @@ static BOOL CheckCustomLink(HWND hwndDlg, POINT* ptClient, UINT uMsg, WPARAM wPa
return bIsCustomLink;
}
-bool IsStringValidLink(TCHAR* pszText)
+bool IsStringValidLink(TCHAR *pszText)
{
if (pszText == NULL)
return false;
@@ -145,10 +144,9 @@ bool IsStringValidLink(TCHAR* pszText)
return _tcsstr(pszText, _T("://")) != NULL;
}
-/*
- * called whenever a group chat tab becomes active (either by switching tabs or activating a
- * container window
- */
+/////////////////////////////////////////////////////////////////////////////////////////
+// called whenever a group chat tab becomes active(either by switching tabs or activating a
+// container window
static void Chat_UpdateWindowState(TWindowData *dat, UINT msg)
{
@@ -255,9 +253,8 @@ static void Chat_UpdateWindowState(TWindowData *dat, UINT msg)
dat->pWnd->Invalidate();
}
-/*
- * initialize button bar, set all the icons and ensure proper button state
- */
+/////////////////////////////////////////////////////////////////////////////////////////
+// initialize button bar, set all the icons and ensure proper button state
static void InitButtons(HWND hwndDlg, SESSION_INFO *si)
{
@@ -296,10 +293,9 @@ static void Chat_ResizeIeView(const TWindowData *dat)
CallService(iMode == 1 ? MS_IEVIEW_WINDOW : MS_HPP_EG_WINDOW, 0, (LPARAM)&ieWindow);
}
-/*
- * resizer callback for the group chat session window. Called from Mirandas dialog
- * resizing service
- */
+/////////////////////////////////////////////////////////////////////////////////////////
+// resizer callback for the group chat session window.Called from Mirandas dialog
+// resizing service
static int RoomWndResize(HWND hwndDlg, LPARAM lParam, UTILRESIZECONTROL *urc)
{
@@ -427,9 +423,8 @@ static int RoomWndResize(HWND hwndDlg, LPARAM lParam, UTILRESIZECONTROL *urc)
return RD_ANCHORX_LEFT | RD_ANCHORY_TOP;
}
-/*
- * subclassing for the message input control (a richedit text control)
- */
+/////////////////////////////////////////////////////////////////////////////////////////
+// subclassing for the message input control(a richedit text control)
static bool TabAutoComplete(HWND hwnd, MESSAGESUBDATA *dat, SESSION_INFO *si)
{
@@ -523,13 +518,13 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
{
HWND hwndParent = GetParent(hwnd);
TWindowData *mwdat = (TWindowData*)GetWindowLongPtr(hwndParent, GWLP_USERDATA);
- SESSION_INFO *Parentsi = (SESSION_INFO*)mwdat->si;
+ SESSION_INFO *si = (SESSION_INFO*)mwdat->si;
- MESSAGESUBDATA *dat = (MESSAGESUBDATA *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
+ MESSAGESUBDATA *dat = (MESSAGESUBDATA*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
if (mwdat->fkeyProcessed && (msg == WM_KEYUP)) {
GetKeyboardState(mwdat->kstate);
- if ( !(mwdat->kstate[VK_CONTROL] & 0x80) && !(mwdat->kstate[VK_SHIFT] & 0x80))
+ if (!(mwdat->kstate[VK_CONTROL] & 0x80) && !(mwdat->kstate[VK_SHIFT] & 0x80))
mwdat->fkeyProcessed = false;
return 0;
}
@@ -542,13 +537,13 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
return CSkin::DrawRichEditFrame(hwnd, mwdat, ID_EXTBKINPUTAREA, msg, wParam, lParam, MessageSubclassProc);
case EM_SUBCLASSED:
- dat = (MESSAGESUBDATA *) mir_calloc(sizeof(MESSAGESUBDATA));
- SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR) dat);
+ dat = (MESSAGESUBDATA*)mir_calloc(sizeof(MESSAGESUBDATA));
+ SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)dat);
return 0;
case WM_CONTEXTMENU:
{
- MODULEINFO *mi = pci->MM_FindModule(Parentsi->pszModule);
+ MODULEINFO *mi = pci->MM_FindModule(si->pszModule);
CHARRANGE sel, all = { 0, -1};
int idFrom = IDC_CHAT_MESSAGE;
@@ -654,7 +649,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
SkinPlaySound("SoundOnTyping");
if (isCtrl && !isAlt && !isShift) {
- MODULEINFO *mi = pci->MM_FindModule(Parentsi->pszModule);
+ MODULEINFO *mi = pci->MM_FindModule(si->pszModule);
switch(wParam) {
case 0x09: // ctrl-i (italics)
@@ -800,7 +795,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
}
if (wParam == VK_TAB && !isCtrl && !isShift) { //tab-autocomplete
SendMessage(hwnd, WM_SETREDRAW, FALSE, 0);
- bool fCompleted = TabAutoComplete(hwnd, dat, Parentsi);
+ bool fCompleted = TabAutoComplete(hwnd, dat, si);
SendMessage(hwnd, WM_SETREDRAW, TRUE, 0);
RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE);
if (!fCompleted && !PluginConfig.m_bAllowTab) {
@@ -831,25 +826,24 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
}
if (wParam == VK_UP && isCtrl && !isAlt) {
- GETTEXTLENGTHEX gtl = {0};
- SETTEXTEX ste;
- LOGFONTA lf;
- char *lpPrevCmd = pci->SM_GetPrevCommand(Parentsi->ptszID, Parentsi->pszModule);
+ char *lpPrevCmd = pci->SM_GetPrevCommand(si->ptszID, si->pszModule);
- if (!Parentsi->lpCurrentCommand || !Parentsi->lpCurrentCommand->last) {
+ if (!si->lpCurrentCommand || !si->lpCurrentCommand->last) {
// Next command is not defined. It means currently entered text is not saved in the history and it
// need to be saved in the window context.
- char *enteredText = Chat_Message_GetFromStream(hwndParent, Parentsi);
- if (mwdat->enteredText) {
+ char *enteredText = Message_GetFromStream(hwndParent);
+ if (mwdat->enteredText)
mir_free(mwdat->enteredText);
- }
mwdat->enteredText = enteredText;
}
SendMessage(hwnd, WM_SETREDRAW, FALSE, 0);
+ LOGFONTA lf;
LoadLogfont(MSGFONTID_MESSAGEAREA, &lf, NULL, FONTMODULE);
+
+ SETTEXTEX ste;
ste.flags = ST_DEFAULT;
ste.codepage = CP_ACP;
if (lpPrevCmd)
@@ -857,6 +851,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
else
SetWindowText(hwnd, _T(""));
+ GETTEXTLENGTHEX gtl = { 0 };
gtl.flags = GTL_PRECISE;
gtl.codepage = CP_ACP;
int iLen = SendMessage(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)&gtl, 0);
@@ -872,7 +867,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
GETTEXTLENGTHEX gtl = {0};
SETTEXTEX ste;
- char *lpPrevCmd = pci->SM_GetNextCommand(Parentsi->ptszID, Parentsi->pszModule);
+ char *lpPrevCmd = pci->SM_GetNextCommand(si->ptszID, si->pszModule);
SendMessage(hwnd, WM_SETREDRAW, FALSE, 0);
ste.flags = ST_DEFAULT;
@@ -914,9 +909,9 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
{
UINT u = 0;
UINT u2 = 0;
- COLORREF cr;
- MODULEINFO *mi = pci->MM_FindModule(Parentsi->pszModule);
+ MODULEINFO *mi = pci->MM_FindModule(si->pszModule);
+ COLORREF cr;
LoadLogfont(MSGFONTID_MESSAGEAREA, NULL, &cr, FONTMODULE);
CHARFORMAT2 cf;
@@ -926,12 +921,12 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
SendMessage(hwnd, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
if (mi && mi->bColor) {
- int index = Chat_GetColorIndex(Parentsi->pszModule, cf.crTextColor);
+ int index = Chat_GetColorIndex(si->pszModule, cf.crTextColor);
u = IsDlgButtonChecked(GetParent(hwnd), IDC_COLOR);
if (index >= 0) {
- Parentsi->bFGSet = TRUE;
- Parentsi->iFG = index;
+ si->bFGSet = TRUE;
+ si->iFG = index;
}
if (u == BST_UNCHECKED && cf.crTextColor != cr)
@@ -941,13 +936,13 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
}
if (mi && mi->bBkgColor) {
- int index = Chat_GetColorIndex(Parentsi->pszModule, cf.crBackColor);
+ int index = Chat_GetColorIndex(si->pszModule, cf.crBackColor);
COLORREF crB = (COLORREF)M.GetDword(FONTMODULE, "inputbg", SRMSGDEFSET_BKGCOLOUR);
u = IsDlgButtonChecked(hwndParent, IDC_BKGCOLOR);
if (index >= 0) {
- Parentsi->bBGSet = TRUE;
- Parentsi->iBG = index;
+ si->bBGSet = TRUE;
+ si->iBG = index;
}
if (u == BST_UNCHECKED && cf.crBackColor != crB)
@@ -999,7 +994,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
break;
case WM_ERASEBKGND:
- return CSkin::m_skinEnabled ? 0 : 1;
+ return !CSkin::m_skinEnabled;
case WM_DESTROY:
mir_free(dat);
@@ -1008,11 +1003,9 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
return mir_callNextSubclass(hwnd, MessageSubclassProc, msg, wParam, lParam);
}
-
-/*
-* subclassing for the message filter dialog (set and configure event filters for the current
-* session
-*/
+/////////////////////////////////////////////////////////////////////////////////////////
+// subclassing for the message filter dialog (set and configure event filters for the
+// current session
static UINT _eventorder[] =
{
@@ -1143,10 +1136,10 @@ static INT_PTR CALLBACK FilterWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP
return FALSE;
}
-/**
- * subclass for some tool bar buttons which must perform special actions
- * on right click.
- */
+/////////////////////////////////////////////////////////////////////////////////////////
+// subclass for some tool bar buttons which must perform special actions
+// on right click.
+
static LRESULT CALLBACK ButtonSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
@@ -1170,9 +1163,8 @@ static LRESULT CALLBACK ButtonSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, L
return mir_callNextSubclass(hwnd, ButtonSubclassProc, msg, wParam, lParam);
}
-/*
- * subclassing for the message history display (rich edit control in which the chat history appears)
- */
+/////////////////////////////////////////////////////////////////////////////////////////
+// subclassing for the message history display(rich edit control in which the chat history appears)
static LRESULT CALLBACK LogSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
@@ -1282,10 +1274,9 @@ static LRESULT CALLBACK LogSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR
return mir_callNextSubclass(hwnd, LogSubclassProc, msg, wParam, lParam);
}
-/*
- * process mouse - hovering for the nickname list. fires events so the protocol can
- * show the userinfo - tooltip.
- */
+/////////////////////////////////////////////////////////////////////////////////////////
+// process mouse - hovering for the nickname list.fires events so the protocol can
+// show the userinfo - tooltip.
static void ProcessNickListHovering(HWND hwnd, int hoveredItem, SESSION_INFO *parentdat)
{
@@ -1353,9 +1344,8 @@ static void ProcessNickListHovering(HWND hwnd, int hoveredItem, SESSION_INFO *pa
SendMessage(hwndToolTip, TTM_SETMAXTIPWIDTH, 0 , 400);
}
-/*
- * subclassing for the nickname list control. It is an ownerdrawn listbox
- */
+/////////////////////////////////////////////////////////////////////////////////////////
+// subclassing for the nickname list control.It is an ownerdrawn listbox
static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
@@ -1464,10 +1454,8 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
case WM_CHAR:
case WM_UNICHAR:
- /*
- * simple incremental search for the user (nick) - list control
- * typing esc or movement keys will clear the current search string
- */
+ // simple incremental search for the user (nick) - list control
+ // typing esc or movement keys will clear the current search string
if (mwdat && mwdat->si) {
SESSION_INFO *si = (SESSION_INFO*)mwdat->si;
if (wParam == 27 && si->szSearch[0]) { // escape - reset everything
@@ -1485,17 +1473,15 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
break;
}
TCHAR szNew[2];
- szNew[0] = (TCHAR) wParam;
+ szNew[0] = (TCHAR)wParam;
szNew[1] = '\0';
_tcscat(si->szSearch, szNew);
}
if (si->szSearch[0]) {
- /*
- * iterate over the (sorted) list of nicknames and search for the
- * string we have
- */
+ // iterate over the (sorted) list of nicknames and search for the
+ // string we have
int i, iItems = SendMessage(hwnd, LB_GETCOUNT, 0, 0);
- for (i=0; i < iItems; i++) {
+ for (i = 0; i < iItems; i++) {
USERINFO *ui = pci->UM_FindUserFromIndex(si->pUsers, i);
if (ui) {
if (!_tcsnicmp(ui->pszNick, si->szSearch, mir_tstrlen(si->szSearch))) {
@@ -1720,10 +1706,9 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
return mir_callNextSubclass(hwnd, NicklistSubclassProc, msg, wParam, lParam);
}
-/*
- * calculate the required rectangle for a string using the given font. This is more
- * precise than using GetTextExtentPoint...()
- */
+/////////////////////////////////////////////////////////////////////////////////////////
+// calculate the required rectangle for a string using the given font. This is more
+// precise than using GetTextExtentPoint...()
int GetTextPixelSize(TCHAR* pszText, HFONT hFont, bool bWidth)
{
@@ -1749,11 +1734,9 @@ static void __cdecl phase2(void * lParam)
PostMessage(si->hWnd, GC_REDRAWLOG3, 0, 0);
}
-
-/*
- * the actual group chat session window procedure. Handles the entire chat session window
- * which is usually a (tabbed) child of a container class window.
- */
+/////////////////////////////////////////////////////////////////////////////////////////
+// the actual group chat session window procedure.Handles the entire chat session window
+// which is usually a (tabbed) child of a container class window.
INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
@@ -2052,7 +2035,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
if (wParam == SIZE_MAXIMIZED)
PostMessage(hwndDlg, GC_SCROLLTOBOTTOM, 0, 0);
- if ( !IsIconic(hwndDlg)) {
+ if (!IsIconic(hwndDlg)) {
int panelHeight = dat->Panel->getHeight() + 1;
UTILRESIZEDIALOG urd = { sizeof(urd) };
@@ -2765,7 +2748,7 @@ LABEL_SHOWWINDOW:
tszTmp = tszAppeal = (TCHAR*)mir_alloc(bufSize * sizeof(TCHAR));
tr2.lpstrText = (LPTSTR) mir_alloc(sizeof(TCHAR) * 2);
if (chr.cpMin) {
- /* prepend nick with space if needed */
+ // prepend nick with space if needed
tr2.chrg.cpMin = chr.cpMin - 1;
tr2.chrg.cpMax = chr.cpMin;
SendDlgItemMessage(hwndDlg, IDC_CHAT_MESSAGE, EM_GETTEXTRANGE, 0, (LPARAM)&tr2);
@@ -2773,15 +2756,15 @@ LABEL_SHOWWINDOW:
*tszTmp++ = _T(' ');
_tcscpy(tszTmp, tr.lpstrText);
}
- else
- /* in the beginning of the message window */
+ else // in the beginning of the message window
mir_sntprintf(tszAppeal, bufSize, tszAplTmpl, tr.lpstrText);
+
st = mir_tstrlen(tszAppeal);
if (chr.cpMax != -1) {
tr2.chrg.cpMin = chr.cpMax;
tr2.chrg.cpMax = chr.cpMax + 1;
- /* if there is no space after selection,
- or there is nothing after selection at all... */
+ // if there is no space after selection,
+ // or there is nothing after selection at all...
if (!SendDlgItemMessage(hwndDlg, IDC_CHAT_MESSAGE, EM_GETTEXTRANGE, 0, (LPARAM)&tr2) || !_istspace(*tr2.lpstrText)) {
tszAppeal[st++] = _T(' ');
tszAppeal[st++] = _T('\0');
@@ -2893,14 +2876,15 @@ LABEL_SHOWWINDOW:
if (GetSendButtonState(hwndDlg) != PBS_DISABLED) {
MODULEINFO *mi = pci->MM_FindModule(si->pszModule);
- ptrA pszRtf(Chat_Message_GetFromStream(hwndDlg, si));
+ ptrA pszRtf(Message_GetFromStream(GetDlgItem(hwndDlg, IDC_CHAT_MESSAGE)));
pci->SM_AddCommand(si->ptszID, si->pszModule, pszRtf);
- ptrT ptszText(Chat_DoRtfToTags(pszRtf, si));
- if (ptszText == NULL)
+ CMString ptszText(ptrT(mir_utf8decodeT(pszRtf)));
+ if (ptszText.IsEmpty())
break;
- rtrimt(ptszText);
+ DoRtfToTags(si->dat, ptszText, mi->nColorCount, mi->crColors);
+ ptszText.Trim();
if (mi && mi->bAckMsg) {
Utils::enableDlgControl(hwndDlg, IDC_CHAT_MESSAGE, false);
@@ -2911,16 +2895,14 @@ LABEL_SHOWWINDOW:
Utils::enableDlgControl(hwndDlg, IDOK, false);
// Typing support for GCW_PRIVMESS sessions
- if (si->iType == GCW_PRIVMESS) {
- if (dat->nTypeMode == PROTOTYPE_SELFTYPING_ON) {
+ if (si->iType == GCW_PRIVMESS)
+ if (dat->nTypeMode == PROTOTYPE_SELFTYPING_ON)
DM_NotifyTyping(dat, PROTOTYPE_SELFTYPING_OFF);
- }
- }
bool fSound = true;
if (ptszText[0] == '/' || si->iType == GCW_SERVER)
fSound = false;
- pci->DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_MESSAGE, NULL, ptszText, 0);
+ pci->DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_MESSAGE, NULL, ptszText.GetBuffer(), 0);
mi->idleTimeStamp = time(0);
mi->lastIdleCheck = 0;
pci->SM_BroadcastMessage(si->pszModule, GC_UPDATESTATUSBAR, 0, 1, TRUE);
@@ -3323,12 +3305,10 @@ LABEL_SHOWWINDOW:
dat->pContainer->iChilds--;
int i = GetTabIndexFromHWND(hwndTab, hwndDlg);
- /*
- * after closing a tab, we need to activate the tab to the left side of
- * the previously open tab.
- * normally, this tab has the same index after the deletion of the formerly active tab
- * unless, of course, we closed the last (rightmost) tab.
- */
+ // after closing a tab, we need to activate the tab to the left side of
+ // the previously open tab.
+ // normally, this tab has the same index after the deletion of the formerly active tab
+ // unless, of course, we closed the last (rightmost) tab.
if (!dat->pContainer->bDontSmartClose && iTabs > 1 && !bForced) {
if (i == iTabs - 1)
i--;
@@ -3336,10 +3316,10 @@ LABEL_SHOWWINDOW:
i++;
TabCtrl_SetCurSel(hwndTab, i);
- TCITEM item = {0};
+ TCITEM item = { 0 };
item.mask = TCIF_PARAM;
- TabCtrl_GetItem(hwndTab, i, &item); // retrieve dialog hwnd for the now active tab...
- dat->pContainer->hwndActive = (HWND) item.lParam;
+ TabCtrl_GetItem(hwndTab, i, &item); // retrieve dialog hwnd for the now active tab...
+ dat->pContainer->hwndActive = (HWND)item.lParam;
SendMessage(dat->pContainer->hwnd, DM_QUERYCLIENTAREA, 0, (LPARAM)&rc);
SetWindowPos(dat->pContainer->hwndActive, HWND_TOP, rc.left, rc.top, (rc.right - rc.left), (rc.bottom - rc.top), SWP_SHOWWINDOW);