TIPPrivate.mesa
Copyright Ó 1985, 1986, 1991, 1992 by Xerox Corporation. All rights reserved.
Last Edited by McGregor, June 10, 1982 10:29 am
Last Edited by: Maxwell, December 17, 1982 9:52 am
Last Edited by: Paul Rovner, June 14, 1983 5:39 pm
Bier, November 30, 1988 6:21:44 pm PST
Doug Wyatt, April 14, 1985 9:45:07 pm PST
Willie-s, October 11, 1991 10:57 am PDT
Christian Jacobi, February 20, 1992 2:33 pm PST
Private and friends level interface.
Kenneth A. Pier, August 5, 1992 6:41 pm PDT
DIRECTORY
RefTab, Rope, TIPFriendsTypes, TIPUser, UserInput, UserInputGetActions, Vector2;
TIPPrivate: CEDAR DEFINITIONS
= BEGIN
TIPTable: TYPE ~ TIPUser.TIPTable;
TIPScreenCoords: TYPE ~ TIPUser.TIPScreenCoords;
TIPScreenCoordsRec: TYPE ~ TIPUser.TIPScreenCoordsRec;
TIPTime: TYPE ~ TIPUser.TIPTime;
TIPClient: TYPE = REF TIPClientRec; -- Handle on a TIP input process
TIPClientRec: TYPE = PRIVATE RECORD [
parseInfo: TIPParseInfo, -- increeks and parse tables for matching
notifyProc: TIPNotifyProc ¬ NIL, -- notification of table recognised events
buttonProc: TIPButtonProc ¬ NIL, -- special button handling (for Cedar InputFocus)
clientData: REF ANY ¬ NIL, -- returned to client when notifyProc or buttonProc is called
discardProc: TIPNotifyProc ← NIL, -- discarded actions (currently unused)
matcher: PROCESS -- the parser process
];
maxTIPNesting: NAT = 10;
TIPParseInfo: TYPE = REF TIPParseInfoRec;
TIPParseInfoRec: TYPE = RECORD [
inCreek, localCreek, timeCreek: UserInput.Handle,
creekStack: ARRAY [0..maxTIPNesting) OF UserInput.Handle,
tableHead: TIPTable
];
TIPNotifyProc: TYPE = TIPFriendsTypes.TIPNotifyProc;
TIPButtonProc: TYPE = TIPFriendsTypes.TIPButtonProc;
MouseEvent: TYPE = TIPFriendsTypes.MouseEvent;
CreateTIPClient: PROC [notify: TIPNotifyProc ¬ NIL, buttons: TIPButtonProc ¬ NIL, clientData: REF ANY, name: Rope.ROPE ¬ NIL] RETURNS [self: TIPClient];
Creates a new input stream that will deliver actions to the TIPNotifyProc or TIPButtonProc (after StartTIPClient is called (see below)). If a given action is a mouse action, and buttons # NIL, then buttons will be given the raw action. Otherwise, the action will be translated using the current InputFocus tip table and passed to notify. To place actions onto the stream, call GetInputHandle to get ahold of the input stream and use the UserInput interface.
name is used for debugging.
StartTIPClient: PROC [tipClient: TIPClient];
Forks a process to begin listening to the actions received on tipClient.
GetInputHandle: PROC [tipClient: TIPClient] RETURNS [handle: UserInput.Handle];
GetParseInfo: PROC [tipClient: TIPClient] RETURNS [parseInfo: TIPParseInfo];
GetClientData: PROC [tipClient: TIPClient] RETURNS [clientData: REF ANY];
DestroyClient: PROC [self: TIPClient];
Cleanly destroys a TIP process.
CreateParseInfo: PROC [parseTable: TIPTable ¬ NIL, name: Rope.ROPE ¬ NIL] RETURNS [new: TIPParseInfo];
For convenience in creating a ParseInfo from scratch
name for debugging.
WideParseOneEvent: PROC [parseInfo: TIPParseInfo] RETURNS [result: LIST OF REF ANY];
given a TIP Parse Table and state, tries to parse a single event. If the first action does not match the start of a valid event, then NIL is returned. Note that the parseInfo.inCreek holds state info on CALL and RETURN.
PushTIPTable: PROC [user: TIPClient, table: TIPTable, opaque: BOOL];
Layer a new TIP table to the input device interpreter. If opaque is TRUE, then unrecognised actions will be discarded without searching the complete TIP table stack past the top entry.
PopTIPTable: PROC [user: TIPClient] RETURNS [old: TIPTable];
discard the topmost entry in the device input interpreter stack. This may cause the popped entry to be garbage-collected unless the client saves a reference to it.
DiscardTypeAhead: PROC [user: TIPClient];
discard any mouse/keyboard events not yet processed
ResetTIPContext: PROC [user: TIPClient, table: TIPTable, notify: TIPNotifyProc,
interrupt: BOOL ¬ FALSE];
Smashes a new TIP table and NotifyProc into the input device interpreter.
Experts/hackers only, please.
InterruptTIP: UNSAFE PROC [self: TIPClient];
Forces TIP interpreter to top level state.
Experts/hackers only, please.
WideMatchEvent: PROC [parseInfo: TIPParseInfo, a: UserInputGetActions.InputActionBody] RETURNS [result: LIST OF REF ¬ NIL];
stdChar: REF CHAR;
stdCoords: TIPScreenCoords;
stdTrackballChange: REF Vector2.VEC;
stdThumbwheelChange: REF INTEGER;
stdTime: TIPTime;
TIP replaces $Char, $Coords, and $TIME with the above real addresses when constructing a TIPTable.
BuildNewTIPTable: PROC [file: Rope.ROPE] RETURNS [table: TIPTable ¬ NIL, option: KeyOption];
DefaultTable: PROC [printKeys: BOOL] RETURNS [table: TIPTable];
GetTIPFilePrefix: PROC[hadError: BOOL] RETURNS [rope: Rope.ROPE];
EnsureEqualTables: PROC [t1, t2: TIPTable];
version: CHAR = '1; -- table syntax version number
predTable: RefTab.Ref; -- table for user defined predicates
KeyOption: TYPE = {none, printKeys, defaultKeys};
Symbol: TYPE = {OptionSym, Small, Fast, FastMouse, SlowMouse, PrintKeys, DefaultKeys, Opaque, Select, Trigger, Enable, From, Endcase, End, While, And, Up, Down, Mouse, After, Before, RightArrow, Comma, Semicolon, LeftCurly, RightCurly, Greater, Dot, VertBar, Char, Coords, Time, KeyIdent, Ident, Number, String, Illegal, Trackball, Thumbwheel, TrackballChange, ThumbwheelChange};
nrOfErrors: CARDINAL = 30;
errorText: REF ARRAY [0..nrOfErrors] OF Rope.ROPE;
InitBuilder: PROC;
END.
The syntax of "compiled" tip table files follows:
capital letters, numbers and parens are character literals
lower case id's are names of syntax equations
id* means 0 or more instances
<id> is a primitive of some sort such as text
file = TIPTABLE version opaque link ignore variant
version = <char>
opaque = flag
link = N --none-- | P --printKeys-- | D --defaultKeys--
ignore = up down move
up = flag
down = flag
move = flag
variant = S small | F fast
small = choiceseries
fast = choice U choicearray D choicearray time
time = choice
choicearray = ( choiceitem* )
choiceitem = ( key choice )
choiceseries = ( choice* )
choice = ( term* )
term = 1 keytrigger | 2 --mousetrigger-- | 3 timetrigger | 4 keyenable |
5 predenable | 6 --CHAR-- | 7 --COORDS-- | 8 choiceseries | 9 results |
A key2Enable | B keyEnableList | C --TIME--
keytrigger = key keystate
key = <byte>
keystate = U --up-- | D --down--
timetrigger = timeoutflavor msecs
timeoutflavor = G --gt-- | L --lt--
msecs = high low
high = <byte>
low = <byte>
keyenable = key keystate
key2Enable = keyenable keyenable
keyEnableList = ( keyenable* )
predenable = atom
results = ( result* )
result = 1 atom | 2 --TIPUser.stdChar-- | 3 <int> | 4 len <text> |
5 --TIPScreenCoords-- | 6 --TIPUser.stdTime--
flag = T | F -- true or false
atom = len pname
pname = <text>
len = <byte>
<text> stored as series of characters. length limited to 255 chars
<int> stored as 4 bytes
<char> and <byte> stored as themselves