<> <> DIRECTORY Atom USING [PropList], IO USING [STREAM, UserAborted], Rope USING [ROPE], RTBasic USING [TV, Type], Spell USING [SpellingList, SpellingGenerator, Filter, Modes], ViewerClasses USING [Viewer] ; UserExec: CEDAR DEFINITIONS IMPORTS IO = BEGIN <> <> ROPE: TYPE = Rope.ROPE; STREAM: TYPE = IO.STREAM; TV: TYPE = RTBasic.TV; Type: TYPE = RTBasic.Type; Viewer: TYPE = ViewerClasses.Viewer; ExecHandle: TYPE = REF ExecRecord; ExecRecord: TYPE = RECORD [ viewer: Viewer, privateStuff: REF ExecPrivateRecord ]; ExecPrivateRecord: TYPE; HistoryList: TYPE = LIST OF HistoryEvent; HistoryEvent: TYPE = REF HistoryEventRecord; HistoryEventRecord: TYPE = RECORD[ input: ROPE _ NIL, commandLine: ROPE _ NIL, -- input with firstToken and any comments removed, *'s expanded, etc. commandLineStream: STREAM _ NIL, expression: Expression _ NIL, subEvents: LIST OF HistoryEvent _ NIL, props: Atom.PropList _ NIL, tryHard: BOOL _ FALSE, -- true for events ending in !. used by interpreter as well as some other events, e.g. list files! means use spelling correction dontCorrect: BOOLEAN _ FALSE, privateStuff: REF HistoryEventPrivateRecord _ NIL ]; HistoryEventPrivateRecord: TYPE; Expression: TYPE = REF ExpressionRecord; ExpressionRecord: TYPE = RECORD[ rope: ROPE, value: TV _ NIL, numRtns: INTEGER _ 0, dontCorrect: BOOLEAN _ FALSE, correctionMade: BOOL _ FALSE, privateStuff: REF ExpressionPrivateRecord _ NIL ]; ExpressionPrivateRecord: TYPE; CommandProc: TYPE = PROC [event: HistoryEvent, exec: ExecHandle, clientData: REF ANY _ NIL] RETURNS[ok: BOOLEAN _ TRUE, msg: ROPE _ NIL]; <> TransformProc: TYPE = PROC [event: HistoryEvent, exec: ExecHandle, clientData: REF ANY _ NIL] RETURNS[result: ROPE _ NIL]; <> MethodProc: TYPE = PROC [event: HistoryEvent, exec: ExecHandle, clientData: REF ANY _ NIL] RETURNS[handled: BOOLEAN _ FALSE]; <> InvalidExecHandle: ERROR [exec: ExecHandle, msg: ROPE]; ErrorThisEvent: ERROR [event: HistoryEvent, msg: ROPE]; <> ParseFailed: ERROR [expr: Expression, msg: ROPE]; EvaluationFailed: ERROR [expr: Expression, msg: ROPE]; <> <> CreateUserExecutive: PROCEDURE [name: ROPE _ NIL, viewer: Viewer _ NIL, paint: BOOL _ TRUE, iconic: BOOL _ FALSE, msg: ROPE _ NIL, startListening: BOOL _ TRUE] RETURNS[exec: ExecHandle]; <> StartListening: PROC [exec: ExecHandle]; <> <> GetExecHandle: PROCEDURE [id: ROPE _ NIL, viewer: Viewer _ NIL, process: UNSAFE PROCESS _ NIL] RETURNS[exec: ExecHandle]; <> <> <> <> <<>> <> <<>> GetDefaultExecHandle: PROCEDURE RETURNS[exec: ExecHandle]; <> <> RegisterCommand: PROC [name: ROPE, proc: CommandProc, briefDoc, doc: ROPE _ NIL, clientData: REF ANY _ NIL]; <> <> <> <> RegisterTransformation: PROC [name: ROPE, proc: TransformProc, briefDoc, doc: ROPE _ NIL, clientData: REF ANY _ NIL]; <> RegisterMethod: PROC [name: ROPE, proc: MethodProc, doc: ROPE _ NIL, clientData: REF ANY _ NIL]; <> <> <> DoIt: PROCEDURE [input: ROPE, exec: ExecHandle _ GetDefaultExecHandle[], partOf: HistoryEvent _ NIL]; <<"does" input. Input can correspond to a single event or a multiple event. If partOf is non-NIL, any events created will be nested under partOf. (For example, history commands and the implementation of command files use this argument.)>> <> << >> StuffIt: PROC [exec: ExecHandle, rope: ROPE, list: LIST OF REF ANY _ NIL]; <> <> <> <> <> <> <> <> <> <> <<{VirtualDesktops.SetName[name: name];>> <> <> <<}>> <> <<};>> <<>> GetStreams: PROC [exec: ExecHandle _ GetExecHandle[]] RETURNS [in, out: STREAM]; <> <> <> <> AcquireStreams: PROC [exec: ExecHandle] RETURNS [in, out: STREAM]; ReleaseStreams: PROC [exec: ExecHandle]; <> CheckForAbort: PROC [exec: ExecHandle, msg: ROPE _ NIL] = INLINE {IF exec # NIL AND UserAbort[exec] THEN UserAborted[exec, msg]}; UserAborted: PROC [exec: ExecHandle, msg: ROPE _ NIL] = INLINE {ERROR IO.UserAborted[exec, msg]}; UserAbort: PROC [exec: ExecHandle] RETURNS [abort: BOOLEAN]; <> SetUserAbort: PROC [exec: ExecHandle]; <> ResetUserAbort: PROC [exec: ExecHandle]; <> <> <> AskUser: PROC [msg: ROPE, timeout: INT _ -1, defaultKey: ATOM _ NIL, exec: ExecHandle _ NIL, viewer: Viewer _ NIL, keyList: LIST OF ATOM _ NIL] RETURNS[value: ATOM]; < LIST[$Yes, $No].>> <<>> <> <<>> <> <<>> <> Confirm: PROC [msg: ROPE, timeout: INT _ -1, defaultConfirm: BOOL _ FALSE, exec: ExecHandle, viewer: Viewer _ NIL] RETURNS[BOOLEAN] = INLINE {RETURN[AskUser[msg: msg, timeout: timeout, defaultKey: IF defaultConfirm THEN $Yes ELSE $No, exec: exec, viewer: viewer] = $Yes]}; <> <> <<>> SetupAskUser: PROC [viewer: Viewer, keyList: LIST OF ATOM _ NIL]; <> FinishAskUser: PROC [viewer: Viewer, keyList: LIST OF ATOM _ NIL]; <> GetUserResponse: PROC [viewer: Viewer] RETURNS [hasResponded: BOOL, value: ATOM]; SetUserResponse: PROC [viewer: Viewer, value: ATOM]; ResetUserResponse: PRIVATE PROC [viewer: Viewer]; <> <> <<>> CreateExpr: PROCEDURE [rope: ROPE, dontCorrect: BOOL _ FALSE] RETURNS [Expression]; EvalExpr: PROCEDURE [expr: Expression, exec: ExecHandle _ NIL, viewer: ViewerClasses.Viewer _ NIL] RETURNS[value: TV, numRtns: INT]; <> <> GetNameAndPassword: PROC RETURNS [name, password: ROPE]; SetNameAndPassword: PROC [name, password: ROPE]; Login: PROC [in, out: STREAM] RETURNS[name, password: ROPE]; <> <> <> GetTheOne: PROCEDURE [ unknown: ROPE, spellingList: Spell.SpellingList _ NIL, generator: Spell.SpellingGenerator _ NIL, event: HistoryEvent, exec: ExecHandle, viewer: Viewer _ NIL, filter: Spell.Filter _ NIL, modes: Spell.Modes _ NIL ] RETURNS [correct: ROPE]; GetMatchingList: PROCEDURE [ unknown: ROPE, spellingList: Spell.SpellingList _ NIL, generator: Spell.SpellingGenerator _ NIL, event: HistoryEvent, exec: ExecHandle, viewer: Viewer _ NIL, filter: Spell.Filter _ NIL, modes: Spell.Modes _ NIL ] RETURNS [matches: LIST OF ROPE]; GetTheFile: PROC [ file: ROPE, defaultExt: ROPE _ NIL, event: HistoryEvent, exec: ExecHandle, viewer: Viewer _ NIL, modes: Spell.Modes _ NIL ] RETURNS [correct: ROPE]; <> GetMatchingFileList: PROC [ file: ROPE, defaultExt: ROPE _ NIL, event: HistoryEvent, exec: ExecHandle, viewer: Viewer _ NIL, modes: Spell.Modes _ NIL ] RETURNS[matches: LIST OF ROPE]; <> <> <> <> <> <> AcquireResource: PROC [resource: REF ANY, owner: ROPE, exec: ExecHandle _ NIL] RETURNS[newlyAcquired: BOOL]; <> <<>> ReleaseResource: PROC [resource: REF ANY, doWhenReleased: PROC[REF ANY] _ NIL] RETURNS[released: BOOL]; <> <> CheckForFile: PROC [file: ROPE] RETURNS [found: BOOLEAN]; <> RopeSubst: PROC [old, new, base: ROPE, case: BOOLEAN _ FALSE, allOccurrences: BOOLEAN _ TRUE] RETURNS[value: ROPE]; <> <> ProcessPutProp: PROC [process: UNSAFE PROCESS, prop: REF ANY, value: REF ANY]; ProcessGetProp: PROC [process: UNSAFE PROCESS, prop: REF ANY] RETURNS[value: REF ANY]; NameProcess: PROC [name: ROPE, process: UNSAFE PROCESS] = INLINE {ProcessPutProp[process, $Name, name]}; END. -- NewUserExec Converting from 3.5 The following are some suggestions about how to convert from 3.5. If you import UserExecUtilities, all of these procedures are now in UserExec. If you imported UserExecExtras, the procedures that you are using are probably in UserExec. If not, see me. If you implement your own CommandProc, make the following changes: exec.commandLine => event.commandLine. exec.commandLineStream => event.commandLineStream. exec.in => UserExec.GetStreams[exec].in exec.out => UserExec.GetStreams[exec].out If you have been using any other fields from exec, see me. Change UserExec.GetExecHandle[] to UserExec.GetExecHandle[returnDefault: TRUE] if you always want an exec handle returned. If you are calling GetExecHandle from a context in which you expect to be running under an exec, then it is probably best to continue calling just GetExecHandle[].