diff --git a/Client/Client/RYLClient/RYLUI/IME/GMIMEPACK.cpp b/Client/Client/RYLClient/RYLUI/IME/GMIMEPACK.cpp index 8e65202..1f867ea 100644 --- a/Client/Client/RYLClient/RYLUI/IME/GMIMEPACK.cpp +++ b/Client/Client/RYLClient/RYLUI/IME/GMIMEPACK.cpp @@ -118,7 +118,7 @@ void GMIMEPACK::InitIme( HWND hMainWnd, UINT unStringLimit ) m_vtCandidateList.reserve( m_unCandidateOnceRetrieveCount ); // '9' is basic windows default retrieve count m_vtCandidateList.clear(); - // ű¹À϶§´Â LID_THAI³Ö´Â´Ù. + // �±��϶��� LID_THAI�ִ´�. if ( CRYLNetworkData::Instance()->m_eInternationalCode == GameRYL::THAILAND ) OnInputLangChange( 0, ZIme::LID_THAI ); // check current keyboard layout else @@ -179,21 +179,21 @@ bool GMIMEPACK::GetIMEMessage( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam case WM_IME_STARTCOMPOSITION: { - // ÄÄÆ÷Áö¼Ç À©µµ¿ì¿¡¼­ ÀÛ¾÷ ½ÃÀÛÇÒ ¶§ + // �������� �����쿡�� �۾� ������ �� return OnImeStartComposition( wParam, lParam ); } break; case WM_IME_COMPOSITION: { - // ÄÄÆ÷Áö¼Ç À©µµ¿ì °ü·Ã ÀÛ¾÷ + // �������� ������ ���� �۾� return OnImeComposition( wParam, lParam ); } break; case WM_IME_ENDCOMPOSITION: { - // ÄÄÆ÷Áö¼Ç ³¡³¯ ¶§ + // �������� ���� �� return OnImeEndComposition( wParam, lParam ); } break; @@ -217,11 +217,11 @@ void GMIMEPACK::OpenIme() ImmSetOpenStatus( m_hImc, true ); -/* Àü°¢ / ¹Ý°¢ ÀüȯÇÒ·Á°í ÇØµÐ Àӽà ÄÚµå +/* ���� / �ݰ� ��ȯ�ҷ��� �ص� �ӽ� �ڵ� DWORD dwConv, dwSent ; ::ImmGetConversionStatus( m_hImc, &dwConv, &dwSent ) ; //dwConv = IME_CMODE_FULLSHAPE ; - dwConv &= ~IME_CMODE_FULLSHAPE; //¹Ý°¢ + dwConv &= ~IME_CMODE_FULLSHAPE; //�ݰ� ::ImmSetConversionStatus( m_hImc, dwConv, dwSent ) ; */ @@ -370,14 +370,18 @@ bool GMIMEPACK::OnKeyDown( WPARAM wParam, LPARAM lParam ) case VK_LEFT: { - LPSTR buf = CharPrev( &m_strCurrentString[ 0 ], &m_strCurrentString[ m_unCaretPos ] ); + if( m_unCaretPos > 0 && m_unCaretPos <= m_strCurrentString.length() ) + { + UINT safePos = (m_unCaretPos > m_strCurrentString.length()) ? static_cast(m_strCurrentString.length()) : m_unCaretPos; + LPSTR buf = CharPrev( &m_strCurrentString[ 0 ], &m_strCurrentString[ 0 ] + safePos ); - UINT unPos = static_cast( &m_strCurrentString[ m_unCaretPos ] - buf ); + UINT unPos = static_cast( (&m_strCurrentString[ 0 ] + safePos) - buf ); - if( unPos != 0 && m_unPrimaryLanguage == ZIme::KEY_THAI ) - unPos = 1; + if( unPos != 0 && m_unPrimaryLanguage == ZIme::KEY_THAI ) + unPos = 1; - m_unCaretPos -= unPos; + m_unCaretPos -= unPos; + } // when shift key was pushed, select string if( m_bShiftPushed ) @@ -423,14 +427,17 @@ bool GMIMEPACK::OnKeyDown( WPARAM wParam, LPARAM lParam ) case VK_RIGHT: { - LPSTR buf = CharNext( &m_strCurrentString[ m_unCaretPos ] ); + if( m_unCaretPos < m_strCurrentString.length() ) + { + LPSTR buf = CharNext( &m_strCurrentString[ 0 ] + m_unCaretPos ); - UINT unPos = static_cast( buf - &m_strCurrentString[ m_unCaretPos ] ); + UINT unPos = static_cast( buf - (&m_strCurrentString[ 0 ] + m_unCaretPos) ); - if( unPos != 0 && m_unPrimaryLanguage == ZIme::KEY_THAI ) - unPos = 1; + if( unPos != 0 && m_unPrimaryLanguage == ZIme::KEY_THAI ) + unPos = 1; - m_unCaretPos += unPos; + m_unCaretPos += unPos; + } // when shift key was pushed, select string if( m_bShiftPushed ) @@ -489,10 +496,11 @@ bool GMIMEPACK::OnKeyDown( WPARAM wParam, LPARAM lParam ) m_bTextSelecting = false; } - else + else if( m_unCaretPos > 0 && m_unCaretPos <= m_strCurrentString.length() ) { - LPSTR buf = CharPrev( &m_strCurrentString[ 0 ], &m_strCurrentString[ m_unCaretPos ] ); - UINT unPos = static_cast( &m_strCurrentString[ m_unCaretPos ] - buf ); + UINT safePos = (m_unCaretPos > m_strCurrentString.length()) ? static_cast(m_strCurrentString.length()) : m_unCaretPos; + LPSTR buf = CharPrev( &m_strCurrentString[ 0 ], &m_strCurrentString[ 0 ] + safePos ); + UINT unPos = static_cast( (&m_strCurrentString[ 0 ] + safePos) - buf ); if( unPos != 0 && m_unPrimaryLanguage == ZIme::KEY_THAI ) unPos = 1; @@ -522,10 +530,10 @@ bool GMIMEPACK::OnKeyDown( WPARAM wParam, LPARAM lParam ) m_bTextSelecting = false; } - else + else if( m_unCaretPos < m_strCurrentString.length() ) { - LPSTR buf = CharNext( &m_strCurrentString[ m_unCaretPos ] ); - UINT unPos = static_cast( buf - &m_strCurrentString[ m_unCaretPos ] ); + LPSTR buf = CharNext( &m_strCurrentString[ 0 ] + m_unCaretPos ); + UINT unPos = static_cast( buf - (&m_strCurrentString[ 0 ] + m_unCaretPos) ); if( unPos != 0 && m_unPrimaryLanguage == ZIme::KEY_THAI ) unPos = 1; @@ -793,7 +801,7 @@ bool GMIMEPACK::OnInputLangChange( WPARAM wParam, LPARAM lParam ) } break; - // Traditional Chinese(´ë¸¸) + // Traditional Chinese(�븸) case ZIme::LID_TRADITIONAL_CHINESE: { m_unPrimaryLanguage = ZIme::KEY_TRADITIONAL_CHINESE; @@ -832,7 +840,7 @@ bool GMIMEPACK::OnInputLangChange( WPARAM wParam, LPARAM lParam ) } break; - // Simplified Chinese(Áß±¹) + // Simplified Chinese(�߱�) case ZIme::LID_SIMPLIFIED_CHINESE: { m_unPrimaryLanguage = ZIme::KEY_SIMPLIFIED_CHINESE; diff --git a/Client/Client/RYLClient/RYLUI/IME/GMIMEPACK.h b/Client/Client/RYLClient/RYLUI/IME/GMIMEPACK.h index 52c7a82..10f76f1 100644 --- a/Client/Client/RYLClient/RYLUI/IME/GMIMEPACK.h +++ b/Client/Client/RYLClient/RYLUI/IME/GMIMEPACK.h @@ -57,7 +57,7 @@ private: //----------------------------------------------------------------------------------------------------- // concerned with copy & paste, cut - static string m_strCopyString; // custom string clipboard ( ¡ØCAUTION¡Ø THIS IS STATIC MEMBER!!! Every IME Instance share this string ) + static string m_strCopyString; // custom string clipboard ( ��CAUTION�� THIS IS STATIC MEMBER!!! Every IME Instance share this string ) UINT m_unSelectStartPos; // caret position where selection start ( smaller than end pos ) UINT m_unSelectEndPos; // caret position where selection end ( larger than start pos ) @@ -117,7 +117,12 @@ public: //----------------------------------------------------------------------------------------------------- // get something inline const char* GetString() { return m_strCurrentString.c_str(); } -inline const string GetSubString( unsigned int unStartPos, unsigned int unEndPos ) { return m_strCurrentString.substr( unStartPos, unEndPos ); } +inline const string GetSubString( unsigned int unStartPos, unsigned int unEndPos ) { + if (unStartPos > m_strCurrentString.length()) return ""; + if (unEndPos > m_strCurrentString.length()) unEndPos = m_strCurrentString.length(); + if (unStartPos > unEndPos) return ""; + return m_strCurrentString.substr( unStartPos, unEndPos - unStartPos ); +} inline const UINT GetStringLength() { return static_cast( m_strCurrentString.length() ); } inline const char* GetBackupString() { return m_strBackupString.c_str(); } inline const UINT GetBackupStrinLength() { return static_cast( m_strBackupString.length() ); }