summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-12-16 18:39:45 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-12-16 18:39:45 +0200
commitfb1c43b4d277632681e361885c575aa4336e8a29 (patch)
treeedbfa30b09875841fe362173b3789e5affa9b7b1
parenta529f0b6af2beeafc12f9195ca396723819b045f (diff)
URL decoding preference affects input widgets
-rw-r--r--src/ui/documentwidget.c4
-rw-r--r--src/ui/inputwidget.c33
-rw-r--r--src/ui/inputwidget.h10
-rw-r--r--src/ui/util.c1
-rw-r--r--src/ui/window.c1
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) {
1173 : cstr_String(&resp->meta), 1173 : cstr_String(&resp->meta),
1174 uiTextCaution_ColorEscape "Send \u21d2", 1174 uiTextCaution_ColorEscape "Send \u21d2",
1175 "document.input.submit"); 1175 "document.input.submit");
1176 setSensitive_InputWidget(findChild_Widget(dlg, "input"), 1176 setSensitiveContent_InputWidget(findChild_Widget(dlg, "input"),
1177 statusCode == sensitiveInput_GmStatusCode); 1177 statusCode == sensitiveInput_GmStatusCode);
1178 break; 1178 break;
1179 } 1179 }
1180 case categorySuccess_GmStatusCode: 1180 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. */
24#include "paint.h" 24#include "paint.h"
25#include "util.h" 25#include "util.h"
26#include "keys.h" 26#include "keys.h"
27#include "prefs.h"
27#include "app.h" 28#include "app.h"
28 29
29#include <the_Foundation/array.h> 30#include <the_Foundation/array.h>
@@ -64,11 +65,12 @@ static void deinit_InputUndo_(iInputUndo *d) {
64 65
65enum iInputWidgetFlag { 66enum iInputWidgetFlag {
66 isSensitive_InputWidgetFlag = iBit(1), 67 isSensitive_InputWidgetFlag = iBit(1),
67 enterPressed_InputWidgetFlag = iBit(2), 68 isUrl_InputWidgetFlag = iBit(2), /* affected by decoding preference */
68 selectAllOnFocus_InputWidgetFlag = iBit(3), 69 enterPressed_InputWidgetFlag = iBit(3),
69 notifyEdits_InputWidgetFlag = iBit(4), 70 selectAllOnFocus_InputWidgetFlag = iBit(4),
70 eatEscape_InputWidgetFlag = iBit(5), 71 notifyEdits_InputWidgetFlag = iBit(5),
71 isMarking_InputWidgetFlag = iBit(6), 72 eatEscape_InputWidgetFlag = iBit(6),
73 isMarking_InputWidgetFlag = iBit(7),
72}; 74};
73 75
74struct Impl_InputWidget { 76struct Impl_InputWidget {
@@ -168,10 +170,6 @@ void setMode_InputWidget(iInputWidget *d, enum iInputMode mode) {
168 d->mode = mode; 170 d->mode = mode;
169} 171}
170 172
171void setSensitive_InputWidget(iInputWidget *d, iBool isSensitive) {
172 iChangeFlags(d->inFlags, isSensitive_InputWidgetFlag, isSensitive);
173}
174
175const iString *text_InputWidget(const iInputWidget *d) { 173const iString *text_InputWidget(const iInputWidget *d) {
176 return collect_String(newUnicodeN_String(constData_Array(&d->text), size_Array(&d->text))); 174 return collect_String(newUnicodeN_String(constData_Array(&d->text), size_Array(&d->text)));
177} 175}
@@ -372,6 +370,14 @@ void setCursor_InputWidget(iInputWidget *d, size_t pos) {
372 } 370 }
373} 371}
374 372
373void setSensitiveContent_InputWidget(iInputWidget *d, iBool isSensitive) {
374 iChangeFlags(d->inFlags, isSensitive_InputWidgetFlag, isSensitive);
375}
376
377void setUrlContent_InputWidget(iInputWidget *d, iBool isUrl) {
378 iChangeFlags(d->inFlags, isUrl_InputWidgetFlag, isUrl);
379}
380
375void setSelectAllOnFocus_InputWidget(iInputWidget *d, iBool selectAllOnFocus) { 381void setSelectAllOnFocus_InputWidget(iInputWidget *d, iBool selectAllOnFocus) {
376 iChangeFlags(d->inFlags, selectAllOnFocus_InputWidgetFlag, selectAllOnFocus); 382 iChangeFlags(d->inFlags, selectAllOnFocus_InputWidgetFlag, selectAllOnFocus);
377} 383}
@@ -591,6 +597,15 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) {
591 deleteMarked_InputWidget_(d); 597 deleteMarked_InputWidget_(d);
592 char *text = SDL_GetClipboardText(); 598 char *text = SDL_GetClipboardText();
593 iString *paste = collect_String(newCStr_String(text)); 599 iString *paste = collect_String(newCStr_String(text));
600 /* Url decoding. */
601 if (d->inFlags & isUrl_InputWidgetFlag) {
602 if (prefs_App()->decodeUserVisibleURLs) {
603 paste = collect_String(urlDecode_String(paste));
604 }
605 else {
606 urlEncodePath_String(paste);
607 }
608 }
594 SDL_free(text); 609 SDL_free(text);
595 iConstForEach(String, i, paste) { 610 iConstForEach(String, i, paste) {
596 insertChar_InputWidget_(d, i.value); 611 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 {
33}; 33};
34 34
35void setHint_InputWidget (iInputWidget *, const char *hintText); 35void setHint_InputWidget (iInputWidget *, const char *hintText);
36void setSensitive_InputWidget(iInputWidget *, iBool isSensitive);
37void setMode_InputWidget (iInputWidget *, enum iInputMode mode); 36void setMode_InputWidget (iInputWidget *, enum iInputMode mode);
38void setMaxLen_InputWidget (iInputWidget *, size_t maxLen); 37void setMaxLen_InputWidget (iInputWidget *, size_t maxLen);
39void setText_InputWidget (iInputWidget *, const iString *text); 38void setText_InputWidget (iInputWidget *, const iString *text);
40void setTextCStr_InputWidget (iInputWidget *, const char *cstr); 39void setTextCStr_InputWidget (iInputWidget *, const char *cstr);
41void setCursor_InputWidget (iInputWidget *, size_t pos); 40void setCursor_InputWidget (iInputWidget *, size_t pos);
42void setSelectAllOnFocus_InputWidget (iInputWidget *, iBool selectAllOnFocus);
43void setNotifyEdits_InputWidget (iInputWidget *, iBool notifyEdits);
44void setEatEscape_InputWidget(iInputWidget *, iBool eatEscape);
45void begin_InputWidget (iInputWidget *); 41void begin_InputWidget (iInputWidget *);
46void end_InputWidget (iInputWidget *, iBool accept); 42void end_InputWidget (iInputWidget *, iBool accept);
47void selectAll_InputWidget (iInputWidget *); 43void selectAll_InputWidget (iInputWidget *);
48 44
45void setSelectAllOnFocus_InputWidget (iInputWidget *, iBool selectAllOnFocus);
46void setSensitiveContent_InputWidget (iInputWidget *, iBool isSensitive);
47void setUrlContent_InputWidget (iInputWidget *, iBool isUrl);
48void setNotifyEdits_InputWidget (iInputWidget *, iBool notifyEdits);
49void setEatEscape_InputWidget (iInputWidget *, iBool eatEscape);
50
49const iString * text_InputWidget (const iInputWidget *); 51const iString * text_InputWidget (const iInputWidget *);
50 52
51iLocalDef iInputWidget *newHint_InputWidget(size_t maxLen, const char *hint) { 53iLocalDef 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) {
1184 setId_Widget(addChild_Widget(values, iClob(inputs[0] = new_InputWidget(0))), "bmed.title"); 1184 setId_Widget(addChild_Widget(values, iClob(inputs[0] = new_InputWidget(0))), "bmed.title");
1185 addChild_Widget(headings, iClob(makeHeading_Widget("URL:"))); 1185 addChild_Widget(headings, iClob(makeHeading_Widget("URL:")));
1186 setId_Widget(addChild_Widget(values, iClob(inputs[1] = new_InputWidget(0))), "bmed.url"); 1186 setId_Widget(addChild_Widget(values, iClob(inputs[1] = new_InputWidget(0))), "bmed.url");
1187 setUrlContent_InputWidget(inputs[1], iTrue);
1187 addChild_Widget(headings, iClob(makeHeading_Widget("Tags:"))); 1188 addChild_Widget(headings, iClob(makeHeading_Widget("Tags:")));
1188 setId_Widget(addChild_Widget(values, iClob(inputs[2] = new_InputWidget(0))), "bmed.tags"); 1189 setId_Widget(addChild_Widget(values, iClob(inputs[2] = new_InputWidget(0))), "bmed.tags");
1189 arrange_Widget(dlg); 1190 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) {
514 iInputWidget *url = new_InputWidget(0); 514 iInputWidget *url = new_InputWidget(0);
515 setSelectAllOnFocus_InputWidget(url, iTrue); 515 setSelectAllOnFocus_InputWidget(url, iTrue);
516 setId_Widget(as_Widget(url), "url"); 516 setId_Widget(as_Widget(url), "url");
517 setUrlContent_InputWidget(url, iTrue);
517 setNotifyEdits_InputWidget(url, iTrue); 518 setNotifyEdits_InputWidget(url, iTrue);
518 setTextCStr_InputWidget(url, "gemini://"); 519 setTextCStr_InputWidget(url, "gemini://");
519 addChildFlags_Widget(navBar, iClob(url), expand_WidgetFlag); 520 addChildFlags_Widget(navBar, iClob(url), expand_WidgetFlag);