DIRECTORY Buttons USING [ButtonProc], Commander USING [CommandProc, Register], Containers USING [ChildXBound, ChildYBound, Create], EditToolBuilder USING [BadNumber, BuildButton, BuildDataFieldPair, ConvertList, DataFieldButton, GetInt, HRule, Layout, LayoutRec, SetInt], IO USING [char, CR, int, Put, rope, RopeFromROS, ROS, STREAM, TAB], MessageWindow USING [Append, Blink], Rope USING [ROPE], TEditHistory USING [CurrentEventNumber, GetRepeatList, Known, NewSliceSize, SliceSize, Undo], TEditInput USING [CloseEvent], TEditOps USING [SetTextContents], ViewerClasses USING [Viewer], ViewerOps USING [CreateViewer, FindViewer, OpenIcon]; EditHistoryImpl: CEDAR PROGRAM IMPORTS Commander, Containers, IO, EditToolBuilder, MessageWindow, TEditHistory, TEditInput, TEditOps, ViewerOps = { OPEN EditToolBuilder; Info: TYPE = REF InfoRec; InfoRec: TYPE = RECORD [ layout: Layout, eventNumArg: ViewerClasses.Viewer, sliceSizeArg: ViewerClasses.Viewer, textField: ViewerClasses.Viewer ]; info: Info; -- for the current edit history tool BuildIt: Commander.CommandProc = { layout: Layout; name: Rope.ROPE = "EditHistory Tool"; viewer: ViewerClasses.Viewer _ ViewerOps.FindViewer[name]; IF viewer # NIL THEN { -- already have an edit history tool around IF viewer.iconic THEN ViewerOps.OpenIcon[viewer]; RETURN [NIL, "Opened existing EditHistory Tool."]}; info _ NEW[InfoRec]; info.layout _ layout _ NEW[LayoutRec]; {OPEN layout; entryLeft _ initLeft _ 5; heightSoFar _ initHeight _ entryVSpace; container _ Containers.Create[[name: name, iconic: TRUE, column: right, scrollable: FALSE]]; [] _ BuildButton[layout, "Show", DoShow]; [] _ BuildButton[layout, "Undo", DoUndo]; [,info.eventNumArg] _ BuildDataFieldPair[layout, "since event number:", EventNumberButton, NIL, 1]; layout.heightSoFar _ layout.heightSoFar + layout.entryVSpace/2; [] _ BuildButton[layout, "Get", DoGetSize]; [] _ BuildButton[layout, "Set", DoSetSize]; [,info.sliceSizeArg] _ BuildDataFieldPair[layout, "history size:", SliceSizeButton, NIL, 1]; HRule[layout]; info.textField _ ViewerOps.CreateViewer[flavor: $Text, info: [parent: layout.container, wx: entryLeft, wy: heightSoFar, wh: 700, ww: 200, border: FALSE, scrollable: TRUE], paint: FALSE]; Containers.ChildYBound[container, info.textField]; Containers.ChildXBound[container, info.textField]; }; RETURN [NIL, "Created new EditHistory Tool."]; }; EventNumberButton: Buttons.ButtonProc = { DataFieldButton[info.eventNumArg, mouseButton#red] }; SliceSizeButton: Buttons.ButtonProc = { DataFieldButton[info.sliceSizeArg, mouseButton#red] }; DoShow: Buttons.ButtonProc = { OPEN IO; num, stop: INT; h: STREAM _ IO.ROS[]; TEditInput.CloseEvent[]; num _ TEditHistory.CurrentEventNumber[]; stop _ EditToolBuilder.GetInt[info.eventNumArg ! BadNumber => { stop _ 0; CONTINUE }]; WHILE TEditHistory.Known[num _ num-1] AND num >= stop DO list: LIST OF REF ANY _ TEditHistory.GetRepeatList[num]; Put[h,int[num]]; Put[h,char[TAB]]; Put[h,char[TAB]]; Put[h,rope[ConvertList[list]]]; Put[h,char[CR]]; Put[h,char[CR]]; ENDLOOP; TEditOps.SetTextContents[info.textField, IO.RopeFromROS[h]]; }; DoUndo: Buttons.ButtonProc = { num: INT _ GetInt[info.eventNumArg ! BadNumber => GOTO Bad]; TEditHistory.Undo[num]; EXITS Bad => { MessageWindow.Append["Please fill in the \"since event number\" field",TRUE]; MessageWindow.Blink[]; } }; DoGetSize: Buttons.ButtonProc = { SetInt[info.sliceSizeArg, TEditHistory.SliceSize[]] }; DoSetSize: Buttons.ButtonProc = { num: INT _ GetInt[info.sliceSizeArg ! BadNumber => GOTO Bad]; TEditHistory.NewSliceSize[num]; EXITS Bad => { MessageWindow.Append["Please enter a number in the \"history size\" field",TRUE]; MessageWindow.Blink[] } }; Commander.Register["EditHistory", BuildIt, "Create an Edit History tool."]; }..... °EditHistoryImpl.mesa Paxton on June 14, 1982 10:42 am McGregor on September 21, 1982 3:28 pm Maxwell, January 6, 1983 12:18 pm Plass, April 20, 1983 9:54 am Russ Atkinson, September 29, 1983 11:03 am Paul Rovner, September 30, 1983 10:37 am Doug Wyatt, January 13, 1984 3:57 pm [cmd: Handle] RETURNS [result: REF _ NIL, msg: Rope.ROPE _ NIL] ... builds an edit history tool. -- make the textField grow as the container grows Ê‘˜šÏc™Jš ™ Jš&™&J™!J™J™*J™(J™$J™—šÏk ˜ Jšœžœ˜Jšœ žœ˜(Jšœ žœ$˜4Jšœžœv˜‹Jš žœžœžœžœžœžœ˜CJšœžœ˜$Jšœžœžœ˜Jšœ žœK˜]Jšœ žœ˜Jšœ žœ˜!Jšœžœ ˜Jšœ žœ&˜5J˜—J˜Jšœž ˜JšžœžœO˜pšœžœ˜J˜—Jšœžœžœ ˜šœ žœžœ˜J˜J˜"J˜#J˜"J˜—Jšœ $˜0J˜šœ#˜#Jšœ?™?Jš ™ J˜Jšœ žœ˜%J˜:šžœ žœžœ+˜BJšžœžœ˜1Jšžœžœ(˜3—Jšœžœ ˜Jšœžœ ˜&šœžœ˜ J˜J˜'Jšœ3žœžœ˜\J˜)J˜)˜JšœEžœ˜M—J˜?J˜+J˜+˜Jšœ=žœ˜E—J˜˜WJšœ:žœžœ˜SJšœžœ˜—Jš1™1J˜2J˜2J˜—Jšžœžœ#˜.˜J˜——˜)J˜5J˜—˜'J˜6J˜—šœžœžœ˜'Jšœ žœ˜Jšœžœžœžœ˜J˜J˜(JšœJžœ˜Všžœ!žœ ž˜8Jš œžœžœžœžœ#˜8J˜Jšœ žœžœ˜#J˜Jšœ žœžœ˜!Jšžœ˜—Jšœ)žœ˜