diff options
Diffstat (limited to 'plugins/Scriver/src')
| -rw-r--r-- | plugins/Scriver/src/chat_log.cpp | 6 | ||||
| -rw-r--r-- | plugins/Scriver/src/chat_window.cpp | 23 | ||||
| -rw-r--r-- | plugins/Scriver/src/input.cpp | 6 | ||||
| -rw-r--r-- | plugins/Scriver/src/msgdialog.cpp | 12 | ||||
| -rw-r--r-- | plugins/Scriver/src/msglog.cpp | 8 | ||||
| -rw-r--r-- | plugins/Scriver/src/utils.cpp | 82 | ||||
| -rw-r--r-- | plugins/Scriver/src/utils.h | 6 | 
7 files changed, 28 insertions, 115 deletions
diff --git a/plugins/Scriver/src/chat_log.cpp b/plugins/Scriver/src/chat_log.cpp index 3d8ea3eb55..34ca7d665f 100644 --- a/plugins/Scriver/src/chat_log.cpp +++ b/plugins/Scriver/src/chat_log.cpp @@ -39,7 +39,7 @@ void CChatRoomDlg::StreamInEvents(LOGINFO* lin, bool bRedraw)  	streamData.si = m_si;
  	streamData.lin = lin;
  	streamData.bStripFormat = FALSE;
 -	streamData.isFirst = bRedraw ? 1 : (GetRichTextLength(m_log.GetHwnd(), CP_ACP, FALSE) == 0);
 +	streamData.isFirst = bRedraw ? 1 : m_log.GetRichTextLength() == 0;
  	EDITSTREAM stream = { 0 };
  	stream.pfnCallback = Srmm_LogStreamCallback;
 @@ -60,7 +60,7 @@ void CChatRoomDlg::StreamInEvents(LOGINFO* lin, bool bRedraw)  		m_log.SendMsg(WM_SETREDRAW, FALSE, 0);
  	// set the insertion point at the bottom
 -	sel.cpMin = sel.cpMax = GetRichTextLength(m_log.GetHwnd(), CP_ACP, FALSE);
 +	sel.cpMin = sel.cpMax = m_log.GetRichTextLength();
  	m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&sel);
  	m_log.SendMsg(EM_EXGETSEL, 0, (LPARAM)&sel);
 @@ -115,7 +115,7 @@ void CChatRoomDlg::StreamInEvents(LOGINFO* lin, bool bRedraw)  	// need to invalidate the window
  	if (bFlag) {
 -		sel.cpMin = sel.cpMax = GetRichTextLength(m_log.GetHwnd(), CP_ACP, FALSE);
 +		sel.cpMin = sel.cpMax = m_log.GetRichTextLength();
  		m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&sel);
  		m_log.SendMsg(WM_SETREDRAW, TRUE, 0);
  		InvalidateRect(m_log.GetHwnd(), nullptr, TRUE);
 diff --git a/plugins/Scriver/src/chat_window.cpp b/plugins/Scriver/src/chat_window.cpp index 4efe867148..40ed6a6db3 100644 --- a/plugins/Scriver/src/chat_window.cpp +++ b/plugins/Scriver/src/chat_window.cpp @@ -27,19 +27,20 @@ void CChatRoomDlg::TabAutoComplete()  	int start = LOWORD(lResult), end = HIWORD(lResult);
  	m_message.SendMsg(EM_SETSEL, end, end);
 -	GETTEXTEX gt = { 0 };
 -	gt.codepage = 1200;
 -	int iLen = GetRichTextLength(m_message.GetHwnd(), gt.codepage, TRUE);
 +	int iLen = m_message.GetRichTextLength(1200);
  	if (iLen <= 0)
  		return;
  	bool isTopic = false, isRoom = false;
  	wchar_t *pszName = nullptr;
  	wchar_t* pszText = (wchar_t*)mir_alloc(iLen + 100 * sizeof(wchar_t));
 +
 +	GETTEXTEX gt = {};
 +	gt.codepage = 1200;
  	gt.cb = iLen + 99 * sizeof(wchar_t);
  	gt.flags = GT_DEFAULT;
 -
  	m_message.SendMsg(EM_GETTEXTEX, (WPARAM)>, (LPARAM)pszText);
 +
  	if (start > 1 && pszText[start - 1] == ' ' && pszText[start - 2] == ':')
  		start -= 2;
 @@ -311,14 +312,14 @@ void CChatRoomDlg::onClick_Ok(CCtrlButton *pButton)  	if (!pButton->Enabled())
  		return;
 -	char *pszRtf = GetRichTextRTF(m_message.GetHwnd());
 -	if (pszRtf == nullptr)
 -		return;
 -
  	MODULEINFO *mi = pci->MM_FindModule(m_si->pszModule);
  	if (mi == nullptr)
  		return;
 +	char *pszRtf = m_message.GetRichTextRtf();
 +	if (pszRtf == nullptr)
 +		return;
 +
  	TCmdList *cmdListNew = tcmdlist_last(cmdList);
  	while (cmdListNew != nullptr && cmdListNew->temporary) {
  		cmdList = tcmdlist_remove(cmdList, cmdListNew);
 @@ -369,10 +370,10 @@ void CChatRoomDlg::onClick_Filter(CCtrlButton *pButton)  		RedrawLog();
  }
 -void CChatRoomDlg::onChange_Message(CCtrlEdit *pEdit)
 +void CChatRoomDlg::onChange_Message(CCtrlEdit*)
  {
  	cmdListCurrent = nullptr;
 -	m_btnOk.Enable(GetRichTextLength(pEdit->GetHwnd(), 1200, FALSE) != 0);
 +	m_btnOk.Enable(m_message.GetRichTextLength() != 0);
  }
  /////////////////////////////////////////////////////////////////////////////////////////
 @@ -425,7 +426,7 @@ void CChatRoomDlg::ScrollToBottom()  	SetScrollInfo(m_log.GetHwnd(), SB_VERT, &sci, TRUE);
  	CHARRANGE sel;
 -	sel.cpMin = sel.cpMax = GetRichTextLength(m_log.GetHwnd(), CP_ACP, FALSE);
 +	sel.cpMin = sel.cpMax = m_log.GetRichTextLength();
  	m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&sel);
  	PostMessage(m_log.GetHwnd(), WM_VSCROLL, MAKEWPARAM(SB_BOTTOM, 0), 0);
  }
 diff --git a/plugins/Scriver/src/input.cpp b/plugins/Scriver/src/input.cpp index 0698cdf2d9..b2ec93eb56 100644 --- a/plugins/Scriver/src/input.cpp +++ b/plugins/Scriver/src/input.cpp @@ -199,7 +199,7 @@ int CScriverWindow::InputAreaShortcuts(HWND hwnd, UINT msg, WPARAM wParam, LPARA  		}
  		if ((wParam == VK_UP || wParam == VK_DOWN) && isCtrl && !db_get_b(0, SRMM_MODULE, SRMSGSET_AUTOCLOSE, SRMSGDEFSET_AUTOCLOSE)) {
 -			if (cmdList) {
 +			if (cmdList && hwnd == m_message.GetHwnd()) {
  				TCmdList *cmdListNew = nullptr;
  				if (wParam == VK_UP) {
  					if (cmdListCurrent == nullptr) {
 @@ -209,7 +209,7 @@ int CScriverWindow::InputAreaShortcuts(HWND hwnd, UINT msg, WPARAM wParam, LPARA  							cmdListNew = tcmdlist_last(cmdList);
  						}
  						if (cmdListNew != nullptr) {
 -							char *textBuffer = GetRichTextUtf(hwnd);
 +							char *textBuffer = m_message.GetRichTextUtf();
  							if (textBuffer != nullptr)
  								// takes textBuffer to a queue, no leak here
  								cmdList = tcmdlist_append(cmdList, textBuffer, 20, TRUE);
 @@ -229,7 +229,7 @@ int CScriverWindow::InputAreaShortcuts(HWND hwnd, UINT msg, WPARAM wParam, LPARA  				if (cmdListNew != nullptr) {
  					SendMessage(hwnd, WM_SETREDRAW, FALSE, 0);
 -					int iLen = SetRichTextRTF(hwnd, cmdListNew->szCmd);
 +					int iLen = m_message.SetRichTextRtf(cmdListNew->szCmd);
  					SendMessage(hwnd, EM_SCROLLCARET, 0, 0);
  					SendMessage(hwnd, WM_SETREDRAW, TRUE, 0);
 diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index 1dce87450c..80585493ba 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -269,7 +269,7 @@ void CSrmmWindow::OnInitDialog()  		int len = 0;
  		ptrW ptszSavedMsg(db_get_wsa(m_hContact, "SRMM", "SavedMsg"));
  		if (ptszSavedMsg)
 -			len = SetRichText(m_message.GetHwnd(), ptszSavedMsg);
 +			len = m_message.SetRichText(ptszSavedMsg);
  		PostMessage(m_message.GetHwnd(), EM_SETSEL, len, len);
  	}
 @@ -412,7 +412,7 @@ void CSrmmWindow::OnDestroy()  	ReleaseSendQueueItems(m_hwnd);
  	if (g_dat.flags & SMF_SAVEDRAFTS) {
 -		ptrA szText(GetRichTextUtf(m_message.GetHwnd()));
 +		ptrA szText(m_message.GetRichTextUtf());
  		if (szText)
  			db_set_utf(m_hContact, "SRMM", "SavedMsg", szText);
  		else
 @@ -455,7 +455,7 @@ void CSrmmWindow::onClick_Ok(CCtrlButton *pButton)  	pf2.dwMask = PFM_RTLPARA;
  	m_message.SendMsg(EM_GETPARAFORMAT, 0, (LPARAM)&pf2);
 -	int bufSize = GetRichTextLength(m_message.GetHwnd(), 1200, TRUE) + 2;
 +	int bufSize = m_message.GetRichTextLength(1200) + 2;
  	ptrW ptszUnicode((wchar_t*)mir_alloc(bufSize * sizeof(wchar_t)));
  	MessageSendQueueItem msi = { 0 };
 @@ -582,7 +582,7 @@ void CSrmmWindow::onClick_History(CCtrlButton*)  void CSrmmWindow::onChange_Message(CCtrlEdit*)
  {
 -	int len = GetRichTextLength(m_message.GetHwnd(), 1200, FALSE);
 +	int len = m_message.GetRichTextLength();
  	cmdListCurrent = nullptr;
  	UpdateReadChars();
  	EnableWindow(GetDlgItem(m_hwnd, IDOK), len != 0);
 @@ -701,7 +701,7 @@ void CSrmmWindow::SetDialogToType()  	m_splitter.Show();
  	UpdateReadChars();
 -	EnableWindow(GetDlgItem(m_hwnd, IDOK), GetRichTextLength(m_message.GetHwnd(), 1200, FALSE) ? TRUE : FALSE);
 +	EnableWindow(GetDlgItem(m_hwnd, IDOK), m_message.GetRichTextLength() != 0);
  	SendMessage(m_hwnd, DM_CLISTSETTINGSCHANGED, 0, 0);
  	SendMessage(m_hwnd, WM_SIZE, 0, 0);
  }
 @@ -786,7 +786,7 @@ void CSrmmWindow::UpdateReadChars()  {
  	if (m_pParent->hwndActive == m_hwnd) {
  		wchar_t szText[256];
 -		int len = GetRichTextLength(m_message.GetHwnd(), 1200, FALSE);
 +		int len = m_message.GetRichTextLength(1200);
  		StatusBarData sbd;
  		sbd.iItem = 1;
 diff --git a/plugins/Scriver/src/msglog.cpp b/plugins/Scriver/src/msglog.cpp index 0f984c7e2d..a96257bef1 100644 --- a/plugins/Scriver/src/msglog.cpp +++ b/plugins/Scriver/src/msglog.cpp @@ -777,7 +777,7 @@ void CSrmmWindow::StreamInEvents(MEVENT hDbEventFirst, int count, int fAppend)  	streamData.hDbEventLast = m_hDbEventLast;
  	streamData.dlgDat = this;
  	streamData.eventsToInsert = count;
 -	streamData.isFirst = fAppend ? GetRichTextLength(m_log.GetHwnd(), CP_ACP, FALSE) == 0 : 1;
 +	streamData.isFirst = fAppend ? m_log.GetRichTextLength() == 0 : 1;
  	streamData.gdat = &g_dat;
  	EDITSTREAM stream = {};
 @@ -791,14 +791,14 @@ void CSrmmWindow::StreamInEvents(MEVENT hDbEventFirst, int count, int fAppend)  		gtxl.flags = GTL_DEFAULT | GTL_PRECISE | GTL_NUMCHARS;
  		gtxl.codepage = 1200;
  		fi.chrg.cpMin = m_log.SendMsg(EM_GETTEXTLENGTHEX, (WPARAM)>xl, 0);
 -		sel.cpMin = sel.cpMax = GetRichTextLength(m_log.GetHwnd(), 1200, FALSE);
 +		sel.cpMin = sel.cpMax = m_log.GetRichTextLength();
  		m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&sel);
  	}
  	else {
  		m_log.SendMsg(WM_SETREDRAW, FALSE, 0);
  		ClearLog();
  		sel.cpMin = 0;
 -		sel.cpMax = GetRichTextLength(m_log.GetHwnd(), 1200, FALSE);
 +		sel.cpMax = m_log.GetRichTextLength();
  		m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&sel);
  		fi.chrg.cpMin = 0;
  		m_isMixed = 0;
 @@ -829,7 +829,7 @@ void CSrmmWindow::StreamInEvents(MEVENT hDbEventFirst, int count, int fAppend)  		CallService(MS_SMILEYADD_REPLACESMILEYS, 0, (LPARAM)&smre);
  	}
 -	int len = GetRichTextLength(m_log.GetHwnd(), 1200, FALSE);
 +	int len = m_log.GetRichTextLength();
  	m_log.SendMsg(EM_SETSEL, len - 1, len - 1);
  	if (!fAppend)
 diff --git a/plugins/Scriver/src/utils.cpp b/plugins/Scriver/src/utils.cpp index ddc542ad38..b1585f00b5 100644 --- a/plugins/Scriver/src/utils.cpp +++ b/plugins/Scriver/src/utils.cpp @@ -50,70 +50,6 @@ void logInfo(const char *fmt, ...)  	}
  }
 -int GetRichTextLength(HWND hwnd, int codepage, BOOL inBytes)
 -{
 -	GETTEXTLENGTHEX gtl;
 -	gtl.codepage = codepage;
 -	if (inBytes) {
 -		gtl.flags = GTL_NUMBYTES;
 -	}
 -	else {
 -		gtl.flags = GTL_NUMCHARS;
 -	}
 -	gtl.flags |= GTL_PRECISE | GTL_USECRLF;
 -	return (int)SendMessage(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)>l, 0);
 -}
 -
 -char* GetRichTextUtf(HWND hwnd)
 -{
 -	int textBufferSize = GetRichTextLength(hwnd, CP_UTF8, TRUE);
 -	if (textBufferSize == 0)
 -		return nullptr;
 -
 -	textBufferSize++;
 -	char *textBuffer = (char*)mir_alloc(textBufferSize);
 -
 -	GETTEXTEX  gt = { 0 };
 -	gt.cb = textBufferSize;
 -	gt.flags = GT_USECRLF;
 -	gt.codepage = CP_UTF8;
 -	SendMessage(hwnd, EM_GETTEXTEX, (WPARAM)>, (LPARAM)textBuffer);
 -	return textBuffer;
 -}
 -
 -int SetRichText(HWND hwnd, const wchar_t *text)
 -{
 -	SETTEXTEX st;
 -	st.flags = ST_DEFAULT;
 -	st.codepage = 1200;
 -	SendMessage(hwnd, EM_SETTEXTEX, (WPARAM)&st, (LPARAM)text);
 -
 -	return GetRichTextLength(hwnd, 1200, FALSE);
 -}
 -
 -int SetRichTextRTF(HWND hwnd, const char *text)
 -{
 -	SETTEXTEX st;
 -	st.flags = ST_DEFAULT;
 -	st.codepage = CP_UTF8;
 -	SendMessage(hwnd, EM_SETTEXTEX, (WPARAM)&st, (LPARAM)text);
 -
 -	return GetRichTextLength(hwnd, 1200, FALSE);
 -}
 -
 -char* GetRichTextRTF(HWND hwnd)
 -{
 -	if (hwnd == 0)
 -		return nullptr;
 -
 -	char *pszText = nullptr;
 -	EDITSTREAM stream = { 0 };
 -	stream.pfnCallback = Srmm_MessageStreamCallback;
 -	stream.dwCookie = (DWORD_PTR)&pszText; // pass pointer to pointer
 -	SendMessage(hwnd, EM_STREAMOUT, SF_RTFNOOBJS | SFF_PLAINRTF | SF_USECODEPAGE | (CP_UTF8 << 16), (LPARAM)&stream);
 -	return pszText; // pszText contains the text
 -}
 -
  void rtrimText(wchar_t *text)
  {
  	static wchar_t szTrimString[] = L":;,.!?\'\"><()[]- \r\n";
 @@ -198,24 +134,6 @@ wchar_t *GetRichEditSelection(HWND hwnd)  	return (wchar_t*)msi.sendBuffer;
  }
 -void AppendToBuffer(char *&buffer, size_t &cbBufferEnd, size_t &cbBufferAlloced, const char *fmt, ...)
 -{
 -	va_list va;
 -	int charsDone;
 -
 -	va_start(va, fmt);
 -	for (;;) {
 -		charsDone = mir_vsnprintf(buffer + cbBufferEnd, cbBufferAlloced - cbBufferEnd, fmt, va);
 -		if (charsDone >= 0)
 -			break;
 -		cbBufferAlloced += 1024;
 -		buffer = (char*)mir_realloc(buffer, cbBufferAlloced);
 -	}
 -	va_end(va);
 -	cbBufferEnd += charsDone;
 -}
 -
 -
  int MeasureMenuItem(WPARAM, LPARAM lParam)
  {
  	LPMEASUREITEMSTRUCT mis = (LPMEASUREITEMSTRUCT)lParam;
 diff --git a/plugins/Scriver/src/utils.h b/plugins/Scriver/src/utils.h index ba88ea469d..dc03c0aba9 100644 --- a/plugins/Scriver/src/utils.h +++ b/plugins/Scriver/src/utils.h @@ -36,15 +36,9 @@ enum SEARCHENGINES {  wchar_t *limitText(wchar_t *text, int limit);
  void logInfo(const char *fmt, ...);
 -int GetRichTextLength(HWND hwnd, int codepage, BOOL inBytes);
  wchar_t *GetRichEditSelection(HWND hwnd);
 -char* GetRichTextRTF(HWND hwnd);
 -char* GetRichTextUtf(HWND hwnd);
  wchar_t *GetRichTextWord(HWND hwnd, POINT *pt);
 -int SetRichText(HWND hwnd, const wchar_t *text);
 -int SetRichTextRTF(HWND hwnd, const char *text);
  void SearchWord(wchar_t * word, int engine);
 -void AppendToBuffer(char *&buffer, size_t &cbBufferEnd, size_t &cbBufferAlloced, const char *fmt, ...);
  int MeasureMenuItem(WPARAM wParam, LPARAM lParam);
  int DrawMenuItem(WPARAM wParam, LPARAM lParam);
  void SetSearchEngineIcons(HMENU hMenu, HIMAGELIST hImageList);
  | 
