int pinyin_predict_pord(void *method, const char *lookfor, char * buffer, int buffer_len, int index) { int lenth = 0; static char lookfor_bk[4]; static int page =0; lenth =0; { sprintf (lookfor_bk, "%s", lookfor); bzero (seltab, 16*MAX_PHRASE_LENGTH); putstr ((unsigned char *)lookfor); page =0; } buffer[0] = 0; while (1) { FillAssociateChars (StartKey+index/10 *10); lenth +=(strlen (seltab[index])+1); if (0==strlen (seltab[index])) return -1; if (lenth>=buffer_len ) return index; strcat (buffer, seltab[index]); strcat (buffer, " "); index++; } return -1; }
static void putstr (unsigned char *p) { int index,len =strlen(( char*)p); // printf ("++++++%s\n", p); if (InputCount <= InputMatch) /* All Match */ { index = (int)p[len-2] * 256 + p[len-1]; ClrIn(); if (UseAssociateMode) { FindAssociateKey(index); CurrentPageIndex = StartKey; MultiPageMode = 0; FillAssociateChars(StartKey); if (CurSelNum > 0) { IsAssociateMode = 1; } } }else { int nCount = InputCount - InputMatch,nMatch = InputMatch,i; MultiPageMode = NextPageIndex = CurrentPageIndex = 0; InputCount = InputMatch = 0; for (i =0; i <nCount; i++) save_InpKey[i] =InpKey[nMatch+i]; memset (InpKey, 0, sizeof(InpKey)); for (i =1; i <=nCount; i++) /* feed the additional keys */ { InpKey[InputCount] =save_InpKey[InputCount]; InputCount++; if (InputCount <=InputMatch+1) { FindMatchKey (); MultiPageMode =0; CurrentPageIndex =StartKey; FillMatchChars (StartKey); } } if (InputMatch ==0) /* left key has no match, delete */ { ClrIn(); return; } } }
void hz_filter1 (int tty_fd, unsigned char key) { int inkey = 0, vv; char *is_sel_key = (char *) 0; if (!IsHanziInput) return outchar (tty_fd, key); if (gsCurrent_method == 0) return intcode_hz_filter (tty_fd, key); switch (key) { case '\010': /* BackSpace Ctrl+H */ case '\177': /* BackSpace */ if (gInputCount > 0) { InpKey[--gInputCount] = 0; if (gInputCount == 0) { RootEmpty (); ClrSelArea (); } else if (gInputCount < InputMatch) { FindMatchKey (); gMultiPageMode = 0; gCurrentPageIndex = StartKey; FillMatchChars (StartKey); DispSelection (); } DispRootArea (); } else outchar (tty_fd, key); break; case '\033': /* ESCAPE */ if (gInputCount > 0) { ClrSelArea (); ClrRootArea (); RootEmpty (); DispRootArea (); } else outchar (tty_fd, key); break; case '<': case '-': case ',': case '[': if (gMultiPageMode) { if (gCurrentPageIndex > StartKey) gCurrentPageIndex = gCurrentPageIndex - cur_table->MaxDupSel; else gCurrentPageIndex = StartKey; if (IsAssociateMode) FillAssociateChars (gCurrentPageIndex); else FillMatchChars (gCurrentPageIndex); DispSelection (); } else outchar (tty_fd, key); break; case '>': case ']': case '.': case '=': if (gMultiPageMode) { gCurrentPageIndex = gNextPageIndex; if (IsAssociateMode) FillAssociateChars (gCurrentPageIndex); else FillMatchChars (gCurrentPageIndex); DispSelection (); } else outchar (tty_fd, key); break; case ' ': if (CurSelNum == 0) outchar (tty_fd, key); if (seltab[0][0]) putstr (tty_fd, seltab[0]); break; default: inkey = cur_table->KeyMap[key]; is_sel_key = strchr (cur_table->selkey, key); vv = is_sel_key - cur_table->selkey; if ((!inkey && !is_sel_key) || (!inkey && is_sel_key && (CurSelNum == 0 || seltab[vv][0] == 0))) { IsAssociateMode = 0; RootEmpty (); ClrSelArea (); ClrRootArea (); outchar (tty_fd, key); return; } if (is_sel_key && CurSelNum > 0 && seltab[vv][0]) { putstr (tty_fd, seltab[vv]); return; } /* now it must be inkey? */ IsAssociateMode = 0; if (inkey >= 1 && gInputCount < MAX_INPUT_LENGTH) InpKey[gInputCount++] = inkey; if (gInputCount <= InputMatch + 1) { FindMatchKey (); gCurrentPageIndex = StartKey; gMultiPageMode = 0; FillMatchChars (StartKey); if (gInputCount >= cur_table->MaxPress && CurSelNum == 1 && cur_table->last_full) { // left only one selection return putstr (tty_fd, seltab[0]); } DispSelection (); } DispRootArea (); break; } /* switch */ }