summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-05-14 12:05:52 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-05-14 12:05:52 +0300
commit79f02ba0448c559e37539ece389aea8ec7e5a173 (patch)
tree09ff74813191628296a5ff83a41ee6c946efbf7f /src/ui
parent8d2880f97638e131cbca4f0b355bca350dc3b97d (diff)
InputWidget: Rewrap when width changes
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/inputwidget.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c
index 6639f957..d9985a8b 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -114,6 +114,7 @@ struct Impl_InputWidget {
114 iArray text; /* iChar[] */ 114 iArray text; /* iChar[] */
115 iArray oldText; /* iChar[] */ 115 iArray oldText; /* iChar[] */
116 iArray lines; 116 iArray lines;
117 int lastUpdateWidth;
117 iString hint; 118 iString hint;
118 iString srcHint; 119 iString srcHint;
119 int leftPadding; 120 int leftPadding;
@@ -239,6 +240,7 @@ static void clearLines_InputWidget_(iInputWidget *d) {
239} 240}
240 241
241static void updateLines_InputWidget_(iInputWidget *d) { 242static void updateLines_InputWidget_(iInputWidget *d) {
243 d->lastUpdateWidth = d->widget.rect.size.x;
242 clearLines_InputWidget_(d); 244 clearLines_InputWidget_(d);
243 if (d->maxLen) { 245 if (d->maxLen) {
244 /* Everything on a single line. */ 246 /* Everything on a single line. */
@@ -339,6 +341,7 @@ void init_InputWidget(iInputWidget *d, size_t maxLen) {
339 d->cursor = 0; 341 d->cursor = 0;
340 d->lastCursor = 0; 342 d->lastCursor = 0;
341 d->cursorLine = 0; 343 d->cursorLine = 0;
344 d->lastUpdateWidth = 0;
342 d->verticalMoveX = -1; /* TODO: Use this. */ 345 d->verticalMoveX = -1; /* TODO: Use this. */
343 d->inFlags = eatEscape_InputWidgetFlag | enterKeyEnabled_InputWidgetFlag; 346 d->inFlags = eatEscape_InputWidgetFlag | enterKeyEnabled_InputWidgetFlag;
344 iZap(d->mark); 347 iZap(d->mark);
@@ -1007,7 +1010,7 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) {
1007 updateMetrics_InputWidget_(d); 1010 updateMetrics_InputWidget_(d);
1008 updateLinesAndResize_InputWidget_(d); 1011 updateLinesAndResize_InputWidget_(d);
1009 } 1012 }
1010 else if (isResize_UserEvent(ev)) { 1013 else if (isResize_UserEvent(ev) || d->lastUpdateWidth != w->rect.size.x) {
1011 d->inFlags |= needUpdateBuffer_InputWidgetFlag; 1014 d->inFlags |= needUpdateBuffer_InputWidgetFlag;
1012 if (d->inFlags & isUrl_InputWidgetFlag) { 1015 if (d->inFlags & isUrl_InputWidgetFlag) {
1013 /* Restore/omit the default scheme if necessary. */ 1016 /* Restore/omit the default scheme if necessary. */