summaryrefslogtreecommitdiff
path: root/plugins/TabSRMM/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-06-19 17:54:32 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-06-19 17:54:32 +0300
commit1c3bbb283ca5f0d25658e190c4c41a4667f71ff2 (patch)
tree892c6964b7d7c4bd572fbdb9dc8736605471d6c6 /plugins/TabSRMM/src
parent7c711561aa5a124b51df2c1cba138eb518e6aad6 (diff)
nick search went to core
Diffstat (limited to 'plugins/TabSRMM/src')
-rw-r--r--plugins/TabSRMM/src/msgdialog.cpp57
-rw-r--r--plugins/TabSRMM/src/msgdlgother.cpp8
-rw-r--r--plugins/TabSRMM/src/msgs.h2
3 files changed, 4 insertions, 63 deletions
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp
index a93a455a2a..02b5eb8de5 100644
--- a/plugins/TabSRMM/src/msgdialog.cpp
+++ b/plugins/TabSRMM/src/msgdialog.cpp
@@ -1976,63 +1976,6 @@ LRESULT CMsgDialog::WndProc_Nicklist(UINT msg, WPARAM wParam, LPARAM lParam)
PostMessage(m_hwnd, WM_CLOSE, 0, 1);
return TRUE;
}
-
- if (wParam == VK_ESCAPE || wParam == VK_UP || wParam == VK_DOWN || wParam == VK_NEXT || wParam == VK_PRIOR || wParam == VK_TAB || wParam == VK_HOME || wParam == VK_END) {
- m_wszSearch[0] = 0;
- m_iSearchItem = -1;
- }
- break;
-
- case WM_SETFOCUS:
- case WM_KILLFOCUS:
- m_wszSearch[0] = 0;
- m_iSearchItem = -1;
- break;
-
- 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
- if (wParam == 27 && m_wszSearch[0]) { // escape - reset everything
- m_wszSearch[0] = 0;
- m_iSearchItem = -1;
- break;
- }
- if (wParam == '\b' && m_wszSearch[0]) // backspace
- m_wszSearch[mir_wstrlen(m_wszSearch) - 1] = '\0';
- else if (wParam < ' ')
- break;
- else {
- if (mir_wstrlen(m_wszSearch) >= _countof(m_wszSearch) - 2) {
- MessageBeep(MB_OK);
- break;
- }
- wchar_t szNew[2];
- szNew[0] = (wchar_t)wParam;
- szNew[1] = '\0';
- mir_wstrcat(m_wszSearch, szNew);
- }
- if (m_wszSearch[0]) {
- // iterate over the (sorted) list of nicknames and search for the
- // string we have
- int i, iItems = m_nickList.SendMsg(LB_GETCOUNT, 0, 0);
- for (i = 0; i < iItems; i++) {
- if (auto *ui = (USERINFO *)m_nickList.GetItemData(i)) {
- if (!wcsnicmp(ui->pszNick, m_wszSearch, mir_wstrlen(m_wszSearch))) {
- m_nickList.SendMsg(LB_SETSEL, FALSE, -1);
- m_nickList.SendMsg(LB_SETSEL, TRUE, i);
- m_iSearchItem = i;
- InvalidateRect(m_nickList.GetHwnd(), nullptr, FALSE);
- return 0;
- }
- }
- }
- if (i == iItems) {
- MessageBeep(MB_OK);
- m_wszSearch[mir_wstrlen(m_wszSearch) - 1] = '\0';
- return 0;
- }
- }
break;
}
diff --git a/plugins/TabSRMM/src/msgdlgother.cpp b/plugins/TabSRMM/src/msgdlgother.cpp
index 52b26b29b8..7942e378cb 100644
--- a/plugins/TabSRMM/src/msgdlgother.cpp
+++ b/plugins/TabSRMM/src/msgdlgother.cpp
@@ -501,14 +501,14 @@ void CMsgDialog::DrawNickList(USERINFO *ui, DRAWITEMSTRUCT *dis)
}
SIZE sz;
- if (m_iSearchItem != -1 && m_iSearchItem == index && m_wszSearch[0]) {
+ if (m_iNickSearch != -1 && m_iNickSearch == index && !m_wszNickSearch.IsEmpty()) {
COLORREF clr_orig = GetTextColor(dis->hDC);
- GetTextExtentPoint32(dis->hDC, ui->pszNick, (int)mir_wstrlen(m_wszSearch), &sz);
+ GetTextExtentPoint32(dis->hDC, ui->pszNick, m_wszNickSearch.GetLength(), &sz);
SetTextColor(dis->hDC, RGB(250, 250, 0));
- TextOut(dis->hDC, x_offset, (dis->rcItem.top + dis->rcItem.bottom - sz.cy) / 2, ui->pszNick, (int)mir_wstrlen(m_wszSearch));
+ TextOut(dis->hDC, x_offset, (dis->rcItem.top + dis->rcItem.bottom - sz.cy) / 2, ui->pszNick, m_wszNickSearch.GetLength());
SetTextColor(dis->hDC, clr_orig);
x_offset += sz.cx;
- TextOut(dis->hDC, x_offset, (dis->rcItem.top + dis->rcItem.bottom - sz.cy) / 2, ui->pszNick + mir_wstrlen(m_wszSearch), int(mir_wstrlen(ui->pszNick) - mir_wstrlen(m_wszSearch)));
+ TextOut(dis->hDC, x_offset, (dis->rcItem.top + dis->rcItem.bottom - sz.cy) / 2, ui->pszNick + m_wszNickSearch.GetLength(), int(mir_wstrlen(ui->pszNick) - m_wszNickSearch.GetLength()));
}
else {
GetTextExtentPoint32(dis->hDC, ui->pszNick, (int)mir_wstrlen(ui->pszNick), &sz);
diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h
index 9d8c96b839..9305fd8ace 100644
--- a/plugins/TabSRMM/src/msgs.h
+++ b/plugins/TabSRMM/src/msgs.h
@@ -553,9 +553,7 @@ public:
bool TabAutoComplete();
HWND m_hwndFilter;
- int m_iSearchItem;
BOOL m_iSavedSpaces;
- wchar_t m_wszSearch[255];
wchar_t *m_wszSearchQuery, *m_wszSearchResult;
SESSION_INFO *m_pLastSession;