-- File: IntAnswerCom.Mesa
-- edited by Horning, February 27, 1979 5:45 PM
-- edited by Brotz, February 13, 1981 4:39 PM
-- edited by Levin, February 13, 1981 4:33 PM
-- edited by Schroeder, Wednesday Nov. 5, 1980 3:06 pm PST
DIRECTORY
Answer,
Editor,
exD: FROM "ExceptionDefs",
Inline,
intCommon: FROM "IntCommon",
inD: FROM "InteractorDefs",
ovD: FROM "OverviewDefs",
prD: FROM "ProtectionDefs",
Storage,
tsD: FROM "TOCSelectionDefs",
vmD: FROM "VirtualMgrDefs";
IntAnswerCom: PROGRAM
IMPORTS Answer, Editor, exD, Inline, intC: intCommon, inD, prD, Storage, tsD, vmD
EXPORTS inD =
BEGIN
AnswerCommand: PUBLIC PROCEDURE [hp: inD.HousePtr, confirmed: BOOLEAN] =
-- Clears old composed message and initializes a new one to the standard reply. Refreshes
-- display of the composed message.
BEGIN
answerError: BOOLEAN ← FALSE;
mnp: inD.MessageTextNbrPtr = intC.cmTextNbr;
answerMessage: vmD.ComposeMessagePtr;
getMessage: vmD.DisplayMessagePtr;
GetChar: PROCEDURE [index: CARDINAL] RETURNS [CHARACTER] =
{RETURN[vmD.GetMessageChar[getMessage, index]]};
PutBlock: PROCEDURE [block: Answer.Block] =
BEGIN
[] ← vmD.InsertSubstringInMessage
[answerMessage, LOOPHOLE[Inline.LowHalf[block.buffer] - 2, STRING],
0, block.length];
END; -- of PutBlock --
GetPages: PROCEDURE [nPages: CARDINAL] RETURNS [LONG POINTER] =
{RETURN[Storage.Pages[nPages]]};
FreePages: PROCEDURE [p: LONG POINTER] =
{Storage.FreePages[Inline.LowHalf[p]]};
answerBody: STRING ="M̌essage¿
"L;
-- main body of AnswerCommand
IF tsD.TOCSelectionEmpty[] THEN {exD.DisplayException[exD.cantAnswer]; RETURN};
IF ~confirmed AND intC.composedMessageEdited
AND vmD.GetMessageSize[mnp.message] # 0
AND ~inD.AskUserToConfirm[exD.willReplaceMessage]
THEN RETURN;
getMessage ← vmD.AllocateDisplayMessageObject[];
[] ← vmD.VirtualizeMessage[tsD.FirstSelectedEntry[], getMessage];
Editor.SwapMessageWithDeletionBuffer[mnp];
Editor.ResetInsertionBuffer[mnp];
answerMessage ← vmD.MapVirtualToComposeMessage[mnp.message];
vmD.InitComposeMessage[answerMessage, ""L];
vmD.StartMessageInsertion[answerMessage, 0];
answerError ← Answer.MakeHeader
[getChar: GetChar,
getLength: vmD.GetMessageSize[getMessage],
putBlock: PutBlock,
getPages: GetPages,
freePages: FreePages,
userName: intC.user.name,
userRegistry: intC.user.registry,
arpaGatewayHostNames: intC.arpaGatewayHostNames,
cForCopies: intC.cForCopies];
[] ← vmD.InsertSubstringInMessage[answerMessage, answerBody, 0, answerBody.length];
vmD.StopMessageInsertion[answerMessage];
vmD.FreeVirtualMessageObject[getMessage];
-- Answer form complete: make Editor and Interactor happy
BEGIN OPEN inD, Editor;
newMessageLength: ovD.CharIndex ← vmD.GetMessageSize[answerMessage];
intC.source ← TextSelection[mnp, 0, 0, 0, char, FALSE];
intC.actionPoint ← 0;
intC.commandType ← get;
intC.target ← TextSelection
[mnp: mnp, start: newMessageLength - 11, end: newMessageLength - 2,
point: newMessageLength - 11, mode: char, pendingDelete: intC.editorType = modeless];
intC.newTargetSelection ← TRUE;
intC.pendingDeleteSetByControl ← FALSE;
SetHighWaterMark[0];
mnp.haveMessage ← TRUE;
intC.composedMessageEdited ← FALSE;
intC.runCommandMode ← FALSE;
IF mnp.protectedFieldPtr # NIL THEN prD.UnprotectAllFields[@mnp.protectedFieldPtr];
RefreshSoThatFirstCharStartsLine[firstChar: 0, firstLine: mnp.lines, mnp: mnp];
intC.deliverCommandHouse.text.length ← 0;
intC.deliverCommandHouse.typeface ← italicFace;
intC.deliverCommandHouse.callable ← FALSE;
TextHouseRefresher[intC.deliverCommandHouse];
IF answerError THEN exD.DisplayException[exD.answerIncomplete];
END; -- of OPEN --
END;-- of AnswerCommand --
END. -- IntAnswerCom --