summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gmdocument.c5
-rw-r--r--src/gmrequest.c2
-rw-r--r--src/ui/documentwidget.c24
3 files changed, 16 insertions, 15 deletions
diff --git a/src/gmdocument.c b/src/gmdocument.c
index 535a873e..a6fc39c5 100644
--- a/src/gmdocument.c
+++ b/src/gmdocument.c
@@ -413,8 +413,9 @@ static void doLayout_GmDocument_(iGmDocument *d) {
413 pos.y += required - delta; 413 pos.y += required - delta;
414 } 414 }
415 } 415 }
416 /* Save the document title. */ 416 /* Save the document title (first high-level heading). */
417 if (type == heading1_GmLineType && isEmpty_String(&d->title)) { 417 if ((type == heading1_GmLineType || type == heading2_GmLineType) &&
418 isEmpty_String(&d->title)) {
418 setRange_String(&d->title, line); 419 setRange_String(&d->title, line);
419 } 420 }
420 /* List bullet. */ 421 /* List bullet. */
diff --git a/src/gmrequest.c b/src/gmrequest.c
index 2b6ee9f9..0d69861d 100644
--- a/src/gmrequest.c
+++ b/src/gmrequest.c
@@ -330,7 +330,7 @@ void submit_GmRequest(iGmRequest *d) {
330 /* TODO: Check supported file types: images, audio */ 330 /* TODO: Check supported file types: images, audio */
331 /* TODO: Detect text files based on contents? E.g., is the content valid UTF-8. */ 331 /* TODO: Detect text files based on contents? E.g., is the content valid UTF-8. */
332 d->resp.statusCode = success_GmStatusCode; 332 d->resp.statusCode = success_GmStatusCode;
333 if (endsWithCase_String(path, ".gmi")) { 333 if (endsWithCase_String(path, ".gmi") || endsWithCase_String(path, ".gemini")) {
334 setCStr_String(&d->resp.meta, "text/gemini; charset=utf-8"); 334 setCStr_String(&d->resp.meta, "text/gemini; charset=utf-8");
335 } 335 }
336 else if (endsWithCase_String(path, ".txt")) { 336 else if (endsWithCase_String(path, ".txt")) {
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index b5fdde93..29803252 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -1001,16 +1001,18 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd)
1001 return iTrue; 1001 return iTrue;
1002 } 1002 }
1003 else if (equal_Command(cmd, "document.input.submit")) { 1003 else if (equal_Command(cmd, "document.input.submit")) {
1004 iString *value = collect_String(suffix_Command(cmd, "value")); 1004 if (arg_Command(cmd)) {
1005 urlEncode_String(value); 1005 iString *value = collect_String(suffix_Command(cmd, "value"));
1006 iString *url = collect_String(copy_String(d->mod.url)); 1006 urlEncode_String(value);
1007 const size_t qPos = indexOfCStr_String(url, "?"); 1007 iString *url = collect_String(copy_String(d->mod.url));
1008 if (qPos != iInvalidPos) { 1008 const size_t qPos = indexOfCStr_String(url, "?");
1009 remove_Block(&url->chars, qPos, iInvalidSize); 1009 if (qPos != iInvalidPos) {
1010 remove_Block(&url->chars, qPos, iInvalidSize);
1011 }
1012 appendCStr_String(url, "?");
1013 append_String(url, value);
1014 postCommandf_App("open url:%s", cstr_String(url));
1010 } 1015 }
1011 appendCStr_String(url, "?");
1012 append_String(url, value);
1013 postCommandf_App("open url:%s", cstr_String(url));
1014 return iTrue; 1016 return iTrue;
1015 } 1017 }
1016 else if (equal_Command(cmd, "valueinput.cancelled") && 1018 else if (equal_Command(cmd, "valueinput.cancelled") &&
@@ -1577,7 +1579,6 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) {
1577 } 1579 }
1578 } 1580 }
1579 } 1581 }
1580
1581// drawRect_Paint(&d->paint, (iRect){ visPos, run->bounds.size }, green_ColorId); 1582// drawRect_Paint(&d->paint, (iRect){ visPos, run->bounds.size }, green_ColorId);
1582// drawRect_Paint(&d->paint, (iRect){ visPos, run->visBounds.size }, red_ColorId); 1583// drawRect_Paint(&d->paint, (iRect){ visPos, run->visBounds.size }, red_ColorId);
1583} 1584}
@@ -1625,7 +1626,6 @@ static void draw_DocumentWidget_(const iDocumentWidget *d) {
1625 const iRect visBufferRect = { zero_I2(), d->visBufferSize }; 1626 const iRect visBufferRect = { zero_I2(), d->visBufferSize };
1626 iRect drawRect = visBufferRect; 1627 iRect drawRect = visBufferRect;
1627 if (!isEmpty_Rangei_(intersect_Rangei_(visRange, d->visBufferValidRange))) { 1628 if (!isEmpty_Rangei_(intersect_Rangei_(visRange, d->visBufferValidRange))) {
1628 const iRangei isct = intersect_Rangei_(visRange, d->visBufferValidRange);
1629 if (visRange.start < d->visBufferValidRange.start) { 1629 if (visRange.start < d->visBufferValidRange.start) {
1630 drawRange = (iRangei){ visRange.start, d->visBufferValidRange.start }; 1630 drawRange = (iRangei){ visRange.start, d->visBufferValidRange.start };
1631 } 1631 }
@@ -1652,7 +1652,7 @@ static void draw_DocumentWidget_(const iDocumentWidget *d) {
1652 } 1652 }
1653 if (!isEmpty_Range(&drawRange)) { 1653 if (!isEmpty_Range(&drawRange)) {
1654 setClip_Paint(p, drawRect); 1654 setClip_Paint(p, drawRect);
1655 fillRect_Paint(p, drawRect, vbDst == 1 ? blue_ColorId : red_ColorId); //tmBackground_ColorId); 1655 fillRect_Paint(p, drawRect, tmBackground_ColorId); // vbDst == 1 ? blue_ColorId : red_ColorId
1656 render_GmDocument(d->doc, drawRange, drawRun_DrawContext_, &ctxStatic); 1656 render_GmDocument(d->doc, drawRange, drawRun_DrawContext_, &ctxStatic);
1657 unsetClip_Paint(p); 1657 unsetClip_Paint(p);
1658 } 1658 }