<> <> <> <> <> <> <> <> DIRECTORY Buttons USING [Button, Create, ReLabel, SetDisplayStyle], Containers USING [ChildXBound, ChildYBound, Container, Create], GVPDefs, IO USING [PutF, PutText, SetIndex, STREAM, UnsafeGetBlock], ObjectDirDefs USING [ObjectNumber], Rope USING [Concat, Equal, Fetch, Length, Substr], ViewerIO USING [CreateViewerStreams], ViewerOps USING [CreateViewer, MoveViewer, PaintViewer], ViewerTools USING [GetContents, MakeNewTextViewer, SetSelection, SetContents]; GVPBrowser: CEDAR MONITOR LOCKS lock IMPORTS Buttons, Containers, GVPDefs, IO, Rope, ViewerIO, ViewerOps, ViewerTools EXPORTS GVPDefs SHARES ObjectDirDefs = BEGIN OPEN GVPDefs; <> <> <> browserButtons, browserText, setInput, repeatInput, patternInput: Viewer; repeatPending, stopScan, stoppable, autoShow: BOOLEAN _ FALSE; showFull: BOOLEAN _ TRUE; pageBuffer: REF PageWordVec _ NIL; objects: ARRAY objRange OF ROPE = -- used for printing and lookup ["Gap ", "Body ", "SLinp ", "SLpend", "SLfwd ", "RSobj ", "RSmail", "temp ", "RSname", "MSname", "test-M", "TOC ", "Arch ", "s15 ", "s16 ", "s17 " ]; <> <> <> MakeBrowserButtons: PUBLIC PROC[h: GVPRef] = BEGIN browserText _ ViewerOps.CreateViewer[flavor: $Typescript, info: [parent: h.root, border: TRUE, iconic: FALSE, wy: offScreen]]; h.browserStream _ ViewerIO.CreateViewerStreams[viewer: browserText, name: NIL].out; browserButtons _ Containers.Create[[name: NIL, parent: h.root, wx: 0, wy: offScreen, wh: 4*rowSize, border: FALSE, scrollable: FALSE]]; setInput _ ViewerTools.MakeNewTextViewer[[parent: browserButtons, wx: col6, wy: row1+2, ww: 30*char, wh: rowHeight, scrollable: FALSE, border: FALSE, data: "0"]]; patternInput _ ViewerTools.MakeNewTextViewer[[parent: browserButtons, wx: col6, wy: row3+2, ww: 30*char, wh: rowHeight, scrollable: FALSE, border: FALSE, data: "/ / /"]]; repeatInput _ ViewerTools.MakeNewTextViewer[[parent: browserButtons, wx: col6, wy: row2+2, ww: 30*char, wh: rowHeight, scrollable: FALSE, border: FALSE, data: "1"]]; [] _ Buttons.Create[info: [name: "SERVER", wx: col1, wy: row1, wh: rowSize+rowHeight, ww: buttonSize, parent: browserButtons], clientData: h, proc: ServerButton]; [] _ Buttons.Create[info: [name: "EDITOR", wx: col1, wy: row3, wh: rowSize+rowHeight, ww: buttonSize, parent: browserButtons], clientData: h, proc: EditorButton]; [] _ Buttons.Create[info: [name: "position #", wx: col3, wy: row1, wh: rowHeight, ww: buttonSize, parent: browserButtons], clientData: h, proc: SetLogicalButton]; [] _ Buttons.Create[info: [name: "page #", wx: col2, wy: row1, wh: rowHeight, ww: buttonSize, parent: browserButtons], clientData: h, proc: SetPhysicalButton]; [] _ Buttons.Create[info: [name: "number >", wx: col5, wy: row1, wh: rowHeight, ww: buttonSize, parent: browserButtons], clientData: h, proc: ValueButton]; [] _ Buttons.Create[info: [name: "FULL", wx: col2, wy: row2, wh: rowHeight, ww: buttonSize, parent: browserButtons], clientData: h, proc: ShowModeButton]; [] _ Buttons.Create[info: [name: "REPEAT", wx: col3, wy: row2, wh: rowHeight, ww: buttonSize, parent: browserButtons], clientData: h, proc: RepeatButton]; [] _ Buttons.Create[info: [name: "AUTO", wx: col4, wy: row2, wh: rowHeight, ww: buttonSize, parent: browserButtons], clientData: h, proc: AutoShowButton]; [] _ Buttons.Create[info: [name: "next", wx: col2, wy: row3, wh: rowHeight, ww: buttonSize, parent: browserButtons], clientData: h, proc: NextButton]; [] _ Buttons.Create[info: [name: "prev", wx: col3, wy: row3, wh: rowHeight, ww: buttonSize, parent: browserButtons], clientData: h, proc: PrevButton]; [] _ Buttons.Create[info: [name: "pattern >", wx: col5, wy: row3, wh: rowHeight, ww: buttonSize, parent: browserButtons], clientData: h, proc: PatternButton]; [] _ Buttons.Create[info: [name: "scan error", wx: col2, wy: row4, wh: rowHeight, ww: buttonSize, parent: browserButtons], clientData: h, proc: ScanErrorButton]; [] _ Buttons.Create[info: [name: "scan match", wx: col3, wy: row4, wh: rowHeight, ww: buttonSize, parent: browserButtons], clientData: h, proc: ScanMatchButton]; [] _ Buttons.Create[info: [name: " ! STOP !", wx: col4, wy: row4, wh: rowHeight, ww: buttonSize, parent: browserButtons], clientData: h, proc: StopButton]; [] _ Buttons.Create[info: [name: "show", wx: col4, wy: row3, wh: rowHeight, ww: buttonSize, parent: browserButtons], clientData: h, proc: ShowButton]; [] _ Buttons.Create[info: [name: "repeat >", wx: col5, wy: row2, wh: rowHeight, ww: buttonSize, parent: browserButtons], clientData: h, proc: RptCountButton]; [] _ Buttons.Create[info: [name: "reset", wx: col4, wy: row1, wh: rowHeight, ww: buttonSize, parent: browserButtons], clientData: h, proc: ResetButton] END; <> <> <> <> BrowserButton: PUBLIC ENTRY ButtonProc = TRUSTED BEGIN h: GVPRef = NARROW[clientData]; r: ROPE = CheckStructure[h]; IF r#NIL THEN {Flash[r]; RETURN}; ToFocus[]; ViewerOps.MoveViewer[viewer: h.currentButtons, x:0, y: offScreen, w: 0, h: 0, paint: FALSE]; ViewerOps.MoveViewer[viewer: browserButtons, x:0, y: 0, w: 0, h: 4*rowSize, paint: FALSE]; ViewerOps.MoveViewer[viewer: h.currentText, x:0, y: offScreen, w: 0, h: 0, paint: FALSE]; ViewerOps.MoveViewer[viewer: browserText, x:0, y: row6, w: 0, h: 0, paint: FALSE]; Containers.ChildXBound[h.root, browserText]; Containers.ChildXBound[h.root, browserButtons]; Containers.ChildYBound[h.root, browserText]; ViewerOps.PaintViewer[h.root, all]; h.currentButtons _ browserButtons; h.currentText _ browserText END; <> <> ShowAuto: PROC[h: GVPRef] RETURNS[r: ROPE] = BEGIN IF autoShow THEN ShowItem[h, showFull]; r _ PlaceRope[h] END; PlaceRope: PROC[h: GVPRef] RETURNS[r:ROPE] ={r _ Rope.Concat["Current ", PositionRope[h]]}; <> <> <> <> SetLogicalButton: ENTRY ButtonProc = TRUSTED BEGIN h: GVPRef = NARROW[clientData]; a: CARDINAL; [num: a] _ NumFromRope[octal: FALSE, r: ViewerTools.GetContents[setInput], start: 0]; IF SetLogical[h, a] THEN Set[ShowAuto[h]] ELSE Flash["Couldn't"] END; SetPhysicalButton: ENTRY ButtonProc = TRUSTED BEGIN h: GVPRef = NARROW[clientData]; a: CARDINAL; [num: a] _ NumFromRope[octal: FALSE, r: ViewerTools.GetContents[setInput], start: 0]; IF SetPhysical[h, a] THEN Set[ShowAuto[h]] ELSE Flash["Couldn't"] END; ResetButton: ENTRY ButtonProc = TRUSTED BEGIN h: GVPRef = NARROW[clientData]; IF SetLogical[h, 0] THEN Set[ShowAuto[h]] ELSE Flash["Couldn't"] END; <> <> <> <> PrevButton: ENTRY ButtonProc = TRUSTED BEGIN h: GVPRef = NARROW[clientData]; stoppable _ TRUE; THROUGH [0..GetRepeatCount[]) DO IF NOT PrevPage[h] THEN {Flash["No more pages"]; EXIT}; [] _ ShowAuto[h]; IF StopRequested[] THEN EXIT ENDLOOP; stoppable _ FALSE; Set[PlaceRope[h]] END; NextButton: ENTRY ButtonProc = TRUSTED BEGIN h: GVPRef = NARROW[clientData]; stoppable _ TRUE; THROUGH [0..GetRepeatCount[]) DO IF NOT NextPage[h] THEN {Flash["No more pages"]; EXIT}; [] _ ShowAuto[h]; IF StopRequested[] THEN EXIT ENDLOOP; stoppable _ FALSE; Set[PlaceRope[h]] END; ShowButton: ENTRY ButtonProc = TRUSTED BEGIN h: GVPRef = NARROW[clientData]; ShowItem[h, showFull]; Set[PlaceRope[h]] END; <> <> <