XlKeyBut.mesa
Copyright Ó 1991 by Xerox Corporation. All rights reserved.
Christian Jacobi, February 6, 1991 11:18:58 am PST
Christian Jacobi, September 12, 1991 11:24 am PDT
Templates for working with KeyBut and SetOfKeyButMask.
Factored out of Xl, as the memory layout and the inlines are machine dependent.
This is a version which should work for both, big endian and little endian machines, but not for PrincOps.
DIRECTORY Basics;
XlKeyBut: CEDAR DEFINITIONS
IMPORTS Basics =
BEGIN
KeyBut: TYPE = MACHINE DEPENDENT {shift, lock, control, mod1, mod2, mod3, mod4, mod5, button1, button2, button3, button4, button5};
SetOfKeyButMask: TYPE = WORD32 MACHINE DEPENDENT RECORD [
--This type is layed out so that its lower 16 bits match the layout in the protocol
--never reported by server
unused0: CARD16 ¬ 0,
anyModfier: BOOL ¬ FALSE, --used for grabs only
unused2: BOOL ¬ FALSE,
unused3: BOOL ¬ FALSE,
--fields for SetOfKeyButMask
button5: BOOL ¬ FALSE,
button4: BOOL ¬ FALSE,
button3: BOOL ¬ FALSE,
button2: BOOL ¬ FALSE,
button1: BOOL ¬ FALSE,
--fields for SetOfKeyMask and SetOfKeyButMask
mod5: BOOL ¬ FALSE,
mod4: BOOL ¬ FALSE,
mod3: BOOL ¬ FALSE,
mod2: BOOL ¬ FALSE,
mod1: BOOL ¬ FALSE,
control: BOOL ¬ FALSE,
lock: BOOL ¬ FALSE,
shift: BOOL ¬ FALSE
];
SetOfKeyMask: TYPE = SetOfKeyButMask;
ORSetOfKeyButMask: PROC [s1, s2: SetOfKeyButMask] RETURNS [SetOfKeyButMask] = INLINE {
RETURN [LOOPHOLE[Basics.BITOR[LOOPHOLE[s1], LOOPHOLE[s2]]]]
};
IncludeKeyButInSet: PROC [keyBut: KeyBut, mask: SetOfKeyButMask ¬ []] RETURNS [SetOfKeyButMask] = INLINE {
Inlined to enable constant folding
Do not use an array as X and mimosa might index from opposite ends
RETURN [LOOPHOLE[Basics.BITOR[
LOOPHOLE[mask],
2 ** LOOPHOLE[keyBut, [0..32)]
]]]
};
IsKeyButInSet: PROC [keyBut: KeyBut, mask: SetOfKeyButMask] RETURNS [BOOL] = INLINE {
Inlined to enable constant folding
Do not use an array as X and mimosa might index from opposite ends
RETURN [0 # Basics.BITAND[
LOOPHOLE[mask],
2 ** LOOPHOLE[keyBut, [0..32)]
]]
};
END.