-- file: Extract.Mesa
-- edited by Brotz, January 3, 1983 1:33 PM
DIRECTORY
Ascii,
Editor,
dsD: FROM "DisplayDefs",
exD: FROM "ExceptionDefs",
inD: FROM "InteractorDefs",
intCommon,
IODefs,
LaurelExecDefs,
ovD: FROM "OverviewDefs",
tsD: FROM "TOCSelectionDefs",
vmD: FROM "VirtualMgrDefs";
Extract: PROGRAM
IMPORTS dsD, Editor, exD, inD, intC: intCommon, IODefs, LaurelExecDefs, tsD, vmD =
BEGIN
ExtractPatternInMailFile: PROCEDURE =
BEGIN
vm: vmD.DisplayMessagePtr;
tnp: inD.TOCTextNbrPtr = intC.tocTextNbr;
toc: vmD.TOCHandle = tnp.toc;
key: CARDINAL;
index: vmD.TOCIndex;
found, foundAny, foundInMessage: BOOLEAN ← FALSE;
pattern: STRING ← [inD.maxBracketStringLength];
at, atEnd, patternEnd: vmD.CharIndex;
MyTerminator: PROCEDURE [char: CHARACTER] RETURNS [BOOLEAN] =
{RETURN[char = Ascii.ESC]};
IF ~tnp.haveToc THEN {exD.DisplayException[exD.noCurrentFile]; RETURN};
IODefs.WriteLine["Extract prints all occurrences of ""pattern""."L];
IODefs.WriteChar[Ascii.CR];
IODefs.WriteLine["Special characters for use in the search pattern are:"L];
IODefs.WriteLine[" # = any char; * = any string; @ = any alpha; & = alpha string;"L];
IODefs.WriteLine[" ! = any non-alpha; ~ = non-alpha string; ’x = use ""x"""L];
IODefs.WriteLine["ESC terminates the search pattern."L];
IODefs.WriteChar[Ascii.CR];
IODefs.WriteString["Type search pattern: "L];
[] ← IODefs.ReadString[pattern, MyTerminator
! IODefs.Rubout => {IODefs.WriteLine[" XXX"L]; GOTO stop};
IODefs.LineOverflow =>
{IODefs.WriteLine[" XXX"L]; IODefs.WriteLine["Pattern too long."L]; GOTO stop}];
IODefs.WriteChar[Ascii.CR];
LaurelExecDefs.MakeMenuCommandCallable[display, FALSE];
LaurelExecDefs.MakeMenuCommandCallable[delete, FALSE];
LaurelExecDefs.MakeMenuCommandCallable[undelete, FALSE];
LaurelExecDefs.MakeMenuCommandCallable[mailFile, FALSE];
LaurelExecDefs.MakeMenuCommandCallable[newMail, FALSE];
LaurelExecDefs.MakeMenuCommandCallable[moveTo, FALSE];
LaurelExecDefs.MakeMenuCommandCallable[user, FALSE];
LaurelExecDefs.MakeMenuCommandCallable[copy, FALSE];
vm ← vmD.AllocateDisplayMessageObject[];
key ← vmD.WaitForLock[toc];
tsD.DeconsiderAll[tnp, key];
tsD.ResetTOCSelection[toc, key];
inD.UpdateTOCThumbLine[tnp, key];
FOR index IN [1 .. vmD.FirstFreeTOCIndex[toc, key]) DO
vmD.LoadDisplayMessage[toc, key, index, vm];
at ← 0;
foundInMessage ← FALSE;
DO
[found, at, atEnd, patternEnd]
← Editor.FindOperation[pattern, at, vmD.GetMessageSize[vm], vm];
SwingPendulum[];
IF found THEN
BEGIN
IF foundInMessage THEN IODefs.WriteString["
"]
ELSE BEGIN
IODefs.WriteChar[Ascii.CR];
IODefs.WriteDecimal[index];
IODefs.WriteString[":"L];
END;
foundInMessage ← foundAny ← TRUE;
FOR i: vmD.CharIndex ← at, i + 1 UNTIL i >= atEnd DO
IODefs.WriteChar[vmD.GetMessageChar[vm, i]];
ENDLOOP;
at ← patternEnd;
END
ELSE EXIT;
ENDLOOP;
vmD.FlushDisplayMessage[vm, key];
ENDLOOP;
inD.UpdateTOCThumbLine[tnp, key];
vmD.UnlockTOC[toc, key];
IF ~foundAny THEN IODefs.WriteLine["No matches found."L]
ELSE IODefs.WriteChar[Ascii.CR];
vmD.FreeVirtualMessageObject[vm];
dsD.ChangeCursor[charArrow];
EXITS stop => NULL;
END; -- of ExtractPatternInMailFile --
pendulumState: {left, right} ← right;
swingTime: CARDINAL ← inD.realTimeClock↑;
SwingPendulum: PROCEDURE =
BEGIN
leftPendulum: dsD.CursorBitMap =
[177740B, 147140B, 150540B, 160340B, 162340B, 165340B, 150540B, 147140B,
142140B, 142140B, 144140B, 144140B, 154140B, 154140B, 140140B, 177740B];
rightPendulum: dsD.CursorBitMap =
[177740B, 147140B, 150540B, 160340B, 162340B, 165340B, 150540B, 147140B,
142140B, 142140B, 141140B, 141140B, 141540B, 141540B, 140140B, 177740B];
IF inD.realTimeClock↑ - swingTime < 13 THEN RETURN;
swingTime ← inD.realTimeClock↑;
IF pendulumState = right THEN
BEGIN
pendulumState ← left;
dsD.cursorBM↑ ← leftPendulum;
END
ELSE BEGIN
pendulumState ← right;
dsD.cursorBM↑ ← rightPendulum;
END;
END; -- of SwingPendulum --
LaurelExecDefs.MakeMenuCommandCallable[display];
LaurelExecDefs.MakeMenuCommandCallable[delete];
LaurelExecDefs.MakeMenuCommandCallable[undelete];
LaurelExecDefs.MakeMenuCommandCallable[mailFile];
LaurelExecDefs.MakeMenuCommandCallable[newMail];
LaurelExecDefs.MakeMenuCommandCallable[moveTo];
LaurelExecDefs.MakeMenuCommandCallable[user];
LaurelExecDefs.MakeMenuCommandCallable[copy];
ExtractPatternInMailFile[];
END. -- of Extract --