SilFile.Mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Tracy Larrabee, March 29, 1984 1:03:45 pm PST
Last Edited by Ken Pier, August 22, 1985 4:19:04 pm PDT
This module contains the definitions of the external data types and procedures which are the custodian of the internal data structures built for Sil files. Creations, deletions, or queries will pass through here.
THE BASIC IDEA:
Information from one or more Sil Files can be contained in one internal Sil Model.
A Sil Model will consist of a main picture (which is to be displayed), several secondary pictures which have been defined as macro character set, and a list of objects which are currently selected.
Each picture will consist of a list of objects which are to be painted.
Each object will be a box or a rope. Both kinds of objects have positional and color attributes, while ropes also have the attributes of font (including bold and italic). (see below.)
DIRECTORY
Rope USING [ROPE],
SilKernel USING [SilModel]
;
SilFile: CEDAR DEFINITIONS = BEGIN
ROPE: TYPE = Rope.ROPE;
SilModel: TYPE = SilKernel.SilModel;
Fonts are very important in Sil. Every object has a font. There is even a special font for background. How the user is encouraged to think about fonts, and how fonts are stored internally differ (see below).
FontType: TYPE = {print, display};
UserFonts: TYPE = [0..9];
MacroFonts: TYPE = [4..9];
FileMacroFonts: TYPE = [4..4]; 
PresetFonts: TYPE = [0..3];
LibraryFonts: TYPE = [5..9];
InternalFonts: TYPE = [0..15];
InternalMacroFonts: TYPE = [8..13];
InternalFileMacroFonts: TYPE = [8..8];
InternalPresetFonts: TYPE = [0..7];
InternalLibraryFonts: TYPE = [9..13];
InternalRopeFonts: TYPE = [0..13]; --those fonts which do not denote boxes. See below
InternalBoxFonts: TYPE = [14..15];
InternalForegroundBoxFonts: TYPE = [14..14];
InternalBackgroundBoxFonts: TYPE = [15..15];
InternalFileMacroFont: InternalFonts = 8;
foregroundBoxFont: InternalFonts = 14;
backgroundBoxFont: InternalFonts = 15;
Internal fonts correspond to user fonts in the following way:
Internal Font: User Font
0: Font 0
1: Font 0 Bold
2: Font 1
3: Font 1 Bold
4: Font 2
5: Font 2 Bold
6: Font 3
7: Font 3 Bold
8: Font 4 - macro definitions looked up in File
9: Font 5 - macro definitions looked up in Sil.lb5
10: Font 6 - macro definitions looked up in Sil.lb6
11: Font 7 - macro definitions looked up in Sil.lb7
12: Font 8 - macro definitions looked up in Sil.lb8
13: Font 9 - macro definitions looked up in Sil.lb9
14: Object is a box (no associated Rope)
15: Object is a background box (no associated Rope)
SilSelection: TYPE = RECORD[
model: SilModel ← NIL,
objects: SilObject ← NIL,
lastObject: SilObject ← NIL, --this is a dummy object marking the end of the select chain
numObjects: INTEGER ← 0,
xMin, yMin, xMax, yMax: INTEGER ← 0
];
PrintingChars: TYPE = CHAR['!..'~]; -- the range of Ascii chars which print meaningfully
MacroName: TYPE = CHAR['!..'~]; -- only printing characters are used
MacroNameSize: INTEGER = ('~ - '!) + 1; -- number of macro names
SilObject: TYPE = LIST OF SilObjectRec;
SilObjectRec: TYPE = RECORD[
xMin, yMin: INTEGER, -- Upper Left boundary of box or string
xMax, yMax: INTEGER, -- Lower right boundary of box, guess for lower right of string
color: Color, -- Color used to display or print object
font: InternalFonts, -- Only interesting for Ropes (fonts 0-13)
italic: BOOL, -- Only interesting for Ropes (fonts 0-13), TRUE for italic strings
value: ROPENIL,
selectObj: SilObject ← NIL -- chain together all the currently selected objects
];
Color: TYPE = [0..15];
maxRopeLen: INTEGER = 256; --the longest a String can be (1 byte for its length)
PictureType: TYPE = {none, fgnd, bkgnd, macro};
BuildMarkArray: TYPE = ARRAY BuildMarkIndex OF BuildMark;
BuildMarkIndex: TYPE = [1..4];
BuildMark: TYPE = RECORD[
xMin, yMin: INTEGER, -- Upper Left boundary of mark
xMax, yMax: INTEGER -- Lower right boundary of mark
];
buildMarks: BuildMarkArray = [
[0, 753, 80, 760], [162, 753, 242, 760], [324, 753, 404, 760], [486, 753, 566, 760]
];
InitSil: PROC[] ;
This procedure will initialize all of Sil's internal structure by reading in any library files and retreiving the names of any fonts.
! SilError with explain =
BadFile: One of the library files contained some sort sort of lie concerning its length (such as a non-integral number of Sil objects).
BadFileName: a Sil file name was given in the user profile which referenced a file which could not be opened.
NewSilModel: PROC[] RETURNS [model: SilModel];
Create an empty Sil Model.
MainFileToModel: PROC[model: SilModel, name: ROPE, relative: BOOL];
This should be called after Sil has been initialized, and new model has been created.
This proc will add any data in the named file to the main picture data currently in the model provided.
! SilError with explain =
BadFile: This Sil file contained some sort sort of lie concerning its length (such as a non-integral number of Sil objects).
BadFileName: No file could be opened for Read-only given this name.
ModelToFile: PROC[model: SilModel, name: ROPE, clipIt: BOOLFALSE, large: BOOLFALSE, xMin, yMin, xMax, yMax: INTEGER ← 0] RETURNS [wasClipped: BOOLFALSE];
This will output all the information in this model to the file name given. If clipit then only output those objects which lie entirely inside the region given. If large then use the new output format for CedarSil files.
! SilError with explain =
BadFileName: No file could be opened with this name.
ClearModel: PROC[model: SilModel];
This will delete the model's main picture as well as any macro definitions.
ClearMacros: PROC[model: SilModel];
This will cause macro definitions in the model to be discarded, along with any macro objects.
AddObjectToMainPicture: PROC [model: SilModel, sobr: SilObjectRec] RETURNS [sob: SilObject ← NIL];
Add new object to the main picture of model.
GetObjectList: PROC [model: SilModel, mode: PictureType ← fgnd, fontNumber: InternalFonts ← 8, c: CHAR ← '!] RETURNS [oblist: SilObject];
Return the pertinent object list (main, or macro) out of the model. If mode is main, ignore fontNumber and c.
CheckSelectionsForMacroDefs: PROC[model: SilModel, disallowName: BOOLFALSE, name: MacroName ← '!] RETURNS [SelectionOk: BOOLTRUE];
Check the selection to see if it references macro's that are not defined in model. If disallowName, make sure that the selection does not reference any macro's with name name.
DefineMacroFromSelection: PROC[model: SilModel, name: MacroName ← '!, xRef, yRef: INTEGER];
Add the macro definition with name name to the model given.
GetMacroBoundingBox: PROC [model: SilModel, fontNumber: InternalFonts ← 8, c: CHAR ← '!] RETURNS [xMin, yMin, xMax, yMax: INTEGER];
Return the bounding box of the macro given.
GetSelection: PROC [] RETURNS [selection: SilSelection];
Return the selection.
CopySelection: PROC [] RETURNS [copiedSelection: SilSelection];
Return a copy of the selection which has all the objects of the real selection, but no mention of their model.
EvaluateSelection: PROC;
Causes the bounding box of the selection to get reevaluated after some selected objects sizes change
DefineSelectWithBox: PROC [model: SilModel, xMin, yMin, xMax, yMax: INTEGER] RETURNS[objXMin, objYMin, objXMax, objYMax: INTEGER ← 0];
In model, find all the objects inside the box defined by xMin, yMin, xMax, and yMax and add them to the selection. If there are no objects in the box, add no elements to the selection.
Return the actual minimum and maximum dimensions of objects inside the box (if there are no objects within the box return the minimum and maximums provided).
DefineSelectWithObject: PROC [model: SilModel, sob: SilObject];
Sob is added to the previously selected objects.
Deselect: PROC [model: SilModel, sob: SilObject];
Deselect sob.
DeselectAll: PROC [];
Deselect all objects.
DeleteAndCacheSelection: PUBLIC PROC[cache: BOOLFALSE];
Delete all objects which are selected. IF cache, put deleted objects on delete queue.
DeleteAndCacheObject: PUBLIC PROC[model: SilModel, sob: SilObject];
Delete this Specific object (delink it from the selection list if necessary).
Undelete: PROC[model: SilModel] RETURNS [sob: SilObject];
Undelete the most recently deleted object for this model and make it the selection.
ObjectAtPos: PROC [model: SilModel, x, y: INTEGER] RETURNS [sob: SilObject ← NIL];
In model, find the object at <x, y> with the smallest bounding box and return that object. If there is no object at <x, y> return NIL.
ObjectIsSelected: PROC [model: SilModel, sob: SilObject] RETURNS [selected: BOOL];
TRUE if sob is already selected
FontNameFromInternalFont: PROC[font: PresetFonts, fontType: FontType ← display] RETURNS [fName: ROPE];
Return the correct Font name for the given Sil font.
InternalFontFromUserFont: PUBLIC PROC [font: UserFonts, bold: BOOL] RETURNS [ifont: InternalFonts];
Return the internal font corresponding to the user font and boldness given.
UserFontFromInternalFont: PUBLIC PROC [ifont: InternalFonts] RETURNS [font: UserFonts, bold: BOOL];
Return the user font and boldness corresponding to the internal font given.
FontIsBold: PROC [font: InternalFonts] RETURNS [bold: BOOL];
True if this internal font corresponds to a bold user font.
GetActiveFileName: PROC [model: SilModel] RETURNS [name: ROPE];
Get the name of the currently active Sil file for this model.
GetLastActiveFileName: PROC [model: SilModel] RETURNS [name: ROPE];
Get the name of the last active Sil file for this model.
Build marks are visual cues placed in Sil files by the Design Automation postprocessing programms. A file which has build marks will have them removed if the file is edited.
MarkFileAsEdited: PROC [model: SilModel] RETURNS [deletedBuildBoxes: BOOLFALSE];
Mark this file as edited. If this is a "built" file the build marks will be deleted and the display process should know about this.
END.