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 /src/ui/inputwidget.c | |
parent | a529f0b6af2beeafc12f9195ca396723819b045f (diff) |
URL decoding preference affects input widgets
Diffstat (limited to 'src/ui/inputwidget.c')
-rw-r--r-- | src/ui/inputwidget.c | 33 |
1 files changed, 24 insertions, 9 deletions
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); |