diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-12-16 18:39:45 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-12-16 18:39:45 +0200 |
commit | fb1c43b4d277632681e361885c575aa4336e8a29 (patch) | |
tree | edbfa30b09875841fe362173b3789e5affa9b7b1 | |
parent | a529f0b6af2beeafc12f9195ca396723819b045f (diff) |
URL decoding preference affects input widgets
-rw-r--r-- | src/ui/documentwidget.c | 4 | ||||
-rw-r--r-- | src/ui/inputwidget.c | 33 | ||||
-rw-r--r-- | src/ui/inputwidget.h | 10 | ||||
-rw-r--r-- | src/ui/util.c | 1 | ||||
-rw-r--r-- | 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) { | |||
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 | ||
65 | enum iInputWidgetFlag { | 66 | enum 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 | ||
74 | struct Impl_InputWidget { | 76 | struct 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 | ||
171 | void setSensitive_InputWidget(iInputWidget *d, iBool isSensitive) { | ||
172 | iChangeFlags(d->inFlags, isSensitive_InputWidgetFlag, isSensitive); | ||
173 | } | ||
174 | |||
175 | const iString *text_InputWidget(const iInputWidget *d) { | 173 | const 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 | ||
373 | void setSensitiveContent_InputWidget(iInputWidget *d, iBool isSensitive) { | ||
374 | iChangeFlags(d->inFlags, isSensitive_InputWidgetFlag, isSensitive); | ||
375 | } | ||
376 | |||
377 | void setUrlContent_InputWidget(iInputWidget *d, iBool isUrl) { | ||
378 | iChangeFlags(d->inFlags, isUrl_InputWidgetFlag, isUrl); | ||
379 | } | ||
380 | |||
375 | void setSelectAllOnFocus_InputWidget(iInputWidget *d, iBool selectAllOnFocus) { | 381 | void 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 | ||
35 | void setHint_InputWidget (iInputWidget *, const char *hintText); | 35 | void setHint_InputWidget (iInputWidget *, const char *hintText); |
36 | void setSensitive_InputWidget(iInputWidget *, iBool isSensitive); | ||
37 | void setMode_InputWidget (iInputWidget *, enum iInputMode mode); | 36 | void setMode_InputWidget (iInputWidget *, enum iInputMode mode); |
38 | void setMaxLen_InputWidget (iInputWidget *, size_t maxLen); | 37 | void setMaxLen_InputWidget (iInputWidget *, size_t maxLen); |
39 | void setText_InputWidget (iInputWidget *, const iString *text); | 38 | void setText_InputWidget (iInputWidget *, const iString *text); |
40 | void setTextCStr_InputWidget (iInputWidget *, const char *cstr); | 39 | void setTextCStr_InputWidget (iInputWidget *, const char *cstr); |
41 | void setCursor_InputWidget (iInputWidget *, size_t pos); | 40 | void setCursor_InputWidget (iInputWidget *, size_t pos); |
42 | void setSelectAllOnFocus_InputWidget (iInputWidget *, iBool selectAllOnFocus); | ||
43 | void setNotifyEdits_InputWidget (iInputWidget *, iBool notifyEdits); | ||
44 | void setEatEscape_InputWidget(iInputWidget *, iBool eatEscape); | ||
45 | void begin_InputWidget (iInputWidget *); | 41 | void begin_InputWidget (iInputWidget *); |
46 | void end_InputWidget (iInputWidget *, iBool accept); | 42 | void end_InputWidget (iInputWidget *, iBool accept); |
47 | void selectAll_InputWidget (iInputWidget *); | 43 | void selectAll_InputWidget (iInputWidget *); |
48 | 44 | ||
45 | void setSelectAllOnFocus_InputWidget (iInputWidget *, iBool selectAllOnFocus); | ||
46 | void setSensitiveContent_InputWidget (iInputWidget *, iBool isSensitive); | ||
47 | void setUrlContent_InputWidget (iInputWidget *, iBool isUrl); | ||
48 | void setNotifyEdits_InputWidget (iInputWidget *, iBool notifyEdits); | ||
49 | void setEatEscape_InputWidget (iInputWidget *, iBool eatEscape); | ||
50 | |||
49 | const iString * text_InputWidget (const iInputWidget *); | 51 | const iString * text_InputWidget (const iInputWidget *); |
50 | 52 | ||
51 | iLocalDef iInputWidget *newHint_InputWidget(size_t maxLen, const char *hint) { | 53 | 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) { | |||
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); |