DIRECTORY Commander, EditToolBuilder, EditToolPrivate, IO, Menus, MessageWindow, Rope, Runtime, TEditInput, TextNode, UndoEvent, ViewerClasses, ViewerEvents, ViewerOps, ViewerSpecs ; EditToolTopImpl: CEDAR PROGRAM IMPORTS Commander, EditToolBuilder, EditToolPrivate, Menus, MessageWindow, Runtime, TEditInput, TextNode, ViewerEvents, ViewerOps EXPORTS EditToolPrivate = { OPEN ViewerSpecs, 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: BOOLEAN _ viewer = NIL; info: Info _ TextNode.pZone.NEW[InfoRec]; info.layout _ TextNode.pZone.NEW[LayoutRec]; IF ~mainEditTool THEN { -- one already exists IF viewer.iconic THEN ViewerOps.OpenIcon[viewer]; MessageWindow.Append["EditTool already exists",TRUE]; RETURN }; IF firstTime THEN firstTime _ FALSE ELSE ReRegister[]; { OPEN info; interrupt _ NEW[BOOLEAN _ 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; }; TRUSTED {IF Runtime.IsBound[Commander.Register] THEN Commander.Register["EditTool", InitToolCommand, "Create a Tioga Edit Tool"]}; [] _ InitToolCommand[NIL]; [] _ ViewerEvents.RegisterEventProc[MyDestroy, destroy]; }. .. >-- EditToolTopImpl.mesa; Edited by Paxton on December 30, 1982 10:26 am -- Edited by McGregor on September 21, 1982 3:20 pm Last Edited by: Maxwell, January 14, 1983 8:39 am Last Edited by: Plass, April 20, 1983 9:52 am -- Initialization --BuildPatternDocEntry[info];-- -- explaining special chars for patterns Ê ˜JšÏcG™GJš3™3J™1J™-šÏk ˜ J˜ J˜J˜Jšžœ˜J˜J˜J˜J˜J˜ J˜ J˜ J˜J˜ J˜ J˜ J˜J˜—Jšœž ˜J˜Jšžœz˜Jšžœ˜J˜Jšœžœ/˜5J˜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šžœžœ˜1Jšœ/žœ˜5Jšžœ˜ ——Jšžœ žœ žœžœ˜6J˜Jšœžœ˜ Jšœ žœžœžœ˜!J˜'J˜J˜+—šœ˜Jšœ˜4—š˜Jšœ˜.Jšœ˜3J˜3J˜*—š˜Jšœ#˜=J˜Jšœ-˜FJ˜Jšœ-˜HJ˜Jšœ!˜=J˜J˜J˜5J˜—š˜Jšœ0˜IJ˜—š˜Jšœ ˜%J˜—š˜Jšœ˜'J˜J˜5J˜—š˜Jšœ˜.J˜—š˜Jšœ=˜UJ˜—š˜Jšœ˜5J˜ Jšœ #˜CJ˜ Jšœ3˜OJ˜ J˜5J˜—š˜Jšœ˜7J˜—š˜Jšœ(™H—š˜J˜J˜GJ˜J˜J˜J˜˜J˜——šžœžœ%ž˜4J˜MJ˜—Jšœžœ˜J˜Jšœ8˜8J˜Jšœ˜J˜J˜J˜—…—p¹