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

📄 hzinput.c

📁 miniucgui1.30版本的源码
💻 C
📖 第 1 页 / 共 4 页
字号:
    PinyinInputCleanup (ime_tab_path, &Pinyin_Module);#else    for (i = 0; i < nIMENr; i++)        unload_input_table (i);#endif    return FALSE;}static void hz_input_done(void){  int i;  for (i = 0; i < NR_INPUTMETHOD; i++)    if (input_table[i]) {        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]);    }#ifdef _IME_GB2312_PINYIN    PinyinInputCleanup (ime_tab_path, &Pinyin_Module);#endif}static void set_active_input_method(int active){#if _IME_GB2312_PINYIN  if (input_table[active] || active == 1)#else  if (input_table[active])#endif  {    CurIME = active;    cur_table = input_table[active];    ClrIn();#if _IME_GB2312_PINYIN    if (CurIME == 1 || CurIME == 0)#else    if (CurIME == 0)#endif        UseAssociateMode = 0;    else         UseAssociateMode = 1;  }}static void refresh_input_method_area(HWND hwnd, HDC hDC){    RECT rc;    char str[100];    int i;    char minibuf[2];        GetClientRect (hwnd, &rc);    FillBoxWithBitmapPart (hDC, rc.right - 4 - 32, 2,                            CTRLBTN_WIDTH, CTRLBTN_HEIGHT,                           0, 0,                           &sg_bmpIME,                           0, (IsFullChar*CTRLBTN_HEIGHT));		    FillBoxWithBitmapPart (hDC, rc.right - 4 - 16, 2,                            CTRLBTN_WIDTH, CTRLBTN_HEIGHT,                           0, 0,                           &sg_bmpIME,                           CTRLBTN_WIDTH, (IsFullPunc*CTRLBTN_HEIGHT));            if (!IsHanziInput) {            DisabledTextOut (hDC, 2, 2, "【英文】");    }#ifdef _IME_GB2312_PINYIN    else if (CurIME != 1)#else    else#endif    {        minibuf[1] = 0;		strcpy (str, input_table[CurIME]->cname);                for( i = 0; i <= MAX_INPUT_LENGTH ; i++)        {            if (i < InputCount)                minibuf[0] = input_table[CurIME]->KeyName[InpKey[i]];            else                 minibuf[0]=' ';                            if (i == InputMatch && InputCount > InputMatch && i != 0)                strcat (str,"-");                            strcat (str,minibuf);        }                TextOut (hDC, 2, 2, str);                                                DispSelection (hDC);    }#ifdef _IME_GB2312_PINYIN    else        RefreshPYInputArea (&Pinyin_Module, hDC, bTwoLines);#endif}/************************************************************************* *                       Internal Code Input Method                      * *************************************************************************/static hz_input_table *IntCode_Init(void){  hz_input_table *table;  int i,index;  UseAssociateMode = 1;  /* force to no associate */  table = malloc(sizeof(hz_input_table));  if (table == NULL)     {#ifdef _DEBUG      fprintf(stderr, "IME: load_input_method");#endif      return NULL;     }    /* reset to zero. */   memset (table, 0, sizeof (hz_input_table));   strcpy(table->magic_number,MAGIC_NUMBER);   strcpy(table->ename, "IntCode");   strcpy(table->cname, "【内码】");   strcpy(table->selkey, "0123456789abcdef");   table->last_full = 1;   for(i = 0; i < 128; i++)   {      table->KeyMap[i] = 0;      if ((i >= '0' && i <= '9') || (i >= 'a' && i <= 'f'))      {         if (i >= '0' && i <= '9')            index = i - '0';         else index = i -'a' + 10;         table->KeyMap[i] = index;         table->KeyName[index] = toupper(i);      }   }       return table;}/* StartKey <= index < EndKey is valid */static void IntCode_FindMatchKey(void){   unsigned long Key = (InpKey[0] << 12) | (InpKey[1] << 8);   switch(InputCount)   {      case 0:      case 1:         StartKey = EndKey = 0;    /* not display selection */         break;      case 2:         StartKey = Key + 0xA1;          EndKey = Key + 0xFF;  /* A1-A9,B0-F7 A1-FE */         break;      case 3:         StartKey = Key + (InpKey[2] << 4);         if (InpKey[2] == 10) StartKey++; /* A1 */         EndKey = StartKey + 0x10;           if (InpKey[2] == 15) EndKey--;  /* FE */          break;    }}/* ABCD  AB then C=a..f, Sel=0-9 begin display selection        ABC then D=0-f,  Sel=0-f */static void IntCode_FillMatchChars(int index){    int MaxSel,i;       CurSelNum = 0;    if (InputCount < 2) return;    if (InputCount == 2) MaxSel = 10; else MaxSel = 16;        if (index % 256 == 0xA1 && InputCount == 3)     {       seltab[0][0] = '\0';       CurSelNum++;    }    while( CurSelNum < MaxSel && index < EndKey)    {         seltab[CurSelNum][0] = index / 256;          seltab[CurSelNum][1] = index % 256;         seltab[CurSelNum][2] = '\0';         CurSelNum++;         index++;    }        for(i = CurSelNum; i < 16; i++)       seltab[i][0] = '\0';  /* zero out the unused area */    InputMatch = InputCount;    /* check if more than one page */    if ( index < EndKey && CurSelNum == MaxSel && MaxSel == 10)    {      /* 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 intcode_hz_filter(unsigned char key,LPARAM lParam){  int inkey = 0;  switch ( key )  {     case '\010':  /* BackSpace Ctrl+H */     case '\177':  /* BackSpace */        if ( InputCount > 0 )         {           InpKey[--InputCount]=0;           if (InputCount == 0)           {               ClrIn();           }           else if (InputCount >= 2)           {               IntCode_FindMatchKey();               MultiPageMode = 0;               CurrentPageIndex = StartKey;               IntCode_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 - 10;           else CurrentPageIndex = StartKey;           IntCode_FillMatchChars(CurrentPageIndex);                   }        else outchar(key,lParam);        break;     case '=':        if ( MultiPageMode )        {           CurrentPageIndex = NextPageIndex;           IntCode_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];        switch(InputCount)        {           case 0:  /* A-F */           case 1:  /* 0-F */           case 2:  /* A-F */              if (inkey >=0 && !(InputCount != 1 && inkey < 10) &&                   !(InputCount == 1 &&                       ( (InpKey[0]==10 && inkey>9) ||       //A1-A9                         (InpKey[0]==10 && inkey==0) ||                        (InpKey[0]==15 && inkey>7)) ) )      //B0-F7                {                  InpKey[InputCount++] = inkey;                                    if (InputCount >=2)                  {                      IntCode_FindMatchKey();                      MultiPageMode = 0;                      CurrentPageIndex = StartKey;                      IntCode_FillMatchChars(StartKey);                                    }                                }              else if (InputCount == 2 && inkey >= 0 && inkey < CurSelNum &&                       seltab[inkey][0])              {                   putstr(seltab[inkey],lParam);              }              else /* not select key or input key */              {                  ClrIn();                  outchar(key,lParam);                  return;              }              break;           case 3:   /* output char */              if (inkey >=1 && !(InpKey[2] == 10 && inkey == 0) &&                  !(InpKey[2] == 15 && inkey == 15))              {                  seltab[0][0] = (InpKey[0] << 4) | InpKey[1];                  seltab[0][1] = (InpKey[2] << 4) | inkey ;                  seltab[0][2] = '\0';                  putstr(seltab[0],lParam);              }              else              {                  ClrIn();                  outchar(key,lParam);                  return;              }              break;        }  } /* switch */}/*************** below are interface to other modules **************//*  use these functions in other modules only *//* set current active input method                   *//* this function sets the active input method to ime *//* ime value can be: 0 for internal code             *//*                   1 for pinyin                    *//*                   2 for wubi                      */static void imeSetStatus(int iStatusCode, int Value){    switch (iStatusCode) {        case IS_ENABLE:            if (Value && !IsHanziInput)                toggle_input_method ();            else if (!Value && IsHanziInput)                toggle_input_method ();        break;        case IS_FULLCHAR:            if (Value && !IsFullChar)                toggle_half_full ();            else if (!Value && IsFullChar)                toggle_half_full ();        break;        case IS_FULLPUNC:            if (Value && !IsFullPunc)                toggle_punc ();            else if (!Value && IsFullPunc)                toggle_punc ();        break;        case IS_METHOD:            if (Value < 0) {                Value = (CurIME + 1) % nIMENr;                set_active_input_method (Value);            }            else {                if (Value >= nIMENr)                    Value = nIMENr - 1;                if (Value != CurIME)                    set_active_input_method (Value);                else                    return;            }        break;        default:        break;    }}static int imeGetStatus(int iStatusCode){    switch (iStatusCode) {        case IS_ENABLE:            return IsHanziInput;        break;        case IS_FULLCHAR:            return IsFullChar;        break;        case IS_FULLPUNC:            return IsFullPunc;        break;        case IS_METHOD:            return CurIME;        break;        default:        break;    }    return 0;}static inline BOOL imeIsSpecialChar (int chr){    if (chr == '\t' || chr == '\n' || chr == '\r')        return TRUE;    return FALSE;}static inline BOOL imeIsSpecialKey (int scancode){    if (scancode == SCANCODE_TAB            || scancode == SCANCODE_ENTER            || scancode > SCANCODE_F1)        return TRUE;    return FALSE;}static inline BOOL imeIsEffectiveIME (void){    return IsHanziInput || IsFullChar || IsFullPunc;}static int clean_left_ctrl = 1;/*************************************************************************

⌨️ 快捷键说明

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