Esempio n. 1
0
void
FillAssociateChars (int index)
{

  char str[25];
  int PhraseNo, CurLen = 0;

  CurSelNum = 0;
  while (CurSelNum < cur_table->MaxDupSel && index < EndKey &&
	 CurLen < MAX_SEL_LENGTH) {

    fseek (cur_table->AssocFile, index << 2, SEEK_SET);
    fread (&PhraseNo, sizeof (int), 1, cur_table->AssocFile);
    load_phrase (PhraseNo, str);
    strcpy (seltab[CurSelNum], str + 2);
    CurLen += strlen (seltab[CurSelNum++]);
    index++;
  }

  if (index < EndKey && CurSelNum == cur_table->MaxDupSel) {
    gNextPageIndex = index;
    gMultiPageMode = 1;
  } else if (gMultiPageMode) {
    gNextPageIndex = StartKey;
  } else
    gMultiPageMode = 0;
}
Esempio n. 2
0
void
FillMatchChars (int j)
{

  int SelNum = 0, CurLen = 0;

  while ((cur_table->item[j].key1 & mask[gInputCount + 5]) == val1 &&
	 (cur_table->item[j].key2 & mask[gInputCount]) == val2 &&
	 SelNum < cur_table->MaxDupSel && j < EndKey &&
	 CurLen < MAX_SEL_LENGTH) {
    if (cur_table->item[j].ch < 0xA1A1)
      load_phrase (cur_table->item[j].ch, seltab[SelNum]);
    else {
      memcpy (&seltab[SelNum], &(cur_table->item[j].ch), 2);
      seltab[SelNum][2] = '\0';
    }
    CurLen += strlen (seltab[SelNum++]);
    j++;
  }

  if (SelNum == 0) {		/* some match found */
    StartKey = save_StartKey;
    EndKey = save_EndKey;
    gMultiPageMode = save_gMultiPageMode;
    gNextPageIndex = save_gNextPageIndex;
    gCurrentPageIndex = save_gCurrentPageIndex;
    return;			/* keep the original selection */
  }

  CurSelNum = SelNum;

  for (SelNum = CurSelNum; SelNum < 16; SelNum++)
    seltab[SelNum][0] = '\0';	/* zero out the unused area */
  InputMatch = gInputCount;	/* until now we have some matches */

  /* check if more than one page */
  if (j < EndKey && (cur_table->item[j].key1 & mask[gInputCount + 5]) == val1
      && (cur_table->item[j].key2 & mask[gInputCount]) == val2
      && CurSelNum == cur_table->MaxDupSel) {
    /* has another matched key, so enter gMultiPageMode, has more pages */
    gNextPageIndex = j;
    gMultiPageMode = 1;
  } else if (gMultiPageMode) {
    gNextPageIndex = StartKey;	/* rotate selection */
  } else
    gMultiPageMode = 0;
}
Esempio n. 3
0
static void FillAssociateChars (int index)
{
	unsigned char str[25];
	int PhraseNo, CurLen = 0;
	char *fp =(char*)cur_table->AssocFile; 
   
	CurSelNum = 0; 

	while ( CurSelNum < cur_table->MaxDupSel && index < EndKey && CurLen < MAX_SEL_LENGTH)
	{
		fp =(char*)cur_table->AssocFile;
		fp +=(index<<2);
		memcpy (&PhraseNo, fp, sizeof (int));
#if MGUI_BYTEORDER == MGUI_BIG_ENDIAN
		PhraseNo = ArchSwap32(PhraseNo);
#endif
		load_phrase( PhraseNo, (char *)str );
		strcpy(seltab[CurSelNum],(char *)(str+2));
		CurLen += strlen(seltab[CurSelNum++]);
		index++;
	}

    /* check if more than one page */
	if ( index < EndKey && CurSelNum == cur_table->MaxDupSel )
	{
      /* has another matched key, so enter MultiPageMode, has more pages */
		NextPageIndex = index;
		MultiPageMode = 1;
	}
	else if (MultiPageMode)
	{
		NextPageIndex = StartKey; /* rotate selection */
	}
	else
		MultiPageMode = 0;
	}
