summaryrefslogtreecommitdiff
path: root/src/ui/inputwidget.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/inputwidget.c')
-rw-r--r--src/ui/inputwidget.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c
index 8d58eac9..49cc0a1e 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -558,6 +558,9 @@ static iInt2 relativeCursorCoord_InputWidget_(const iInputWidget *d) {
558} 558}
559 559
560static void updateVisible_InputWidget_(iInputWidget *d) { 560static void updateVisible_InputWidget_(iInputWidget *d) {
561 if (width_Widget(d) == 0) {
562 return; /* Nothing to do yet. */
563 }
561 const int totalWraps = numWrapLines_InputWidget_(d); 564 const int totalWraps = numWrapLines_InputWidget_(d);
562 const int visWraps = iClamp(totalWraps, d->minWrapLines, d->maxWrapLines); 565 const int visWraps = iClamp(totalWraps, d->minWrapLines, d->maxWrapLines);
563 /* Resize the height of the editor. */ 566 /* Resize the height of the editor. */
@@ -575,6 +578,14 @@ static void updateVisible_InputWidget_(iInputWidget *d) {
575 else if (cursorY < d->visWrapLines.start) { 578 else if (cursorY < d->visWrapLines.start) {
576 delta = cursorY - d->visWrapLines.start; 579 delta = cursorY - d->visWrapLines.start;
577 } 580 }
581 if (d->visWrapLines.end + delta > totalWraps) {
582 /* Don't scroll past the bottom. */
583 delta = totalWraps - d->visWrapLines.end;
584 }
585 if (d->visWrapLines.start + delta < 0) {
586 /* Don't ever scroll above the top. */
587 delta = -d->visWrapLines.start;
588 }
578 d->visWrapLines.start += delta; 589 d->visWrapLines.start += delta;
579 d->visWrapLines.end += delta; 590 d->visWrapLines.end += delta;
580 iAssert(contains_Range(&d->visWrapLines, cursorY)); 591 iAssert(contains_Range(&d->visWrapLines, cursorY));
@@ -584,6 +595,7 @@ static void updateVisible_InputWidget_(iInputWidget *d) {
584 } 595 }
585// printf("[InputWidget %p] total:%d viswrp:%d cur:%d vis:%d..%d\n", 596// printf("[InputWidget %p] total:%d viswrp:%d cur:%d vis:%d..%d\n",
586// d, totalWraps, visWraps, d->cursor.y, d->visWrapLines.start, d->visWrapLines.end); 597// d, totalWraps, visWraps, d->cursor.y, d->visWrapLines.start, d->visWrapLines.end);
598// fflush(stdout);
587} 599}
588 600
589static void showCursor_InputWidget_(iInputWidget *d) { 601static void showCursor_InputWidget_(iInputWidget *d) {