📄 jyinput.c
字号:
int xPos = (FONT_SIZE + 1) * (m_nSelectPos % 10) + SECONDLINE_XPOS - 1;
for (x = xPos; x < xPos + FONT_SIZE + 2; x ++)
{
SetPixel(hdc, x, y, ~GetPixel(hdc, x, y) );
}
}
return TRUE;
}
static void _XorAlpha(int nIndex, HDC hdc)
{
int x, y;
for(y = FIRSTLINE_YPOS + 1; y < FIRSTLINE_YPOS + FONT_SIZE; y ++){
int xPos = FIRSTLINE_XPOS + (FONT_SIZE + 4) * nIndex - 1;
for( x = xPos; x <= 8 + xPos ; x ++){
SetPixel(hdc, x, y, ~GetPixel(hdc, x, y) );
}
}
}
static void _Draw_EN_AlphaList(HDC hdc)
{
int n;
char szOut[10];
int nKeyOffset ;
if (m_stEN_info.nCurKey == 0)
{
return;
}
nKeyOffset = m_stEN_info.nCurKey - KEY_0;
memset(szOut, 0, 10);
for(n = 0; n < input_alpha_count[nKeyOffset]; n++){
if (m_piinfo.keymode & IME_MODE_ALPHABET_LOW) {
szOut[n * 2] = input_alpha_list_low[nKeyOffset][n];
}else{
szOut[n * 2] = input_alpha_list_up[nKeyOffset][n];
}
szOut[n * 2 + 1] = ' ';
}
TextOut(hdc, FIRSTLINE_XPOS, FIRSTLINE_YPOS, szOut);
_XorAlpha(m_stEN_info.nPressCount, hdc);
}
static void _XorSymbol(int nIndex, HDC hdc)
{
int x, y;
for(y = SECONDLINE_YPOS + 1; y < SECONDLINE_YPOS + FONT_SIZE; y ++){
int xPos = SECONDLINE_XPOS + FONT_SIZE * nIndex;
for( x = xPos; x <= 8 + xPos ; x ++){
SetPixel(hdc, x, y, ~GetPixel(hdc, x, y) );
}
}
}
static void _DrawSymbolKeyPad(HDC hdc)
{
int n = 0;
int x, y;
char szSymbol[2];
for(n = 0; n < LINE_DISPLAY_MAXCOUNT; n++)
{
int k = n + m_nSymbolPage * LINE_DISPLAY_MAXCOUNT;
if (k > sizeof(array_symbol))
{
break;
}
memset(szSymbol, 0, 2);
szSymbol[0] = array_symbol[k];
TextOut(hdc, SECONDLINE_XPOS + FONT_SIZE * n, SECONDLINE_YPOS, (const char *)szSymbol);
}
_XorSymbol(m_nSelectPos % LINE_DISPLAY_MAXCOUNT, hdc);
}
static void _Draw_Select_HZ(HDC hdc)
{
ST_INPUT_INFO *piinfo = &m_piinfo;
if (piinfo->outcode_cur == 0 || piinfo->hz_found_begin == piinfo->hz_found_end)
{
int n = 0;
if (m_bHZAssn)
{
int j = 0;
char hz_buf[3] = "";
char *p = (char *)g_pstAssnArray[m_nAssnSelectIndex].snWords;
p += m_assn_Hz_Pos * sizeof(unsigned short);
for (j=0; j < LINE_DISPLAY_MAXCOUNT; j++)
{
if (*p == '\0')
break;
memcpy(hz_buf, p, 2);
hz_buf[2] = '\0';
p += 2;
TextOut(hdc, SECONDLINE_XPOS + (FONT_SIZE + 1) * j, SECONDLINE_YPOS, (const char *)hz_buf );
}
_XorHzSelect(hdc);
}
else
{
if (piinfo->outcode_cur == 0)
{
for(n = 0; n < LINE_DISPLAY_MAXCOUNT; n++)
{
TextOut(hdc, SECONDLINE_XPOS + (FONT_SIZE + 1) * n, SECONDLINE_YPOS
, (const char *)often_hz[n + m_often_Hz_Pos] );
}
_XorHzSelect(hdc);
}
}
}
else
{
int j = 0;
char hz_buf[3] = "";
while( j < LINE_DISPLAY_MAXCOUNT)
{
if((piinfo->hz_found_cur + 2 * j) < piinfo->hz_found_end)
{
memcpy(hz_buf, &(key_arrary_hz_select[j]), 2);
hz_buf[2] = '\0';
TextOut(hdc, SECONDLINE_XPOS + (FONT_SIZE + 1) * j, SECONDLINE_YPOS, (const char *)hz_buf );
j++;
}
else
{
TextOut(hdc, SECONDLINE_XPOS + (FONT_SIZE + 1) * j, SECONDLINE_YPOS, (const char *)" " );
j++;
}
}
_XorHzSelect(hdc);
}
}
static void _put_py_to_array()
{
int j = 0;
char hz_buf[3] = "";
ST_INPUT_INFO *piinfo = &m_piinfo;
while( j < LINE_DISPLAY_MAXCOUNT)
{
if((piinfo->hz_found_cur + 2 * j) < piinfo->hz_found_end)
{
key_arrary_hz_select[j] = g_pszPyImeArray[piinfo->hz_found_cur + 2 * j ];
key_arrary_hz_select[j] |= ((unsigned short)(g_pszPyImeArray[piinfo->hz_found_cur + 2 * j + 1 ]) << 8 );
}
else if (strcmp(piinfo->py_code, "shen") == 0)
{
j--;
key_arrary_hz_select[j] = 0xca;
key_arrary_hz_select[j] |= ((unsigned short)(0xb2) << 8 );
break;
}
j++;
}
}
static unsigned short _proc_en_key_press(int nKey)
{
ST_INPUT_INFO *piinfo = &m_piinfo;
if (piinfo->keymode & IME_MODE_ALPHABET_LOW || IME_MODE_ALPHABET_UP)
{
if (nKey == KEY_LEFT)
{
m_stEN_info.nPressCount --;
m_stEN_info.nTime = 0;
if (m_stEN_info.nPressCount < 0) {
m_stEN_info.nPressCount = input_alpha_count[m_stEN_info.nCurKey - KEY_0] - 1;
}
}
if (nKey == KEY_RIGHT)
{
m_stEN_info.nPressCount ++;
m_stEN_info.nTime = 0;
if (m_stEN_info.nPressCount > input_alpha_count[m_stEN_info.nCurKey - KEY_0] - 1) {
m_stEN_info.nPressCount = 0;
}
}
//if (nKey == KEY_XING)
//{
// return 127;
//}
if (!((nKey >= KEY_2 && nKey <= KEY_9) || nKey == 0 )) {
return 0;
}
if (nKey == 0 && m_stEN_info.nCurKey != 0) {
int nAlpha = 0;
if (piinfo->keymode & IME_MODE_ALPHABET_LOW) {
nAlpha = input_alpha_list_low[m_stEN_info.nCurKey - KEY_0][m_stEN_info.nPressCount];
}else{
nAlpha = input_alpha_list_up[m_stEN_info.nCurKey - KEY_0][m_stEN_info.nPressCount];
}
m_stEN_info.nCurKey = 0;
m_stEN_info.nTime = 0;
m_stEN_info.nPressCount = 0;
return nAlpha;
}
if (m_stEN_info.nCurKey == 0) {
m_stEN_info.nCurKey = nKey;
m_stEN_info.nTime = 0;
m_stEN_info.nPressCount = 0;
return 0;
}
if (m_stEN_info.nCurKey == nKey) {
m_stEN_info.nPressCount ++;
m_stEN_info.nTime = 0;
if (m_stEN_info.nPressCount > input_alpha_count[m_stEN_info.nCurKey - KEY_0] - 1) {
m_stEN_info.nPressCount = 0;
}
return 0;
}
if (m_stEN_info.nCurKey != nKey) {
int nAlpha = 0;
if (piinfo->keymode & IME_MODE_ALPHABET_LOW) {
nAlpha = input_alpha_list_low[m_stEN_info.nCurKey - KEY_0][m_stEN_info.nPressCount];
}else{
nAlpha = input_alpha_list_up[m_stEN_info.nCurKey - KEY_0][m_stEN_info.nPressCount];
}
m_stEN_info.nCurKey = nKey;
m_stEN_info.nTime = 0;
m_stEN_info.nPressCount = 0;
return nAlpha;
}
}
return 0;
}
static void _find_py_hzcode(char *outcode, int outcode_pos, int *Begin, int *End)
{
unsigned short int begin,end;
unsigned i,off;
unsigned char ExCode[20];
BOOL First = TRUE;
unsigned char * tmp;
if(outcode_pos < 1){
*Begin = 0;
*End = 0;
return ;
}
Py_List2 = (unsigned char *)(g_pszPyImeArray + 0x3747);
Py_List3 = (unsigned char *)g_pszPyImeArray;
tmp = (unsigned char *)(Py_List1 + (outcode[0] - 'a') * 2);
begin = *tmp++;
begin |= (*tmp << 8);
tmp = (unsigned char *)(Py_List1 + (outcode[0] - 'a') * 2 + 2);
end = *tmp++;
end |= (*tmp << 8);
if(begin == end){
*Begin = 0;
*End = 0;
return ;
}
off = begin;
while(off < end){
i = 0;
while (((ExCode[i] = *(Py_List2 + off + 2 + i)) & 0x80) == 0){
if (ExCode[i] < 'a') ExCode[i] = ExCode[i] - 'A' + 'a';
i++;
}
ExCode[i]=0;
off = off + 2 + i;
if (_mystrncmp((char*)ExCode, outcode + 1, outcode_pos - 1) > 0) break;
if(First == FALSE) break;
if (strcmp(outcode, "a") == 0||
strcmp(outcode, "e") == 0||
strcmp(outcode, "o") ==0) {
First = FALSE;
}
else if (First && (_mystrncmp((char*)ExCode, outcode + 1, outcode_pos - 1)) == 0){
begin = off;
First = FALSE;
}
}
if (First) end = begin;
else end = off;
tmp = (unsigned char *)(Py_List2 + begin);
begin = *tmp++;
begin |= (*tmp << 8);
begin &= 0xff7f;
_ExchLowHigh((char *)&begin,2);
tmp = (unsigned char *)(Py_List2 + end);
end = *tmp++;
end |= (*tmp << 8);
end &= 0xff7f;
_ExchLowHigh((char *)&end,2);
if(end - begin > 300) end = begin + 300;
i = end - begin;
*Begin = begin;
*End = end;
return;
}
static BOOL _find_alpha_list(unsigned char cpy, int nPos)
{
ST_INPUT_INFO *piinfo = &m_piinfo;
int n;
int nAlphiCount = alpha_count[piinfo->hz_outcode[nPos] - KEY_0];
for(n = 0; n < nAlphiCount; n++){
if (alpha_list[piinfo->hz_outcode[nPos] - KEY_0][n] == cpy ) {
return TRUE;
}
}
return FALSE;
}
static int _proc_py_index()
{
ST_INPUT_INFO *piinfo = &m_piinfo;
int nAlphiCount, nLen, j, n, k, i;
unsigned char szFirst;
int nCount = 0;
memset(m_szPylist, 0, sizeof(m_szPylist));
szFirst = alpha_list[piinfo->hz_outcode[0] - KEY_0][0];
nAlphiCount = alpha_count[piinfo->hz_outcode[0] - KEY_0];
nLen = strlen(piinfo->hz_outcode);
//从py_table中获取相关的拼音列表
for(n = 0; n < nAlphiCount; n++)
{
for(j = 0; j < 37; j++)
{
char * szPy = (char *)py_table[szFirst - 'a'+ n][j];
if (szPy == NULL )
break;
if (strlen(szPy) == 0)
break;
if ((int)strlen(szPy) == nLen)
{
for(k = 0; k < nLen; k ++)
{
if (_find_alpha_list(szPy[k], k))
{
if (k == nLen - 1)
{
memcpy(m_szPylist + strlen(m_szPylist) , szPy, strlen(szPy));
memcpy(m_szPylist + strlen(m_szPylist), " ", 1);
nCount ++;
}
}
else
{
break;
}
}
}
}
}
//如果没有找到相关的拼音列表而且只有一个按键,查找有效铵键中的字母做为拼音列表
if (nCount == 0 && piinfo->outcode_cur == 1)
{
int i;
//这里判断键盘中的第一个字母是不是i,v,u
for( i = 0 ;i < nAlphiCount; i++)
{
char * szPy = (char *)py_table[szFirst - 'a'+ i][0];
//如果是i,v,u这三个字母,它的拼音长度为0
if (strlen(szPy) != 0)
{
memcpy(m_szPylist, szPy, 1);
memcpy(m_szPylist + strlen(m_szPylist) , " ", 1);
nCount ++;
break;
}
}
}
//如果还是没有找到的话,查找自动生成表,以获得相关的拼音列表
if (nCount == 0)
{
for(i = 0 ; i < AUTO_COMPLETE_COUNT; i ++)
{
BOOL bFind;
if (nCount > 0 )
break;
bFind = TRUE;
for(j = 0; j < PY_TYPE_MAXCOUNT; j++)
{
if (piinfo->hz_outcode[j] == 0)
{
if (bFind)
{
nCount ++;
memcpy(m_szPylist, auto_complete[i][0], strlen((char *)auto_complete[i][0]));
memcpy(m_szPylist + strlen(m_szPylist) , " ", 1);
}
break;
}
if (!_find_alpha_list(auto_complete[i][0][j], j) )
{
bFind = FALSE;
break;
}
}
}
}
return nCount;
}
static BOOL _Py_Select_Change()
{
ST_INPUT_INFO *piinfo = &m_piinfo;
int hz_found_begin = 0;
int hz_found_end = 0;
_find_py_hzcode(piinfo->py_code, piinfo->outcode_cur, &hz_found_begin, &hz_found_end);
piinfo->hz_found_begin = hz_found_begin;
piinfo->hz_found_end = hz_found_end;
piinfo->hz_found_cur = piinfo->hz_found_begin;
if (piinfo->hz_found_begin == piinfo->hz_found_end)
{
if (m_bHZAssn)
_put_assn_to_array();
else
_put_often_to_array();
}else
_put_py_to_array();
return TRUE;
}
static void _XorBhList(HDC hdc)
{
int i;
char szOut[BHTEXT_MAXSHOWCOUNT * 2 + 1] = "";
int nCount = m_piinfo.outcode_cur;
if (nCount < BHTEXT_MAXSHOWCOUNT)
{
for (i = 0; i < nCount; i++)
{
int k = m_piinfo.hz_outcode[i] - 1;
memcpy(szOut + i * 2, __g_sBHText+(k * 2), 2);
}
}
else
{
for (i = 0; i < BHTEXT_MAXSHOWCOUNT; i++)
{
int k = m_piinfo.hz_outcode[nCount - BHTEXT_MAXSHOWCOUNT + i] - 1;
memcpy(szOut + i * 2, __g_sBHText + (k * 2), 2);
}
}
TextOut(hdc, FONT_SIZE * 3, 2, szOut);
return ;
}
static int _find_bh_hzcode()
{
ST_INPUT_INFO *piinfo = &m_piinfo;
int n = 0;
int nPos = 0;
int nFind = 0;
char szBuQiBM[20] = "";
int nIndex;
int nCount = m_piinfo.outcode_cur;
m_nBHFind = 0;
piinfo->hz_found_begin == 0;
memset((char*)&m_sBHHZList, 0, BHSELECT_MAXCOUNT);
memcpy(szBuQiBM, piinfo->hz_outcode, piinfo->outcode_cur);
for (n = 0; n < nCount; n++)
{
szBuQiBM[n] = m_piinfo.hz_outcode[n] + '0';
}
//这里笔画从1开始,所以这里需要减一
for (nIndex = m_stBHIndex.nBhIndex[m_piinfo.hz_outcode[0]-1]; nIndex<m_stBHIndex.nBhIndex[m_piinfo.hz_outcode[0]]; nIndex++)
{
int nCmp = memcmp(g_pstBhTable[nIndex].szBm, szBuQiBM, nCount);
if (nCmp == 0)
{
memcpy((char*)&m_sBHHZList[m_nBHFind], g_pstBhTable[nIndex].szHz, 2);
m_nBHFind++;
if (m_nBHFind >= BHSELECT_MAXCOUNT)
break;
}
}
piinfo->hz_found_end = m_nBHFind * 2;
return m_nBHFind;
}
static void _put_bh_to_array()
{
int n;
for(n = 0; n < LINE_DISPLAY_MAXCOUNT; n ++)
{
int k = n + m_nSelectPos;
if (k > m_nBHFind)
break;
key_arrary_hz_select[n] = m_sBHHZList[m_nSelectPos - m_nSelectPos % LINE_DISPLAY_MAXCOUNT + n];
}
}
static BOOL _proc_py_key_press(unsigned short key)
{
ST_INPUT_INFO *piinfo = &m_piinfo;
if(key >= KEY_2 && key <= KEY_9)
{
int nCount;
if (piinfo->outcode_cur >= PY_TYPE_MAXCOUNT)
return TRUE;
piinfo->hz_outcode[piinfo->outcode_cur++] = (char)key;
piinfo->hz_outcode[piinfo->outcode_cur] ='\0';
nCount = _proc_py_index();
if (nCount == 0)
{
if (m_nPyCount != 0)
{
piinfo->hz_outcode[piinfo->outcode_cur-1] ='\0';
piinfo->outcode_cur --;
nCount = _proc_py_index();
}
}
m_nPyCount = nCount;
m_nPySelect = 0;
m_nFirst = 0;
memcpy(piinfo->py_code , m_szPylist + (piinfo->outcode_cur + 1) * m_nPySelect, piinfo->outcode_cur) ;
piinfo->py_code[piinfo->outcode_cur] = 0;
_Py_Select_Change();
m_nSelectPos = 0;
return TRUE;
}
else if (key == KEY_XING)
{
if (piinfo->outcode_cur != 0)
{
m_nPySelect ++;
if (m_nPySelect >m_nPyCount - 1)
m_nPySelect = 0;
memcpy(piinfo->py_code , m_szPylist + (piinfo->outcode_cur + 1) * m_nPySelect, piinfo->outcode_cur) ;
piinfo->py_code[piinfo->outcode_cur] = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -