diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-02-23 11:48:06 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-02-23 11:48:06 +0200 |
commit | 78092e44e6ba554c6ed31df5bfa3d7c38d2341d2 (patch) | |
tree | 47301877cf313436dc3617b52c81575fd759abe9 /src/ui/inputwidget.c | |
parent | 64b9cea544ecb2c0ae95afae5e84543ac6117f62 (diff) |
Show a search indicator in the URL bar
Indicate to user when entered text will be user for a search engine query.
IssueID #157
Diffstat (limited to 'src/ui/inputwidget.c')
-rw-r--r-- | src/ui/inputwidget.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c index 25c3e145..58a47610 100644 --- a/src/ui/inputwidget.c +++ b/src/ui/inputwidget.c | |||
@@ -81,6 +81,8 @@ struct Impl_InputWidget { | |||
81 | iArray text; /* iChar[] */ | 81 | iArray text; /* iChar[] */ |
82 | iArray oldText; /* iChar[] */ | 82 | iArray oldText; /* iChar[] */ |
83 | iString hint; | 83 | iString hint; |
84 | int leftPadding; | ||
85 | int rightPadding; | ||
84 | size_t cursor; | 86 | size_t cursor; |
85 | size_t lastCursor; | 87 | size_t lastCursor; |
86 | iRanges mark; | 88 | iRanges mark; |
@@ -114,6 +116,8 @@ void init_InputWidget(iInputWidget *d, size_t maxLen) { | |||
114 | init_String(&d->hint); | 116 | init_String(&d->hint); |
115 | init_Array(&d->undoStack, sizeof(iInputUndo)); | 117 | init_Array(&d->undoStack, sizeof(iInputUndo)); |
116 | d->font = uiInput_FontId | alwaysVariableFlag_FontId; | 118 | d->font = uiInput_FontId | alwaysVariableFlag_FontId; |
119 | d->leftPadding = 0; | ||
120 | d->rightPadding = 0; | ||
117 | d->cursor = 0; | 121 | d->cursor = 0; |
118 | d->lastCursor = 0; | 122 | d->lastCursor = 0; |
119 | d->inFlags = eatEscape_InputWidgetFlag; | 123 | d->inFlags = eatEscape_InputWidgetFlag; |
@@ -196,6 +200,12 @@ void setHint_InputWidget(iInputWidget *d, const char *hintText) { | |||
196 | setCStr_String(&d->hint, hintText); | 200 | setCStr_String(&d->hint, hintText); |
197 | } | 201 | } |
198 | 202 | ||
203 | void setContentPadding_InputWidget(iInputWidget *d, int left, int right) { | ||
204 | d->leftPadding = left; | ||
205 | d->rightPadding = right; | ||
206 | refresh_Widget(d); | ||
207 | } | ||
208 | |||
199 | static const iChar sensitiveChar_ = 0x25cf; /* black circle */ | 209 | static const iChar sensitiveChar_ = 0x25cf; /* black circle */ |
200 | 210 | ||
201 | static iString *visText_InputWidget_(const iInputWidget *d) { | 211 | static iString *visText_InputWidget_(const iInputWidget *d) { |
@@ -488,7 +498,9 @@ iLocalDef iInt2 padding_(void) { | |||
488 | 498 | ||
489 | static iInt2 textOrigin_InputWidget_(const iInputWidget *d, const char *visText) { | 499 | static iInt2 textOrigin_InputWidget_(const iInputWidget *d, const char *visText) { |
490 | const iWidget *w = constAs_Widget(d); | 500 | const iWidget *w = constAs_Widget(d); |
491 | iRect bounds = adjusted_Rect(bounds_Widget(w), padding_(), neg_I2(padding_())); | 501 | iRect bounds = adjusted_Rect(bounds_Widget(w), |
502 | addX_I2(padding_(), d->leftPadding), | ||
503 | neg_I2(addX_I2(padding_(), d->rightPadding))); | ||
492 | const iInt2 emSize = advance_Text(d->font, "M"); | 504 | const iInt2 emSize = advance_Text(d->font, "M"); |
493 | const int textWidth = advance_Text(d->font, visText).x; | 505 | const int textWidth = advance_Text(d->font, visText).x; |
494 | const int cursorX = advanceN_Text(d->font, visText, d->cursor).x; | 506 | const int cursorX = advanceN_Text(d->font, visText, d->cursor).x; |