BlackBerryImpl.mesa
Copyright Ó 1988, 1992 by Xerox Corporation. All rights reserved.
created by Eduardo Pelegri-Llopart January 7, 1988 8:56:07 am PST
Doug Terry, July 27, 1990 7:01 am PDT
Willie-s, April 27, 1992 11:36 am PDT
DIRECTORY
Atom USING [GetPName],
BlackBerry,
LoganBerry USING [Entry],
LoganBerryBrowser USING [Tool],
MessageWindow USING [Append, Blink],
Rope USING [Concat, ROPE, Length, Fetch],
TiogaAccess USING [TiogaChar, Create, Put, Writer, Looks],
TiogaAccessViewers USING [WriteViewer],
TypeScript USING [ChangeLooks, PutRope, PutChar],
ViewerTools USING [ MakeNewTextViewer],
ViewerClasses USING [Viewer, ViewerRec];
BlackBerryImpl:
CEDAR
PROGRAM
IMPORTS
MessageWindow, TypeScript, Atom, Rope, ViewerTools, TiogaAccess, TiogaAccessViewers
EXPORTS BlackBerry
~ {
RopeIntoWriterWithLooks:
PROC [writer: TiogaAccess.Writer, rope: Rope.ROPE, looks: TiogaAccess.Looks]
RETURNS [] ~ {
Place each of the characters of the rope into the writer
FOR i: INT IN [0..rope.Length)
DO
c: TiogaAccess.TiogaChar ~ [
charSet: 0,
char: rope.Fetch[i],
looks: looks,
format: NIL,
comment: TRUE,
endOfNode: FALSE,
deltaLevel: 0,
propList: NIL
];
writer.Put[c];
ENDLOOP;
};
BlankLooks: TiogaAccess.Looks ¬ ALL[FALSE];
NewLine: TiogaAccess.TiogaChar ~ [
charSet: 0,
char: '\n,
looks: BlankLooks,
format: NIL,
comment: FALSE,
endOfNode: TRUE,
deltaLevel: 0,
propList: NIL
];
LookIntoLooks:
PROC [look:
CHAR]
RETURNS [looks: TiogaAccess.Looks] ~ {
looks ¬ BlankLooks;
IF look = ' THEN RETURN [looks: looks];
looks[look] ¬ TRUE;
};
firstTime: BOOL ¬ TRUE; -- is this the first time we are being called?
queryName: Rope.ROPE; -- the name of this query
count: INT ¬ 0; -- how many entries have we created.
outWriter: TiogaAccess.Writer; -- the writer to be used while collecting the data.
outViewer: ViewerClasses.Viewer; -- the viewer I'll use for playing.
info: ViewerClasses.ViewerRec; -- information used in the viewer.
CountLimit: INT ¬ 4; -- Why not 4?
SetCountLimit:
PUBLIC
PROC [limit:
INT] ~ {
IF limit < 1 THEN limit ¬ LAST[INT];
CountLimit ¬ limit;
};
PrintEntry:
PUBLIC PROC [entry: LoganBerry.Entry, tool: LoganBerryBrowser.Tool] ~ {
Use a writer to put the info. Eventually we will write it into a file or a viewer.
PutEntryIntoTypescript:
PROC [entry: LoganBerry.Entry, tool: LoganBerryBrowser.Tool]
RETURNS [] ~ {
FOR e: LoganBerry.Entry ¬ entry, e.rest
UNTIL e =
NIL
DO
IF e.first.type#
NIL
THEN {
TypeScript.ChangeLooks[tool.inner, 'b]; -- print atribute type in bold
TypeScript.PutRope[tool.inner, Atom.GetPName[e.first.type]];
TypeScript.ChangeLooks[tool.inner, ' ]; -- restore normal looks
TypeScript.PutRope[tool.inner, ": "];
};
TypeScript.PutRope[tool.inner, Rope.Concat[e.first.value, "\n"]];
ENDLOOP;
TypeScript.PutChar[tool.inner, '\n];
};
IF tool.innerFlavor#$TypeScript
THEN {
MessageWindow.Append[message: "Wrong flavor of browser's output viewer", clearFirst: TRUE];
MessageWindow.Blink[];
RETURN;
};
IF firstTime
THEN {
outWriter ¬ TiogaAccess.Create[];
count ¬ 0;
firstTime ¬ FALSE;
};
IF entry#
NIL
THEN {
IF (entry.first.type=
NIL)
THEN {
IF count >=
CountLimit
THEN{
TiogaAccessViewers.WriteViewer[outWriter, outViewer];
TypeScript.PutRope[tool.inner, " completed\n"];
};
firstTime ¬ TRUE;
count ¬ 0;
TypeScript.PutRope[tool.inner, Rope.Concat[entry.first.value, "\n"]];
RETURN
};
IF (entry.first.type=$ERROR)
THEN {
PutEntryIntoTypescript[entry, tool];
RETURN
}
};
count ¬ count + 1;
SELECT count
FROM
< CountLimit => PutEntryIntoTypescript[entry, tool];
=
CountLimit => {
queryName ¬ "LB Query";
info.name ¬ queryName;
outViewer ¬ ViewerTools.MakeNewTextViewer[info: info, paint: TRUE];
TypeScript.PutRope[tool.inner, "\nDiverting Output to Viewer "];
TypeScript.PutRope[tool.inner, queryName];
TypeScript.PutChar[tool.inner, ' ];
THROUGH [0..CountLimit)
DO
TypeScript.PutChar[tool.inner, '.];
ENDLOOP;
};
>
CountLimit => {
TypeScript.PutChar[tool.inner, '.];
};
ENDCASE;
FOR e: LoganBerry.Entry ¬ entry, e.rest
UNTIL e =
NIL
DO
IF e.first.type#
NIL
THEN {
RopeIntoWriterWithLooks[outWriter, Atom.GetPName[e.first.type], LookIntoLooks['b]];
RopeIntoWriterWithLooks[outWriter, ": ", BlankLooks];
};
RopeIntoWriterWithLooks[outWriter, e.first.value, BlankLooks];
outWriter.Put[NewLine];
ENDLOOP;
outWriter.Put[NewLine];
};
}.