From fb1c43b4d277632681e361885c575aa4336e8a29 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jaakko=20Ker=C3=A4nen?= jaakko.keranen@iki.fi
Date: Wed, 16 Dec 2020 18:39:45 +0200
Subject: [PATCH 1/1] URL decoding preference affects input widgets
src/ui/documentwidget.c | 4 ++--
src/ui/inputwidget.c | 33 ++++++++++++++++++++++++---------
src/ui/inputwidget.h | 10 ++++++----
src/ui/util.c | 1 +
src/ui/window.c | 1 +
5 files changed, 34 insertions(+), 15 deletions(-)
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 <the_Foundation/array.h>
@@ -64,11 +65,12 @@ static void deinit_InputUndo_(iInputUndo *d) {
enum iInputWidgetFlag {
isSensitive_InputWidgetFlag = iBit(1),
};
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) {
-}
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) {
+}
+void setUrlContent_InputWidget(iInputWidget *d, iBool 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");
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);
--
2.25.1
text/plain
This content has been proxied by September (ba2dc).