示例#1
0
int pinyin_translate_word(void *method, const char *strokes, char *buffer, int buffer_len, int index)
{
	static char strokes_bk[32];
	static int  length = 0;
	static int  page = 0;
	int         idex, key;
    int         lensum;
	
	if ( 0!=bcmp (strokes_bk, strokes, strlen(strokes))||WORK_TIM)
	{
		sprintf (strokes_bk, "%s", strokes);
        WORK_TIM = FALSE;
        page = 0;
		length = strlen (strokes);
		ClrIn ();
		
		for (idex = 0; idex<length; idex++)
		{
			key = cur_table->KeyMap[(int)(*(strokes+idex))];
			InpKey [InputCount++] = key;
		}

		FindMatchKey ();
    	CurrentPageIndex = StartKey;
    	MultiPageMode    = 1;
    	FillMatchChars(StartKey);
    	if (InputMatch<InputCount)
       		return -1;
    }
    
    lensum  =0; 
    buffer[0] =0;
    MultiPageMode =1;

    while (MultiPageMode)
    {
        if (page!=index/10)
        {
            page= index/10;
            FillMatchChars (StartKey+page*10); 
        }

    	if (InputMatch<InputCount)
       		return -1;
        lensum+=(strlen(seltab[index%10])+1);

        if (lensum>buffer_len)
           return index; 
        if (0==strlen (seltab[index%10]))
            break;
        strcat (buffer, seltab[index%10]);
        strcat (buffer, " ");
        index++;
        
    }
   return -1;
  
}
示例#2
0
BOOL char_match_exist (const char *match)
{
    int len = strlen (match);
    int idex = 0;
    int key = 0;

    bzero (InpKey, sizeof (long)*InputCount);
    FindMatchKey ();
    ClrIn();

    for (idex=0; idex<len; idex++)
    {
       key =(char)(cur_table->KeyMap[(int)(*(match+idex))]); 
       InpKey[InputCount++] = key;
    }

    FindMatchKey();
    CurrentPageIndex = StartKey;
    MultiPageMode    = 1;
    FillMatchChars(StartKey);

    if (EndKey== 0)
    {
       return FALSE;
    }
    else
    {
       return TRUE;
    }
       
}
示例#3
0
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;
		}

	}
}
示例#4
0
文件: hzinput.c 项目: descent/jmcce
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 */
}