fix: #62 Text length limit for CEdit is 30000
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
#include "ShellDlg.h"
|
||||
#include "afxdialogex.h"
|
||||
|
||||
#define EDIT_MAXLENGTH 30000
|
||||
|
||||
BEGIN_MESSAGE_MAP(CAutoEndEdit, CEdit)
|
||||
ON_WM_CHAR()
|
||||
END_MESSAGE_MAP()
|
||||
@@ -77,6 +79,7 @@ BOOL CShellDlg::OnInitDialog()
|
||||
m_nReceiveLength = m_nCurSel;
|
||||
m_Edit.SetSel((int)m_nCurSel, (int)m_nCurSel);
|
||||
m_Edit.PostMessage(EM_SETSEL, m_nCurSel, m_nCurSel);
|
||||
m_Edit.SetLimitText(EDIT_MAXLENGTH);
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// <20>쳣: OCX <20><><EFBFBD><EFBFBD>ҳӦ<D2B3><D3A6><EFBFBD><EFBFBD> FALSE
|
||||
@@ -115,6 +118,17 @@ VOID CShellDlg::AddKeyBoardData(void)
|
||||
//<2F>滻<EFBFBD><E6BBBB>ԭ<EFBFBD><D4AD><EFBFBD>Ļ<EFBFBD><C4BB>з<EFBFBD> <20><><EFBFBD><EFBFBD>cmd <20>Ļ<EFBFBD><C4BB><EFBFBD>ͬw32<33>µı༭<C4B1>ؼ<EFBFBD><D8BC>Ļ<EFBFBD><C4BB>з<EFBFBD><D0B7><EFBFBD>һ<EFBFBD><D2BB> <20><><EFBFBD>еĻس<C4BB><D8B3><EFBFBD><EFBFBD><EFBFBD>
|
||||
strResult.Replace("\n", "\r\n");
|
||||
|
||||
if (strResult.GetLength() + m_Edit.GetWindowTextLength() >= EDIT_MAXLENGTH)
|
||||
{
|
||||
CString text;
|
||||
m_Edit.GetWindowTextA(text);
|
||||
auto n = EDIT_MAXLENGTH - strResult.GetLength() - 5; // <20><>5<EFBFBD><35><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>clear<61><72><EFBFBD><EFBFBD>
|
||||
if (n < 0) {
|
||||
strResult = strResult.Right(strResult.GetLength() + n);
|
||||
}
|
||||
m_Edit.SetWindowTextA(text.Right(max(n, 0)));
|
||||
}
|
||||
|
||||
//<2F>õ<EFBFBD><C3B5><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>ڵ<EFBFBD><DAB5>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>
|
||||
int iLength = m_Edit.GetWindowTextLength(); //kdfjdjfdir
|
||||
//hello
|
||||
@@ -151,6 +165,24 @@ void CShellDlg::OnClose()
|
||||
}
|
||||
|
||||
|
||||
CString ExtractAfterLastNewline(const CString& str)
|
||||
{
|
||||
int nPos = str.ReverseFind(_T('\n'));
|
||||
if (nPos != -1)
|
||||
{
|
||||
return str.Mid(nPos + 1);
|
||||
}
|
||||
|
||||
nPos = str.ReverseFind(_T('\r'));
|
||||
if (nPos != -1)
|
||||
{
|
||||
return str.Mid(nPos + 1);
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
BOOL CShellDlg::PreTranslateMessage(MSG* pMsg)
|
||||
{
|
||||
if (pMsg->message == WM_KEYDOWN)
|
||||
@@ -174,13 +206,20 @@ BOOL CShellDlg::PreTranslateMessage(MSG* pMsg)
|
||||
#ifdef _DEBUG
|
||||
TRACE("[Shell]=> %s", (char*)pSrc);
|
||||
#endif
|
||||
if (0 == strcmp((char*)pSrc, "exit\r\n")) { // <20>˳<EFBFBD><CBB3>ն<EFBFBD>
|
||||
return PostMessage(WM_CLOSE);
|
||||
}
|
||||
else if (0 == strcmp((char*)pSrc, "clear\r\n")) { // <20><><EFBFBD><EFBFBD><EFBFBD>ն<EFBFBD>
|
||||
str = ExtractAfterLastNewline(str.Left(str.GetLength() - 7));
|
||||
m_Edit.SetWindowTextA(str);
|
||||
m_nCurSel = m_Edit.GetWindowTextLength();
|
||||
m_nReceiveLength = m_nCurSel;
|
||||
m_Edit.SetSel(m_nCurSel, m_nCurSel);
|
||||
return TRUE;
|
||||
}
|
||||
int length = str.GetLength() - m_nCurSel;
|
||||
m_iocpServer->OnClientPreSending(m_ContextObject, pSrc, length);
|
||||
m_nCurSel = m_Edit.GetWindowTextLength();
|
||||
if (0 == strcmp((char*)pSrc, "exit\r\n"))
|
||||
{
|
||||
return PostMessage(WM_CLOSE);
|
||||
}
|
||||
}
|
||||
// <20><><EFBFBD><EFBFBD>VK_BACK
|
||||
if (pMsg->wParam == VK_BACK && pMsg->hwnd == m_Edit.m_hWnd)
|
||||
|
||||
Reference in New Issue
Block a user