-- file: InteractorDefs
-- edited: by McCreight, September 12, 1980 2:36 PM
-- edited: by Brotz, June 24, 1982 10:51 AM
-- edited: by Levin, January 7, 1981 5:07 PM
-- edited: by Schroeder, November 5, 1980 9:00 AM

DIRECTORY
Core USING [DMSUser],
dsD: FROM "DisplayDefs" USING [bmWidth, CursorShape, DCBptr, FaceType,
PictureClass, ScreenXCoord, ScreenYCoord, xOrigin],
exD: FROM "ExceptionDefs" USING [Exception],
Inline USING [BITAND],
KeyDefs USING [updown],
prA: FROM "ProtectionAbstractions" USING [ProtectedFieldPtr],
RetrieveDefs USING [MBXState],
vmD: FROM "VirtualMgrDefs" USING [CharIndex, ComposedMessagePtr, TOCHandle,
TOCIndex, VirtualMessagePtr];

inD: DEFINITIONS IMPORTS Inline =

BEGIN

-- Purpose: handles user interactions including the display, keyboard and mouse. This
-- division gathers together commands and their arguments and is responsible for the
-- display of all error messages.


InstallCatcher: PROCEDURE;
-- Sets up uncaught signal handler during MCStart


BuildScreenStructures: PROCEDURE;
-- Allocates and fills in the region - neighborhood - house structure. Implemented in
-- InitInteractor.Mesa


SetScreenParameters: PROCEDURE [screenParameters: ScreenParametersArray];
-- Sets all Y dependent parameters for the screen. Links DCB’s into the hardware display
-- chain.


IdleLoop: PROCEDURE;
-- Called by cursor tracking routines and any other routine that has time on its hands.
-- Checks clock and calls procedures that must be activated at regular intervals, such as
-- the time update for the top window and periodic mail checks.


SetTime: PROCEDURE;
-- initiates time requests on the network.


ReportMBXState: PROCEDURE[mbxState: RetrieveDefs.MBXState];
-- reports mailbox state on the screen


UpdateTOCThumbLine: PROCEDURE [tnp: TOCTextNbrPtr, key: CARDINAL];
-- Checks the TOC thumb line for a change in state and updates accordingly.


IndicateCommandBusy: PROCEDURE [hp: HousePtr];
-- Shows that a command is in progress, by: displaying the command house in gray and
-- changing the cursor shape.


IndicateCommandFinished: PROCEDURE [hp: HousePtr];
-- Shows that a command is finished, by: displaying the command house in white.


MakeCommandsCallable: PROCEDURE [callable: BOOLEAN];
-- Sets the callable property of all commands currently on screen to be the value of the
-- input parameter.


