keymap.pas 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2014 by Free Pascal development team
  4. Keymap.resource definitions and console.device key map definitions
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. unit Keymap;
  12. interface
  13. uses exec, inputevent;
  14. Type
  15. PKeyMap = ^TKeyMap;
  16. TKeyMap = record
  17. km_LoKeyMapTypes : Pointer;
  18. km_LoKeyMap : Pointer;
  19. km_LoCapsable : Pointer;
  20. km_LoRepeatable : Pointer;
  21. km_HiKeyMapTypes : Pointer;
  22. km_HiKeyMap : Pointer;
  23. km_HiCapsable : Pointer;
  24. km_HiRepeatable : Pointer;
  25. end;
  26. pKeymapNode = ^TKeyMapNode;
  27. TKeyMapNode = record
  28. kn_Node : TNode; { including name of Keymap }
  29. kn_KeyMap : TKeyMap;
  30. end;
  31. { the structure of Keymap.resource }
  32. pKeyMapResource = ^TKeyMapResource;
  33. TKeyMapResource = record
  34. kr_Node : TNode;
  35. kr_List : tList; { a list of KeyMapNodes }
  36. end;
  37. Const
  38. { Key Map Types }
  39. KC_NOQUAL = 0;
  40. KC_VANILLA = 7; { note that SHIFT+ALT+CTRL is VANILLA }
  41. KCB_SHIFT = 0;
  42. KCF_SHIFT = $01;
  43. KCB_ALT = 1;
  44. KCF_ALT = $02;
  45. KCB_CONTROL = 2;
  46. KCF_CONTROL = $04;
  47. KCB_DOWNUP = 3;
  48. KCF_DOWNUP = $08;
  49. KCB_DEAD = 5; { may be dead or modified by dead key: }
  50. KCF_DEAD = $20; { use dead prefix bytes }
  51. KCB_STRING = 6;
  52. KCF_STRING = $40;
  53. KCB_NOP = 7;
  54. KCF_NOP = $80;
  55. { Dead Prefix Bytes }
  56. DPB_MOD = 0;
  57. DPF_MOD = $01;
  58. DPB_DEAD = 3;
  59. DPF_DEAD = $08;
  60. DP_2DINDEXMASK = $0f; { mask for index for 1st of two dead keys }
  61. DP_2DFACSHIFT = 4; { shift for factor for 1st of two dead keys }
  62. var KeyMapBase : pLibrary;
  63. const
  64. KEYMAPNAME : PChar = 'keymap.library';
  65. function AskKeyMapDefault : PKeyMap; syscall KeyMapBase 6;
  66. function MapANSI(TheString : PChar; Count : LongInt; Buffer : PChar; Length : LongInt; KeyMap : PKeyMap) : LongInt; syscall KeyMapBase 8;
  67. function MapRawKey(Event : PInputEvent; Buffer : PChar; Length : LongInt; KeyMap : PKeyMap) : SmallInt; syscall KeyMapBase 7;
  68. procedure SetKeyMapDefault(KeyMap : PKeyMap); syscall KeyMapBase 5;
  69. implementation
  70. initialization
  71. KeyMapBase := OpenLibrary(KEYMAPNAME, 0);
  72. finalization
  73. CloseLibrary(KeyMapBase);
  74. end. (* UNIT KEYMAP *)