Esempio n. 4
0
gboolean feed_phrase(KeySym ksym, int state)
{
  int i;

//  dbg("ksym:%x %c\n", ksym, ksym);
  load_phrase("phrase.table", &file_modify_time, tran, tranN);
  load_phrase("phrase-ctrl.table", &ctrl_file_modify_time, tran_ctrl, tran_ctrlN);


  if (ksym < 0x7f && isupper(ksym))
    ksym = tolower(ksym);

  struct keystruc *tr;
  int trN;

  if (state & ControlMask) {
    tr = tran_ctrl;
    trN = tran_ctrlN;
  } else {
    tr = tran;
    trN = tranN;
  }

  char tt[2], *str;

  for(i=0; i < trN; i++) {
    if (tr[i].ksym!= ksym)
      continue;

    str = ((state & LockMask) && tr[i].str_caps) ? tr[i].str_caps : tr[i].str;

    if (str) {
send_it:
#if USE_TSIN
      if (current_method_type() == method_type_TSIN && current_CS->im_state == GCIN_STATE_CHINESE) {
        add_to_tsin_buf_str(str);
        if (tsin_cursor_end())
          flush_tsin_buffer();
      }
      else
#endif
      if (gtab_phrase_on()) {
        insert_gbuf_nokey(str);
        if (gtab_cursor_end())
          output_gbuf();
      } else
        send_text(str);
      return TRUE;
    }
  }

#if 0
  if ((state&(ControlMask|ShiftMask|Mod1Mask|Mod4Mask|Mod5Mask))==ShiftMask && ksym>=' ' && ksym < 0x7e) {
    str = tt;
    tt[0]=ksym;
    tt[1]=0;
    goto send_it;
  }
#endif

  return FALSE;
}
Esempio n. 5
0
static void FillMatchChars (int j)
{
	int SelNum = 0, CurLen = 0;
    //bzero( seltab, sizeof( seltab ) );

	while ((cur_table->item[j].key1 & mask[InputCount+5])==val1&&
           (cur_table->item[j].key2 & mask[InputCount])==val2&&
           SelNum <cur_table->MaxDupSel&&j<EndKey&& 
           CurLen < MAX_SEL_LENGTH
		  )
	{
		unsigned short ch = cur_table->item[j].ch;
#if MGUI_BYTEORDER == MGUI_BIG_ENDIAN
		ch = ArchSwap16 (ch);
#endif

		if (ch < 0xA1A1)
			load_phrase (ch, seltab[SelNum]);
		else
		{
			memcpy (&seltab[SelNum], &(cur_table->item[j].ch), 2);
			seltab [SelNum][2] = '\0';
		}

		CurLen += strlen(seltab[SelNum++]);
		j++;
	}
    
	if (SelNum == 0)  /* some match found */
	{
		StartKey = save_StartKey;
		EndKey = save_EndKey;
		MultiPageMode = save_MultiPageMode;
		NextPageIndex = save_NextPageIndex;
		CurrentPageIndex = save_CurrentPageIndex;
		return;    /* keep the original selection */
	}

	CurSelNum = SelNum;

	for (SelNum = CurSelNum; SelNum < 16; SelNum++)
		seltab[SelNum][0] = '\0';  /* zero out the unused area */

	InputMatch = InputCount; /* until now we have some matches */

    /* check if more than one page */
	if (j < EndKey && (cur_table->item[j].key1 & mask[InputCount+5]) == val1 &&
        (cur_table->item[j].key2 & mask[InputCount] ) == val2 &&
        CurSelNum == cur_table->MaxDupSel
       )
	{
      /* has another matched key, so enter MultiPageMode, has more pages */
		NextPageIndex = j;
		MultiPageMode = 1;
	}  
	else if (MultiPageMode)
	{
		NextPageIndex = StartKey; /* rotate selection */
	}
	else
		MultiPageMode = 0;
}