-- GVPDefs.mesa
-- HGM, May 23, 1984 10:13:49 pm PDT
-- Steve Temple, October 1, 1982 10:16 am
-- Schroeder, March 31, 1983 9:49 am
DIRECTORY
Basics
USING [Byte, bitsPerWord, bytesPerWord],
Buttons
USING [ButtonProc],
IO
USING [
STREAM],
PrincOps
USING [wordsPerPage],
Rope
USING [
ROPE],
ViewerClasses
USING [Viewer],
HeapXDefs
USING [ObjectHeader, PageHeader];
GVPDefs:
CEDAR DEFINITIONS =
BEGIN
ROPE: TYPE = Rope.ROPE;
ButtonProc: TYPE = Buttons.ButtonProc;
Viewer: TYPE = ViewerClasses.Viewer;
Byte: TYPE = Basics.Byte;
maxString: CARDINAL = 64;
lastCard: CARDINAL = LAST[CARDINAL];
bytesPerWord: CARDINAL = Basics.bytesPerWord;
bitsPerWord: CARDINAL = Basics.bitsPerWord;
wordsPerPage: CARDINAL = PrincOps.wordsPerPage;
pageWordSize: CARDINAL = wordsPerPage;
bytesPerPage: CARDINAL = wordsPerPage * bytesPerWord;
pageByteSize: CARDINAL = wordsPerPage * bytesPerWord;
PageByteVec: TYPE = PACKED ARRAY [0..pageByteSize) OF Byte;
PageWordVec: TYPE = ARRAY [0..pageWordSize) OF WORD;
WordSeq: TYPE = RECORD[SEQUENCE length: CARDINAL OF CARDINAL];
PageHeader: TYPE = HeapXDefs.PageHeader;
ObjectHeader: TYPE = HeapXDefs.ObjectHeader;
pageHdrSize: CARDINAL = SIZE[PageHeader];
objHdrSize: CARDINAL = SIZE[ObjectHeader];
pageHdrByteSize: CARDINAL = pageHdrSize * bytesPerWord;
objHdrByteSize: CARDINAL = objHdrSize * bytesPerWord;
ObjHdrPtr: TYPE = REF ObjectHeader;
-- the next 3 lines are a fudge, objects types are really an enumerated type with 16 values
firstObj: CARDINAL = 0; -- types of objects
lastObj: CARDINAL = 15;
objRange: TYPE = [0..15];
-- the next 3 lines may change with the Grapevine system
segSize: CARDINAL = 6; -- number of disk pages in a "segment"
maxObjNumPage: CARDINAL = 256; -- maximum "page" field of an object number
maxObjNumIndex: CARDINAL = 85; -- maximum "index" field of an object number
-- the following is concerned with dealing with the server
Command: TYPE = Byte;
login: Command = 1;
readHeaders: Command = 2;
openFile: Command = 3;
readPage: Command = 4;
writePage: Command = 5;
restartServer: Command = 6;
setLength: Command = 7;
errorCode: Command = 255;
oldFile: Byte = 0;
oldOrNewFile: Byte = 1;
-- definitions of the chars which occur in the file heap.map
MapEntry: TYPE = CHAR;
emptyPage: MapEntry = '.;
fullPage: MapEntry = 'f;
alteredPage: MapEntry = 'a;
-- useful numbers when we are building the viewers (numbers are pixel widths/heights)
rowHeight: CARDINAL = 15;
rowSpace: CARDINAL = 8;
rowSize: CARDINAL = rowSpace + rowHeight;
char: CARDINAL = 6;
buttonSize: CARDINAL = 12*char;
buttonSpace: CARDINAL = 15*char;
row1: CARDINAL = rowSpace;
row2: CARDINAL = row1 + rowSize;
row3: CARDINAL = row2 + rowSize;
row4: CARDINAL = row3 + rowSize;
row5: CARDINAL = row4 + rowSize;
row6: CARDINAL = row5 + rowSize;
col1: CARDINAL = 3*char;
col2: CARDINAL = col1 + buttonSpace;
col3: CARDINAL = col2 + buttonSpace;
col4: CARDINAL = col3 + buttonSpace;
col5: CARDINAL = col4 + buttonSpace;
col6: CARDINAL = col5 + buttonSpace;
offScreen: CARDINAL = 5000;
-- The monitor lock and the data record for GVPatch. The record has streams for each
-- typescript and the current position and current viewer. It also has a stream onto the heap.
GVPRec: TYPE = RECORD [editorStream: IO.STREAM ← NIL,
browserStream: IO.STREAM ← NIL,
logStream: IO.STREAM ← NIL,
heapStream: IO.STREAM ← NIL,
pPage: CARDINAL 𡤀,
lPage: CARDINAL ← 0,
root: Viewer ← NIL,
currentText: Viewer ← NIL,
currentButtons: Viewer ← NIL];
GVPRef: TYPE = REF GVPRec;
lock: MONITORLOCK;
-- Procedure definitions now follow, comments on each procedure are in the source
-- code for the given module
-- ====== PROCs from GVPDriver
GetHeapFile: PROC [h: GVPRef] RETURNS [r: ROPE ← NIL];
ReadPage: PROC[h: GVPRef, page: CARDINAL, pageBuffer: REF PageByteVec]
RETURNS[r: ROPE ← NIL];
WritePage: PROC[h: GVPRef, page: CARDINAL, pageBuffer: REF PageByteVec]
RETURNS[r: ROPE ← NIL];
ReadServerPage: PROC[h: GVPRef, page: CARDINAL, pageBuffer: REF PageByteVec]
RETURNS [r: ROPE ← NIL];
WriteServerPage: PROC[h: GVPRef, page: CARDINAL, pageBuffer: REF PageByteVec]
RETURNS [r: ROPE ← NIL];
ReadFile: PROC [h: GVPRef, name: ROPE] RETURNS [r: ROPE ← NIL];
WriteFile: PROC [h: GVPRef, name: ROPE] RETURNS [r: ROPE ← NIL];
RestartServer: PROC [h: GVPRef, line: ROPE] RETURNS [r: ROPE ← NIL];
SetServerLength: PROC[h: GVPRef, name: ROPE, pages, bytes: CARDINAL]
RETURNS[r: ROPE ← NIL];
SetLocalLength: PROC[h: GVPRef, name: ROPE, pages, bytes: CARDINAL]
RETURNS[r: ROPE ← NIL];
DriverInit: PROC;
DriverTidyUp: PROC;
-- ====== PROCs from GVPBrowser
MakeBrowserButtons: PROC[h: GVPRef];
BrowserButton: ButtonProc;
StopRequested: PROC RETURNS[stop: BOOLEAN];
ObjectRope: PROC[index: CARDINAL, brief: BOOLEAN] RETURNS[r: ROPE ← NIL];
BrowserInit: PROC;
BrowserTidyUp: PROC;
-- ====== PROCs from GVPProcs
SetLogical: PROC[h: GVPRef, n: CARDINAL] RETURNS[ok: BOOLEAN ← FALSE];
SetPhysical: PROC[h: GVPRef, n: CARDINAL] RETURNS[ok: BOOLEAN ← FALSE];
NextPage: PROC[h: GVPRef] RETURNS[ok: BOOLEAN ← FALSE];
PrevPage: PROC[h: GVPRef] RETURNS[ok: BOOLEAN ← FALSE];
PositionRope: PROC[h: GVPRef] RETURNS[r: ROPE];
ScanHeap: PROC[h: GVPRef, onlyError: BOOLEAN] RETURNS[r: ROPE ← NIL];
CheckStructure: PROC[h: GVPRef] RETURNS[r: ROPE ← NIL];
GetPageState: PROC[page: CARDINAL] RETURNS [state: MapEntry];
SetPageState: PROC[page: CARDINAL, state: MapEntry];
ReadHeapPage: PROC[h: GVPRef, page: CARDINAL, pageBuffer: REF PageByteVec]
RETURNS[r: ROPE ← NIL];
WriteLocalPage: PROC[h: GVPRef, page: CARDINAL, pageBuffer: REF PageByteVec]
RETURNS [r: ROPE ← NIL];
WriteHeap: PROC [h: GVPRef] RETURNS[r: ROPE ← NIL];
ProcsInit: PROC;
ProcsTidyUp: PROC;
-- ====== PROCs from GVPMain
Set: PROC[r: ROPE ← NIL];
Flash: PROC[r: ROPE];
GetHandle: PROC RETURNS[handle: GVPRef];
Failed: PROC[r: ROPE] RETURNS[failed: BOOLEAN];
ToFocus: PROC;
NumFromRope: PROC[octal: BOOLEAN, r: ROPE, start: CARDINAL]
RETURNS [num, end: CARDINAL];
GetServerName: PROC RETURNS[r: ROPE];
GetSearchPattern: PROC RETURNS[page, index, type: CARDINAL];
ServerButton: ButtonProc;
-- ====== PROCs from GVPEditor
MakeEditorButtons: PROC[h: GVPRef];
EditorButton: ButtonProc;
GetEditBuffer: PROC RETURNS[buffer: REF WordSeq ← NIL];
PutEditBuffer: PROC[buffer: REF WordSeq, r: ROPE];
EditorInit: PROC;
EditorTidyUp: PROC;
END.