SilUserInput.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Tracy Larrabee, March 29, 1984 11:29:40 am PST
Last Edited by: Pier, August 15, 1985 4:51:16 pm PDT
This module defines types and external procedures needed for User Input retreival and inventory: things that handle input from Viewers (including placement of the input focus), deal with TIPTables, query and append to the Sil UserAction queue, and grid the cursor.
The way that user input works: Actions by the user will cause one or more User Input Records (UInputRec - defined below) to be placed on the User Input Queue (UInput - defined below). The display module (actually the PaintProc) will take the records off, whenever it has an opportunity to do so, and process them.
DIRECTORY
BiScrollers USING [BiScroller],
Rope USING [ROPE],
SilKernel USING [SilData, SilUIData],
TIPUser USING [TIPTable],
ViewerClasses USING [ModifyProc, NotifyProc, Viewer]
;
SilUserInput: CEDAR DEFINITIONS = BEGIN
ROPE: TYPE = Rope.ROPE;
SilData: TYPE = SilKernel.SilData;
SilUIData: TYPE = SilKernel.SilUIData;
Following, we have types that are needed to produce a user input record which may be placed on the user input queue and will contain all information needed to process any particular user input.
CaretSet: TYPE = {mark, origin};
Relation: TYPE = {absolute, relative};
SelectMode: TYPE = {add, change, remove, relative, reduce, delete};
ObjectAttributes: TYPE = {color, font, face};
Face: TYPE = {italic, nonItalic, bold, nonBold};
OperationMode: TYPE = {copy, moveStretch, moveNoStretch, delete};
Details: TYPE = {boxWidth, gridSize};
MacroMode: TYPE = {expand, check, define, clear};
CompMode: TYPE = {tics, magnification, oneLevel, yInc, frames};
InputCharMode: TYPE = {NotInputingRope, InputingRope, waitingFor1CharArg, waitingForConfirmation};
UIType: TYPE = {CenterOnMark, ChangeSelected, Compliment, Destroy, DrawBox, DrawRope, EraseArea, HardCopy, InputFile, KillPicture, ManipulateMacro, MarkAsEdited, MergeArea, OperateOnSelected, SelectForAttrib, SelectWithPos, SetCaret, SetCursor, SetDefaultAttribs, SetDetails, ShowMacros, StoreFile, SwapFonts, TrackMouse, Undelete, UserChar};
UInput: TYPE = LIST OF UInputRec;
UInputRec: TYPE = RECORD [
SELECT in: UIType FROM
CenterOnMark  => [],
ChangeSelected  => [char: CHAR ← 'a],
Compliment   => [mode: CompMode],
DrawBox    => [markRel: Relation ← relative, originRel: Relation ← relative,
       x: INTEGER ← 0, y: INTEGER ← 0, background: BOOLFALSE],
DrawRope   => [rope: ROPE, rel: Relation ← absolute],
EraseArea   => [xMin, yMin, xMax, yMax: INTEGER],
HardCopy   => [char: CHAR ← 'a],
InputFile    => [mode: Relation ← absolute],
KillPicture   => [],
ManipulateMacro => [mode: MacroMode, char: CHAR ← 'a],
MarkAsEdited  => [],
MergeArea   => [xMin, yMin, xMax, yMax: INTEGER],
OperateOnSelected => [op: OperationMode, rel: Relation ← relative, x: INTEGER ← 0,
       y: INTEGER ← 0],
SelectForAttrib  => [mode: SelectMode, char: CHAR ← 'a],
SelectWithPos  => [x: INTEGER, y: INTEGER, mode: SelectMode ← change],
SetCaret    => [caret: CaretSet, x: INTEGER ← 0, y: INTEGER ← 0, mode: Relation],
SetCursor    => [caret: CaretSet ← mark],
SetDefaultAttribs => [char: CHAR ← 'a],
SetDetails    => [detail: Details, char: CHAR ← 'a],
ShowMacros   => [char: CHAR ← 'a],
StoreFile    => [clip: BOOLTRUE, large: BOOLFALSE],
SwapFonts   => [],
TrackMouse   => [x: INTEGER, y: INTEGER],
Undelete    => [],
UserChar    => [c: CHAR ← 'a]
ENDCASE
];
Grid spacing is handled by the input module.
defaultGridSpacing: NAT = 4;
InitTipTable: PROC [tipTable: TIPUser.TIPTable];
Set the tip table so it can be referenced later on. This routine had better be called before any Sil windows are created.
InitUserInput: PROC [data: SilData, viewer: ViewerClasses.Viewer];
Initialize all the state needed to process user input. This routine must be called once for every Sil window.
DestroyUserInput: PROC [uiData: SilUIData];
Perform necessary actions for the destruction of this user input. A cleanup procedure analogous to Init User Input.
SilNotify: ViewerClasses.NotifyProc;
[self: Viewer, input: LIST OF REF ANY]
The notify proc which the viewers package will call. This process will be placing user input records on the user input queue.
While using SilNotify we will need to acquire the input focus (we will not receive control characters if we don't have the input focus - we will only receive mouse clicks). These three routines will handle input focus management.
SilModifyInputFocus: ViewerClasses.ModifyProc;
[self: Viewer, change: ModifyAction]
Call me when the user input focus changes.
GetInputFocus: PROC[uiData: SilUIData];
Make sure that we have the input Focus.
HasInputFocus: PROC[] RETURNS [hasIt: BOOL];
Do we have the input Focus?
Enque: PROC [UI: UInputRec, uiData: SilUIData];
Enque the user input so that it can be processed sequentially with all the other user inputs.
Does a notify on gotInput.
Deque: PROC [uiData: SilUIData] RETURNS [UI: UInputRec];
Deque a user input so that it can be processed. Returns NIL if there was no input.
InputAvailable: PROC [uiData: SilUIData] RETURNS [yes: BOOL];
True if there is user input available, else false.
AwaitUserInput: PROC [uiData: SilUIData];
Wait until somebody typed (or moused) something.
The fact that a caret needs to be updated in the Sil window associated with this user input module is an event which is very similar to a user input event - so, it is handled here.
SetCaretChange: PROC [uiData: SilUIData];
Set the information which will tell the display process to blink the caret.
CaretHasChanged: PROC [uiData: SilUIData];
Make uiData reflect the fact that the caret has been blinked.
ShouldChangeCaret: PROC [uiData: SilUIData] RETURNS [changeIt: BOOL];
True if the caret should be blinked.
The gridding of the cursor is handled here, and the display module must be able to tell this module that it should change its grid interval, or that the display has gone into magnify mode. (For more info on magnify mode, see the users explanation of Sil or the display implementation module.)
ChangeGridInterval: PROC [uiData: SilUIData, gridSpacing: NAT];
Change the cursor grid spacing.
MagnifyGrid: PROC [uiData: SilUIData, xOffset, yOffset: REAL, magnification: NAT];
Make the cursor gridding reflect the current magnification. xOffset and yOffset fit in the equation: Client coords = Sil Coords * (mag, -mag) + offset.
There are certain characters which are treated differently if a string is being input than at other times (like control-w - means back up a word in string input, and set the line width otherwise), so the input module must know whether or not it is accepting a string in order to enque the right input records.
NotInputingRope: PROC [uiData: SilUIData];
Tell the userinput module that Sil is no longer in Rope Editing Mode.
InputingRope: PROC [uiData: SilUIData];
Tell the userinput module that Sil is now in Rope Editing Mode.
GetBiScroller: PROC [uiData: SilUIData] RETURNS [bs: BiScrollers.BiScroller];
Return the BiScroller associated with this particular Sil model
END.