MouseButton: PROCEDURE [button: ButtonType, position: KeyDefs.updown]
RETURNS [BOOLEAN] = INLINE
-- Returns Boolean value for test of any mouse button position
BEGIN
-- Hardware convention: Mouse button up corresponds to its bit in mouseButton↑ being 1.
RETURN[Inline.BITAND[mouseBitsLoc↑, button]
# (IF position = up THEN 0 ELSE LOOPHOLE[button])];
END; -- of MouseButton --


SavedMouseButton: PROCEDURE
[bits: UNSPECIFIED, button: ButtonType, position: KeyDefs.updown]
RETURNS [BOOLEAN] = INLINE
-- Returns Boolean value for test of a saved mouse button position
BEGIN
-- Hardware convention: Mouse button up corresponds to its bit in mouseButton↑ being 1.
RETURN[Inline.BITAND[bits, button]
# (IF position = up THEN 0 ELSE LOOPHOLE[button])];
END; -- of MouseButton --




AcceptKeyboardInput: PROCEDURE;
-- Called by cursor tracking routines when keyboard input is acceptable. Dispatches to
-- the proper command interpreter. The standard Laurel editor operates in a mode such
-- that the acceptKeyboardInputStream is identical to intC.keystream. Thus, when input
-- is present on the acceptKeyboardInputStream it is also present on the intC.keystream.
-- Other command interpreters may introduce a filter between these two keystreams.
-- This procedure guarantees that input is present on the acceptKeyboardInputStream;
-- if operating in a nonstandard mode, the current KeyboardInputAcceptor must funnel
-- input from this keystream to whichever keystream is used by subsequent procedures.


StartBlinkingCaret: PROCEDURE [x: ScreenXCoord, y: ScreenYCoord];
-- Notes time of call, places caret at x,y.


SetCaretBlinking: PROCEDURE [charIndex: CharIndex, mnp: MessageTextNbrPtr];
-- Like StartBlinkingCaret, but works with indexes and messages.


SetBracketsCaretBlinking: PROCEDURE;
-- Like StartBlinkingCaret, but works with the current caret in brackets.


MaintainBlinkingCaret: PROCEDURE;
-- Inverts caret at remembered x,y at appropriate time.


StopBlinkingCaret: PROCEDURE;
-- Restores caret picture to original state.


CaretIsBlinking: PROCEDURE RETURNS [BOOLEAN];
-- Indicates whether the editor is in a state such that the caret should be blinking.


PlayTune: PROCEDURE [s: STRING];
-- Tweaks speaker output to play tune encoded in s.


ScreenTracker: PROCEDURE [trackerType: TrackerType];
-- Determines which cursor tracking routine should handle cursor tracking based on the
-- cursor’s current position. This procedure is the highest on any calling chain. A
-- return to ScreenTracker means that a lower level cursor tracker has determined that
-- the cursor has moved out of its jurisdiction and a new lower level cursor tracker
-- should be invoked.


CommandTracker: PROCEDURE [cnp: CommandNbrPtr, trackerType: TrackerType];
-- This is the nbrTracker for command neighborhoods. Sets cursor shape for command
-- neighborhood. Watches for button up and down, calls routines to invert and restore
-- command houses on screen. Calls routines in Command Dept. as appropriate.


HouseTracker: PROCEDURE [hp: HousePtr, trackerType: TrackerType];
-- Tracks cursor when within a command house. Watches for button down and up,
-- inverts house display pattern, and calls command procedure when fired.


TextHouseRefresher: PROCEDURE [hp: HousePtr];
-- Repaints one text house on the display screen according to the parameters contained in
-- hp↑.


BracketsHouseRefresher: PROCEDURE [hp: HousePtr];
-- Repaints one brackets command house on the display screen.


NullHouseRefresher: PROCEDURE [hp: HousePtr];
-- Place-holder for houses that don’t exist.


RefreshHouse: PROCEDURE [hp: HousePtr, text: STRING];
-- Resets hp.text to text and calls hp.houseRefresher.


MoveTOCDMBoundary: PROCEDURE[bnp: BoundaryPadNbrPtr, y: ScreenYCoord];
-- Changes TOC-DM boundary to legal position closest to y.


MoveDMCMBoundary: PROCEDURE[bnp: BoundaryPadNbrPtr, y: ScreenYCoord];
-- Changes DM-CM boundary to legal position closest to y.


AdjustBoundaries: PROCEDURE [tocdmY, dmcmY: ScreenYCoord];
-- Adjust screen so that the boundary pads will be at tocdmY and dmcmY.


-- TOC Department of the Interactor Division
-- Responsible for cursor tracking and display manipulation within the TOC town.
-- Procedures in this department may call on the Virtual TOC routines and share a
-- number of common data structures, such as the TOC line index, selected item indices,
-- TOC town boundaries, etc.


TOCTracker: PROCEDURE [tnp: TOCTextNbrPtr, trackerType: TrackerType];
-- Tracks cursor within the TOC text neighborhood. Chooses among three
-- subneighborhood cursor trackers depending on the cursor’s position.


TOCTextPainter: PROCEDURE [tnp: TOCTextNbrPtr, key: CARDINAL];
-- Paints the entire TOC Text neighborhood.


Consider: PROCEDURE
[lowIndex, highIndex: vmD.TOCIndex, tnp: TOCTextNbrPtr, key: CARDINAL];
-- Paints considered marker on the first lines of all visible TOCEntries in the range
-- [lowIndex..highIndex].


Deconsider: PROCEDURE
[lowIndex, highIndex: vmD.TOCIndex, tnp: TOCTextNbrPtr, key: CARDINAL];
-- Removes selected marker from the first lines of all visible TOCEntries in the range
-- [lowIndex..highIndex].


DisplayTOCTail: PROCEDURE [tnp: TOCTextNbrPtr, key: CARDINAL, line: LinePtr,
index: vmD.TOCIndex, lineNum: TOCLineNumber];
-- Paints the rest of the TOC neighborhood from line to the bottom. The first text
-- displayed is lineNum of index. Displays End of messages if necessary.


DisplayTOCEntry: PROCEDURE [tnp: TOCTextNbrPtr, key: CARDINAL,
index: vmD.TOCIndex, suppressed: CARDINAL, firstLine: LinePtr]
RETURNS [firstUnusedLine: LinePtr, nLines: CARDINAL];
-- Paints the index’th TOCEntry on screen. suppressed gives number of lines of the
-- TOCEntry to skip before displaying the rest of the TOCEntry. firstLine points to the
-- Line descriptor for the first line to be used. DisplayTOCEntry stops displaying when
-- either it has displayed the entire entry or it runs to the end of the Line list. In
-- either case it returns the total number of lines (including suppressed lines) that this
-- TOCEntry requires and the next available Line.


MapTOCIndexToTOCLine: PROCEDURE [index: vmD.TOCIndex, tnp: TOCTextNbrPtr,
line: LinePtr ← NIL] RETURNS [LinePtr];
-- Returns the tocLine for index. Returns NIL if index is not currently displayed. Starts
-- search at line if not NIL.


MapYToTOCIndex: PROCEDURE [y: ScreenYCoord, tnp: TOCTextNbrPtr]
RETURNS [vmD.TOCIndex];
-- Returns the vmD.TOCIndex of the TOCEntry that occupies the line containing y.


ThisIsAFirstLine: PROCEDURE [y: ScreenYCoord, tnp: TOCTextNbrPtr]
RETURNS [BOOLEAN];
-- Returns TRUE if y is in a first line of a TOCEntry, FALSE otherwise.


MapTOCIndexToTopY: PROCEDURE [index: vmD.TOCIndex, tnp: TOCTextNbrPtr]
RETURNS [ScreenYCoord, BOOLEAN];
-- Returns the first scanline for index. Returns FALSE if index is not currently
-- displayed.


ScrollUpTOC: PROCEDURE [y: ScreenYCoord, tnp: TOCTextNbrPtr, key: CARDINAL];
-- Computes number of lines to scroll up, moves area of screen up, refreshes bottom of
-- TOC with new text, and fixes up Line structures.


ScrollDownTOC: PROCEDURE [y: ScreenYCoord, tnp: TOCTextNbrPtr, key: CARDINAL];
-- Computes number of lines to scroll down, moves area of screen down, refreshes top of
-- TOC with new text, and fixes up Line structures.


ThumbTOC: PROCEDURE [tlnp: ThumbLineNbrPtr, np: NbrPtr, x: ScreenXCoord];
-- Determines which TOCEntry will be the first entry on screen after thumbing. Calls
-- DisplayTOC to display that entry and those that follow.


MakeTOCIndexVisible: PROCEDURE [index: vmD.TOCIndex, key: CARDINAL];
-- Makes the first line of index visible within the TOC window, including as much of the
-- entry as possible.


RefreshTOCChange: PROCEDURE [toc: vmD.TOCHandle, key: CARDINAL,
index: vmD.TOCIndex, action: TOCChangeAction];
-- Updates the TOC selection according to action, and repaints the TOC neighborhood if toc
-- is the one currently displayed there. A single TOC entry may be inserted at index or
-- the index’th entry may be deleted or replaced by a new single entry. The change must
-- have already been made in the virtual TOC.


TOCChangeAction: TYPE = {delete, insert, replace};


FillScreenWithWords: PROCEDURE [x: ScreenXCoord, y: ScreenYCoord,
limX: ScreenXCoord, startCharIndex: CARDINAL, s: STRING]
RETURNS [firstUnusedCharIndex: CARDINAL, firstEmptyX: ScreenXCoord];
-- Fills the screen section [x..limX) with characters from s, breaking just before a word
-- begins. All white space characters remain on the same line as the word they follow.


NextTOCEntry: PROCEDURE [tnp: TOCTextNbrPtr, key: CARDINAL, entry: vmD.TOCIndex]
RETURNS [exists: BOOLEAN, nextEntry: vmD.TOCIndex];
-- Determines the next TOCEntry after entry according to the current TOC filter.


-- Message Nbr Department of the Interactor Division
-- Responsible for cursor tracking and display manipulation within the CM town.
-- Procedures in this division may call on the Virtual CM routines and share a number of
-- common data structures, such as selected item indices, town boundaries, etc.


TextNbrTracker: PROCEDURE [mnp: MessageTextNbrPtr, trackerType: TrackerType];
-- Tracks cursor within a message text area. Monitors mouse buttons for selection. Calls on
-- TextScrollBarTracker and Selector to track the cursor within their respective domains.


ScrollUpMessageNbr: PROCEDURE [y: ScreenYCoord, mnp: MessageTextNbrPtr];
-- y is the ScreenYCoord of the cursor. Scrolls the screen Up, based on this y position.
-- Adjusts all structures to reflect the new screen contents.


ScrollDownMessageNbr: PROCEDURE [y: ScreenYCoord, mnp: MessageTextNbrPtr];
-- y is the ScreenYCoord of the cursor. Scrolls the screen Down, based on this y position.
-- Adjusts all structures to reflect the new screen contents.


ThumbMessageNbr: PROCEDURE[tlnp: ThumbLineNbrPtr, np: NbrPtr, x: ScreenXCoord];
-- Determines which CharIndex of mnp.message will be on the top line and displays the
-- message accordingly.


MoveLines: PROCEDURE [top, bottom, newTop: LinePtr, mnp: MessageTextNbrPtr]
RETURNS [newBottom: LinePtr];



-- Boundary Department of the Interactor Division


BoundaryLineNbrTracker: PROCEDURE [bnp: BoundaryLineNbrPtr];
-- Tracks cursor within a boundary line neighborhood.


BoundaryPadNbrTracker: PROCEDURE [bnp: BoundaryPadNbrPtr, trackerType: TrackerType];
-- Tracks cursor within a boundary pad neighborhood.


ExceptionsTracker: PROCEDURE [mnp: MessageTextNbrPtr, trackerType: TrackerType];
-- Tracks cursor within the Exceptions neighborhood.


ThumbLineNbrTracker: PROCEDURE [tlnp: ThumbLineNbrPtr, trackerType: TrackerType];
-- Tracks cursor within a thumb line neighborhood.


ChangeCommandMenu: PROCEDURE [cnp: CommandNbrPtr, region: RegionPtr,
linesToKeep: CARDINAL];
-- The list of houses pointed to by cnp has changed. linesToKeep is the number of line of
-- the cnp that have not changed. Changes the menu on screen to display all houses now
-- in cnp’s houses list. Rearranges screen if necessary to accommodate changed command
-- neighborhood height.


GetStringForBrackets: PROCEDURE [hp: HousePtr, leftX, rightX: ScreenXCoord,
maxDeltaX: CARDINAL, bracketFace: dsD.FaceType, displayChars: BOOLEAN,
initialDisplayString, abortString, outputString: STRING,
acceptWhiteSpace: BOOLEAN ← FALSE, enumerate: PROC [STRING] ← NIL]
RETURNS [aborted: BOOLEAN, newRightX: ScreenXCoord];
-- Displays initialDisplayString in brackets. Accepts keyboard input and
-- displays it appended to initialDisplayString. If abort (DEL or CANCEL),
-- displays abortString in brackets and terminates. On termination (DEL or
-- CANCEL or ESC (or DO)), puts the then displayed string in outputString.
-- Returns the new right x position.


-- Editor Department of the Interactor Division
-- cf. EditorDefs.Mesa



-- Command Department of the Interactor Division
-- Contains Interactor portion of all commands. Any screen manipulation caused by
-- command invocation is done by these procedures. Global data for various commands is
-- held here. Display of errors occurring from commands is done by procedures in this
-- department. All procedures in this department have no call or return parameters so that
-- the type of each procedure is the same. Thus, callers of these procedures will be able to
-- be table driven.



GetMailFileCommand: CommandProcedure;
-- Calls ReturnMailFileOperation with activeMailFileName and TOCStructure. Clears TOC
-- Entries neighborhood and clears DM text neighborhood. Calls GetMailFileOperation
-- with GMFFileName, user’s file server name, password and file server port.; calls
-- DisplayException if failure is reported back. Determines what portion of the TOC
-- should be displayed, selects a default selected message interval, and calls DisplayTOC
-- to display the TOC.


LoginCommand: CommandProcedure;
-- Prompts for name and password. Returns them in user.
-- Side effects: changes user.


QuitCommand: CommandProcedure;
-- Calls QuitOperation. Calls DisplayException if failure is reported back.


GetNewMailCommand: CommandProcedure;
-- Calls AccessNewMailOperation with activeMailFileName, user’s DMS name, user’s file
-- server name, mail server password, file server password, mail server port, and file
-- server port. Calls DisplayException if failure is reported back.


DeleteCommand: CommandProcedure;
-- Sets deleted field and changed field for each selected TOCEntry. Updates the display to
-- reflect the changes.


UndeleteCommand: CommandProcedure;
-- Clears deleted field for each TOCEntry in the closed interval [selectedTOCEntry1 ..
-- selectedTOCEntry2]. Updates the display to reflect the changes.


HardcopyCommand: CommandProcedure;
-- Calls HardcopyOperation with active mail file stream and the interval end points
-- selectedTOCEntry1, selectedTOCEntry2. Calls DisplayException if failure is reported
-- back.


SetPrinterCommand: CommandProcedure;
-- Sets intC.hardcopyHost to contents of following brackets.


SetCopiesCommand: CommandProcedure;
-- Sets intC.hardCopies to contents of following brackets.


SetDuplexCommand: CommandProcedure;
-- Complements intC.twoSidedPrinting and Yes/No contents of following brackets.


SetPasswordProtectedCommand: CommandProcedure;
-- Complements intC.passwordPrinting and Yes/No contents of following brackets.


SetOverrideFormCommand: CommandProcedure;
-- Sets form to use for subsequent hardcopies to contents of following brackets.


HardcopyConfirmCommand: CommandProcedure;
-- Restores original command menu and continues hardcopy processing.


HardcopyCancelCommand: CommandProcedure;
-- Cancels hardcopy processing and restores original command menu.


DisplayMessageCommand: CommandProcedure;
-- Clears DM text neighborhood. Sets selectedTOCEntry2 to SelectedTOCEntry1. Calls
-- VirtualizeMessage with selectedTOCEntry1 and the DM VirtualStructure; calls
-- DisplayException if failure is reported back. Calls DisplayOneLine on the DM
-- VirtualStructure until either the neighborhood is full or the end of the DM
-- neighborhood is reached.


MoveMessageToFileCommand: CommandProcedure;
-- Calls AppendMailToFileOperation with [selectedTOCEntry1 .. selectedTOCEntry2],
-- MMFFileName, and activeMailFileStream. Calls DisplayException if failure is
-- reported back.


Confirm: PROCEDURE [lineNumber: CARDINAL] RETURNS [confirmed: BOOLEAN];
-- Displays confirmation message on lineNumber of exception region, waits for
-- confirmation input from user, displays exception if unexpected input received.


ConfirmInner: PROCEDURE [lineNumber: CARDINAL] RETURNS [char: CHARACTER];
-- Displays confirmation message on lineNumber of exception region, waits for
-- confirmation input from user, returns character typed by user.


ConfirmBrackets: PROCEDURE [hp: HousePtr, acceptWhiteSpace: BOOLEAN ← FALSE,
fileExtension: STRING ← NIL]
RETURNS [confirmed: BOOLEAN];
-- Accepts keyboard input file name, sets hp.text to this file name, and displays it in its
-- display position. Changes area of screen sensitive to mouse to reflect new brackets
-- size. Returns Boolean value FALSE if brackets fill in is aborted, TRUE if completed.


AskUserToConfirm: PROCEDURE [exception: exD.Exception]
RETURNS [confirmed: BOOLEAN];
-- Displays string corresponding to exception and the confirmation request message to
-- user. Returns the user’s answer.


SetExternalConfirmProc: PUBLIC PROCEDURE [proc: PROCEDURE RETURNS [BOOLEAN] ];
-- Allows a loaded program to redirect confirmation input and output. To cancel, call this
-- procedure with argument NIL.


NewFormCommand: CommandProcedure;
-- Clears old composed message and initializes a new one to the standard composed
-- message template. Refreshes display of the composed message.


AnswerCommand: CommandProcedure;
-- Clears old composed message and initializes a new one to the standard reply. Refreshes
-- display of the composed message.


ForwardCommand: CommandProcedure;
-- Clears old composed message and initializes a new one to the standard template for
-- forwarded messages, followed by the entire displayed message (surrounded by dashed
-- lines). Refreshes display of the composed message.


GetCommand: CommandProcedure;
-- Replaces the current composed message with the contents of the file named in the
-- brackets.


PutCommand: CommandProcedure;
-- Writes the current composed message onto the file named in the brackets.


CopyCommand: CommandProcedure;
-- Copies a remote or local file to a remote or local file using opD.Copy. The composed
-- message is not affected by this command.


RunCommand: CommandProcedure;
-- Interface to bcd loader and typescript handler.


SendCommand: CommandProcedure;
-- Calls SendOperation with CM VirtualStructure. Calls DisplayException if failure is
-- reported back.


SendOperation: PROCEDURE [cm: vmD.ComposedMessagePtr, user: Core.DMSUser,
formatProc: PROC [vmD.ComposedMessagePtr], confirmed: BOOLEAN ← FALSE,
userFeedback: BOOLEAN ← TRUE]
RETURNS [result: SendOperationResult];
-- Sends cm, formatted with formatProc.

SendOperationResult: TYPE = {ok, cancelled, commFailure, badMessage};


FindCommand: CommandProcedure;
-- Starting at the current selection, searches for text in following brackets. If found, selects
-- the found text and normalizes it in the composed message region.


SubstituteCommand: CommandProcedure;
-- Within the bounds of the current selection, substitutes the text in the following brackets
-- for each occurence of the text in the preceding brackets.


ShortenEditorMenuCommand: CommandProcedure;
-- Restores the editor menu to its original one line appearance.


NullCommand: CommandProcedure;
-- Does nothing. Purely a placeholder for information houses.



-- Interface Variables

keyboardInputAcceptorPtr: POINTER TO KeyboardInputAcceptor;



-- Things Defined Elsewhere

ScreenXCoord: TYPE = dsD.ScreenXCoord;
ScreenYCoord: TYPE = dsD.ScreenYCoord;
CharIndex: TYPE = vmD.CharIndex;


-- Type Definitions

KeyboardInputAcceptor: TYPE = PROCEDURE [mnp: MessageTextNbrPtr, char: CHARACTER];

CommandProcedure: TYPE = PROCEDURE [hp: HousePtr, confirmed: BOOLEAN];

TrackerType: TYPE = {normal, brackets};

ButtonType: TYPE = MACHINE DEPENDENT {middle(1), right(2), left(4), any(7)};

Region: TYPE = RECORD
[nextRegion: RegionPtr, -- next region on chain
dcb: dsD.DCBptr, -- DCB for this region
regionType: RegionType, -- identifies which region this is
topY, -- first scan line of region
bottomY: ScreenYCoord, -- first scan line not in region
cursorShape: dsD.CursorShape, -- shape for region
nbrs: NbrPtr]; -- first Nbr on Neighborhood list
RegionPtr: TYPE = POINTER TO Region;

RegionType: TYPE = {mailCommandRegion, tocRegion, tocCommandRegion, dmRegion,
cmCommandRegion, cmRegion, exceptionsRegion};

ScreenParametersArray: TYPE = ARRAY RegionType OF CARDINAL;

Nbr: TYPE = RECORD
[nextNbr: NbrPtr, -- next Nbr on chain
nLines: CARDINAL, -- actual number of screen lines covered by this Nbr
topY, -- first scan line in nbr.
bottomY: ScreenYCoord, -- first scan line not in nbr.
leftX, -- first X coord. in neighborhood
rightX: ScreenXCoord, -- first X coord. not in neighborhood
cursorShape: dsD.CursorShape, -- shape for neighborhood
nbrVariant: SELECT nbrClassTag: NbrClass FROM
command =>
[houses: HousePtr,
nbrTracker: PROCEDURE [CommandNbrPtr, TrackerType]],
tocText =>
[lines,
firstLineOffScreen: LinePtr,
toc: vmD.TOCHandle,
displayFormatted: BOOLEAN,
haveToc: BOOLEAN,
nbrTracker: PROCEDURE [TOCTextNbrPtr, TrackerType]],
messageText =>
[haveMessage: BOOLEAN,
editable: BOOLEAN,
lines,
firstLineOffScreen: LinePtr,
message: vmD.VirtualMessagePtr,
protectedFieldPtr: prA.ProtectedFieldPtr,
insertionBuffer: vmD.ComposedMessagePtr,
deletionBuffer: vmD.ComposedMessagePtr,
endString: STRING, -- Normally points to "End of Message.".
nbrTracker: PROCEDURE [MessageTextNbrPtr, TrackerType]],
boundaryLine => [nbrTracker: PROCEDURE [BoundaryLineNbrPtr]],
boundaryPad =>
[command: PROCEDURE [BoundaryPadNbrPtr, ScreenYCoord],
nbrTracker: PROCEDURE [BoundaryPadNbrPtr, TrackerType]],
thumbLine =>
[exists: BOOLEAN,
length,
start,
end,
selection: CARDINAL,
startX,
endX,
selectionX: ScreenXCoord,
np: NbrPtr, -- Nbr to thumb.
command: PROCEDURE [ThumbLineNbrPtr, NbrPtr, ScreenXCoord],
nbrTracker: PROCEDURE [ThumbLineNbrPtr, TrackerType]],
ENDCASE];
NbrPtr: TYPE = POINTER TO Nbr;

CommandNbrPtr: TYPE = POINTER TO command Nbr;
TOCTextNbrPtr: TYPE = POINTER TO tocText Nbr;
MessageTextNbrPtr: TYPE = POINTER TO messageText Nbr;
BoundaryLineNbrPtr: TYPE = POINTER TO boundaryLine Nbr;
BoundaryPadNbrPtr: TYPE = POINTER TO boundaryPad Nbr;
ThumbLineNbrPtr: TYPE = POINTER TO thumbLine Nbr;

NbrClass: TYPE = {command, tocText, messageText, boundaryLine, boundaryPad,
thumbLine};

House: TYPE = RECORD
[nextHouse: HousePtr, -- next house on chain
lineNumber: CARDINAL, -- line of the command Nbr for this House (starting at 0)
topY, -- first Y coord. in house
bottomY: ScreenYCoord, -- first Y not in house
leftX, -- first X coord. in house
rightX: ScreenXCoord, -- first X coord. not in house
text: STRING, -- string to be displayed on screen
fixedEdge: HouseFixedEdgeType, -- side of house whose position is fixed
typeface: dsD.FaceType, -- typeface for text
picture: dsD.PictureClass ← resetMenuIcon, -- picture if usePicture is TRUE
needsConfirmation: BOOLEAN, -- TRUE = command must be confirmed
trackerIndicateDone: BOOLEAN, -- TRUE = tracker will handle ungraying.
callable: BOOLEAN, -- TRUE = tracker indicate call status and call command.
usePicture: BOOLEAN ← FALSE, -- TRUE = paint picture instead of text.
command: CommandProcedure, -- to be called if house is bugged
houseRefresher: PROCEDURE [HousePtr]]; -- paints house
HousePtr: TYPE = POINTER TO House;

HouseFixedEdgeType: TYPE = {left, right};

Line: TYPE = RECORD
[y: ScreenYCoord, -- Y position of this line
nextLine: LinePtr,
state: LineState,
lineVariant: SELECT OVERLAID * FROM
tocLine => [linePair: LinePair],
messageLine =>
[rightX: ScreenXCoord,
firstCharIndex, -- first CharIndex displayed
pendingIndex: CharIndex], -- first CharIndex after reformatting
ENDCASE];
LinePtr: TYPE = POINTER TO Line;

LinePair: TYPE = RECORD
[index: vmD.TOCIndex, -- which TOC is displayed in line
lineNumber: TOCLineNumber]; -- which line of this TOC Entry
LinePairPtr: TYPE = POINTER TO LinePair;

LineState: TYPE = {index, end, empty, normalText, endOfMessage, trailingBlankLine};

TextSelection: TYPE = RECORD
[mnp: MessageTextNbrPtr,
start, end, point: CharIndex,
key: CARDINAL,
mode: SelectionMode,
pendingDelete: BOOLEAN];
TextSelectionPtr: TYPE = POINTER TO TextSelection;

SelectionMode: TYPE = {char, word, line, paragraph, everything};

TOCLineNumber: TYPE = CARDINAL;

CaretState: TYPE = {white, black, notVisible};

NewMailStatus: TYPE = {newMail, noNewMail, badMailboxID};

TextNbrSizes: TYPE = RECORD[toc, dm, cm: CARDINAL];

BoundarySetArray: TYPE = ARRAY [0 .. 9] OF TextNbrSizes;

BoundarySet: TYPE = POINTER TO BoundarySetArray;



-- Global Constants --

leftMargin: ScreenXCoord = dsD.xOrigin;
rightMargin: ScreenXCoord = leftMargin + dsD.bmWidth*16;
lineBarLeftX: ScreenXCoord = 24;
consideredLeftX: ScreenXCoord = leftMargin;
markLeftX: ScreenXCoord = leftMargin + 7;
numberLeftX: ScreenXCoord = leftMargin + 19;
numberRightX: ScreenXCoord = leftMargin + 43;

CRWidth: CARDINAL = 5;
digitWidth: CARDINAL = 6;

maxBracketStringLength: CARDINAL = 60;

maxLinesPerTOCEntry: CARDINAL = 3;

mouseX: POINTER TO CARDINAL = LOOPHOLE[424B];
mouseY: POINTER TO CARDINAL = LOOPHOLE[425B];
cursorX: POINTER TO CARDINAL = LOOPHOLE[426B];
cursorY: POINTER TO CARDINAL = LOOPHOLE[427B];
realTimeClock: POINTER TO CARDINAL = LOOPHOLE[430B];
mouseBitsLoc: POINTER TO UNSPECIFIED = LOOPHOLE[177030B];


END. -- of InteractorDefs