DIRECTORY Commander USING [CommandProc, Register], CommanderOps USING [Failed, NextArgument], Containers USING [ScrollOffset], Convert USING [AtomFromRope ], EditToolBuilder USING [HRule, LayoutRec, ToMiddle, ToNext, VGap], EditToolPrivate USING [BuildExtraButtons, BuildFileListEntries, BuildFormatButtons, BuildGetAndSetOpsEntries, BuildInitCapEntry, BuildLooksButtons, BuildMiniPatternDocEntry, BuildOperationEntry, BuildOperationField, BuildPropertyButtons, BuildRealExtraButtons, BuildRealFileListEntries, BuildRealFormatButtons, BuildRealGetAndSetOpsEntries, BuildRealLooksButtons, BuildRealPropertyButtons, BuildRealSortButtons, BuildRealStyleButtons, BuildRegisterButtons, BuildSearchButtons, BuildSortButtons, BuildSourceEntry, BuildStyleButtons, BuildSubstituteEntry, BuildTargetEntry, ButtonCommandRec, DoCountMenuButton, DoItMenuButton, DoNoMenuButton, DoSearchMenuButton, DoSubstituteMenuButton, DoYesMenuButton, HeightScheme, Info, InfoRec, LastHRule, maxNumHeights, numScrollRegions, otherField], EditToolOps, Menus USING [AppendMenuEntry, CopyEntry, FindEntry, SetClientData, CreateEntry, CreateMenu, GetLine, SetLine, MenuLine, MenuEntry, ChangeNumberOfLines, GetNumberOfLines, Menu, MenuProc], Rope USING [ROPE, Equal, Match], TiogaOps USING [CommandProc, RegisterCommand], TEditInput USING [CommandProc, Interpret, interrupt, Register, UnRegister], ViewerClasses USING [Column, Viewer, ViewerClass], ViewerEvents USING [EventProc, RegisterEventProc], ViewerLocks USING [CallUnderWriteLocks], ViewerBLT USING [ChangeNumberOfLines], ViewerOps USING [AddProp, ChangeColumn, ComputeColumn, CreateViewer, DestroyViewer, EnumerateViewers, EnumProc, GrowViewer, MoveBelowViewer, OpenIcon, PaintViewer, TopViewer, SetOpenHeight ]; EditToolTopImpl: CEDAR PROGRAM IMPORTS Commander, CommanderOps, Containers, Convert, EditToolBuilder, EditToolPrivate, TiogaOps, Menus, Rope, TEditInput, ViewerBLT, ViewerEvents, ViewerLocks, ViewerOps EXPORTS EditToolPrivate, EditToolOps = { OPEN EditToolBuilder, EditToolPrivate, EditToolOps; ROPE: TYPE ~ Rope.ROPE; registered: LIST OF RegCom ¬ NIL; additionalRegistered: LIST OF ButtonCommandRec ¬ NIL; RegCom: TYPE = RECORD [atom: ATOM, op: TEditInput.CommandProc]; editTool: PUBLIC ViewerClasses.Viewer; mainToolInfo: PUBLIC Info; BuildContainer: PROC [info: Info, name: ROPE, useRealNames: BOOL, useAuxMenu: BOOL] RETURNS [viewer: ViewerClasses.Viewer] = { OPEN info; editToolMenu: Menus.Menu ¬ Menus.CreateMenu[2]; scrollSectionInfo[0].name ¬ "Subs"; scrollSectionInfo[0].entryNum ¬ 0; scrollSectionInfo[1].name ¬ "Looks"; scrollSectionInfo[1].entryNum ¬ 1; scrollSectionInfo[2].name ¬ "Format"; scrollSectionInfo[2].entryNum ¬ 2; scrollSectionInfo[3].name ¬ "Style"; scrollSectionInfo[3].entryNum ¬ 3; scrollSectionInfo[4].name ¬ "Property"; scrollSectionInfo[4].entryNum ¬ 4; scrollSectionInfo[5].name ¬ "Sort"; scrollSectionInfo[5].entryNum ¬ 5; scrollSectionInfo[6].name ¬ "Operations"; scrollSectionInfo[6].entryNum ¬ 6; scrollSectionInfo[7].name ¬ "Others"; scrollSectionInfo[7].entryNum ¬ 7; 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]]; Menus.AppendMenuEntry[editToolMenu, Menus.CreateEntry["Sections", DoScrollToOpsMenuButton, NEW[ BOOL ¬ useAuxMenu ]]]; -- clientData says whether subMenu available. Menus.AppendMenuEntry[editToolMenu, Menus.CreateEntry["RealOps", DoRealNamesMenuButton, NEW[ BOOL ¬ useRealNames]]]; -- clientData says whether realNames used. FOR i: NAT IN [0..EditToolPrivate.numScrollRegions) DO Menus.AppendMenuEntry[editToolMenu, Menus.CreateEntry[scrollSectionInfo[i].name, DoScrollToMenuButton, NEW[INTEGER ¬ info.scrollSectionInfo[i].entryNum]], 1]; ENDLOOP; goToSectionMenu ¬ Menus.GetLine[editToolMenu, 1]; IF ~useAuxMenu THEN Menus.ChangeNumberOfLines[editToolMenu, 1]; layout.container ¬ viewer ¬ ViewerOps.CreateViewer[flavor: $Container, info: [name: name, iconic: TRUE, column: right, menu: editToolMenu, icon: VAL[5]], paint: TRUE]; editTool ¬ viewer; -- save in global variable }; ChangeEditToolPanel: PROC [viewer: ViewerClasses.Viewer, realNamePanel: BOOL] = { class: ViewerClasses.ViewerClass ¬ viewer.class; menu: Menus.Menu ¬ viewer.menu; opened: BOOL ¬ ~viewer.iconic; clientData: REF ANY¬ Menus.SetClientData[ Menus.FindEntry[ menu, "Sections"], NIL ]; data: REF BOOL ¬ NARROW[clientData]; auxMenuAvail: BOOL ¬ data­; whichHeightScheme: EditToolPrivate.HeightScheme ¬ mainToolInfo.whichHeightScheme; currentHeightIndex: [0..EditToolPrivate.maxNumHeights) ¬ mainToolInfo.currentHeightIndex; oldScrollOffset: INTEGER ¬ ABS[ Containers.ScrollOffset[ viewer ] ]; scrollOffset, offset: INTEGER; height: INTEGER; onlyViewerInColumn: BOOL ¬ TRUE; column: ViewerClasses.Column ¬ viewer.column; viewerAbove: ViewerClasses.Viewer ¬ viewer.sibling; -- sibling chains the viewers of a column bottom up. FindViewerLocation: ViewerOps.EnumProc ~ { IF v.column = viewer.column AND NOT v.iconic AND NOT Rope.Equal[viewer.name, v.name] THEN onlyViewerInColumn ¬ FALSE; }; FOR heightIndex: INTEGER IN [0..numScrollRegions) DO IF oldScrollOffset = mainToolInfo.scrollSectionInfo[heightIndex].startLocation THEN { offset ¬ 0; EXIT; }; ENDLOOP; IF offset # 0 THEN offset ¬ oldScrollOffset - mainToolInfo.scrollSectionInfo[currentHeightIndex].startLocation; ViewerOps.EnumerateViewers[ FindViewerLocation ]; ViewerOps.DestroyViewer[ viewer, TRUE ]; -- viewer information is no longer useful, editTool has new viewer value and mainToolInfo has new info. ReRegister[]; ReRegisterAdditional[]; [mainToolInfo, editTool] ¬ DrawPanelViewer[realNamePanel, auxMenuAvail]; viewer ¬ editTool; mainToolInfo.currentHeightIndex ¬ currentHeightIndex; mainToolInfo.whichHeightScheme ¬ whichHeightScheme; scrollOffset ¬ mainToolInfo.scrollSectionInfo[currentHeightIndex].startLocation + offset; IF scrollOffset < 0 THEN scrollOffset ¬ 0; IF whichHeightScheme = fixed THEN height ¬ mainToolInfo.heights[0] ELSE height ¬ mainToolInfo.scrollSectionInfo[currentHeightIndex].height; [] ¬ class.scroll[ self: viewer, op: up, amount: scrollOffset ]; ViewerOps.SetOpenHeight[viewer, height]; IF viewer.column # column THEN ViewerOps.ChangeColumn[ viewer, column ]; IF opened THEN ViewerOps.OpenIcon[ icon: viewer, paint: FALSE ]; IF onlyViewerInColumn THEN ViewerOps.GrowViewer[ viewer ] ELSE IF viewerAbove = NIL THEN ViewerOps.TopViewer[ viewer ] ELSE ViewerOps.MoveBelowViewer[ altered: viewer, static: viewerAbove ]; }; DoRealNamesMenuButton: PUBLIC Menus.MenuProc = { viewer: ViewerClasses.Viewer ¬ NARROW[parent]; menu: Menus.Menu ¬ viewer.menu; data: REF BOOL ¬ NARROW[ clientData ]; useRealNames: BOOL ¬ ~data­; -- Toggled, reflects the new intended value. ChangeEditToolPanel[ viewer, useRealNames ]; }; DoScrollToOpsMenuButton: PUBLIC Menus.MenuProc = { viewer: ViewerClasses.Viewer ¬ NARROW[parent]; menu: Menus.Menu ¬ viewer.menu; data: REF BOOL ¬ NARROW[ clientData ]; menuNowAvail: BOOL ¬ ~data­; -- Toggled, reflects the new intended value. newLines: Menus.MenuLine ¬ Menus.GetNumberOfLines[menu]; [] ¬ Menus.SetClientData[ Menus.FindEntry[ menu, "Sections"], NEW[BOOL ¬ menuNowAvail ]]; IF menuNowAvail THEN { Menus.SetLine[menu, 2, mainToolInfo.goToSectionMenu]; newLines ¬ newLines+1; } ELSE -- yes, so remove it newLines ¬ newLines-1; ViewerBLT.ChangeNumberOfLines[viewer, newLines]; }; DoScrollToMenuButton: PUBLIC Menus.MenuProc = { viewer: ViewerClasses.Viewer ¬ NARROW[parent]; scrollRegion: INTEGER ¬ NARROW[ clientData, REF INTEGER ]­; amount: INTEGER; scrollOffset: INTEGER ¬ ABS[ Containers.ScrollOffset[ viewer ] ]; class: ViewerClasses.ViewerClass ¬ viewer.class; IF mouseButton = blue THEN { IF mainToolInfo.currentHeightIndex # scrollRegion OR mainToolInfo.whichHeightScheme = fixed THEN { mainToolInfo.currentHeightIndex ¬ scrollRegion; ViewerOps.SetOpenHeight[ viewer, mainToolInfo.scrollSectionInfo[scrollRegion].height ]; ViewerOps.ComputeColumn[ viewer.column, TRUE ]; }; IF mainToolInfo.whichHeightScheme = fixed THEN mainToolInfo.whichHeightScheme ¬ variable; } ELSE IF mouseButton = red THEN { IF mainToolInfo.currentHeightIndex # scrollRegion THEN mainToolInfo.currentHeightIndex ¬ scrollRegion; IF mainToolInfo.whichHeightScheme = variable THEN { mainToolInfo.whichHeightScheme ¬ fixed; ViewerOps.SetOpenHeight[ viewer, mainToolInfo.heights[0] ]; ViewerOps.ComputeColumn[ viewer.column, TRUE ]; }; }; IF scrollOffset > mainToolInfo.scrollSectionInfo[scrollRegion].startLocation THEN { amount ¬ scrollOffset - mainToolInfo.scrollSectionInfo[scrollRegion].startLocation; [] ¬ class.scroll[ self: viewer, op: down, amount: amount ] } ELSE IF scrollOffset < mainToolInfo.scrollSectionInfo[scrollRegion].startLocation THEN { amount ¬ mainToolInfo.scrollSectionInfo[scrollRegion].startLocation - scrollOffset; [] ¬ class.scroll[ self: viewer, op: up, amount: amount ] }; }; MyDestroy: ViewerEvents.EventProc = { IF viewer#editTool THEN RETURN; -- filter mainToolInfo ¬ NIL; editTool ¬ NIL; UnRegister[]; UnRegisterAdditional[]; }; Stop: Menus.MenuProc = { mainToolInfo.interrupt­ ¬ TRUE; }; ChangeState: PUBLIC PROC [flag: BOOL, trueList, falseList: LIST OF REF] = { DoButton[IF ~flag THEN trueList ELSE falseList] }; CycleTriple: PUBLIC PROC [state: [0..2], list0, list1, list2: LIST OF REF] = { next: ARRAY [0..3) OF LIST OF REF ~ [list1, list2, list0]; DoButton[next[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] }; Register: PUBLIC PROC [atom: ATOM, op: TEditInput.CommandProc] RETURNS [LIST OF REF] = { 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 }; RegisterAdditional: PROC [name: ROPE, proc: TiogaOps.CommandProc, before: BOOL ¬ TRUE, startNextLine: BOOL ¬ TRUE] = { viewer: ViewerClasses.Viewer ¬ editTool; noMainEditTool: BOOL ¬ viewer = NIL; registerButtonCommand: LIST OF ButtonCommandRec ¬ NIL; menu: Menus.Menu; menuEntry: Menus.MenuEntry; clientData: REF ANY; data: REF BOOL; menuNowAvail: BOOL; atom: ATOM ¬ Convert.AtomFromRope[ name ]; exists: BOOL ¬ FALSE; DrawUpdates: PROC = { scrollOffset: INTEGER ¬ Containers.ScrollOffset[viewer]; ViewerOps.DestroyViewer[ viewer: mainToolInfo.lastRule, paint: FALSE ]; -- destroy rule mainToolInfo.layout ¬ NEW[ EditToolBuilder.LayoutRec ¬ mainToolInfo.lastLayout]; mainToolInfo.layout.heightSoFar ¬ mainToolInfo.lastLayout.heightSoFar + scrollOffset; EditToolPrivate.BuildRegisterButtons[mainToolInfo, registerButtonCommand]; mainToolInfo.lastLayout ¬ mainToolInfo.layout­; mainToolInfo.lastLayout.heightSoFar ¬ mainToolInfo.layout.heightSoFar - scrollOffset; ToNext[mainToolInfo.layout, TRUE]; mainToolInfo.lastRule ¬ LastHRule[info: mainToolInfo.layout]; mainToolInfo.layout.heightSoFar ¬ mainToolInfo.layout.heightSoFar - scrollOffset; mainToolInfo.scrollSectionInfo[EditToolPrivate.otherField].height ¬ mainToolInfo.layout.heightSoFar - mainToolInfo.scrollSectionInfo[EditToolPrivate.otherField].startLocation; ViewerOps.PaintViewer[ viewer: viewer, hint: client ]; }; TiogaOps.RegisterCommand[ atom, proc, TRUE]; FOR r: LIST OF ButtonCommandRec ¬ additionalRegistered, r.rest UNTIL r=NIL DO IF Rope.Equal[r.first.name, name] THEN { exists ¬ TRUE; r.first.commandOp ¬ proc; EXIT; }; ENDLOOP; IF ~exists THEN { IF additionalRegistered = NIL THEN registerButtonCommand ¬ CONS[ [name, atom, LIST[atom], proc, before, FALSE, NIL], registerButtonCommand] ELSE registerButtonCommand ¬ CONS[ [name, atom, LIST[atom], proc, before, startNextLine, NIL], registerButtonCommand]; additionalRegistered ¬ CONS[registerButtonCommand.first, additionalRegistered]; }; IF noMainEditTool OR exists THEN RETURN; menu ¬ viewer.menu; menuEntry ¬ Menus.CopyEntry[ Menus.FindEntry[ menu, "Sections"] ]; clientData ¬ Menus.SetClientData[ menuEntry, NIL]; -- only way to query the clientData without affecting it. data ¬ NARROW[ clientData ]; menuNowAvail ¬ data­; ViewerLocks.CallUnderWriteLocks[DrawUpdates, viewer]; IF ~viewer.iconic AND menuNowAvail AND mainToolInfo.whichHeightScheme = variable AND mainToolInfo.currentHeightIndex = EditToolPrivate.otherField THEN { ViewerOps.SetOpenHeight[ viewer, mainToolInfo.scrollSectionInfo[EditToolPrivate.otherField].height ]; ViewerOps.ComputeColumn[ viewer.column, TRUE ]; }; }; ReRegisterAdditional: PROC = { FOR r: LIST OF ButtonCommandRec ¬ additionalRegistered, r.rest UNTIL r=NIL DO TiogaOps.RegisterCommand[ r.first.atom, r.first.commandOp, r.first.before ]; ENDLOOP}; UnRegisterAdditional: PROC = { FOR r: LIST OF ButtonCommandRec ¬ additionalRegistered, r.rest UNTIL r=NIL DO TEditInput.UnRegister[r.first.atom, r.first.commandOp]; ENDLOOP}; -------------------------- ClearAllNewCommandButtons: PUBLIC PROC = { toolViewer: ViewerClasses.Viewer ¬ editTool; noMainEditTool: BOOL ¬ toolViewer = NIL; menu: Menus.Menu; menuEntry: Menus.MenuEntry; clientData: REF ANY; data: REF BOOL; menuNowAvail: BOOL; destroyNewCommandButton: PROC= { scrollOffset: INTEGER ¬ Containers.ScrollOffset[toolViewer]; FOR r: LIST OF ButtonCommandRec ¬ additionalRegistered, r.rest UNTIL r=NIL DO ViewerOps.DestroyViewer[ viewer: r.first.viewer, paint: FALSE ]; -- destroy buttons ENDLOOP; ViewerOps.DestroyViewer[ viewer: mainToolInfo.lastRule, paint: FALSE ]; -- destroy rule mainToolInfo.layout ¬ NEW[ EditToolBuilder.LayoutRec ¬ mainToolInfo.layoutBeforeExtraCommandButtons ]; mainToolInfo.lastLayout ¬ mainToolInfo.layoutBeforeExtraCommandButtons; mainToolInfo.layout.heightSoFar ¬ mainToolInfo.lastLayout.heightSoFar + scrollOffset; mainToolInfo.lastRule ¬ LastHRule[info: mainToolInfo.layout]; -- draw new rule mainToolInfo.lastLayout.heightSoFar ¬ mainToolInfo.layout.heightSoFar ¬ mainToolInfo.lastLayout.heightSoFar - scrollOffset; mainToolInfo.scrollSectionInfo[EditToolPrivate.otherField].height ¬ mainToolInfo.layout.heightSoFar - mainToolInfo.scrollSectionInfo[EditToolPrivate.otherField].startLocation; ViewerOps.PaintViewer[ viewer: toolViewer, hint: client ]; }; IF noMainEditTool THEN RETURN; menu ¬ toolViewer.menu; menuEntry ¬ Menus.CopyEntry[ Menus.FindEntry[ menu, "Sections"] ]; clientData ¬ Menus.SetClientData[ menuEntry, NIL]; -- only way to query the clientData without affecting it. data ¬ NARROW[ clientData ]; menuNowAvail ¬ data­; ViewerLocks.CallUnderWriteLocks[destroyNewCommandButton, toolViewer]; IF ~toolViewer.iconic AND menuNowAvail AND mainToolInfo.whichHeightScheme = variable AND mainToolInfo.currentHeightIndex = EditToolPrivate.otherField THEN { ViewerOps.SetOpenHeight[ toolViewer, mainToolInfo.scrollSectionInfo[EditToolPrivate.otherField].height ]; ViewerOps.ComputeColumn[ toolViewer.column, TRUE ]; }; UnRegisterAdditional[]; additionalRegistered ¬ NIL; }; RegisterCommandButton: PUBLIC PROC [buttonName: ROPE, proc: TiogaOps.CommandProc, before: BOOL ¬ TRUE, startNextLine: BOOL ¬ TRUE] = { RegisterAdditional[ buttonName, proc, before, startNextLine ]}; EditToolCommand: Commander.CommandProc = { viewer: ViewerClasses.Viewer ¬ editTool; aMainEditTool: BOOL ¬ viewer # NIL; menu: Menus.Menu; menuEntry: Menus.MenuEntry; clientData: REF ANY; data: REF BOOL; useRealNames: BOOL ¬ FALSE; wantsRealNames: BOOL ¬ FALSE; wantsIconic: BOOL ¬ FALSE; FOR arg: ROPE _ CommanderOps.NextArgument[cmd], CommanderOps.NextArgument[cmd] UNTIL arg = NIL DO SELECT TRUE FROM Rope.Match[arg, "-realnames", FALSE] => wantsRealNames _ TRUE; Rope.Match[arg, "-iconic", FALSE] => wantsIconic _ TRUE; ENDCASE => CommanderOps.Failed[cmd.procData.doc]; ENDLOOP; IF aMainEditTool THEN { menu ¬ viewer.menu; menuEntry ¬ Menus.CopyEntry[ Menus.FindEntry[ menu, "RealOps"] ]; clientData ¬ Menus.SetClientData[ menuEntry, NIL]; -- only way to query the clientData without affecting it. data ¬ NARROW[ clientData ]; useRealNames ¬ data­; IF wantsRealNames = useRealNames THEN { IF viewer.iconic AND NOT wantsIconic THEN ViewerOps.OpenIcon[viewer]; RETURN[NIL, "An Edit Tool already exists."]; } ELSE { ChangeEditToolPanel[ viewer, wantsRealNames ]; -- mainToolInfo and editTool will be reinitialized. [] ¬ Menus.SetClientData[Menus.FindEntry[ menu, "RealOps"], NEW[BOOL ¬ wantsRealNames]]; -- Record new value in the clientData associated with RealNames. RETURN [NIL, "Changed the Edit Tool pane."]; } } ELSE { ReRegister[]; ReRegisterAdditional[]; [mainToolInfo, editTool] ¬ DrawPanelViewer[wantsRealNames, TRUE]; RETURN [NIL, "Created new Edit Tool."]; }; }; DrawPanelViewer: PROC [useRealNames: BOOL, useAuxMenu: BOOL] RETURNS [info:Info, viewer: ViewerClasses.Viewer] = { lastHeightSoFar: INTEGER; info ¬ NEW[InfoRec]; info.layout ¬ NEW[LayoutRec]; {OPEN info; BuildRealContents: PROC[] = { scrollSectionInfo[1].startLocation ¬ layout.heightSoFar; EditToolPrivate.BuildRealLooksButtons[info]; -- caret/selection looks, Looks:, Get, Set, etc. ToNext[layout]; scrollSectionInfo[1].height ¬ layout.heightSoFar - lastHeightSoFar; HRule[layout]; lastHeightSoFar ¬ layout.heightSoFar; -------------------------- scrollSectionInfo[2].startLocation ¬ layout.heightSoFar; EditToolPrivate.BuildRealFormatButtons[info]; ToNext[layout]; scrollSectionInfo[2].height ¬ layout.heightSoFar - lastHeightSoFar; HRule[layout]; lastHeightSoFar ¬ layout.heightSoFar; scrollSectionInfo[3].startLocation ¬ layout.heightSoFar; EditToolPrivate.BuildRealStyleButtons[info]; ToNext[layout]; heights[2] ¬ layout.heightSoFar+layout.entryVSpace+1; scrollSectionInfo[3].height ¬ layout.heightSoFar - lastHeightSoFar; HRule[layout]; lastHeightSoFar ¬ layout.heightSoFar; scrollSectionInfo[4].startLocation ¬ layout.heightSoFar; EditToolPrivate.BuildRealPropertyButtons[info]; -- property values scrollSectionInfo[4].height ¬ layout.heightSoFar - lastHeightSoFar; HRule[layout]; lastHeightSoFar ¬ layout.heightSoFar; scrollSectionInfo[5].startLocation ¬ layout.heightSoFar; EditToolPrivate.BuildRealSortButtons[info]; -- Sort increasing/decreasing; sort text/lines/branches; Sort ToNext[layout]; scrollSectionInfo[5].height ¬ layout.heightSoFar - lastHeightSoFar; HRule[layout]; lastHeightSoFar ¬ layout.heightSoFar; scrollSectionInfo[6].startLocation ¬ layout.heightSoFar; BuildOperationField[info]; -- the "Operations:" field VGap[layout]; BuildRealGetAndSetOpsEntries[info]; -- "GetLast" "SetCom" "GetCom" etc. VGap[layout]; BuildRealFileListEntries[info]; -- the "Files:" field and the DoForEachFile command VGap[layout]; heights[3] ¬ layout.heightSoFar+layout.entryVSpace+1; scrollSectionInfo[6].height ¬ layout.heightSoFar - lastHeightSoFar; HRule[layout]; lastHeightSoFar ¬ layout.heightSoFar; scrollSectionInfo[7].startLocation ¬ layout.heightSoFar; EditToolPrivate.BuildRealExtraButtons[info]; -- the low level edit -------------------------- }; BuildContents: PROC[] = { scrollSectionInfo[1].startLocation ¬ layout.heightSoFar; BuildLooksButtons[info]; -- caret/selection looks, Looks:, Get, Set, etc. ToNext[layout]; scrollSectionInfo[1].height ¬ layout.heightSoFar - lastHeightSoFar; HRule[layout]; lastHeightSoFar ¬ layout.heightSoFar; -------------------------- scrollSectionInfo[2].startLocation ¬ layout.heightSoFar; BuildFormatButtons[info]; -- format names ToNext[layout]; scrollSectionInfo[2].height ¬ layout.heightSoFar - lastHeightSoFar; HRule[layout]; lastHeightSoFar ¬ layout.heightSoFar; scrollSectionInfo[3].startLocation ¬ layout.heightSoFar; BuildStyleButtons[info]; -- style names ToNext[layout]; heights[2] ¬ layout.heightSoFar+layout.entryVSpace+1; scrollSectionInfo[3].height ¬ layout.heightSoFar - lastHeightSoFar; HRule[layout]; lastHeightSoFar ¬ layout.heightSoFar; scrollSectionInfo[4].startLocation ¬ layout.heightSoFar; BuildPropertyButtons[info]; -- property values scrollSectionInfo[4].height ¬ layout.heightSoFar - lastHeightSoFar; HRule[layout]; lastHeightSoFar ¬ layout.heightSoFar; scrollSectionInfo[5].startLocation ¬ layout.heightSoFar; BuildSortButtons[info]; -- Sort increasing/decreasing; sort text/lines/branches; Sort ToNext[layout]; scrollSectionInfo[5].height ¬ layout.heightSoFar - lastHeightSoFar; HRule[layout]; lastHeightSoFar ¬ layout.heightSoFar; scrollSectionInfo[6].startLocation ¬ layout.heightSoFar; 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; scrollSectionInfo[6].height ¬ layout.heightSoFar - lastHeightSoFar; HRule[layout]; lastHeightSoFar ¬ layout.heightSoFar; scrollSectionInfo[7].startLocation ¬ layout.heightSoFar; BuildExtraButtons[info]; -- the low level edit -------------------------- }; interrupt ¬ TEditInput.interrupt; layout.entryLeft ¬ layout.initLeft ¬ 0; layout.entryVSpace ¬ 3; scrollSectionInfo[0].startLocation ¬ lastHeightSoFar ¬ layout.heightSoFar ¬ layout.initHeight ¬ 1; viewer ¬ BuildContainer[info, "EditTool", useRealNames, useAuxMenu]; -- 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, useRealNames]; -- the various choices for seaching ToNext[layout]; BuildInitCapEntry[info, useRealNames]; -- Capitalize like first replaced char or not ToMiddle[layout]; BuildOperationEntry[info, useRealNames]; -- Do Replace / Do Operations Specified Below ToNext[layout]; BuildSubstituteEntry[info, useRealNames]; -- the within/after/entire choice ToNext[layout]; BuildMiniPatternDocEntry[info]; scrollSectionInfo[0].height ¬ heights[1] ¬ layout.heightSoFar+layout.entryVSpace+1; HRule[layout]; lastHeightSoFar ¬ layout.heightSoFar; -------------------------- IF useRealNames THEN BuildRealContents[] ELSE BuildContents[]; -------------------------- ToNext[layout, TRUE]; lastLayout ¬ layout­; layoutBeforeExtraCommandButtons ¬ layout­; IF additionalRegistered # NIL THEN { EditToolPrivate.BuildRegisterButtons[info, additionalRegistered]; lastLayout ¬ layout­; ToNext[layout, TRUE]; }; lastRule ¬ LastHRule[layout]; scrollSectionInfo[7].height ¬ layout.heightSoFar - lastHeightSoFar; whichHeightScheme ¬ fixed; currentHeightIndex ¬ 0; ViewerOps.SetOpenHeight[layout.container, heights[currentHeightIndex]]; }; -- of open info. ViewerOps.AddProp[ viewer, $EditTool, info ]; -- save the info structure away in the viewer so other tools can get at them. }; Commander.Register["EditTool", EditToolCommand, "Create a Tioga Edit Tool\nswitches:\n -realnames - use alternate panel\n -iconic - create as icon"]; [] ¬ ViewerEvents.RegisterEventProc[MyDestroy, destroy]; }. j EditToolTopImpl.mesa Copyright Σ 1985, 1986, 1990, 1991, 1992 by Xerox Corporation. All rights reserved. Michael Plass, October 8, 1991 12:22 pm PDT Russ Atkinson (RRA) June 18, 1985 5:08:56 pm PDT Alison Lee September 10, 1986 2:58:07 pm PDT Swinehart, November 14, 1986 10:11:06 am PST Bier, July 26, 1991 11:18 am PDT Doug Wyatt, March 25, 1992 4:59 pm PST Don't want the aux menu to show, so show only the top level to start. What portion was visible in a viewer. Set things back to the right section if we were previously over the beginning of a section. If not over the beginning of a section, determine its offset from the section it was last known to be so that we can be back in the same proximity. Draw new alternate panel, leaving realNames, auxMenuAvail same as before. Restore previous state information to the best of our ability, e.g. height, opened, proper column, slide it back to same place within a column. Must open the tool at the same column it was before. Restore the viewer to its right location. Toggle the clientData value. add it. Want variable height Scheme, do it if it is not the same. Want to Revert to a fixed height Scheme, use heights[0] value. must scroll down to get to whereToScrollTo must scroll up to get to whereToScrollTo -------------------------- -------------------------- -------------------------- -------------------------- TEditInput.Register[atom, op]; -------------------------- Check to see if it exists. just change the reference to the proc. Record it for the future. Never start a New Line since it already happened for the first additional button Don't bother to update if the EditTool viewer doesn't exist or the command already appears. an EditTool already exists, so update by first removing the LastHRule and last ToNext Adjust height if viewer is on, user is using scrollToOps menu, using variable height, and portion visible is in the other buttons area. Back up mainTool.layout to the end of Standard Registered Command Return if the EditTool viewer does not exists, otherwise destroy the viewers Adjust height, user is using scrollToOps menu, using variable height, and portion visible is in the operations area. Unregister the Commands and set additionalRegistered to NIL [cmd: Handle] RETURNS [result: REF _ NIL, msg: ROPE _ NIL] An EditTool already exists. The desired editTool panel already exist, just flush the command. Same as selecting the RealNames button in the menu but from command line, switch panes. No EditTool exists as yet, create a whole new one. [] _ NoteNewEditToolCommand[cmd]; NoteNewEditToolCommand: Commander.CommandProc = { line: ROPE _ UserProfile.Line["EditTool.NewTool", NIL]; IF line # NIL THEN [] _ CommandTool.DoCommand[line, cmd]; }; -------------------------- -------------------------- -------------------------- -------------------------- -------------------------- -------------------------- -------------------------- -------------------------- -------------------------- -------------------------- -------------------------- -------------------------- -------------------------- Save the information in info.layout, in case additional buttons get added later -------------------------- --BuildPatternDocEntry[info];-- -- explaining special chars for patterns -------------------------- -- Initialization Commander.Register["NoteNewEditTool", NoteNewEditToolCommand, "Executes the EditTool.NewTool user profile item."]; Κ7–"cedarcode" style•NewlineDelimiter ™codešœ™Kšœ ΟeœI™TK™+K™0K™,K™,K™ K™&K™—šΟk ˜ Kšœ žœ˜(Kšœ žœ˜*Kšœ žœ˜ Kšœžœ˜Kšœžœ,˜AKšœžœžΠnrœΜ˜“K˜ Kšœžœ―˜ΊKšœžœžœ˜ Kšœ žœ ˜.Kšœ žœ;˜KKšœžœ˜2Kšœ žœ ˜2Kšœ žœ˜(Kšœ žœ˜&Kšœ žœˆŸ œ˜Ώ—K˜KšΟnœžœž˜Kšžœ€˜«Kšžœ˜$Kšœžœ/˜7K˜šžœžœžœ˜K˜—Kšœ žœžœ žœ˜!Kšœžœžœžœ˜5K˜Kšœžœžœžœ˜?K˜Kšœ žœ˜&Kšœžœ˜K˜Kš  œžœžœžœžœžœ!˜|šœžœ˜ K˜/Kšœ#˜#Kšœ"˜"Kšœ$˜$Kšœ"˜"Kšœ%˜%Kšœ"˜"Kšœ$˜$Kšœ"˜"Kšœ'˜'Kšœ"˜"Kšœ#˜#Kšœ"˜"Kšœ)˜)Kšœ"˜"Kšœ%˜%Kšœ"˜"K˜Ešœ#˜#KšœBžœ˜I—šœ#˜#KšœJžœ˜Q—KšœO˜OKšœM˜MKšœR˜Ršœ#˜#Kšœ@žœ˜G—Kšœ[žœžœΟc-˜€KšœXžœžœ‘*˜Ÿšžœžœžœ'ž˜6Kšœgžœžœ,˜žKšžœ˜K˜—Kšœ1˜1K™Ešžœ žœ,˜?K˜—Kš œHœΟbΠbkœ+žœžœ˜©Kšœ‘˜-K˜K˜—š œžœ/žœ˜QKšœ0˜0Kšœ˜Kšœžœ˜Kšœ žœžœ;žœ˜TKšœžœžœ ˜$Kšœžœ ˜K˜QKšœY˜YKšœžœžœ&˜DKšœžœ˜Kšœžœ˜Kšœžœž˜ K˜-Kšœ5‘4˜iK˜š œ˜*Kšžœžœžœ žœžœ!žœžœ˜uK˜—K˜K™%šžœžœžœž˜4šžœL˜Nšžœ˜K™[Kšœ ž˜ Kšž˜K˜——Kšžœ˜—K™“Kšžœ žœ]˜oK˜Kšœ1˜1K˜Kšœ*‘g˜‘K˜K™IK˜ K˜KšŸœŸœ-˜HK˜K˜K™Kšœ5˜5Kšœ3˜3KšœY˜YKšžœžœ˜*šžœžœ!˜BKšžœD˜H—Kšœ@˜@Kšœ(˜(Kšžœžœ*˜HK˜K™4Kšžœžœ*žœ˜@K˜K™)šžœžœ˜9Kšžœžœžœžœ˜žœžœ˜Yšžœ ˜šžœ˜Kšœ ™ Kšœ5˜5K˜Kšœ˜—šžœ‘˜Kšœ˜——K˜0K˜—K˜š œžœ˜/Kšœžœ ˜.Kš œžœžœžœžœ˜;Kšœž˜Kšœžœžœ&˜AKšœ0˜0K˜šžœ˜šžœ˜K™9šžœ0žœ&˜[šžœ˜Kšœ/˜/KšœW˜WKšœ(ž˜/K˜——Kšžœ'žœ+˜YK˜—šžœžœ˜šœžœ˜Kšœ>™>šžœ/˜1Kšžœ0˜4—šžœ*˜,šžœ˜Kšœ'˜'Kšœ;˜;Kšœ(ž˜/K˜——K˜———šžœJ˜Lšžœ˜K™*KšœS˜SKšœ;˜;K˜—šžœžœJ˜Qšžœ˜Kšœ(™(KšœS˜SKšœ9˜9K˜———K˜—K˜š  œ˜%Kšžœžœžœ‘ ˜)Kšœžœ˜Kšœ žœ˜K˜ K˜K˜K˜—š œ˜Kšœžœ˜K˜K˜—Kšœ™K˜š  œžœžœžœžœžœžœ˜KKšœ žœžœ žœ˜2K˜—Kšœ™K˜š   œžœžœ&žœžœžœ˜NKš œžœžœžœžœžœ˜:Kšœ˜K˜—Kšœ™K˜š œžœžœ˜Kš œžœžœžœžœ˜%Kšœ žœžœ˜Kšœžœ˜'Kšžœžœžœ"‘˜LKšžœ žœ žœžœ&˜IKšžœ(˜,K˜—Kšœ™K˜š œžœžœžœžœžœžœžœ˜XKšΟy™Kšœ žœ˜*Kšžœžœ ˜K˜—š  œžœ˜š žœžœžœžœžœž˜9K˜.Kšžœ˜ K˜——š  œžœ˜š žœžœžœžœžœž˜9K˜0Kšžœ˜ ——K˜Kšœ™K˜š œžœžœ&žœžœžœžœ˜vK˜(Kšœžœ žœ˜$Kšœžœžœžœ˜6K˜Kšœ˜Kšœ žœžœ˜Kšœžœžœ˜Kšœžœ˜Kšœžœ ˜*Kšœžœž˜K˜š  œžœ˜Kšœžœ#˜8Kšœ?žœ€˜XKšœžœ7˜PKšœU˜UKšœJ˜JKšœ/˜/KšœU˜UKšœžœ˜"Kšœ=˜=KšœQ˜QKšœ―˜―Kšœ6˜6K˜K˜—Kšœ&žœ˜,K˜K™š žœžœžœ1žœžœž˜Mšžœžœ˜(K™&Kšœ žœ˜Kšœ˜Kšžœ˜Kšœ˜—Kšžœ˜K˜—šžœž˜K™K™Pšžœžœžœ˜#Kš œžœžœžœžœ˜h—šžœ˜Kšœžœžœ%žœ˜q—Kšœžœ4˜OK˜—K˜Kšœ[™[Kšžœžœžœžœ˜(K˜KšœU™UK˜KšœB˜BKšœ-žœ‘9˜mKšœžœ˜Kšœ˜Kšœ5˜5K˜K™‡šžœžœžœ+žœ=˜‘šžœ˜Kšœe˜eKšœ(ž˜/Kšœ˜——Kšœ˜—K˜š œžœ˜š žœžœžœ1žœžœž˜MKšœIžœ˜LKšžœ˜ ——K˜š œžœ˜š žœžœžœ1žœžœž˜MKšœ7˜7Kšžœ˜ ——Kšœ˜K˜š œž œ˜*K˜,Kšœžœžœ˜(Kšœ˜Kšœ˜Kšœ žœžœ˜Kšœžœžœ˜Kšœžœ˜K˜š œžœ˜ Kšœžœ'˜<š žœžœžœ1žœžœž˜MKšœ Ÿ Οr œ¦ ž¦€˜TKšžœ˜—Kšœ?žœ€˜XKšœA™AKšœžœžœHžœž˜fKšœG˜GKšœU˜UKšœ?€˜OKšœ{˜{Kšœ―˜―Kšœ:˜:K˜—K˜K™LKšžœž ˜Kšœ˜KšœB˜BKšœ žœ žœ‘9˜mKšœžœ˜Kšœ˜Kšœ Ÿœ˜Ešžœžœžœ+žœ=˜•šžœ˜K™tKšœi˜iKšœ,ž˜3K˜——K˜Kšœ8ž™;K˜Kšœž˜K˜K˜—š œžœžœžœ&žœžœžœžœ˜†Kšœ?˜?—K˜š œ˜*Kšœ:™:K˜(Kšœžœ žœ˜#Kšœ˜Kšœ˜Kšœ žœžœ˜Kšœžœžœ˜Kšœžœžœ˜Kšœžœžœ˜Kšœ žœžœ˜š žœžœBžœžœž˜ašžœžœž˜Kšœžœžœ˜>Kšœžœžœ˜8Kšžœ*˜1—Kšžœ˜—šžœ˜šž˜Kšœ™Kšœ˜KšœA˜AKšœ žœ žœ‘9˜mKšœžœžœ˜Kšœ˜šžœ˜ šžœ˜KšœA™AKšžœžœ žœ˜EKšžœžœ"˜,K˜——šžœ˜K™WKšœ0‘3˜cKšœ<žœžœ‘@˜šKšžœžœ!˜,K˜—K˜—šžœ˜K™2Kšœ ˜ Kš¦˜Kš¦œ¦œ žœ˜AKšœ!™!Kšžœžœ˜'K˜——Kšœ˜—K˜š œ™1Kšœžœ(žœ™7Kšžœžœžœ'™9K™K™—š  œžœžœžœžœ.˜rKšœžœ˜Kšœ˜Kšœžœ ˜Kšœžœ ˜K˜Kšœžœ˜ K˜š œžœ˜Kšœ8˜8Kšœ.‘0˜^K˜KšœC˜CK˜Kšœ%˜%Kšœ˜Kšœ8˜8Kšœ-˜-K˜KšœC˜CK˜Kšœ%˜%Kšœ™Kšœ8˜8Kšœ,˜,K˜K˜5KšœC˜CK˜Kšœ%˜%Kšœ™Kšœ8˜8Kšœ0‘˜BKšœC˜CK˜Kšœ%˜%Kšœ™Kšœ8˜8Kšœ,‘=˜iK˜KšœC˜CK˜Kšœ%˜%Kšœ™Kšœ8˜8Kšœ‘˜5K˜ Kšœ$‘#˜GK˜ Kšœ ‘3˜SK˜ K˜5KšœC˜CK˜Kšœ%˜%Kšœ™Kšœ8˜8Kšœ.‘˜CKšœ‘˜K˜K˜—š  œžœ˜Kšœ8˜8Kšœ‘0˜JK˜KšœC˜CK˜Kšœ%˜%Kšœ˜Kšœ8˜8Kšœ‘˜)K˜KšœC˜CK˜Kšœ%˜%Kšœ™Kšœ8˜8Kšœ‘˜'K˜K˜5KšœC˜CK˜Kšœ%˜%Kšœ™Kšœ8˜8Kšœ‘˜.KšœC˜CK˜Kšœ%˜%Kšœ™Kšœ8˜8Kšœ‘=˜UK˜KšœC˜CK˜Kšœ%˜%Kšœ™Kšœ8˜8Kšœ‘˜5K˜ Kšœ ‘#˜CK˜ Kšœ‘3˜OK˜ K˜5KšœC˜CK˜Kšœ%˜%Kšœ™Kšœ8˜8Kšœ‘˜0Kšœ˜K˜—˜Kšœ!˜!K˜'K˜K˜bKšœ™KšœE‘˜^Kšœ™Kšœ‘˜.Kšœ‘˜3K˜3K˜*Kšœ™Kšœ(‘#˜KK˜Kšœ'‘-˜TK˜Kšœ)‘-˜VK˜Kšœ*‘!˜KK˜K˜KšœS˜SKšœ˜K˜%Kšœ˜šžœ ž˜Kšžœ˜Kšžœ˜—Kšœ˜Kšœžœ˜K˜K˜*šžœžœžœ˜$KšœA˜AK™OKšœ˜Kšœ žœ˜—K˜K˜KšœC˜CKšœ™KšœH™HKšœ™K˜K˜K˜GKšœ‘˜—Kšœ/‘M˜|K˜—K˜Kšœ™K˜Kšœ•˜•šœr™rK™—Kšœ8˜8K˜Kšœ˜J˜—…—\>~ί