grafthistory: comment about downloading the pack index
[elinks/elinks-j605.git] / src / document / document.h
blob845c15fbecf29c8685b1eb680c6530bd437db035
1 #ifndef EL__DOCUMENT_DOCUMENT_H
2 #define EL__DOCUMENT_DOCUMENT_H
4 #include "document/options.h"
5 #include "intl/charsets.h" /* unicode_val_T */
6 #include "main/object.h"
7 #include "protocol/uri.h"
8 #include "util/color.h"
9 #include "util/lists.h"
10 #include "util/box.h"
12 struct cache_entry;
13 struct document_refresh;
14 struct form_control;
15 struct frame_desc;
16 struct frameset_desc;
17 struct module;
18 struct screen_char;
20 /* Nodes are used for marking areas of text on the document canvas as
21 * searchable. */
22 struct node {
23 LIST_HEAD(struct node);
25 struct box box;
29 /* The document line consisting of the chars ready to be copied to the terminal
30 * screen. */
31 struct line {
32 struct screen_char *chars;
33 int length;
36 /* Codepage status */
37 enum cp_status {
38 CP_STATUS_NONE,
39 CP_STATUS_SERVER,
40 CP_STATUS_ASSUMED,
41 CP_STATUS_IGNORED
45 struct point {
46 int x, y;
50 enum link_type {
51 LINK_HYPERTEXT,
52 LINK_MAP,
53 LINK_BUTTON,
54 LINK_CHECKBOX,
55 LINK_SELECT,
56 LINK_FIELD,
57 LINK_AREA,
60 struct script_event_hook {
61 LIST_HEAD(struct script_event_hook);
63 enum script_event_hook_type {
64 SEVHOOK_ONCLICK,
65 SEVHOOK_ONDBLCLICK,
66 SEVHOOK_ONMOUSEOVER,
67 SEVHOOK_ONHOVER,
68 SEVHOOK_ONFOCUS,
69 SEVHOOK_ONMOUSEOUT,
70 SEVHOOK_ONBLUR,
71 } type;
72 unsigned char *src;
75 struct link {
76 unicode_val_T accesskey;
78 enum link_type type;
80 unsigned char *where;
81 unsigned char *target;
82 unsigned char *where_img;
83 unsigned char *title;
85 /* The set of characters belonging to this link (their coordinates
86 * in the document) - each character has own {struct point}. */
87 struct point *points;
88 int npoints;
90 int number;
92 /* This is supposed to be the colour-pair of the link, but the actual
93 * colours on the canvas can differ--e.g., with image links. */
94 struct color_pair color;
96 /* XXX: They don't neccessary need to be link-specific, but we just
97 * don't support them for any other elements for now. Well, we don't
98 * even have a good place where to store them in that case. */
99 struct list_head *event_hooks; /* -> struct script_event_hook */
101 union {
102 unsigned char *name;
103 struct form_control *form_control;
104 } data;
107 #define get_link_index(document, link) (link - document->links)
109 #define link_is_textinput(link) \
110 ((link)->type == LINK_FIELD || (link)->type == LINK_AREA)
112 #define link_is_form(link) \
113 ((link)->type != LINK_HYPERTEXT && (link)->type != LINK_MAP)
115 #define get_link_form_control(link) \
116 (link_is_form(link) ? (link)->data.form_control : NULL)
118 #define get_link_name(link) \
119 (!link_is_form(link) ? (link)->data.name : NULL)
122 struct search {
123 int x, y;
124 signed int n:24; /* This structure is size-critical */
125 unsigned char c;
129 struct document {
130 OBJECT_HEAD(struct document);
132 struct document_options options;
134 struct list_head forms; /* -> struct form */
135 struct list_head tags; /* -> struct tag */
136 struct list_head nodes; /* -> struct node */
138 #ifdef CONFIG_ECMASCRIPT
139 /* ECMAScript snippets to be executed during loading the document into
140 * a window. This currently involves <script>s and onLoad handlers.
141 * Note that if you hit a string beginning by '^' here, it is followed
142 * by an external reference - you must wait with processing other items
143 * until it gets resolved and loaded. New items are guaranteed to
144 * always appear at the list end. */
145 struct list_head onload_snippets; /* -> struct string_list_item */
146 /* FIXME: We should externally maybe using cache_entry store the
147 * dependencies between the various entries so nothing gets removed
148 * unneeded. */
149 struct uri_list ecmascript_imports;
150 #endif
151 #ifdef CONFIG_CSS
152 /* FIXME: We should externally maybe using cache_entry store the
153 * dependencies between the various entries so nothing gets removed
154 * unneeded. */
155 struct uri_list css_imports;
156 /* Calculated from the id's of all the cache entries in css_imports.
157 * Used for checking rerendering for available CSS imports. */
158 unsigned long css_magic;
159 #endif
161 struct uri *uri;
162 unsigned char *title;
164 struct frame_desc *frame;
165 struct frameset_desc *frame_desc; /* RENAME ME */
166 struct document_refresh *refresh;
168 struct line *data;
170 struct link *links;
171 /* Arrays with one item per rendered document's line. */
172 struct link **lines1; /* The first link on the line. */
173 struct link **lines2; /* The last link on the line. */
175 struct search *search;
176 struct search **slines1;
177 struct search **slines2;
179 unsigned int id; /* Used to check cache entries. */
181 int cp;
182 int width, height; /* size of document */
183 int nlinks;
184 int nsearch;
185 color_T bgcolor;
187 enum cp_status cp_status;
190 #define document_has_frames(document_) ((document_) && (document_)->frame_desc)
192 /* Initializes a document and its canvas. */
193 /* Return NULL on allocation failure. */
194 struct document *
195 init_document(struct cache_entry *cached, struct document_options *options);
197 /* Releases the document and all its resources. */
198 void done_document(struct document *document);
200 /* Free's the allocated members of the link. */
201 void done_link_members(struct link *link);
203 /* Calculates css magic from available CSS imports. Used for determining
204 * validity of formatted documents in the cache. */
205 unsigned long get_document_css_magic(struct document *document);
207 void update_cached_document_options(void);
209 struct document *get_cached_document(struct cache_entry *cached, struct document_options *options);
211 /* Release a reference to the document. */
212 void release_document(struct document *document);
214 int get_format_cache_size(void);
215 int get_format_cache_used_count(void);
216 int get_format_cache_refresh_count(void);
218 void shrink_format_cache(int);
220 extern struct module document_module;
222 /* FIXME: support for entities and all Unicode characters.
223 * For now, we only support simple printable character. */
224 #define accesskey_string_to_unicode(s) (((s)[0] && !(s)[1] && isprint((s)[0])) ? (s)[0] : 0)
226 #endif