diff options
Diffstat (limited to 'src/ui/inputwidget.c')
-rw-r--r-- | src/ui/inputwidget.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c index 6246078e..8ed52022 100644 --- a/src/ui/inputwidget.c +++ b/src/ui/inputwidget.c | |||
@@ -535,6 +535,7 @@ static void updateLine_InputWidget_(iInputWidget *d, iInputLine *line) { | |||
535 | } | 535 | } |
536 | const iTextMetrics tm = measure_WrapText(&wrapText, d->font); | 536 | const iTextMetrics tm = measure_WrapText(&wrapText, d->font); |
537 | line->wrapLines.end = line->wrapLines.start + height_Rect(tm.bounds) / lineHeight_Text(d->font); | 537 | line->wrapLines.end = line->wrapLines.start + height_Rect(tm.bounds) / lineHeight_Text(d->font); |
538 | iAssert(!isEmpty_Range(&line->wrapLines)); | ||
538 | } | 539 | } |
539 | 540 | ||
540 | static void updateLineRangesStartingFrom_InputWidget_(iInputWidget *d, int y) { | 541 | static void updateLineRangesStartingFrom_InputWidget_(iInputWidget *d, int y) { |
@@ -776,6 +777,7 @@ static iRangei visibleLineRange_InputWidget_(const iInputWidget *d) { | |||
776 | } | 777 | } |
777 | else break; | 778 | else break; |
778 | } | 779 | } |
780 | iAssert(isEmpty_Range(&vis) || (vis.start >= 0 && vis.end >= vis.start)); | ||
779 | return vis; | 781 | return vis; |
780 | } | 782 | } |
781 | 783 | ||
@@ -1193,6 +1195,7 @@ static iBool deleteMarked_InputWidget_(iInputWidget *d) { | |||
1193 | if (!isEmpty_Range(&m)) { | 1195 | if (!isEmpty_Range(&m)) { |
1194 | deleteIndexRange_InputWidget_(d, m); | 1196 | deleteIndexRange_InputWidget_(d, m); |
1195 | setCursor_InputWidget(d, indexToCursor_InputWidget_(d, m.start)); | 1197 | setCursor_InputWidget(d, indexToCursor_InputWidget_(d, m.start)); |
1198 | iZap(d->mark); /* setCursor thinks we're marking when Shift is down */ | ||
1196 | return iTrue; | 1199 | return iTrue; |
1197 | } | 1200 | } |
1198 | return iFalse; | 1201 | return iFalse; |
@@ -1296,8 +1299,8 @@ static iInt2 coordCursor_InputWidget_(const iInputWidget *d, iInt2 coord) { | |||
1296 | 1299 | ||
1297 | static iBool copy_InputWidget_(iInputWidget *d, iBool doCut) { | 1300 | static iBool copy_InputWidget_(iInputWidget *d, iBool doCut) { |
1298 | if (!isEmpty_Range(&d->mark)) { | 1301 | if (!isEmpty_Range(&d->mark)) { |
1299 | const iRanges m = mark_InputWidget_(d); | 1302 | const iRanges m = mark_InputWidget_(d); |
1300 | iString *str = collectNew_String(); | 1303 | iString * str = collectNew_String(); |
1301 | mergeLinesRange_(&d->lines, m, str); | 1304 | mergeLinesRange_(&d->lines, m, str); |
1302 | SDL_SetClipboardText( | 1305 | SDL_SetClipboardText( |
1303 | cstr_String(d->inFlags & isUrl_InputWidgetFlag ? canonicalUrl_String(str) : str)); | 1306 | cstr_String(d->inFlags & isUrl_InputWidgetFlag ? canonicalUrl_String(str) : str)); |
@@ -1866,7 +1869,7 @@ static void draw_InputWidget_(const iInputWidget *d) { | |||
1866 | drawRange_Text(d->font, drawPos, uiAnnotation_ColorId, range_String(&d->hint)); | 1869 | drawRange_Text(d->font, drawPos, uiAnnotation_ColorId, range_String(&d->hint)); |
1867 | } | 1870 | } |
1868 | else { | 1871 | else { |
1869 | /* TODO: Make a function out of this. */ | 1872 | iAssert(~d->inFlags & isSensitive_InputWidgetFlag || size_Range(&visLines) == 1); |
1870 | drawPos.y += visLineOffsetY; | 1873 | drawPos.y += visLineOffsetY; |
1871 | iMarkPainter marker = { | 1874 | iMarkPainter marker = { |
1872 | .paint = &p, | 1875 | .paint = &p, |
@@ -1874,14 +1877,13 @@ static void draw_InputWidget_(const iInputWidget *d) { | |||
1874 | .contentBounds = contentBounds, | 1877 | .contentBounds = contentBounds, |
1875 | .mark = mark_InputWidget_(d) | 1878 | .mark = mark_InputWidget_(d) |
1876 | }; | 1879 | }; |
1877 | iAssert(~d->inFlags & isSensitive_InputWidgetFlag || size_Range(&visLines) == 1); | 1880 | wrapText.context = ▮ |
1881 | wrapText.wrapFunc = isFocused ? draw_MarkPainter_ : NULL; /* mark is drawn under each line of text */ | ||
1878 | for (size_t vis = visLines.start; vis < visLines.end; vis++) { | 1882 | for (size_t vis = visLines.start; vis < visLines.end; vis++) { |
1879 | const iInputLine *line = constAt_Array(&d->lines, vis); | 1883 | const iInputLine *line = constAt_Array(&d->lines, vis); |
1880 | wrapText.text = range_String(&line->text); | 1884 | wrapText.text = range_String(&line->text); |
1881 | wrapText.wrapFunc = isFocused ? draw_MarkPainter_ : NULL; /* mark is drawn under each line of text */ | 1885 | marker.line = line; |
1882 | wrapText.context = ▮ | 1886 | marker.pos = drawPos; |
1883 | marker.line = line; | ||
1884 | marker.pos = drawPos; | ||
1885 | addv_I2(&drawPos, draw_WrapText(&wrapText, d->font, drawPos, fg).advance); /* lines end with \n */ | 1887 | addv_I2(&drawPos, draw_WrapText(&wrapText, d->font, drawPos, fg).advance); /* lines end with \n */ |
1886 | } | 1888 | } |
1887 | wrapText.wrapFunc = NULL; | 1889 | wrapText.wrapFunc = NULL; |