<> <> <> DIRECTORY BBAction USING [Action], BBEval USING [EvalHead], BBInterp USING [Tree], Commander USING [CommandProc], File USING [Capability, nullCapability], IO USING [DeliverWhenProc], Menus USING [Menu, MenuEntry], Spell USING [Modes, SpellingGenerator], TiogaOps USING [Location, SelectionGrain], -- for ActionAreaData. If this becomes a problem, can make ActionAreaData opaque. TTY USING [Handle], UserExec USING [HistoryEvent, HistoryList, MethodProc, CommandProc, TransformProc, ExecHandle, Expression, ROPE, STREAM, TV, Viewer], WorldVM USING [World] ; UserExecPrivate: CEDAR DEFINITIONS IMPORTS UserExec, File = BEGIN OPEN UserExec; <> <> ExecPrivateRecord: TYPE = MONITORED RECORD[ historyList: HistoryList, id: ROPE, -- i.e. A, B, ... Z, AA, AB, etc. execState: GlobalExecState _ notListening, eventState: LocalExecState _ readyForNext, <> evalMode: BOOLEAN _ FALSE, actionAreaData: REF ActionAreaData _ NIL, spawnedActionArea: ExecHandle _ NIL, evalHead: BBEval.EvalHead _ NIL, <> lastChar: CHARACTER _ NULL, -- lastcharacter output to (or echoed to) exec.out .used in UserExecImpl.DefaultDeliverWhen, e.g. to remember if a CR was preceded by a '. dontPrompt: BOOLEAN _ FALSE, -- for continuing an event, e.g. following ESC completion. What the user sees on the input line is accurate. continuation: BOOLEAN _ FALSE, eventNum: INT _ 1, -- the event number of the next event to be created. used to prompt the user. Also used in UserExecInterpImpl.TreatAsExpr and used in HistoryImpl.CreateEvent. advice: LIST OF Advice _ NIL, -- list of expressions to be evaluated when userexecutive is again ready for input. lastLine: ROPE _ NIL, -- holds last input line. ExecProcessInput obtains the input from this field. Used in UserExecImpl.DefaultDeliverWhen to handle treatment of esc. <> execDotW: TTY.Handle, -- UserExecRegCmdsImpl.CallRegisteredProc sets Exec.w to this before calling a procedure registered through Exec.AppendCommand process: UNSAFE PROCESS, -- initialized to Process.GetCurrent[] when exec handle is created. used by UserExecImpl.GetExecHandle to find out which exec the current process is under. Also used to determine the parent for a spawned action area. <<>> <> execOwner: UNSAFE PROCESS _ NIL, -- usually itself execOwnerCount: INT _ 0, -- to permit clients to Acquire/Release Exec without having to worry about previously owned in same process. in, out: STREAM _ NIL ]; GlobalExecState: TYPE = {notListening, listening, dormant, suspended, destroyed}; <> LocalExecState: TYPE = {readyForNext, receivingInput, running}; <> ActionAreaData: TYPE = RECORD[ action: BBAction.Action _ NIL, parentExec: ExecHandle _ NIL, world: WorldVM.World _ NIL, viewer: Viewer _ NIL, fullMsg, abbrevMsg, iconMsg: ROPE _ NIL, aborted, booted: BOOL _ FALSE, -- when action = NIL, this says whether it was proceeded or aborted. Used in userexecimpl tiogaDoc: BOOL _ TRUE, restoreSelAfterEachEvent: BOOL _ FALSE, start, end: TiogaOps.Location _ [NIL, 0], level: TiogaOps.SelectionGrain _ char, caretBefore: BOOL _ NULL, pendingDelete: BOOL _ NULL ]; Advice: TYPE = REF AdviceRecord; AdviceRecord: TYPE = RECORD[before, after: PROC[data: REF ANY], data: REF ANY]; <> HistoryEventPrivateRecord: TYPE = RECORD[ eventNum: NAT, value: TV _ NIL, -- move to userexec state: EventState _ notFinishedYet, offender: ROPE _ NIL, -- set by EventFailed so that when event completes, can tell that it caused an error showInput: BOOLEAN _ FALSE, -- tells userexec to print the event it is about to execut inCommandFile: BOOLEAN _ FALSE, -- either cm or commands inCMFile: BOOLEAN _ FALSE -- true when inside of a CM file ]; ExpressionPrivateRecord: TYPE = RECORD[ tree: BBInterp.Tree _ NIL, valueRope: ROPE _ NIL, goForIt: BOOL _ FALSE ]; EventState: TYPE = {notFinishedYet, causedAnError, aborted, completed}; <> EvalHeadData: TYPE = RECORD[ exec: UserExec.ExecHandle, viewer: Viewer, generators: REF GeneratorsRecord _ NIL, -- for use in correcting interpreter errors. need to be separate for each exec because can now do evaluation in many execs. expr: Expression _ NIL, defaultInterface: ROPE _ NIL, confirmMenuUp: BOOL _ FALSE ]; <> GeneratorsRecord: TYPE = RECORD[ typeElementGenerator: Spell.SpellingGenerator, -- used to generate elements in a type, e.g. record, globalframe, etc. enumTypeGenerator: Spell.SpellingGenerator, -- used to generate the elements of an enumerated subrangeGenerator: Spell.SpellingGenerator, -- used to generate the elements of a subrange type frameGenerator: Spell.SpellingGenerator -- used to generate global framenames and interface names from cached list ]; <> MethodList: TYPE = LIST OF REF MethodRecord; MethodRecord: TYPE = RECORD[ name: ROPE _ NIL, proc: MethodProc _ NIL, doc: ROPE _ NIL, clientData: REF ANY _ NIL ]; CommandList: TYPE = LIST OF REF CommandRecord; CommandRecord: TYPE = RECORD[ name: ROPE _ NIL, commandProc: UserExec.CommandProc _ NIL, oldStyleProc: UNSAFE PROCEDURE _ NIL, -- for registering with Exec interface transformProc: UserExec.TransformProc _ NIL, briefDocumentation, documentation: ROPE _ NIL, nameOfBCD: ROPE _ NIL, clientData: REF ANY _ NIL, fromCatalogue: BOOL _ FALSE ]; ResponseRecord: TYPE = MONITORED RECORD[ hasResponded: BOOLEAN _ FALSE, -- tells program waiting for response that the value in value is now valid. Reset to FALSE in UserExecImpl.ExecGetRope. value: ATOM _ NIL, keyList: LIST OF ATOM _ NIL, menuCount: INT _ 0, HasResponded: CONDITION ]; <> ExecDeliverWhen: IO.DeliverWhenProc; w: TTY.Handle; -- exported to Exec. Included here so both UserExecImpl and UserExecRegCmdsImpl can set it. commandString: LONG STRING; -- ditto. commandGenerator: Spell.SpellingGenerator; <> defaultExec: ExecHandle; execHandleList: LIST OF ExecHandle; <> methodList: MethodList; execMenu: Menus.Menu; secondMenuLine: Menus.MenuEntry; experimentalNewFeatures: BOOLEAN; version: ROPE; Zone: PRIVATE ZONE; -- prefixed zone. tildas: ROPE; -- "~~~~...~~~~" defaultDepth, defaultWidth: INT; -- controls printing of expressions. <> FileNotFound: SIGNAL [name: ROPE, defaultExt: ROPE _ NIL] RETURNS [shouldBe: ROPE]; <> GoToSleep: ERROR; -- tells exec handle to go dormant and stop listening. Restart via StartExec. HistoryError: ERROR [ec: HistoryErrorCode, msg: ROPE _ NIL]; <> HistoryErrorCode: TYPE = {UseWhat, UseForWhat, UseHuh, NotFound}; <> DestroyExec: PROCEDURE [exec: ExecHandle]; CaptionForExec: PROC [exec: ExecHandle, paint: BOOL _ TRUE] RETURNS[caption: ROPE]; <> GetPrivateStuff: PROC [exec: ExecHandle] RETURNS[REF ExecPrivateRecord]; <> GetExecFromStream: PROC [in: STREAM] RETURNS[UserExec.ExecHandle]; AcquireExec: PROC [exec: ExecHandle] RETURNS[newlyAcquired: BOOL]; <<>> ReleaseExec: PROC [exec: ExecHandle] RETURNS[released: BOOL]; AdviseExec: PROC [exec: ExecHandle, before, after: PROC[data: REF ANY], data: REF ANY]; CreateExecLogFile: PROC [exec: ExecHandle] RETURNS[stream: STREAM]; CloseExecLogFile: PROC [exec: ExecHandle]; <> EventFailed: PROC [event: HistoryEvent, msg: ROPE _ NIL, offender: ROPE _ NIL]; CreateSubEvent: PROC [event: HistoryEvent, input: ROPE] RETURNS[subEvent: HistoryEvent]; <> StoreInSymTab: PROC [value: TV, event: HistoryEvent, exec: ExecHandle]; <> EvalEvent: PROC [event: HistoryEvent, exec: ExecHandle]; GetEvalHead: PROC [exec: ExecHandle, expr: Expression _ NIL, viewer: Viewer _ NIL] RETURNS [BBEval.EvalHead]; <> ExpandCommandLine: PROC [line: ROPE, modes: Spell.Modes _ NIL, event: HistoryEvent, exec: ExecHandle] RETURNS [ROPE]; <> GetRestOfStream: PROC [in: STREAM, includeLast: BOOL _ TRUE] RETURNS[ROPE]; Prompt: PROC [eventNum: INT, exec: ExecHandle]; <> DoesUserMean: PROC [rope: ROPE, exec: ExecHandle, intro: ROPE _ NIL -- defaults to "perhaps user means:" -- ]; <> ReadQuietly: PROC [rope: ROPE, exec: ExecHandle]; <> GetEventsFromSelection: PROC [exec: ExecHandle] RETURNS [start, end: HistoryEvent] ; <> BlinkIcon: PROC [icon: Viewer, n: INT _ 10]; <> LookupCommand: PROC [name: ROPE, event: HistoryEvent _ NIL, exec: ExecHandle _ NIL] RETURNS[fullName: ROPE]; <> <> GetRegistrationData: PROC [name: ROPE] RETURNS[REF CommandRecord]; dummyCommanderProc: Commander.CommandProc; -- commands registered with userexec are given this dummy def for commander, which when invoked simply prints out that the operation must be performed in a work area CallRegisteredProc: PROC [command: ROPE, event: HistoryEvent, exec: ExecHandle] RETURNS[handled: BOOLEAN _ FALSE]; <> <<>> Register: PROC [ name: ROPE _ NIL, proc: UserExec.CommandProc _ NIL, oldStyleProc: UNSAFE PROCEDURE _ NIL, transformProc: UserExec.TransformProc _ NIL, briefDoc, doc: ROPE _ NIL, nameOfBCD: ROPE _ NIL, clientData: REF ANY _ NIL, fromCatalogue: BOOL _ FALSE ]; <> <> RunAndCall: UserExec.CommandProc; <> RunBCDFile: PROCEDURE[fileName: ROPE, fileCapability: File.Capability _ File.nullCapability, callDebuggerFirst: BOOL _ FALSE, out: STREAM] RETURNS[name: ROPE, error: ROPE]; <> RenameFile: PROCEDURE[oldName, newName: ROPE, out: STREAM] RETURNS[success: BOOL]; PrintDeclFromSource: PROC [target: ROPE, file: ROPE, exec: UserExec.ExecHandle] RETURNS [BOOLEAN]; <> ProcessProfile: PROC; <> PrintCommand: PROCEDURE[name: ROPE, event: HistoryEvent, exec: ExecHandle] RETURNS[recognized: BOOLEAN]; <> UpdateFrameCache: PROC; <> RegisterCommanderStuff: PROCEDURE; <> RopeFromCMFile: PROC [file: ROPE, event: HistoryEvent, exec: ExecHandle] RETURNS[contents: ROPE, name: ROPE]; <> <> <<>> StripComments: PROC [event: HistoryEvent, rope: ROPE] RETURNS [ROPE]; <> <<>> ExecOwner: PROC[exec: ExecHandle] RETURNS[UNSAFE PROCESS] = INLINE {private: REF ExecPrivateRecord = GetPrivateStuff[exec]; RETURN[private.execOwner]}; <> WaitUntilSaved: PROC [fileName: ROPE, exec: UserExec.ExecHandle]; ForAllSplitViewers: PROC [viewer: Viewer, proc: SplitViewerProc]; SplitViewerProc: TYPE = PROC[viewer: Viewer]; END. -- UserExecPrivate