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.

123 lines
2.7 KiB

  1. /****************************************************************************/
  2. /* */
  3. /* ECKANJI.C - */
  4. /* */
  5. /* Copyright (c) 1985 - 1999, Microsoft Corporation */
  6. /* */
  7. /* Kanji Support Routines */
  8. /* */
  9. /****************************************************************************/
  10. #include "precomp.h"
  11. #pragma hdrstop
  12. #ifdef KANJI
  13. /***************************************************************************\
  14. * SysHasKanji
  15. *
  16. * <brief description>
  17. *
  18. * History:
  19. \***************************************************************************/
  20. BOOL SysHasKanji(
  21. )
  22. {
  23. return (*(WORD *)&keybdInfo.Begin_First_range != 0x0FEFF ||
  24. *(WORD *)&keybdInfo.Begin_Second_range != 0x0FEFF);
  25. }
  26. /***************************************************************************\
  27. * KAlign
  28. *
  29. * Make sure the given char isn't the index of the second byte of a Kanji word.
  30. *
  31. * History:
  32. \***************************************************************************/
  33. int KAlign(
  34. PED ped,
  35. int ichIn)
  36. {
  37. int ichCheck;
  38. int ichOut;
  39. LPSTR lpch;
  40. /*
  41. * ichOut chases ichCheck until ichCheck > ichIn
  42. */
  43. if (ped->fSingle)
  44. ichOut = ichCheck = 0;
  45. else
  46. ichOut = ichCheck = ped->mpilich[IlFromIch(ped, ichIn)];
  47. lpch = ECLock(ped) + ichCheck;
  48. while (ichCheck <= ichIn) {
  49. ichOut = ichCheck;
  50. if (IsTwoByteCharPrefix(*(unsigned char *)lpch))
  51. {
  52. lpch++;
  53. ichCheck++;
  54. }
  55. lpch++;
  56. ichCheck++;
  57. }
  58. ECUnlock(ped);
  59. return (ichOut);
  60. }
  61. /***************************************************************************\
  62. * KBump
  63. *
  64. * If ichMaxSel references Kanji prefix, bump dch by cxChar to bypass prefix
  65. * char. This routine is called only from DoKey in ea1.asm.
  66. *
  67. * History:
  68. \***************************************************************************/
  69. int KBump(
  70. PED ped,
  71. int dch)
  72. {
  73. unsigned char *pch;
  74. pch = ECLock(ped) + ped->ichMaxSel;
  75. if (IsTwoByteCharPrefix(*pch))
  76. dch += ped->cxChar;
  77. ECUnlock(ped);
  78. return (dch);
  79. }
  80. /***************************************************************************\
  81. * KCombine
  82. *
  83. * Kanji prefix byte was found in bytestream queue. Get next byte and combine.
  84. *
  85. * History:
  86. \***************************************************************************/
  87. int KCombine(
  88. HWND hwnd,
  89. int ch)
  90. {
  91. MSG msg;
  92. int i;
  93. /*
  94. * Loop counter to avoid the infinite loop.
  95. */
  96. i = 10;
  97. while (!PeekMessage(&msg, hwnd, WM_CHAR, WM_CHAR, PM_REMOVE)) {
  98. if (--i == 0)
  99. return 0;
  100. Yield();
  101. }
  102. return (UINT)ch | ((UINT)msg.wParam << 8);
  103. }
  104. #endif