diff options
Diffstat (limited to 'src/gmdocument.c')
-rw-r--r-- | src/gmdocument.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/gmdocument.c b/src/gmdocument.c index eb147925..f1f63b29 100644 --- a/src/gmdocument.c +++ b/src/gmdocument.c | |||
@@ -28,6 +28,7 @@ struct Impl_GmDocument { | |||
28 | iInt2 size; | 28 | iInt2 size; |
29 | iArray layout; /* contents of source, laid out in document space */ | 29 | iArray layout; /* contents of source, laid out in document space */ |
30 | iPtrArray links; | 30 | iPtrArray links; |
31 | iString title; /* the first top-level title */ | ||
31 | }; | 32 | }; |
32 | 33 | ||
33 | iDefineObjectConstruction(GmDocument) | 34 | iDefineObjectConstruction(GmDocument) |
@@ -166,6 +167,7 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
166 | static const char *bullet = "\u2022"; | 167 | static const char *bullet = "\u2022"; |
167 | clear_Array(&d->layout); | 168 | clear_Array(&d->layout); |
168 | clearLinks_GmDocument_(d); | 169 | clearLinks_GmDocument_(d); |
170 | clear_String(&d->title); | ||
169 | if (d->size.x <= 0 || isEmpty_String(&d->source)) { | 171 | if (d->size.x <= 0 || isEmpty_String(&d->source)) { |
170 | return; | 172 | return; |
171 | } | 173 | } |
@@ -242,6 +244,10 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
242 | pos.y += required - delta; | 244 | pos.y += required - delta; |
243 | } | 245 | } |
244 | } | 246 | } |
247 | /* Document title. */ | ||
248 | if (type == header1_GmLineType && isEmpty_String(&d->title)) { | ||
249 | setRange_String(&d->title, line); | ||
250 | } | ||
245 | /* List bullet. */ | 251 | /* List bullet. */ |
246 | run.color = colors[type]; | 252 | run.color = colors[type]; |
247 | if (type == bullet_GmLineType) { | 253 | if (type == bullet_GmLineType) { |
@@ -289,9 +295,11 @@ void init_GmDocument(iGmDocument *d) { | |||
289 | d->size = zero_I2(); | 295 | d->size = zero_I2(); |
290 | init_Array(&d->layout, sizeof(iGmRun)); | 296 | init_Array(&d->layout, sizeof(iGmRun)); |
291 | init_PtrArray(&d->links); | 297 | init_PtrArray(&d->links); |
298 | init_String(&d->title); | ||
292 | } | 299 | } |
293 | 300 | ||
294 | void deinit_GmDocument(iGmDocument *d) { | 301 | void deinit_GmDocument(iGmDocument *d) { |
302 | deinit_String(&d->title); | ||
295 | clearLinks_GmDocument_(d); | 303 | clearLinks_GmDocument_(d); |
296 | deinit_PtrArray(&d->links); | 304 | deinit_PtrArray(&d->links); |
297 | deinit_Array(&d->layout); | 305 | deinit_Array(&d->layout); |
@@ -410,4 +418,8 @@ const iString *linkUrl_GmDocument(const iGmDocument *d, iGmLinkId linkId) { | |||
410 | return NULL; | 418 | return NULL; |
411 | } | 419 | } |
412 | 420 | ||
421 | const iString *title_GmDocument(const iGmDocument *d) { | ||
422 | return &d->title; | ||
423 | } | ||
424 | |||
413 | iDefineClass(GmDocument) | 425 | iDefineClass(GmDocument) |