-- file: Editor.Mesa
-- last edited by Brotz, April 27, 1981 4:38 PM
-- last edited by Levin, February 21, 1980 3:44 PM
DIRECTORY
dsD: FROM "DisplayDefs",
inD: FROM "InteractorDefs",
KeyDefs,
ovD: FROM "OverviewDefs",
vmD: FROM "VirtualMgrDefs";
Editor: DEFINITIONS =
BEGIN OPEN inD;
-- Editor Department of the Interactor Division
-- Implements the editor for the composed message. Commands are: Insert, Append,
-- Replace, Delete, Undo, Redo. Other operations (which are not commands per se) are
-- selection, scrolling, and command aborting.
EditorType: TYPE = {modal, modeless};
CommandType: TYPE = {noCommand, insert, delete, append, replace, get};
Rectangle: TYPE = RECORD
[left, right: dsD.ScreenXCoord,
top, bottom: dsD.ScreenYCoord];
UnderlineType: TYPE = {target, source};
UnrecognizedCommandProcedure: TYPE = PROCEDURE
[mnp: MessageTextNbrPtr, char: CHARACTER];
shiftedSelectionFlag: CHARACTER = 241C;
-- If in keystream, indicates use secondary selection.
nextCode: CHARACTER = 35C; -- NEXT key set to this value if editor is modeless.
cancelCode: CHARACTER = 36C; -- CANCEL key set to this value if editor is modeless.
insertDeletionCode: CHARACTER = 37C; -- LF key set to this value if editor is modeless.
nextBracketStringCode: CHARACTER = 242C; -- red bug of bracket command house.
composedMessagePages: CARDINAL = 5;
insertionBufferPages: CARDINAL = 2;
deletionBufferPages: CARDINAL = 2;
-- Procedures --
AcceptTypeIn: PROCEDURE [mnp: MessageTextNbrPtr, char: CHARACTER];
BracketCommand: PROCEDURE [mnp: MessageTextNbrPtr, char: CHARACTER];
ButlersBoundaryCommand: PROCEDURE [commandNumber: CARDINAL];
CancelSourceSelection: PROCEDURE [mnp: MessageTextNbrPtr];
CancelTargetSelection: PROCEDURE;
Decode: KeyboardInputAcceptor;
-- Dispatches to specific routines for handling a specific editor command. Fixes up
-- scratch buffer and lastCommand upon return of any of the command routines.
Deleter: PROCEDURE [mnp: MessageTextNbrPtr];
-- Deletes primary selection from mnp.message. Sets new primary selection to the null range
-- at the start of the just used primary selection. Depends on caller to adjust primary
-- selection after return if default selection is desired.
DoTargetSelection: PROCEDURE;
FCommand: PROCEDURE;
FindOperation: PROCEDURE [s: STRING, start, end: ovD.CharIndex,
mnp: MessageTextNbrPtr]
RETURNS [found: BOOLEAN, at, atEnd, patternEnd: ovD.CharIndex];
-- Searches for a match to s within [start .. end) of mnp.message. If found, returns TRUE,
-- with [at .. atEnd) the matched range, and patternEnd the first character not matched
-- by the pattern, which may differ from atEnd due to } selection termination.
GCommand: PROCEDURE [mnp: MessageTextNbrPtr];
-- Replaces the current primary selection with the contents of the file named in
-- the get/put brackets.
InsertFromLastCommand: PROCEDURE [mnp: MessageTextNbrPtr];
-- Only callable if editorType = modal. Implements R ESC, A ESC, I ESC.
InsertLastDeletion: PROCEDURE [mnp: MessageTextNbrPtr];
-- Only callable if editor is modeless. Implements the editor Move command.
InsertRangeInMess: PROCEDURE [targetIndex: ovD.CharIndex, targetMessage: vmD.ComposeMessagePtr, from: vmD.MessageRange];
-- ### Temporary KLUDGE to keep from losing virtual manager error messages.
MakeCharIndexVisible: PROCEDURE [index: ovD.CharIndex, mnp: MessageTextNbrPtr,
offScreenSlop: CARDINAL ← 40] RETURNS [line: LinePtr];
-- Ensures that the caret will be visible during type in.
PCommand: PROCEDURE [mnp: MessageTextNbrPtr];
-- Writes the current primary selection onto the file named in the get/put brackets.
PrepareForTypeIn: PROCEDURE [mnp: MessageTextNbrPtr];
-- Resets primary selection and handles pending delete properly.
Redo: PROCEDURE [mnp: MessageTextNbrPtr];
-- Redoes the last command with the Segment [start .. end).
ReplaceRangeInMess: PROCEDURE [to, from: vmD.MessageRange];
-- ### Temporary KLUDGE to keep from losing virtual manager error messages.
SCommand: PROCEDURE;
SelectEverything: PROCEDURE [mnp: MessageTextNbrPtr];
-- Implements editor E command.
SelectNextBlank: PROCEDURE [mnp: MessageTextNbrPtr, forward: BOOLEAN ← TRUE];
-- Implements editor NEXT command.
TCommand: PROCEDURE [mnp: MessageTextNbrPtr];
TurnOnDeliver: PROCEDURE;
Undo: PROCEDURE [mnp: MessageTextNbrPtr];
-- Undoes the last command, ignoring subsequent window commands or selections.
UnrecognizedCommand: PROCEDURE;
UpdateScreen: PROCEDURE [start: ovD.CharIndex, nCharsDeleted,
nCharsInserted: CARDINAL, mnp: MessageTextNbrPtr,
select: BOOLEAN ← TRUE];
-- Shortcut call to screen refreshers. Updates selections and Deliver command as well.
-- Smart Display Section of the Editor Department
-- Maintains lines and characters within lines on the screen. Handles scrolling,
-- refreshing, mapping x,y to character indices.
RefreshFromFirstChange: PROCEDURE [actionIndex: ovD.CharIndex,
deletedChars, insertedChars: CARDINAL, mnp: MessageTextNbrPtr];
-- A change in the message text has occured at actionPoint. Its relation to the screen is
-- unknown. This routine is to fix up the screen to reflect the new state of the message
-- text.
RefreshToPlaceCharOnLine: PROCEDURE [startCharIndex: ovD.CharIndex, line: LinePtr,
mnp: MessageTextNbrPtr, underline: BOOLEAN ← TRUE];
-- Refresh CM window from line on (inclusive), so that firstCharIndex appears somewhere
-- in line after refresh. Selections will be refreshed with their underlines iff underline
-- is TRUE.
RefreshSoThatFirstCharStartsLine: PROCEDURE [firstChar: ovD.CharIndex,
firstLine: LinePtr, mnp: MessageTextNbrPtr, underline: BOOLEAN ← TRUE];
-- Refresh all lines of screen in range [firstLine .. bottomLine], so that firstChar starts
-- firstLine. Selections will be refreshed with their underlines iff underline is TRUE.
-- Side effects: advances highWaterMark.
RefreshEndOfMessage: PROCEDURE [mnp: MessageTextNbrPtr];
-- Repaints "End of Message" line if visible with current endOfMessageString.
MapXInLineToCharIndex: PROCEDURE [x: ScreenXCoord, line: LinePtr,
message: vmD.VirtualMessagePtr]
RETURNS [index: ovD.CharIndex, leftX, rightX: ScreenXCoord];
-- Returns the charIndex covering x in line and returns the x bounds of that charIndex.
ScrollUpCM: 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.
MapYToNonBlankLine: PROCEDURE [y: ScreenYCoord, mnp: MessageTextNbrPtr]
RETURNS [line: LinePtr];
-- Returns the screen line associated with y. If y falls on blank line below the end of
-- message, then returns the end of message line.
ClearScreenLinesToTrailingBlankLines: PROCEDURE [startLine: LinePtr,
charIndex: ovD.CharIndex, mnp: MessageTextNbrPtr];
-- Clears the screen bit map and fixes the line blocks for all lines from [startLine ..
-- firstLineOffScreen].
ScrollDownCM: 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.
Underline: PROCEDURE [start, end: ovD.CharIndex, underlineType: UnderlineType,
pendingDelete: BOOLEAN, mnp: MessageTextNbrPtr];
-- Draws an underline indication on the screen for the visible section of the message in
-- the range [start .. end).
DrawUnderlineInLine: PROCEDURE [start, end: ScreenXCoord, line: LinePtr,
underlineType: UnderlineType, pendingDelete: BOOLEAN];
-- XOR’s an underline from start to end on the last scan line for line.
DeUnderline: PROCEDURE [start, end: ovD.CharIndex, underlineType: UnderlineType,
pendingDelete: BOOLEAN, mnp: MessageTextNbrPtr];
-- Removes the underline indication on the screen for the visible section of the message
-- in the range [start .. end).
UnderlineSelection: PROCEDURE [selection: TextSelectionPtr, underline: UnderlineType];
-- Underlines entire selection.
DeUnderlineSelection: PROCEDURE [selection: TextSelectionPtr, underline: UnderlineType];
-- DeUnderlines entire selection.
ClearSourceSelection: PROCEDURE;
-- DeUnderlines and reinitializes intC.source.
InitializeSelection: PROCEDURE [selection: TextSelectionPtr];
-- Initializes a selection to its default values.
FormatCM: PROCEDURE [cm: vmD.ComposeMessagePtr];
-- Formats all of the composed message from the high water mark to the end,
-- expanding the message to break up long lines if necessary. highWaterMark is
-- set to the end of the message.
MapCharIndexToLine: PROCEDURE [index: ovD.CharIndex, mnp: MessageTextNbrPtr]
RETURNS [LinePtr];
-- Returns the screen line that contains index. Returns NIL if index is not currently
-- displayed on any visible screen line.
RangeRightXInLine: PROCEDURE [start, to: ovD.CharIndex, startX: ScreenXCoord,
message: vmD.VirtualMessagePtr] RETURNS [width: CARDINAL];
-- Returns the sum of the widths in screen raster points of the characters from the
-- interval [start .. to) in messsage if placed starting at startX.
MapCharIndexInLineToLeftX: PROCEDURE [index: ovD.CharIndex, line: LinePtr,
message: vmD.VirtualMessagePtr] RETURNS [x: ScreenXCoord];
-- index is in line.
-- Returns the ScreenXCoord of the left edge of the character corresponding to index in
-- message.
AdjustFirstCharIndices: PROCEDURE [firstLine: LinePtr, increment: INTEGER];
-- Increments the firstCharIndex of all screen lines from firstLine on.
MapCursorToCharIndex: PROCEDURE [x: ScreenXCoord, y: ScreenYCoord,
mnp: MessageTextNbrPtr] RETURNS [index: ovD.CharIndex];
-- Map x,y to a char index in message. If x,y is to the right of the rightmost char on its
-- line, treat as rightmost character. Similarly, if y is too far down on screen, treat as if
-- y was on the last screen line that holds normal message text.
NthLineFrom: PROCEDURE [line: LinePtr, n: CARDINAL] RETURNS [nthLine: LinePtr];
-- Returns the nth line from line in the line chain, or NIL if fewer than n lines remain.
SetHighWaterMark: PROCEDURE [h: ovD.CharIndex];
-- Sets highWaterMark.
-- Keyboard management procedures --
ShiftKey: PROCEDURE [state: KeyDefs.updown] RETURNS [yes: BOOLEAN];
ComKey: PROCEDURE [state: KeyDefs.updown] RETURNS [yes: BOOLEAN];
ControlKey: PROCEDURE [state: KeyDefs.updown] RETURNS [yes: BOOLEAN];
ComTap: PROCEDURE RETURNS [yes: BOOLEAN];
-- Returns TRUE iff a Com tap has occurred. Upon return of TRUE, Com tap is reset.
ControlTap: PROCEDURE RETURNS [yes: BOOLEAN];
-- Returns TRUE iff a Control tap has occurred. Upon return of TRUE, Control tap is reset.
ResetTaps: PROCEDURE;
-- To be called when any mouse buttons go down in selection areas or on a SHIFT-CANCEL.
MonitorTaps: PROCEDURE;
-- To be called continuously. Maintains Control and COM key states and records Com and
-- Control taps.
-- Buffer management procedures --
ResetInsertionBuffer: PROCEDURE [mnp: MessageTextNbrPtr];
-- Resets mnp.insertionBuffer to be empty.
ResetDeletionBuffer: PROCEDURE [mnp: MessageTextNbrPtr];
-- Resets mnp.deletionBuffer to be empty.
ResetBuffers: PROCEDURE [mnp: MessageTextNbrPtr];
-- Resets both mnp.insertionBufffer and mnp.deletionBuffer.
SwapMessageWithDeletionBuffer: PROCEDURE [mnp: MessageTextNbrPtr];
-- Exchanges contents of mnp.message with mnp.deletionBuffer.
SwapMessageWithInsertionBuffer: PROCEDURE [mnp: MessageTextNbrPtr];
-- Exchanges contents of mnp.message with mnp.insertionBuffer.
SwapInsertionWithDeletionBuffer: PROCEDURE [mnp: MessageTextNbrPtr];
-- Exchanges contents of mnp.insertionBuffer with mnp.deletionBuffer.
END. -- of Editor --