summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-03-04 16:40:59 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-03-04 16:40:59 +0300
commit643402d4a23f81d97c9067725fd5840054cc7e74 (patch)
tree83658d002041a016c6c7c2e348db9067abb4e70e
parente2eb0f327cf2086013d8534182b86f923ea98a7a (diff)
fixes #2244 (Scriver: after message log unification the Quote button doesnt use selected text)
-rw-r--r--plugins/Scriver/src/utils.cpp30
-rw-r--r--plugins/Scriver/src/utils.h1
-rw-r--r--src/mir_app/src/srmm_log_rtf.cpp26
3 files changed, 25 insertions, 32 deletions
diff --git a/plugins/Scriver/src/utils.cpp b/plugins/Scriver/src/utils.cpp
index c3bb35d3f2..b0e4869327 100644
--- a/plugins/Scriver/src/utils.cpp
+++ b/plugins/Scriver/src/utils.cpp
@@ -72,36 +72,6 @@ wchar_t* limitText(wchar_t *text, int limit)
return text;
}
-static DWORD CALLBACK StreamOutCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG * pcb)
-{
- MessageSendQueueItem *msi = (MessageSendQueueItem *)dwCookie;
- msi->sendBuffer = (char*)mir_realloc(msi->sendBuffer, msi->sendBufferSize + cb + 2);
- memcpy(msi->sendBuffer + msi->sendBufferSize, pbBuff, cb);
- msi->sendBufferSize += cb;
- *((wchar_t*)(msi->sendBuffer + msi->sendBufferSize)) = '\0';
- *pcb = cb;
- return 0;
-}
-
-wchar_t *GetRichEditSelection(HWND hwnd)
-{
- CHARRANGE sel;
- SendMessage(hwnd, EM_EXGETSEL, 0, (LPARAM)&sel);
- if (sel.cpMin == sel.cpMax)
- return nullptr;
-
- MessageSendQueueItem msi;
- msi.sendBuffer = nullptr;
- msi.sendBufferSize = 0;
-
- EDITSTREAM stream;
- memset(&stream, 0, sizeof(stream));
- stream.pfnCallback = StreamOutCallback;
- stream.dwCookie = (DWORD_PTR)&msi;
- SendMessage(hwnd, EM_STREAMOUT, SF_TEXT | SF_UNICODE | SFF_SELECTION, (LPARAM)&stream);
- return (wchar_t*)msi.sendBuffer;
-}
-
int MeasureMenuItem(WPARAM, LPARAM lParam)
{
LPMEASUREITEMSTRUCT mis = (LPMEASUREITEMSTRUCT)lParam;
diff --git a/plugins/Scriver/src/utils.h b/plugins/Scriver/src/utils.h
index 9f0bed1256..0a67a4811e 100644
--- a/plugins/Scriver/src/utils.h
+++ b/plugins/Scriver/src/utils.h
@@ -36,7 +36,6 @@ enum SEARCHENGINES {
wchar_t *limitText(wchar_t *text, int limit);
void logInfo(const char *fmt, ...);
-wchar_t *GetRichEditSelection(HWND hwnd);
void SearchWord(wchar_t * word, int engine);
int MeasureMenuItem(WPARAM wParam, LPARAM lParam);
int DrawMenuItem(WPARAM wParam, LPARAM lParam);
diff --git a/src/mir_app/src/srmm_log_rtf.cpp b/src/mir_app/src/srmm_log_rtf.cpp
index b98f6ca28d..f2f1fae8d6 100644
--- a/src/mir_app/src/srmm_log_rtf.cpp
+++ b/src/mir_app/src/srmm_log_rtf.cpp
@@ -95,11 +95,35 @@ int CRtfLogWindow::GetType()
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static DWORD CALLBACK StreamOutCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
+{
+ CMStringW *str = (CMStringW *)dwCookie;
+ str->Append((wchar_t*)pbBuff, cb / 2);
+ *pcb = cb;
+ return 0;
+}
+
wchar_t* CRtfLogWindow::GetSelection()
{
- return nullptr;
+ CHARRANGE sel;
+ SendMessage(m_rtf.GetHwnd(), EM_EXGETSEL, 0, (LPARAM)&sel);
+ if (sel.cpMin == sel.cpMax)
+ return nullptr;
+
+ CMStringW result;
+
+ EDITSTREAM stream;
+ memset(&stream, 0, sizeof(stream));
+ stream.pfnCallback = StreamOutCallback;
+ stream.dwCookie = (DWORD_PTR)&result;
+ SendMessage(m_rtf.GetHwnd(), EM_STREAMOUT, SF_TEXT | SF_UNICODE | SFF_SELECTION, (LPARAM)&stream);
+ return result.Detach();
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
INT_PTR CRtfLogWindow::Notify(WPARAM, LPARAM lParam)
{
LPNMHDR hdr = (LPNMHDR)lParam;