summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ui/documentwidget.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index b7b40aca..199b6aa9 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -1032,6 +1032,7 @@ static void allocVisBuffer_DocumentWidget_(const iDocumentWidget *d) {
1032 if (isVisible && !d->visBuffer->texture[0]) { 1032 if (isVisible && !d->visBuffer->texture[0]) {
1033 iZap(d->visBuffer->validRange); 1033 iZap(d->visBuffer->validRange);
1034 d->visBuffer->size = size; 1034 d->visBuffer->size = size;
1035 iAssert(size.x > 0);
1035 iForIndices(i, d->visBuffer->texture) { 1036 iForIndices(i, d->visBuffer->texture) {
1036 d->visBuffer->texture[i] = 1037 d->visBuffer->texture[i] =
1037 SDL_CreateTexture(renderer_Window(get_Window()), 1038 SDL_CreateTexture(renderer_Window(get_Window()),
@@ -1066,7 +1067,7 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd)
1066 } 1067 }
1067 } 1068 }
1068 invalidate_DocumentWidget_(d); 1069 invalidate_DocumentWidget_(d);
1069 allocVisBuffer_DocumentWidget_(d); 1070 deallocVisBuffer_DocumentWidget_(d);
1070 refresh_Widget(w); 1071 refresh_Widget(w);
1071 updateWindowTitle_DocumentWidget_(d); 1072 updateWindowTitle_DocumentWidget_(d);
1072 } 1073 }
@@ -1815,17 +1816,6 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) {
1815// drawRect_Paint(&d->paint, (iRect){ visPos, run->visBounds.size }, red_ColorId); 1816// drawRect_Paint(&d->paint, (iRect){ visPos, run->visBounds.size }, red_ColorId);
1816} 1817}
1817 1818
1818static iRangei intersect_Rangei_(iRangei a, iRangei b) {
1819 if (a.end < b.start || a.start > b.end) {
1820 return (iRangei){ 0, 0 };
1821 }
1822 return (iRangei){ iMax(a.start, b.start), iMin(a.end, b.end) };
1823}
1824
1825iLocalDef iBool isEmpty_Rangei_(iRangei d) {
1826 return size_Range(&d) == 0;
1827}
1828
1829static void draw_DocumentWidget_(const iDocumentWidget *d) { 1819static void draw_DocumentWidget_(const iDocumentWidget *d) {
1830 const iWidget *w = constAs_Widget(d); 1820 const iWidget *w = constAs_Widget(d);
1831 const iRect bounds = bounds_Widget(w); 1821 const iRect bounds = bounds_Widget(w);
@@ -1858,7 +1848,7 @@ static void draw_DocumentWidget_(const iDocumentWidget *d) {
1858 beginTarget_Paint(p, visBuf->texture[vbDst]); 1848 beginTarget_Paint(p, visBuf->texture[vbDst]);
1859 const iRect visBufferRect = { zero_I2(), visBuf->size }; 1849 const iRect visBufferRect = { zero_I2(), visBuf->size };
1860 iRect drawRect = visBufferRect; 1850 iRect drawRect = visBufferRect;
1861 if (!isEmpty_Rangei_(intersect_Rangei_(visRange, visBuf->validRange))) { 1851 if (!isEmpty_Rangei(intersect_Rangei(visRange, visBuf->validRange))) {
1862 if (visRange.start < visBuf->validRange.start) { 1852 if (visRange.start < visBuf->validRange.start) {
1863 drawRange = (iRangei){ visRange.start, visBuf->validRange.start }; 1853 drawRange = (iRangei){ visRange.start, visBuf->validRange.start };
1864 } 1854 }