diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-07-27 21:48:02 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-07-27 21:48:02 +0300 |
commit | 6f18be186a4861a758023ceba92f098273b2dc5c (patch) | |
tree | 4fe629e0fa54de8eea5eb2b117efae277287f86b /src/ui | |
parent | d3b5fe0d8d05d8e76d3f4646f02b0fa78561b1db (diff) |
Visualizing links
Show which links are to the same site, and which are HTTP/S, Gopher, or files.
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/documentwidget.c | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 36ec99ff..a02dc67f 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -179,6 +179,9 @@ static void updateWindowTitle_DocumentWidget_(const iDocumentWidget *d) { | |||
179 | } | 179 | } |
180 | 180 | ||
181 | static void setSource_DocumentWidget_(iDocumentWidget *d, const iString *source) { | 181 | static void setSource_DocumentWidget_(iDocumentWidget *d, const iString *source) { |
182 | iUrl parts; | ||
183 | init_Url(&parts, d->url); | ||
184 | setHost_GmDocument(d->doc, collect_String(newRange_String(parts.host))); | ||
182 | setSource_GmDocument(d->doc, source, documentWidth_DocumentWidget_(d)); | 185 | setSource_GmDocument(d->doc, source, documentWidth_DocumentWidget_(d)); |
183 | d->foundMark = iNullRange; | 186 | d->foundMark = iNullRange; |
184 | d->selectMark = iNullRange; | 187 | d->selectMark = iNullRange; |
@@ -676,34 +679,41 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) { | |||
676 | /* TODO: making a copy is unnecessary; the text routines should accept Rangecc */ | 679 | /* TODO: making a copy is unnecessary; the text routines should accept Rangecc */ |
677 | initRange_String(&text, run->text); | 680 | initRange_String(&text, run->text); |
678 | iInt2 origin = addY_I2(d->bounds.pos, -d->widget->scrollY); | 681 | iInt2 origin = addY_I2(d->bounds.pos, -d->widget->scrollY); |
682 | enum iColorId fg = run->color; | ||
679 | if (run == d->widget->hoverLink) { | 683 | if (run == d->widget->hoverLink) { |
680 | const char *desc = ""; | 684 | //const char *desc = ""; |
681 | const iString *url = linkUrl_GmDocument(d->widget->doc, d->widget->hoverLink->linkId); | 685 | const iGmDocument *doc = d->widget->doc; |
682 | if (indexOfCStr_String(url, "://") == iInvalidPos) { | 686 | const iGmLinkId linkId = d->widget->hoverLink->linkId; |
683 | url = d->widget->url; | 687 | const iString *url = linkUrl_GmDocument(doc, linkId); |
684 | } | 688 | // const int flags = linkFlags_GmDocument(doc, linkId); |
685 | iUrl parts; | 689 | iUrl parts; |
686 | init_Url(&parts, url); | 690 | init_Url(&parts, url); |
687 | desc = cstrFormat_String("\u2192 %s", cstr_String(collect_String(newRange_String(parts.protocol)))); | 691 | // desc = cstrFormat_String("\u2192 %s", cstr_String(collect_String(newRange_String(parts.protocol)))); |
688 | int descWidth = measure_Text(default_FontId, desc).x + gap_UI; | 692 | const iString *host = collect_String(newRange_String(parts.host)); |
689 | iRect linkRect = expanded_Rect(moved_Rect(run->bounds, origin), init_I2(gap_UI, 0)); | 693 | fg = linkColor_GmDocument(doc, linkId); |
690 | linkRect.size.x += descWidth; | 694 | if (!isEmpty_String(host)) { |
691 | fillRect_Paint(&d->paint, linkRect, teal_ColorId); | 695 | // int descWidth = measure_Text(default_FontId, cstr_String(host)).x + gap_UI; |
692 | drawAlign_Text(default_FontId, | 696 | iRect linkRect = moved_Rect(run->visBounds, origin); |
693 | addX_I2(topRight_Rect(linkRect), -gap_UI), | 697 | // linkRect.size.x += descWidth; |
694 | cyan_ColorId, | 698 | // fillRect_Paint(&d->paint, linkRect, teal_ColorId); |
695 | right_Alignment, | 699 | drawAlign_Text(default_FontId, |
696 | "%s", | 700 | // init_I2(right_Rect(d->bounds), top_Rect(linkRect)), |
697 | desc); | 701 | topRight_Rect(linkRect), |
698 | } | 702 | fg - 1, |
699 | const iInt2 visPos = add_I2(run->bounds.pos, origin); | 703 | left_Alignment, |
704 | " \u2014 %s", | ||
705 | cstr_String(host)); | ||
706 | } | ||
707 | } | ||
708 | const iInt2 visPos = add_I2(run->visBounds.pos, origin); | ||
700 | /* Text markers. */ | 709 | /* Text markers. */ |
701 | fillRange_DrawContext_(d, run, teal_ColorId, d->widget->foundMark, &d->inFoundMark); | 710 | fillRange_DrawContext_(d, run, teal_ColorId, d->widget->foundMark, &d->inFoundMark); |
702 | fillRange_DrawContext_(d, run, brown_ColorId, d->widget->selectMark, &d->inSelectMark); | 711 | fillRange_DrawContext_(d, run, brown_ColorId, d->widget->selectMark, &d->inSelectMark); |
703 | drawString_Text(run->font, visPos, run->color, &text); | 712 | drawString_Text(run->font, visPos, fg, &text); |
704 | deinit_String(&text); | 713 | deinit_String(&text); |
705 | 714 | ||
706 | // drawRect_Paint(&d->paint, (iRect){ visPos, run->bounds.size }, red_ColorId); | 715 | // drawRect_Paint(&d->paint, (iRect){ visPos, run->bounds.size }, green_ColorId); |
716 | // drawRect_Paint(&d->paint, (iRect){ visPos, run->visBounds.size }, red_ColorId); | ||
707 | } | 717 | } |
708 | 718 | ||
709 | static void draw_DocumentWidget_(const iDocumentWidget *d) { | 719 | static void draw_DocumentWidget_(const iDocumentWidget *d) { |