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 ŽEdited by Teitelman on May 9, 1983 5:05 pm userexecprivate is for internal communication between modules of userexec, and, in certain exceptional cases, for use by privileged clients. If you are using this interface, please let me (Teitelman) know about it. it is subject to change without notice. Concrete types for opaque types in userexec ExecPrivateRecord and related types for dealing with the interpreter the following relate to interactions with typein and output. for compatibility with old Exec interface following deals with problems of synchronizing input/output to exec where may have several events running simultaneously. ExecState contains the global state of the exec. EventState describes its state with respect to the current event. There is some redundancy, in that if execState = destroyed, eventState could never be running. However, execState might be dormant or notListening and eventState could be running, e.g. if DoIt were called directly. readyForNext means at prompt. receivingInput means user has already typed something. Events and expressions EvalHead the type of the REF stored in BBEval.EvalHead.data. Used in various Help procedures. Included here so that can set defaultInterface field in UserExecInterpImpl Miscellaneous constants and variables suitable for spelling correction and pattern matching on registered commands. commandList: CommandList; signals raised by runbcd raised by UseCommand manipulating execHandles computes caption using name of exec, mode and default context, action area status etc. checks to see if exec is NIL, or destroyed and raises InvalidExecHandle processing events creates a subevent to the current (sub)event, inheriting the relevant properties from the current event, e.g. eventNum, and attaches it to event. makes the & variable associated with event have as its value the indicated tv. For use for those commands which return a value, e.g. walkstack, showframe, etc. move to userexec in case exec # NIL, evalhead is cached in exec, and GetEvalHead just fills in the expr parts of data field of the evalHead. modes used in expansion of *'s. Defaults to users profile settings, but overriden for things like ^X which should not have to be confirmed prompts with &n and _ if appropriate. Computes a sticky addr for beginning of line and saves it on exec. prompts user, loads input stream, and otherwise sets things upto allow user to simply type cr. defined in UserExecRegCmdsImpl, called from UserExecRegCmdsImpl.DoesUserMean, UserExecMethodsImpl.ExpandControlX, Escape. Miscellaneous forks a process which blinks the icon every n seconds until the icon is either opened, destroyed, or some other viewer is selected. name may be misspelled, or incomplete. If there is more than command that matches name, prints an ambiguous message to exec. if event, exec = NIL, simply calls Commander.Lookup. processes the command line and then invokes the registered procedure in appropriate way Private The following procedures should not be of interest to any client of userexec, even a wizard. The only reason they appear in an interface is that they happen to be called from more than one module. defined in UserExecOpsImpl, also called from UserExecMethodsImpl by ImplicitRunAndCall defined in UserExecMiscImpl, called from UserExecRegCmdsImpl.CallRegisteredProc, and UserExecOpsImpl.Run, RunAndCall defined in UserExecMiscImpl, called from DwimImpl.HelpWrongType (for INLINE), and UserExecMethodsImpl.Help. opens stream on file if exists, searches for target as a declaration, and if found, prints declaration to exec.out. If anything fails, returns FALSE. Stream on File is closed defined in ViewerExecOpsImpl, called from ViewerExecOpsImpl.WasProfileEdited, and from UserExecOpsImpl.LoginProc, Login defined in UserExecMethodsImpl, called from UserExecMethodsImpl.Help, also called from UserExecRegCmdsImpl.LookupCommand, prints explanation of name. Used by ? command. Returns FALSE if name not a command defined in DwimImpl. called from UserExecMiscImpl.LoadAndGo. called after run command executed. defined in UserExecRegCmdsImpl. called from UserExecMiscImpl.LoadAndGo. called after run command executed. defined in UserExecMiscImpl, called from UserExecRegCmdsImpl.ExpandCommandLine, and UserExecOpsImpl.CommandsFrom tries RopeFromFile[fileName]. If fails, tries to add .commands and go again. If that fails, tries cm and go again. If that fails, raises FileNotFound to get correction. If that fails, prints message and raises abortthisevent. name is the name of the file that was finally used, and has @ stripped off. defined in UserExecMiscImpl, called from UserExecMiscImpl.DoIt, and also from UserExecRegCmdsImpl.ExpandCommandLine, To be moved to UserExec ส K– "cedar" style˜J˜Jšœ*™*Jšœึ™ึJšœ'™'J˜šฯk ˜ Jšœ œ ˜Jšœœ ˜Jšœ œ˜Jšœ œ˜Jšœœ˜(Jšœœ˜Jšœœ˜Jšœœ˜'Jšœ œฯcQ˜}Jšœœ ˜Jš œ œ]œœœ ˜…Jšœœ˜J˜J˜—J˜Jšะblœœ œœ˜;J˜Jšœœ ˜headšœ+™+šœ#™#šฯnœœ œœ˜+J˜Jšœœž!˜+J˜*J˜*Jšœ ™ J˜Jšœ œœ˜Jšœœœ˜)Jšœ œ˜$Jšœœ˜ J˜Jšœ<™