From def1a4ff84d738ef871bc4a33de3f66683ccc099 Mon Sep 17 00:00:00 2001 From: Nick Gammon Date: Wed, 31 Jul 2013 16:58:11 +1000 Subject: [PATCH] Reverted changes to UTF-8 stuff --- sendvw.cpp | 117 ++++++++++++++++++++--------------------------------- 1 file changed, 43 insertions(+), 74 deletions(-) diff --git a/sendvw.cpp b/sendvw.cpp index 981ccfd9..9f5b652a 100644 --- a/sendvw.cpp +++ b/sendvw.cpp @@ -317,95 +317,64 @@ void CSendView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) CMUSHclientDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); - // not hit? Just press on and let the edit view handle it - if (nChar != VK_RETURN) - { - CEditView::OnChar(nChar, nRepCnt, nFlags); - return; - } - - // here for - - - pDoc->m_iCurrentActionSource = eUserTyping; - - CString strText; - GetEditCtrl().GetWindowText(strText); - + if (nChar == VK_RETURN) + { - if (pDoc->m_bUTF_8) - { - - // first convert input text to wide characters + pDoc->m_iCurrentActionSource = eUserTyping; - // find how big table has to be + CString strText; + GetEditCtrl().GetWindowText(strText); - int iWideLength = MultiByteToWideChar (CP_THREAD_ACP, 0, strText, strText.GetLength (), NULL, 0); - - // vector to hold Unicode message - vector vMessage; + // spell check on send? + if (pDoc->m_bSpellCheckOnSend) + { + // look for scripting prefix + if (pDoc->m_bEnableScripts && // providing scripting active + !pDoc->m_strScriptPrefix.IsEmpty () && // and we *have* a script prefix + strText.Left (pDoc->m_strScriptPrefix.GetLength ()) == pDoc->m_strScriptPrefix // and it matches + ) + { } // do nothing (don't spell check script commands) + else + { + Frame.SetStatusMessageNow (Translate ("Spell check ...")); + bool bOK = App.SpellCheck (this, &GetEditCtrl()); + pDoc->ShowStatusLine (); + if (!bOK) + return; // spell check was cancelled + // get the text again, as the spell check may have changed it + GetEditCtrl().GetWindowText(strText); + } - // adjust size - vMessage.resize (iWideLength); + } // end of spell check wanted - // do the conversion now - MultiByteToWideChar (CP_THREAD_ACP, 0, strText, -1, &vMessage [0], iWideLength); - - // now convert back to UTF-8 - - int iUTFLength = WideCharToMultiByte (CP_UTF8, 0, (LPCWSTR) &vMessage [0], iWideLength, NULL, 0, NULL, NULL); - - // get a string pointer - char * buf = strText.GetBuffer (iUTFLength); - // convert into UTF-8 - WideCharToMultiByte (CP_UTF8, 0, (LPCWSTR) &vMessage [0], iWideLength, buf, iUTFLength, NULL, NULL); - strText.ReleaseBuffer (); - } + // tell each plugin what we have received + // the plugin callback OnPluginCommandEntered gets a chance to attack the entire command + pDoc->SendToAllPluginCallbacksRtn (ON_PLUGIN_COMMAND_ENTERED, strText); - // spell check on send? - if (pDoc->m_bSpellCheckOnSend) - { - // look for scripting prefix - if (pDoc->m_bEnableScripts && // providing scripting active - !pDoc->m_strScriptPrefix.IsEmpty () && // and we *have* a script prefix - strText.Left (pDoc->m_strScriptPrefix.GetLength ()) == pDoc->m_strScriptPrefix // and it matches - ) - { } // do nothing (don't spell check script commands) - else + // special string to indicate command should be discarded + if (strText == "\t") { - Frame.SetStatusMessageNow (Translate ("Spell check ...")); - bool bOK = App.SpellCheck (this, &GetEditCtrl()); - pDoc->ShowStatusLine (); - if (!bOK) - return; // spell check was cancelled - // get the text again, as the spell check may have changed it - GetEditCtrl().GetWindowText(strText); + if (!pDoc->m_bAutoRepeat) + SetCommand (""); + return; } - } // end of spell check wanted + // special string to indicate command should be ignored + if (strText == "\r") + return; - // tell each plugin what we have received - // the plugin callback OnPluginCommandEntered gets a chance to attack the entire command - pDoc->SendToAllPluginCallbacksRtn (ON_PLUGIN_COMMAND_ENTERED, strText); + SendCommand (strText, FALSE); - // special string to indicate command should be discarded - if (strText == "\t") - { - if (!pDoc->m_bAutoRepeat) - SetCommand (""); - return; - } +// cancel any previous message on the status line + pDoc->ShowStatusLine (); - // special string to indicate command should be ignored - if (strText == "\r") + pDoc->m_iCurrentActionSource = eUnknownActionSource; return; - SendCommand (strText, FALSE); + } // end of return key -// cancel any previous message on the status line - pDoc->ShowStatusLine (); - - pDoc->m_iCurrentActionSource = eUnknownActionSource; + + CEditView::OnChar(nChar, nRepCnt, nFlags); }