diff options
-rw-r--r-- | src/ui/inputwidget.c | 31 | ||||
-rw-r--r-- | src/ui/window.c | 6 | ||||
-rw-r--r-- | src/ui/window.h | 1 |
3 files changed, 33 insertions, 5 deletions
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c index 06e6373e..04d3ff69 100644 --- a/src/ui/inputwidget.c +++ b/src/ui/inputwidget.c | |||
@@ -258,9 +258,26 @@ static iString *visText_InputWidget_(const iInputWidget *d) { | |||
258 | static void updateBuffered_InputWidget_(iInputWidget *d) { | 258 | static void updateBuffered_InputWidget_(iInputWidget *d) { |
259 | if (isFinishedLaunching_App()) { | 259 | if (isFinishedLaunching_App()) { |
260 | invalidateBuffered_InputWidget_(d); | 260 | invalidateBuffered_InputWidget_(d); |
261 | iString *visText = visText_InputWidget_(d); | 261 | iString *bufText = NULL; |
262 | d->buffered = new_TextBuf(d->font, cstr_String(visText)); | 262 | if (d->inFlags & isUrl_InputWidgetFlag) { |
263 | delete_String(visText); | 263 | /* Highlight the host name. */ |
264 | iUrl parts; | ||
265 | const iString *text = text_InputWidget(d); | ||
266 | init_Url(&parts, text); | ||
267 | if (!isEmpty_Range(&parts.host)) { | ||
268 | bufText = new_String(); | ||
269 | appendRange_String(bufText, (iRangecc){ constBegin_String(text), parts.host.start }); | ||
270 | appendCStr_String(bufText, uiTextStrong_ColorEscape); | ||
271 | appendRange_String(bufText, parts.host); | ||
272 | appendCStr_String(bufText, restore_ColorEscape); | ||
273 | appendRange_String(bufText, (iRangecc){ parts.host.end, constEnd_String(text) }); | ||
274 | } | ||
275 | } | ||
276 | if (!bufText) { | ||
277 | bufText = visText_InputWidget_(d); | ||
278 | } | ||
279 | d->buffered = new_TextBuf(d->font, uiInputText_ColorId, cstr_String(bufText)); | ||
280 | delete_String(bufText); | ||
264 | } | 281 | } |
265 | } | 282 | } |
266 | 283 | ||
@@ -275,6 +292,12 @@ void setText_InputWidget(iInputWidget *d, const iString *text) { | |||
275 | punyEncodeUrlHost_String(enc); | 292 | punyEncodeUrlHost_String(enc); |
276 | text = enc; | 293 | text = enc; |
277 | } | 294 | } |
295 | /* Omit the default (Gemini) scheme if the window is narrow. */ | ||
296 | if (isNarrow_Window(get_Window()) && startsWithCase_String(text, "gemini:")) { | ||
297 | iString *shortened = collect_String(copy_String(text)); | ||
298 | remove_Block(&shortened->chars, 0, 7); | ||
299 | text = shortened; | ||
300 | } | ||
278 | } | 301 | } |
279 | clearUndo_InputWidget_(d); | 302 | clearUndo_InputWidget_(d); |
280 | clear_Array(&d->text); | 303 | clear_Array(&d->text); |
@@ -919,7 +942,7 @@ static void draw_InputWidget_(const iInputWidget *d) { | |||
919 | } | 942 | } |
920 | if (d->buffered && !isFocused && !isHint) { | 943 | if (d->buffered && !isFocused && !isHint) { |
921 | /* Most input widgets will use this, since only one is focused at a time. */ | 944 | /* Most input widgets will use this, since only one is focused at a time. */ |
922 | draw_TextBuf(d->buffered, textOrigin, uiInputText_ColorId); | 945 | draw_TextBuf(d->buffered, textOrigin, white_ColorId); |
923 | } | 946 | } |
924 | else { | 947 | else { |
925 | draw_Text(d->font, | 948 | draw_Text(d->font, |
diff --git a/src/ui/window.c b/src/ui/window.c index 6e81c14c..5d5b8e0c 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -536,10 +536,14 @@ static int navBarAvailableSpace_(iWidget *navBar) { | |||
536 | return avail; | 536 | return avail; |
537 | } | 537 | } |
538 | 538 | ||
539 | iBool isNarrow_Window(const iWindow *d) { | ||
540 | return width_Rect(safeRootRect_Window(d)) / gap_UI < 140; | ||
541 | } | ||
542 | |||
539 | static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) { | 543 | static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) { |
540 | if (equal_Command(cmd, "window.resized") || equal_Command(cmd, "metrics.changed")) { | 544 | if (equal_Command(cmd, "window.resized") || equal_Command(cmd, "metrics.changed")) { |
541 | const iBool isPhone = deviceType_App() == phone_AppDeviceType; | 545 | const iBool isPhone = deviceType_App() == phone_AppDeviceType; |
542 | const iBool isNarrow = !isPhone && width_Rect(bounds_Widget(navBar)) / gap_UI < 140; | 546 | const iBool isNarrow = !isPhone && isNarrow_Window(get_Window()); |
543 | /* Adjust navbar padding. */ { | 547 | /* Adjust navbar padding. */ { |
544 | int hPad = isPhone || isNarrow ? gap_UI / 2 : gap_UI * 3 / 2; | 548 | int hPad = isPhone || isNarrow ? gap_UI / 2 : gap_UI * 3 / 2; |
545 | int vPad = gap_UI * 3 / 2; | 549 | int vPad = gap_UI * 3 / 2; |
diff --git a/src/ui/window.h b/src/ui/window.h index 98c63957..9ac3bc00 100644 --- a/src/ui/window.h +++ b/src/ui/window.h | |||
@@ -104,6 +104,7 @@ uint32_t frameTime_Window (const iWindow *); | |||
104 | SDL_Renderer *renderer_Window (const iWindow *); | 104 | SDL_Renderer *renderer_Window (const iWindow *); |
105 | int snap_Window (const iWindow *); | 105 | int snap_Window (const iWindow *); |
106 | iBool isFullscreen_Window (const iWindow *); | 106 | iBool isFullscreen_Window (const iWindow *); |
107 | iBool isNarrow_Window (const iWindow *); | ||
107 | 108 | ||
108 | iWindow * get_Window (void); | 109 | iWindow * get_Window (void); |
109 | 110 | ||