summaryrefslogtreecommitdiff
path: root/src/ui/inputwidget.c
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 /src/ui/inputwidget.c
parenta529f0b6af2beeafc12f9195ca396723819b045f (diff)
URL decoding preference affects input widgets
Diffstat (limited to 'src/ui/inputwidget.c')
-rw-r--r--src/ui/inputwidget.c33
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
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);