diff options
author | George Hazan <george.hazan@gmail.com> | 2013-07-23 17:58:28 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-07-23 17:58:28 +0000 |
commit | 2476b4957b4a290bcceb40e6b25b4472d9dea22e (patch) | |
tree | 4dd37da0d22618bb9e63bd03d1a02bd5715473e0 /plugins/TabSRMM | |
parent | d0602c28cc309845567dd24b0cfd614ddb0c2784 (diff) |
fix for broken clickable nicks
git-svn-id: http://svn.miranda-ng.org/main/trunk@5457 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/TabSRMM')
-rw-r--r-- | plugins/TabSRMM/src/chat/window.cpp | 61 |
1 files changed, 31 insertions, 30 deletions
diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp index 5e47773b02..98670b688f 100644 --- a/plugins/TabSRMM/src/chat/window.cpp +++ b/plugins/TabSRMM/src/chat/window.cpp @@ -2965,39 +2965,40 @@ LABEL_SHOWWINDOW: }
else if (msg == WM_LBUTTONUP) {
USERINFO *ui = si->pUsers;
- SendDlgItemMessage(hwndDlg, IDC_CHAT_MESSAGE, EM_EXGETSEL, 0, (LPARAM)&chr);
- tszTmp = tszAppeal = (TCHAR *) malloc((lstrlen(tr.lpstrText) + lstrlen(tszAplTmpl) + 3) * sizeof(TCHAR));
- tr2.lpstrText = (LPTSTR) malloc(sizeof(TCHAR) * 2);
- if (chr.cpMin) {
- /* 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);
- if (! _istspace(*tr2.lpstrText))
- *tszTmp++ = _T(' ');
- _tcscpy(tszTmp, tr.lpstrText);
- }
- else
- /* in the beginning of the message window */
- mir_sntprintf(tszAppeal, SIZEOF(tszAppeal), tszAplTmpl, tr.lpstrText);
- st = lstrlen(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 (! SendDlgItemMessage(hwndDlg, IDC_CHAT_MESSAGE, EM_GETTEXTRANGE, 0, (LPARAM)&tr2) || ! _istspace(*tr2.lpstrText)) {
- tszAppeal[st++] = _T(' ');
- tszAppeal[st++] = _T('\0');
- }
- }
- else {
+ SendDlgItemMessage(hwndDlg, IDC_CHAT_MESSAGE, EM_EXGETSEL, 0, (LPARAM)&chr);
+ size_t bufSize = lstrlen(tr.lpstrText) + lstrlen(tszAplTmpl) + 3;
+ tszTmp = tszAppeal = (TCHAR*)malloc(bufSize * sizeof(TCHAR));
+ tr2.lpstrText = (LPTSTR) malloc(sizeof(TCHAR) * 2);
+ if (chr.cpMin) {
+ /* 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);
+ if (! _istspace(*tr2.lpstrText))
+ *tszTmp++ = _T(' ');
+ _tcscpy(tszTmp, tr.lpstrText);
+ }
+ else
+ /* in the beginning of the message window */
+ mir_sntprintf(tszAppeal, bufSize, tszAplTmpl, tr.lpstrText);
+ st = lstrlen(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 (! SendDlgItemMessage(hwndDlg, IDC_CHAT_MESSAGE, EM_GETTEXTRANGE, 0, (LPARAM)&tr2) || ! _istspace(*tr2.lpstrText)) {
tszAppeal[st++] = _T(' ');
tszAppeal[st++] = _T('\0');
}
- SendDlgItemMessage(hwndDlg, IDC_CHAT_MESSAGE, EM_REPLACESEL, FALSE, (LPARAM)tszAppeal);
- free((void*) tr2.lpstrText);
- free((void*) tszAppeal);
+ }
+ else {
+ tszAppeal[st++] = _T(' ');
+ tszAppeal[st++] = _T('\0');
+ }
+ SendDlgItemMessage(hwndDlg, IDC_CHAT_MESSAGE, EM_REPLACESEL, FALSE, (LPARAM)tszAppeal);
+ free((void*) tr2.lpstrText);
+ free((void*) tszAppeal);
}
}
SetFocus(GetDlgItem(hwndDlg, IDC_CHAT_MESSAGE));
|