PropRegistry.mesa
Copyright Ó 1991, 1992 by Xerox Corporation. All rights reserved.
Created by Ken Pier, July 7, 1992 9:52 am PDT
PropRegistry: CEDAR DEFINITIONS = BEGIN
ROPE: TYPE = Rope.ROPE;
Doc: TYPE = REF;
Key: TYPE = ATOM;
Target:
TYPE =
RECORD [v: Doc, targetData:
REF];
-- class specific targetData
RegistryClass: TYPE = REF RegistryClassObj;
RegistryClassObj:
TYPE =
RECORD [
name: ATOM,
getProp: PropGetProc,
setProp: PropSetProc,
remProp: PropRemProc,
listProps: PropListProc,
getTarget: GetTargetProc,
setTarget: SetTargetProc,
validTarget: ValidateTargetProc
];
PropGetProc:
TYPE =
PROC [key: Key, doc: Doc, hint:
REF]
RETURNS [prop, error:
ROPE];
Get the property "prop" whose name is "key" from the currently selected object(s) in "doc". Return NIL if key not found. Return a description in "error" if an error occurs or if the prop is non-unique for the currently selected object(s). "hint" allows further discrimination of "key".
PropSetProc:
TYPE =
PROC [key: Key, doc: Doc, hint:
REF, prop:
ROPE, edited:
BOOL];
Set the property "prop" whose name is "key" on the currently selected object(s) in "doc". If edited = FALSE the editor should not consider the document edited, even though this property has been set. "hint" allows further discrimination of "key".
PropRemProc:
TYPE =
PROC [key: Key, doc: Doc, hint:
REF, edited:
BOOL];
Remove the property whose name is "key" on the currently selected object(s) in "doc". If edited = FALSE the editor should not consider the document edited, even though this property has been set. "hint" allows further discrimination of "key".
PropListProc:
TYPE =
PROC [doc: Doc, hint:
REF]
RETURNS [props:
LIST
OF Key];
List all the propertys "props" of the currently selected object(s) in "doc". Duplicate props may occur for non-unique values of any given key. "hint" allows further discrimination of "key".
GetTargetProc:
TYPE =
PROC [doc: Doc, hint:
REF]
RETURNS [success:
BOOL, t: Target];
Get the current selection target of "doc", using "hint" if needed. success is FALSE if target acquisition fails.
SetTargetProc:
TYPE =
PROC [doc: Doc, hint:
REF, t: Target]
RETURNS [success:
BOOL, error:
ROPE];
Set the current selection target of "doc" to "t", using "hint" if needed. Return TRUE if the target "t" becomes a legitimate target within "doc". Return FALSE and an optional error message if "t" is not legitimate.
ValidateTargetProc:
TYPE =
PROC [doc: Doc, hint:
REF, t: Target]
RETURNS [success:
BOOL, error:
ROPE];
Return TRUE if the target "t" is still a legitimate target within "doc", using "hint" if needed. Return FALSE and an optional error message if "t" is not legitimate.
Register:
PROC [class: RegistryClass];
Add a RegistryClass to the Prop Registry; replaces any previously registered RegistryClass of the same "name". The "name" field of the RegistryClass may be identical to the "class" field of the ViewerClass for which this registry occurs.
GetRegistered:
PROC [name:
ATOM]
RETURNS [class: RegistryClass];
Return NIL of no RegistryClass of that name exists
END.