WMHebrewIME.Mod 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. MODULE WMHebrewIME; (** AUTHOR "gubsermi"; PURPOSE "Write hebrew characters"; *)
  2. IMPORT
  3. Strings, WMInputMethods, Texts, KernelLog;
  4. CONST
  5. imeName* = "Hebrew";
  6. TYPE
  7. IME* = OBJECT(WMInputMethods.IME)
  8. PROCEDURE GetName*() : Strings.String;
  9. BEGIN
  10. RETURN Strings.NewString(imeName);
  11. END GetName;
  12. (* Map characters from US-Keyboard to hebrew keyboard *)
  13. PROCEDURE KeyEvent*(ucs : LONGINT; flags : SET; keysym : LONGINT);
  14. BEGIN
  15. CASE ucs OF
  16. (* unshifted *)
  17. (* numeric row: `1234567890-= *)
  18. | 60H : InsertChar(0000003BH) (*`*)
  19. (* first row: qwertyuiop[] *)
  20. | 71H : InsertChar(0000002FH) (*q*)
  21. | 77H : InsertChar(000005F3H) (*w*)
  22. | 65H : InsertChar(000005E7H) (*e*)
  23. | 72H : InsertChar(000005E8H) (*r*)
  24. | 74H : InsertChar(000005D0H) (*t*)
  25. | 79H : InsertChar(000005D8H) (*y*)
  26. | 75H : InsertChar(000005D5H) (*u*)
  27. | 69H : InsertChar(000005DFH) (*i*)
  28. | 6FH : InsertChar(000005DDH) (*o*)
  29. | 70H : InsertChar(000005E4H) (*p*)
  30. (* second row : asdfghjkl;' *)
  31. | 61H : InsertChar(000005E9H) (*a*)
  32. | 73H : InsertChar(000005D3H) (*s*)
  33. | 64H : InsertChar(000005D2H) (*d*)
  34. | 66H : InsertChar(000005DBH) (*f*)
  35. | 67H : InsertChar(000005E2H) (*g*)
  36. | 68H : InsertChar(000005D9H) (*h*)
  37. | 6AH : InsertChar(000005D7H) (*j*)
  38. | 6BH : InsertChar(000005DCH) (*k*)
  39. | 6CH : InsertChar(000005DAH) (*l*)
  40. | 3BH : InsertChar(000005E3H) (*;*)
  41. | 27H : InsertChar(0000002CH) (*'*)
  42. (* third row : zxcvbnm,./;' *)
  43. | 7AH : InsertChar(000005D6H) (*z*)
  44. | 78H : InsertChar(000005E1H) (*x*)
  45. | 63H : InsertChar(000005D1H) (*c*)
  46. | 76H : InsertChar(000005D4H) (*v*)
  47. | 62H : InsertChar(000005E0H); (*b*)
  48. | 6EH : InsertChar(000005DEH) (*n*)
  49. | 6DH : InsertChar(000005E6H) (*m*)
  50. | 2CH : InsertChar(000005EAH) (*,*)
  51. | 2EH : InsertChar(000005E5H) (*.*)
  52. | 2FH : InsertChar(0000002EH) (*/*)
  53. (* shifted *)
  54. | 22H: InsertChar(000005F4H) (*"*)
  55. ELSE
  56. InsertChar(ucs)
  57. END
  58. END KeyEvent;
  59. END IME;
  60. (* installs the Hebrew IME *)
  61. PROCEDURE Install*;
  62. VAR ime : IME;
  63. BEGIN
  64. NEW(ime);
  65. WMInputMethods.InstallIME(ime);
  66. END Install;
  67. (* helper procedure for development : return the UCS code of a selected character in a text *)
  68. PROCEDURE SelectedCharToUCS*;
  69. VAR r : Texts.TextReader;
  70. selectionText: Texts.Text;
  71. ucs : LONGINT;
  72. from, to : Texts.TextPosition;
  73. BEGIN
  74. IF Texts.GetLastSelection(selectionText, from, to) THEN
  75. selectionText.AcquireRead;
  76. NEW(r, selectionText);
  77. r.SetPosition(MIN(from.GetPosition(), to.GetPosition()));
  78. r.ReadCh(ucs);
  79. selectionText.ReleaseRead;
  80. KernelLog.String("InsertChar("); KernelLog.Hex(ucs, 0); KernelLog.String("H) (**)"); KernelLog.Ln;
  81. END;
  82. END SelectedCharToUCS;
  83. END WMHebrewIME.Install~
  84. System.Free WMHebrewIME~
  85. WMHebrewIME.SelectedCharToUCS ~
  86. WMKeyCode.Open ~