diff options
author | George Hazan <ghazan@miranda.im> | 2019-09-03 17:16:05 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-09-03 17:16:05 +0300 |
commit | bb1bd90072098e8b0e03909cd7a864ca51428aa0 (patch) | |
tree | 447c13e71267be03bef1f6a54e616ef43628af3a /src/core/stdmsg | |
parent | 7ebc74088a674e52f523d2467997f3343eb7dc13 (diff) |
StdMsg: further merge
Diffstat (limited to 'src/core/stdmsg')
-rw-r--r-- | src/core/stdmsg/src/chat_window.cpp | 89 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgdialog.cpp | 129 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgs.h | 29 |
3 files changed, 125 insertions, 122 deletions
diff --git a/src/core/stdmsg/src/chat_window.cpp b/src/core/stdmsg/src/chat_window.cpp index 3f98522e12..569ff940ca 100644 --- a/src/core/stdmsg/src/chat_window.cpp +++ b/src/core/stdmsg/src/chat_window.cpp @@ -604,7 +604,7 @@ LRESULT CChatRoomDlg::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) if (wParam == '\n' || wParam == '\r') { if ((isCtrl && g_dat.bSendOnCtrlEnter) || (!isCtrl && g_dat.bSendOnEnter)) { - m_btnOk.OnClick(&m_btnOk); + m_btnOk.Click(); return 0; } if (g_dat.bSendOnDblEnter) { @@ -613,7 +613,7 @@ LRESULT CChatRoomDlg::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) else { m_message.SendMsg(WM_KEYDOWN, VK_BACK, 0); m_message.SendMsg(WM_KEYUP, VK_BACK, 0); - m_btnOk.OnClick(&m_btnOk); + m_btnOk.Click(); return 0; } } @@ -629,12 +629,11 @@ LRESULT CChatRoomDlg::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) case WM_KEYDOWN: { - static int start, end; bool isShift = (GetKeyState(VK_SHIFT) & 0x8000) != 0; bool isCtrl = (GetKeyState(VK_CONTROL) & 0x8000) != 0; bool isAlt = (GetKeyState(VK_MENU) & 0x8000) != 0; if (wParam == VK_RETURN) { - szTabSave[0] = '\0'; + m_szTabSave[0] = '\0'; if ((isCtrl && g_dat.bSendOnCtrlEnter) || (!isCtrl && g_dat.bSendOnEnter)) return 0; @@ -651,94 +650,20 @@ LRESULT CChatRoomDlg::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) } if (wParam == VK_TAB && !isCtrl && !isShift) { // tab-autocomplete - LRESULT lResult = (LRESULT)m_message.SendMsg(EM_GETSEL, 0, 0); - - m_message.SendMsg(WM_SETREDRAW, FALSE, 0); - start = LOWORD(lResult); - end = HIWORD(lResult); - m_message.SendMsg(EM_SETSEL, end, end); - - GETTEXTLENGTHEX gtl = {}; - gtl.flags = GTL_PRECISE; - gtl.codepage = CP_ACP; - int iLen = m_message.SendMsg(EM_GETTEXTLENGTHEX, (WPARAM)>l, 0); - if (iLen > 0) { - wchar_t *pszText = (wchar_t *)mir_alloc(sizeof(wchar_t)*(iLen + 100)); - - GETTEXTEX gt = {}; - gt.cb = iLen + 99; - gt.flags = GT_DEFAULT; - gt.codepage = 1200; - m_message.SendMsg(EM_GETTEXTEX, (WPARAM)>, (LPARAM)pszText); - - while (start > 0 && pszText[start - 1] != ' ' && pszText[start - 1] != 13 && pszText[start - 1] != VK_TAB) - start--; - while (end < iLen && pszText[end] != ' ' && pszText[end] != 13 && pszText[end - 1] != VK_TAB) - end++; - - if (szTabSave[0] == '\0') - mir_wstrncpy(szTabSave, pszText + start, end - start + 1); - - wchar_t *pszSelName = (wchar_t *)mir_alloc(sizeof(wchar_t)*(end - start + 1)); - mir_wstrncpy(pszSelName, pszText + start, end - start + 1); - - wchar_t *pszName = g_chatApi.UM_FindUserAutoComplete(m_si, szTabSave, pszSelName); - if (pszName == nullptr) { - pszName = szTabSave; - m_message.SendMsg(EM_SETSEL, start, end); - if (end != start) - m_message.SendMsg(EM_REPLACESEL, FALSE, (LPARAM)pszName); - szTabSave[0] = '\0'; - } - else { - m_message.SendMsg(EM_SETSEL, start, end); - if (end != start) - m_message.SendMsg(EM_REPLACESEL, FALSE, (LPARAM)pszName); - } - mir_free(pszText); - mir_free(pszSelName); - } - - m_message.SendMsg(WM_SETREDRAW, TRUE, 0); - RedrawWindow(m_message.GetHwnd(), nullptr, nullptr, RDW_INVALIDATE); + TabAutoComplete(); return 0; } - if (szTabSave[0] != '\0' && wParam != VK_RIGHT && wParam != VK_LEFT && wParam != VK_SPACE && wParam != VK_RETURN && wParam != VK_BACK && wParam != VK_DELETE) { - if (g_Settings.bAddColonToAutoComplete && start == 0) + if (m_szTabSave[0] != '\0' && wParam != VK_RIGHT && wParam != VK_LEFT && wParam != VK_SPACE && wParam != VK_RETURN && wParam != VK_BACK && wParam != VK_DELETE) { + if (g_Settings.bAddColonToAutoComplete && m_iTabStart == 0) SendMessageA(m_message.GetHwnd(), EM_REPLACESEL, FALSE, (LPARAM) ": "); - szTabSave[0] = '\0'; + m_szTabSave[0] = '\0'; } if (ProcessHotkeys(wParam, isShift, isCtrl, isAlt)) return TRUE; - if (wParam == 0x46 && isCtrl && !isAlt) { // ctrl-f (toggle filter) - onClick_Filter(&m_btnFilter); - return TRUE; - } - - if (wParam == 0x4e && isCtrl && !isAlt) { // ctrl-n (nicklist) - onClick_NickList(&m_btnNickList); - return TRUE; - } - - if (wParam == 0x4f && isCtrl && !isAlt) { // ctrl-o (options) - onClick_ChanMgr(&m_btnChannelMgr); - return TRUE; - } - - if ((wParam == 45 && isShift || wParam == 0x56 && isCtrl) && !isAlt) { // ctrl-v (paste clean text) - m_message.SendMsg(EM_PASTESPECIAL, CF_TEXT, 0); - return TRUE; - } - - if (wParam == 0x57 && isCtrl && !isAlt) { // ctrl-w (close window) - CloseTab(); - return TRUE; - } - if (wParam == VK_NEXT || wParam == VK_PRIOR) { m_log.SendMsg(msg, wParam, lParam); m_iLastEnterTime = 0; diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp index c2e461f57f..bfd017866c 100644 --- a/src/core/stdmsg/src/msgdialog.cpp +++ b/src/core/stdmsg/src/msgdialog.cpp @@ -73,8 +73,10 @@ CMsgDialog::CMsgDialog(CTabbedWindow *pOwner, int iDialogId, SESSION_INFO *si) : m_avatar(this, IDC_AVATAR),
m_splitterX(this, IDC_SPLITTERX),
m_splitterY(this, IDC_SPLITTERY),
+ m_cmdList(20),
m_pOwner(pOwner)
{
+ m_szTabSave[0] = 0;
m_autoClose = 0;
m_forceResizable = true;
@@ -132,6 +134,19 @@ INT_PTR CMsgDialog::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) return CSuper::DlgProc(uMsg, wParam, lParam);
}
+LRESULT CMsgDialog::WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ if (msg == WM_KEYDOWN) {
+ bool isShift = (GetKeyState(VK_SHIFT) & 0x8000) != 0;
+ bool isCtrl = (GetKeyState(VK_CONTROL) & 0x8000) != 0;
+ bool isAlt = (GetKeyState(VK_MENU) & 0x8000) != 0;
+ if (ProcessHotkeys(wParam, isShift, isCtrl, isAlt))
+ return FALSE;
+ }
+
+ return CSuper::WndProc_Log(msg, wParam, lParam);
+}
+
LRESULT CMsgDialog::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam)
{
if (msg == WM_KEYDOWN) {
@@ -139,29 +154,54 @@ LRESULT CMsgDialog::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) bool isCtrl = (GetKeyState(VK_CONTROL) & 0x8000) != 0;
bool isAlt = (GetKeyState(VK_MENU) & 0x8000) != 0;
- if (wParam <= '9' && wParam >= '1' && isCtrl && !isAlt) // CTRL + 1 -> 9 (switch tab)
- if (g_Settings.bTabsEnable) {
+ if (g_Settings.bTabsEnable) {
+ if (wParam <= '9' && wParam >= '1' && isCtrl && !isAlt) { // CTRL + 1 -> 9 (switch tab)
m_pOwner->SwitchTab(wParam - '1');
return TRUE;
}
- if (wParam <= VK_NUMPAD9 && wParam >= VK_NUMPAD1 && isCtrl && !isAlt) // CTRL + 1 -> 9 (switch tab)
- if (g_Settings.bTabsEnable) {
+ if (wParam <= VK_NUMPAD9 && wParam >= VK_NUMPAD1 && isCtrl && !isAlt) { // CTRL + 1 -> 9 (switch tab)
m_pOwner->SwitchTab(wParam - VK_NUMPAD1);
return TRUE;
}
- if (wParam == VK_TAB && isCtrl && !isShift) // CTRL-TAB (switch tab/window)
- if (g_Settings.bTabsEnable) {
+ if (wParam == VK_TAB && isCtrl && !isShift) { // CTRL-TAB (switch tab/window)
m_pOwner->SwitchNextTab();
return TRUE;
}
- if (wParam == VK_TAB && isCtrl && isShift) // CTRL_SHIFT-TAB (switch tab/window)
- if (g_Settings.bTabsEnable) {
+ if (wParam == VK_TAB && isCtrl && isShift) { // CTRL_SHIFT-TAB (switch tab/window)
m_pOwner->SwitchPrevTab();
return TRUE;
}
+
+ if (wParam == 0x57 && isCtrl && !isAlt) { // ctrl-w (close window)
+ CloseTab();
+ return TRUE;
+ }
+ }
+
+ if (isChat()) {
+ if (wParam == 0x46 && isCtrl && !isAlt) { // ctrl-f (toggle filter)
+ m_btnFilter.Click();
+ return TRUE;
+ }
+
+ if (wParam == 0x4e && isCtrl && !isAlt) { // ctrl-n (nicklist)
+ m_btnNickList.Click();
+ return TRUE;
+ }
+
+ if (wParam == 0x4f && isCtrl && !isAlt) { // ctrl-o (options)
+ m_btnChannelMgr.Click();
+ return TRUE;
+ }
+
+ if ((wParam == 45 && isShift || wParam == 0x56 && isCtrl) && !isAlt) { // ctrl-v (paste clean text)
+ m_message.SendMsg(EM_PASTESPECIAL, CF_TEXT, 0);
+ return TRUE;
+ }
+ }
}
return CSuper::WndProc_Message(msg, wParam, lParam);
@@ -216,11 +256,64 @@ void CMsgDialog::StopFlash() }
}
+void CMsgDialog::TabAutoComplete()
+{
+ LRESULT lResult = (LRESULT)m_message.SendMsg(EM_GETSEL, 0, 0);
+
+ m_message.SendMsg(WM_SETREDRAW, FALSE, 0);
+ m_iTabStart = LOWORD(lResult);
+ int end = HIWORD(lResult);
+ m_message.SendMsg(EM_SETSEL, end, end);
+
+ GETTEXTLENGTHEX gtl = {};
+ gtl.flags = GTL_PRECISE;
+ gtl.codepage = CP_ACP;
+ int iLen = m_message.SendMsg(EM_GETTEXTLENGTHEX, (WPARAM)& gtl, 0);
+ if (iLen > 0) {
+ wchar_t *pszText = (wchar_t *)mir_alloc(sizeof(wchar_t) * (iLen + 100));
+
+ GETTEXTEX gt = {};
+ gt.cb = iLen + 99;
+ gt.flags = GT_DEFAULT;
+ gt.codepage = 1200;
+ m_message.SendMsg(EM_GETTEXTEX, (WPARAM)& gt, (LPARAM)pszText);
+
+ while (m_iTabStart > 0 && pszText[m_iTabStart - 1] != ' ' && pszText[m_iTabStart - 1] != 13 && pszText[m_iTabStart - 1] != VK_TAB)
+ m_iTabStart--;
+ while (end < iLen && pszText[end] != ' ' && pszText[end] != 13 && pszText[end - 1] != VK_TAB)
+ end++;
+
+ if (m_szTabSave[0] == '\0')
+ mir_wstrncpy(m_szTabSave, pszText + m_iTabStart, end - m_iTabStart + 1);
+
+ wchar_t *pszSelName = (wchar_t *)mir_alloc(sizeof(wchar_t) * (end - m_iTabStart + 1));
+ mir_wstrncpy(pszSelName, pszText + m_iTabStart, end - m_iTabStart + 1);
+
+ wchar_t *pszName = g_chatApi.UM_FindUserAutoComplete(m_si, m_szTabSave, pszSelName);
+ if (pszName == nullptr) {
+ pszName = m_szTabSave;
+ m_message.SendMsg(EM_SETSEL, m_iTabStart, end);
+ if (end != m_iTabStart)
+ m_message.SendMsg(EM_REPLACESEL, FALSE, (LPARAM)pszName);
+ m_szTabSave[0] = '\0';
+ }
+ else {
+ m_message.SendMsg(EM_SETSEL, m_iTabStart, end);
+ if (end != m_iTabStart)
+ m_message.SendMsg(EM_REPLACESEL, FALSE, (LPARAM)pszName);
+ }
+ mir_free(pszText);
+ mir_free(pszSelName);
+ }
+
+ m_message.SendMsg(WM_SETREDRAW, TRUE, 0);
+ RedrawWindow(m_message.GetHwnd(), nullptr, nullptr, RDW_INVALIDATE);
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
CSrmmWindow::CSrmmWindow(CTabbedWindow *pOwner, MCONTACT hContact) :
CSuper(pOwner, IDD_MSG),
- m_cmdList(20),
m_bNoActivate(g_dat.bDoNotStealFocus)
{
m_hContact = hContact;
@@ -863,19 +956,6 @@ int CSrmmWindow::Resizer(UTILRESIZECONTROL *urc) /////////////////////////////////////////////////////////////////////////////////////////
-LRESULT CSrmmWindow::WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam)
-{
- if (msg == WM_KEYDOWN) {
- bool isShift = (GetKeyState(VK_SHIFT) & 0x8000) != 0;
- bool isCtrl = (GetKeyState(VK_CONTROL) & 0x8000) != 0;
- bool isAlt = (GetKeyState(VK_MENU) & 0x8000) != 0;
- if (ProcessHotkeys(wParam, isShift, isCtrl, isAlt))
- return FALSE;
- }
-
- return CSuper::WndProc_Log(msg, wParam, lParam);
-}
-
LRESULT CSrmmWindow::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam)
{
bool isShift, isCtrl, isAlt;
@@ -893,11 +973,6 @@ LRESULT CSrmmWindow::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) m_message.SendMsg(EM_SETSEL, 0, -1);
return 0;
}
-
- if (wParam == 23 && GetKeyState(VK_CONTROL) & 0x8000) { // ctrl-w
- CloseTab();
- return 0;
- }
break;
case WM_KEYDOWN:
diff --git a/src/core/stdmsg/src/msgs.h b/src/core/stdmsg/src/msgs.h index 426cd76934..7c8e8252e7 100644 --- a/src/core/stdmsg/src/msgs.h +++ b/src/core/stdmsg/src/msgs.h @@ -40,12 +40,26 @@ class CMsgDialog : public CSrmmBaseDialog protected:
CCtrlBase m_avatar;
CCtrlButton m_btnOk;
- CSplitter m_splitterX, m_splitterY;
CTabbedWindow *m_pOwner;
DWORD m_nFlash = 0;
char *m_szProto = nullptr;
+ // splitters
+ CSplitter m_splitterX, m_splitterY;
+ int m_iSplitterX, m_iSplitterY;
+ SIZE m_minEditBoxSize;
+ RECT m_minEditInit;
+
+ // tab autocomplete
+ int m_iTabStart = 0;
+ wchar_t m_szTabSave[20];
+ void TabAutoComplete();
+
+ // entered messages
+ int m_cmdListInd = 0;
+ LIST<wchar_t> m_cmdList;
+
CMsgDialog(CTabbedWindow *pOwner, int idDialog, SESSION_INFO *si = nullptr);
virtual int GetStatus() const PURE;
@@ -56,6 +70,7 @@ protected: void OnDestroy() override;
INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
+ LRESULT WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam) override;
LRESULT WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) override;
public:
@@ -81,7 +96,6 @@ class CSrmmWindow : public CMsgDialog {
typedef CMsgDialog CSuper;
- LRESULT WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam) override;
LRESULT WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) override;
void NotifyTyping(int mode);
@@ -96,9 +110,6 @@ class CSrmmWindow : public CMsgDialog HFONT m_hFont = nullptr;
- SIZE m_minEditBoxSize;
- RECT m_minEditInit;
-
int m_windowWasCascaded;
int m_nTypeSecs, m_nTypeMode;
int m_limitAvatarH;
@@ -114,10 +125,6 @@ public: MEVENT m_hDbEventFirst, m_hDbEventLast;
int m_avatarWidth, m_avatarHeight;
- int m_iSplitterY;
-
- int m_cmdListInd;
- LIST<wchar_t> m_cmdList;
HBITMAP m_avatarPic;
wchar_t *m_wszInitialText;
@@ -169,10 +176,6 @@ class CChatRoomDlg : public CMsgDialog LRESULT WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) override;
LRESULT WndProc_Nicklist(UINT msg, WPARAM wParam, LPARAM lParam) override;
- wchar_t szTabSave[20];
-
- int m_iSplitterX, m_iSplitterY;
-
public:
CChatRoomDlg(CTabbedWindow*, SESSION_INFO*);
|