From b9c5c010586da8c59bec01cd2e2d21835ef7916b Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 12 Nov 2015 21:59:18 +0000 Subject: Koen Danckaert's patch to speed up line metrics update --- generic/tkText.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index cb89218..ac56c85 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -572,8 +572,6 @@ CreateWidget( * start,end do not require a total recalculation. */ - TkBTreeAddClient(sharedPtr->tree, textPtr, textPtr->charHeight); - textPtr->state = TK_TEXT_STATE_NORMAL; textPtr->relief = TK_RELIEF_FLAT; textPtr->cursor = None; @@ -583,6 +581,8 @@ CreateWidget( textPtr->prevWidth = Tk_Width(newWin); textPtr->prevHeight = Tk_Height(newWin); + TkBTreeAddClient(sharedPtr->tree, textPtr, textPtr->charHeight); + /* * This will add refCounts to textPtr. */ @@ -2319,6 +2319,7 @@ TextWorldChanged( { Tk_FontMetrics fm; int border; + int oldCharHeight = textPtr->charHeight; textPtr->charWidth = Tk_TextWidth(textPtr->tkfont, "0", 1); if (textPtr->charWidth <= 0) { @@ -2330,6 +2331,9 @@ TextWorldChanged( if (textPtr->charHeight <= 0) { textPtr->charHeight = 1; } + if (textPtr->charHeight != oldCharHeight) { + TkBTreeClientRangeChanged(textPtr, textPtr->charHeight); + } border = textPtr->borderWidth + textPtr->highlightWidth; Tk_GeometryRequest(textPtr->tkwin, textPtr->width * textPtr->charWidth + 2*textPtr->padX + 2*border, -- cgit v0.12 From de27a7c6e4d71115b1757e59735cbece10a62ae5 Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 12 Nov 2015 22:50:12 +0000 Subject: Moved comment to follow the moved code in previous commit --- generic/tkText.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index ac56c85..6e982b0 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -566,12 +566,6 @@ CreateWidget( textPtr->end = NULL; } - /* - * Register with the B-tree. In some sense it would be best if we could do - * this later (after configuration options), so that any changes to - * start,end do not require a total recalculation. - */ - textPtr->state = TK_TEXT_STATE_NORMAL; textPtr->relief = TK_RELIEF_FLAT; textPtr->cursor = None; @@ -581,6 +575,12 @@ CreateWidget( textPtr->prevWidth = Tk_Width(newWin); textPtr->prevHeight = Tk_Height(newWin); + /* + * Register with the B-tree. In some sense it would be best if we could do + * this later (after configuration options), so that any changes to + * start,end do not require a total recalculation. + */ + TkBTreeAddClient(sharedPtr->tree, textPtr, textPtr->charHeight); /* -- cgit v0.12 From f6a8214c69fd081220a6401284532d1d373749be Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 13 Nov 2015 14:54:12 +0000 Subject: Fix test-cases textDisp-33.2 and textDisp-33.3 --- tests/textDisp.test | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/textDisp.test b/tests/textDisp.test index a6bbfd7..9c6af70 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -4104,7 +4104,7 @@ test textDisp-33.2 {one line longer than fits in the widget} { .tt debug 1 set tk_textHeightCalc "" .tt insert 1.0 [string repeat "more wrap + " 1] - after 100 ; update + after 100 ; update idletasks # Nothing should have been recalculated. set tk_textHeightCalc } {} @@ -4184,7 +4184,7 @@ test textDisp-34.1 {Text widgets multi-scrolling problem: Bug 2677890} -setup { return $result } -cleanup { destroy .t1 .sy -} -result {{0.0 1.0} {0.0 1.0} {0.0 1.0} {0.0 0.24}} +} -result {{0.0 0.24} {0.0 0.24} {0.0 0.24} {0.0 0.24}} deleteWindows option clear -- cgit v0.12