📄 cimeex.cpp
字号:
m_InsertPos.nLine = 0;
return TRUE;
}
BOOL cIMEex::DeleteAfter()
{
m_bChanged = TRUE;
int nInsertIndex = GetInsertIndex();
if( m_InsertPos.nLine >= m_nCurTotalLine - 1 && nInsertIndex >= m_nCurTotalLen ) return FALSE;
char* p = GetInsertBufPtr();
int nDeleteNum = IsDBCSLeadByte( *p ) ? 2 : 1;
if( m_InsertPos.nIndex >= m_pLineDesc[m_InsertPos.nLine].nLen )
{
if( m_pLineDesc[m_InsertPos.nLine+1].nLen == 0 )
{
--m_nCurTotalLine;
for( int i = m_InsertPos.nLine+1 ; i < m_nCurTotalLine ; ++i )
{
m_pLineDesc[i] = m_pLineDesc[i+1];
}
m_pLineDesc[m_InsertPos.nLine].nEndKind = m_pLineDesc[m_InsertPos.nLine+1].nEndKind;
}
else
{
if( m_pLineDesc[m_InsertPos.nLine].nEndKind == EK_WRAP )
{
//´ÙÀ½ÁÙÀ» Áö¿ö¾ßÇÑ´Ù.
m_InsertPos.nIndex = 0;
++m_InsertPos.nLine;
return DeleteAfter();
}
m_pLineDesc[m_InsertPos.nLine].nEndKind = EK_WRAP;
}
}
else
{
memmove( p, p + nDeleteNum, m_nCurTotalLen - nInsertIndex - nDeleteNum );
m_nCurTotalLen -= nDeleteNum;
ZeroMemory( m_pStrBuf + m_nCurTotalLen, nDeleteNum );
m_pLineDesc[m_InsertPos.nLine].nLen -= nDeleteNum;
for( int i = m_InsertPos.nLine + 1 ; i < m_nCurTotalLine ; ++i )
{
m_pLineDesc[i].nStartIndex -= nDeleteNum;
}
if( m_InsertPos.nLine > 0 && m_pLineDesc[m_InsertPos.nLine].nLen == 0 )
{
if( m_pLineDesc[m_InsertPos.nLine-1].nEndKind == EK_WRAP )
{
m_pLineDesc[m_InsertPos.nLine-1].nEndKind = m_pLineDesc[m_InsertPos.nLine].nEndKind;
--m_nCurTotalLine;
--m_InsertPos.nLine;
m_InsertPos.nIndex = m_pLineDesc[m_InsertPos.nLine].nLen;
for( int i = m_InsertPos.nLine + 1 ; i < m_nCurTotalLine ; ++i )
{
m_pLineDesc[i] = m_pLineDesc[i+1];
}
}
}
}
return Wrap( m_InsertPos.nLine );
}
BOOL cIMEex::DeleteBefore()
{
m_bChanged = TRUE;
int nInsertIndex = GetInsertIndex();
if( nInsertIndex <= 0 ) return FALSE;
char* p = GetInsertBufPtr();
// int nDeleteNum = IsDBCSLeadByte( *(p-1) ) ? 2 : 1; //ÇÑ±Û Áß°£¿¡ À־ TRUEÀÌ´Ù.
//¾Æ´Ñ °Íµµ ÀÖ´Ù. T_T
int nDeleteNum = IsDBCSLeadByte( *CharPrev( m_pStrBuf, p ) ) ? 2 : 1;
if( m_InsertPos.nIndex <= 0 )
{
--m_InsertPos.nLine;
m_InsertPos.nIndex = m_pLineDesc[m_InsertPos.nLine].nLen;
if( m_pLineDesc[m_InsertPos.nLine+1].nLen == 0 )
{
--m_nCurTotalLine;
for( int i = m_InsertPos.nLine+1 ; i < m_nCurTotalLine ; ++i )
{
m_pLineDesc[i] = m_pLineDesc[i+1];
}
m_pLineDesc[m_InsertPos.nLine].nEndKind = m_pLineDesc[m_InsertPos.nLine+1].nEndKind;
}
else
{
if( m_pLineDesc[m_InsertPos.nLine].nEndKind == EK_WRAP )
{
return DeleteBefore();
}
m_pLineDesc[m_InsertPos.nLine].nEndKind = EK_WRAP;
}
}
else
{
memmove( p - nDeleteNum, p, m_nCurTotalLen - nInsertIndex );
m_nCurTotalLen -= nDeleteNum;
ZeroMemory( m_pStrBuf + m_nCurTotalLen, nDeleteNum );
m_InsertPos.nIndex -= nDeleteNum;
m_pLineDesc[m_InsertPos.nLine].nLen -= nDeleteNum;
for( int i = m_InsertPos.nLine + 1 ; i < m_nCurTotalLine ; ++i )
{
m_pLineDesc[i].nStartIndex -= nDeleteNum;
}
if( m_InsertPos.nLine > 0 && m_pLineDesc[m_InsertPos.nLine].nLen == 0 )
{
if( m_pLineDesc[m_InsertPos.nLine-1].nEndKind == EK_WRAP )
{
m_pLineDesc[m_InsertPos.nLine-1].nEndKind = m_pLineDesc[m_InsertPos.nLine].nEndKind;
--m_nCurTotalLine;
--m_InsertPos.nLine;
m_InsertPos.nIndex = m_pLineDesc[m_InsertPos.nLine].nLen;
for( int i = m_InsertPos.nLine + 1 ; i < m_nCurTotalLine ; ++i )
{
m_pLineDesc[i] = m_pLineDesc[i+1];
}
}
}
}
return Wrap( m_InsertPos.nLine );
}
BOOL cIMEex::DeleteAllText()
{
ZeroMemory( m_pStrBuf, m_nCurTotalLen );
ZeroMemory( m_pLineDesc, m_nCurTotalLine * sizeof(sLineDesc) );
m_InsertPos.nIndex = 0;
m_InsertPos.nLine = 0;
m_nCurTotalLine = 1;
m_nCurTotalLen = 0;
return TRUE;
}
BOOL cIMEex::GetLineText( int nLine, char* strText, int* pStrLen )
{
if( nLine >= m_nCurTotalLine ) return FALSE;
strncpy( strText, m_pStrBuf + m_pLineDesc[nLine].nStartIndex, m_pLineDesc[nLine].nLen );
strText[m_pLineDesc[nLine].nLen] = 0;
if( pStrLen )
*pStrLen = m_pLineDesc[nLine].nLen;
return TRUE;
}
//´Ù Áö¿ì°í »õ·Î ³Ö´Â´Ù.
//µÚ·Î ¶Ç´Â ¾ÕÀ¸·Î ADDÇÏ´Â ±â´Éµµ ÇÊ¿äÇϸé Ãß°¡.
void cIMEex::SetScriptText( char* str )
{
DeleteAllText();
char strInsert[3];
while( *str )
{
switch( *str )
{
case TEXT_DELIMITER:
{
++str;
switch( *str )
{
case TEXT_NEWLINECHAR:
{
Enter();
}
break;
}
}
break;
default:
{
if( IsDBCSLeadByte(*str) )
{
strInsert[0] = *str;
strInsert[1] = *(++str);
strInsert[2] = 0;
}
else
{
strInsert[0] = *str;
strInsert[1] = 0;
}
Insert( strInsert );
}
break;
}
++str;
}
}
void cIMEex::GetScriptText( char* str )
{
*str = 0; //¾²·¹±â°ª Á¤¸®
for( int i = 0 ; i < m_nCurTotalLine ; ++i )
{
strncat( str, m_pStrBuf + m_pLineDesc[i].nStartIndex, m_pLineDesc[i].nLen );
if( m_pLineDesc[i].nEndKind == EK_ENTER )
strcat( str, "^n" );
}
}
void cIMEex::SetValidCheckMethod( int nMethodNum )
{
m_nValidCheckMethod = nMethodNum;
}
BOOL cIMEex::IsValidChar( unsigned char* str )
{
if( *str == 0 ) return TRUE;
BOOL bValid = FALSE;
switch( m_nValidCheckMethod )
{
////TextArea¿¡ '(ÀÛÀºµû¿ÈÇ¥)¾Èµé¾î°¡µµ·Ï.. ÇÁ·Î½ÃÁ®Ã³¸®¿¡ ¹®Á¦°¡ ÀÖ¾î¼.
case VCM_DBPARAM:
case VCM_ID:
case VCM_PASSWORD:
{
if( *str == '\'' )
break;
}
///
case VCM_DEFAULT:
{
if( (*str >= 32 && *str < 127) || IsDBCSLeadByte(*str) ) //¿µ¹®, ÇѱÛ..ÇÑÀÚ Æ¯¼ö¹®ÀÚ
{
bValid = TRUE;
break;
}
}
case VCM_CHARNAME: //ÇѱÛ( Çѹ®, Ư¼ö¹®ÀÚ Á¦¿Ü)
{
//¿µ¹®, (¼ýÀÚ, ÇѱÛ)¸¸°¡´É
//ÇѱÛüũ
#ifdef TAIWAN_LOCAL
///////////
if( IsDBCSLeadByte(*str) ) //¿µ¹®, ÇѱÛ..ÇÑÀÚ Æ¯¼ö¹®ÀÚ
{
bValid = TRUE;
break;
}
///////////
#else
if( str[0] >= 0xa1 && str[0] <= 0xac && str[1] >= 0x80 && str[1] <= 0xfe )
{
if( str[0] == 0xa4 || ( str[1] > 0x80 && str[1] < 0xa1 ) )
{
bValid = TRUE;
break;
}
// if( str[0] == 0xa4 ) //¿©±ä ¤¡¤¤¤§¤© µî ÃÊÁßÁ¾¼º ´ÜÀÏ·Î Àִ°͵éÀÌ ÀÖ´Ù.
// {
// bValid = TRUE;
// break;
// }
break;
}
if( str[0] >= 0xb0 && str[0] <=0xc8 && str[1] >= 0xa1 && str[1] <= 0xfe )//0xB0A1~0xC8FE
{
bValid = TRUE;
break;
}
if( str[0] >= 0x81 && str[0] <= 0xc6 && str[1] >= 0x41 && str[1] <= 0xfe )
{
bValid = TRUE;
break;
}
#endif
}
// case VCM_ID:
// case VCM_PASSWORD:
{
//¿µ¹®,(¼ýÀÚ)¸¸°¡´É //Á¦ÀϾտ¡ ¼ýÀÚ°¡ °¡´ÉÇѰ¡?
if( ( *str >= 'A' && *str <= 'Z' ) || ( *str >= 'a' && *str <= 'z' ) )
{
bValid = TRUE;
break;
}
}
case VCM_NUMBER:
{
if( *str >= '0' && *str <= '9' )
{
bValid = TRUE;
break;
}
}
}
return bValid;
}
BOOL cIMEex::SetLimitLine( int nMaxLine )
{
if( nMaxLine < m_nCurTotalLine )
return FALSE;
m_nMaxTotalLine = nMaxLine;
return TRUE;
}
void cIMEex::CheckAfterChange()
{
if( m_nValidCheckMethod == VCM_NUMBER )
{
char buf[32];
strcpy( buf, RemoveComma(m_pStrBuf) );
int len = strlen(buf);
if( len == 0 )
{
strcpy( buf, "0" );
}
else
{
if( len > 1 && *buf == '0' )
{
memmove( buf, buf+1, strlen(buf) );
}
AddComma( buf );
}
SetScriptText( buf );
}
}
/*
BOOL cIMEex::IsValidChar( int nChar )
{
if( m_nValidCheckMethod == VCM_NUMBER )
{
if( nChar < '0' || nChar > '9' )
return FALSE;
}
else if( m_nValidCheckMethod == VCM_PASSWORD )
{
//´ë¼Ò¹®ÀÚ¿µ¹® + ¼ýÀÚ
}
else
{
if( nChar < 32 || nChar == 127 ) return FALSE; //127 = ctrl+backsapce
for( int i = 0 ; m_cbInvalidChar[i] ; ++i )
{
if( nChar == m_cbInvalidChar[i] )
return FALSE;
}
//¾ÆÀ̵ðÀÏ °æ¿ì ù¹øÂ° ¹®ÀÚÀÇ À¯È¿¼ºµµ °Ë»ç
}
return TRUE;
}
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -