From fb1c43b4d277632681e361885c575aa4336e8a29 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Wed, 16 Dec 2020 18:39:45 +0200 Subject: URL decoding preference affects input widgets --- src/ui/inputwidget.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'src/ui/inputwidget.c') 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); -- cgit v1.2.3