DIRECTORY Atom USING [GetPName, GetProp, PropList, PutProp], Basics USING [bitsPerWord], BasicTime USING [Now], Buttons USING [Button, ButtonProc, Create, SetDisplayStyle], Commander USING [CommandProc, Register], CommandTool USING [CurrentWorkingDirectory], Containers USING [ChildXBound, ChildYBound, Container, Create], ImagerBackdoor USING [DrawBits], IO USING [Close, Error, PutF, STREAM, time], Labels USING [Create, Label, Set], Loader USING [BCDBuildTime], Process USING [MsecToTicks, SetTimeout], Rope USING [Equal, IsEmpty, Length, ROPE, FromRefText], Rules USING [Create, Rule], TapeOps USING [DriveNumber], TapeStreams USING [ConversionRecord], TapeToolInternal USING [Action, BuildOperations, Create, ExecuteOp, Flush, GetToolParameters, Parameters, PrompterSeq, ReactToProfile, RegisterIdle, RegisterProfile, TapeTool, TapeToolOp, TapeToolRecord, UnRegisterIdle, UnregisterProfile], TypeScript USING [Create], UserProfile USING [CallWhenProfileChanges], VFonts USING [CharWidth, Font, StringWidth], ViewerClasses USING [PaintProc, Viewer, ViewerClass, ViewerClassRec], ViewerEvents USING [EventProc, EventRegistration, RegisterEventProc, UnRegisterEventProc], ViewerIO USING [CreateViewerStreams], ViewerOps USING [AddProp, CreateViewer, FetchProp, MoveViewer, PaintViewer, RegisterViewerClass, SetOpenHeight], ViewerTools USING [GetContents, GetSelectedViewer, InhibitUserEdits, MakeNewTextViewer, SelPosRec, SetContents, SetSelection]; TapeToolInterfaceImpl: CEDAR MONITOR IMPORTS Atom, BasicTime, Buttons, Commander, CommandTool, Containers, ImagerBackdoor, IO, Labels, Loader, Process, Rope, Rules, TapeToolInternal, TypeScript, UserProfile, VFonts, ViewerEvents, ViewerIO, ViewerOps, ViewerTools EXPORTS TapeToolInternal = BEGIN OPEN Tool: TapeToolInternal; TapeTool: TYPE ~ Tool.TapeTool; PrompterSeq: TYPE ~ Tool.PrompterSeq; ROPE: TYPE ~ Rope.ROPE; STREAM: TYPE ~ IO.STREAM; ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- promptW: NAT = 13; promptH: NAT = 10; promptWpl: NAT ~ (promptW + Basics.bitsPerWord - 1)/Basics.bitsPerWord; PromptArray: TYPE = ARRAY [0..promptWpl*promptH) OF WORD; prompt: REF PromptArray ~ NEW[PromptArray _ [001600B, 000700B, 00340B, 000160B, 177770B, 177770B, 000160B, 000340B, 000700B, 001600B]]; tapeToolPrompter: ViewerClasses.ViewerClass = NEW[ViewerClasses.ViewerClassRec _ [paint: PaintPrompter]]; ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- minFeedbackLines: NAT = 4; interactionQuestionLines: NAT = 1; idleMessage: ROPE _ " "; offScreen: INT = -9999; ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- NewTapeTool: PROC [iconic: BOOL, wDir: ROPE _ NIL, pgt: BOOL _ FALSE] RETURNS [ tool: Tool.TapeTool ] = BEGIN AddSeparatingRule: PROC = BEGIN rule: Rules.Rule = Rules.Create[info: [ wx: 0, wy: tool.height, ww: 9999, -- arbitrary; Containers.ChildXBound overrides wh: 1, parent: tool.outer ]]; Containers.ChildXBound[tool.outer, rule]; -- constrain rule to be width of parent tool.height _ tool.height + tool.params.entryVSpace; -- spacing after rule END; BuildBailOut: PROC = BEGIN prev: ViewerClasses.Viewer; prev _ Buttons.Create[ info: [name: "Stop!", wx: tool.params.entryHSpace, wy: tool.height, wh: tool.params.entryHeight, parent: tool.outer, border: TRUE ], proc: AbortOperation, fork: TRUE, clientData: tool, guarded: TRUE, font: tool.params.font ]; tool.height _ tool.height + tool.params.entryHeight + tool.params.entryVSpace; AddSeparatingRule[]; END; BuildServerInfo: PROC = BEGIN prev: ViewerClasses.Viewer; prev _ Buttons.Create[ info: [name: "Server:", wx: tool.params.entryHSpace, wy: tool.height, wh: tool.params.entryHeight, parent: tool.outer, border: FALSE ], proc: SelectServerName, fork: FALSE, clientData: tool, font: tool.params.font ]; tool.serverNameViewer _ ViewerTools.MakeNewTextViewer[info: [ wx: prev.wx + prev.ww + tool.params.entryHSpace/2, wy: tool.height, ww: VFonts.CharWidth['M, tool.params.font] * 7, wh: tool.params.entryHeight, data: tool.params.defaultServer, parent: tool.outer, scrollable: FALSE, border: FALSE ]]; prev _ Buttons.Create[ info: [name: "Drive:", wx: tool.serverNameViewer.wx + tool.serverNameViewer.ww + tool.params.entryHSpace, wy: tool.height, wh: tool.params.entryHeight, parent: tool.outer, border: FALSE ], proc: SelectDriveNumber, fork: FALSE, clientData: tool, font: tool.params.font ]; tool.driveNumberViewer _ ViewerTools.MakeNewTextViewer[ info: [ wx: prev.wx + prev.ww + tool.params.entryHSpace/2, wy: tool.height, ww: VFonts.CharWidth['0, tool.params.font] * 4, -- arbitrary; Containers.ChildXBound overrides wh: tool.params.entryHeight, data: "0", parent: tool.outer, scrollable: FALSE, border: FALSE ] ]; prev _ Buttons.Create[ info: [name: "Density:", wx: tool.driveNumberViewer.wx + tool.driveNumberViewer.ww + tool.params.entryHSpace, wy: tool.height, wh: tool.params.entryHeight, parent: tool.outer, border: FALSE ], proc: SelectDensity, fork: FALSE, clientData: tool, font: tool.params.font ]; tool.densityLabel _ Labels.Create[ info: [ wx: prev.wx + prev.ww + tool.params.entryHSpace/2, wy: tool.height, ww: VFonts.CharWidth['M, tool.params.font] * 7, wh: tool.params.entryHeight, name: (IF pgt THEN "800 bpi NRZI" ELSE "1600 bpi PE"), parent: tool.outer, border: FALSE ] ]; tool.density _ IF pgt THEN NRZI800 ELSE PE1600; tool.height _ tool.height + tool.params.entryHeight + tool.params.entryVSpace; AddSeparatingRule[]; END; -- BuildServerInfo BuildFileInfo: PROC = BEGIN prev: ViewerClasses.Viewer; prev _ Buttons.Create[ info: [name: "File(s):", wx: tool.params.entryHSpace, wy: tool.height, wh: tool.params.entryHeight, parent: tool.outer, border: FALSE ], proc: SelectFileName, fork: FALSE, clientData: tool, guarded: FALSE, font: tool.params.font ]; tool.fileNameViewer _ ViewerTools.MakeNewTextViewer[info: [ wx: prev.wx + prev.ww + tool.params.entryHSpace, wy: tool.height, ww: 9999, wh: tool.params.entryHeight, data: IF tool.params.fileNamePrefixes = NIL THEN NIL ELSE IF tool.params.localDisk THEN NIL ELSE tool.params.fileNamePrefixes.first, parent: tool.outer, scrollable: TRUE, border: FALSE ]]; Containers.ChildXBound[container: tool.outer, child: tool.fileNameViewer]; tool.height _ tool.height + tool.params.entryHeight + tool.params.entryVSpace; prev _ Buttons.Create[ info: [name: "WD:", wx: tool.params.entryHSpace, wy: tool.height, wh: tool.params.entryHeight, parent: tool.outer, border: FALSE ], proc: SelectWDName, fork: FALSE, clientData: tool, guarded: FALSE, font: tool.params.font ]; tool.wdViewer _ ViewerTools.MakeNewTextViewer[info: [ wx: prev.wx + prev.ww + tool.params.entryHSpace/2, wy: tool.height, ww: VFonts.CharWidth['M, tool.params.font] * 12, wh: tool.params.entryHeight, data: (IF wDir.IsEmpty[] THEN "///" ELSE wDir), parent: tool.outer, scrollable: FALSE, border: FALSE ]]; IF tool.params.localDisk THEN BEGIN prev _ Buttons.Create[ info: [name: "Include Tioga Format:", wx: tool.wdViewer.wx + tool.wdViewer.ww + tool.params.entryHSpace/2, wy: tool.height, wh: tool.params.entryHeight, parent: tool.outer, border: FALSE ], proc: SelectTiogaRead, fork: FALSE, clientData: tool, font: tool.params.font ]; tool.tiogaReadLabel _ Labels.Create[ info: [ wx: prev.wx + prev.ww + tool.params.entryHSpace/2, wy: tool.height, ww: 9999, wh: tool.params.entryHeight, name: "yes", parent: tool.outer, border: FALSE ] ]; Containers.ChildXBound[container: tool.outer, child: tool.tiogaReadLabel]; END; tool.height _ tool.height + tool.params.entryHeight + tool.params.entryVSpace; prev _ Buttons.Create[ info: [name: "Block size:", wx: tool.params.entryHSpace, wy: tool.height, wh: tool.params.entryHeight, parent: tool.outer, border: FALSE ], proc: SelectBlockSize, fork: FALSE, clientData: tool, font: tool.params.font ]; tool.blockingViewer _ ViewerTools.MakeNewTextViewer[info: [ wx: prev.wx + prev.ww + tool.params.entryHSpace/3, wy: tool.height, ww: VFonts.CharWidth['0, tool.params.font] * 8, wh: tool.params.entryHeight, data: (IF pgt THEN " 512" ELSE " 1024"), parent: tool.outer, scrollable: FALSE, border: FALSE ]]; tool.hlreclContainer _ Containers.Create[info: [ wx: 194, wy: tool.height, ww: 9999, -- arbitrary; Containers.ChildXBound overrides wh: tool.params.entryHeight, parent: tool.outer, border: FALSE, scrollable: FALSE ]]; tool.lreclContainer _ Containers.Create[info: [ wx: 0, wy: 0, ww: 9999, -- arbitrary; Containers.ChildXBound overrides wh: tool.params.entryHeight, parent: tool.hlreclContainer, border: FALSE, scrollable: FALSE ]]; tool.lreclX _ tool.lreclContainer.wx; tool.lreclY _ tool.lreclContainer.wy; prev _ Buttons.Create[ info: [name: "LRecl:", wx: 0, wy: 0, wh: tool.params.entryHeight, parent: tool.lreclContainer, border: FALSE ], proc: SelectLRecl, fork: FALSE, clientData: tool, font: tool.params.font ]; tool.lreclViewer _ ViewerTools.MakeNewTextViewer[info: [ wx: prev.wx + prev.ww + tool.params.entryHSpace/3, wy: 0, ww: VFonts.CharWidth['0, tool.params.font] * 8, wh: tool.params.entryHeight, data: " 0", parent: tool.lreclContainer, scrollable: FALSE, border: FALSE ]]; Containers.ChildXBound[container: tool.outer, child: tool.hlreclContainer]; Containers.ChildXBound[container: tool.hlreclContainer, child: tool.lreclContainer]; tool.height _ tool.height + tool.params.entryHeight + tool.params.entryVSpace; prev _ Buttons.Create[ info: [name: "Pad:", wx: tool.params.entryHSpace, wy: tool.height, wh: tool.params.entryHeight, parent: tool.outer, border: FALSE ], proc: SelectFillBlock, fork: FALSE, clientData: tool, font: tool.params.font ]; tool.fillBlockLabel _ Labels.Create[ info: [ wx: prev.wx + prev.ww + tool.params.entryHSpace/3, wy: tool.height, ww: VFonts.StringWidth["with Blanks ", tool.params.font], wh: tool.params.entryHeight, name: "with Blanks", parent: tool.outer, border: FALSE ] ]; prev _ Buttons.Create[ info: [name: "Conversions:", wx: 194, wy: tool.height, wh: tool.params.entryHeight, parent: tool.outer, border: FALSE ], proc: SelectConversion, fork: FALSE, clientData: tool, font: tool.params.font ]; tool.conversionsViewer _ ViewerTools.MakeNewTextViewer[ info: [ wx: prev.wx + prev.ww + tool.params.entryHSpace/3, wy: tool.height, ww: 9999, wh: tool.params.entryHeight, data: (IF pgt THEN "ToPGT" ELSE NIL), parent: tool.outer, scrollable: TRUE, border: FALSE ] ]; tool.height _ tool.height + tool.params.entryHeight + tool.params.entryVSpace; Containers.ChildXBound[container: tool.outer, child: tool.conversionsViewer]; AddSeparatingRule[]; END; BuildInteraction: PROC = BEGIN h: INT _ 0; tool.interaction _ Containers.Create[info: [ wx: 0, wy: tool.height, ww: 9999, -- arbitrary; Containers.ChildXBound overrides wh: (interactionQuestionLines + 1) * tool.params.entryHeight + 2, parent: tool.outer, border: FALSE, scrollable: FALSE ]]; tool.question _ ViewerTools.MakeNewTextViewer[info: [ wx: tool.params.entryHSpace, wy: 0, ww: 9999, -- arbitrary; Containers.ChildXBound overrides wh: interactionQuestionLines * tool.params.entryHeight, data: idleMessage, parent: tool.interaction, scrollable: TRUE, border: FALSE ]]; Containers.ChildXBound[container: tool.interaction, child: tool.question]; ViewerTools.InhibitUserEdits[tool.question]; tool.height _ tool.height + tool.question.wh + 2; tool.autoConfirmButton _ Buttons.Create[ info: [name: "Auto-Confirm", wx: tool.params.entryHSpace, wy: tool.question.wh + 2, wh: tool.params.entryHeight, parent: tool.interaction, border: TRUE ], proc: AutoConfirmButton, fork: FALSE, clientData: tool, font: tool.params.font ]; tool.prompt _ Containers.Create[info: [ wx: tool.autoConfirmButton.wx + tool.autoConfirmButton.ww + tool.params.entryHSpace, wy: tool.question.wh + 2, ww: 9999, -- arbitrary; Containers.ChildXBound overrides wh: tool.params.entryHeight, parent: tool.interaction, border: FALSE, scrollable: FALSE ]]; tool.prompter _ ViewerOps.CreateViewer[ flavor: $TapeToolPrompter, info: [ wx: tool.params.entryHSpace, wy: 0, ww: promptW+Tool.PrompterSeq.LAST, wh: promptH, data: tool, parent: tool.prompt, scrollable: FALSE, border: FALSE ] ]; tool.yesButton _ Buttons.Create[ info: [name: "Yes", wx: tool.prompter.wx + tool.prompter.ww + tool.params.entryHSpace, wy: 0, wh: tool.params.entryHeight, parent: tool.prompt, border: TRUE ], proc: YesButton, fork: FALSE, clientData: tool, font: tool.params.font ]; tool.noButton _ Buttons.Create[ info: [name: "No", wx: tool.yesButton.wx + tool.yesButton.ww + tool.params.entryHSpace, wy: 0, wh: tool.params.entryHeight, parent: tool.prompt, border: TRUE ], proc: NoButton, fork: FALSE, clientData: tool, font: tool.params.font ]; TRUSTED{Process.SetTimeout[@tool.responseMade, Process.MsecToTicks[90]]}; Containers.ChildXBound[container: tool.interaction, child: tool.prompt]; tool.promptX _ tool.prompt.wx; tool.promptY _ tool.prompt.wy; DisableQuestion[tool]; tool.height _ tool.height + tool.prompt.wh + 2; AddSeparatingRule[]; Containers.ChildXBound[container: tool.outer, child: tool.interaction]; END; v: ViewerClasses.Viewer; tool _ NEW[Tool.TapeToolRecord]; tool.params _ Tool.GetToolParameters[]; tool.outer _ Containers.Create[ info: [ name: "Tape Tool", iconic: TRUE, column: right, scrollable: FALSE ], paint: TRUE ]; tool.destroyEvent _ ViewerEvents.RegisterEventProc[proc: MyDestroy, event: destroy]; Tool.RegisterIdle[tool]; Tool.RegisterProfile[tool]; tool.height _ tool.params.entryVSpace; BuildBailOut[]; BuildServerInfo[]; Tool.BuildOperations[tool]; BuildFileInfo[]; BuildInteraction[]; v _ TypeScript.Create[ info: [ wx: 0, wy: tool.height + 5, ww: 9999, wh: 9999, parent: tool.outer, border: FALSE] ]; tool.height _ tool.height + minFeedbackLines * tool.params.entryHeight + tool.params.entryVSpace; tool.typeScript _ ViewerIO.CreateViewerStreams[name: "TapeTool.log", viewer: v, backingFile: "TapeTool.log"].out; Containers.ChildXBound[container: tool.outer, child: v]; Containers.ChildYBound[container: tool.outer, child: v]; ViewerTools.InhibitUserEdits[v]; ViewerOps.MoveViewer[tool.lreclContainer, 0, offScreen, tool.lreclContainer.ww, tool.lreclContainer.wh, TRUE]; ViewerOps.AddProp[tool.outer, $TapeToolViewer, tool]; ViewerOps.SetOpenHeight[tool.outer, tool.height]; ViewerOps.PaintViewer[tool.outer, all]; tool.serverName _ tool.params.defaultServer; tool.driveNumber _ 0; Labels.Set[tool.statusLabel, "Connection Closed"]; tool.typeScript.PutF["TapeTool of %t\nSession began at %t\n", IO.time[Loader.BCDBuildTime[]], IO.time[BasicTime.Now[]]]; tool.opsQueue _ Tool.Create[tool]; END; -- Internal Procs ShowLReclViewer: PUBLIC PROC [tool: Tool.TapeTool] = BEGIN ViewerOps.MoveViewer[tool.lreclContainer, 0, 0, tool.lreclContainer.ww, tool.lreclContainer.wh, TRUE]; END; RemoveLReclViewer: PUBLIC PROC [tool: Tool.TapeTool] = BEGIN ViewerOps.MoveViewer[tool.lreclContainer, 0, offScreen, tool.lreclContainer.ww, tool.lreclContainer.wh, TRUE]; END; YesButton: Buttons.ButtonProc = BEGIN ENABLE UNWIND => NULL; tool: Tool.TapeTool _ NARROW[clientData]; ResponseSeen[tool, TRUE]; END; NoButton: Buttons.ButtonProc = BEGIN ENABLE UNWIND => NULL; tool: Tool.TapeTool _ NARROW[clientData]; ResponseSeen[tool, FALSE]; END; AutoConfirmButton: Buttons.ButtonProc = BEGIN ENABLE UNWIND => NULL; tool: Tool.TapeTool _ NARROW[clientData]; IF (tool.autoConfirm _ NOT tool.autoConfirm) THEN BEGIN Buttons.SetDisplayStyle[NARROW[parent], $WhiteOnBlack]; ResponseSeen[tool, TRUE]; END ELSE Buttons.SetDisplayStyle[NARROW[parent], $BlackOnWhite]; END; ResponseSeen: ENTRY PROC [tool: TapeTool, value: BOOL] = BEGIN ENABLE UNWIND => NULL; ResponseSeenInternal[tool, value]; END; ResponseSeenInternal: INTERNAL PROC [tool: TapeTool, value: BOOL] = BEGIN ENABLE UNWIND => NULL; tool.responseValue _ value; tool.responseSeen _ TRUE; BROADCAST tool.responseMade; -- wakes up both prompter and main operation END; WaitForResponse: PUBLIC PROC [tool: TapeTool, ignoreAutoConfirm: BOOL _ FALSE] RETURNS [value: BOOL _ FALSE] = BEGIN p: PROCESS _ NIL; WaitForResponseEntry: ENTRY PROC [tool: TapeTool] = BEGIN ENABLE UNWIND => NULL; tool.responseSeen _ FALSE; p _ FORK PrompterProcess[tool]; UNTIL tool.responseSeen DO WAIT tool.responseMade; IF tool.AbortNow THEN BEGIN tool.responseValue _ FALSE; tool.responseSeen _ TRUE; BROADCAST tool.responseMade; DisableQuestion[tool]; ERROR ABORTED; END; ENDLOOP; value _ tool.responseValue; END; IF NOT ignoreAutoConfirm THEN IF tool.autoConfirm THEN RETURN [TRUE]; EnableQuestion[tool]; WaitForResponseEntry[tool]; DisableQuestion[tool]; TRUSTED{JOIN p}; END; PrompterProcess: PROC [tool: TapeTool] = BEGIN Done: ENTRY PROC [tool: TapeTool] RETURNS [BOOL] = BEGIN ENABLE UNWIND => NULL; IF tool.AbortNow THEN RETURN[FALSE]; WAIT tool.responseMade; RETURN[tool.responseSeen] END; UNTIL Done[tool] DO ViewerOps.PaintViewer[tool.prompter, all]; ENDLOOP; ViewerOps.PaintViewer[tool.prompter, all]; -- clears prompter entirely END; PaintPrompter: ViewerClasses.PaintProc = BEGIN tool: TapeTool = NARROW[self.data]; IF ~tool.responseSeen THEN BEGIN -- strictly speaking, should be inside the monitor ImagerBackdoor.DrawBits[context: context, base: LOOPHOLE[prompt], wordsPerLine: promptWpl, fMin: 0, sMin: 0, fSize: promptW, sSize: promptH, tx: tool.prompterSeq, ty: promptH]; tool.prompterSeq _ (tool.prompterSeq + 2) MOD PrompterSeq.LAST.SUCC; END; END; AbortOperation: Buttons.ButtonProc = BEGIN tool: Tool.TapeTool _ NARROW[clientData]; AbortOperationEntry: ENTRY PROC [tool: TapeTool] = BEGIN ENABLE UNWIND => NULL; IF NOT tool.active THEN RETURN; -- tool is idle tool.AbortNow _ TRUE; ResponseSeenInternal[tool, FALSE]; -- wake up waiting operation, if any. END; AbortOperationEntry[tool]; END; EnableQuestion: PUBLIC PROC [tool: TapeTool] = BEGIN ViewerOps.MoveViewer[tool.prompt, tool.promptX, tool.promptY, tool.prompt.ww, tool.prompt.wh, TRUE]; END; DisableQuestion: PUBLIC PROC [tool: TapeTool] = BEGIN ViewerOps.MoveViewer[tool.prompt, 0, offScreen, tool.prompt.ww, tool.prompt.wh, TRUE]; END; SelectServerName: Buttons.ButtonProc = BEGIN tool: Tool.TapeTool _ NARROW[clientData]; ViewerTools.SetSelection[tool.serverNameViewer]; END; SelectDriveNumber: Buttons.ButtonProc = BEGIN tool: Tool.TapeTool _ NARROW[clientData]; ViewerTools.SetSelection[tool.driveNumberViewer]; END; SelectDensity: Buttons.ButtonProc = BEGIN tool: Tool.TapeTool _ NARROW[clientData]; SELECT tool.density FROM PE1600 => { Labels.Set[tool.densityLabel, "800 bpi NRZI"]; tool.density _ NRZI800}; NRZI800 => { Labels.Set[tool.densityLabel, "1600 bpi PE"]; tool.density _ PE1600}; ENDCASE => ERROR; END; SelectBlockSize: Buttons.ButtonProc = BEGIN tool: Tool.TapeTool _ NARROW[clientData]; ViewerTools.SetSelection[tool.blockingViewer]; END; SelectLRecl: Buttons.ButtonProc = BEGIN tool: Tool.TapeTool _ NARROW[clientData]; ViewerTools.SetSelection[tool.lreclViewer]; END; SelectFileName: Buttons.ButtonProc = BEGIN tool: Tool.TapeTool _ NARROW[clientData]; selection: REF ViewerTools.SelPosRec _ NIL; SELECT TRUE FROM mouseButton = blue => ViewerTools.SetContents[tool.fileNameViewer, NIL]; ViewerTools.GetSelectedViewer[] = tool.fileNameViewer => BEGIN NextName: PROC [this: ROPE, list: LIST OF ROPE] RETURNS [next: ROPE _ NIL] = BEGIN IF list = NIL THEN RETURN; FOR l: LIST OF ROPE _ list, l.rest UNTIL l = NIL DO IF this.Equal[l.first, FALSE] THEN RETURN[IF l.rest = NIL THEN list.first ELSE l.rest.first] ENDLOOP; RETURN[list.first] END; contents: ROPE _ ViewerTools.GetContents[tool.fileNameViewer]; ViewerTools.SetContents[tool.fileNameViewer, contents _ NextName[contents, tool.params.fileNamePrefixes]]; selection _ NEW[ViewerTools.SelPosRec _ [start: contents.Length[], length: 0]]; END; ENDCASE; ViewerTools.SetSelection[tool.fileNameViewer, selection]; END; SelectWDName: Buttons.ButtonProc = BEGIN tool: Tool.TapeTool _ NARROW[clientData]; ViewerTools.SetSelection[tool.wdViewer]; END; SelectConversion: Buttons.ButtonProc = BEGIN tool: Tool.TapeTool _ NARROW[clientData]; selection: REF ViewerTools.SelPosRec _ NIL; SELECT TRUE FROM mouseButton = blue => ViewerTools.SetContents[tool.conversionsViewer, NIL]; ViewerTools.GetSelectedViewer[] = tool.conversionsViewer => BEGIN NextName: PROC [this: ROPE, r: REF] RETURNS [next: ROPE _ NIL, val: REF TapeStreams.ConversionRecord _ NIL] = BEGIN WITH r SELECT FROM list: Atom.PropList => BEGIN FOR l: Atom.PropList _ list, l.rest UNTIL l = NIL DO IF this.Equal[ToRope[l.first.key], FALSE] THEN { IF l.rest = NIL THEN RETURN[NIL, NIL] ELSE RETURN[ToRope[l.rest.first.key], ToConvert[l.rest.first.val]]}; ENDLOOP; RETURN[ToRope[list.first.key], ToConvert[list.first.val]]; END; ENDCASE => NULL; END; contents: ROPE _ ViewerTools.GetContents[tool.conversionsViewer]; trans: REF TapeStreams.ConversionRecord; [contents, trans] _ NextName[contents, Atom.GetProp[$TapeTool, $Conversions]]; IF trans # NIL AND trans.name = $ToEbcdic THEN ShowLReclViewer[tool] ELSE RemoveLReclViewer[tool]; ViewerTools.SetContents[tool.conversionsViewer, contents]; selection _ NEW[ViewerTools.SelPosRec _ [start: contents.Length[], length: 0]]; END; ENDCASE; ViewerTools.SetSelection[tool.conversionsViewer, selection]; END; SelectFillBlock: Buttons.ButtonProc = BEGIN tool: Tool.TapeTool _ NARROW[clientData]; SELECT tool.fillBlock FROM truncate => { Labels.Set[tool.fillBlockLabel, "with Blanks"]; tool.fillBlock _ blanks }; blanks => { Labels.Set[tool.fillBlockLabel, "with Zeros"]; tool.fillBlock _ zeroes }; zeroes => { Labels.Set[tool.fillBlockLabel, "truncate"]; tool.fillBlock _ truncate }; ENDCASE => ERROR; END; SelectTiogaRead: Buttons.ButtonProc = BEGIN tool: Tool.TapeTool _ NARROW[clientData]; Labels.Set[tool.tiogaReadLabel, (IF tool.tiogaReadValue THEN "no" ELSE "yes")]; tool.tiogaReadValue _ NOT tool.tiogaReadValue; END; MyDestroy: ViewerEvents.EventProc = BEGIN tool: Tool.TapeTool _ NARROW[ViewerOps.FetchProp[viewer, $TapeToolViewer]]; IF tool = NIL THEN RETURN; ViewerEvents.UnRegisterEventProc[proc: tool.destroyEvent, event: destroy]; Tool.UnRegisterIdle[tool]; Tool.UnregisterProfile[tool]; IF tool.open THEN { Tool.Flush[tool.opsQueue]; Tool.ExecuteOp[tool: tool, op: [op: Close]]; }; IO.Close[tool.typeScript ! IO.Error => CONTINUE]; END; ToRope: PROC [ r: REF ANY ] RETURNS [ rope: ROPE ] = BEGIN WITH r SELECT FROM ro: ROPE => rope _ ro; a: ATOM => rope _ Atom.GetPName[a]; t: REF TEXT => rope _ Rope.FromRefText[t]; ENDCASE => ERROR; END; ToConvert: PROC [ r: REF ANY ] RETURNS [ val: REF TapeStreams.ConversionRecord _ NIL] = BEGIN WITH r SELECT FROM t: REF TapeStreams.ConversionRecord => val _ t; ENDCASE => val _ NIL; END; MakeNewTapeTool: Commander.CommandProc = BEGIN Atom.PutProp[$TapeTool, $state, NewTapeTool[TRUE, CommandTool.CurrentWorkingDirectory[], FALSE]]; END; MakePGTTapeTool: Commander.CommandProc = BEGIN Atom.PutProp[$TapeTool, $state, NewTapeTool[TRUE, CommandTool.CurrentWorkingDirectory[], TRUE]]; END; Commander.Register["TapeTool", MakeNewTapeTool, "Generate a new TapeTool"]; Commander.Register["PGTape", MakePGTTapeTool, "Generate a new TapeTool for PGT tapes"]; ViewerOps.RegisterViewerClass[$TapeToolPrompter, tapeToolPrompter]; UserProfile.CallWhenProfileChanges[Tool.ReactToProfile]; END.... ΐTapeToolInterfaceImpl.mesa Copyright c 1984 by Xerox Corp. All rights reserved. Last edited by Tim Diebert: June 10, 1985 8:40:33 am PDT Last edited by McCreight: February 25, 1985 6:57:33 pm PST Tim Diebert : May 31, 1985 3:31:36 pm PDT Global "Variables" (constant after init) Configuration Parameters (private) Tool Construction ***Main Body of NewTapeTool*** -- closeEvent _ ViewerEvents.RegisterEventProc[proc: MyClose, event: close]; Κπ˜šœ™Jšœ Οmœ*™5J™8J™:Icode™)—J˜šΟk ˜ Jšœžœ(˜2Jšœžœ˜Jšœ žœ˜Jšœžœ/˜žœžœ˜xJšœ"˜"Jšžœ˜—J˜šΠbc˜J˜—J˜š’œžœžœž˜:šœ/˜/Jšœ0žœ˜6—Jšžœ˜—J˜š’œžœžœž˜<šœ7˜7Jšœ0žœ˜6—Jšžœ˜—J˜šŸ œž˜%Jšžœžœžœ˜Jšœžœ ˜)Jšœžœ˜Jšžœ˜—J˜šŸœž˜$Jšžœžœžœ˜Jšœžœ ˜)Jšœžœ˜Jšžœ˜J˜—J˜šŸœž˜-Jšžœžœžœ˜Jšœžœ ˜)šžœžœ˜,šžœž˜ Jšœžœ˜7Jšœžœ˜Jšž˜—Jšžœžœ˜<—Jšžœ˜J˜—š ’ œžœžœžœž˜>Jšžœžœžœ˜Jšœ"˜"Jšžœ˜—J˜š ’œžœžœžœž˜IJšžœžœžœ˜Jšœ˜Jšœžœ˜Jšž œ ,˜JJšžœ˜—J˜š’œž ˜Jš œ$žœžœžœ žœžœž˜WJšœžœžœ˜š’œžœžœž˜9Jšžœžœžœ˜Jšœžœ˜Jšœžœ˜šžœž˜Jšžœ˜šžœ ž ˜Jšœžœ˜Jšœžœ˜Jšž œ˜J˜Jšž˜Jšžœ˜—Jšžœ˜—Jšœ˜Jšžœ˜—Jš žœžœžœžœžœžœ˜EJ˜Jšœ˜J˜Jšžœžœ˜Jšžœ˜—J˜š’œžœž˜.š ’œžœžœžœžœž˜8Jšžœžœžœ˜Jšžœžœžœžœ˜$Jšžœ˜Jšžœ˜Jšžœ˜—Jšžœ žœ+ž œ˜HJšœ, ˜GJšžœ˜—J˜š’ œž˜.Jšœžœ ˜#šžœžœžœ 2˜TKšœ0žœz˜²šœ*žœ žœžœ˜DJšžœ˜——Jšžœ˜—J˜šŸœž˜*Jšœžœ ˜)š’œžœžœž˜8Jšžœžœžœ˜Jšžœ žœžœ ˜0Jšœžœ˜Jšœžœ %˜IJšžœ˜—Jšœ˜Jšžœ˜J˜—šŸœž œž˜4Jšœ^žœ˜dJšžœ˜—J˜šŸœž œž˜5JšœPžœ˜VJšžœ˜—J˜J˜šŸœž˜,Jšœžœ ˜)Jšœ0˜0Jšžœ˜—J˜šŸœž˜-Jšœžœ ˜)Jšœ1˜1Jšžœ˜—J˜šŸ œž˜)Jšœžœ ˜)Jšžœž˜JšžœM˜SJšžœK˜RJšžœžœ˜Jšžœ˜—J˜šŸœž˜+Jšœžœ ˜)Jšœ.˜.Jšžœ˜—J˜šŸ œž˜'Jšœžœ ˜)Jšœ+˜+Jšžœ˜J˜—šŸœž˜*Jšœžœ ˜)Jšœ žœžœ˜+šžœžœž˜JšœCžœ˜Hšœ9ž˜>š’œžœžœžœžœžœžœžœžœž˜RJšžœžœžœžœ˜š žœžœžœžœžœžœž˜3Jšžœžœžœžœžœ žœžœ žœ˜\Jšžœ˜—Jšžœ ˜Jšžœ˜—Jšœ žœ0˜>šœ,˜,Jšœ=˜=—Jšœ žœ@˜OJšžœ˜—Jšžœ˜—Jšœ9˜9Jšžœ˜—J˜šŸ œž˜(Jšœžœ ˜)Jšœ(˜(Jšžœ˜—J˜šŸœž˜,Jšœžœ ˜)Jšœ žœžœ˜+šžœžœž˜JšœFžœ˜Kšœ;ž˜Aš’œžœžœžœžœ žœžœžœ žœž˜wšžœžœž˜šœž˜šžœ!žœžœž˜4šžœ!žœž˜0šžœ ž˜Jšžœžœžœžœ˜Jšžœžœ9˜D——Jšžœ˜—Jšžœ4˜:Jšžœ˜—Jšžœžœ˜—Jšžœ˜—Jšœ žœ3˜AJšœžœ˜(JšœN˜Nšžœ žœžœ˜)Jšžœžœ˜8—Jšœ:˜:Jšœ žœ@˜OJšžœ˜—Jšžœ˜—Jšœ<˜