test: country.c Source File

Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

# country.c

Go to the documentation of this file.

    00001 // Copyright (c) 1985 - 1999, Microsoft Corporation
    00002 //
    00003 //  MODULE:   country.c
    00004 //
    00005 //  PURPOSE:   Console IME control.
    00006 //             FarEast country specific module for conime.
    00007 //
    00008 //  PLATFORMS: Windows NT-FE 3.51
    00009 //
    00010 //  FUNCTIONS:
    00011 //    ImeUIMakeInfoString() - routine for make status string
    00012 //
    00013 //  History:
    00014 //
    00015 //  10.Jul.1996 v-HirShi (Hirotoshi Shimizu)    Created for TAIWAN & KOREA & PRC
    00016 //
    00017 //  COMMENTS:
    00018 //
    00019 #include "precomp.h"
    00020 #pragma hdrstop
    00021
    00022 // for Japanese
    00023 //                             none  plaural single    auto  phrase
    00024 WCHAR IMECMode[]          = { 0x7121, 0x8907, 0x5358, 0x81ea, 0x9023 };
    00025 WCHAR IMECModeRoman[]     = { 0xff9b, 0xff70, 0xff8f, 0x0020 };
    00026 WCHAR IMECModeKana[]      = { 0xff76, 0xff85, 0x0020, 0x0020 };
    00027 WCHAR IMECModeAHAN[]      = { 0x534a, 0x0041, 0x0020 };
    00028 WCHAR IMECModeAZEN[]      = { 0x5168, 0xff21 };
    00029 WCHAR IMECModeHHAN[]      = { 0x534a, 0xff71, 0x0020 };
    00030 WCHAR IMECModeHZEN[]      = { 0x5168, 0x3042 };
    00031 WCHAR IMECModeKHAN[]      = { 0x534a, 0xff76, 0x0020 };
    00032 WCHAR IMECModeKZEN[]      = { 0x5168, 0x30ab };
    00033
    00034 // for CHT /Taiwan
    00035 WCHAR IMECModeFullShape[] = { 0x5168, 0x5f62 };
    00036 WCHAR IMECModeHalfShape[] = { 0x534a, 0x5f62 };
    00037 WCHAR IMECModeKeyboard[]  = { 0x9375, 0x76e4 };
    00038 WCHAR IMECModeSymbol[]    = { 0x7b26, 0x53f7 };
    00039 WCHAR IMECGuide[9][7]     = {{ 0x5009, 0x9821, 0x8acb, 0x8f38, 0x5165, 0x5b57, 0x6839 },    // kura
    00040                              { 0x5167, 0x78bc, 0x8acb, 0x8f38, 0x5165, 0x5167, 0x78bc },    // naima
    00041                              { 0x55ae, 0x78bc, 0x8acb, 0x8f38, 0x5165, 0x55ae, 0x78bc },    // tanma
    00042                              { 0x901f, 0x6210, 0x8acb, 0x8f38, 0x5165, 0x5b57, 0x6839 },    // sokusei
    00043                              { 0x5927, 0x6613, 0x8acb, 0x8f38, 0x5165, 0x5b57, 0x6839 },    // taieki
    00044                              { 0x82f1, 0x6570, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000 },    // eisuu
    00045                              { 0xff55, 0xff53, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000 },    // US
    00046                              { 0x6ce8, 0x97f3, 0x8acb, 0x8f38, 0x5165, 0x7b26, 0x865f },    // chuon fugou
    00047                              { 0x6ce8, 0x97f3, 0x8acb, 0x3000, 0x9078, 0x3000, 0x5b57 } }; // chuon senji
    00048 /*
    00049 WCHAR IMECNAMEPRC[9][7]   = { 0x5168, 0x62fc, 0 };                   // zenhei
    00050                             { 0x53cc, 0x62fc, 0 };                   // souhei
    00051                             { 0x6807, 0x51c6, 0 };                   // sijun
    00052                             { 0x53cc, 0x6253, 0 };                   // souda
    00053                             { 0x90d1, 0x7801, 0 };                   // hou?
    00054                             { 0x8868, 0x5f62, 0x7801, 0 };           // hyoukei
    00055                             { 0x7e41, 0x4f53, 0x6ce8, 0x97f3, 0 };   // chuon
    00056                             { 0x7e41, 0x4f53, 0x4ed3, 0x9889, 0 };   // kaihou
    00057                             { 0x533a, 0x4f4d, 0 };                   // kui
    00058                             { 0x0047, 0x0042, 0x004a, 0x5185, 0x7801, 0 };   // GBKnaikou
    00059                             { 0x0055, 0x006e, 0x0069, 0x0063, 0x006f, 0x0064, 0x0065, 0 };   // Unicode
    00060 */
    00061
    00062 BOOL
    00063 ConimeHotkey(
    00064     HWND hWnd,
    00065     HANDLE hConsole,
    00066     DWORD HotkeyID
    00067     )
    00068 {
    00069 //    PCONSOLE_TABLE ConTbl;
    00070 //
    00071 //    ConTbl = SearchConsole(hConsole);
    00072 //    if (ConTbl == NULL) {
    00073 //        DBGPRINT(("CONIME: Error! Cannot found registed Console\n"));
    00074 //        return FALSE;
    00075 //    }
    00076
    00077     return ImmSimulateHotKey(hWnd,(DWORD)HotkeyID);
    00078 }
    00079
    00080 BOOL
    00081 GetIMEName(
    00082     PCONSOLE_TABLE ConTbl
    00083     )
    00084 {
    00085     WCHAR buf[MaxBufSize];
    00086     WCHAR name[MaxBufSize];
    00087     DWORD bufsize = MaxBufSize;
    00088     LONG lResult;
    00089     HKEY hkLayout;
    00090     int i;
    00091
    00092     ConTbl->LayoutName[0] = TEXT('\0');
    00093     ConTbl->GuideLine[0] = TEXT('\0');
    00094
    00095     if (ImmEscape(ConTbl->hklActive, ConTbl->hIMC_Current, IME_ESC_IME_NAME, (LPTSTR)&name) == 0)
    00096     {
    00097         if (!ImmGetIMEFileName(ConTbl->hklActive, (LPTSTR)&name, MaxBufSize ) )
    00098         {
    00099             if (GetKeyboardLayoutName((LPTSTR)&name) )
    00100             {
    00101                 /*
    00102                  * quick dirty ImmIsIME
    00103                  */
    00104                 if (name[0] != TEXT('E') &&
    00105                     name[0] != TEXT('e'))
    00106                 {
    00107                     return FALSE;
    00108                 }
    00109
    00110                 lstrcpy( buf, KBDLAYOUT );
    00111                 lstrcat( buf, KBDSEPALATER );
    00112                 lstrcat( buf, name );
    00113                 lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
    00114                                        (LPCTSTR)buf,
    00115                                        0,
    00116                                        KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS,
    00117                                        &hkLayout );
    00118                 if ( lResult == ERROR_SUCCESS ) {
    00119                     lResult = RegQueryValueEx( hkLayout,
    00120                                                KBDLAYOUTTEXT,
    00121                                                NULL,
    00122                                                NULL,
    00123                                                (LPBYTE)ConTbl->LayoutName,
    00124                                                &bufsize );
    00125                     RegCloseKey( hkLayout );
    00126                     if (ConTbl->LayoutName[0] != TEXT('\0')) {
    00127                         for (i = 0; i < 8; i ++){
    00128                             if ((ConTbl->LayoutName[0] == IMECGuide[i][0]) &&
    00129                                 (ConTbl->LayoutName[1] == IMECGuide[i][1]) ) {
    00130                                 lstrcpyn(&(ConTbl->GuideLine[0]), &(IMECGuide[i][2]), IMECGuideLen+1);
    00131                                 break;
    00132                             }
    00133                         }
    00134                     }
    00135                 }
    00136                 else{
    00137                     return FALSE;
    00138                 }
    00139             }
    00140             else
    00141             {
    00142                 return FALSE;
    00143             }
    00144         }
    00145         else
    00146         {
    00147             lstrcpy( ConTbl->LayoutName, name );
    00148         }
    00149     }
    00150     else
    00151     {
    00152         lstrcpy( ConTbl->LayoutName, name);
    00153     }
    00154
    00155     return TRUE;
    00156 }
    00157
    00158 BOOL
    00159 GetOpenStatusByCodepage(
    00160     HIMC hIMC,
    00161     PCONSOLE_TABLE ConTbl
    00162     )
    00163 {
    00164     switch ( HKL_TO_LANGID(ConTbl->hklActive))
    00165     {
    00166         case    LANG_ID_JAPAN:
    00167             return ImmGetOpenStatus(hIMC);
    00168             break;
    00169         case    LANG_ID_TAIWAN:
    00170         case    LANG_ID_PRC:
    00171         case    LANG_ID_KOREA:
    00172             if (ImmGetOpenStatus(hIMC)) {
    00173                 return ImmIsIME(ConTbl->hklActive);
    00174             }
    00175             break;
    00176         default:
    00177             return FALSE;
    00178     }
    00179     return FALSE;
    00180 }
    00181
    00182 BOOL
    00183 ImeUIMakeInfoString(
    00184     PCONSOLE_TABLE ConTbl,
    00185     LPCONIME_UIMODEINFO lpModeInfo
    00186     )
    00187 {
    00188
    00189     switch ( HKL_TO_LANGID(ConTbl->hklActive))
    00190     {
    00191         case    LANG_ID_JAPAN:
    00192             return MakeInfoStringJapan(ConTbl, lpModeInfo);
    00193             break;
    00194         case    LANG_ID_TAIWAN:
    00195             return MakeInfoStringTaiwan(ConTbl, lpModeInfo);
    00196             break;
    00197         case    LANG_ID_PRC:
    00198             return MakeInfoStringPRC(ConTbl, lpModeInfo);
    00199             break;
    00200         case    LANG_ID_KOREA:
    00201             return MakeInfoStringKorea(ConTbl, lpModeInfo);
    00202             break;
    00203         default:
    00204             return FALSE;
    00205     }
    00206 }
    00207
    00208 BOOL
    00209 MakeInfoStringJapan(
    00210     PCONSOLE_TABLE ConTbl,
    00211     LPCONIME_UIMODEINFO lpModeInfo
    00212     )
    00213 {
    00214     int i , j;
    00215     DWORD dwConversion;
    00216     DWORD dwSentence;
    00217
    00218     dwConversion = ConTbl->dwConversion;
    00219     dwSentence = ConTbl->dwSentence;
    00220
    00221     i = j = 0;
    00222     if (ConTbl->fOpen){
    00223         if (dwConversion & IME_CMODE_FULLSHAPE) {
    00224             if (dwConversion & IME_CMODE_NATIVE) {
    00225                 if (dwConversion & IME_CMODE_KATAKANA) {
    00226                     for (j = 0; j < IMECModeKZENLen; j++, i++)
    00227                         lpModeInfo->ModeString[i].Char.UnicodeChar = IMECModeKZEN[j];
    00228                 }
    00229                 else {
    00230                     for (j = 0; j < IMECModeHZENLen; j++, i++)
    00231                         lpModeInfo->ModeString[i].Char.UnicodeChar = IMECModeHZEN[j];
    00232                 }
    00233             }
    00234             else {
    00235                 for (j = 0; j < IMECModeAZENLen; j++, i++)
    00236                     lpModeInfo->ModeString[i].Char.UnicodeChar = IMECModeAZEN[j];
    00237             }
    00238         }
    00239         else {
    00240             if (dwConversion & IME_CMODE_NATIVE) {
    00241                 if (dwConversion & IME_CMODE_KATAKANA) {
    00242                     for (j = 0; j < IMECModeKHANLen; j++, i++)
    00243                         lpModeInfo->ModeString[i].Char.UnicodeChar = IMECModeKHAN[j];
    00244                 }
    00245                 else {
    00246                     for (j = 0; j < IMECModeHHANLen; j++, i++)
    00247                         lpModeInfo->ModeString[i].Char.UnicodeChar = IMECModeHHAN[j];
    00248                 }
    00249             }
    00250             else {
    00251                 for (j = 0; j < IMECModeAHANLen; j++, i++)
    00252                     lpModeInfo->ModeString[i].Char.UnicodeChar = IMECModeAHAN[j];
    00253             }
    00254         }
    00255
    00256         if (dwSentence & IME_SMODE_NONE)
    00257             lpModeInfo->ModeString[i].Char.UnicodeChar = IMECMode[MODEDISP_NONE];
    00258         else if (dwSentence & IME_SMODE_PLAURALCLAUSE)
    00259             lpModeInfo->ModeString[i].Char.UnicodeChar = IMECMode[MODEDISP_PLAURAL];
    00260         else if (dwSentence & IME_SMODE_SINGLECONVERT)
    00261             lpModeInfo->ModeString[i].Char.UnicodeChar = IMECMode[MODEDISP_SINGLE];
    00262         else if (dwSentence & IME_SMODE_AUTOMATIC)
    00263             lpModeInfo->ModeString[i].Char.UnicodeChar = IMECMode[MODEDISP_AUTO];
    00264         else if (dwSentence & IME_SMODE_PHRASEPREDICT)
    00265             lpModeInfo->ModeString[i].Char.UnicodeChar = IMECMode[MODEDISP_PHRASE];
    00266         else {
    00267             lpModeInfo->ModeString[i++].Char.UnicodeChar = 0x0020;
    00268             lpModeInfo->ModeString[i].Char.UnicodeChar = 0x0020;
    00269         }
    00270         i++;
    00271
    00272         if (GetKeyState(VK_KANA) & 1) {
    00273             for (j = 0; j < IMECModeKanaLen; j++, i++)
    00274                 lpModeInfo->ModeString[i].Char.UnicodeChar = IMECModeKana[j];
    00275         }
    00276         else if (dwConversion & IME_CMODE_ROMAN) {
    00277             for (j = 0; j < IMECModeRomanLen; j++, i++)
    00278                 lpModeInfo->ModeString[i].Char.UnicodeChar = IMECModeRoman[j];
    00279         }
    00280     }
    00281     else {
    00282         /*
    00283          * In this case, fOpen is 0 (==close).
    00284          * Should be fill mode text buffer in console.
    00285          * So, console can do fill up that pass to 0 length.
    00286          */
    00287         i = 0;
    00288     }
    00289     for (j = 0; j < i; j++ )
    00290         lpModeInfo->ModeString[j].Attributes = 0x0007;
    00291     lpModeInfo->ModeStringLen = i;
    00292     lpModeInfo->Position = VIEW_RIGHT;
    00293     return TRUE;
    00294 }
    00295
    00296
    00297 BOOL
    00298 MakeInfoStringTaiwan(
    00299     PCONSOLE_TABLE ConTbl,
    00300     LPCONIME_UIMODEINFO lpModeInfo
    00301     )
    00302 {
    00303     DWORD j;
    00304     DWORD ModeInfoPtr;
    00305     DWORD LengthForDisp;
    00306
    00307     ModeInfoPtr = 0;
    00308
    00309     if (ImmIsIME(ConTbl->hklActive) ){
    00310         ModeInfoPtr = MakeStatusStrTaiwan1(ConTbl, lpModeInfo, ModeInfoPtr);
    00311         if (ConTbl->fInComposition) {
    00312             if (ConTbl->fInCandidate){
    00313                 ModeInfoPtr = IncludeCandidateT(ConTbl, lpModeInfo, ModeInfoPtr);
    00314             }
    00315             else{
    00316                 ModeInfoPtr = IncludeCompositionT(ConTbl, lpModeInfo, ModeInfoPtr);
    00317             }
    00318         }
    00319         ModeInfoPtr = MakeStatusStrTaiwan2(ConTbl, lpModeInfo, ModeInfoPtr);
    00320     }
    00321
    00322     lpModeInfo->ModeStringLen = ModeInfoPtr;
    00323     lpModeInfo->Position = VIEW_LEFT;
    00324     return TRUE;
    00325 }
    00326
    00327 DWORD
    00328 MakeStatusStrTaiwan1(
    00329     PCONSOLE_TABLE ConTbl,
    00330     LPCONIME_UIMODEINFO lpModeInfo,
    00331     DWORD ModeInfoPtr
    00332     )
    00333 {
    00334     DWORD i;
    00335     DWORD j;
    00336     DWORD Length;
    00337     DWORD dwConversion;
    00338
    00339     dwConversion = ConTbl->dwConversion;
    00340
    00341     i = ModeInfoPtr;
    00342     j = 0;
    00343     Length = 0;
    00344     while (Length < IMECNameLength ) {
    00345         if (ConTbl->LayoutName[j] == 0 )
    00346             break;
    00347         lpModeInfo->ModeString[i].Char.UnicodeChar = ConTbl->LayoutName[j];
    00348         Length += IsUnicodeFullWidth(lpModeInfo->ModeString[i].Char.UnicodeChar) ? 2 : 1;
    00349         j++;
    00350         i++;
    00351     }
    00352     if (Length < IMECNameLength+1) {
    00353         for (j = Length; j < IMECNameLength+1; j++ ) {
    00354             lpModeInfo->ModeString[i++].Char.UnicodeChar = UNICODE_SPACE;
    00355         }
    00356     }
    00357
    00358     if (dwConversion & IME_CMODE_FULLSHAPE) {
    00359         for (j = 0; j < IMECModeFullShapeLen; j++)
    00360             lpModeInfo->ModeString[i++].Char.UnicodeChar = IMECModeFullShape[j];
    00361     }
    00362     else{
    00363         for (j = 0; j < IMECModeHalfShapeLen; j++)
    00364             lpModeInfo->ModeString[i++].Char.UnicodeChar = IMECModeHalfShape[j];
    00365     }
    00366
    00367     lpModeInfo->ModeString[i++].Char.UnicodeChar = UNICODE_SPACE;
    00368
    00369 #if defined (CANDCOUNTPRC) //for wider candidate list space Oct.16.1996
    00370     if (ConTbl->fInCandidate){
    00371         for (j = 0; j < IMECGuideLen; j++ )
    00372             lpModeInfo->ModeString[i++].Char.UnicodeChar = IMECGuide[8][2+j];
    00373     }
    00374     else if (ConTbl->GuideLine[0]){
    00375         for (j = 0; j < IMECGuideLen; j++ )
    00376             lpModeInfo->ModeString[i++].Char.UnicodeChar = ConTbl->GuideLine[j];
    00377     }
    00378 #endif
    00379
    00380     lpModeInfo->ModeString[i++].Char.UnicodeChar = UNICODE_COLON;
    00381
    00382     for (j = 0; j < i; j++ )
    00383         lpModeInfo->ModeString[j].Attributes = 0x0007;
    00384     return i;
    00385 }
    00386
    00387 DWORD
    00388 MakeStatusStrTaiwan2(
    00389     PCONSOLE_TABLE ConTbl,
    00390     LPCONIME_UIMODEINFO lpModeInfo,
    00391     DWORD ModeInfoPtr
    00392     )
    00393 {
    00394     DWORD LengthOfStr;
    00395     DWORD LengthForNum;
    00396     DWORD LengthForNum2;
    00397     DWORD CountDispWidth;
    00398     DWORD StatusWidth;
    00399     DWORD i;
    00400     DWORD j;
    00401
    00402     i = ModeInfoPtr;
    00403
    00404     StatusWidth = ConTbl->ScreenBufferSize.X;
    00405     if (StatusWidth > MAXSTATUSCOL) {
    00406         StatusWidth = MAXSTATUSCOL;
    00407     }
    00408 #if defined (CANDCOUNTCHT) //for wider candidate list space v-hirshi Oct.16.1996
    00409     LengthOfStr = DispLenStructedUnicode(lpModeInfo->ModeString,ModeInfoPtr) + 1 + 4;
    00410 #else
    00411     LengthOfStr = DispLenStructedUnicode(lpModeInfo->ModeString,ModeInfoPtr);
    00412 #endif
    00413
    00414     if (LengthOfStr > StatusWidth) {
    00415         for ( ; LengthOfStr > StatusWidth; i-- ) {
    00416             LengthOfStr -= (IsUnicodeFullWidth(lpModeInfo->ModeString[i].Char.UnicodeChar) ? 2 : 1 );
    00417         }
    00418     }
    00419
    00420     for (j = 0; j < (StatusWidth - LengthOfStr); j++) {
    00421         lpModeInfo->ModeString[i++].Char.UnicodeChar = UNICODE_SPACE;
    00422     }
    00423
    00424 #if defined (CANDCOUNTCHT) //for wider candidate list space v-hirshi Oct.16.1996
    00425     lpModeInfo->ModeString[i++].Char.UnicodeChar = UNICODE_SPACE;
    00426
    00427     if (ConTbl->dwConversion & IME_CMODE_SYMBOL) {
    00428         for (j = 0; j < IMECModeSymbolLen; j++)
    00429             lpModeInfo->ModeString[i++].Char.UnicodeChar = IMECModeSymbol[j];
    00430     }
    00431     else{
    00432         for (j = 0; j < IMECModeKeyboardLen; j++)
    00433             lpModeInfo->ModeString[i++].Char.UnicodeChar = IMECModeKeyboard[j];
    00434     }
    00435 #endif
    00436
    00437     for (j = ModeInfoPtr; j < i; j++ )
    00438         lpModeInfo->ModeString[j].Attributes = 0x0007;
    00439     return i;
    00440 }
    00441
    00442 DWORD
    00443 IncludeCompositionT(
    00444     PCONSOLE_TABLE ConTbl,
    00445     LPCONIME_UIMODEINFO lpModeInfo,
    00446     DWORD ModeInfoPtr
    00447     )
    00448 {
    00449     DWORD i;
    00450     DWORD j;
    00451     DWORD k;
    00452     PWCHAR      TempBuf;
    00453     PUCHAR      TempBufA;
    00454     LPCONIME_UICOMPMESSAGE lpCompStrMem;
    00455
    00456     i = ModeInfoPtr;
    00457     if (ConTbl->lpCompStrMem == NULL) {
    00458         return i;
    00459     }
    00460     lpCompStrMem = ConTbl->lpCompStrMem;
    00461     TempBuf  = (PWCHAR)((PUCHAR)lpCompStrMem + sizeof(CONIME_UICOMPMESSAGE));
    00462     TempBufA = (PUCHAR)((PUCHAR)lpCompStrMem + sizeof(CONIME_UICOMPMESSAGE) +
    00463                        lpCompStrMem->dwCompStrLen +  sizeof(WCHAR));
    00464
    00465     k = 0;
    00466     for (j = 0; k < lpCompStrMem->dwCompStrLen; j++, k += sizeof(WCHAR)) {
    00467        lpModeInfo->ModeString[i].Char.UnicodeChar = TempBuf[j];
    00468        lpModeInfo->ModeString[i++].Attributes = lpCompStrMem->CompAttrColor[TempBufA[j]];
    00469     }
    00470     return i;
    00471 }
    00472
    00473 DWORD
    00474 IncludeCandidateT(
    00475     PCONSOLE_TABLE ConTbl,
    00476     LPCONIME_UIMODEINFO lpModeInfo,
    00477     DWORD ModeInfoPtr
    00478     )
    00479 {
    00480     DWORD i;
    00481     DWORD j;
    00482     DWORD dwLength;
    00483     PWCHAR      TempBuf;
    00484     PUCHAR      TempBufA;
    00485     LPCONIME_CANDMESSAGE SystemLine;
    00486     LPCONIME_UICOMPMESSAGE lpCompStrMem;
    00487     lpCompStrMem = ConTbl->lpCompStrMem;
    00488
    00489     i = ModeInfoPtr;
    00490     if (ConTbl->SystemLine == NULL) {
    00491         return i;
    00492     }
    00493     SystemLine = ConTbl->SystemLine;
    00494     dwLength = (SystemLine->AttrOff - sizeof(DWORD) ) / sizeof(WCHAR) ;
    00495     TempBuf  = (PWCHAR)(SystemLine->String);
    00496     TempBufA = (PUCHAR)((LPSTR)SystemLine + SystemLine->AttrOff);
    00497
    00498     for (j = 0; TempBuf[j] != 0; j++ ) {
    00499        lpModeInfo->ModeString[i].Char.UnicodeChar = TempBuf[j];
    00500        lpModeInfo->ModeString[i++].Attributes = lpCompStrMem->CompAttrColor[TempBufA[j]];
    00501     }
    00502
    00503     return i;
    00504 }
    00505
    00506 DWORD
    00507 DispLenStructedUnicode(
    00508     PCHAR_INFO lpString,
    00509     DWORD SrcLength
    00510     )
    00511 {
    00512     DWORD i;
    00513     DWORD Length;
    00514
    00515     Length = 0;
    00516
    00517     for ( i = 0; i < SrcLength; i++) {
    00518         Length += IsUnicodeFullWidth(lpString[i].Char.UnicodeChar) ? 2 : 1;
    00519     }
    00520     return Length;
    00521 }
    00522
    00523
    00524 BOOL
    00525 MakeInfoStringPRC(
    00526     PCONSOLE_TABLE ConTbl,
    00527     LPCONIME_UIMODEINFO lpModeInfo
    00528     )
    00529 {
    00530     DWORD j;
    00531     DWORD ModeInfoPtr;
    00532     DWORD LengthForDisp;
    00533
    00534     ModeInfoPtr = 0;
    00535
    00536     if (ImmIsIME(ConTbl->hklActive) ){
    00537         ModeInfoPtr = MakeStatusStrPRC1(ConTbl, lpModeInfo, ModeInfoPtr);
    00538         if (ConTbl->fInComposition) {
    00539             if (ConTbl->fInCandidate){
    00540                 ModeInfoPtr = IncludeCandidateP(ConTbl, lpModeInfo, ModeInfoPtr);
    00541             }
    00542             else{
    00543                 ModeInfoPtr = IncludeCompositionP(ConTbl, lpModeInfo, ModeInfoPtr);
    00544             }
    00545         }
    00546         ModeInfoPtr = MakeStatusStrPRC2(ConTbl, lpModeInfo, ModeInfoPtr);
    00547     }
    00548
    00549     lpModeInfo->ModeStringLen = ModeInfoPtr;
    00550     lpModeInfo->Position = VIEW_LEFT;
    00551     return TRUE;
    00552 }
    00553
    00554 DWORD
    00555 MakeStatusStrPRC1(
    00556     PCONSOLE_TABLE ConTbl,
    00557     LPCONIME_UIMODEINFO lpModeInfo,
    00558     DWORD ModeInfoPtr
    00559     )
    00560 {
    00561     DWORD i;
    00562     DWORD j;
    00563     DWORD dwConversion;
    00564     DWORD Length;
    00565
    00566     dwConversion = ConTbl->dwConversion;
    00567
    00568     i = ModeInfoPtr;
    00569     j = 0;
    00570     Length = 0;
    00571     while (Length < 9) {
    00572         if (ConTbl->LayoutName[j] == 0 )
    00573             break;
    00574         if (ConTbl->LayoutName[j] == 0x8f93)
    00575             break;
    00576         lpModeInfo->ModeString[i].Char.UnicodeChar = ConTbl->LayoutName[j];
    00577         Length += IsUnicodeFullWidth(lpModeInfo->ModeString[i].Char.UnicodeChar) ? 2 : 1;
    00578         j++;
    00579         i++;
    00580     }
    00581     if (Length < 9) {
    00582         for (j = Length; j < 9; j++ ) {
    00583             lpModeInfo->ModeString[i++].Char.UnicodeChar = UNICODE_SPACE;
    00584         }
    00585     }
    00586
    00587
    00588     if (dwConversion & IME_CMODE_FULLSHAPE) {
    00589         for (j = 0; j < IMECModeFullShapeLen; j++)
    00590             lpModeInfo->ModeString[i++].Char.UnicodeChar = IMECModeFullShape[j];
    00591     }
    00592     else{
    00593         for (j = 0; j < IMECModeHalfShapeLen; j++)
    00594             lpModeInfo->ModeString[i++].Char.UnicodeChar = IMECModeHalfShape[j];
    00595     }
    00596
    00597 // v-HirShi Oct.14.1996 delete it for get space
    00598 //  lpModeInfo->ModeString[i++].Char.UnicodeChar = UNICODE_SPACE;
    00599
    00600     lpModeInfo->ModeString[i++].Char.UnicodeChar = UNICODE_COLON;
    00601
    00602     for (j = 0; j < i; j++ )
    00603         lpModeInfo->ModeString[j].Attributes = 0x0007;
    00604     return i;
    00605 }
    00606
    00607 DWORD
    00608 MakeStatusStrPRC2(
    00609     PCONSOLE_TABLE ConTbl,
    00610     LPCONIME_UIMODEINFO lpModeInfo,
    00611     DWORD ModeInfoPtr
    00612     )
    00613 {
    00614     DWORD LengthOfStr;
    00615     DWORD LengthForNum;
    00616     DWORD LengthForNum2;
    00617     DWORD CountDispWidth;
    00618     DWORD StatusWidth;
    00619     DWORD i;
    00620     DWORD j;
    00621
    00622     i = ModeInfoPtr;
    00623
    00624     StatusWidth = ConTbl->ScreenBufferSize.X;
    00625     if (StatusWidth > MAXSTATUSCOL) {
    00626         StatusWidth = MAXSTATUSCOL;
    00627     }
    00628 #if defined (CANDCOUNTPRC) //for wider candidate list space v-hirshi Oct.16.1996
    00629     LengthOfStr = DispLenStructedUnicode(lpModeInfo->ModeString,ModeInfoPtr) + 1 + 4;
    00630 #else
    00631     LengthOfStr = DispLenStructedUnicode(lpModeInfo->ModeString,ModeInfoPtr);
    00632 #endif
    00633
    00634     if (LengthOfStr > StatusWidth) {
    00635         for ( ; LengthOfStr > StatusWidth; i-- ) {
    00636             LengthOfStr -= (IsUnicodeFullWidth(lpModeInfo->ModeString[i].Char.UnicodeChar) ? 2 : 1 );
    00637         }
    00638     }
    00639     for (j = 0; j < (StatusWidth - LengthOfStr); j++) {
    00640         lpModeInfo->ModeString[i++].Char.UnicodeChar = UNICODE_SPACE;
    00641     }
    00642 #if defined (CANDCOUNTPRC) //for wider candidate list space v-hirshi Oct.16.1996
    00643     lpModeInfo->ModeString[i++].Char.UnicodeChar = UNICODE_SPACE;
    00644
    00645     if (ConTbl->dwConversion & IME_CMODE_SYMBOL) {
    00646         for (j = 0; j < IMECModeSymbolLen; j++)
    00647             lpModeInfo->ModeString[i++].Char.UnicodeChar = IMECModeSymbol[j];
    00648     }
    00649     else{
    00650         for (j = 0; j < IMECModeKeyboardLen; j++)
    00651             lpModeInfo->ModeString[i++].Char.UnicodeChar = IMECModeKeyboard[j];
    00652     }
    00653 #endif
    00654
    00655     for (j = ModeInfoPtr; j < i; j++ )
    00656         lpModeInfo->ModeString[j].Attributes = 0x0007;
    00657     return i;
    00658 }
    00659
    00660 DWORD
    00661 IncludeCompositionP(
    00662     PCONSOLE_TABLE ConTbl,
    00663     LPCONIME_UIMODEINFO lpModeInfo,
    00664     DWORD ModeInfoPtr
    00665     )
    00666 {
    00667     DWORD i;
    00668     DWORD j;
    00669     DWORD k;
    00670     PWCHAR      TempBuf;
    00671     PUCHAR      TempBufA;
    00672     LPCONIME_UICOMPMESSAGE lpCompStrMem;
    00673
    00674     i = ModeInfoPtr;
    00675     if (ConTbl->lpCompStrMem == NULL) {
    00676         return i;
    00677     }
    00678     lpCompStrMem = ConTbl->lpCompStrMem;
    00679     TempBuf  = (PWCHAR)((PUCHAR)lpCompStrMem + sizeof(CONIME_UICOMPMESSAGE));
    00680     TempBufA = (PUCHAR)((PUCHAR)lpCompStrMem + sizeof(CONIME_UICOMPMESSAGE) +
    00681                        lpCompStrMem->dwCompStrLen +  sizeof(WCHAR));
    00682
    00683     k = 0;
    00684     for (j = 0; k < lpCompStrMem->dwCompStrLen; j++, k += sizeof(WCHAR)) {
    00685        lpModeInfo->ModeString[i].Char.UnicodeChar = TempBuf[j];
    00686        lpModeInfo->ModeString[i++].Attributes = lpCompStrMem->CompAttrColor[TempBufA[j]];
    00687     }
    00688     return i;
    00689 }
    00690
    00691 DWORD
    00692 IncludeCandidateP(
    00693     PCONSOLE_TABLE ConTbl,
    00694     LPCONIME_UIMODEINFO lpModeInfo,
    00695     DWORD ModeInfoPtr
    00696     )
    00697 {
    00698     DWORD i;
    00699     DWORD j;
    00700     DWORD k;
    00701     DWORD UnicodeLen;
    00702     DWORD dwLength;
    00703     PWCHAR      TempBuf;
    00704     PUCHAR      TempBufA;
    00705     LPCONIME_CANDMESSAGE SystemLine;
    00706     LPCONIME_UICOMPMESSAGE lpCompStrMem;
    00707
    00708     i = ModeInfoPtr;
    00709     if (ConTbl->SystemLine == NULL) {
    00710         return i;
    00711     }
    00712     lpCompStrMem = ConTbl->lpCompStrMem;
    00713     TempBuf  = (PWCHAR)((PUCHAR)lpCompStrMem + sizeof(CONIME_UICOMPMESSAGE));
    00714     TempBufA = (PUCHAR)((PUCHAR)lpCompStrMem + sizeof(CONIME_UICOMPMESSAGE) +
    00715                        lpCompStrMem->dwCompStrLen +  sizeof(WCHAR));
    00716
    00717     k = 0;
    00718     UnicodeLen = 0;
    00719     for (j = 0; (k < lpCompStrMem->dwCompStrLen )&&(UnicodeLen < PRCCOMPWIDTH); j++, k += sizeof(WCHAR)) {
    00720        lpModeInfo->ModeString[i].Char.UnicodeChar = TempBuf[j];
    00721        lpModeInfo->ModeString[i++].Attributes = lpCompStrMem->CompAttrColor[TempBufA[j]];
    00722        UnicodeLen += IsUnicodeFullWidth(TempBuf[j]) ? 2 : 1;
    00723     }
    00724
    00725     for ( j = UnicodeLen; j < PRCCOMPWIDTH; j++) {
    00726         lpModeInfo->ModeString[i++].Char.UnicodeChar = UNICODE_SPACE;
    00727     }
    00728     lpModeInfo->ModeString[i++].Char.UnicodeChar = UNICODE_COLON;
    00729
    00730     SystemLine = ConTbl->SystemLine;
    00731     dwLength = (SystemLine->AttrOff - sizeof(DWORD) ) / sizeof(WCHAR) ;
    00732     TempBuf  = (PWCHAR)(SystemLine->String);
    00733     TempBufA = (PUCHAR)((LPSTR)SystemLine + SystemLine->AttrOff);
    00734
    00735     for (j = 0; TempBuf[j] != 0; j++ ) {
    00736        lpModeInfo->ModeString[i].Char.UnicodeChar = TempBuf[j];
    00737        lpModeInfo->ModeString[i++].Attributes = lpCompStrMem->CompAttrColor[TempBufA[j]];
    00738     }
    00739
    00740     return i;
    00741 }
    00742
    00743 BOOL
    00744 MakeInfoStringKorea(
    00745     PCONSOLE_TABLE ConTbl,
    00746     LPCONIME_UIMODEINFO lpModeInfo
    00747     )
    00748 {
    00749     int i , j;
    00750
    00751     i = 0;
    00752     lpModeInfo->ModeString[i++].Char.UnicodeChar = UNICODE_SPACE;
    00753     for (j = 0; j < i; j++ )
    00754         lpModeInfo->ModeString[j].Attributes = 0x0007;
    00755     lpModeInfo->ModeStringLen = i;
    00756     lpModeInfo->Position = VIEW_RIGHT;
    00757     return TRUE;
    00758 }