diff options
-rw-r--r-- | src/gmdocument.c | 12 | ||||
-rw-r--r-- | src/gmdocument.h | 1 | ||||
-rw-r--r-- | src/ui/documentwidget.c | 3 | ||||
-rw-r--r-- | src/ui/window.c | 1 |
4 files changed, 16 insertions, 1 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) |
diff --git a/src/gmdocument.h b/src/gmdocument.h index 959c75ea..22e614ea 100644 --- a/src/gmdocument.h +++ b/src/gmdocument.h | |||
@@ -30,3 +30,4 @@ iInt2 size_GmDocument (const iGmDocument *); | |||
30 | 30 | ||
31 | const iGmRun * findRun_GmDocument (const iGmDocument *, iInt2 pos); | 31 | const iGmRun * findRun_GmDocument (const iGmDocument *, iInt2 pos); |
32 | const iString * linkUrl_GmDocument (const iGmDocument *, iGmLinkId linkId); | 32 | const iString * linkUrl_GmDocument (const iGmDocument *, iGmLinkId linkId); |
33 | const iString * title_GmDocument (const iGmDocument *); | ||
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 030a323b..cb530e9b 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -140,6 +140,9 @@ static void updateSource_DocumentWidget_(iDocumentWidget *d) { | |||
140 | deinit_String(&str); | 140 | deinit_String(&str); |
141 | updateVisible_DocumentWidget_(d); | 141 | updateVisible_DocumentWidget_(d); |
142 | refresh_Widget(as_Widget(d)); | 142 | refresh_Widget(as_Widget(d)); |
143 | setTitle_Window(get_Window(), | ||
144 | !isEmpty_String(title_GmDocument(d->doc)) ? title_GmDocument(d->doc) | ||
145 | : collectNewCStr_String("Lagrange")); | ||
143 | } | 146 | } |
144 | 147 | ||
145 | static void fetch_DocumentWidget_(iDocumentWidget *d) { | 148 | static void fetch_DocumentWidget_(iDocumentWidget *d) { |
diff --git a/src/ui/window.c b/src/ui/window.c index 6196a638..a110c5ad 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -90,7 +90,6 @@ static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) { | |||
90 | else if (equal_Command(cmd, "document.changed")) { | 90 | else if (equal_Command(cmd, "document.changed")) { |
91 | iInputWidget *url = findWidget_App("url"); | 91 | iInputWidget *url = findWidget_App("url"); |
92 | setTextCStr_InputWidget(url, valuePtr_Command(cmd, "url")); | 92 | setTextCStr_InputWidget(url, valuePtr_Command(cmd, "url")); |
93 | setTitle_Window(get_Window(), text_InputWidget(url)); | ||
94 | updateTextCStr_LabelWidget(findChild_Widget(navBar, "reload"), reloadCStr_); | 93 | updateTextCStr_LabelWidget(findChild_Widget(navBar, "reload"), reloadCStr_); |
95 | return iFalse; | 94 | return iFalse; |
96 | } | 95 | } |