DIRECTORY InputFocus USING [SetInputFocus], MessageWindow USING [Append, Blink], Process USING [Detach], TEditDisplay USING [EstablishLine], TEditDocument USING [maxClip, Selection, SpinAndLock, TEditDocumentData, Unlock], TEditImpl USING [ReloadTipTable, ReloadReadonlyTipTable, ReloadTypeScriptTipTable], TEditInput, TEditInputOps, -- USING Lots TEditProfile USING [ReadProfile], TEditSelection USING [CancelPrimary, CancelSecondary, CaretAfterSelection, CaretBeforeSelection, GrowSelection, GrowSelectionToBlanks, LockSel, MakePointSelection, MakePrimary, MakeSecondary, pSel, PendingDeleteSelection, NotPendingDeleteSelection, SelectEverything, UnlockSel], TEditTouchup USING [LockAfterRefresh, UnlockAfterRefresh], TextNode USING [ForwardClipped, Location, Level, Parent, Ref, RefTextNode, Root], TreeCheck USING [Verify], UserProfile USING [CallWhenProfileChanges, ProfileChangedProc], ViewerOps USING [PaintViewer], ViewerClasses USING [Viewer, ViewerRec], WindowManager USING [UnWaitCursor, WaitCursor]; TEditInput2Impl: CEDAR PROGRAM IMPORTS InputFocus, TEditImpl, TEditDisplay, MessageWindow, Process, TEditDocument, TEditInput, TEditInputOps, TEditProfile, TEditSelection, TEditTouchup, TextNode, TreeCheck, UserProfile, ViewerOps, WindowManager EXPORTS TEditInput = BEGIN OPEN TEditInput, TEditSelection; Break: CommandProc = { TEditInputOps.Break[] }; Join: CommandProc = { TEditInputOps.Join[] }; Nest: CommandProc = { TEditInputOps.Nest[] }; Paste: CommandProc = { TEditInputOps.Paste[] }; SaveForPaste: CommandProc = { TEditInputOps.SaveForPaste[] }; SetType: CommandProc = { TEditInputOps.SetType[] }; GetType: CommandProc = { TEditInputOps.GetType[] }; UnNest: CommandProc = { TEditInputOps.UnNest[] }; AllCaps: CommandProc = { TEditInputOps.Capitalise[allCaps] }; AllLower: CommandProc = { TEditInputOps.Capitalise[allLower] }; FirstCap: CommandProc = { TEditInputOps.Capitalise[firstCap] }; InitialCaps: CommandProc = { TEditInputOps.Capitalise[initCaps] }; ForkPaint: PROC [viewer: ViewerClasses.Viewer] = TRUSTED { Process.Detach[FORK ViewerOps.PaintViewer[viewer, client ! ABORTED => CONTINUE]] }; AllLevels: PUBLIC CommandProc = { tdd: TEditDocument.TEditDocumentData _ NARROW[viewer.data]; IF tdd = NIL THEN RETURN; tdd.clipLevel _ TEditDocument.maxClip; ForkPaint[viewer]; RETURN [FALSE] }; FirstLevelOnly: PUBLIC CommandProc = { tdd: TEditDocument.TEditDocumentData _ NARROW[viewer.data]; IF tdd = NIL THEN RETURN; tdd.clipLevel _ 1; CheckFirstLevel[tdd]; ForkPaint[viewer]; RETURN [FALSE] }; CheckFirstLevel: PROC [tdd: TEditDocument.TEditDocumentData] = { node: TextNode.Ref; delta: INTEGER; pos: TextNode.Location; [] _ TEditDocument.SpinAndLock[tdd, "CheckFirstLevel", TRUE]; -- ok to interrupt repaint pos _ tdd.lineTable.lines[0].pos; -- the start of the first line delta _ TextNode.Level[pos.node]-tdd.clipLevel; -- how much too deep it is, if any IF delta > 0 THEN { FOR i:INTEGER IN [0..delta) DO -- only do this if pos is too deep pos _ [TextNode.Parent[pos.node],0]; ENDLOOP; IF (node _ TextNode.ForwardClipped[pos.node,].nx) # NIL THEN pos _ [node,0]; TEditDisplay.EstablishLine[tdd, pos] }; TEditDocument.Unlock[tdd] }; MaxLevelShown: PUBLIC PROC [tdd: TEditDocument.TEditDocumentData] RETURNS [level: INTEGER] = { node, n: TextNode.Ref; max: INTEGER _ 0; IF tdd = NIL THEN RETURN [0]; FOR l: INTEGER IN [0..tdd.lineTable.lastLine] DO IF (n _ tdd.lineTable.lines[l].pos.node) # node THEN { node _ n; max _ MAX[TextNode.Level[node],max] }; ENDLOOP; level _ max }; MoreLevels: PUBLIC CommandProc = { tdd: TEditDocument.TEditDocumentData _ NARROW[viewer.data]; IF tdd = NIL THEN RETURN; [] _ TEditDocument.SpinAndLock[tdd, "MoreLevels", TRUE]; -- ok to interrupt repaint IF tdd.clipLevel < TEditDocument.maxClip THEN tdd.clipLevel _ MaxLevelShown[tdd]+1; ForkPaint[viewer]; TEditDocument.Unlock[tdd]; RETURN [FALSE] }; FewerLevels: PUBLIC CommandProc = { tdd: TEditDocument.TEditDocumentData _ NARROW[viewer.data]; level: INTEGER; IF tdd = NIL THEN RETURN; IF ~TEditTouchup.LockAfterRefresh[tdd, "FewerLevels"] THEN RETURN [FALSE]; { ENABLE UNWIND => TEditTouchup.UnlockAfterRefresh[tdd]; level _ tdd.clipLevel; IF level = TEditDocument.maxClip THEN level _ MaxLevelShown[tdd]; IF level # 1 THEN { tdd.clipLevel _ level-1; CheckFirstLevel[tdd]; ForkPaint[viewer] }; TEditTouchup.UnlockAfterRefresh[tdd]; RETURN [FALSE] }}; CaretAfter: CommandProc = { CaretAfterSelection[] }; CaretBefore: CommandProc = { CaretBeforeSelection[] }; Everything: CommandProc = { SelectEverything[] }; GrowSel: CommandProc = { GrowSelection[] }; GrowSelToBlanks: CommandProc = { GrowSelectionToBlanks[] }; InsertLineBreak: CommandProc = { TEditInputOps.InsertLineBreak[] }; MakeNotPendingDelete: CommandProc = { NotPendingDeleteSelection[] }; MakePendingDelete: CommandProc = { PendingDeleteSelection[] }; MakePointSelection: PUBLIC CommandProc = { TEditSelection.LockSel[primary, "MakePointSelection"]; IF pSel.viewer#NIL THEN TEditSelection.MakePointSelection[pSel, IF pSel.insertion=before THEN pSel.start.pos ELSE [pSel.end.pos.node,pSel.end.pos.where+1]]; TEditSelection.UnlockSel[primary] }; MakeControlCharacter: CommandProc = { TEditInputOps.MakeControlCharacter[] }; MakeOctalCharacter: CommandProc = { TEditInputOps.MakeOctalCharacter[] }; UnMakeControlCharacter: CommandProc = { TEditInputOps.UnMakeControlCharacter[] }; UnMakeOctalCharacter: CommandProc = { TEditInputOps.UnMakeOctalCharacter[] }; MakePrimaryOp: CommandProc = { MakePrimary[] }; MakeSecondaryOp: CommandProc = { MakeSecondary[] }; CancelPrimaryOp: CommandProc = { CancelPrimary[] }; CancelSecondaryOp: CommandProc = { CancelSecondary[] }; Paint: CommandProc = { ViewerOps.PaintViewer[viewer, client] }; PlaceholderBrackets: CommandProc = { TEditInputOps.InsertBrackets[1C,2C] }; justRegistered: BOOL _ TRUE; ProfileChanged: UserProfile.ProfileChangedProc = { IF justRegistered THEN { justRegistered _ FALSE; RETURN }; TEditProfile.ReadProfile[] }; ReadTip: CommandProc = { ReadTipTables[] }; ReadTipTables: PUBLIC PROC = { WindowManager.WaitCursor[]; TEditImpl.ReloadTipTable[]; TEditImpl.ReloadReadonlyTipTable[]; TEditImpl.ReloadTypeScriptTipTable[]; InputFocus.SetInputFocus[]; -- kill selection; force ChangeTIPContext WindowManager.UnWaitCursor[] }; ReloadStyle: CommandProc = { TEditInputOps.ReloadStyle[] }; SelectMatchingPlaceholderBrackets: CommandProc = { TEditInputOps.SelectMatchingBrackets[1C,2C] }; SelectMatchingSingleQuotes: CommandProc = { -- look for 140C as left single quote TEditInputOps.SelectMatchingBrackets['\140,''] }; SelectMatchingDoubleQuotes: CommandProc = { TEditInputOps.SelectMatchingBrackets['",'"] }; SelectMatchingDashBrackets: CommandProc = { TEditInputOps.SelectMatchingBrackets['-,'-] }; PreviousPlaceholder: CommandProc = { TEditInputOps.FindPlaceholders[FALSE] }; PreviousViewer: CommandProc = { TEditInputOps.NextViewer[FALSE] }; NextPlaceholder: CommandProc = { TEditInputOps.FindPlaceholders[TRUE] }; NextViewer: CommandProc = { TEditInputOps.NextViewer[TRUE] }; ReadAbbreviations: CommandProc = { TEditInputOps.LoadAbbreviations["Default"] }; VerifyTree: CommandProc = { IF pSel.viewer=NIL THEN RETURN; TreeCheck.Verify[TextNode.Root[pSel.start.pos.node]]; MessageWindow.Append["Verified", TRUE]; MessageWindow.Blink[] }; SelectMatchingParens: CommandProc = { TEditInputOps.SelectMatchingBrackets['(,')] }; SelectMatchingAngleBrackets: CommandProc = { TEditInputOps.SelectMatchingBrackets['<,'>] }; SelectMatchingCurlyBrackets: CommandProc = { TEditInputOps.SelectMatchingBrackets['{,'}] }; SelectMatchingSquareBrackets: CommandProc = { TEditInputOps.SelectMatchingBrackets['[,']] }; ParenBrackets: CommandProc = { TEditInputOps.InsertBrackets['(,')] }; DashBrackets: CommandProc = { TEditInputOps.InsertBrackets['-,'-] }; DoubleQuoteBrackets: CommandProc = { TEditInputOps.InsertBrackets['",'"] }; AngleBrackets: CommandProc = { TEditInputOps.InsertBrackets['<,'>] }; SingleQuoteBrackets: CommandProc = { -- use 140C for left single quote TEditInputOps.InsertBrackets['\140,''] }; CurlyBrackets: CommandProc = { TEditInputOps.InsertBrackets['{,'}] }; SquareBrackets: CommandProc = { TEditInputOps.InsertBrackets['[,']] }; ComArray: TYPE = ARRAY ComIndex OF LIST OF REF ANY; coms: REF ComArray = NEW [ComArray]; SetCommand: PUBLIC PROC [num: ComIndex, params: LIST OF REF ANY] = { coms[num] _ params }; GetCommand: PUBLIC PROC [num: ComIndex] RETURNS [params: LIST OF REF ANY] = { RETURN [coms[num]] }; DoCommand: PROC [viewer: ViewerClasses.Viewer, num: ComIndex] = { Interpret[viewer,coms[num]] }; Command0: CommandProc = { DoCommand[viewer,0] }; Command1: CommandProc = { DoCommand[viewer,1] }; Command2: CommandProc = { DoCommand[viewer,2] }; Command3: CommandProc = { DoCommand[viewer,3] }; Command4: CommandProc = { DoCommand[viewer,4] }; Command5: CommandProc = { DoCommand[viewer,5] }; Command6: CommandProc = { DoCommand[viewer,6] }; Command7: CommandProc = { DoCommand[viewer,7] }; Command8: CommandProc = { DoCommand[viewer,8] }; Command9: CommandProc = { DoCommand[viewer,9] }; SetComment: CommandProc = { TEditInputOps.SetCommentProp[TRUE] }; SetNotComment: CommandProc = { TEditInputOps.SetCommentProp[FALSE] }; RegisterCommandAtoms: PROC = { Register[$Break, Break]; Register[$Join, Join]; Register[$Nest, Nest]; Register[$Paste, Paste]; Register[$SaveForPaste, SaveForPaste]; Register[$SetType, SetType]; Register[$GetType, GetType]; Register[$UnNest, UnNest]; Register[$AllCaps, AllCaps]; Register[$AllLower, AllLower]; Register[$FirstCap, FirstCap]; Register[$InitialCaps, InitialCaps]; Register[$AllLevels, AllLevels]; Register[$FewerLevels, FewerLevels]; Register[$MoreLevels, MoreLevels]; Register[$FirstLevelOnly, FirstLevelOnly]; Register[$CaretAfter, CaretAfter]; Register[$CaretBefore, CaretBefore]; Register[$Everything, Everything]; Register[$GrowSelection, GrowSel]; Register[$GrowSelectionToBlanks, GrowSelToBlanks]; Register[$InsertLineBreak, InsertLineBreak]; Register[$MakeNotPendingDelete, MakeNotPendingDelete]; Register[$MakePendingDelete, MakePendingDelete]; Register[$MakePointSelection, MakePointSelection]; Register[$MakeControlCharacter, MakeControlCharacter]; Register[$MakeOctalCharacter, MakeOctalCharacter]; Register[$UnMakeControlCharacter, UnMakeControlCharacter]; Register[$UnMakeOctalCharacter, UnMakeOctalCharacter]; Register[$MakePrimary, MakePrimaryOp]; Register[$MakeSecondary, MakeSecondaryOp]; Register[$CancelPrimary, CancelPrimaryOp]; Register[$CancelSecondary, CancelSecondaryOp]; Register[$Paint, Paint]; Register[$PlaceholderBrackets, PlaceholderBrackets]; Register[$PreviousPlaceholder, PreviousPlaceholder]; Register[$PreviousViewer, PreviousViewer]; Register[$ReadProfile, ReadTip]; Register[$ReloadStyle, ReloadStyle]; Register[$SelectMatchingPlaceholderBrackets, SelectMatchingPlaceholderBrackets]; Register[$NextPlaceholder, NextPlaceholder]; Register[$NextViewer, NextViewer]; Register[$ReadAbbreviations, ReadAbbreviations]; Register[$VerifyTree, VerifyTree]; Register[$SelectMatchingParens, SelectMatchingParens]; Register[$SelectMatchingAngleBrackets, SelectMatchingAngleBrackets]; Register[$SelectMatchingCurlyBrackets, SelectMatchingCurlyBrackets]; Register[$SelectMatchingSquareBrackets, SelectMatchingSquareBrackets]; Register[$SelectMatchingSingleQuotes, SelectMatchingSingleQuotes]; Register[$SelectMatchingDoubleQuotes, SelectMatchingDoubleQuotes]; Register[$SelectMatchingDashBrackets, SelectMatchingDashBrackets]; Register[$ParenBrackets, ParenBrackets]; Register[$DashBrackets, DashBrackets]; Register[$AngleBrackets, AngleBrackets]; Register[$DoubleQuoteBrackets, DoubleQuoteBrackets]; Register[$SingleQuoteBrackets, SingleQuoteBrackets]; Register[$CurlyBrackets, CurlyBrackets]; Register[$SquareBrackets, SquareBrackets]; Register[$Command0, Command0]; Register[$Command1, Command1]; Register[$Command2, Command2]; Register[$Command3, Command3]; Register[$Command4, Command4]; Register[$Command5, Command5]; Register[$Command6, Command6]; Register[$Command7, Command7]; Register[$Command8, Command8]; Register[$Command9, Command9]; Register[$SetComment, SetComment]; Register[$SetNotComment, SetNotComment]; }; RegisterCommandAtoms; UserProfile.CallWhenProfileChanges[ProfileChanged]; END. ¬-- TEditInput2Impl.mesa; Edited by Paxton on October 29, 1982 9:59 am Last Edited by: Maxwell, January 6, 1983 11:24 am Last Edited by: Plass, April 15, 1983 2:08 pm Ê ˜JšÏcE™EJ™1J™-JšÏk ˜ ˜Jšœ žœ˜!Jšœžœ˜$Jšœžœ ˜Jšœ žœ˜#Jšœžœ>˜QJšœ žœD˜SJ˜ Jšœ ˜Jšœ žœ˜!Jšœžœ‚˜–Jšœ žœ(˜:Jšœ žœC˜QJšœ žœ ˜Jšœ žœ.˜?Jšœ žœ˜Jšœžœ˜(Jšœžœ˜/J˜—Jšœž ˜J˜JšžœÎ˜ÕJšžœ ˜J˜Jšžœžœ˜&J˜˜J˜J˜—˜J˜J˜—˜J˜J˜—˜J˜J˜—˜J˜J˜—˜J˜J˜—˜J˜J˜—˜J˜J˜—˜J˜$J˜—˜J˜%J˜—˜J˜%J˜—˜J˜%J˜—šÏn œžœ"žœ˜:Jšœžœ(žœžœ˜SJ˜—šœ žœ˜!Jšœ'žœ˜;Jšžœžœžœžœ˜J˜&Jšœ˜Jšžœžœ˜J˜—šœžœ˜&Jšœ'žœ˜;Jšžœžœžœžœ˜J˜J˜Jšœ˜Jšžœžœ˜J˜—šŸœžœ+˜@J˜Jšœžœ˜Jšœ˜Jšœ7žœ˜XJšœ"˜@Jšœ0"˜Ršžœ žœž˜š žœžœžœ žœ"˜AJ˜$Jšžœ˜—Jšžœ2žœžœ˜LJ˜'—Jšœ˜J˜—šŸ œžœžœ'˜AJšžœ žœ˜J˜Jšœžœ˜Jšžœžœžœžœ˜šžœžœžœž˜0šžœ.žœ˜6J˜ Jšœžœ˜&—Jšžœ˜—J˜J˜—šœ žœ˜"Jšœ'žœ˜;Jšžœžœžœžœ˜Jšœ2žœ˜SJšžœ'žœ&˜SJšœ˜Jšœ˜Jšžœžœ˜J˜—šœ žœ˜#Jšœ'žœ˜;Jšœžœ˜Jšžœžœžœžœ˜Jšžœ4žœžœžœ˜JJšœžœžœ)˜8Jšœ˜Jšžœžœ˜Ašžœ žœ˜J˜J˜Jšœ˜—Jšœ%˜%Jšžœžœ˜J˜—˜J˜J˜—˜J˜J˜—˜J˜J˜—˜J˜J˜—˜ J˜J˜—˜ J˜"J˜—˜%J˜J˜—˜"J˜J˜—šœžœ˜*Jšœ6˜6šžœ žœž˜šœ'˜'Jšžœžœ˜,Jšžœ+˜/——šœ$˜$J˜——˜%J˜'J˜—˜#J˜%J˜—˜'J˜)J˜—˜%J˜'J˜—J˜/J˜J˜3J˜J˜3J˜J˜7J˜J˜?J˜˜$J˜'J˜—Jšœžœžœ˜J˜šœ2˜2Jšžœžœžœžœ˜:J˜J˜—Jšœ+˜+J˜šœžœžœ˜J˜J˜J˜#J˜%Jšœ)˜EJ˜J˜—˜J˜J˜—˜2J˜.J˜—šœ,%˜QJ˜1J˜—˜+J˜.J˜—˜+J˜.J˜—˜$Jšœžœ˜(J˜—˜Jšœžœ˜"J˜—˜ Jšœžœ˜'J˜—˜Jšœžœ˜!J˜—˜"J˜-J˜—˜Jšžœ žœžœžœ˜J˜5Jšœ!žœ˜@J˜—˜%J˜.J˜—˜,J˜.J˜—˜,J˜.J˜—˜-J˜.J˜—˜J˜&J˜—˜J˜&J˜—˜$J˜&J˜—˜J˜&J˜—šœ%!˜FJ˜)J˜—˜J˜&J˜—˜J˜&J˜—Jšœ žœžœ žœžœžœžœžœ˜3Jšœžœ žœ ˜$J˜šŸ œžœžœžœžœžœžœ˜DJ˜J˜—šŸ œžœžœžœ žœžœžœžœ˜MJšžœ˜J˜—šŸ œžœ2˜AJšœ˜J˜—˜J˜J˜—˜J˜J˜—˜J˜J˜—˜J˜J˜—˜J˜J˜—˜J˜J˜—˜J˜J˜—˜J˜J˜—˜J˜J˜—˜J˜J˜—˜Jšœžœ˜%J˜—˜Jšœžœ˜&J˜—šŸœžœ˜J˜J˜J˜J˜J˜&J˜J˜J˜J˜J˜J˜J˜$J˜ J˜$J˜"J˜*J˜"J˜$J˜"J˜"J˜2J˜,J˜6J˜0J˜2J˜6J˜2J˜:J˜6J˜&J˜*J˜*J˜.J˜J˜4J˜4J˜*J˜ J˜$J˜PJ˜,J˜"J˜0J˜"J˜6J˜DJ˜DJ˜FJ˜BJ˜BJ˜BJ˜(J˜&J˜(J˜4J˜4J˜(J˜*J˜J˜J˜J˜J˜J˜J˜J˜J˜J˜J˜"J˜(J˜J˜—J˜J˜J˜3J˜Jšžœ˜J˜J˜—…—09Ð