summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gmdocument.c9
-rw-r--r--src/ui/documentwidget.c56
2 files changed, 47 insertions, 18 deletions
diff --git a/src/gmdocument.c b/src/gmdocument.c
index 29e97300..0197ed99 100644
--- a/src/gmdocument.c
+++ b/src/gmdocument.c
@@ -925,7 +925,7 @@ static void doLayout_GmDocument_(iGmDocument *d) {
925 : paragraph_FontId; 925 : paragraph_FontId;
926 alignDecoration_GmRun_(&icon, iFalse); 926 alignDecoration_GmRun_(&icon, iFalse);
927 icon.color = linkColor_GmDocument(d, run.linkId, icon_GmLinkPart); 927 icon.color = linkColor_GmDocument(d, run.linkId, icon_GmLinkPart);
928 icon.flags |= decoration_GmRunFlag; 928 icon.flags |= decoration_GmRunFlag | startOfLine_GmRunFlag;
929 pushBack_Array(&d->layout, &icon); 929 pushBack_Array(&d->layout, &icon);
930 } 930 }
931 run.lineType = type; 931 run.lineType = type;
@@ -1039,7 +1039,12 @@ static void doLayout_GmDocument_(iGmDocument *d) {
1039 deinit_RunTypesetter_(&rts); 1039 deinit_RunTypesetter_(&rts);
1040 } 1040 }
1041 /* Flag the end of line, too. */ 1041 /* Flag the end of line, too. */
1042 ((iGmRun *) back_Array(&d->layout))->flags |= endOfLine_GmRunFlag; 1042 iGmRun *lastRun = back_Array(&d->layout);
1043 lastRun->flags |= endOfLine_GmRunFlag;
1044 if (lastRun->linkId && lastRun->flags & startOfLine_GmRunFlag) {
1045 /* Single-run link: the icon should also be marked endOfLine. */
1046 lastRun[-1].flags |= endOfLine_GmRunFlag;
1047 }
1043 /* Image or audio content. */ 1048 /* Image or audio content. */
1044 if (type == link_GmLineType) { 1049 if (type == link_GmLineType) {
1045 /* TODO: Cleanup here? Move to a function of its own. */ 1050 /* TODO: Cleanup here? Move to a function of its own. */
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 06e3475a..45b96082 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -4749,7 +4749,18 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) {
4749 runOffset_DocumentWidget_(d->widget, run)); 4749 runOffset_DocumentWidget_(d->widget, run));
4750 const iRect visRect = { visPos, run->visBounds.size }; 4750 const iRect visRect = { visPos, run->visBounds.size };
4751 /* Fill the background. */ { 4751 /* Fill the background. */ {
4752 if (run->linkId && linkFlags & isOpen_GmLinkFlag && ~linkFlags & content_GmLinkFlag) { 4752#if 0
4753 iBool isInlineImageCaption = run->linkId && linkFlags & content_GmLinkFlag &&
4754 ~linkFlags & permanent_GmLinkFlag;
4755 if (run->flags & decoration_GmRunFlag && ~run->flags & startOfLine_GmRunFlag) {
4756 /* This is the metadata. */
4757 isInlineImageCaption = iFalse;
4758 }
4759#endif
4760 /* While this is consistent, it's a bit excessive to indicate that an inlined image
4761 is open: the image itself is the indication. */
4762 const iBool isInlineImageCaption = iFalse;
4763 if (run->linkId && (linkFlags & isOpen_GmLinkFlag || isInlineImageCaption)) {
4753 /* Open links get a highlighted background. */ 4764 /* Open links get a highlighted background. */
4754 int bg = tmBackgroundOpenLink_ColorId; 4765 int bg = tmBackgroundOpenLink_ColorId;
4755 const int frame = tmFrameOpenLink_ColorId; 4766 const int frame = tmFrameOpenLink_ColorId;
@@ -4757,6 +4768,9 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) {
4757 iRect wideRect = { init_I2(d->docBounds.pos.x - pad, visPos.y), 4768 iRect wideRect = { init_I2(d->docBounds.pos.x - pad, visPos.y),
4758 init_I2(d->docBounds.size.x + 2 * pad, 4769 init_I2(d->docBounds.size.x + 2 * pad,
4759 height_Rect(run->visBounds)) }; 4770 height_Rect(run->visBounds)) };
4771 adjustEdges_Rect(&wideRect,
4772 run->flags & startOfLine_GmRunFlag ? -pad * 3 / 4 : 0, 0,
4773 run->flags & endOfLine_GmRunFlag ? pad * 3 / 4 : 0, 0);
4760 /* The first line is composed of two runs that may be drawn in either order, so 4774 /* The first line is composed of two runs that may be drawn in either order, so
4761 only draw half of the background. */ 4775 only draw half of the background. */
4762 if (run->flags & decoration_GmRunFlag) { 4776 if (run->flags & decoration_GmRunFlag) {
@@ -4773,13 +4787,21 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) {
4773 e.g., at the buffer boundary, and there are slightly overlapping characters in 4787 e.g., at the buffer boundary, and there are slightly overlapping characters in
4774 monospace blocks. Clearing the background here ensures a cleaner visual appearance 4788 monospace blocks. Clearing the background here ensures a cleaner visual appearance
4775 since only one glyph is visible at any given point. */ 4789 since only one glyph is visible at any given point. */
4776 fillRect_Paint(&d->paint, (iRect){ visPos, run->visBounds.size }, tmBackground_ColorId); 4790 fillRect_Paint(&d->paint, visRect, tmBackground_ColorId);
4777 } 4791 }
4778 } 4792 }
4779 if (run->linkId && ~run->flags & decoration_GmRunFlag) { 4793 if (run->linkId) {
4780 fg = linkColor_GmDocument(doc, run->linkId, isHover ? textHover_GmLinkPart : text_GmLinkPart); 4794 if (run->flags & decoration_GmRunFlag && run->flags & startOfLine_GmRunFlag) {
4781 if (linkFlags & content_GmLinkFlag) { 4795 /* Link icon. */
4782 fg = linkColor_GmDocument(doc, run->linkId, textHover_GmLinkPart); /* link is inactive */ 4796 if (linkFlags & content_GmLinkFlag) {
4797 fg = linkColor_GmDocument(doc, run->linkId, textHover_GmLinkPart);
4798 }
4799 }
4800 else if (~run->flags & decoration_GmRunFlag) {
4801 fg = linkColor_GmDocument(doc, run->linkId, isHover ? textHover_GmLinkPart : text_GmLinkPart);
4802 if (linkFlags & content_GmLinkFlag) {
4803 fg = linkColor_GmDocument(doc, run->linkId, textHover_GmLinkPart); /* link is inactive */
4804 }
4783 } 4805 }
4784 } 4806 }
4785 if (run->flags & altText_GmRunFlag) { 4807 if (run->flags & altText_GmRunFlag) {
@@ -4877,16 +4899,18 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) {
4877 &text, " %s" close_Icon, isHover ? escape_Color(tmLinkText_ColorId) : ""); 4899 &text, " %s" close_Icon, isHover ? escape_Color(tmLinkText_ColorId) : "");
4878 } 4900 }
4879 const iInt2 size = measureRange_Text(metaFont, range_String(&text)).bounds.size; 4901 const iInt2 size = measureRange_Text(metaFont, range_String(&text)).bounds.size;
4880 fillRect_Paint( 4902 if (size.x) {
4881 &d->paint, 4903 fillRect_Paint(
4882 (iRect){ add_I2(origin, addX_I2(topRight_Rect(run->bounds), -size.x - gap_UI)), 4904 &d->paint,
4883 addX_I2(size, 2 * gap_UI) }, 4905 (iRect){ add_I2(origin, addX_I2(topRight_Rect(run->bounds), -size.x - gap_UI)),
4884 tmBackground_ColorId); 4906 addX_I2(size, 2 * gap_UI) },
4885 drawAlign_Text(metaFont, 4907 tmBackground_ColorId);
4886 add_I2(topRight_Rect(run->bounds), origin), 4908 drawAlign_Text(metaFont,
4887 fg, 4909 add_I2(topRight_Rect(run->bounds), origin),
4888 right_Alignment, 4910 fg,
4889 "%s", cstr_String(&text)); 4911 right_Alignment,
4912 "%s", cstr_String(&text));
4913 }
4890 deinit_String(&text); 4914 deinit_String(&text);
4891 } 4915 }
4892 else if (run->flags & endOfLine_GmRunFlag && 4916 else if (run->flags & endOfLine_GmRunFlag &&