-- TiogaExecute.mesa -- written by Bill Paxton, May 1981 -- last edit by Bill Paxton, 29-Jun-81 10:15:29 -- This package implements the Execute command in Tioga DIRECTORY Rope, TextNode, UndoEvent; TiogaExecute: DEFINITIONS = BEGIN OPEN nodeI:TextNode, ropeI:Rope; RefTextNode: TYPE = nodeI.RefTextNode; Offset: TYPE = nodeI.Offset; NodeList: TYPE = nodeI.NodeList; Rope: TYPE = ropeI.Ref; Event: TYPE = UndoEvent.Ref; -- ***** Execute Exec: PROC [keyNode: RefTextNode, keyStart, keyLen: Offset, dictList: NodeList, event: Event ← NIL] RETURNS [foundIt: BOOLEAN, exec: Rope, resultStart, resultLen: Offset]; -- dictList is a list of dictionaries -- looks for key in dictionaries, returns foundIt=FALSE if cannot find the key -- each dictionary in the list is expected to have entries as top level branches -- an entry is a branch of the following form: -- <key> is the text of the top node -- typename of the top node determines what kind of entry it is -- if dictionary key has typename = "abbrev" or typename = "", -- text of first child node replaces key in keyNode -- start and length of replacement returned as resultStart & resultLen -- replacement recorded with event so can be undone -- children of first child node are inserted as children of keyNode -- siblings of first child node are inserted as siblings of keyNode -- looks of first letter of key are added to looks of expansion text -- if key is all uppercase, then -- first letter of each word in the expansion is forced uppercase -- this is useful for expansion as a title, for example. -- key is considered to be all uppercase if it has at least one uppercase -- and no lowercase letters -- otherwise, if first letter of key is uppercase, then -- first letter of expansion is forced uppercase -- useful for expansion at start of sentence -- if it has typename = "command", -- text of first child node is returned to be executed -- note that this does not automatically delete the key -- no other typenames are currently defined -- ***** Initialization Start: PROC; -- for initialization only END.