⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hzinput.c

📁 miniucgui1.30版本的源码
💻 C
📖 第 1 页 / 共 4 页
字号:
  EndKey = cur_table->KeyIndex[InpKey[0]+1];  for (; StartKey < EndKey; StartKey++)  {      key1 = (cur_table->item[StartKey].key1 & mask[InputCount+5]);      key2 = (cur_table->item[StartKey].key2 & mask[InputCount]);      if (key1 > val1) break;      if (key1 < val1) continue;      if (key2 < val2) continue;      break;  }  CharIndex[InputCount] = StartKey;}/*  Find the matched chars/phrases and fill it into SelTab    The starting checked index is j      The Selection Line 1xxx 2xxx,  80-20=60 60/2=30 chinese chars only    0-9 Selection can contain only 30 chinese chars*/static void FillAssociateChars(int index){    unsigned 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 );#if MGUI_BYTEORDER == MGUI_BIG_ENDIAN         PhraseNo = ArchSwap32(PhraseNo);#endif         load_phrase( PhraseNo, str );         strcpy(seltab[CurSelNum],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;}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)    {          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;        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;}/* return value: Has output? */static BOOL hz_filter(unsigned char key, LPARAM lParam){    int inkey = 0,vv;    char *is_sel_key = (char*)0;    if (IsHanziInput) {        unsigned char cc [2];        if (IsFullPunc) {            unsigned char cpunc[4];            int len;                    len = epunc2cpunc (key, cpunc);            if (len != 0) {                writemsg(cpunc, len, lParam, TRUE);                ClrIn();                return TRUE;            }        }            if (IsFullChar && key >= ' ' && key <= 127) {            key = (key - ' ') << 1;            cc[0] = (unsigned char)(fullchar[key]);            cc[1] = (unsigned char)(fullchar[key+1]);                   writemsg(cc, 2, lParam, TRUE);            return FALSE;        }    }    else {        outchar (key, lParam);        return FALSE;    }    if (CurIME == 0) {        intcode_hz_filter(key, lParam);        return TRUE;    }#ifdef _IME_GB2312_PINYIN    if (CurIME == 1) {        Pinyin_HZFilter (&Pinyin_Module, key, lParam);        return TRUE;    }#endif    switch ( key ) {    case '\010':  /* BackSpace Ctrl+H */    case '\177':  /* BackSpace */        if ( InputCount > 0 )         {           InpKey[--InputCount]=0;           if (InputCount == 0)           {               ClrIn();             }           else if (InputCount < InputMatch)           {               FindMatchKey();               MultiPageMode = 0;               CurrentPageIndex = StartKey;               FillMatchChars(StartKey);            }          }        else outchar(key,lParam);        break;     case '\033':  /* ESCAPE */        if (InputCount > 0)         {           ClrIn();         }        else outchar(key,lParam);        break;     case '-':        if ( MultiPageMode )        {           if ( CurrentPageIndex > StartKey)                 CurrentPageIndex = CurrentPageIndex - cur_table->MaxDupSel;           else CurrentPageIndex = StartKey;           if (IsAssociateMode)                FillAssociateChars(CurrentPageIndex);           else FillMatchChars(CurrentPageIndex);         }        else outchar(key,lParam);        break;     case '=':        if ( MultiPageMode )        {           CurrentPageIndex = NextPageIndex;           if (IsAssociateMode)               FillAssociateChars(CurrentPageIndex);           else FillMatchChars(CurrentPageIndex);                   }        else outchar(key,lParam);        break;     case ' ':        if ( CurSelNum == 0 )           outchar(key,lParam);        if ( seltab[0][0] )           putstr(seltab[0],lParam);        break;     default:        inkey   = cur_table->KeyMap[key];        is_sel_key = strchr( cur_table->selkey, key);        vv = is_sel_key - cur_table->selkey;           /* selkey index, strchr may return NULL */       /* if a key is simultaneously inkey & is_sel_key, then selkey first?*/        if ( (!inkey && !is_sel_key) ||              (!inkey && is_sel_key && (CurSelNum == 0 || seltab[vv][0] == 0)) )        {           IsAssociateMode = 0;           ClrIn();           outchar(key,lParam);           break;        }        if (is_sel_key && CurSelNum > 0 && seltab[vv][0])        {            putstr(seltab[vv],lParam);            break;        }                /* now it must be inkey? */        IsAssociateMode = 0;         if ( inkey >= 1 && InputCount < MAX_INPUT_LENGTH )            InpKey[InputCount++] = inkey;                     if (InputCount <= InputMatch+1)         {             FindMatchKey();             CurrentPageIndex = StartKey;             MultiPageMode = 0;             FillMatchChars(StartKey);             if (InputCount >= cur_table->MaxPress && CurSelNum == 1 &&                 cur_table->last_full)             {                // left only one selection                  putstr(seltab[0],lParam);             }        }                break;  } /* switch */  return TRUE;}static void DispSelection(HDC hDC){  int i, pos = 1;  char str[100];  char minibuf[2];  minibuf[1]=0;  str[0]=0;  if (MultiPageMode && CurrentPageIndex != StartKey)   {    strcat(str,"< ");      pos += 2;  }  for( i = 0; i < CurSelNum; i++ )  {     if ( !seltab[i][0] ) {        if (CurIME == 0 && i == 0) 	        continue; 	    else	        break;     }     minibuf[0]= input_table[CurIME]->selkey[i];     strcat(str,minibuf);     strcat(str,seltab[i]);     strcat(str," ");   }  if ( MultiPageMode && NextPageIndex != StartKey)    {     strcat (str,"> ");  }    if (bTwoLines)    TextOut (hDC, 2, 18, str);  else    TextOut (hDC, 150, 2, str);}static void unload_input_table(int i){  if (((i >= 0) && (i < 10)) && input_table[i])  {    if (i == CurIME)    {      if (IsHanziInput)          toggle_input_method();      CurIME = 0;    }    if (input_table[i]->PhraseFile)        fclose(input_table[i]->PhraseFile);    if (input_table[i]->AssocFile)        fclose(input_table[i]->AssocFile);    free_input_method(input_table[i]);    input_table[i] = NULL;  }}static int toggle_input_method(void){  if (input_table[CurIME] || CurIME == 1)  {    IsHanziInput ^= 1;    cur_table = input_table[CurIME];    ClrIn();  }    return IsHanziInput;}static void toggle_half_full(void){   IsFullChar ^= 1;   ClrIn();}static void toggle_punc (void){   IsFullPunc ^= 1;   ClrIn();}static BOOL hz_input_init(void){    char szFileName[MAX_PATH + 1];    char szKey[10];    char szValue[MAX_NAME + 1];    int number;    int i;    if( GetValueFromEtcFile(ETCFILEPATH, "imeinfo", "imetabpath",            ime_tab_path, MAX_PATH) < 0 ) {        fprintf (stderr, "IME: Get imetab file path error!\n");        return FALSE;    }    IsOpened = 1;    IsHanziInput = 1;	// default is hanzi input     IsFullChar = 0;    IsFullPunc = 0;    CurIME = 0;    input_table[0] = IntCode_Init();    if (input_table[0] == NULL)        return FALSE;#ifdef _IME_GB2312_PINYIN    if (!InitPinyinInput (ime_tab_path, &Pinyin_Module)) {        fprintf (stderr, "IME: Init Pinyin module failure!\n");        unload_input_table (0);        return FALSE;    }    nIMENr = 2;#else    nIMENr = 1;#endif    if( !LoadSystemBitmap (&sg_bmpIME, "IMEctrlbtn") ){		fprintf (stderr, "IME: Load the control button failure!\n");		return FALSE;	}    if( GetValueFromEtcFile (ETCFILEPATH, "imeinfo", "imenumber",            szValue, 10) < 0 )        goto error;            number = atoi (szValue);    if(number <= 0)        goto error;    number = (number < NR_INPUTMETHOD) ? number : NR_INPUTMETHOD;    for (i = 0; i < number; i++) {        sprintf(szKey, "ime%d", i);        if( GetValueFromEtcFile(ETCFILEPATH, "imeinfo",            szKey, szValue, MAX_NAME) < 0 )        goto error;        #ifdef _DEBUG        fprintf (stderr, "IME: Loading Input Method %d: %s\n",i, szValue);#endif        strcpy(szFileName, ime_tab_path);        strcat(szFileName, szValue);        strcat(szFileName, ".tab");        input_table [i + nIMENr] = load_input_method(szFileName);        if (!input_table [i + nIMENr])            goto error;    }    nIMENr += number;    if (nIMENr > 1)        CurIME = 1;    cur_table = input_table [CurIME];    return TRUE;    error:#ifdef _IME_GB2312_PINYIN    for (i = 0; i < nIMENr; i++) {        if (i != 1)            unload_input_table (i);    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -