DIRECTORY Commander USING [CommandProc, Register], EditToolBuilder USING [HRule, LayoutRec, ToMiddle, ToNext, VGap], EditToolPrivate USING [BuildExtraButtons, BuildFileListEntries, BuildGetAndSetOpsEntries, BuildInitCapEntry, BuildLooksButtons, BuildMiniPatternDocEntry, BuildOperationEntry, BuildOperationField, BuildPropertyButtons, BuildSearchButtons, BuildSortButtons, BuildSourceEntry, BuildStyleButtons, BuildSubstituteEntry, BuildTargetEntry, BuildTypeButtons, DoCountMenuButton, DoItMenuButton, DoNoMenuButton, DoSearchMenuButton, DoSubstituteMenuButton, DoYesMenuButton, Info, InfoRec], Menus USING [AppendMenuEntry, CreateEntry, CreateMenu, Menu, MenuProc], Rope USING [ROPE], TEditInput USING [CommandProc, Interpret, Register, UnRegister], TextNode USING [pZone], UndoEvent USING [Ref], ViewerClasses USING [Viewer], ViewerEvents USING [EventProc, RegisterEventProc], ViewerOps USING [CreateViewer, FindViewer, OpenIcon, SetOpenHeight]; EditToolTopImpl: CEDAR PROGRAM IMPORTS Commander, EditToolBuilder, EditToolPrivate, Menus, TEditInput, TextNode, ViewerEvents, ViewerOps EXPORTS EditToolPrivate = { OPEN EditToolBuilder, EditToolPrivate; Event: TYPE = UndoEvent.Ref; BuildContainer: PROC [info: Info, name: Rope.ROPE] = { OPEN info; viewer: ViewerClasses.Viewer; editToolMenu: Menus.Menu _ Menus.CreateMenu[]; Menus.AppendMenuEntry[editToolMenu, Menus.CreateEntry["Stop", Stop]]; Menus.AppendMenuEntry[editToolMenu, Menus.CreateEntry[name: "Search", proc: DoSearchMenuButton, fork: TRUE]]; Menus.AppendMenuEntry[editToolMenu, Menus.CreateEntry[name: "Substitute", proc: DoSubstituteMenuButton, fork: TRUE]]; Menus.AppendMenuEntry[editToolMenu, Menus.CreateEntry["Yes", DoYesMenuButton]]; Menus.AppendMenuEntry[editToolMenu, Menus.CreateEntry["No", DoNoMenuButton]]; Menus.AppendMenuEntry[editToolMenu, Menus.CreateEntry["Replace", DoItMenuButton]]; Menus.AppendMenuEntry[editToolMenu, Menus.CreateEntry[name: "Count", proc: DoCountMenuButton, fork: TRUE]]; layout.container _ viewer _ ViewerOps.CreateViewer[flavor: $Container, info: [name: name, iconic: TRUE, column: right, menu: editToolMenu, icon: LOOPHOLE[5]], paint: TRUE]; editTool _ viewer; -- save in global variable }; editTool: PUBLIC ViewerClasses.Viewer; MyDestroy: ViewerEvents.EventProc = { IF viewer#editTool THEN RETURN; -- filter mainToolInfo _ NIL; editTool _ NIL; UnRegister[]; }; Stop: Menus.MenuProc = { mainToolInfo.interrupt^ _ TRUE; }; ---------------------------- ChangeState: PUBLIC PROC [flag: BOOLEAN, trueList, falseList: LIST OF REF] = { DoButton[IF ~flag THEN trueList ELSE falseList] }; ---------------------------- CycleTriple: PUBLIC PROC [state: [0..2], list0, list1, list2: LIST OF REF] = { nextState: ARRAY [0..2] OF [0..2] = [1,2,0]; nextLIST: ARRAY [0..2] OF LIST OF REF = [list0, list1, list2]; DoButton[nextLIST[nextState[state]]] }; ---------------------------- DoButton: PUBLIC PROC [ redList, blueList: LIST OF REF _ NIL, redButton: BOOL _ FALSE, viewer: ViewerClasses.Viewer _ NIL] = { IF viewer=NIL THEN viewer _ mainToolInfo.targetArg; -- must be a text viewer IF ~redButton AND blueList#NIL THEN TEditInput.Interpret[viewer,blueList] ELSE TEditInput.Interpret[viewer,redList] }; ---------------------------- registered: LIST OF RegCom; RegCom: TYPE = RECORD [atom: ATOM, op: TEditInput.CommandProc]; Register: PUBLIC PROC [atom: ATOM, op: TEditInput.CommandProc] RETURNS [LIST OF REF] = { TEditInput.Register[atom, op]; registered _ CONS[[atom, op], registered]; RETURN [LIST[atom]] }; ReRegister: PROC = { FOR r: LIST OF RegCom _ registered, r.rest UNTIL r=NIL DO TEditInput.Register[r.first.atom, r.first.op]; ENDLOOP }; UnRegister: PROC = { FOR r: LIST OF RegCom _ registered, r.rest UNTIL r=NIL DO TEditInput.UnRegister[r.first.atom, r.first.op]; ENDLOOP }; mainToolInfo: PUBLIC Info; firstTime: BOOLEAN _ TRUE; InitToolCommand: Commander.CommandProc = { name: Rope.ROPE _ "EditTool"; viewer: ViewerClasses.Viewer _ ViewerOps.FindViewer[name]; mainEditTool: BOOL _ viewer = NIL; info: Info _ TextNode.pZone.NEW[InfoRec]; info.layout _ TextNode.pZone.NEW[LayoutRec]; IF ~mainEditTool THEN { IF viewer.iconic THEN ViewerOps.OpenIcon[viewer]; RETURN [NIL, "Opened existing Edit Tool."]}; IF firstTime THEN firstTime _ FALSE ELSE ReRegister[]; {OPEN info; interrupt _ NEW[BOOL _ FALSE]; layout.entryLeft _ layout.initLeft _ 0; layout.entryVSpace _ 3; layout.heightSoFar _ layout.initHeight _ 1; ---------------------------- BuildContainer[info,name]; -- build enclosing viewer ---------------------------- BuildTargetEntry[info]; -- the "target:" field BuildSourceEntry[info]; -- the "replacement:" field heights[0] _ layout.heightSoFar+layout.entryVSpace; layout.heightSoFar _ layout.heightSoFar+2; ---------------------------- BuildSearchButtons[info]; -- the various choices for seaching ToNext[layout]; BuildInitCapEntry[info]; -- Capitalize like first replaced char or not ToMiddle[layout]; BuildOperationEntry[info]; -- Do Replace / Do Operations Specified Below ToNext[layout]; BuildSubstituteEntry[info]; -- the within/after/entire choice ToNext[layout]; BuildMiniPatternDocEntry[info]; heights[1] _ layout.heightSoFar+layout.entryVSpace+1; HRule[layout]; ---------------------------- BuildLooksButtons[info]; -- caret/selection looks, Looks:, Get, Set, etc. ToNext[layout]; HRule[layout]; ---------------------------- BuildTypeButtons[info]; -- type names ToNext[layout]; HRule[layout]; ---------------------------- BuildStyleButtons[info]; -- style names ToNext[layout]; heights[2] _ layout.heightSoFar+layout.entryVSpace+1; HRule[layout]; ---------------------------- BuildPropertyButtons[info]; -- property values HRule[layout]; ---------------------------- BuildSortButtons[info]; -- Sort increasing/decreasing; sort text/lines/branches; Sort ToNext[layout]; HRule[layout]; ---------------------------- BuildOperationField[info]; -- the "Operations:" field VGap[layout]; BuildGetAndSetOpsEntries[info]; -- "GetLast" "SetCom" "GetCom" etc. VGap[layout]; BuildFileListEntries[info]; -- the "Files:" field and the DoForEachFile command VGap[layout]; heights[3] _ layout.heightSoFar+layout.entryVSpace+1; HRule[layout]; ---------------------------- BuildExtraButtons[info]; -- the low level edit commands HRule[layout]; ---------------------------- ---------------------------- currentHeightIndex _ 0; ViewerOps.SetOpenHeight[layout.container, heights[currentHeightIndex]]; }; mainToolInfo _ info; RETURN [NIL, "Created new Edit Tool."]; }; Commander.Register["EditTool", InitToolCommand, "Create a Tioga Edit Tool"]; [] _ InitToolCommand[NIL]; [] _ ViewerEvents.RegisterEventProc[MyDestroy, destroy]; }. .. ÄEditToolTopImpl.mesa Paxton on December 30, 1982 10:26 am McGregor on September 21, 1982 3:20 pm Maxwell, January 14, 1983 8:39 am Plass, April 20, 1983 9:52 am Russ Atkinson, September 29, 1983 11:02 am Doug Wyatt, January 13, 1984 3:55 pm -- Initialization [cmd: Handle] RETURNS [result: REF _ NIL, msg: Rope.ROPE _ NIL] an EditTool already exists, so flush the command --BuildPatternDocEntry[info];-- -- explaining special chars for patterns ÊW˜šÏc™Jš$™$Jš&™&J™!J™J™*J™$J™—šÏk ˜ Jšœ žœ˜(Jšœžœ,˜AJšœžœÉ˜ÞJšœžœ<˜GJšœžœžœ˜Jšœ žœ0˜@Jšœ žœ ˜Jšœ žœ˜Jšœžœ ˜Jšœ žœ ˜2Jšœ žœ5˜DJ˜—Jšœž ˜Jšžœb˜iJšžœ˜Jšœžœžœ"˜*J˜Jšœžœ˜J˜šÏnœžœžœžœ˜AJ˜J˜.J˜Ešœ#˜#JšœBžœ˜I—šœ#˜#JšœJžœ˜Q—JšœO˜OJšœM˜MJšœR˜Ršœ#˜#Jšœ@žœ˜G—˜FJšœžœ+žœ žœ˜e—Jšœ˜-J˜J˜—Jšœ žœ˜&J˜šœ%˜%Jšžœžœžœ ˜)Jšœžœ˜Jšœ žœ˜J˜ J˜J˜—˜Jšœžœ˜J˜J˜—Jš˜J˜šŸ œžœžœžœžœžœžœ˜NJšœ žœžœ žœ˜2J˜—Jš˜J˜š Ÿ œžœžœ&žœžœžœ˜NJšœ žœžœ˜,Jš œ žœžœžœžœžœ˜>J˜'J˜—Jš˜J˜šŸœžœžœ˜Jš œžœžœžœžœ˜%Jšœ žœžœ˜Jšœžœ˜'Jšžœžœžœ"˜LJšžœ žœ žœžœ&˜IJšžœ(˜,J˜—Jš˜J˜Jšœ žœžœ˜Jšœžœžœžœ˜?J˜šŸœžœžœžœžœžœžœžœ˜XJ˜Jšœ žœ˜*Jšžœžœ ˜J˜—šŸ œžœ˜š žœžœžœžœžœž˜9J˜.Jšžœ˜ J˜——šŸ œžœ˜š žœžœžœžœžœž˜9J˜0Jšžœ˜ J˜——Jš™J˜Jšœžœ˜Jšœ žœžœ˜J˜šœ*˜*Jšœ?™?Jšœ žœ˜J˜:Jšœžœ žœ˜"Jšœžœ ˜)Jšœžœ ˜,˜šžœžœ˜Jšœ0™0Jšžœžœ˜1Jšžœžœ!˜,——Jšžœ žœ žœžœ˜6J˜šœžœ˜ Jšœ žœžœžœ˜J˜'J˜J˜+Jšœ˜Jšœ˜4Jš˜Jšœ˜.Jšœ˜3J˜3J˜*Jš˜Jšœ#˜=J˜Jšœ-˜FJ˜Jšœ-˜HJ˜Jšœ!˜=J˜J˜J˜5J˜Jš˜Jšœ0˜IJ˜Jš˜Jšœ ˜%J˜Jš˜Jšœ˜'J˜J˜5J˜Jš˜Jšœ˜.J˜Jš˜Jšœ=˜UJ˜Jš˜Jšœ˜5J˜ Jšœ #˜CJ˜ Jšœ3˜OJ˜ J˜5J˜Jš˜Jšœ˜7J˜Jš˜Jšœ(™HJš˜J˜J˜GJ˜—J˜J˜Jšžœžœ˜'˜J˜——˜LJ˜—Jšœžœ˜J˜Jšœ8˜8J˜Jšœ˜J˜J˜J˜—…—"#