(*$ Implementation- *)
DEFINITION MODULE KeyMapD;

(* (C) Copyright 1994 Marcel Timmermans. All rights reserved. *)

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

TYPE
 KeyMapTypes=(shift,alt,control,downup,kmp4,dead,string,nop);
 KeyMapTypeSet=SET OF KeyMapTypes;

CONST
 noQual=KeyMapTypeSet{};
 vanilla=KeyMapTypeSet{shift,alt,control}; (* note that SHIFT+ALT+CTRL is VANILLA *)

TYPE
(* Dead Prefix Bytes *)
 DeadPrefixBytes=(dpbMod,dpb1,dpb2,dpbDead);
 DeadPrefixByteSet=SET OF DeadPrefixBytes;

CONST
 dp2dIndexMask  = 0FH;  (* mask for index for 1st of two dead keys *)
 dp2dFacShift   = 4;    (* shift for factor for 1st of two dead keys *)

 maxKeys=64;

TYPE
 Types=ARRAY [0..maxKeys-1] OF KeyMapTypeSet;
 TypesPtr=POINTER TO Types;

 KeyInfo=RECORD
  CASE :INTEGER OF
  |0: ch:ARRAY [0..3] OF CHAR;
  |1: st:ADDRESS
  END
 END;

 Info=ARRAY [0..maxKeys-1] OF KeyInfo;
 InfoPtr=POINTER TO Info;

 BitTable=ARRAY [0..maxKeys DIV (8*SIZE(LONGSET))-1] OF LONGSET;
 BitTablePtr=POINTER TO BitTable;

 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; (* including name of keymap *)
  keyMap:KeyMap;
 END;

(* the structure of keymap.resource *)
 KeyMapResource=RECORD
  node:Node;
  list:List; (* a list of KeyMapNodes *)
 END;

END KeyMapD.
