(* $M- *)
DEFINITION MODULE KeyMap;

FROM SYSTEM IMPORT
 ADDRESS,LONGSET;
FROM Exec IMPORT
 Node,List;

TYPE  
 KeyMapTypes=(shift,alt,control,downup,kmp4,dead,string,nop);
 KeyMapTypeSet=SET OF KeyMapTypes;
 DeadPrefixBytes=(dpbMod,dpb1,dpb2,dpbDead);
 DeadPrefixByteSet=SET OF DeadPrefixBytes;

CONST
 dp2dIndexMask=0FH;
 dp2dFacShift=4;
 maxKeys=64;
 noQual=KeyMapTypeSet{};
 vanilla=KeyMapTypeSet{shift,alt,control};

TYPE
 BitTable=
  ARRAY [0..maxKeys DIV (8*SIZE(LONGSET))-1] OF LONGSET;
 BitTablePtr=POINTER TO BitTable;
 KeyInfo=RECORD
  CASE :INTEGER OF
  | 0: ch:ARRAY [0..3] OF CHAR;
  | 1: st:ADDRESS
  END
 END;
 Types=ARRAY [0..maxKeys-1] OF KeyMapTypeSet;
 TypesPtr=POINTER TO Types;
 Info=ARRAY [0..maxKeys-1] OF KeyInfo;
 InfoPtr=POINTER TO Info;
 KeyMap=RECORD
  loKeyMapTypes:TypesPtr;
  loKeyMap:InfoPtr;
  loCapsable:BitTablePtr;
  loRepeatable:BitTablePtr;
  hiKeyMapTypes:TypesPtr;
  hiKeyMap:InfoPtr;
  hiCapsable:BitTablePtr;
  hiRepeatable:BitTablePtr;
 END;
 KeyMapPtr=POINTER TO KeyMap;
 KeyMapNode=RECORD
  node:Node;
  keyMap:KeyMap;
 END;
 KeyMapResource=RECORD
  node:Node;
  list:List;
 END;

END KeyMap.
