summaryrefslogtreecommitdiff
path: root/plugins/TabSRMM/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/TabSRMM/src')
-rw-r--r--plugins/TabSRMM/src/chat/window.cpp20
-rw-r--r--plugins/TabSRMM/src/msgs.h3
2 files changed, 21 insertions, 2 deletions
diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp
index 8679ba7687..f4db3d6fb4 100644
--- a/plugins/TabSRMM/src/chat/window.cpp
+++ b/plugins/TabSRMM/src/chat/window.cpp
@@ -837,6 +837,17 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
LOGFONTA lf;
char *lpPrevCmd = pci->SM_GetPrevCommand(Parentsi->ptszID, Parentsi->pszModule);
+ if (!Parentsi->lpCurrentCommand || !Parentsi->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) {
+ mir_free(mwdat->enteredText);
+ }
+
+ mwdat->enteredText = enteredText;
+ }
+
SendMessage(hwnd, WM_SETREDRAW, FALSE, 0);
LoadLogfont(MSGFONTID_MESSAGEAREA, &lf, NULL, FONTMODULE);
@@ -869,8 +880,12 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
ste.codepage = CP_ACP;
if (lpPrevCmd)
SendMessage(hwnd, EM_SETTEXTEX, (WPARAM)&ste, (LPARAM)lpPrevCmd);
- else
- SetWindowText(hwnd, _T(""));
+ else if (mwdat->enteredText) {
+ // If we cannot load the message from history, load the last edited text.
+ SendMessage(hwnd, EM_SETTEXTEX, (WPARAM)&ste, (LPARAM)mwdat->enteredText);
+ mir_free(mwdat->enteredText);
+ mwdat->enteredText = NULL;
+ }
gtl.flags = GTL_PRECISE;
gtl.codepage = CP_ACP;
@@ -3484,6 +3499,7 @@ LABEL_SHOWWINDOW:
delete dat->Panel;
if (dat->pContainer->dwFlags & CNT_SIDEBAR)
dat->pContainer->SideBar->removeSession(dat);
+ mir_free(dat->enteredText);
mir_free(dat);
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);
}
diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h
index d4551f333f..d510046ba1 100644
--- a/plugins/TabSRMM/src/msgs.h
+++ b/plugins/TabSRMM/src/msgs.h
@@ -332,6 +332,9 @@ struct TWindowData
LONG iInputAreaHeight;
bool bIsAutosizingInput;
bool fLimitedUpdate;
+
+ // Used for history in chats.
+ char *enteredText;
};
#define MESSAGE_WINDOW_DATA_SIZE offsetof(_MessageWindowData, hdbEventFirst);