summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-08-06 19:16:27 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-08-06 19:16:27 +0300
commit5589056ac1c9b9f16ec3078673da46b2129a27ec (patch)
tree5e862a548af8325232fbad97476fd5242bb7fd51
parent186573dae1d0eab4560f02fe3b999418ea0f4614 (diff)
InputWidget: Omit default scheme; highlight domain name
These were working in v1.5 but were broken in v1.6.
-rw-r--r--src/ui/inputwidget.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c
index f1f368b6..9f233345 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -691,7 +691,6 @@ void setMode_InputWidget(iInputWidget *d, enum iInputMode mode) {
691 d->mode = mode; 691 d->mode = mode;
692} 692}
693 693
694#if 0
695static void restoreDefaultScheme_(iString *url) { 694static void restoreDefaultScheme_(iString *url) {
696 iUrl parts; 695 iUrl parts;
697 init_Url(&parts, url); 696 init_Url(&parts, url);
@@ -706,17 +705,14 @@ static const iString *omitDefaultScheme_(iString *url) {
706 } 705 }
707 return url; 706 return url;
708} 707}
709#endif
710 708
711const iString *text_InputWidget(const iInputWidget *d) { 709const iString *text_InputWidget(const iInputWidget *d) {
712 if (d) { 710 if (d) {
713 iString *text = collect_String(text_InputWidget_(d)); 711 iString *text = collect_String(text_InputWidget_(d));
714#if 0
715 if (d->inFlags & isUrl_InputWidgetFlag) { 712 if (d->inFlags & isUrl_InputWidgetFlag) {
716 /* Add the "gemini" scheme back if one is omitted. */ 713 /* Add the "gemini" scheme back if one is omitted. */
717 restoreDefaultScheme_(text); 714 restoreDefaultScheme_(text);
718 } 715 }
719#endif
720 return text; 716 return text;
721 } 717 }
722 return collectNew_String(); 718 return collectNew_String();
@@ -820,6 +816,22 @@ static void updateBuffered_InputWidget_(iInputWidget *d) {
820 for (int i = visRange.start; i < visRange.end; i++) { 816 for (int i = visRange.start; i < visRange.end; i++) {
821 append_String(visText, &line_InputWidget_(d, i)->text); 817 append_String(visText, &line_InputWidget_(d, i)->text);
822 } 818 }
819 if (d->inFlags & isUrl_InputWidgetFlag) {
820 /* Highlight the host name. */
821 iUrl parts;
822 init_Url(&parts, visText);
823 if (!isEmpty_Range(&parts.host)) {
824 const char *cstr = cstr_String(visText);
825 insertData_Block(&visText->chars,
826 parts.host.end - cstr,
827 restore_ColorEscape,
828 strlen(restore_ColorEscape));
829 insertData_Block(&visText->chars,
830 parts.host.start - cstr,
831 uiTextStrong_ColorEscape,
832 strlen(uiTextStrong_ColorEscape));
833 }
834 }
823 iWrapText wt = wrap_InputWidget_(d, 0); 835 iWrapText wt = wrap_InputWidget_(d, 0);
824 wt.text = range_String(visText); 836 wt.text = range_String(visText);
825 const int fg = uiInputText_ColorId; 837 const int fg = uiInputText_ColorId;
@@ -853,12 +865,10 @@ void setText_InputWidget(iInputWidget *d, const iString *text) {
853 punyEncodeUrlHost_String(enc); 865 punyEncodeUrlHost_String(enc);
854 text = enc; 866 text = enc;
855 } 867 }
856#if 0
857 /* Omit the default (Gemini) scheme if there isn't much space. */ 868 /* Omit the default (Gemini) scheme if there isn't much space. */
858 if (isNarrow_Root(as_Widget(d)->root)) { 869 if (isNarrow_Root(as_Widget(d)->root)) {
859 text = omitDefaultScheme_(collect_String(copy_String(text))); 870 text = omitDefaultScheme_(collect_String(copy_String(text)));
860 } 871 }
861#endif
862 } 872 }
863 clearUndo_InputWidget_(d); 873 clearUndo_InputWidget_(d);
864 iString *nfcText = collect_String(copy_String(text)); 874 iString *nfcText = collect_String(copy_String(text));
@@ -873,10 +883,6 @@ void setText_InputWidget(iInputWidget *d, const iString *text) {
873 if (!isFocused_Widget(d)) { 883 if (!isFocused_Widget(d)) {
874 iZap(d->mark); 884 iZap(d->mark);
875 } 885 }
876// else {
877// d->cursor.y = iMin(d->cursor.y, (int) size_Array(&d->lines) - 1);
878// d->cursor.x = iMin(d->cursor.x, size_String(&cursorLine_InputWidget_(d)->text));
879// }
880 if (!isFocused_Widget(d)) { 886 if (!isFocused_Widget(d)) {
881 d->inFlags |= needUpdateBuffer_InputWidgetFlag; 887 d->inFlags |= needUpdateBuffer_InputWidgetFlag;
882 } 888 }
@@ -1414,12 +1420,10 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) {
1414 /* Resize according to width immediately. */ 1420 /* Resize according to width immediately. */
1415 if (d->lastUpdateWidth != w->rect.size.x) { 1421 if (d->lastUpdateWidth != w->rect.size.x) {
1416 d->inFlags |= needUpdateBuffer_InputWidgetFlag; 1422 d->inFlags |= needUpdateBuffer_InputWidgetFlag;
1417#if 0
1418 if (d->inFlags & isUrl_InputWidgetFlag) { 1423 if (d->inFlags & isUrl_InputWidgetFlag) {
1419 /* Restore/omit the default scheme if necessary. */ 1424 /* Restore/omit the default scheme if necessary. */
1420 setText_InputWidget(d, text_InputWidget(d)); 1425 setText_InputWidget(d, text_InputWidget(d));
1421 } 1426 }
1422#endif
1423 updateAllLinesAndResizeHeight_InputWidget_(d); 1427 updateAllLinesAndResizeHeight_InputWidget_(d);
1424 d->lastUpdateWidth = w->rect.size.x; 1428 d->lastUpdateWidth = w->rect.size.x;
1425 } 1429 }