-- file: IntRefreshers.mesa
-- edited by Brotz, January 15, 1981 5:12 PM
-- edited by Schroeder, August 1, 1978 11:43 AM
-- edited by Levin, February 7, 1980 5:44 PM

DIRECTORY
displayCommon: FROM "DisplayCommon",
dsD: FROM "DisplayDefs",
inD: FROM "InteractorDefs",
InlineDefs: FROM "InlineDefs",
intCommon: FROM "IntCommon",
tsD: FROM "TOCSelectionDefs",
ovD: FROM "OverviewDefs",
vmD: FROM "VirtualMgrDefs";

IntRefreshers: PROGRAM
IMPORTS disC: displayCommon, dsD, inD, InlineDefs, intC: intCommon, tsD
EXPORTS inD
SHARES inD = PUBLIC

BEGIN

OPEN inD;

-- 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.


TextHouseRefresher: PROCEDURE [hp: HousePtr] =
-- Repaints one simple text house on the display screen, according to the parameters
-- contained in hp↑.
BEGIN
IF NOT disC.bitMapReady THEN RETURN;
dsD.ClearRectangle[hp.leftX, hp.rightX, hp.topY, hp.bottomY];
IF hp.usePicture THEN dsD.PaintPicture[hp.leftX, hp.topY, hp.picture, dsD.paint]
ELSE BEGIN
SELECT hp.fixedEdge FROM
left => hp.rightX ← hp.leftX + dsD.GetStringWidth[hp.text, hp.typeface];
right => hp.leftX ← hp.rightX - dsD.GetStringWidth[hp.text, hp.typeface];
ENDCASE;
[] ← dsD.PutStringInBitMap[hp.leftX, hp.topY, hp.text, hp.typeface];
END;
END; -- of TextHouseRefresher --


BracketsHouseRefresher: PROCEDURE [hp: HousePtr] =
-- Repaints one brackets command house on the display screen.
BEGIN
OPEN dsD;
curX, limX, x: ScreenXCoord;
i: CARDINAL;

ClearRectangle[hp.leftX, hp.rightX, hp.topY, hp.bottomY];
curX ← PutCharInBitMap[’{, hp.leftX, hp.topY, boldFace];
limX ← (IF hp.nextHouse = NIL OR hp.nextHouse.lineNumber # hp.lineNumber
THEN inD.rightMargin ELSE hp.nextHouse.leftX) -
GetStringWidth[" } "L, boldFace];-- space before bracket is for caret
IF GetStringWidth[hp.text, plainFace]+curX <= limX THEN
curX ← PutStringInBitMap[curX, hp.topY, hp.text, hp.typeface]
ELSE
BEGIN
FOR i IN [0..5] DO
curX ← PutCharInBitMap[hp.text[i], curX, hp.topY, plainFace];
ENDLOOP;
curX ← x ← PutStringInBitMap[curX, hp.topY, "..."L, plainFace];
FOR i ← hp.text.length-1, i-1 DO
IF (x ← GetCharRightX[hp.text[i], x]) > limX THEN EXIT;
ENDLOOP;
FOR i IN [i + 1 .. hp.text.length - 1] DO
curX ← PutCharInBitMap[hp.text[i], curX, hp.topY, plainFace];
ENDLOOP;
END;
hp.rightX ← PutCharInBitMap[’}, curX, hp.topY, boldFace];
END; -- of BracketsHouseRefresher --


FreePagesHouseRefresher: PROCEDURE [count: CARDINAL] =
-- Repaints the free pages house with count on the display screen.
BEGIN
text: STRING ← intC.freePagesHouse.text;
remainder, i, j: CARDINAL;
FOR i DECREASING IN [0 .. 5) DO
[count, remainder] ← InlineDefs.DIVMOD[count, 10];
text[i] ← ’0 + remainder;
IF count = 0 THEN
BEGIN
FOR j IN [0 .. i) DO text[j] ← ’ ; ENDLOOP;
EXIT;
END;
ENDLOOP;
TextHouseRefresher[intC.freePagesHouse];
END; -- of FreePagesHouseRefresher --


NullHouseRefresher: PROCEDURE [hp: HousePtr] =
-- Place-holder.
BEGIN
END; -- of NullHouseRefresher --


TOCTextPainter: PROCEDURE [tnp: TOCTextNbrPtr] =
-- Paints the TOC text neighborhood starting with the first selected entry.
BEGIN
endLineNumber: CARDINAL;
line: LinePtr;
index: vmD.TOCIndex;
IF ~intC.haveMailFile THEN RETURN;
intC.TOCRegion.dcb.width ← 0;
index ← tsD.FirstSelectedEntry[];
IF index = 0 THEN index ← 1;
DisplayTOCTail[tnp, tnp.lines, index, 1];
IF tnp.nLines > 0 AND tnp.firstLineOffScreen.state = empty THEN
BEGIN -- scroll End of messages down to bottom line on screen.
endLineNumber ← 1;
FOR line ← tnp.lines, line.nextLine UNTIL line.state = end DO
endLineNumber ← endLineNumber + 1;
ENDLOOP;
ScrollDownTOC[tnp.lines.y + (tnp.nLines - endLineNumber) * dsD.lineHeight, tnp];
END;
intC.TOCRegion.dcb.width ← dsD.bmWidth;
UpdateTOCThumbLine[];
END; -- of TOCTextPainter --


END. -- of IntRefreshers --