1 /* Hypertext "Anchor" Object HTAnchor.h
2 ** ==========================
4 ** An anchor represents a region of a hypertext document which is linked
5 ** to another anchor in the same or a different document.
11 /* Version 0 (TBL) written in Objective-C for the NeXT browser */
12 /* Version 1 of 24-Oct-1991 (JFG), written in C, browser-independant */
18 #define HTAnchor_findChild HTAnFiCh
19 #define HTAnchor_findChildAndLink HTAnFiLi
20 #define HTAnchor_findAddress HTAnFiAd
21 #define HTAnchor_delete HTAnDele
22 #define HTAnchor_makeLastChild HTAnMaLa
23 #define HTAnchor_parent HTAnPare
24 #define HTAnchor_setDocument HTAnSeDo
25 #define HTAnchor_document HTAnDocu
26 #define HTAnchor_setFormat HTAnSeFo
27 #define HTAnchor_format HTAnForm
28 #define HTAnchor_setIndex HTAnSeIn
29 #define HTAnchor_isIndex HTAnIsIn
30 #define HTAnchor_address HTAnAddr
31 #define HTAnchor_hasChildren HTAnHaCh
32 #define HTAnchor_title HTAnTitl
33 #define HTAnchor_setTitle HTAnSeTi
34 #define HTAnchor_appendTitle HTAnApTi
35 #define HTAnchor_link HTAnLink
36 #define HTAnchor_followMainLink HTAnFoMa
37 #define HTAnchor_followTypedLink HTAnFoTy
38 #define HTAnchor_makeMainLink HTAnMaMa
41 /* Main definition of anchor
42 ** =========================
45 typedef struct _HyperDoc HyperDoc; /* Ready for forward references */
46 typedef struct _HTAnchor HTAnchor;
47 typedef struct _HTParentAnchor HTParentAnchor;
51 typedef HTAtom HTLinkType;
54 HTAnchor * dest; /* The anchor to which this leads */
55 HTLinkType * type; /* Semantics of this link */
58 struct _HTAnchor { /* Generic anchor : just links */
59 HTLink mainLink; /* Main (or default) destination of this */
60 HTList * links; /* List of extra links from this, if any */
61 /* We separate the first link from the others to avoid too many small mallocs
62 involved by a list creation. Most anchors only point to one place. */
63 HTParentAnchor * parent; /* Parent of this anchor (self for adults) */
66 struct _HTParentAnchor {
67 /* Common part from the generic anchor structure */
68 HTLink mainLink; /* Main (or default) destination of this */
69 HTList * links; /* List of extra links from this, if any */
70 HTParentAnchor * parent; /* Parent of this anchor (self) */
72 /* ParentAnchor-specific information */
73 HTList * children; /* Subanchors of this, if any */
74 HTList * sources; /* List of anchors pointing to this, if any */
75 HyperDoc * document; /* The document within which this is an anchor */
76 char * address; /* Absolute address of this node */
77 HTFormat * format; /* Pointer to node format descriptor */
78 BOOL isIndex; /* Acceptance of a keyword search */
79 char * title; /* Title of document */
83 /* Common part from the generic anchor structure */
84 HTLink mainLink; /* Main (or default) destination of this */
85 HTList * links; /* List of extra links from this, if any */
86 HTParentAnchor * parent; /* Parent of this anchor */
88 /* ChildAnchor-specific information */
89 char * tag; /* Address of this anchor relative to parent */
93 /* Create new or find old sub-anchor
94 ** ---------------------------------
96 ** This one is for a new anchor being edited into an existing
97 ** document. The parent anchor must already exist.
100 extern HTChildAnchor * HTAnchor_findChild
102 (HTParentAnchor *parent,
106 /* Create or find a child anchor with a possible link
107 ** --------------------------------------------------
109 ** Create new anchor with a given parent and possibly
110 ** a name, and possibly a link to a _relatively_ named anchor.
111 ** (Code originally in ParseHTML.h)
113 extern HTChildAnchor * HTAnchor_findChildAndLink
115 HTParentAnchor * parent, /* May not be 0 */
116 CONST char * tag, /* May be "" or 0 */
117 CONST char * href, /* May be "" or 0 */
118 HTLinkType * ltype /* May be 0 */
122 /* Create new or find old named anchor
123 ** -----------------------------------
125 ** This one is for a reference which is found in a document, and might
126 ** not be already loaded.
127 ** Note: You are not guaranteed a new anchor -- you might get an old one,
131 extern HTAnchor * HTAnchor_findAddress
133 (CONST char * address)
137 /* Delete an anchor and possibly related things (auto garbage collection)
138 ** --------------------------------------------
140 ** The anchor is only deleted if the corresponding document is not loaded.
141 ** All outgoing links from parent and children are deleted, and this anchor
142 ** is removed from the sources list of all its targets.
143 ** We also try to delete the targets whose documents are not loaded.
144 ** If this anchor's source list is empty, we delete it and its children.
147 extern BOOL HTAnchor_delete
149 (HTParentAnchor *this)
153 /* Move an anchor to the head of the list of its siblings
154 ** ------------------------------------------------------
156 ** This is to ensure that an anchor which might have already existed
157 ** is put in the correct order as we load the document.
160 extern void HTAnchor_makeLastChild
162 (HTChildAnchor *this)
165 /* Data access functions
166 ** ---------------------
169 extern HTParentAnchor * HTAnchor_parent
174 extern void HTAnchor_setDocument
176 (HTParentAnchor *this, HyperDoc *doc)
179 extern HyperDoc * HTAnchor_document
181 (HTParentAnchor *this)
183 /* We don't want code to change an address after anchor creation... yet ?
184 extern void HTAnchor_setAddress
186 (HTAnchor *this, char *addr)
190 extern char * HTAnchor_address
195 extern void HTAnchor_setFormat
197 (HTParentAnchor *this, HTFormat *form)
200 extern HTFormat * HTAnchor_format
202 (HTParentAnchor *this)
205 extern void HTAnchor_setIndex
207 (HTParentAnchor *this)
210 extern BOOL HTAnchor_isIndex
212 (HTParentAnchor *this)
215 extern BOOL HTAnchor_hasChildren
217 (HTParentAnchor *this)
222 extern CONST char * HTAnchor_title
224 (HTParentAnchor *this)
227 extern void HTAnchor_setTitle
229 (HTParentAnchor *this, CONST char * title)
232 extern void HTAnchor_appendTitle
234 (HTParentAnchor *this, CONST char * title)
237 /* Link this Anchor to another given one
238 ** -------------------------------------
241 extern BOOL HTAnchor_link
243 (HTAnchor *source, HTAnchor *destination, HTLinkType *type)
246 /* Manipulation of links
247 ** ---------------------
250 extern HTAnchor * HTAnchor_followMainLink
255 extern HTAnchor * HTAnchor_followTypedLink
257 (HTAnchor *this, HTLinkType *type)
260 extern BOOL HTAnchor_makeMainLink
262 (HTAnchor *this, HTLink *movingLink)
265 #endif /* HTANCHOR_H */