IPOperatorOutImpl.mesa
Last edited by Andy Shore; January 30, 1983 5:18 pm
Last edited by Doug Wyatt; March 2, 1983 11:02 am
DIRECTORY
IPOperatorOut,
IPEncodingOut,
IPVariables USING [FrameVariable, ImagerVariable, StrokeEnd],
Rope USING [ROPE, Find, IsEmpty, Length, MaxLen];
IPOperatorOutImpl: CEDAR PROGRAM
IMPORTS IPOperatorOut, IPEncodingOut, Rope
EXPORTS IPOperatorOut = BEGIN OPEN IPOperatorOut;
Master Creation
BeginMaster: PUBLIC PROCEDURE [name: Rope.ROPE] RETURNS [ip: Handle] = {
ip ← Handle[IPEncodingOut.OpenOutputMaster[name !
IPEncodingOut.Error => Error[FileNotAvailable]]];
ip.AppendOp[beginBlock];
};
EndMaster: PUBLIC PROCEDURE [ip: Handle] = {
ip.AppendOp[endBlock];
ip.CloseMaster[];
};
Vectors (2.4.3)
Get: PUBLIC PROCEDURE [ip: Handle, n: INT] = {
ip.AppendInteger[n];
ip.AppendOp[get];
};
MakeVec: PUBLIC PROCEDURE [ip: Handle, n: INT] = {
ip.AppendInteger[n];
ip.AppendOp[makevec];
};
MakeVecLU: PUBLIC PROCEDURE [ip: Handle, l, u : INT] = {
ip.AppendInteger[l];
ip.AppendInteger[u];
ip.AppendOp[makeveclu];
};
Frames (2.4.4)
FGet: PUBLIC PROCEDURE [ip: Handle, n: IPVariables.FrameVariable] = {
ip.AppendInteger[n];
ip.AppendOp[fget];
};
FSet: PUBLIC PROCEDURE [ip: Handle, x: Number, n: IPVariables.FrameVariable] = {
ip.AppendNumber[x];
ip.AppendInteger[n];
ip.AppendOp[fset];
};
Body Operators (2.4.5, 2.4.7, 4.10)
BeginMakeSimpleCO: PUBLIC PROCEDURE [ip: Handle] = {
ip.AppendOp[makesimpleco];
ip.BeginBody[];
};
BeginDoSaveSimpleBody: PUBLIC PROCEDURE [ip: Handle] = {
ip.AppendOp[dosavesimplebody];
ip.BeginBody[];
};
BeginCorrect: PUBLIC PROCEDURE [ip: Handle] = {
ip.AppendOp[correct];
ip.BeginBody[];
};
BeginIf: PUBLIC PROCEDURE [ip: Handle] = {
ip.AppendOp[if];
ip.BeginBody[];
};
BeginIfElse: PUBLIC PROCEDURE [ip: Handle] = {
ip.AppendOp[ifelse];
ip.BeginBody[];
};
BeginIfCopy: PUBLIC PROCEDURE [ip: Handle] = {
ip.AppendOp[ifcopy];
ip.BeginBody[];
};
EndMakeSimpleCO, EndDoSaveSimpleBody, EndCorrect, EndIf, EndIfElse, EndIfCopy: PUBLIC PROCEDURE [ip: Handle] = {ip.EndBody[];};
Imager State (4.2)
IGet: PUBLIC PROCEDURE [ip: Handle, n: IPVariables.ImagerVariable] = {
ip.AppendInteger[LOOPHOLE[n, CARDINAL]];
ip.AppendOp[iget];
};
ISet: PUBLIC PROCEDURE [ip: Handle, x: Number, n: IPVariables.ImagerVariable] = {
ip.AppendNumber[x];
ip.AppendInteger[LOOPHOLE[n, CARDINAL]];
ip.AppendOp[iset];
};
SetStrokeWidth: PUBLIC PROCEDURE [ip: Handle, width: Number] = {
ip.ISet[LOOPHOLE[width], IPVariables.ImagerVariable[strokeWidth]];
};
SetStrokeEnd: PUBLIC PROCEDURE [ip: Handle, end: IPVariables.StrokeEnd] = {
ip.ISet[Number[integer[LOOPHOLE[end, CARDINAL]]], IPVariables.ImagerVariable[strokeEnd]];
};
SetAmplifySpace: PUBLIC PROCEDURE [ip: Handle, amplify: Number] = {
ip.ISet[amplify, IPVariables.ImagerVariable[amplifySpace]];
};
SetPriorityImportant: PUBLIC PROCEDURE [ip: Handle, on: BOOLEANFALSE] = {
ip.ISet[Number[integer[IF on THEN 1 ELSE 0]], IPVariables.ImagerVariable[priorityImportant]];
};
Transformations (4.4)
Translate: PUBLIC PROCEDURE [ip: Handle, x, y: Number, concatT: BOOLEANTRUE] = {
ip.AppendNumber[x];
ip.AppendNumber[y];
ip.AppendOp[translate];
IF concatT THEN ip.AppendOp[concatt];
};
Rotate: PUBLIC PROCEDURE [ip: Handle, alpha: Number, concatT: BOOLEANTRUE] = {
ip.AppendNumber[alpha];
ip.AppendOp[rotate];
IF concatT THEN ip.AppendOp[concatt];
};
Scale: PUBLIC PROCEDURE [ip: Handle, s: Number, concatT: BOOLEANTRUE] = {
ip.AppendNumber[s];
ip.AppendOp[scale];
IF concatT THEN ip.AppendOp[concatt];
};
Scale2: PUBLIC PROCEDURE [ip: Handle, sx, sy: Number, concatT: BOOLEANTRUE] = {
ip.AppendNumber[sx];
ip.AppendNumber[sy];
ip.AppendOp[scale2];
IF concatT THEN ip.AppendOp[concatt];
};
Show: PUBLIC PROCEDURE [ip: Handle, text: Rope.ROPENIL, start: INT ← 0, len: INT ← Rope.MaxLen] = {
IF (text # NIL) AND NOT Rope.IsEmpty[text] THEN {
ip.AppendRope[text, start, len];
ip.AppendOp[show];
};
};
Current Position (4.5)
SetXY: PUBLIC PROCEDURE [ip: Handle, x, y: Number] = {
ip.AppendNumber[x];
ip.AppendNumber[y];
ip.AppendOp[setxy];
};
SetXYRel: PUBLIC PROCEDURE [ip: Handle, x, y: Number] = {
xFound, yFound: BOOLFALSE;
IF NOT NumberIsZero[x] THEN {
ip.AppendNumber[x];
xFound ← TRUE;
};
IF NOT NumberIsZero[y] THEN {
ip.AppendNumber[y];
yFound ← TRUE;
};
IF xFound AND yFound THEN ip.AppendOp[setxyrel]
ELSE IF xFound THEN ip.AppendOp[setxrel]
ELSE IF yFound THEN ip.AppendOp[setyrel];
};
SetXRel: PUBLIC PROCEDURE [ip: Handle, x: Number] = {
ip.AppendNumber[x];
ip.AppendOp[setxrel];
};
SetYRel: PUBLIC PROCEDURE [ip: Handle, y: Number] = {
ip.AppendNumber[y];
ip.AppendOp[setyrel];
};
PushCP: PUBLIC PROCEDURE [ip: Handle] = {
ip.IGet[IPVariables.ImagerVariable[DCScpx]];
ip.IGet[IPVariables.ImagerVariable[DCScpy]];
};
PopCP: PUBLIC PROCEDURE [ip: Handle] = {
ip.AppendInteger[LOOPHOLE[IPVariables.ImagerVariable[DCScpy], CARDINAL]];
ip.AppendOp[iset];
ip.AppendInteger[LOOPHOLE[IPVariables.ImagerVariable[DCScpx], CARDINAL]];
ip.AppendOp[iset];
};
Color (4.7)
SetGray: PUBLIC PROCEDURE [ip: Handle, f: Number] = {
ip.AppendNumber[f];
ip.AppendOp[setgray];
};
Masks (4.8)
MoveTo: PUBLIC PROCEDURE [ip: Handle, x, y: Number] = {
ip.AppendNumber[x];
ip.AppendNumber[y];
ip.AppendOp[moveto];
};
LineTo: PUBLIC PROCEDURE [ip: Handle, x, y: Number] = {
ip.AppendNumber[x];
ip.AppendNumber[y];
ip.AppendOp[lineto];
};
LineToX: PUBLIC PROCEDURE [ip: Handle, x: Number] = {
ip.AppendNumber[x];
ip.AppendOp[linetox];
};
LineToY: PUBLIC PROCEDURE [ip: Handle, y: Number] = {
ip.AppendNumber[y];
ip.AppendOp[linetoy];
};
MaskRectangle: PUBLIC PROCEDURE [ip: Handle, x, y, w, h: Number] = {
ip.AppendNumber[x];
ip.AppendNumber[y];
ip.AppendNumber[w];
ip.AppendNumber[h];
ip.AppendOp[maskrectangle];
};
MaskUnderline: PUBLIC PROCEDURE [ip: Handle, dy, h: Number] = {
ip.AppendNumber[dy];
ip.AppendNumber[h];
ip.AppendOp[maskunderline];
};
MaskVector: PUBLIC PROCEDURE [ip: Handle, x1, y1, x2, y2: Number] = {
ip.MoveTo[x1, y1];
IF NumbersAreEqual[x1, x2] THEN ip.LineToY[y2]
ELSE IF NumbersAreEqual[y1, y2] THEN ip.LineToX[x2]
ELSE ip.LineTo[x2, y2];
ip.AppendOp[maskstroke];
};
Characters (4.9)
SetFont: PUBLIC PROCEDURE [ip: Handle, font: IPVariables.FrameVariable] = {
ip.AppendInteger[font];
ip.AppendOp[setfont];
};
Corrected Masks (4.10)
CorrectSpace: PUBLIC PROCEDURE [ip: Handle, x, y: Number] = {
ip.AppendNumber[x];
ip.AppendNumber[y];
ip.AppendOp[correctspace];
};
SetCorrectMeasure: PUBLIC PROCEDURE [ip: Handle, x, y: Number] = {
ip.AppendNumber[x];
ip.AppendNumber[y];
ip.AppendOp[setcorrectmeasure];
};
SetCorrectTolerance: PUBLIC PROCEDURE [ip: Handle, x, y: Number] = {
ip.AppendNumber[x];
ip.AppendNumber[y];
ip.AppendOp[setcorrecttolerance];
};
Space: PUBLIC PROCEDURE [ip: Handle, x: Number] = {
ip.AppendNumber[x];
ip.AppendOp[space];
};
PushAndDisableCorrection: PUBLIC PROCEDURE [ip: Handle] = {
ip.IGet[IPVariables.ImagerVariable[correctPass]];
ip.ISet[int[0], IPVariables.ImagerVariable[correctPass]];
};
PopAndRestoreCorrection: PUBLIC PROCEDURE [ip: Handle] = {
ip.AppendInteger[LOOPHOLE[IPVariables.ImagerVariable[correctPass], CARDINAL]];
ip.AppendOp[iset];
};
Other Nice Functions
SetUpFont: PUBLIC PROCEDURE [ip: Handle, fontNumber: IPVariables.FrameVariable, name: Rope.ROPE, scale: Number, rotation: Number ← int[0], putInFrame: BOOLEANTRUE] = {
ip.AppendHierarchicalName[name];
ip.AppendOp[findfont];
ip.Scale[s: scale, concatT: FALSE];
IF NOT NumberIsZero[rotation] THEN {
ip.Rotate[alpha: rotation, concatT: FALSE];
ip.AppendOp[concat];
};
ip.AppendOp[modifyfont];
IF putInFrame THEN {
ip.AppendInteger[fontNumber];
ip.AppendOp[fset];
};
};
AppendHierarchicalName: PUBLIC PROCEDURE [ip: Handle, name: Rope.ROPE, start: INT ← 0, len: INT ← Rope.MaxLen] = {
first: INT ← start;
pos: INT;
length: INTMIN[len, Rope.Length[name]-start];
identifierCount: INT ← 1;
break down heirarchical name into a MAKEVEC of identifiers
WHILE (pos ← name.Find[s2: "/", pos1: first, case: FALSE]) # -1 DO
ip.AppendIdentifier[id: name, start: first, len: pos-first];
identifierCount ← identifierCount+1;
first ← pos+1;
ENDLOOP;
ip.AppendIdentifier[id: name, start: first, len: length-first];
ip.MakeVec[identifierCount];
};
NumberIsZero: PUBLIC PROCEDURE [n: Number] RETURNS [BOOLEAN] = {
WITH n SELECT FROM
integer => RETURN [value = 0];
rational => IF j = 0 THEN ERROR ELSE RETURN [i = 0];
real => RETURN [value = 0.0];
ENDCASE => ERROR;
};
NumbersAreEqual: PROCEDURE [n1, n2: Number] RETURNS [BOOLEAN] = {
WITH na: n1 SELECT FROM
integer => WITH nb: n2 SELECT FROM
integer => RETURN [na = nb];
rational => RETURN [REAL[na.value] = REAL[nb.i]/REAL[nb.j]];
real => RETURN [REAL[na.value] = nb.value];
ENDCASE => ERROR;
rational => WITH nb: n2 SELECT FROM
integer => RETURN [REAL[nb.value] = REAL[na.i]/REAL[na.j]];
rational => RETURN [na = nb];
real => RETURN [nb.value = REAL[na.i]/REAL[na.j]];
ENDCASE => ERROR;
real => WITH nb: n2 SELECT FROM
integer => RETURN [REAL[nb.value] = na.value];
rational => RETURN [na.value = REAL[nb.i]/REAL[nb.j]];
real => RETURN [na = nb];
ENDCASE => ERROR;
ENDCASE => ERROR;
};
Full Interpress Extensions
CurveTo: PUBLIC PROCEDURE [ip: Handle, x1, y1, x2, y2, x3, y3: Number] = {
ip.AppendNumber[x1];
ip.AppendNumber[y1];
ip.AppendNumber[x2];
ip.AppendNumber[y2];
ip.AppendNumber[x3];
ip.AppendNumber[y3];
ip.AppendOp[curveto];
};
Error: PUBLIC ERROR [errorCode: ErrorCode] = CODE;
END.
Change Log
Created by Shore; August 24, 1982 10:30 am
Changed by Shore; September 16, 1982 2:05 pm
moved some procs to IPOperatorOut as INLINEs
Changed by Shore; September 24, 1982 3:44 pm
made changes suggested by Sproull
Changed by Shore; November 11, 1982 2:47 pm
change to Cedar.Style and added node styles
Changed by Shore; January 19, 1983 4:16 pm
changed to CEDAR, Interpress 2.0, and new node styles
Changed by Shore; January 30, 1983 1:18 pm
fixed SHOW of empty string
Changed by Wyatt; March 2, 1983 11:02 am
added CurveTo