Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

758 lines
23 KiB

  1. // Copyright (c) 1985 - 1999, Microsoft Corporation
  2. //
  3. // MODULE: country.c
  4. //
  5. // PURPOSE: Console IME control.
  6. // FarEast country specific module for conime.
  7. //
  8. // PLATFORMS: Windows NT-FE 3.51
  9. //
  10. // FUNCTIONS:
  11. // ImeUIMakeInfoString() - routine for make status string
  12. //
  13. // History:
  14. //
  15. // 10.Jul.1996 v-HirShi (Hirotoshi Shimizu) Created for TAIWAN & KOREA & PRC
  16. //
  17. // COMMENTS:
  18. //
  19. #include "precomp.h"
  20. #pragma hdrstop
  21. // for Japanese
  22. // none plaural single auto phrase
  23. WCHAR IMECMode[] = { 0x7121, 0x8907, 0x5358, 0x81ea, 0x9023 };
  24. WCHAR IMECModeRoman[] = { 0xff9b, 0xff70, 0xff8f, 0x0020 };
  25. WCHAR IMECModeKana[] = { 0xff76, 0xff85, 0x0020, 0x0020 };
  26. WCHAR IMECModeAHAN[] = { 0x534a, 0x0041, 0x0020 };
  27. WCHAR IMECModeAZEN[] = { 0x5168, 0xff21 };
  28. WCHAR IMECModeHHAN[] = { 0x534a, 0xff71, 0x0020 };
  29. WCHAR IMECModeHZEN[] = { 0x5168, 0x3042 };
  30. WCHAR IMECModeKHAN[] = { 0x534a, 0xff76, 0x0020 };
  31. WCHAR IMECModeKZEN[] = { 0x5168, 0x30ab };
  32. // for CHT /Taiwan
  33. WCHAR IMECModeFullShape[] = { 0x5168, 0x5f62 };
  34. WCHAR IMECModeHalfShape[] = { 0x534a, 0x5f62 };
  35. WCHAR IMECModeKeyboard[] = { 0x9375, 0x76e4 };
  36. WCHAR IMECModeSymbol[] = { 0x7b26, 0x53f7 };
  37. WCHAR IMECGuide[9][7] = {{ 0x5009, 0x9821, 0x8acb, 0x8f38, 0x5165, 0x5b57, 0x6839 }, // kura
  38. { 0x5167, 0x78bc, 0x8acb, 0x8f38, 0x5165, 0x5167, 0x78bc }, // naima
  39. { 0x55ae, 0x78bc, 0x8acb, 0x8f38, 0x5165, 0x55ae, 0x78bc }, // tanma
  40. { 0x901f, 0x6210, 0x8acb, 0x8f38, 0x5165, 0x5b57, 0x6839 }, // sokusei
  41. { 0x5927, 0x6613, 0x8acb, 0x8f38, 0x5165, 0x5b57, 0x6839 }, // taieki
  42. { 0x82f1, 0x6570, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000 }, // eisuu
  43. { 0xff55, 0xff53, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000 }, // US
  44. { 0x6ce8, 0x97f3, 0x8acb, 0x8f38, 0x5165, 0x7b26, 0x865f }, // chuon fugou
  45. { 0x6ce8, 0x97f3, 0x8acb, 0x3000, 0x9078, 0x3000, 0x5b57 } }; // chuon senji
  46. /*
  47. WCHAR IMECNAMEPRC[9][7] = { 0x5168, 0x62fc, 0 }; // zenhei
  48. { 0x53cc, 0x62fc, 0 }; // souhei
  49. { 0x6807, 0x51c6, 0 }; // sijun
  50. { 0x53cc, 0x6253, 0 }; // souda
  51. { 0x90d1, 0x7801, 0 }; // hou?
  52. { 0x8868, 0x5f62, 0x7801, 0 }; // hyoukei
  53. { 0x7e41, 0x4f53, 0x6ce8, 0x97f3, 0 }; // chuon
  54. { 0x7e41, 0x4f53, 0x4ed3, 0x9889, 0 }; // kaihou
  55. { 0x533a, 0x4f4d, 0 }; // kui
  56. { 0x0047, 0x0042, 0x004a, 0x5185, 0x7801, 0 }; // GBKnaikou
  57. { 0x0055, 0x006e, 0x0069, 0x0063, 0x006f, 0x0064, 0x0065, 0 }; // Unicode
  58. */
  59. BOOL
  60. ConimeHotkey(
  61. HWND hWnd,
  62. HANDLE hConsole,
  63. DWORD HotkeyID
  64. )
  65. {
  66. // PCONSOLE_TABLE ConTbl;
  67. //
  68. // ConTbl = SearchConsole(hConsole);
  69. // if (ConTbl == NULL) {
  70. // DBGPRINT(("CONIME: Error! Cannot found registed Console\n"));
  71. // return FALSE;
  72. // }
  73. return ImmSimulateHotKey(hWnd,(DWORD)HotkeyID);
  74. }
  75. BOOL
  76. GetIMEName(
  77. PCONSOLE_TABLE ConTbl
  78. )
  79. {
  80. WCHAR buf[MaxBufSize];
  81. WCHAR name[MaxBufSize];
  82. DWORD bufsize = MaxBufSize;
  83. LONG lResult;
  84. HKEY hkLayout;
  85. int i;
  86. ConTbl->LayoutName[0] = TEXT('\0');
  87. ConTbl->GuideLine[0] = TEXT('\0');
  88. if (ImmEscape(ConTbl->hklActive, ConTbl->hIMC_Current, IME_ESC_IME_NAME, (LPTSTR)&name) == 0)
  89. {
  90. if (!ImmGetIMEFileName(ConTbl->hklActive, (LPTSTR)&name, MaxBufSize ) )
  91. {
  92. if (GetKeyboardLayoutName((LPTSTR)&name) )
  93. {
  94. /*
  95. * quick dirty ImmIsIME
  96. */
  97. if (name[0] != TEXT('E') &&
  98. name[0] != TEXT('e'))
  99. {
  100. return FALSE;
  101. }
  102. lstrcpy( buf, KBDLAYOUT );
  103. lstrcat( buf, KBDSEPALATER );
  104. lstrcat( buf, name );
  105. lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
  106. (LPCTSTR)buf,
  107. 0,
  108. KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS,
  109. &hkLayout );
  110. if ( lResult == ERROR_SUCCESS ) {
  111. lResult = RegQueryValueEx( hkLayout,
  112. KBDLAYOUTTEXT,
  113. NULL,
  114. NULL,
  115. (LPBYTE)ConTbl->LayoutName,
  116. &bufsize );
  117. RegCloseKey( hkLayout );
  118. if (ConTbl->LayoutName[0] != TEXT('\0')) {
  119. for (i = 0; i < 8; i ++){
  120. if ((ConTbl->LayoutName[0] == IMECGuide[i][0]) &&
  121. (ConTbl->LayoutName[1] == IMECGuide[i][1]) ) {
  122. lstrcpyn(&(ConTbl->GuideLine[0]), &(IMECGuide[i][2]), IMECGuideLen+1);
  123. break;
  124. }
  125. }
  126. }
  127. }
  128. else{
  129. return FALSE;
  130. }
  131. }
  132. else
  133. {
  134. return FALSE;
  135. }
  136. }
  137. else
  138. {
  139. lstrcpy( ConTbl->LayoutName, name );
  140. }
  141. }
  142. else
  143. {
  144. lstrcpy( ConTbl->LayoutName, name);
  145. }
  146. return TRUE;
  147. }
  148. BOOL
  149. GetOpenStatusByCodepage(
  150. HIMC hIMC,
  151. PCONSOLE_TABLE ConTbl
  152. )
  153. {
  154. switch ( HKL_TO_LANGID(ConTbl->hklActive))
  155. {
  156. case LANG_ID_JAPAN:
  157. return ImmGetOpenStatus(hIMC);
  158. break;
  159. case LANG_ID_TAIWAN:
  160. case LANG_ID_PRC:
  161. case LANG_ID_KOREA:
  162. if (ImmGetOpenStatus(hIMC)) {
  163. return ImmIsIME(ConTbl->hklActive);
  164. }
  165. break;
  166. default:
  167. return FALSE;
  168. }
  169. return FALSE;
  170. }
  171. BOOL
  172. ImeUIMakeInfoString(
  173. PCONSOLE_TABLE ConTbl,
  174. LPCONIME_UIMODEINFO lpModeInfo
  175. )
  176. {
  177. switch ( HKL_TO_LANGID(ConTbl->hklActive))
  178. {
  179. case LANG_ID_JAPAN:
  180. return MakeInfoStringJapan(ConTbl, lpModeInfo);
  181. break;
  182. case LANG_ID_TAIWAN:
  183. return MakeInfoStringTaiwan(ConTbl, lpModeInfo);
  184. break;
  185. case LANG_ID_PRC:
  186. return MakeInfoStringPRC(ConTbl, lpModeInfo);
  187. break;
  188. case LANG_ID_KOREA:
  189. return MakeInfoStringKorea(ConTbl, lpModeInfo);
  190. break;
  191. default:
  192. return FALSE;
  193. }
  194. }
  195. BOOL
  196. MakeInfoStringJapan(
  197. PCONSOLE_TABLE ConTbl,
  198. LPCONIME_UIMODEINFO lpModeInfo
  199. )
  200. {
  201. int i , j;
  202. DWORD dwConversion;
  203. DWORD dwSentence;
  204. dwConversion = ConTbl->dwConversion;
  205. dwSentence = ConTbl->dwSentence;
  206. i = j = 0;
  207. if (ConTbl->fOpen){
  208. if (dwConversion & IME_CMODE_FULLSHAPE) {
  209. if (dwConversion & IME_CMODE_NATIVE) {
  210. if (dwConversion & IME_CMODE_KATAKANA) {
  211. for (j = 0; j < IMECModeKZENLen; j++, i++)
  212. lpModeInfo->ModeString[i].Char.UnicodeChar = IMECModeKZEN[j];
  213. }
  214. else {
  215. for (j = 0; j < IMECModeHZENLen; j++, i++)
  216. lpModeInfo->ModeString[i].Char.UnicodeChar = IMECModeHZEN[j];
  217. }
  218. }
  219. else {
  220. for (j = 0; j < IMECModeAZENLen; j++, i++)
  221. lpModeInfo->ModeString[i].Char.UnicodeChar = IMECModeAZEN[j];
  222. }
  223. }
  224. else {
  225. if (dwConversion & IME_CMODE_NATIVE) {
  226. if (dwConversion & IME_CMODE_KATAKANA) {
  227. for (j = 0; j < IMECModeKHANLen; j++, i++)
  228. lpModeInfo->ModeString[i].Char.UnicodeChar = IMECModeKHAN[j];
  229. }
  230. else {
  231. for (j = 0; j < IMECModeHHANLen; j++, i++)
  232. lpModeInfo->ModeString[i].Char.UnicodeChar = IMECModeHHAN[j];
  233. }
  234. }
  235. else {
  236. for (j = 0; j < IMECModeAHANLen; j++, i++)
  237. lpModeInfo->ModeString[i].Char.UnicodeChar = IMECModeAHAN[j];
  238. }
  239. }
  240. if (dwSentence & IME_SMODE_NONE)
  241. lpModeInfo->ModeString[i].Char.UnicodeChar = IMECMode[MODEDISP_NONE];
  242. else if (dwSentence & IME_SMODE_PLAURALCLAUSE)
  243. lpModeInfo->ModeString[i].Char.UnicodeChar = IMECMode[MODEDISP_PLAURAL];
  244. else if (dwSentence & IME_SMODE_SINGLECONVERT)
  245. lpModeInfo->ModeString[i].Char.UnicodeChar = IMECMode[MODEDISP_SINGLE];
  246. else if (dwSentence & IME_SMODE_AUTOMATIC)
  247. lpModeInfo->ModeString[i].Char.UnicodeChar = IMECMode[MODEDISP_AUTO];
  248. else if (dwSentence & IME_SMODE_PHRASEPREDICT)
  249. lpModeInfo->ModeString[i].Char.UnicodeChar = IMECMode[MODEDISP_PHRASE];
  250. else {
  251. lpModeInfo->ModeString[i++].Char.UnicodeChar = 0x0020;
  252. lpModeInfo->ModeString[i].Char.UnicodeChar = 0x0020;
  253. }
  254. i++;
  255. if (GetKeyState(VK_KANA) & 1) {
  256. for (j = 0; j < IMECModeKanaLen; j++, i++)
  257. lpModeInfo->ModeString[i].Char.UnicodeChar = IMECModeKana[j];
  258. }
  259. else if (dwConversion & IME_CMODE_ROMAN) {
  260. for (j = 0; j < IMECModeRomanLen; j++, i++)
  261. lpModeInfo->ModeString[i].Char.UnicodeChar = IMECModeRoman[j];
  262. }
  263. }
  264. else {
  265. /*
  266. * In this case, fOpen is 0 (==close).
  267. * Should be fill mode text buffer in console.
  268. * So, console can do fill up that pass to 0 length.
  269. */
  270. i = 0;
  271. }
  272. for (j = 0; j < i; j++ )
  273. lpModeInfo->ModeString[j].Attributes = 0x0007;
  274. lpModeInfo->ModeStringLen = i;
  275. lpModeInfo->Position = VIEW_RIGHT;
  276. return TRUE;
  277. }
  278. BOOL
  279. MakeInfoStringTaiwan(
  280. PCONSOLE_TABLE ConTbl,
  281. LPCONIME_UIMODEINFO lpModeInfo
  282. )
  283. {
  284. DWORD j;
  285. DWORD ModeInfoPtr;
  286. DWORD LengthForDisp;
  287. ModeInfoPtr = 0;
  288. if (ImmIsIME(ConTbl->hklActive) ){
  289. ModeInfoPtr = MakeStatusStrTaiwan1(ConTbl, lpModeInfo, ModeInfoPtr);
  290. if (ConTbl->fInComposition) {
  291. if (ConTbl->fInCandidate){
  292. ModeInfoPtr = IncludeCandidateT(ConTbl, lpModeInfo, ModeInfoPtr);
  293. }
  294. else{
  295. ModeInfoPtr = IncludeCompositionT(ConTbl, lpModeInfo, ModeInfoPtr);
  296. }
  297. }
  298. ModeInfoPtr = MakeStatusStrTaiwan2(ConTbl, lpModeInfo, ModeInfoPtr);
  299. }
  300. lpModeInfo->ModeStringLen = ModeInfoPtr;
  301. lpModeInfo->Position = VIEW_LEFT;
  302. return TRUE;
  303. }
  304. DWORD
  305. MakeStatusStrTaiwan1(
  306. PCONSOLE_TABLE ConTbl,
  307. LPCONIME_UIMODEINFO lpModeInfo,
  308. DWORD ModeInfoPtr
  309. )
  310. {
  311. DWORD i;
  312. DWORD j;
  313. DWORD Length;
  314. DWORD dwConversion;
  315. dwConversion = ConTbl->dwConversion;
  316. i = ModeInfoPtr;
  317. j = 0;
  318. Length = 0;
  319. while (Length < IMECNameLength ) {
  320. if (ConTbl->LayoutName[j] == 0 )
  321. break;
  322. lpModeInfo->ModeString[i].Char.UnicodeChar = ConTbl->LayoutName[j];
  323. Length += IsUnicodeFullWidth(lpModeInfo->ModeString[i].Char.UnicodeChar) ? 2 : 1;
  324. j++;
  325. i++;
  326. }
  327. if (Length < IMECNameLength+1) {
  328. for (j = Length; j < IMECNameLength+1; j++ ) {
  329. lpModeInfo->ModeString[i++].Char.UnicodeChar = UNICODE_SPACE;
  330. }
  331. }
  332. if (dwConversion & IME_CMODE_FULLSHAPE) {
  333. for (j = 0; j < IMECModeFullShapeLen; j++)
  334. lpModeInfo->ModeString[i++].Char.UnicodeChar = IMECModeFullShape[j];
  335. }
  336. else{
  337. for (j = 0; j < IMECModeHalfShapeLen; j++)
  338. lpModeInfo->ModeString[i++].Char.UnicodeChar = IMECModeHalfShape[j];
  339. }
  340. lpModeInfo->ModeString[i++].Char.UnicodeChar = UNICODE_SPACE;
  341. #if defined (CANDCOUNTPRC) //for wider candidate list space Oct.16.1996
  342. if (ConTbl->fInCandidate){
  343. for (j = 0; j < IMECGuideLen; j++ )
  344. lpModeInfo->ModeString[i++].Char.UnicodeChar = IMECGuide[8][2+j];
  345. }
  346. else if (ConTbl->GuideLine[0]){
  347. for (j = 0; j < IMECGuideLen; j++ )
  348. lpModeInfo->ModeString[i++].Char.UnicodeChar = ConTbl->GuideLine[j];
  349. }
  350. #endif
  351. lpModeInfo->ModeString[i++].Char.UnicodeChar = UNICODE_COLON;
  352. for (j = 0; j < i; j++ )
  353. lpModeInfo->ModeString[j].Attributes = 0x0007;
  354. return i;
  355. }
  356. DWORD
  357. MakeStatusStrTaiwan2(
  358. PCONSOLE_TABLE ConTbl,
  359. LPCONIME_UIMODEINFO lpModeInfo,
  360. DWORD ModeInfoPtr
  361. )
  362. {
  363. DWORD LengthOfStr;
  364. DWORD LengthForNum;
  365. DWORD LengthForNum2;
  366. DWORD CountDispWidth;
  367. DWORD StatusWidth;
  368. DWORD i;
  369. DWORD j;
  370. i = ModeInfoPtr;
  371. StatusWidth = ConTbl->ScreenBufferSize.X;
  372. if (StatusWidth > MAXSTATUSCOL) {
  373. StatusWidth = MAXSTATUSCOL;
  374. }
  375. #if defined (CANDCOUNTCHT) //for wider candidate list space v-hirshi Oct.16.1996
  376. LengthOfStr = DispLenStructedUnicode(lpModeInfo->ModeString,ModeInfoPtr) + 1 + 4;
  377. #else
  378. LengthOfStr = DispLenStructedUnicode(lpModeInfo->ModeString,ModeInfoPtr);
  379. #endif
  380. if (LengthOfStr > StatusWidth) {
  381. for ( ; LengthOfStr > StatusWidth; i-- ) {
  382. LengthOfStr -= (IsUnicodeFullWidth(lpModeInfo->ModeString[i].Char.UnicodeChar) ? 2 : 1 );
  383. }
  384. }
  385. for (j = 0; j < (StatusWidth - LengthOfStr); j++) {
  386. lpModeInfo->ModeString[i++].Char.UnicodeChar = UNICODE_SPACE;
  387. }
  388. #if defined (CANDCOUNTCHT) //for wider candidate list space v-hirshi Oct.16.1996
  389. lpModeInfo->ModeString[i++].Char.UnicodeChar = UNICODE_SPACE;
  390. if (ConTbl->dwConversion & IME_CMODE_SYMBOL) {
  391. for (j = 0; j < IMECModeSymbolLen; j++)
  392. lpModeInfo->ModeString[i++].Char.UnicodeChar = IMECModeSymbol[j];
  393. }
  394. else{
  395. for (j = 0; j < IMECModeKeyboardLen; j++)
  396. lpModeInfo->ModeString[i++].Char.UnicodeChar = IMECModeKeyboard[j];
  397. }
  398. #endif
  399. for (j = ModeInfoPtr; j < i; j++ )
  400. lpModeInfo->ModeString[j].Attributes = 0x0007;
  401. return i;
  402. }
  403. DWORD
  404. IncludeCompositionT(
  405. PCONSOLE_TABLE ConTbl,
  406. LPCONIME_UIMODEINFO lpModeInfo,
  407. DWORD ModeInfoPtr
  408. )
  409. {
  410. DWORD i;
  411. DWORD j;
  412. DWORD k;
  413. PWCHAR TempBuf;
  414. PUCHAR TempBufA;
  415. LPCONIME_UICOMPMESSAGE lpCompStrMem;
  416. i = ModeInfoPtr;
  417. if (ConTbl->lpCompStrMem == NULL) {
  418. return i;
  419. }
  420. lpCompStrMem = ConTbl->lpCompStrMem;
  421. TempBuf = (PWCHAR)((PUCHAR)lpCompStrMem + sizeof(CONIME_UICOMPMESSAGE));
  422. TempBufA = (PUCHAR)((PUCHAR)lpCompStrMem + sizeof(CONIME_UICOMPMESSAGE) +
  423. lpCompStrMem->dwCompStrLen + sizeof(WCHAR));
  424. k = 0;
  425. for (j = 0; k < lpCompStrMem->dwCompStrLen; j++, k += sizeof(WCHAR)) {
  426. lpModeInfo->ModeString[i].Char.UnicodeChar = TempBuf[j];
  427. lpModeInfo->ModeString[i++].Attributes = lpCompStrMem->CompAttrColor[TempBufA[j]];
  428. }
  429. return i;
  430. }
  431. DWORD
  432. IncludeCandidateT(
  433. PCONSOLE_TABLE ConTbl,
  434. LPCONIME_UIMODEINFO lpModeInfo,
  435. DWORD ModeInfoPtr
  436. )
  437. {
  438. DWORD i;
  439. DWORD j;
  440. DWORD dwLength;
  441. PWCHAR TempBuf;
  442. PUCHAR TempBufA;
  443. LPCONIME_CANDMESSAGE SystemLine;
  444. LPCONIME_UICOMPMESSAGE lpCompStrMem;
  445. lpCompStrMem = ConTbl->lpCompStrMem;
  446. i = ModeInfoPtr;
  447. if (ConTbl->SystemLine == NULL) {
  448. return i;
  449. }
  450. SystemLine = ConTbl->SystemLine;
  451. dwLength = (SystemLine->AttrOff - sizeof(DWORD) ) / sizeof(WCHAR) ;
  452. TempBuf = (PWCHAR)(SystemLine->String);
  453. TempBufA = (PUCHAR)((LPSTR)SystemLine + SystemLine->AttrOff);
  454. for (j = 0; TempBuf[j] != 0; j++ ) {
  455. lpModeInfo->ModeString[i].Char.UnicodeChar = TempBuf[j];
  456. lpModeInfo->ModeString[i++].Attributes = lpCompStrMem->CompAttrColor[TempBufA[j]];
  457. }
  458. return i;
  459. }
  460. DWORD
  461. DispLenStructedUnicode(
  462. PCHAR_INFO lpString,
  463. DWORD SrcLength
  464. )
  465. {
  466. DWORD i;
  467. DWORD Length;
  468. Length = 0;
  469. for ( i = 0; i < SrcLength; i++) {
  470. Length += IsUnicodeFullWidth(lpString[i].Char.UnicodeChar) ? 2 : 1;
  471. }
  472. return Length;
  473. }
  474. BOOL
  475. MakeInfoStringPRC(
  476. PCONSOLE_TABLE ConTbl,
  477. LPCONIME_UIMODEINFO lpModeInfo
  478. )
  479. {
  480. DWORD j;
  481. DWORD ModeInfoPtr;
  482. DWORD LengthForDisp;
  483. ModeInfoPtr = 0;
  484. if (ImmIsIME(ConTbl->hklActive) ){
  485. ModeInfoPtr = MakeStatusStrPRC1(ConTbl, lpModeInfo, ModeInfoPtr);
  486. if (ConTbl->fInComposition) {
  487. if (ConTbl->fInCandidate){
  488. ModeInfoPtr = IncludeCandidateP(ConTbl, lpModeInfo, ModeInfoPtr);
  489. }
  490. else{
  491. ModeInfoPtr = IncludeCompositionP(ConTbl, lpModeInfo, ModeInfoPtr);
  492. }
  493. }
  494. ModeInfoPtr = MakeStatusStrPRC2(ConTbl, lpModeInfo, ModeInfoPtr);
  495. }
  496. lpModeInfo->ModeStringLen = ModeInfoPtr;
  497. lpModeInfo->Position = VIEW_LEFT;
  498. return TRUE;
  499. }
  500. DWORD
  501. MakeStatusStrPRC1(
  502. PCONSOLE_TABLE ConTbl,
  503. LPCONIME_UIMODEINFO lpModeInfo,
  504. DWORD ModeInfoPtr
  505. )
  506. {
  507. DWORD i;
  508. DWORD j;
  509. DWORD dwConversion;
  510. DWORD Length;
  511. dwConversion = ConTbl->dwConversion;
  512. i = ModeInfoPtr;
  513. j = 0;
  514. Length = 0;
  515. while (Length < 9) {
  516. if (ConTbl->LayoutName[j] == 0 )
  517. break;
  518. if (ConTbl->LayoutName[j] == 0x8f93)
  519. break;
  520. lpModeInfo->ModeString[i].Char.UnicodeChar = ConTbl->LayoutName[j];
  521. Length += IsUnicodeFullWidth(lpModeInfo->ModeString[i].Char.UnicodeChar) ? 2 : 1;
  522. j++;
  523. i++;
  524. }
  525. if (Length < 9) {
  526. for (j = Length; j < 9; j++ ) {
  527. lpModeInfo->ModeString[i++].Char.UnicodeChar = UNICODE_SPACE;
  528. }
  529. }
  530. if (dwConversion & IME_CMODE_FULLSHAPE) {
  531. for (j = 0; j < IMECModeFullShapeLen; j++)
  532. lpModeInfo->ModeString[i++].Char.UnicodeChar = IMECModeFullShape[j];
  533. }
  534. else{
  535. for (j = 0; j < IMECModeHalfShapeLen; j++)
  536. lpModeInfo->ModeString[i++].Char.UnicodeChar = IMECModeHalfShape[j];
  537. }
  538. // v-HirShi Oct.14.1996 delete it for get space
  539. // lpModeInfo->ModeString[i++].Char.UnicodeChar = UNICODE_SPACE;
  540. lpModeInfo->ModeString[i++].Char.UnicodeChar = UNICODE_COLON;
  541. for (j = 0; j < i; j++ )
  542. lpModeInfo->ModeString[j].Attributes = 0x0007;
  543. return i;
  544. }
  545. DWORD
  546. MakeStatusStrPRC2(
  547. PCONSOLE_TABLE ConTbl,
  548. LPCONIME_UIMODEINFO lpModeInfo,
  549. DWORD ModeInfoPtr
  550. )
  551. {
  552. DWORD LengthOfStr;
  553. DWORD LengthForNum;
  554. DWORD LengthForNum2;
  555. DWORD CountDispWidth;
  556. DWORD StatusWidth;
  557. DWORD i;
  558. DWORD j;
  559. i = ModeInfoPtr;
  560. StatusWidth = ConTbl->ScreenBufferSize.X;
  561. if (StatusWidth > MAXSTATUSCOL) {
  562. StatusWidth = MAXSTATUSCOL;
  563. }
  564. #if defined (CANDCOUNTPRC) //for wider candidate list space v-hirshi Oct.16.1996
  565. LengthOfStr = DispLenStructedUnicode(lpModeInfo->ModeString,ModeInfoPtr) + 1 + 4;
  566. #else
  567. LengthOfStr = DispLenStructedUnicode(lpModeInfo->ModeString,ModeInfoPtr);
  568. #endif
  569. if (LengthOfStr > StatusWidth) {
  570. for ( ; LengthOfStr > StatusWidth; i-- ) {
  571. LengthOfStr -= (IsUnicodeFullWidth(lpModeInfo->ModeString[i].Char.UnicodeChar) ? 2 : 1 );
  572. }
  573. }
  574. for (j = 0; j < (StatusWidth - LengthOfStr); j++) {
  575. lpModeInfo->ModeString[i++].Char.UnicodeChar = UNICODE_SPACE;
  576. }
  577. #if defined (CANDCOUNTPRC) //for wider candidate list space v-hirshi Oct.16.1996
  578. lpModeInfo->ModeString[i++].Char.UnicodeChar = UNICODE_SPACE;
  579. if (ConTbl->dwConversion & IME_CMODE_SYMBOL) {
  580. for (j = 0; j < IMECModeSymbolLen; j++)
  581. lpModeInfo->ModeString[i++].Char.UnicodeChar = IMECModeSymbol[j];
  582. }
  583. else{
  584. for (j = 0; j < IMECModeKeyboardLen; j++)
  585. lpModeInfo->ModeString[i++].Char.UnicodeChar = IMECModeKeyboard[j];
  586. }
  587. #endif
  588. for (j = ModeInfoPtr; j < i; j++ )
  589. lpModeInfo->ModeString[j].Attributes = 0x0007;
  590. return i;
  591. }
  592. DWORD
  593. IncludeCompositionP(
  594. PCONSOLE_TABLE ConTbl,
  595. LPCONIME_UIMODEINFO lpModeInfo,
  596. DWORD ModeInfoPtr
  597. )
  598. {
  599. DWORD i;
  600. DWORD j;
  601. DWORD k;
  602. PWCHAR TempBuf;
  603. PUCHAR TempBufA;
  604. LPCONIME_UICOMPMESSAGE lpCompStrMem;
  605. i = ModeInfoPtr;
  606. if (ConTbl->lpCompStrMem == NULL) {
  607. return i;
  608. }
  609. lpCompStrMem = ConTbl->lpCompStrMem;
  610. TempBuf = (PWCHAR)((PUCHAR)lpCompStrMem + sizeof(CONIME_UICOMPMESSAGE));
  611. TempBufA = (PUCHAR)((PUCHAR)lpCompStrMem + sizeof(CONIME_UICOMPMESSAGE) +
  612. lpCompStrMem->dwCompStrLen + sizeof(WCHAR));
  613. k = 0;
  614. for (j = 0; k < lpCompStrMem->dwCompStrLen; j++, k += sizeof(WCHAR)) {
  615. lpModeInfo->ModeString[i].Char.UnicodeChar = TempBuf[j];
  616. lpModeInfo->ModeString[i++].Attributes = lpCompStrMem->CompAttrColor[TempBufA[j]];
  617. }
  618. return i;
  619. }
  620. DWORD
  621. IncludeCandidateP(
  622. PCONSOLE_TABLE ConTbl,
  623. LPCONIME_UIMODEINFO lpModeInfo,
  624. DWORD ModeInfoPtr
  625. )
  626. {
  627. DWORD i;
  628. DWORD j;
  629. DWORD k;
  630. DWORD UnicodeLen;
  631. DWORD dwLength;
  632. PWCHAR TempBuf;
  633. PUCHAR TempBufA;
  634. LPCONIME_CANDMESSAGE SystemLine;
  635. LPCONIME_UICOMPMESSAGE lpCompStrMem;
  636. i = ModeInfoPtr;
  637. if (ConTbl->SystemLine == NULL) {
  638. return i;
  639. }
  640. lpCompStrMem = ConTbl->lpCompStrMem;
  641. TempBuf = (PWCHAR)((PUCHAR)lpCompStrMem + sizeof(CONIME_UICOMPMESSAGE));
  642. TempBufA = (PUCHAR)((PUCHAR)lpCompStrMem + sizeof(CONIME_UICOMPMESSAGE) +
  643. lpCompStrMem->dwCompStrLen + sizeof(WCHAR));
  644. k = 0;
  645. UnicodeLen = 0;
  646. for (j = 0; (k < lpCompStrMem->dwCompStrLen )&&(UnicodeLen < PRCCOMPWIDTH); j++, k += sizeof(WCHAR)) {
  647. lpModeInfo->ModeString[i].Char.UnicodeChar = TempBuf[j];
  648. lpModeInfo->ModeString[i++].Attributes = lpCompStrMem->CompAttrColor[TempBufA[j]];
  649. UnicodeLen += IsUnicodeFullWidth(TempBuf[j]) ? 2 : 1;
  650. }
  651. for ( j = UnicodeLen; j < PRCCOMPWIDTH; j++) {
  652. lpModeInfo->ModeString[i++].Char.UnicodeChar = UNICODE_SPACE;
  653. }
  654. lpModeInfo->ModeString[i++].Char.UnicodeChar = UNICODE_COLON;
  655. SystemLine = ConTbl->SystemLine;
  656. dwLength = (SystemLine->AttrOff - sizeof(DWORD) ) / sizeof(WCHAR) ;
  657. TempBuf = (PWCHAR)(SystemLine->String);
  658. TempBufA = (PUCHAR)((LPSTR)SystemLine + SystemLine->AttrOff);
  659. for (j = 0; TempBuf[j] != 0; j++ ) {
  660. lpModeInfo->ModeString[i].Char.UnicodeChar = TempBuf[j];
  661. lpModeInfo->ModeString[i++].Attributes = lpCompStrMem->CompAttrColor[TempBufA[j]];
  662. }
  663. return i;
  664. }
  665. BOOL
  666. MakeInfoStringKorea(
  667. PCONSOLE_TABLE ConTbl,
  668. LPCONIME_UIMODEINFO lpModeInfo
  669. )
  670. {
  671. int i , j;
  672. i = 0;
  673. lpModeInfo->ModeString[i++].Char.UnicodeChar = UNICODE_SPACE;
  674. for (j = 0; j < i; j++ )
  675. lpModeInfo->ModeString[j].Attributes = 0x0007;
  676. lpModeInfo->ModeStringLen = i;
  677. lpModeInfo->Position = VIEW_RIGHT;
  678. return TRUE;
  679. }