<> <> <> <> <> <> <> DIRECTORY Buttons USING [Button, ButtonProc, Create], Commander USING [CommandProc, Register], Containers USING [ChildXBound, ChildYBound, Container, Create], GVPDefs, IO USING [Flush, PutF, time], Labels USING [Create, Set, SetDisplayStyle], Process USING [MsecToTicks, Pause], Rope USING [Fetch, Length], ViewerEvents USING [EventProc, RegisterEventProc], ViewerIO USING [CreateViewerStreams], ViewerOps USING [CreateViewer, MoveViewer, PaintViewer, SaveViewer], ViewerTools USING [GetContents, MakeNewTextViewer, SetSelection]; GVPMain: CEDAR MONITOR LOCKS lock IMPORTS Buttons, Commander, Containers, GVPDefs, IO, Labels, Process, Rope, ViewerEvents, ViewerIO, ViewerOps, ViewerTools EXPORTS GVPDefs = BEGIN OPEN GVPDefs; lock: PUBLIC MONITORLOCK; h: GVPRef _ NIL; message, focus, root: Viewer; serverButtons, logText, serverInput, fileInput, cLineInput, lengthInput: Viewer; <> <> <<(If a viewer is taken off screen with the selection in it you can't get it (the selection) back)>> <> <> <> MainInit: PROC = BEGIN root _ Containers.Create[[name: "GV-Patch", iconic: FALSE, scrollable: FALSE]]; h.root _ root; -- this is a fudge I don't really understand focus _ ViewerTools.MakeNewTextViewer[[parent: root, wx: 0, wy: row5, ww: char, wh: rowHeight, border: FALSE]]; message _ Labels.Create[[parent: root, wx: col1, wy: row5, ww: 90*char, wh: rowHeight, border: FALSE]]; MakeEditorButtons[h]; MakeBrowserButtons[h]; MakeServerButtons[h]; ViewerOps.MoveViewer[viewer: serverButtons, x: 0, y: 0, w: 0, h: 4*rowSize, paint: FALSE]; ViewerOps.MoveViewer[viewer: logText, x: 0, y: row6, w: 0, h: 0, paint: FALSE]; Containers.ChildXBound[root, serverButtons]; Containers.ChildXBound[root, logText]; Containers.ChildYBound[root, logText]; ViewerOps.PaintViewer[root, all]; ToFocus[]; h.currentButtons _ serverButtons; h.currentText _ logText END; <> <> <> DestroyProc: ViewerEvents.EventProc = TRUSTED BEGIN IF viewer#root THEN RETURN; h.root _ NIL; BrowserTidyUp[]; ProcsTidyUp[]; EditorTidyUp[]; DriverTidyUp[]; h _ NIL END; ToFocus: PUBLIC PROC = {ViewerTools.SetSelection[focus]}; -- selection put in "focus" GetHandle: PUBLIC PROC RETURNS[handle: GVPRef] = {handle _ h}; -- return data record^ <> <> Set: PUBLIC PROC[r: ROPE _ NIL] = { Labels.Set[message, r, TRUE] }; Flash: PUBLIC PROC[r: ROPE] = BEGIN Labels.Set[message, r, TRUE]; Labels.SetDisplayStyle[message, $WhiteOnBlack]; Process.Pause[Process.MsecToTicks[750]]; Labels.SetDisplayStyle[message, $BlackOnWhite] END; <> Failed: PUBLIC PROC[r: ROPE] RETURNS [failed: BOOLEAN] = BEGIN failed _ r#NIL; IF failed THEN Flash[r] ELSE Set[] END; <> <> <> <> <> <> <> <> NumFromRope: PUBLIC PROC[octal: BOOLEAN, r: ROPE, start: CARDINAL] RETURNS [num, end: CARDINAL] = BEGIN i: CARDINAL _ start; top: CHAR = IF octal THEN '7 ELSE '9; base: CARDINAL = IF octal THEN 8 ELSE 10; c: CHAR _ ' ; len: CARDINAL = Rope.Length[r]; num _ 0; end _ len; UNTIL c IN ['0..top] OR c='/ DO IF i=len THEN {num _ lastCard; RETURN}; c _ Rope.Fetch[r, i]; i _ i + 1 ENDLOOP; IF c IN ['0..top] THEN BEGIN i _ i - 1; UNTIL i = len OR NOT( c IN ['0..top] ) DO c _ Rope.Fetch[r, i]; IF c IN ['0..top] THEN num _ num * base + c - '0; i _ i + 1 ENDLOOP; IF i#len THEN i _ i-1 END ELSE num _ lastCard; end _ i END; <> <> <> <