Lagrange [work/v1.8]

URL decoding preference affects input widgets

=> fb1c43b4d277632681e361885c575aa4336e8a29

diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index c9eda18f..75309737 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -1173,8 +1173,8 @@ static void checkResponse_DocumentWidget_(iDocumentWidget *d) {
                         : cstr_String(&resp->meta),
                     uiTextCaution_ColorEscape "Send \u21d2",
                     "document.input.submit");
-                setSensitive_InputWidget(findChild_Widget(dlg, "input"),
-                                         statusCode == sensitiveInput_GmStatusCode);
+                setSensitiveContent_InputWidget(findChild_Widget(dlg, "input"),
+                                                statusCode == sensitiveInput_GmStatusCode);
                 break;
             }
             case categorySuccess_GmStatusCode:
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c
index c4c7475e..85bd8b8b 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -24,6 +24,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
 #include "paint.h"
 #include "util.h"
 #include "keys.h"
+#include "prefs.h"
 #include "app.h"
 
 #include 
@@ -64,11 +65,12 @@ static void deinit_InputUndo_(iInputUndo *d) {
 
 enum iInputWidgetFlag {
     isSensitive_InputWidgetFlag      = iBit(1),
-    enterPressed_InputWidgetFlag     = iBit(2),
-    selectAllOnFocus_InputWidgetFlag = iBit(3),
-    notifyEdits_InputWidgetFlag      = iBit(4),
-    eatEscape_InputWidgetFlag        = iBit(5),
-    isMarking_InputWidgetFlag        = iBit(6),
+    isUrl_InputWidgetFlag            = iBit(2), /* affected by decoding preference */
+    enterPressed_InputWidgetFlag     = iBit(3),
+    selectAllOnFocus_InputWidgetFlag = iBit(4),
+    notifyEdits_InputWidgetFlag      = iBit(5),
+    eatEscape_InputWidgetFlag        = iBit(6),
+    isMarking_InputWidgetFlag        = iBit(7),
 };
 
 struct Impl_InputWidget {
@@ -168,10 +170,6 @@ void setMode_InputWidget(iInputWidget *d, enum iInputMode mode) {
     d->mode = mode;
 }
 
-void setSensitive_InputWidget(iInputWidget *d, iBool isSensitive) {
-    iChangeFlags(d->inFlags, isSensitive_InputWidgetFlag, isSensitive);
-}
-
 const iString *text_InputWidget(const iInputWidget *d) {
     return collect_String(newUnicodeN_String(constData_Array(&d->text), size_Array(&d->text)));
 }
@@ -372,6 +370,14 @@ void setCursor_InputWidget(iInputWidget *d, size_t pos) {
     }
 }
 
+void setSensitiveContent_InputWidget(iInputWidget *d, iBool isSensitive) {
+    iChangeFlags(d->inFlags, isSensitive_InputWidgetFlag, isSensitive);
+}
+
+void setUrlContent_InputWidget(iInputWidget *d, iBool isUrl) {
+    iChangeFlags(d->inFlags, isUrl_InputWidgetFlag, isUrl);
+}
+
 void setSelectAllOnFocus_InputWidget(iInputWidget *d, iBool selectAllOnFocus) {
     iChangeFlags(d->inFlags, selectAllOnFocus_InputWidgetFlag, selectAllOnFocus);
 }
@@ -591,6 +597,15 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) {
                         deleteMarked_InputWidget_(d);
                         char *text = SDL_GetClipboardText();
                         iString *paste = collect_String(newCStr_String(text));
+                        /* Url decoding. */
+                        if (d->inFlags & isUrl_InputWidgetFlag) {
+                            if (prefs_App()->decodeUserVisibleURLs) {
+                                paste = collect_String(urlDecode_String(paste));
+                            }
+                            else {
+                                urlEncodePath_String(paste);
+                            }
+                        }
                         SDL_free(text);
                         iConstForEach(String, i, paste) {
                             insertChar_InputWidget_(d, i.value);
diff --git a/src/ui/inputwidget.h b/src/ui/inputwidget.h
index 7fb8a8bd..654433ea 100644
--- a/src/ui/inputwidget.h
+++ b/src/ui/inputwidget.h
@@ -33,19 +33,21 @@ enum iInputMode {
 };
 
 void    setHint_InputWidget     (iInputWidget *, const char *hintText);
-void    setSensitive_InputWidget(iInputWidget *, iBool isSensitive);
 void    setMode_InputWidget     (iInputWidget *, enum iInputMode mode);
 void    setMaxLen_InputWidget   (iInputWidget *, size_t maxLen);
 void    setText_InputWidget     (iInputWidget *, const iString *text);
 void    setTextCStr_InputWidget (iInputWidget *, const char *cstr);
 void    setCursor_InputWidget   (iInputWidget *, size_t pos);
-void    setSelectAllOnFocus_InputWidget (iInputWidget *, iBool selectAllOnFocus);
-void    setNotifyEdits_InputWidget      (iInputWidget *, iBool notifyEdits);
-void    setEatEscape_InputWidget(iInputWidget *, iBool eatEscape);
 void    begin_InputWidget       (iInputWidget *);
 void    end_InputWidget         (iInputWidget *, iBool accept);
 void    selectAll_InputWidget   (iInputWidget *);
 
+void    setSelectAllOnFocus_InputWidget (iInputWidget *, iBool selectAllOnFocus);
+void    setSensitiveContent_InputWidget (iInputWidget *, iBool isSensitive);
+void    setUrlContent_InputWidget       (iInputWidget *, iBool isUrl);
+void    setNotifyEdits_InputWidget      (iInputWidget *, iBool notifyEdits);
+void    setEatEscape_InputWidget        (iInputWidget *, iBool eatEscape);
+
 const iString * text_InputWidget    (const iInputWidget *);
 
 iLocalDef iInputWidget *newHint_InputWidget(size_t maxLen, const char *hint) {
diff --git a/src/ui/util.c b/src/ui/util.c
index e1db3129..b6378055 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -1184,6 +1184,7 @@ iWidget *makeBookmarkEditor_Widget(void) {
     setId_Widget(addChild_Widget(values, iClob(inputs[0] = new_InputWidget(0))), "bmed.title");
     addChild_Widget(headings, iClob(makeHeading_Widget("URL:")));
     setId_Widget(addChild_Widget(values, iClob(inputs[1] = new_InputWidget(0))), "bmed.url");
+    setUrlContent_InputWidget(inputs[1], iTrue);
     addChild_Widget(headings, iClob(makeHeading_Widget("Tags:")));
     setId_Widget(addChild_Widget(values, iClob(inputs[2] = new_InputWidget(0))), "bmed.tags");
     arrange_Widget(dlg);
diff --git a/src/ui/window.c b/src/ui/window.c
index 6edd4c0e..c2d43aae 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -514,6 +514,7 @@ static void setupUserInterface_Window(iWindow *d) {
             iInputWidget *url = new_InputWidget(0);
             setSelectAllOnFocus_InputWidget(url, iTrue);
             setId_Widget(as_Widget(url), "url");
+            setUrlContent_InputWidget(url, iTrue);
             setNotifyEdits_InputWidget(url, iTrue);
             setTextCStr_InputWidget(url, "gemini://");
             addChildFlags_Widget(navBar, iClob(url), expand_WidgetFlag);
Proxy Information
Original URL
gemini://git.skyjake.fi/lagrange/work%2Fv1.8/cdiff/fb1c43b4d277632681e361885c575aa4336e8a29
Status Code
Success (20)
Meta
text/gemini; charset=utf-8
Capsule Response Time
292.978157 milliseconds
Gemini-to-HTML Time
0.3258 milliseconds

This content has been proxied by September (ba2dc).