summaryrefslogtreecommitdiff
path: root/src/ui/inputwidget.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-05-14 15:18:26 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-05-14 15:18:26 +0300
commitd268545d12db5b02ee5975acb311d5b3cd875d6a (patch)
treebca6bb8ee7ab9b2e6b9c0d36692a901424f9a94f /src/ui/inputwidget.c
parent21b16be87fec3ec163fb52b94619ba5f3b5df6d2 (diff)
InputWidget: Touch tweaks
Diffstat (limited to 'src/ui/inputwidget.c')
-rw-r--r--src/ui/inputwidget.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c
index 59bb8331..9b334c36 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -175,9 +175,9 @@ static void updateCursorLine_InputWidget_(iInputWidget *d) {
175 /* May need to scroll to keep the cursor visible. */ 175 /* May need to scroll to keep the cursor visible. */
176 iWidget *flow = findOverflowScrollable_Widget(w); 176 iWidget *flow = findOverflowScrollable_Widget(w);
177 if (flow) { 177 if (flow) {
178 const iRect rootRect = rect_Root(w->root); 178 const iRect rootRect = { rect_Root(w->root).pos, visibleSize_Root(w->root) };
179 int yCursor = contentBounds_InputWidget_(d).pos.y + 179 int yCursor = contentBounds_InputWidget_(d).pos.y +
180 lineHeight_Text(d->font) * d->cursorLine; 180 lineHeight_Text(d->font) * (int) d->cursorLine;
181 const int margin = lineHeight_Text(d->font) * 3; 181 const int margin = lineHeight_Text(d->font) * 3;
182 if (yCursor < top_Rect(rootRect) + margin) { 182 if (yCursor < top_Rect(rootRect) + margin) {
183 scrollOverflow_Widget(flow, top_Rect(rootRect) + margin - yCursor); 183 scrollOverflow_Widget(flow, top_Rect(rootRect) + margin - yCursor);
@@ -877,7 +877,8 @@ static iInt2 textOrigin_InputWidget_(const iInputWidget *d) { //}, const char *v
877 877
878static size_t coordIndex_InputWidget_(const iInputWidget *d, iInt2 coord) { 878static size_t coordIndex_InputWidget_(const iInputWidget *d, iInt2 coord) {
879 const iInt2 pos = sub_I2(coord, contentBounds_InputWidget_(d).pos); 879 const iInt2 pos = sub_I2(coord, contentBounds_InputWidget_(d).pos);
880 const size_t lineNumber = iMin(pos.y / lineHeight_Text(d->font), (int) size_Array(&d->lines) - 1); 880 const size_t lineNumber = iMin(iMax(0, pos.y) / lineHeight_Text(d->font),
881 (int) size_Array(&d->lines) - 1);
881 const iInputLine *line = line_InputWidget_(d, lineNumber); 882 const iInputLine *line = line_InputWidget_(d, lineNumber);
882 const char *endPos; 883 const char *endPos;
883 tryAdvanceNoWrap_Text(d->font, range_String(&line->text), pos.x, &endPos); 884 tryAdvanceNoWrap_Text(d->font, range_String(&line->text), pos.x, &endPos);