-- TiogaInputImpl.mesa Edited by McGregor on 7-Aug-81 14:05:39 -- Last changed by Winiger, 14-Aug-81 9:32:55 DIRECTORY JaMControlDefs USING [RegisterCommand, InterpreteAtom], InputFocus USING [SetInputFocus], CedarAtoms USING [GetPName], MessageWindow USING [AppendMessageWindow], Inline USING [LowHalf], Real USING [RoundC], TextLooks USING [Look], TiogaDocumentDefs USING [TiogaDocumentData], TiogaImplDefs, TiogaInputOpsDefs, -- USING Lots TiogaSelectionDefs USING [Extend, pSel, PushOrExchangeSelections, SelectChar, SelectionId, SelectNode, SelectWord, SetInsertSelection, sSel, Update], TiogaTypeScriptDefs USING [ProcessChar], TIPUser USING [InstantiateNewTIPTable, TIPScreenCoords], UserTerminal USING [BlinkDisplay], ViewerOps USING [PaintViewer], Viewers USING [NotifyProc, Viewer], WTMisc USING [Print]; TiogaInputImpl: MONITOR IMPORTS Inline, InputFocus, Real, TiogaInputOpsDefs, TiogaSelectionDefs, TiogaTypeScriptDefs, TIPUser, UserTerminal, ViewerOps, WTMisc , MessageWindow, CedarAtoms, JaMControlDefs EXPORTS TiogaImplDefs = BEGIN OPEN TiogaSelectionDefs; mx, my: CARDINAL; -- global Coord param for ops below n: LONG INTEGER; -- global number param for ops below sel: SelectionId; -- global sel ID; can be set to "secondary" by $SelSecondary pendingDelete: BOOLEAN; -- global sel ID; can be set to TRUE by $SelPendDel InterpretAtom: PROCEDURE [viewer: Viewers.Viewer, atom: ATOM] = BEGIN OPEN TiogaInputOpsDefs; SELECT atom FROM -- $Again => Again[]; $AllCaps => Capitalise[allCaps, sel]; $AllLower => Capitalise[allLower, sel]; $ApplyLook => ModifyLook[NumberToLook[n], add, sel]; $BackSpace => BackSpace[]; $BackWord => BackWord[]; -- $BSRight => BSRight[]; -- $BWRight => BWRight[] -- $CaretLook => CaretLook[]; -- $ControlChar => ControlChar[]; $Copy => Copy[sel]; $Delete => Delete[sel]; -- $Eval => Eval[]; -- $Include => Include[]; $InitialCaps => Capitalise[initCaps, sel]; -- $MakeNode => MakeNode[]; -- $MergeNodes => MergeNodes[]; $Move => Move[sel]; -- $NodeType => NodeType[]; -- $OctalChar => OctalChar[]; $Paint => ViewerOps.PaintViewer[viewer]; $ReadProfile => ReloadTIPTable[viewer]; $RemoveLook => ModifyLook[NumberToLook[n], remove, sel]; -- $Replace => Replace[sel]; -- $SelAll => SelAll[]; $SelChar => SelectChar[viewer, NARROW[viewer.data], mx, my, sel]; -- $SelCharSpots => SelCharSpots[]; -- $SelClick => SelClick[]; -- $SelDelims => SelDelims[]; -- $SelDotUnder => SelDotUnder[]; $SelExchange => PushOrExchangeSelections[]; $SelExtend => Extend[viewer, NARROW[viewer.data], mx, my, sel]; -- $SelInvert => SelInvert[]; -- $SelLeft => SelLeft[]; -- $SelLine => SelLine[]; $SelNode => SelectNode[viewer, NARROW[viewer.data], mx, my, sel]; -- $SelNoDelims => SelNoDelims[]; $SelPendDel => pendingDelete ← TRUE; -- $SelPoint => SelPoint[]; $SelPrimary => sel ← primary; -- $SelRight => SelRight[]; $SelSecondary => sel ← secondary; -- $SelSelSpots => SelSelSpots[]; -- $SelSent => SelSent[]; $SelUpdate => Update[viewer, NARROW[viewer.data], mx, my, sel]; -- $SelUnderline => SelUnderline[]; $SelWord => SelectWord[viewer, NARROW[viewer.data], mx, my, sel]; -- $SplitNode => SplitNode[]; -- $Stop => Stop[]; $Transpose => Transpose[sel]; -- $Undo => Undo[]; ENDCASE => JaMControlDefs.InterpreteAtom[CedarAtoms.GetPName[atom]]; END; NumberToLook: PROC [n: LONG INTEGER] RETURNS [look: TextLooks.Look] = INLINE BEGIN RETURN['a+Inline.LowHalf[n]]; END; TiogaNotifyProc: PUBLIC ENTRY Viewers.NotifyProc = BEGIN tdd: TiogaDocumentDefs.TiogaDocumentData ← NARROW[self.data]; IF tdd.tsInfo=NIL THEN InterpretInput[self, input] ELSE InterpretTypescriptInput[self, input]; END; InterpretInput: PROCEDURE [viewer: Viewers.Viewer, params: LIST OF REF ANY] = BEGIN OPEN TiogaInputOpsDefs; InsSel: PROC RETURNS [BOOLEAN] = INLINE {RETURN[pSel.granularity=point AND sSel.viewer=NIL]}; sel ← primary; -- reset non-sticky switches pendingDelete ← FALSE; FOR input: LIST OF REF ANY ← params, input.rest UNTIL input=NIL DO WITH input.first SELECT FROM z: REF CHARACTER => {IF ~InsSel[] THEN SetInsertSelection[]; BufferedInsertChar[z↑]}; z: ATOM => {WaitForRepaintToFinish[]; InterpretAtom[viewer, z]}; z: REF LONG INTEGER => n ← z↑; z: TIPUser.TIPScreenCoords => {mx ← Real.RoundC[z.x]; my ← viewer.ch-Real.RoundC[z.y]}; z: REF TEXT => {IF ~InsSel[] THEN SetInsertSelection[]; BufferedInsertText[z]}; ENDCASE => UserTerminal.BlinkDisplay; ENDLOOP; END; InterpretTypescriptInput: PROCEDURE [viewer: Viewers.Viewer, params: LIST OF REF ANY] = BEGIN OPEN TiogaInputOpsDefs; sel ← primary; -- reset non-sticky switches pendingDelete ← FALSE; FOR input: LIST OF REF ANY ← params, input.rest UNTIL input=NIL DO WITH input.first SELECT FROM z: REF CHARACTER => TiogaTypeScriptDefs.ProcessChar[viewer, z↑]; z: ATOM => {WaitForRepaintToFinish[]; InterpretAtom[viewer, z]}; z: TIPUser.TIPScreenCoords => {mx ← Real.RoundC[z.x]; my ← viewer.ch-Real.RoundC[z.y]}; ENDCASE => UserTerminal.BlinkDisplay; ENDLOOP; END; ReloadTIPTable: PROCEDURE [viewer: Viewers.Viewer] = BEGIN viewer.class.tipTable ← TIPUser.InstantiateNewTIPTable["Tioga.tip" ! ANY => {UserTerminal.BlinkDisplay; CONTINUE}]; InputFocus.SetInputFocus[]; -- kill selection; force ChangeTIPContext END; -- for debugging... Print: PROC [ref: REF READONLY ANY] RETURNS[STRING] = {RETURN[WTMisc.Print[ref]]}; -- main code (under development) RegAllCaps: PROC = {TiogaInputOpsDefs.Capitalise[allCaps, sel]}; RegAllLower: PROC = {TiogaInputOpsDefs.Capitalise[allLower, sel]}; RegCopy: PROC = {TiogaInputOpsDefs.Copy[sel]}; RegDelete: PROC = {TiogaInputOpsDefs.Delete[sel]}; RegInitialCaps: PROC = {TiogaInputOpsDefs.Capitalise[initCaps, sel]}; RegMove: PROC = {TiogaInputOpsDefs.Move[sel]}; RegSelPrimary: PROC = {sel ← primary}; RegSelSecondary: PROC = {sel ← secondary}; RegTranspose: PROC = {TiogaInputOpsDefs.Transpose[sel]}; JaMControlDefs.RegisterCommand["AllCaps"L,RegAllCaps]; JaMControlDefs.RegisterCommand["AllLower"L,RegAllLower]; JaMControlDefs.RegisterCommand["Copy"L,RegCopy]; JaMControlDefs.RegisterCommand["Delete"L,RegDelete]; JaMControlDefs.RegisterCommand["InitialCaps"L,RegInitialCaps]; JaMControlDefs.RegisterCommand["Move"L,RegMove]; JaMControlDefs.RegisterCommand["SelPrimary"L,RegSelPrimary]; JaMControlDefs.RegisterCommand["SelSecondary"L,RegSelSecondary]; JaMControlDefs.RegisterCommand["Transpose"L,RegTranspose]; MessageWindow.AppendMessageWindow[" JaM (8.7.81)"]; END.