From ebfd31e30fb9cdf38f72c82ced2fd49727303548 Mon Sep 17 00:00:00 2001 From: Joe Mistachkin Date: Fri, 16 Nov 2012 21:21:54 +0000 Subject: Add support for an 'M' binding substitution that is replaced with the number of script-based binding patterns matched so far for the event. --- ChangeLog | 6 ++++++ generic/tkBind.c | 12 ++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8237eed..3f58f0b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2012-11-16 Joe Mistachkin + + * generic/tkBind.c: Add support for an 'M' binding substitution + that is replaced with the number of script-based binding patterns + matched so far for the event. + 2012-11-13 Jan Nijtmans * win/tkWinTest.c: [Bug 3585396]: winDialog.test requires user diff --git a/generic/tkBind.c b/generic/tkBind.c index 21bfb5c..dbbaaf4 100644 --- a/generic/tkBind.c +++ b/generic/tkBind.c @@ -660,7 +660,8 @@ static int DeleteVirtualEvent(Tcl_Interp *interp, char *eventString); static void DeleteVirtualEventTable(VirtualEventTable *vetPtr); static void ExpandPercents(TkWindow *winPtr, const char *before, - XEvent *eventPtr,KeySym keySym,Tcl_DString *dsPtr); + XEvent *eventPtr,KeySym keySym, + unsigned int scriptCount, Tcl_DString *dsPtr); static void FreeTclBinding(ClientData clientData); static PatSeq * FindSequence(Tcl_Interp *interp, Tcl_HashTable *patternTablePtr, ClientData object, @@ -1415,6 +1416,7 @@ Tk_BindEvent( PatSeq *vMatchDetailList, *vMatchNoDetailList; int flags, oldScreen, i, deferModal; unsigned int matchCount, matchSpace; + unsigned int scriptCount; Tcl_Interp *interp; Tcl_DString scripts, savedResult; Detail detail; @@ -1571,6 +1573,7 @@ Tk_BindEvent( pendingPtr = &staticPending; matchCount = 0; + scriptCount = 0; matchSpace = sizeof(staticPending.matchArray) / sizeof(PatSeq *); Tcl_DStringInit(&scripts); @@ -1628,7 +1631,7 @@ Tk_BindEvent( } if (sourcePtr->eventProc == EvalTclBinding) { ExpandPercents(winPtr, (char *) sourcePtr->clientData, - eventPtr, detail.keySym, &scripts); + eventPtr, detail.keySym, scriptCount++, &scripts); } else { if (matchCount >= matchSpace) { PendingBinding *newPtr; @@ -2259,6 +2262,8 @@ ExpandPercents( * in % replacements. */ KeySym keySym, /* KeySym: only relevant for KeyPress and * KeyRelease events). */ + unsigned int scriptCount, /* The number of script-based binding patterns + * matched so far for this event. */ Tcl_DString *dsPtr) /* Dynamic string in which to append new * command. */ { @@ -2540,6 +2545,9 @@ ExpandPercents( } } goto doString; + case 'M': + number = scriptCount; + goto doNumber; case 'N': if ((flags & KEY) && (eventPtr->type != MouseWheelEvent)) { number = (int) keySym; -- cgit v0.12 From a3b16715620dc27a7e998a8a37f8625ab0fcef0f Mon Sep 17 00:00:00 2001 From: Joe Mistachkin Date: Fri, 16 Nov 2012 22:09:07 +0000 Subject: Add docs and tests. --- doc/bind.n | 3 +++ tests/bind.test | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/doc/bind.n b/doc/bind.n index cd556e7..7fb847d 100644 --- a/doc/bind.n +++ b/doc/bind.n @@ -548,6 +548,9 @@ event generated by \fBSendEvent\fR. .IP \fB%K\fR 5 The keysym corresponding to the event, substituted as a textual string. Valid only for \fBKeyPress\fR and \fBKeyRelease\fR events. +.IP \fB%M\fR 5 +The number of script-based binding patterns matched so far for the +event. Valid for all event types. .IP \fB%N\fR 5 The keysym corresponding to the event, substituted as a decimal number. Valid only for \fBKeyPress\fR and \fBKeyRelease\fR events. diff --git a/tests/bind.test b/tests/bind.test index 85372f8..de9da70 100644 --- a/tests/bind.test +++ b/tests/bind.test @@ -25,6 +25,14 @@ proc setup {} { foreach p [event info] {event delete $p} update } +proc setup2 {} { + catch {destroy .b.e} + entry .b.e + pack .b.e + focus -force .b.e + foreach p [event info] {event delete $p} + update +} setup foreach i [bind Test] { @@ -1565,6 +1573,24 @@ test bind-16.44 {ExpandPercents procedure} { event gen .b.f set x } {?? ??} +test bind-16.45 {ExpandPercents procedure} { + setup2 + bind .b.e {set x "%M"} + bind Entry {set y "%M"} + bind all {set z "%M"} + set x none; set y none; set z none + event gen .b.e + list $x $y $z +} {0 1 2} +test bind-16.46 {ExpandPercents procedure} { + setup2 + bind all {set z "%M"} + bind Entry {set y "%M"} + bind .b.e {set x "%M"} + set x none; set y none; set z none + event gen .b.e + list $x $y $z +} {0 1 2} test bind-17.1 {event command} { -- cgit v0.12 From f2847e8d081eb6653eb582647d34346d2aef190a Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Fri, 21 Nov 2014 22:10:15 +0000 Subject: Fixed bug [c24b97d905] - text count -displaylines is wrong with elided newlines --- generic/tkText.c | 53 ++++++++++++++++++++++++++++++---------------------- generic/tkTextDisp.c | 20 +++++++++++++------- 2 files changed, 44 insertions(+), 29 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index f3e1c26..1156086 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -871,7 +871,7 @@ TextWidgetObjCmd( } else if (c == 'd' && (length > 8) && !strncmp("-displaylines", option, (unsigned) length)) { TkTextLine *fromPtr, *lastPtr; - TkTextIndex index; + TkTextIndex index, index2; int compare = TkTextIndexCmp(indexFromPtr, indexToPtr); value = 0; @@ -906,35 +906,44 @@ TextWidgetObjCmd( /* * We're going to count up all display lines in the logical * line of 'indexFromPtr' up to, but not including the logical - * line of 'indexToPtr', and then subtract off what we didn't - * want from 'from' and add on what we didn't count from 'to. + * line of 'indexToPtr' (except if this line is elided), and + * then subtract off what came in too much from elided lines, + * also subtract off we didn't want from 'from' and add on + * what we didn't count from 'to'. */ - while (index.linePtr != indexToPtr->linePtr) { - value += TkTextUpdateOneLine(textPtr, fromPtr,0,&index,0); - - /* - * We might have skipped past indexToPtr, if we have - * multiple logical lines in a single display line. - */ - if (TkTextIndexCmp(&index,indexToPtr) > 0) { - break; - } + while (TkTextIndexCmp(&index,indexToPtr) < 0) { + value += TkTextUpdateOneLine(textPtr, index.linePtr, + 0, &index, 0); } - /* - * Now we need to adjust the count to add on the number of - * display lines in the last logical line, and subtract off - * the number of display lines overcounted in the first - * logical line. This logic is still ok if both indices are in - * the same logical line. - */ + index2 = index; + + /* + * Now we need to adjust the count to: + * - subtract off the number of display lines between + * indexToPtr and index2, since we might have skipped past + * indexToPtr, if we have several logical lines in a + * single display line + * - subtract off the number of display lines overcounted + * in the first logical line + * - add on the number of display lines in the last logical + * line + * This logic is still ok if both indexFromPtr and indexToPtr + * are in the same logical line. + */ + index = *indexToPtr; + index.byteIndex = 0; + while (TkTextIndexCmp(&index,&index2) < 0) { + value -= TkTextUpdateOneLine(textPtr, index.linePtr, + 0, &index, 0); + } index.linePtr = indexFromPtr->linePtr; index.byteIndex = 0; while (1) { TkTextFindDisplayLineEnd(textPtr, &index, 1, NULL); - if (index.byteIndex >= indexFromPtr->byteIndex) { + if (TkTextIndexCmp(&index,indexFromPtr) >= 0) { break; } TkTextIndexForwBytes(textPtr, &index, 1, &index); @@ -946,7 +955,7 @@ TextWidgetObjCmd( index.byteIndex = 0; while (1) { TkTextFindDisplayLineEnd(textPtr, &index, 1, NULL); - if (index.byteIndex >= indexToPtr->byteIndex) { + if (TkTextIndexCmp(&index,indexToPtr) >= 0) { break; } TkTextIndexForwBytes(textPtr, &index, 1, &index); diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index f16c45b..510f3e0 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -3703,9 +3703,11 @@ TkTextUpdateOneLine( /* * Iterate through all display-lines corresponding to the single logical - * line 'linePtr', adding up the pixel height of each such display line as - * we go along. The final total is, therefore, the height of the logical - * line. + * line 'linePtr' (and lines merged into this line due to eol elision), + * adding up the pixel height of each such display line as we go along. + * The final total is, therefore, the total height of all display lines + * made up by the logical line 'linePtr' and subsequent logical lines + * merged into this line. */ displayLines = 0; @@ -3736,7 +3738,7 @@ TkTextUpdateOneLine( break; } - if (logicalLines == 0) { + if (mergedLines == 0) { if (indexPtr->linePtr != linePtr) { /* * If we reached the end of the logical line, then either way @@ -3746,9 +3748,11 @@ TkTextUpdateOneLine( partialCalc = 0; break; } - } else if (indexPtr->byteIndex != 0) { + } else { + if (indexPtr->byteIndex != 0) { /* - * We must still be on the same wrapped line. + * We must still be on the same wrapped line, on a new logical + * line merged with the logical line 'linePtr'. */ } else { /* @@ -3771,9 +3775,11 @@ TkTextUpdateOneLine( } /* - * We must still be on the same wrapped line. + * We must still be on the same wrapped line, on a new logical + * line merged with the logical line 'linePtr'. */ } + } if (partialCalc && displayLines > 50 && mergedLines == 0) { /* * Only calculate 50 display lines at a time, to avoid huge -- cgit v0.12 From 943fa965c46c715dce18664f2f1fa7989819ab2c Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Fri, 21 Nov 2014 22:18:00 +0000 Subject: Fixed text-9.2.44 - This test was wrong (my bad when fixing bug [3021557fff]) but that was hidden --- tests/text.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/text.test b/tests/text.test index 52689ba..3f407e6 100644 --- a/tests/text.test +++ b/tests/text.test @@ -698,7 +698,7 @@ test text-9.2.44 {TextWidgetCmd procedure, "count" option} -setup { .t tag add hidden 2.9 3.17 .t tag configure hidden -elide true lappend res [.t count -displaylines 1.19 3.24] [.t count -displaylines 1.0 end] -} -result {2 6 2 5} +} -result {2 6 1 5} # Newer tags are higher priority .t tag configure elide1 -elide 0 -- cgit v0.12 From 468c69c64d2e0a365e9bdf75aeccb3621b7ab78f Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Fri, 21 Nov 2014 22:45:09 +0000 Subject: Added tests for bug [c24b97d905] - text count -displaylines is wrong with elided newlines --- tests/text.test | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/text.test b/tests/text.test index 3f407e6..6121b85 100644 --- a/tests/text.test +++ b/tests/text.test @@ -699,6 +699,40 @@ test text-9.2.44 {TextWidgetCmd procedure, "count" option} -setup { .t tag configure hidden -elide true lappend res [.t count -displaylines 1.19 3.24] [.t count -displaylines 1.0 end] } -result {2 6 1 5} +test text-9.2.45 {TextWidgetCmd procedure, "count" option} -setup { + .t delete 1.0 end + update + set res {} +} -body { + for {set i 1} {$i < 5} {incr i} { + .t insert end "Line $i+++Line $i---Line $i///Line $i - This is Line [format %c [expr 64+$i]]\n" + } + .t tag configure hidden -elide true + .t tag add hidden 2.15 3.10 + .t configure -wrap none + set res [.t count -displaylines 2.0 3.0] +} -result {0} +test text-9.2.46 {TextWidgetCmd procedure, "count" option} -setup { + toplevel .mytop + pack [text .mytop.t] + wm geometry .mytop 100x300+0+0 + .mytop.t delete 1.0 end + update + set res {} +} -body { + for {set i 1} {$i < 5} {incr i} { + # 0 1 2 3 4 + # 012345 678901234 567890123 456789012 34567890123456789 + .mytop.t insert end "Line $i+++Line $i---Line $i///Line $i - This is Line [format %c [expr 64+$i]]\n" + } + .mytop.t tag configure hidden -elide true + .mytop.t tag add hidden 2.15 3.10 + .mytop.t configure -wrap char + lappend res [.mytop.t count -displaylines 2.0 3.0] + lappend res [.mytop.t count -displaylines 2.0 3.40] +} -cleanup { + destroy .mytop +} -result {1 3} # Newer tags are higher priority .t tag configure elide1 -elide 0 -- cgit v0.12 From 6c1055e3cba134b747ca58b472254ff6b48d686b Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Sat, 22 Nov 2014 22:05:23 +0000 Subject: Fixed bug [7703f947aa] - Wrong refresh of display lines when tagging text as elided --- generic/tkTextDisp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index f16c45b..d610d85 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -6429,6 +6429,7 @@ FindDLine( CONST TkTextIndex *indexPtr)/* Index of desired character. */ { TkTextLine *linePtr; + DLine *dlPtrPrev; if (dlPtr == NULL) { return NULL; @@ -6449,6 +6450,7 @@ FindDLine( linePtr = dlPtr->index.linePtr; while (linePtr != indexPtr->linePtr) { while (dlPtr->index.linePtr == linePtr) { + dlPtrPrev = dlPtr; dlPtr = dlPtr->nextPtr; if (dlPtr == NULL) { return NULL; @@ -6466,7 +6468,7 @@ FindDLine( } } if (indexPtr->linePtr != dlPtr->index.linePtr) { - return dlPtr; + return dlPtrPrev; } /* -- cgit v0.12 From 6eadef1510a35534787bd442e63feb70ecc80a88 Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Sat, 22 Nov 2014 22:14:37 +0000 Subject: Fixed textDisp-9.3 to -9.6 - The expected test results were not relevant without the update between tag add and tag remove --- tests/textDisp.test | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/textDisp.test b/tests/textDisp.test index 70c7208..ef65956 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -1173,40 +1173,44 @@ test textDisp-9.3 {TkTextRedrawTag} { .t insert 1.0 "Line 1\nLine 2 is long enough to wrap around\nLine 3\nLine 4" update .t tag add big 2.2 2.4 + update .t tag remove big 1.0 end update list $tk_textRelayout $tk_textRedraw -} {2.0 2.0} +} {{2.0 2.20} {2.0 2.20 eof}} test textDisp-9.4 {TkTextRedrawTag} { .t configure -wrap char .t delete 1.0 end .t insert 1.0 "Line 1\nLine 2 is long enough to wrap around\nLine 3\nLine 4" update .t tag add big 2.2 2.20 + update .t tag remove big 1.0 end update list $tk_textRelayout $tk_textRedraw -} {2.0 2.0} +} {{2.0 2.20} {2.0 2.20 eof}} test textDisp-9.5 {TkTextRedrawTag} { .t configure -wrap char .t delete 1.0 end .t insert 1.0 "Line 1\nLine 2 is long enough to wrap around\nLine 3\nLine 4" update .t tag add big 2.2 2.end + update .t tag remove big 1.0 end update list $tk_textRelayout $tk_textRedraw -} {{2.0 2.20} {2.0 2.20}} +} {{2.0 2.20} {2.0 2.20 eof}} test textDisp-9.6 {TkTextRedrawTag} { .t configure -wrap char .t delete 1.0 end .t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap\nLine 4" update .t tag add big 2.2 3.5 + update .t tag remove big 1.0 end update list $tk_textRelayout $tk_textRedraw -} {{2.0 2.20 3.0} {2.0 2.20 3.0}} +} {{2.0 2.20 3.0 3.20} {2.0 2.20 3.0 3.20 4.0 eof}} test textDisp-9.7 {TkTextRedrawTag} { .t configure -wrap char .t delete 1.0 end -- cgit v0.12 From 1df113a3a8cf2b44cba1304f8c01c012953cf354 Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Sat, 22 Nov 2014 22:23:41 +0000 Subject: Added test for bug [7703f947aa] - Wrong refresh of display lines when tagging text as elided --- tests/textDisp.test | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/textDisp.test b/tests/textDisp.test index ef65956..96670ac 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -1262,6 +1262,19 @@ test textDisp-9.11 {TkTextRedrawTag} { update set tk_textRedraw } {} +test textDisp-9.12 {TkTextRedrawTag} { + .t configure -wrap char + .t delete 1.0 end + for {set i 1} {$i < 5} {incr i} { + .t insert end "Line $i+++Line $i\n" + } + .t tag configure hidden -elide true + .t tag add hidden 2.6 3.6 + update + .t tag add hidden 3.11 4.6 + update + list $tk_textRelayout $tk_textRedraw +} {2.0 {2.0 eof}} test textDisp-10.1 {TkTextRelayoutWindow} { .t configure -wrap char -- cgit v0.12 -- cgit v0.12 From f85372b9e5d051cc570a8f167d50947a059f07b0 Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Sun, 23 Nov 2014 14:07:38 +0000 Subject: Fixing FindDLine was not enough in all cases, now fix its callers (see test case 'A' in bug [7703f947aa]) --- generic/tkTextDisp.c | 4 ++-- tests/textDisp.test | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index d610d85..2b88ad6 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -4792,8 +4792,8 @@ TextRedrawTag( endIndexPtr = curIndexPtr; } endPtr = FindDLine(dlPtr, endIndexPtr); - if ((endPtr != NULL) && (endPtr->index.linePtr == endIndexPtr->linePtr) - && (endPtr->index.byteIndex < endIndexPtr->byteIndex)) { + if ((endPtr != NULL) + && (TkTextIndexCmp(&endPtr->index,endIndexPtr) < 0)) { endPtr = endPtr->nextPtr; } diff --git a/tests/textDisp.test b/tests/textDisp.test index 96670ac..4b5c8c1 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -1275,6 +1275,21 @@ test textDisp-9.12 {TkTextRedrawTag} { update list $tk_textRelayout $tk_textRedraw } {2.0 {2.0 eof}} +test textDisp-9.13 {TkTextRedrawTag} { + .t configure -wrap none + .t delete 1.0 end + for {set i 1} {$i < 10} {incr i} { + .t insert end "Line $i - This is Line [format %c [expr 64+$i]]\n" + } + .t tag add hidden 2.8 2.17 + .t tag add hidden 6.8 7.17 + .t tag configure hidden -background red + .t tag configure hidden -elide true + update + .t tag configure hidden -elide false + update + list $tk_textRelayout $tk_textRedraw +} {{2.0 6.0 7.0} {2.0 6.0 7.0}} test textDisp-10.1 {TkTextRelayoutWindow} { .t configure -wrap char -- cgit v0.12 From a5bb515a22bb00c314271eba4ae4a2d53d8adf21 Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Sun, 30 Nov 2014 21:21:08 +0000 Subject: Fixed bbox caller of FindDLine, see case 'B' in bug [7703f947aa] --- generic/tkTextDisp.c | 18 ++++++++++++++++-- tests/textDisp.test | 23 +++++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 2b88ad6..c1b477c 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -6826,15 +6826,29 @@ TkTextIndexBbox( */ dlPtr = FindDLine(dInfoPtr->dLinePtr, indexPtr); + + /* + * Two cases shall be trapped here because the logic later really + * needs dlPtr to be the display line containing indexPtr: + * 1. if no display line contains the desired index (NULL dlPtr) + * 2. if indexPtr is before the first display line, in which case + * dlPtr currently points to the first display line + */ + if ((dlPtr == NULL) || (TkTextIndexCmp(&dlPtr->index, indexPtr) > 0)) { return -1; } /* - * Find the chunk within the line that contains the desired index. + * Find the chunk within the display line that contains the desired + * index. The chunks making the display line are skipped up to but not + * including the one crossing indexPtr. Skipping is done based on + * a byteIndex offset possibly spanning several logical lines in case + * they are elided. */ - byteIndex = indexPtr->byteIndex - dlPtr->index.byteIndex; + byteIndex = TkTextIndexCount(textPtr, &dlPtr->index, indexPtr, + COUNT_INDICES); for (chunkPtr = dlPtr->chunkPtr; ; chunkPtr = chunkPtr->nextPtr) { if (chunkPtr == NULL) { return -1; diff --git a/tests/textDisp.test b/tests/textDisp.test index 4b5c8c1..3add847 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -2754,6 +2754,29 @@ test textDisp-22.9 {TkTextCharBbox, handling of spacing} {textfonts} { [.t bbox 1.1] [.t bbox 2.9] } [list [list 24 11 10 4] [list 55 [expr {$fixedDiff/2 + 15}] 10 4] [list 10 [expr {2*$fixedDiff + 43}] 10 4] [list 76 [expr {2*$fixedDiff + 40}] 10 4] [list 10 11 7 $fixedHeight] [list 69 [expr {$fixedDiff + 34}] 7 $fixedHeight]] .t tag delete spacing +test textDisp-22.10 {TkTextCharBbox, handling of elided lines} {textfonts} { + .t configure -wrap char + .t delete 1.0 end + for {set i 1} {$i < 10} {incr i} { + .t insert end "Line $i - Line [format %c [expr 64+$i]]\n" + } + .t tag add hidden 2.8 2.13 + .t tag add hidden 6.8 7.13 + .t tag configure hidden -elide true + update + list \ + [expr {[lindex [.t bbox 2.9] 0] - [lindex [.t bbox 2.8] 0]}] \ + [expr {[lindex [.t bbox 2.10] 0] - [lindex [.t bbox 2.8] 0]}] \ + [expr {[lindex [.t bbox 2.13] 0] - [lindex [.t bbox 2.8] 0]}] \ + [expr {[lindex [.t bbox 6.9] 0] - [lindex [.t bbox 6.8] 0]}] \ + [expr {[lindex [.t bbox 6.10] 0] - [lindex [.t bbox 6.8] 0]}] \ + [expr {[lindex [.t bbox 6.13] 0] - [lindex [.t bbox 6.8] 0]}] \ + [expr {[lindex [.t bbox 6.14] 0] - [lindex [.t bbox 6.8] 0]}] \ + [expr {[lindex [.t bbox 6.15] 0] - [lindex [.t bbox 6.8] 0]}] \ + [expr {[lindex [.t bbox 7.0] 0] - [lindex [.t bbox 6.8] 0]}] \ + [expr {[lindex [.t bbox 7.1] 0] - [lindex [.t bbox 6.8] 0]}] \ + [expr {[lindex [.t bbox 7.12] 0] - [lindex [.t bbox 6.8] 0]}] +} [list 0 0 0 0 0 0 0 0 0 0 0] .t delete 1.0 end .t insert end "Line 1" -- cgit v0.12 From 4189da39eaad93b53fa0ba77e21d1d7cf79ed0e5 Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Sun, 30 Nov 2014 22:01:10 +0000 Subject: Fixed FindDLine again (the previous fix [575b376065] was an improvement despite it did not fix all cases), see case 'C' in bug [7703f947aa] --- generic/tkTextDisp.c | 99 +++++++++++++++++++++++++++------------------------- tests/textDisp.test | 13 +++++++ 2 files changed, 64 insertions(+), 48 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index c1b477c..e6991da 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -542,7 +542,8 @@ static void DisplayDLine(TkText *textPtr, DLine *dlPtr, static void DisplayLineBackground(TkText *textPtr, DLine *dlPtr, DLine *prevPtr, Pixmap pixmap); static void DisplayText(ClientData clientData); -static DLine * FindDLine(DLine *dlPtr, CONST TkTextIndex *indexPtr); +static DLine * FindDLine(TkText *textPtr, DLine *dlPtr, + CONST TkTextIndex *indexPtr); static void FreeDLines(TkText *textPtr, DLine *firstPtr, DLine *lastPtr, int action); static void FreeStyle(TkText *textPtr, TextStyle *stylePtr); @@ -1758,7 +1759,7 @@ UpdateDisplayInfo( */ index = textPtr->topIndex; - dlPtr = FindDLine(dInfoPtr->dLinePtr, &index); + dlPtr = FindDLine(textPtr, dInfoPtr->dLinePtr, &index); if ((dlPtr != NULL) && (dlPtr != dInfoPtr->dLinePtr)) { FreeDLines(textPtr, dInfoPtr->dLinePtr, dlPtr, DLINE_UNLINK); } @@ -3703,9 +3704,11 @@ TkTextUpdateOneLine( /* * Iterate through all display-lines corresponding to the single logical - * line 'linePtr', adding up the pixel height of each such display line as - * we go along. The final total is, therefore, the height of the logical - * line. + * line 'linePtr' (and lines merged into this line due to eol elision), + * adding up the pixel height of each such display line as we go along. + * The final total is, therefore, the total height of all display lines + * made up by the logical line 'linePtr' and subsequent logical lines + * merged into this line. */ displayLines = 0; @@ -3736,7 +3739,7 @@ TkTextUpdateOneLine( break; } - if (logicalLines == 0) { + if (mergedLines == 0) { if (indexPtr->linePtr != linePtr) { /* * If we reached the end of the logical line, then either way @@ -3746,9 +3749,11 @@ TkTextUpdateOneLine( partialCalc = 0; break; } - } else if (indexPtr->byteIndex != 0) { + } else { + if (indexPtr->byteIndex != 0) { /* - * We must still be on the same wrapped line. + * We must still be on the same wrapped line, on a new logical + * line merged with the logical line 'linePtr'. */ } else { /* @@ -3771,9 +3776,11 @@ TkTextUpdateOneLine( } /* - * We must still be on the same wrapped line. + * We must still be on the same wrapped line, on a new logical + * line merged with the logical line 'linePtr'. */ } + } if (partialCalc && displayLines > 50 && mergedLines == 0) { /* * Only calculate 50 display lines at a time, to avoid huge @@ -4581,11 +4588,11 @@ TextChanged( rounded = *index1Ptr; rounded.byteIndex = 0; - firstPtr = FindDLine(dInfoPtr->dLinePtr, &rounded); + firstPtr = FindDLine(textPtr, dInfoPtr->dLinePtr, &rounded); if (firstPtr == NULL) { return; } - lastPtr = FindDLine(dInfoPtr->dLinePtr, index2Ptr); + lastPtr = FindDLine(textPtr, dInfoPtr->dLinePtr, index2Ptr); while ((lastPtr != NULL) && (lastPtr->index.linePtr == index2Ptr->linePtr)) { lastPtr = lastPtr->nextPtr; @@ -4769,13 +4776,13 @@ TextRedrawTag( */ if (curIndexPtr->byteIndex == 0) { - dlPtr = FindDLine(dlPtr, curIndexPtr); + dlPtr = FindDLine(textPtr, dlPtr, curIndexPtr); } else { TkTextIndex tmp; tmp = *curIndexPtr; tmp.byteIndex -= 1; - dlPtr = FindDLine(dlPtr, &tmp); + dlPtr = FindDLine(textPtr, dlPtr, &tmp); } if (dlPtr == NULL) { break; @@ -4791,7 +4798,7 @@ TextRedrawTag( curIndexPtr = &search.curIndex; endIndexPtr = curIndexPtr; } - endPtr = FindDLine(dlPtr, endIndexPtr); + endPtr = FindDLine(textPtr, dlPtr, endIndexPtr); if ((endPtr != NULL) && (TkTextIndexCmp(&endPtr->index,endIndexPtr) < 0)) { endPtr = endPtr->nextPtr; @@ -5040,7 +5047,7 @@ TkTextSetYView( if (dInfoPtr->flags & DINFO_OUT_OF_DATE) { UpdateDisplayInfo(textPtr); } - dlPtr = FindDLine(dInfoPtr->dLinePtr, indexPtr); + dlPtr = FindDLine(textPtr, dInfoPtr->dLinePtr, indexPtr); if (dlPtr != NULL) { if ((dlPtr->y + dlPtr->height) > dInfoPtr->maxY) { /* @@ -5113,7 +5120,7 @@ TkTextSetYView( MeasureUp(textPtr, indexPtr, close + lineHeight - textPtr->charHeight/2, &tmpIndex, &overlap); - if (FindDLine(dInfoPtr->dLinePtr, &tmpIndex) != NULL) { + if (FindDLine(textPtr, dInfoPtr->dLinePtr, &tmpIndex) != NULL) { bottomY = dInfoPtr->maxY - dInfoPtr->y; } } @@ -5376,7 +5383,7 @@ TkTextSeeCmd( * the widget is not mapped. [Bug #641778] */ - dlPtr = FindDLine(dInfoPtr->dLinePtr, &index); + dlPtr = FindDLine(textPtr, dInfoPtr->dLinePtr, &index); if (dlPtr == NULL) { return TCL_OK; } @@ -6424,12 +6431,13 @@ AsyncUpdateYScrollbar( static DLine * FindDLine( + TkText *textPtr, /* Widget record for text widget. */ register DLine *dlPtr, /* Pointer to first in list of DLines to * search. */ CONST TkTextIndex *indexPtr)/* Index of desired character. */ { - TkTextLine *linePtr; DLine *dlPtrPrev; + TkTextIndex indexPtr2; if (dlPtr == NULL) { return NULL; @@ -6438,49 +6446,44 @@ FindDLine( < TkBTreeLinesTo(NULL, dlPtr->index.linePtr)) { /* * The first display line is already past the desired line. + * FV: Some concern here as to whether we should rather return + * NULL here. */ return dlPtr; } /* - * Find the first display line that covers the desired text line. + * The display line containing the desired index is such that the index + * of the first character of this display line is at or before the + * desired index, and the index onf the first character of the next + * display line is after the desired index. */ - linePtr = dlPtr->index.linePtr; - while (linePtr != indexPtr->linePtr) { - while (dlPtr->index.linePtr == linePtr) { + while (TkTextIndexCmp(&dlPtr->index,indexPtr) < 0) { dlPtrPrev = dlPtr; dlPtr = dlPtr->nextPtr; if (dlPtr == NULL) { - return NULL; - } - } - /* - * VMD: some concern here as to whether this logic, or the caller's - * logic will work well with partial peer widgets. - */ - - linePtr = TkBTreeNextLine(NULL, linePtr); - if (linePtr == NULL) { - Tcl_Panic("FindDLine reached end of text"); - } - } - if (indexPtr->linePtr != dlPtr->index.linePtr) { - return dlPtrPrev; - } - - /* - * Now get to the right position within the text line. - */ - - while (indexPtr->byteIndex >= (dlPtr->index.byteIndex+dlPtr->byteCount)) { - dlPtr = dlPtr->nextPtr; - if ((dlPtr == NULL) || (dlPtr->index.linePtr != indexPtr->linePtr)) { + * We're past the last display line, either because the desired + * index lies past the visible text, or because the desired index + * is on the last display line showing the last logical line. + */ + indexPtr2 = dlPtrPrev->index; + TkTextFindDisplayLineEnd(textPtr, &indexPtr2, 1, NULL); + if (TkTextIndexCmp(&indexPtr2,indexPtr) >= 0) { + dlPtr = dlPtrPrev; + break; + } else { + return NULL; + } + } + if (TkTextIndexCmp(&dlPtr->index,indexPtr) > 0) { + dlPtr = dlPtrPrev; break; } } + return dlPtr; } @@ -6825,7 +6828,7 @@ TkTextIndexBbox( * Find the display line containing the desired index. */ - dlPtr = FindDLine(dInfoPtr->dLinePtr, indexPtr); + dlPtr = FindDLine(textPtr, dInfoPtr->dLinePtr, indexPtr); /* * Two cases shall be trapped here because the logic later really @@ -6970,7 +6973,7 @@ TkTextDLineInfo( * Find the display line containing the desired index. */ - dlPtr = FindDLine(dInfoPtr->dLinePtr, indexPtr); + dlPtr = FindDLine(textPtr, dInfoPtr->dLinePtr, indexPtr); if ((dlPtr == NULL) || (TkTextIndexCmp(&dlPtr->index, indexPtr) > 0)) { return -1; } diff --git a/tests/textDisp.test b/tests/textDisp.test index 3add847..b04b2ce 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -2777,6 +2777,19 @@ test textDisp-22.10 {TkTextCharBbox, handling of elided lines} {textfonts} { [expr {[lindex [.t bbox 7.1] 0] - [lindex [.t bbox 6.8] 0]}] \ [expr {[lindex [.t bbox 7.12] 0] - [lindex [.t bbox 6.8] 0]}] } [list 0 0 0 0 0 0 0 0 0 0 0] +test textDisp-22.11 {TkTextCharBbox, handling of wrapped elided lines} {textfonts} { + .t configure -wrap char + .t delete 1.0 end + for {set i 1} {$i < 10} {incr i} { + .t insert end "Line $i - Line _$i - Lines .$i - Line [format %c [expr 64+$i]]\n" + } + .t tag add hidden 1.30 2.5 + .t tag configure hidden -elide true + update + list \ + [expr {[lindex [.t bbox 1.30] 0] - [lindex [.t bbox 2.4] 0]}] \ + [expr {[lindex [.t bbox 1.30] 0] - [lindex [.t bbox 2.5] 0]}] +} [list 0 0] .t delete 1.0 end .t insert end "Line 1" -- cgit v0.12 From 5c1c0e42427bb03e666c93d381e13bd6b5236992 Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Wed, 3 Dec 2014 06:44:13 +0000 Subject: Fixed indentation and typos in comments --- generic/tkTextDisp.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index e6991da..c3ea9e0 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -6446,8 +6446,6 @@ FindDLine( < TkBTreeLinesTo(NULL, dlPtr->index.linePtr)) { /* * The first display line is already past the desired line. - * FV: Some concern here as to whether we should rather return - * NULL here. */ return dlPtr; @@ -6456,7 +6454,7 @@ FindDLine( /* * The display line containing the desired index is such that the index * of the first character of this display line is at or before the - * desired index, and the index onf the first character of the next + * desired index, and the index of the first character of the next * display line is after the desired index. */ @@ -6464,24 +6462,24 @@ FindDLine( dlPtrPrev = dlPtr; dlPtr = dlPtr->nextPtr; if (dlPtr == NULL) { - /* - * We're past the last display line, either because the desired - * index lies past the visible text, or because the desired index - * is on the last display line showing the last logical line. - */ - indexPtr2 = dlPtrPrev->index; - TkTextFindDisplayLineEnd(textPtr, &indexPtr2, 1, NULL); - if (TkTextIndexCmp(&indexPtr2,indexPtr) >= 0) { - dlPtr = dlPtrPrev; - break; - } else { - return NULL; - } - } + /* + * We're past the last display line, either because the desired + * index lies past the visible text, or because the desired index + * is on the last display line showing the last logical line. + */ + indexPtr2 = dlPtrPrev->index; + TkTextFindDisplayLineEnd(textPtr, &indexPtr2, 1, NULL); + if (TkTextIndexCmp(&indexPtr2,indexPtr) >= 0) { + dlPtr = dlPtrPrev; + break; + } else { + return NULL; + } + } if (TkTextIndexCmp(&dlPtr->index,indexPtr) > 0) { dlPtr = dlPtrPrev; break; - } + } } return dlPtr; -- cgit v0.12 From ea784dc43022a4c1d83e038f7aae74244b4e96b7 Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Wed, 3 Dec 2014 06:47:02 +0000 Subject: Fixed embedded windows tests that were failing following [dc9f4bea9f] - See comment in bug [7703f947aa] --- tests/textWind.test | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/textWind.test b/tests/textWind.test index 79dca50..23a9e71 100644 --- a/tests/textWind.test +++ b/tests/textWind.test @@ -461,6 +461,7 @@ test textWind-10.4.1 {EmbWinLayoutProc procedure, error in creating window} {tex .t delete 1.0 end .t insert 1.0 "Some sample text" catch {destroy .t.f} + update .t window create 1.5 -create { frame .t.f frame .t.f.f -width 10 -height 20 -bg $color @@ -473,6 +474,7 @@ catch {destroy .t.f} test textWind-10.5 {EmbWinLayoutProc procedure, error in creating window} {textfonts} { .t delete 1.0 end .t insert 1.0 "Some sample text" + update .t window create 1.5 -create { concat .t } @@ -484,6 +486,7 @@ test textWind-10.6 {EmbWinLayoutProc procedure, error in creating window} {textf .t delete 1.0 end .t insert 1.0 "Some sample text" catch {destroy .t2} + update .t window create 1.5 -create { toplevel .t2 -width 100 -height 150 wm geom .t2 +0+0 @@ -497,6 +500,7 @@ test textWind-10.6.1 {EmbWinLayoutProc procedure, error in creating window} { .t delete 1.0 end .t insert 1.0 "Some sample text" catch {destroy .t2} + update .t window create 1.5 -create { toplevel .t2 -width 100 -height 150 wm geom .t2 +0+0 @@ -595,6 +599,8 @@ test textWind-11.2 {EmbWinDisplayProc procedure, geometry transforms} { .t insert 1.0 "Some sample text" pack forget .t place .t -x 30 -y 50 + catch {destroy .t.f} + update frame .t.f -width 30 -height 20 -bg $color .t window create 1.12 -window .t.f update -- cgit v0.12 From 93c7a0785f44c173c4ede19f18cfaa66350a5be3 Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Wed, 3 Dec 2014 12:14:29 +0000 Subject: Fixed embedded windows tests that were failing (on Linux) following [dc9f4bea9f] - See comment in bug [7703f947aa] --- tests/textWind.test | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/textWind.test b/tests/textWind.test index 23a9e71..537076f 100644 --- a/tests/textWind.test +++ b/tests/textWind.test @@ -444,6 +444,7 @@ test textWind-10.4 {EmbWinLayoutProc procedure, error in creating window} {textf .t delete 1.0 end .t insert 1.0 "Some sample text" catch {destroy .t.f} + update set msg {} after idle { .t window create 1.5 -create { -- cgit v0.12 From 7c755fdd9a297714bf92a596b061f0cb29dd4177 Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Wed, 3 Dec 2014 20:29:56 +0000 Subject: Make textDisp-9.6 pass on Linux as well (reduce font-dependance and sensitivity to toplevel window geometry) --- tests/textDisp.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/textDisp.test b/tests/textDisp.test index b04b2ce..5c0aace 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -1203,7 +1203,7 @@ test textDisp-9.5 {TkTextRedrawTag} { test textDisp-9.6 {TkTextRedrawTag} { .t configure -wrap char .t delete 1.0 end - .t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap\nLine 4" + .t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap" update .t tag add big 2.2 3.5 update -- cgit v0.12 From 98cbe87ecb05677a40ecbc6c7d2215ddf4a3fef8 Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Wed, 3 Dec 2014 20:30:35 +0000 Subject: Make textDisp-9.6 pass on Linux as well (reduce font-dependance and sensitivity to toplevel window geometry) --- tests/textDisp.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/textDisp.test b/tests/textDisp.test index 5c0aace..a3f9ae9 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -1210,7 +1210,7 @@ test textDisp-9.6 {TkTextRedrawTag} { .t tag remove big 1.0 end update list $tk_textRelayout $tk_textRedraw -} {{2.0 2.20 3.0 3.20} {2.0 2.20 3.0 3.20 4.0 eof}} +} {{2.0 2.20 3.0 3.20} {2.0 2.20 3.0 3.20 eof}} test textDisp-9.7 {TkTextRedrawTag} { .t configure -wrap char .t delete 1.0 end -- cgit v0.12 From 3d74aa895c0cfe1a4e2d1894d8c065597c2144a4 Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Wed, 3 Dec 2014 23:16:02 +0000 Subject: Checked dlineinfo caller of FindDLine, comments added --- generic/tkTextDisp.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index c3ea9e0..b9790db 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -6972,6 +6972,15 @@ TkTextDLineInfo( */ dlPtr = FindDLine(textPtr, dInfoPtr->dLinePtr, indexPtr); + + /* + * Two cases shall be trapped here because the logic later really + * needs dlPtr to be the display line containing indexPtr: + * 1. if no display line contains the desired index (NULL dlPtr) + * 2. if indexPtr is before the first display line, in which case + * dlPtr currently points to the first display line + */ + if ((dlPtr == NULL) || (TkTextIndexCmp(&dlPtr->index, indexPtr) > 0)) { return -1; } -- cgit v0.12 From ee4862a1f616723e90a7b931ad6ca9f4e502e72e Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Wed, 3 Dec 2014 23:18:42 +0000 Subject: Changed variable name for a better one --- generic/tkTextDisp.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index b9790db..f17994b 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -6812,7 +6812,7 @@ TkTextIndexBbox( TextDInfo *dInfoPtr = textPtr->dInfoPtr; DLine *dlPtr; register TkTextDispChunk *chunkPtr; - int byteIndex; + int byteCount; /* * Make sure that all of the screen layout information is up to date. @@ -6844,20 +6844,20 @@ TkTextIndexBbox( * Find the chunk within the display line that contains the desired * index. The chunks making the display line are skipped up to but not * including the one crossing indexPtr. Skipping is done based on - * a byteIndex offset possibly spanning several logical lines in case + * a byteCount offset possibly spanning several logical lines in case * they are elided. */ - byteIndex = TkTextIndexCount(textPtr, &dlPtr->index, indexPtr, + byteCount = TkTextIndexCount(textPtr, &dlPtr->index, indexPtr, COUNT_INDICES); for (chunkPtr = dlPtr->chunkPtr; ; chunkPtr = chunkPtr->nextPtr) { if (chunkPtr == NULL) { return -1; } - if (byteIndex < chunkPtr->numBytes) { + if (byteCount < chunkPtr->numBytes) { break; } - byteIndex -= chunkPtr->numBytes; + byteCount -= chunkPtr->numBytes; } /* @@ -6867,13 +6867,13 @@ TkTextIndexBbox( * coordinate on the screen. Translate it to reflect horizontal scrolling. */ - (*chunkPtr->bboxProc)(textPtr, chunkPtr, byteIndex, + (*chunkPtr->bboxProc)(textPtr, chunkPtr, byteCount, dlPtr->y + dlPtr->spaceAbove, dlPtr->height - dlPtr->spaceAbove - dlPtr->spaceBelow, dlPtr->baseline - dlPtr->spaceAbove, xPtr, yPtr, widthPtr, heightPtr); *xPtr = *xPtr + dInfoPtr->x - dInfoPtr->curXPixelOffset; - if ((byteIndex == chunkPtr->numBytes-1) && (chunkPtr->nextPtr == NULL)) { + if ((byteCount == chunkPtr->numBytes-1) && (chunkPtr->nextPtr == NULL)) { /* * Last character in display line. Give it all the space up to the * line. -- cgit v0.12 From 0c263a2b355d175fd814b725aaac01ffc6b8818d Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Wed, 3 Dec 2014 23:19:33 +0000 Subject: Fixed typos in comments --- tests/textDisp.test | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/textDisp.test b/tests/textDisp.test index a3f9ae9..3b5eca2 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -1458,7 +1458,7 @@ test textDisp-11.15 {TkTextSetYView, only a few lines visible} { update .top.t see 11.0 .top.t index @0,0 - # Thie index 9.0 should be just visible by a couple of pixels + # The index 9.0 should be just visible by a couple of pixels } {9.0} test textDisp-11.16 {TkTextSetYView, only a few lines visible} { .top.t yview 8.0 @@ -1471,7 +1471,7 @@ test textDisp-11.17 {TkTextSetYView, only a few lines visible} { update .top.t see 4.0 .top.t index @0,0 - # Thie index 2.0 should be just visible by a couple of pixels + # The index 2.0 should be just visible by a couple of pixels } {2.0} destroy .top -- cgit v0.12 From d3e4744b3c4c9b1b1a5f41831994df026020e737 Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Wed, 3 Dec 2014 23:25:43 +0000 Subject: Fixed text see command for elided target indices. --- generic/tkTextDisp.c | 95 ++++++++++++++++++++++++++++------------------------ tests/textDisp.test | 16 ++++++++- 2 files changed, 66 insertions(+), 45 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index f17994b..3d442af 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -5056,19 +5056,20 @@ TkTextSetYView( */ dlPtr = NULL; - } else if ((dlPtr->index.linePtr == indexPtr->linePtr) - && (dlPtr->index.byteIndex <= indexPtr->byteIndex)) { - if (dInfoPtr->dLinePtr == dlPtr && dInfoPtr->topPixelOffset != 0) { - /* - * It is on the top line, but that line is hanging off the top - * of the screen. Change the top overlap to zero and update. - */ - - dInfoPtr->newTopPixelOffset = 0; - goto scheduleUpdate; - } - return; - } + } else { + if (TkTextIndexCmp(&dlPtr->index, indexPtr) <= 0) { + if (dInfoPtr->dLinePtr == dlPtr && dInfoPtr->topPixelOffset != 0) { + /* + * It is on the top line, but that line is hanging off the top + * of the screen. Change the top overlap to zero and update. + */ + + dInfoPtr->newTopPixelOffset = 0; + goto scheduleUpdate; + } + return; + } + } } /* @@ -5379,8 +5380,8 @@ TkTextSeeCmd( } /* - * Find the chunk that contains the desired index. dlPtr may be NULL if - * the widget is not mapped. [Bug #641778] + * Find the display line containing the desired index. dlPtr may be NULL + * if the widget is not mapped. [Bug #641778] */ dlPtr = FindDLine(textPtr, dInfoPtr->dLinePtr, &index); @@ -5388,7 +5389,16 @@ TkTextSeeCmd( return TCL_OK; } - byteCount = index.byteIndex - dlPtr->index.byteIndex; + /* + * Find the chunk within the display line that contains the desired + * index. The chunks making the display line are skipped up to but not + * including the one crossing index. Skipping is done based on a + * byteCount offset possibly spanning several logical lines in case + * they are elided. + */ + + byteCount = TkTextIndexCount(textPtr, &dlPtr->index, &index, + COUNT_INDICES); for (chunkPtr = dlPtr->chunkPtr; chunkPtr != NULL ; chunkPtr = chunkPtr->nextPtr) { if (byteCount < chunkPtr->numBytes) { @@ -5399,36 +5409,33 @@ TkTextSeeCmd( /* * Call a chunk-specific function to find the horizontal range of the - * character within the chunk. chunkPtr is NULL if trying to see in elided - * region. + * character within the chunk. */ - if (chunkPtr != NULL) { - (*chunkPtr->bboxProc)(textPtr, chunkPtr, byteCount, - dlPtr->y + dlPtr->spaceAbove, - dlPtr->height - dlPtr->spaceAbove - dlPtr->spaceBelow, - dlPtr->baseline - dlPtr->spaceAbove, &x, &y, &width, - &height); - delta = x - dInfoPtr->curXPixelOffset; - oneThird = lineWidth/3; - if (delta < 0) { - if (delta < -oneThird) { - dInfoPtr->newXPixelOffset = (x - lineWidth/2); - } else { - dInfoPtr->newXPixelOffset -= ((-delta) ); - } - } else { - delta -= (lineWidth - width); - if (delta > 0) { - if (delta > oneThird) { - dInfoPtr->newXPixelOffset = (x - lineWidth/2); - } else { - dInfoPtr->newXPixelOffset += (delta ); - } - } else { - return TCL_OK; - } - } + (*chunkPtr->bboxProc)(textPtr, chunkPtr, byteCount, + dlPtr->y + dlPtr->spaceAbove, + dlPtr->height - dlPtr->spaceAbove - dlPtr->spaceBelow, + dlPtr->baseline - dlPtr->spaceAbove, &x, &y, &width, + &height); + delta = x - dInfoPtr->curXPixelOffset; + oneThird = lineWidth/3; + if (delta < 0) { + if (delta < -oneThird) { + dInfoPtr->newXPixelOffset = (x - lineWidth/2); + } else { + dInfoPtr->newXPixelOffset -= ((-delta) ); + } + } else { + delta -= (lineWidth - width); + if (delta > 0) { + if (delta > oneThird) { + dInfoPtr->newXPixelOffset = (x - lineWidth/2); + } else { + dInfoPtr->newXPixelOffset += (delta ); + } + } else { + return TCL_OK; + } } dInfoPtr->flags |= DINFO_OUT_OF_DATE; if (!(dInfoPtr->flags & REDRAW_PENDING)) { diff --git a/tests/textDisp.test b/tests/textDisp.test index 3b5eca2..fff52d4 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -1473,7 +1473,21 @@ test textDisp-11.17 {TkTextSetYView, only a few lines visible} { .top.t index @0,0 # The index 2.0 should be just visible by a couple of pixels } {2.0} -destroy .top +test textDisp-11.18 {TkTextSetYView, see in elided lines} { + .top.t delete 1.0 end + for {set i 1} {$i < 20} {incr i} { + .top.t insert end [string repeat "Line $i" 10] + .top.t insert end "\n" + } + .top.t yview 4.0 + .top.t tag add hidden 4.10 "4.10 lineend" + .top.t tag add hidden 5.15 10.3 + .top.t tag configure hidden -elide true + update + .top.t see "8.0 lineend" + # The index "8.0 lineend" is on screen despite elided -> no scroll + .top.t index @0,0 +} {4.0} .t configure -wrap word .t delete 50.0 51.0 -- cgit v0.12 From 3f037b375807f9780183c7ce635bffdd313bd98d Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Fri, 5 Dec 2014 20:33:13 +0000 Subject: Fixed text count -xpixels with indices in elided lines --- generic/tkTextDisp.c | 8 +++++--- tests/textDisp.test | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 3d442af..851ee3e 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -3382,7 +3382,8 @@ TkTextFindDisplayLineEnd( * of the original index within its display * line. */ { - if (!end && indexPtr->byteIndex == 0) { + if (!end && indexPtr->byteIndex == 0 + && !TkTextIsElided(textPtr, indexPtr, NULL)) { /* * Nothing to do. */ @@ -3461,8 +3462,9 @@ TkTextFindDisplayLineEnd( * this now. */ - *xOffset = DlineXOfIndex(textPtr, dlPtr, - indexPtr->byteIndex - dlPtr->index.byteIndex); + *xOffset = DlineXOfIndex(textPtr, dlPtr, + TkTextIndexCount(textPtr, &dlPtr->index, indexPtr, + COUNT_INDICES)); } if (end) { /* diff --git a/tests/textDisp.test b/tests/textDisp.test index fff52d4..c3ed43f 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -2065,6 +2065,27 @@ test textDisp-16.40 {text count -xpixels} { [.t count -xpixels 1.0 "1.0 displaylineend"] \ [.t count -xpixels 1.0 end] } {35 -35 0 42 42 42 0} +test textDisp-16.41 {text count -xpixels with indices in elided lines} { + set res {} + .t delete 1.0 end + for {set i 1} {$i < 40} {incr i} { + .t insert end [string repeat "Line $i" 20] + .t insert end "\n" + } + .t configure -wrap none + .t tag add hidden 5.15 20.15 + .t tag configure hidden -elide true + lappend res [.t count -xpixels 5.15 6.0] \ + [.t count -xpixels 5.15 6.1] \ + [.t count -xpixels 6.0 6.1] \ + [.t count -xpixels 6.1 6.2] \ + [.t count -xpixels 6.1 6.0] \ + [.t count -xpixels 6.0 7.0] \ + [.t count -xpixels 6.1 7.1] \ + [.t count -xpixels 15.0 20.15] \ + [.t count -xpixels 20.15 20.16] \ + [.t count -xpixels 20.16 20.15] +} [list 0 0 0 0 0 0 0 0 $fixedWidth -$fixedWidth] .t delete 1.0 end foreach i {a b c d e f g h i j k l m n o p q r s t u v w x y z} { -- cgit v0.12 From f869e6f21320a63d0e5017a7e4731fd31effaa3a Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Fri, 5 Dec 2014 21:32:03 +0000 Subject: indexPtr->byteIndex == 0 is the beginning of a display line only if indexPtr is not elided --- generic/tkTextDisp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 851ee3e..dd4aa31 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -5033,7 +5033,8 @@ TkTextSetYView( */ textPtr->topIndex = *indexPtr; - if (indexPtr->byteIndex != 0) { + if (!(indexPtr->byteIndex == 0 + && !TkTextIsElided(textPtr, indexPtr, NULL))) { TkTextFindDisplayLineEnd(textPtr, &textPtr->topIndex, 0, NULL); } dInfoPtr->newTopPixelOffset = pickPlace; -- cgit v0.12 From b92f66cfffb2a317ff6aa4657e078cfa1a5eb4ee Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Fri, 5 Dec 2014 22:13:26 +0000 Subject: Fixed bad comment resulting from copy/paste between functions --- generic/tkTextBTree.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/generic/tkTextBTree.c b/generic/tkTextBTree.c index 67ff79d..92164fc 100644 --- a/generic/tkTextBTree.c +++ b/generic/tkTextBTree.c @@ -1882,8 +1882,7 @@ TkBTreePreviousLine( * number of pixels in the widget. * * Results: - * The result is the index of linePtr within the tree, where 0 - * corresponds to the first line in the tree. + * The result is the pixel height of the top of the given line. * * Side effects: * None. -- cgit v0.12 From 2c4e0f969c6f41151d04bd6416dad4f027307b9d Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Fri, 5 Dec 2014 23:39:32 +0000 Subject: Fixed text count -ypixels with indices in elided lines --- generic/tkTextDisp.c | 9 ++++++--- tests/textDisp.test | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 851ee3e..8281411 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -3601,15 +3601,18 @@ TkTextIndexYPixels( int pixelHeight; TkTextIndex index; - pixelHeight = TkBTreePixelsTo(textPtr, indexPtr->linePtr); + index = *indexPtr; + TkTextFindDisplayLineEnd(textPtr, &index, 0, NULL); + + pixelHeight = TkBTreePixelsTo(textPtr, index.linePtr); /* * Iterate through all display-lines corresponding to the single logical - * line belonging to indexPtr, adding up the pixel height of each such + * line belonging to index, adding up the pixel height of each such * display line as we go along, until we go past 'indexPtr'. */ - if (indexPtr->byteIndex == 0) { + if (index.byteIndex == 0) { return pixelHeight; } diff --git a/tests/textDisp.test b/tests/textDisp.test index c3ed43f..71de1ac 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -2620,6 +2620,34 @@ test textDisp-19.16 {count -ypixels} { [.t count -ypixels 16.0 "16.0 displaylineend +1c"] \ [.t count -ypixels "16.0 +1 displaylines" "16.0 +4 displaylines +3c"] } [list [expr {260 + 20 * $fixedDiff}] [expr {260 + 20 * $fixedDiff}] $fixedHeight [expr {2*$fixedHeight}] $fixedHeight [expr {3*$fixedHeight}]] +test textDisp-19.17 {count -ypixels with indices in elided lines} { + .t configure -wrap none + .t delete 1.0 end + for {set i 1} {$i < 100} {incr i} { + .t insert end [string repeat "Line $i" 20] + .t insert end "\n" + } + .t tag add hidden 5.15 20.15 + .t tag configure hidden -elide true + set res {} + update + lappend res \ + [.t count -ypixels 1.0 6.0] \ + [.t count -ypixels 2.0 7.5] \ + [.t count -ypixels 5.0 8.5] \ + [.t count -ypixels 6.1 6.2] \ + [.t count -ypixels 6.1 18.8] \ + [.t count -ypixels 18.0 20.50] \ + [.t count -ypixels 5.2 20.60] \ + [.t count -ypixels 20.60 20.70] \ + [.t count -ypixels 5.0 25.0] \ + [.t count -ypixels 25.0 5.0] \ + [.t count -ypixels 25.4 27.50] \ + [.t count -ypixels 35.0 38.0] + .t yview 35.0 + update + lappend res [.t count -ypixels 5.0 25.0] +} [list [expr {4 * $fixedHeight}] [expr {3 * $fixedHeight}] 0 0 0 0 0 0 [expr {5 * $fixedHeight}] [expr {- 5 * $fixedHeight}] [expr {2 * $fixedHeight}] [expr {3 * $fixedHeight}] [expr {5 * $fixedHeight}]] .t delete 1.0 end .t insert end "Line 1" for {set i 2} {$i <= 200} {incr i} { -- cgit v0.12 From ffdfc492a9d0f7819d377c309d95fbdfc73e3de4 Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Sat, 6 Dec 2014 09:21:56 +0000 Subject: indexPtr->byteIndex == 0 is the beginning of a display line only if indexPtr is not elided --- generic/tkTextDisp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 538c59d..59efe04 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -4780,7 +4780,8 @@ TextRedrawTag( * the line containing the previous character. */ - if (curIndexPtr->byteIndex == 0) { + if ((curIndexPtr->byteIndex == 0) + && !TkTextIsElided(textPtr, curIndexPtr, NULL)) { dlPtr = FindDLine(textPtr, dlPtr, curIndexPtr); } else { TkTextIndex tmp; -- cgit v0.12 From 3a03b0aeef51008c61d388eb1ae74120f1709cc5 Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Sat, 6 Dec 2014 14:29:36 +0000 Subject: indexPtr->byteIndex == 0 is the beginning of a display line only if indexPtr is not elided. The start of a logical line is not always the start of a display line. --- generic/tkTextDisp.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 59efe04..ae5cdb2 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -6157,13 +6157,11 @@ GetYPixelCount( /* * For the common case where this dlPtr is also the start of the logical - * line, we can return right away. Note the implicit assumption here that - * the start of a logical line is always the start of a display line (if - * the 'elide won't elide first newline' bug is fixed, this will no longer - * necessarily be true). + * line, we can return right away. */ - if (dlPtr->index.byteIndex == 0) { + if ((dlPtr->index.byteIndex == 0) + && !TkTextIsElided(textPtr, &dlPtr->index, NULL)) { return count; } -- cgit v0.12 From 8cec2da5aca5eb44d7f6b9628e8b17a2d4d1988a Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Sun, 7 Dec 2014 18:50:46 +0000 Subject: Fixed text yview scroll pixels|lines with elided lines --- generic/tkTextDisp.c | 24 ++++++++++++++++++++++++ tests/textDisp.test | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 8281411..6b6d305 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -5285,6 +5285,18 @@ MeasureUp( distance -= dlPtr->height; if (distance <= 0) { *dstPtr = dlPtr->index; + + /* + * Adjust index to the start of the display line. This is + * needed because the start of a logical line is not always + * the start of a display line (this is however true if the + * eol is not elided). + */ + + if (TkTextIsElided(textPtr, dstPtr, NULL)) { + TkTextFindDisplayLineEnd(textPtr, dstPtr, 0, + NULL); + } if (overlap != NULL) { *overlap = -distance; } @@ -5677,6 +5689,18 @@ YScrollByLines( offset++; if (offset == 0) { textPtr->topIndex = dlPtr->index; + + /* + * Adjust index to the start of the display line. This is + * needed because the start of a logical line is not + * always the start of a display line (this is however + * true if the eol is not elided). + */ + + if (TkTextIsElided(textPtr, &textPtr->topIndex, NULL)) { + TkTextFindDisplayLineEnd(textPtr, &textPtr->topIndex, 0, + NULL); + } break; } } diff --git a/tests/textDisp.test b/tests/textDisp.test index 71de1ac..471a096 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -2086,6 +2086,36 @@ test textDisp-16.41 {text count -xpixels with indices in elided lines} { [.t count -xpixels 20.15 20.16] \ [.t count -xpixels 20.16 20.15] } [list 0 0 0 0 0 0 0 0 $fixedWidth -$fixedWidth] +test textDisp-16.42 {TkTextYviewCmd procedure with indices in elided lines} { + .t configure -wrap none + .t delete 1.0 end + for {set i 1} {$i < 100} {incr i} { + .t insert end [string repeat "Line $i" 20] + .t insert end "\n" + } + .t tag add hidden 5.15 20.15 + .t tag configure hidden -elide true + .t yview 35.0 + set res {} + .t yview scroll [expr {- 15 * $fixedHeight}] pixels + update + .t index @0,0 +} {5.0} +test textDisp-16.43 {TkTextYviewCmd procedure with indices in elided lines} { + .t configure -wrap none + .t delete 1.0 end + for {set i 1} {$i < 100} {incr i} { + .t insert end [string repeat "Line $i" 20] + .t insert end "\n" + } + .t tag add hidden 5.15 20.15 + .t tag configure hidden -elide true + .t yview 35.0 + set res {} + .t yview scroll -15 units + update + .t index @0,0 +} {5.0} .t delete 1.0 end foreach i {a b c d e f g h i j k l m n o p q r s t u v w x y z} { @@ -2648,6 +2678,23 @@ test textDisp-19.17 {count -ypixels with indices in elided lines} { update lappend res [.t count -ypixels 5.0 25.0] } [list [expr {4 * $fixedHeight}] [expr {3 * $fixedHeight}] 0 0 0 0 0 0 [expr {5 * $fixedHeight}] [expr {- 5 * $fixedHeight}] [expr {2 * $fixedHeight}] [expr {3 * $fixedHeight}] [expr {5 * $fixedHeight}]] +test textDisp-19.18 {count -ypixels with indices in elided lines} { + .t configure -wrap none + .t delete 1.0 end + for {set i 1} {$i < 100} {incr i} { + .t insert end [string repeat "Line $i" 20] + .t insert end "\n" + } + .t tag add hidden 5.15 20.15 + .t tag configure hidden -elide true + .t yview 35.0 + set res {} + update + lappend res [.t count -ypixels 5.0 25.0] + .t yview scroll [expr {- 15 * $fixedHeight}] pixels + update + lappend res [.t count -ypixels 5.0 25.0] +} [list [expr {5 * $fixedHeight}] [expr {5 * $fixedHeight}]] .t delete 1.0 end .t insert end "Line 1" for {set i 2} {$i <= 200} {incr i} { -- cgit v0.12 From 6d0fefe054df3df3b2bd4574fda0187ea6842e78 Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Wed, 10 Dec 2014 21:52:21 +0000 Subject: Fixed indentation in FindDLine --- generic/tkTextDisp.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 4715864..5f266f8 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -6495,26 +6495,26 @@ FindDLine( */ while (TkTextIndexCmp(&dlPtr->index,indexPtr) < 0) { - dlPtrPrev = dlPtr; - dlPtr = dlPtr->nextPtr; - if (dlPtr == NULL) { - /* - * We're past the last display line, either because the desired - * index lies past the visible text, or because the desired index - * is on the last display line showing the last logical line. - */ - indexPtr2 = dlPtrPrev->index; - TkTextFindDisplayLineEnd(textPtr, &indexPtr2, 1, NULL); - if (TkTextIndexCmp(&indexPtr2,indexPtr) >= 0) { - dlPtr = dlPtrPrev; - break; - } else { - return NULL; - } + dlPtrPrev = dlPtr; + dlPtr = dlPtr->nextPtr; + if (dlPtr == NULL) { + /* + * We're past the last display line, either because the desired + * index lies past the visible text, or because the desired index + * is on the last display line showing the last logical line. + */ + indexPtr2 = dlPtrPrev->index; + TkTextFindDisplayLineEnd(textPtr, &indexPtr2, 1, NULL); + if (TkTextIndexCmp(&indexPtr2,indexPtr) >= 0) { + dlPtr = dlPtrPrev; + break; + } else { + return NULL; + } } if (TkTextIndexCmp(&dlPtr->index,indexPtr) > 0) { dlPtr = dlPtrPrev; - break; + break; } } -- cgit v0.12 From 3c52d6b6edc99a34704df6b89766cb572f273a5a Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Wed, 10 Dec 2014 21:57:38 +0000 Subject: Fixed TextChanged caller of FindDLine for correct taking into account of elided newlines --- generic/tkTextDisp.c | 68 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 58 insertions(+), 10 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 6b6d305..946c543 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -4559,6 +4559,8 @@ TextChanged( TextDInfo *dInfoPtr = textPtr->dInfoPtr; DLine *firstPtr, *lastPtr; TkTextIndex rounded; + TkTextLine *linePtr; + int notBegin; /* * Schedule both a redisplay and a recomputation of display information. @@ -4584,23 +4586,69 @@ TextChanged( /* * Find the DLines corresponding to index1Ptr and index2Ptr. There is one * tricky thing here, which is that we have to relayout in units of whole - * text lines: round index1Ptr back to the beginning of its text line, and - * include all the display lines after index2, up to the end of its text - * line. This is necessary because the indices stored in the display lines - * will no longer be valid. It's also needed because any edit could change - * the way lines wrap. + * text lines: This is necessary because the indices stored in the display + * lines will no longer be valid. It's also needed because any edit could + * change the way lines wrap. + * To relayout in units of whole text (logical) lines, round index1Ptr + * back to the beginning of its text line (or, if this line start is + * elided, to the beginning of the text line that starts the display line + * it is included in), and include all the display lines after index2Ptr, + * up to the end of its text line (or, if this line end is elided, up to + * the end of the first non elided text line after this line end). */ rounded = *index1Ptr; - rounded.byteIndex = 0; + do { + rounded.byteIndex = 0; + notBegin = !TkTextIndexBackBytes(textPtr, &rounded, 1, &rounded); + } while (TkTextIsElided(textPtr, &rounded, NULL) && notBegin); + if (notBegin) { + TkTextIndexForwBytes(textPtr, &rounded, 1, &rounded); + } + + /* + * 'rounded' now points to the start of a display line as well as the + * real (non elided) start of a logical line, and this index is the + * closest before index1Ptr. + */ + firstPtr = FindDLine(textPtr, dInfoPtr->dLinePtr, &rounded); + if (firstPtr == NULL) { + + /* + * index1Ptr pertains to no display line, i.e this index is after + * the last display line. Since index2Ptr is after index1Ptr, there + * are no display line to free/redisplay and we can return early. + */ + return; } - lastPtr = FindDLine(textPtr, dInfoPtr->dLinePtr, index2Ptr); - while ((lastPtr != NULL) - && (lastPtr->index.linePtr == index2Ptr->linePtr)) { - lastPtr = lastPtr->nextPtr; + + rounded = *index2Ptr; + linePtr = index2Ptr->linePtr; + do { + linePtr = TkBTreeNextLine(textPtr, linePtr); + if (linePtr == NULL) { + break; + } + rounded.linePtr = linePtr; + rounded.byteIndex = 0; + TkTextIndexBackBytes(textPtr, &rounded, 1, &rounded); + } while (TkTextIsElided(textPtr, &rounded, NULL)); + + if (linePtr == NULL) { + lastPtr = NULL; + } else { + TkTextIndexForwBytes(textPtr, &rounded, 1, &rounded); + + /* + * 'rounded' now points to the start of a display line as well as the + * real (non elided) start of a logical line, and this index is the + * closest after index2Ptr. + */ + + lastPtr = FindDLine(textPtr, dInfoPtr->dLinePtr, &rounded); } /* -- cgit v0.12 From fdbe235403c6984d75a441f07d8e46e0eebf3ea6 Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Wed, 10 Dec 2014 22:00:20 +0000 Subject: Fixed textDisp-4.1 and -4.2 - The expected test results were not relevant without the update between deletion and insertion --- tests/textDisp.test | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/textDisp.test b/tests/textDisp.test index 471a096..678ad4e 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -537,20 +537,24 @@ test textDisp-4.1 {UpdateDisplayInfo, basic} {textfonts} { .t insert end "Line 1\nLine 2\nLine 3\n" update .t delete 2.0 2.end + update + set res $tk_textRelayout .t insert 2.0 "New Line 2" update - list [.t bbox 1.0] [.t bbox 2.0] [.t bbox 3.0] $tk_textRelayout -} [list [list 5 5 7 $fixedHeight] [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 5 [expr {2*$fixedDiff + 31}] 7 $fixedHeight] 2.0] + lappend res [.t bbox 1.0] [.t bbox 2.0] [.t bbox 3.0] $tk_textRelayout +} [list 2.0 [list 5 5 7 $fixedHeight] [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 5 [expr {2*$fixedDiff + 31}] 7 $fixedHeight] 2.0] test textDisp-4.2 {UpdateDisplayInfo, re-use tail of text line} {textfonts} { .t delete 1.0 end .t insert end "Line 1\nLine 2 is so long that it wraps around\nLine 3" update .t mark set x 2.21 .t delete 2.2 + update + set res $tk_textRelayout .t insert 2.0 X update - list [.t bbox 2.0] [.t bbox x] [.t bbox 3.0] $tk_textRelayout -} [list [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 12 [expr {2*$fixedDiff + 31}] 7 $fixedHeight] [list 5 [expr {3*$fixedDiff + 44}] 7 $fixedHeight] {2.0 2.20}] + lappend res [.t bbox 2.0] [.t bbox x] [.t bbox 3.0] $tk_textRelayout +} [list 2.0 2.20 [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 12 [expr {2*$fixedDiff + 31}] 7 $fixedHeight] [list 5 [expr {3*$fixedDiff + 44}] 7 $fixedHeight] {2.0 2.20}] test textDisp-4.3 {UpdateDisplayInfo, tail of text line shifts} {textfonts} { .t delete 1.0 end .t insert end "Line 1\nLine 2 is so long that it wraps around\nLine 3" -- cgit v0.12 From 9c92fb313b176276ff2f81adb8efc1a2e361eb68 Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Wed, 10 Dec 2014 22:48:21 +0000 Subject: More complete comment --- generic/tkTextDisp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 5c44935..f9a28a1 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -243,7 +243,8 @@ typedef struct DLine { * top to bottom. Note: the next DLine doesn't * always correspond to the next line of text: * (a) can have multiple DLines for one text - * line, and (b) can have gaps where DLine's + * line (wrapping), (b) can have elided newlines, + * and (c) can have gaps where DLine's * have been deleted because they're out of * date. */ int flags; /* Various flag bits: see below for values. */ -- cgit v0.12 From 41471915d5b30ca17a33826b7ee3075fcbec9ae5 Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Sun, 14 Dec 2014 16:48:25 +0000 Subject: At least one display line is supposed to change when calling TkTextChanged. --- generic/tkTextDisp.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index f9a28a1..e87b5e8 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -4650,6 +4650,19 @@ TextChanged( */ lastPtr = FindDLine(textPtr, dInfoPtr->dLinePtr, &rounded); + + /* + * At least one display line is supposed to change. This makes the + * redisplay OK in case the display line we expect to get here was + * unlinked by a previous call to TkTextChanged and the text widget + * did not update before reaching this point. This happens for + * instance when moving the cursor up one line. + * Note that lastPtr != NULL here, otherwise we would have returned + * earlier when we tested for firstPtr being NULL. + */ + if (lastPtr == firstPtr) { + lastPtr = lastPtr->nextPtr; + } } /* -- cgit v0.12 From 8eff440ff3090ad62bb45748fff7bcb4592f1c12 Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Wed, 17 Dec 2014 21:52:09 +0000 Subject: Removed useless statements in tests textDisp-16.42 and textDisp-16.43 --- tests/textDisp.test | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/textDisp.test b/tests/textDisp.test index 678ad4e..b8db32c 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -2100,7 +2100,6 @@ test textDisp-16.42 {TkTextYviewCmd procedure with indices in elided lines} { .t tag add hidden 5.15 20.15 .t tag configure hidden -elide true .t yview 35.0 - set res {} .t yview scroll [expr {- 15 * $fixedHeight}] pixels update .t index @0,0 @@ -2115,7 +2114,6 @@ test textDisp-16.43 {TkTextYviewCmd procedure with indices in elided lines} { .t tag add hidden 5.15 20.15 .t tag configure hidden -elide true .t yview 35.0 - set res {} .t yview scroll -15 units update .t index @0,0 -- cgit v0.12 From 900b25a5d878ed258bdec05e4aa01c0d992d550e Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Wed, 17 Dec 2014 21:54:54 +0000 Subject: Fixed vertical scrolling with elided lines. MeasureUp was not measuring fully correctly. --- generic/tkTextDisp.c | 2 ++ tests/textDisp.test | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index e87b5e8..e318338 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -5328,6 +5328,8 @@ MeasureUp( index.linePtr = TkBTreeFindLine(srcPtr->tree, textPtr, lineNum); index.byteIndex = 0; + TkTextFindDisplayLineEnd(textPtr, &index, 0, NULL); + lineNum = TkBTreeLinesTo(textPtr, index.linePtr); lowestPtr = NULL; do { dlPtr = LayoutDLine(textPtr, &index); diff --git a/tests/textDisp.test b/tests/textDisp.test index b8db32c..ea2100c 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -2118,6 +2118,19 @@ test textDisp-16.43 {TkTextYviewCmd procedure with indices in elided lines} { update .t index @0,0 } {5.0} +test textDisp-16.44 {TkTextYviewCmd procedure, scroll down, with elided lines} { + .t configure -wrap none + .t delete 1.0 end + foreach x [list 0 1 2 3 4 5 6 7 8 9 0] { + .t insert end "$x aaa1\n$x bbb2\n$x ccc3\n$x ddd4\n$x eee5\n$x fff6" + .t insert end "$x 1111\n$x 2222\n$x 3333\n$x 4444\n$x 5555\n$x 6666" hidden + } + .t tag configure hidden -elide true ; # 5 hidden lines + update + .t see [expr {5 + [winfo height .t] / $fixedHeight} + 1].0 + update + .t index @0,0 +} {2.0} .t delete 1.0 end foreach i {a b c d e f g h i j k l m n o p q r s t u v w x y z} { -- cgit v0.12 From 733c6f5efcb2da9e189da69bb388edab5356f896 Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Sat, 20 Dec 2014 13:42:50 +0000 Subject: Fixed comment --- generic/tkText.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 1156086..139e71d 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -908,8 +908,8 @@ TextWidgetObjCmd( * line of 'indexFromPtr' up to, but not including the logical * line of 'indexToPtr' (except if this line is elided), and * then subtract off what came in too much from elided lines, - * also subtract off we didn't want from 'from' and add on - * what we didn't count from 'to'. + * also subtract off what we didn't want from 'from' and add + * on what we didn't count from 'to'. */ while (TkTextIndexCmp(&index,indexToPtr) < 0) { -- cgit v0.12 From 83cfcd5e8c925fd14880f339c9a1e3d469aa2e1e Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Sun, 21 Dec 2014 20:54:05 +0000 Subject: Fixed test of index being at start of both a logical line and a display line in TkTextFindDisplayLineEnd --- generic/tkTextDisp.c | 4 +++- tests/textDisp.test | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index e318338..9d6a307 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -3383,8 +3383,10 @@ TkTextFindDisplayLineEnd( * of the original index within its display * line. */ { + TkTextIndex indexPtr2; + TkTextIndexBackBytes(textPtr, indexPtr, 1, &indexPtr2); if (!end && indexPtr->byteIndex == 0 - && !TkTextIsElided(textPtr, indexPtr, NULL)) { + && !TkTextIsElided(textPtr, &indexPtr2, NULL)) { /* * Nothing to do. */ diff --git a/tests/textDisp.test b/tests/textDisp.test index ea2100c..cab0ff6 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -2089,7 +2089,9 @@ test textDisp-16.41 {text count -xpixels with indices in elided lines} { [.t count -xpixels 15.0 20.15] \ [.t count -xpixels 20.15 20.16] \ [.t count -xpixels 20.16 20.15] -} [list 0 0 0 0 0 0 0 0 $fixedWidth -$fixedWidth] + .t tag remove hidden 20.0 20.15 + lappend res [expr {[.t count -xpixels 5.0 20.0] != 0}] +} [list 0 0 0 0 0 0 0 0 $fixedWidth -$fixedWidth 1] test textDisp-16.42 {TkTextYviewCmd procedure with indices in elided lines} { .t configure -wrap none .t delete 1.0 end -- cgit v0.12 From 49a0cf76e1ce632f0b5e41e12b1e17696e84d5f7 Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Tue, 23 Dec 2014 10:59:48 +0000 Subject: Fixed wrong index returned by @x,y with elided lines at end of text - Bug [c199ef90a6] --- generic/tkTextDisp.c | 7 ++++++- tests/textDisp.test | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index f16c45b..bb026af 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -6649,10 +6649,15 @@ DlineIndexOfX( * We've reached the end of the text. */ + TkTextIndexBackChars(NULL, indexPtr, 1, indexPtr, COUNT_INDICES); return; } if (chunkPtr->nextPtr == NULL) { - TkTextIndexBackChars(NULL, indexPtr, 1, indexPtr, COUNT_INDICES); + /* + * We've reached the end of the display line. + */ + + TkTextIndexBackChars(NULL, indexPtr, 1, indexPtr, COUNT_INDICES); return; } chunkPtr = chunkPtr->nextPtr; diff --git a/tests/textDisp.test b/tests/textDisp.test index 70c7208..ae294c6 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -2444,7 +2444,7 @@ test textDisp-19.11.23 {TextWidgetCmd procedure, "index +displaylines"} { [.t index "12.0 +2d lines"] [.t index "11.0 +2d lines"] \ [.t index "13.0 +2d lines"] [.t index "13.0 +3d lines"] \ [.t index "13.0 +4d lines"] -} {16.17 16.33 16.28 16.46 16.28 16.49 16.65 17.0} +} {16.17 16.33 16.28 16.46 16.28 16.49 16.65 16.72} .t tag remove elide 1.0 end test textDisp-19.11.24 {TextWidgetCmd procedure, "index +/-displaylines"} { list [.t index "11.5 + -1 display lines"] \ -- cgit v0.12 From d5a212484ba29cda723148f470600e7808b497d8 Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Tue, 23 Dec 2014 11:09:50 +0000 Subject: Cherrypicked bug fix for Bug [c199ef90a6] - Wrong index returned by @x,y with elided lines at end of text --- generic/tkTextDisp.c | 7 ++++++- tests/textDisp.test | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 9d6a307..14f843b 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -6754,10 +6754,15 @@ DlineIndexOfX( * We've reached the end of the text. */ + TkTextIndexBackChars(NULL, indexPtr, 1, indexPtr, COUNT_INDICES); return; } if (chunkPtr->nextPtr == NULL) { - TkTextIndexBackChars(NULL, indexPtr, 1, indexPtr, COUNT_INDICES); + /* + * We've reached the end of the display line. + */ + + TkTextIndexBackChars(NULL, indexPtr, 1, indexPtr, COUNT_INDICES); return; } chunkPtr = chunkPtr->nextPtr; diff --git a/tests/textDisp.test b/tests/textDisp.test index cab0ff6..6c21700 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -2558,7 +2558,7 @@ test textDisp-19.11.23 {TextWidgetCmd procedure, "index +displaylines"} { [.t index "12.0 +2d lines"] [.t index "11.0 +2d lines"] \ [.t index "13.0 +2d lines"] [.t index "13.0 +3d lines"] \ [.t index "13.0 +4d lines"] -} {16.17 16.33 16.28 16.46 16.28 16.49 16.65 17.0} +} {16.17 16.33 16.28 16.46 16.28 16.49 16.65 16.72} .t tag remove elide 1.0 end test textDisp-19.11.24 {TextWidgetCmd procedure, "index +/-displaylines"} { list [.t index "11.5 + -1 display lines"] \ -- cgit v0.12 From 0b9a2355f3a95352e0c15610b9b1943840770bf9 Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Sun, 28 Dec 2014 13:57:22 +0000 Subject: Fixed indentation in TkTextUpdateOneLine --- generic/tkTextDisp.c | 70 ++++++++++++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 14f843b..f99ecd8 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -3733,7 +3733,7 @@ TkTextUpdateOneLine( * test below this while loop. */ - height = CalculateDisplayLineHeight(textPtr, indexPtr, &bytes, + height = CalculateDisplayLineHeight(textPtr, indexPtr, &bytes, &logicalLines); if (height > 0) { @@ -3747,47 +3747,47 @@ TkTextUpdateOneLine( break; } - if (mergedLines == 0) { - if (indexPtr->linePtr != linePtr) { - /* - * If we reached the end of the logical line, then either way - * we don't have a partial calculation. - */ + if (mergedLines == 0) { + if (indexPtr->linePtr != linePtr) { + /* + * If we reached the end of the logical line, then either way + * we don't have a partial calculation. + */ - partialCalc = 0; - break; - } + partialCalc = 0; + break; + } } else { if (indexPtr->byteIndex != 0) { - /* - * We must still be on the same wrapped line, on a new logical - * line merged with the logical line 'linePtr'. - */ - } else { - /* - * Must check if indexPtr is really a new logical line which is - * not merged with the previous line. The only code that would - * really know this is LayoutDLine, which doesn't pass the - * information on, so we have to check manually here. - */ + /* + * We must still be on the same wrapped line, on a new logical + * line merged with the logical line 'linePtr'. + */ + } else { + /* + * Must check if indexPtr is really a new logical line which is + * not merged with the previous line. The only code that would + * really know this is LayoutDLine, which doesn't pass the + * information on, so we have to check manually here. + */ - TkTextIndex idx; + TkTextIndex idx; - TkTextIndexBackChars(textPtr, indexPtr, 1, &idx, COUNT_INDICES); - if (!TkTextIsElided(textPtr, &idx, NULL)) { - /* - * We've ended a logical line. - */ + TkTextIndexBackChars(textPtr, indexPtr, 1, &idx, COUNT_INDICES); + if (!TkTextIsElided(textPtr, &idx, NULL)) { + /* + * We've ended a logical line. + */ - partialCalc = 0; - break; - } + partialCalc = 0; + break; + } - /* - * We must still be on the same wrapped line, on a new logical - * line merged with the logical line 'linePtr'. - */ - } + /* + * We must still be on the same wrapped line, on a new logical + * line merged with the logical line 'linePtr'. + */ + } } if (partialCalc && displayLines > 50 && mergedLines == 0) { /* -- cgit v0.12 From 396c5124922c8af09c7137aef801a864251aff76 Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Sun, 28 Dec 2014 15:09:46 +0000 Subject: Fixed Bad counting of the total number of vertical pixels in the text widget, resulting in small change of the Y scrollbar size. Happened because CalculateDisplayLineHeight expects an index at start of a display line, which was not always the case. --- generic/tkTextDisp.c | 14 ++++++++++++++ tests/text.test | 18 ++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index f99ecd8..ae9c341 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -3711,6 +3711,20 @@ TkTextUpdateOneLine( } /* + * CalculateDisplayLineHeight _must_ be called (below) with an index at + * the beginning of a display line. Force this to happen. This is needed + * when TkTextUpdateOneLine is called with a line that is merged with its + * previous line: the number of merged logical lines in a display line is + * calculated correctly only when CalculateDisplayLineHeight receives + * an index at the beginning of a display line. In turn this causes the + * merged lines to receive their correct zero pixel height in + * TkBTreeAdjustPixelHeight. + */ + + TkTextFindDisplayLineEnd(textPtr, indexPtr, 0, NULL); + linePtr = indexPtr->linePtr; + + /* * Iterate through all display-lines corresponding to the single logical * line 'linePtr' (and lines merged into this line due to eol elision), * adding up the pixel height of each such display line as we go along. diff --git a/tests/text.test b/tests/text.test index 6121b85..e75f38a 100644 --- a/tests/text.test +++ b/tests/text.test @@ -733,6 +733,24 @@ test text-9.2.46 {TextWidgetCmd procedure, "count" option} -setup { } -cleanup { destroy .mytop } -result {1 3} +test text-9.2.47 {TextWidgetCmd procedure, "count" option} -setup { + .t delete 1.0 end + update + set res {} +} -body { + for {set i 1} {$i < 25} {incr i} { + .t insert end "Line $i\n" + } + .t tag configure hidden -elide true + .t tag add hidden 5.7 11.0 + update + set y1 [lindex [.t yview] 1] + .t count -displaylines 5.0 11.0 + set y2 [lindex [.t yview] 1] + .t count -displaylines 5.0 12.0 + set y3 [lindex [.t yview] 1] + list [expr {$y1 == $y2}] [expr {$y1 == $y3}] +} -result {1 1} # Newer tags are higher priority .t tag configure elide1 -elide 0 -- cgit v0.12 From 1db2bc4ee2cae75817034ad61179cc146ba1db3b Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Sun, 28 Dec 2014 18:00:53 +0000 Subject: Further fixed text count -ypixels with indices in elided lines, [30d6b995dc] was not always correct --- generic/tkTextDisp.c | 44 ++++++++++++++++++++++++++++++-------------- tests/textDisp.test | 14 +++++++++++++- 2 files changed, 43 insertions(+), 15 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index ae9c341..be77550 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -3603,29 +3603,44 @@ TkTextIndexYPixels( { int pixelHeight; TkTextIndex index; + int alreadyStartOfLine = 1; + + /* + * Find the index denoting the closest position being at the same time + * the start of a logical line above indexPtr and the start of a display + * line. + */ index = *indexPtr; - TkTextFindDisplayLineEnd(textPtr, &index, 0, NULL); + while (1) { + TkTextFindDisplayLineEnd(textPtr, &index, 0, NULL); + if (index.byteIndex == 0) { + break; + } + TkTextIndexBackBytes(textPtr, &index, 1, &index); + alreadyStartOfLine = 0; + } pixelHeight = TkBTreePixelsTo(textPtr, index.linePtr); /* - * Iterate through all display-lines corresponding to the single logical - * line belonging to index, adding up the pixel height of each such - * display line as we go along, until we go past 'indexPtr'. + * Shortcut to avoid layout of a superfluous display line. We know there + * is nothing more to add up to the height since the index we were given + * was already the start of a logical line. */ - if (index.byteIndex == 0) { - return pixelHeight; + if (alreadyStartOfLine) { + return pixelHeight; } - index.tree = textPtr->sharedTextPtr->tree; - index.linePtr = indexPtr->linePtr; - index.byteIndex = 0; - index.textPtr = NULL; + /* + * Iterate through display lines, starting at the logical line belonging + * to index, adding up the pixel height of each such display line as we + * go along, until we go past 'indexPtr'. + */ while (1) { - int bytes, height; + int bytes, height, compare; /* * Currently this call doesn't have many side-effects. However, if in @@ -3637,9 +3652,10 @@ TkTextIndexYPixels( height = CalculateDisplayLineHeight(textPtr, &index, &bytes, NULL); - index.byteIndex += bytes; + TkTextIndexForwBytes(textPtr, &index, bytes, &index); - if (index.byteIndex > indexPtr->byteIndex) { + compare = TkTextIndexCmp(&index,indexPtr); + if (compare > 0) { return pixelHeight; } @@ -3647,7 +3663,7 @@ TkTextIndexYPixels( pixelHeight += height; } - if (index.byteIndex == indexPtr->byteIndex) { + if (compare == 0) { return pixelHeight; } } diff --git a/tests/textDisp.test b/tests/textDisp.test index 6c21700..954c1f6 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -2692,7 +2692,6 @@ test textDisp-19.17 {count -ypixels with indices in elided lines} { [.t count -ypixels 25.4 27.50] \ [.t count -ypixels 35.0 38.0] .t yview 35.0 - update lappend res [.t count -ypixels 5.0 25.0] } [list [expr {4 * $fixedHeight}] [expr {3 * $fixedHeight}] 0 0 0 0 0 0 [expr {5 * $fixedHeight}] [expr {- 5 * $fixedHeight}] [expr {2 * $fixedHeight}] [expr {3 * $fixedHeight}] [expr {5 * $fixedHeight}]] test textDisp-19.18 {count -ypixels with indices in elided lines} { @@ -2712,6 +2711,19 @@ test textDisp-19.18 {count -ypixels with indices in elided lines} { update lappend res [.t count -ypixels 5.0 25.0] } [list [expr {5 * $fixedHeight}] [expr {5 * $fixedHeight}]] +test textDisp-19.19 {count -ypixels with indices in elided lines} { + .t configure -wrap char + .t delete 1.0 end + for {set i 1} {$i < 25} {incr i} { + .t insert end [string repeat "Line $i -" 6] + .t insert end "\n" + } + .t tag add hidden 5.27 11.0 + .t tag configure hidden -elide true + .t yview 5.0 + update + set res [list [.t count -ypixels 5.0 11.0] [.t count -ypixels 5.0 11.20]] +} [list [expr {1 * $fixedHeight}] [expr {2 * $fixedHeight}]] .t delete 1.0 end .t insert end "Line 1" for {set i 2} {$i <= 200} {incr i} { -- cgit v0.12 From 4c6441684099d28cec1b4f1c61aa7607e6fddd90 Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Sun, 28 Dec 2014 20:58:10 +0000 Subject: Further fixed text see with indices in elided lines, [5f352f3a71] was not always correct --- generic/tkTextDisp.c | 4 +++- tests/textDisp.test | 31 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index be77550..4d9d042 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -5181,7 +5181,9 @@ TkTextSetYView( * If the line is not close, place it in the center of the window. */ - lineHeight = CalculateDisplayLineHeight(textPtr, indexPtr, NULL, NULL); + tmpIndex = *indexPtr; + TkTextFindDisplayLineEnd(textPtr, &tmpIndex, 0, NULL); + lineHeight = CalculateDisplayLineHeight(textPtr, &tmpIndex, NULL, NULL); /* * It would be better if 'bottomY' were calculated using the actual height diff --git a/tests/textDisp.test b/tests/textDisp.test index 954c1f6..1f85117 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -1492,6 +1492,37 @@ test textDisp-11.18 {TkTextSetYView, see in elided lines} { # The index "8.0 lineend" is on screen despite elided -> no scroll .top.t index @0,0 } {4.0} +test textDisp-11.19 {TkTextSetYView, see in elided lines} { + .top.t delete 1.0 end + for {set i 1} {$i < 50} {incr i} { + .top.t insert end "Line $i\n" + } + # button just for having a line with a larger height + button .top.t.b -text "Test" -bd 2 -highlightthickness 2 + .top.t window create 21.0 -window .top.t.b + .top.t tag add hidden 15.36 21.0 + .top.t tag configure hidden -elide true + .top.t configure -height 15 + wm geometry .top 300x200+0+0 + # Indices 21.0, 17.0 and 15.0 are all on the same display line + # therefore index @0,0 shall be the same for all of them + .top.t see end + update + .top.t see 21.0 + update + set ind1 [.top.t index @0,0] + .top.t see end + update + .top.t see 17.0 + update + set ind2 [.top.t index @0,0] + .top.t see end + update + .top.t see 15.0 + update + set ind3 [.top.t index @0,0] + list [expr {$ind1 == $ind2}] [expr {$ind1 == $ind3}] +} {1 1} .t configure -wrap word .t delete 50.0 51.0 -- cgit v0.12 From 76f6c6ce18084bc621fe2fea51f2f794d36d9e0a Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Mon, 29 Dec 2014 16:27:07 +0000 Subject: CalculateDisplayLineHeight checks, in debug mode, that the index it receives really is at the beginning of a display line. --- generic/tkTextDisp.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 4d9d042..a63c9bc 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -3537,6 +3537,27 @@ CalculateDisplayLineHeight( DLine *dlPtr; int pixelHeight; + if (tkTextDebug) { + int oldtkTextDebug = tkTextDebug; + /* + * Check that the indexPtr we are given really is at the start of a + * display line. The gymnastics with tkTextDebug is to prevent + * failure of a test suite test, that checks that lines are rendered + * exactly once. TkTextFindDisplayLineEnd is used here for checking + * indexPtr but it calls LayoutDLine/FreeDLine which makes the + * counting wrong. The debug mode shall threfore be switched off when + * calling TkTextFindDisplayLineEnd. + */ + + TkTextIndex indexPtr2 = *indexPtr; + tkTextDebug = 0; + TkTextFindDisplayLineEnd(textPtr, &indexPtr2, 0, NULL); + tkTextDebug = oldtkTextDebug; + if (TkTextIndexCmp(&indexPtr2,indexPtr) != 0) { + Tcl_Panic("CalculateDisplayLineHeight called with bad indexPtr"); + } + } + /* * Special case for artificial last line. May be better to move this * inside LayoutDLine. -- cgit v0.12 From bba7aa7bfd719b6b6ebb8bd5283f01f4f9b41700 Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Tue, 30 Dec 2014 14:59:37 +0000 Subject: Polishing FindDLine - Avoid use of TkTextFindDisplayLineEnd when not really necessary (performance reasons, and avoids LayoutDLine/FreeDLine which maps/unmaps embedded windows unnecessarily) --- generic/tkTextDisp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index a63c9bc..6b23002 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -6592,7 +6592,6 @@ FindDLine( CONST TkTextIndex *indexPtr)/* Index of desired character. */ { DLine *dlPtrPrev; - TkTextIndex indexPtr2; if (dlPtr == NULL) { return NULL; @@ -6617,14 +6616,16 @@ FindDLine( dlPtrPrev = dlPtr; dlPtr = dlPtr->nextPtr; if (dlPtr == NULL) { + TkTextIndex indexPtr2; /* * We're past the last display line, either because the desired * index lies past the visible text, or because the desired index * is on the last display line showing the last logical line. */ indexPtr2 = dlPtrPrev->index; - TkTextFindDisplayLineEnd(textPtr, &indexPtr2, 1, NULL); - if (TkTextIndexCmp(&indexPtr2,indexPtr) >= 0) { + TkTextIndexForwBytes(textPtr, &indexPtr2, dlPtrPrev->byteCount, + &indexPtr2); + if (TkTextIndexCmp(&indexPtr2,indexPtr) > 0) { dlPtr = dlPtrPrev; break; } else { -- cgit v0.12 From 5535a062a85b295f8e1079cd3df6990cd542f4cf Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Tue, 30 Dec 2014 16:29:23 +0000 Subject: Fixed comment in TkTextIndexYPixels --- generic/tkTextDisp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 6b23002..56d1003 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -3646,8 +3646,8 @@ TkTextIndexYPixels( /* * Shortcut to avoid layout of a superfluous display line. We know there - * is nothing more to add up to the height since the index we were given - * was already the start of a logical line. + * is nothing more to add up to the height if the index we were given was + * already the start of a logical line. */ if (alreadyStartOfLine) { -- cgit v0.12 From 2654486bec2bab3077fe2332ffff661a74279424 Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Tue, 30 Dec 2014 16:38:53 +0000 Subject: Fixed comments in TextChanged --- generic/tkTextDisp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 56d1003..6d49488 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -4669,11 +4669,10 @@ TextChanged( firstPtr = FindDLine(textPtr, dInfoPtr->dLinePtr, &rounded); if (firstPtr == NULL) { - /* * index1Ptr pertains to no display line, i.e this index is after * the last display line. Since index2Ptr is after index1Ptr, there - * are no display line to free/redisplay and we can return early. + * is no display line to free/redisplay and we can return early. */ return; @@ -4698,8 +4697,8 @@ TextChanged( /* * 'rounded' now points to the start of a display line as well as the - * real (non elided) start of a logical line, and this index is the - * closest after index2Ptr. + * start of a logical line not merged with its previous line, and + * this index is the closest after index2Ptr. */ lastPtr = FindDLine(textPtr, dInfoPtr->dLinePtr, &rounded); @@ -4713,6 +4712,7 @@ TextChanged( * Note that lastPtr != NULL here, otherwise we would have returned * earlier when we tested for firstPtr being NULL. */ + if (lastPtr == firstPtr) { lastPtr = lastPtr->nextPtr; } -- cgit v0.12 From 8d366e13d6030e0baf15350712a1d19505d631c4 Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Tue, 30 Dec 2014 16:56:47 +0000 Subject: Reverted [8568be1258] since this commit was not correct. --- generic/tkTextDisp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 6d49488..058f85c 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -4895,8 +4895,7 @@ TextRedrawTag( * the line containing the previous character. */ - if ((curIndexPtr->byteIndex == 0) - && !TkTextIsElided(textPtr, curIndexPtr, NULL)) { + if (curIndexPtr->byteIndex == 0) { dlPtr = FindDLine(textPtr, dlPtr, curIndexPtr); } else { TkTextIndex tmp; -- cgit v0.12 From b7dcf57dd9d78be3f083b07850c0742392b3eb7b Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Tue, 30 Dec 2014 17:08:43 +0000 Subject: Reverted [9f0edc127f] since this commit was not correct. --- generic/tkTextDisp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 058f85c..ec14e10 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -5151,8 +5151,7 @@ TkTextSetYView( */ textPtr->topIndex = *indexPtr; - if (!(indexPtr->byteIndex == 0 - && !TkTextIsElided(textPtr, indexPtr, NULL))) { + if (indexPtr->byteIndex != 0) { TkTextFindDisplayLineEnd(textPtr, &textPtr->topIndex, 0, NULL); } dInfoPtr->newTopPixelOffset = pickPlace; -- cgit v0.12 From 8b3c7501475ddb19633768c09e221eb111280b4f Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Tue, 30 Dec 2014 17:13:00 +0000 Subject: Better fix than [9f0edc127f], now takes merged lines into account. --- generic/tkTextDisp.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index ec14e10..c310100 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -5151,9 +5151,7 @@ TkTextSetYView( */ textPtr->topIndex = *indexPtr; - if (indexPtr->byteIndex != 0) { - TkTextFindDisplayLineEnd(textPtr, &textPtr->topIndex, 0, NULL); - } + TkTextFindDisplayLineEnd(textPtr, &textPtr->topIndex, 0, NULL); dInfoPtr->newTopPixelOffset = pickPlace; goto scheduleUpdate; } -- cgit v0.12 From 36305f748dab71e0a260a3d2e4b40c0ef65a39c8 Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Tue, 30 Dec 2014 17:36:06 +0000 Subject: A logical line is merged with its previous line if and only if the eol of the previous line is elided ([926d2c3900] was not fully correct). --- generic/tkTextDisp.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index c310100..c21b600 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -5401,7 +5401,8 @@ MeasureUp( for (dlPtr = lowestPtr; dlPtr != NULL; dlPtr = dlPtr->nextPtr) { distance -= dlPtr->height; if (distance <= 0) { - *dstPtr = dlPtr->index; + TkTextIndex tmpIndex = dlPtr->index; + *dstPtr = dlPtr->index; /* * Adjust index to the start of the display line. This is @@ -5410,9 +5411,9 @@ MeasureUp( * eol is not elided). */ - if (TkTextIsElided(textPtr, dstPtr, NULL)) { - TkTextFindDisplayLineEnd(textPtr, dstPtr, 0, - NULL); + TkTextIndexBackBytes(textPtr, &tmpIndex, 1, &tmpIndex); + if (TkTextIsElided(textPtr, &tmpIndex, NULL)) { + TkTextFindDisplayLineEnd(textPtr, dstPtr, 0, NULL); } if (overlap != NULL) { *overlap = -distance; @@ -5805,6 +5806,7 @@ YScrollByLines( for (dlPtr = lowestPtr; dlPtr != NULL; dlPtr = dlPtr->nextPtr) { offset++; if (offset == 0) { + TkTextIndex tmpIndex = dlPtr->index; textPtr->topIndex = dlPtr->index; /* @@ -5814,7 +5816,8 @@ YScrollByLines( * true if the eol is not elided). */ - if (TkTextIsElided(textPtr, &textPtr->topIndex, NULL)) { + TkTextIndexBackBytes(textPtr, &tmpIndex, 1, &tmpIndex); + if (TkTextIsElided(textPtr, &tmpIndex, NULL)) { TkTextFindDisplayLineEnd(textPtr, &textPtr->topIndex, 0, NULL); } -- cgit v0.12 From c26c8c4f03ba06cb0b9149185fbb7fd13debda79 Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Tue, 30 Dec 2014 17:52:30 +0000 Subject: Reverted [53f96d9a97] since this commit was not correct. --- generic/tkTextDisp.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index c21b600..1383c2a 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -6299,11 +6299,13 @@ GetYPixelCount( /* * For the common case where this dlPtr is also the start of the logical - * line, we can return right away. + * line, we can return right away. Note the implicit assumption here that + * the start of a logical line is always the start of a display line (if + * the 'elide won't elide first newline' bug is fixed, this will no longer + * necessarily be true). */ - if ((dlPtr->index.byteIndex == 0) - && !TkTextIsElided(textPtr, &dlPtr->index, NULL)) { + if (dlPtr->index.byteIndex == 0) { return count; } -- cgit v0.12 From 478ebe7bce8f3afd32435d357e473df19ddae367 Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Tue, 30 Dec 2014 17:57:17 +0000 Subject: A logical line is merged with its previous line if and only if the eol of the previous line is elided ([53f96d9a97] was not fully correct). --- generic/tkTextDisp.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 1383c2a..c90f898 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -6287,6 +6287,7 @@ GetYPixelCount( * index. */ { TkTextLine *linePtr = dlPtr->index.linePtr; + TkTextIndex tmpIndex = dlPtr->index; int count; /* @@ -6299,13 +6300,12 @@ GetYPixelCount( /* * For the common case where this dlPtr is also the start of the logical - * line, we can return right away. Note the implicit assumption here that - * the start of a logical line is always the start of a display line (if - * the 'elide won't elide first newline' bug is fixed, this will no longer - * necessarily be true). + * line, we can return right away. */ - if (dlPtr->index.byteIndex == 0) { + TkTextIndexBackBytes(textPtr, &tmpIndex, 1, &tmpIndex); + if ((dlPtr->index.byteIndex == 0) + && !TkTextIsElided(textPtr, &tmpIndex, NULL)) { return count; } -- cgit v0.12 From 70b8bebf37ae425095f1b36d882c9e8ec04fe160 Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Thu, 1 Jan 2015 22:45:36 +0000 Subject: Factorized a bit the code, making use of a new function IsStartOfNotMergedLine when possible, instead of repeating the same code. Also, removed possible bugs linked to wrong testing conditions (indexPtr->byteIndex [!=]= 0) --- generic/tkTextDisp.c | 110 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 70 insertions(+), 40 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index c90f898..6cf78fb 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -591,6 +591,8 @@ static int TextGetScrollInfoObj(Tcl_Interp *interp, int *intPtr); static void AsyncUpdateLineMetrics(ClientData clientData); static void AsyncUpdateYScrollbar(ClientData clientData); +static int IsStartOfNotMergedLine(TkText *textPtr, + CONST TkTextIndex *indexPtr); /* * Result values returned by TextGetScrollInfoObj: @@ -3383,10 +3385,7 @@ TkTextFindDisplayLineEnd( * of the original index within its display * line. */ { - TkTextIndex indexPtr2; - TkTextIndexBackBytes(textPtr, indexPtr, 1, &indexPtr2); - if (!end && indexPtr->byteIndex == 0 - && !TkTextIsElided(textPtr, &indexPtr2, NULL)) { + if (!end && IsStartOfNotMergedLine(textPtr, indexPtr)) { /* * Nothing to do. */ @@ -3809,36 +3808,19 @@ TkTextUpdateOneLine( break; } } else { - if (indexPtr->byteIndex != 0) { + if (IsStartOfNotMergedLine(textPtr, indexPtr)) { /* - * We must still be on the same wrapped line, on a new logical - * line merged with the logical line 'linePtr'. + * We've ended a logical line. */ - } else { - /* - * Must check if indexPtr is really a new logical line which is - * not merged with the previous line. The only code that would - * really know this is LayoutDLine, which doesn't pass the - * information on, so we have to check manually here. - */ - - TkTextIndex idx; - TkTextIndexBackChars(textPtr, indexPtr, 1, &idx, COUNT_INDICES); - if (!TkTextIsElided(textPtr, &idx, NULL)) { - /* - * We've ended a logical line. - */ - - partialCalc = 0; - break; - } - - /* - * We must still be on the same wrapped line, on a new logical - * line merged with the logical line 'linePtr'. - */ + partialCalc = 0; + break; } + + /* + * We must still be on the same wrapped line, on a new logical + * line merged with the logical line 'linePtr'. + */ } if (partialCalc && displayLines > 50 && mergedLines == 0) { /* @@ -4895,13 +4877,12 @@ TextRedrawTag( * the line containing the previous character. */ - if (curIndexPtr->byteIndex == 0) { + if (IsStartOfNotMergedLine(textPtr, curIndexPtr)) { dlPtr = FindDLine(textPtr, dlPtr, curIndexPtr); } else { - TkTextIndex tmp; + TkTextIndex tmp = *curIndexPtr; - tmp = *curIndexPtr; - tmp.byteIndex -= 1; + TkTextIndexBackBytes(textPtr, &tmp, 1, &tmp); dlPtr = FindDLine(textPtr, dlPtr, &tmp); } if (dlPtr == NULL) { @@ -5038,7 +5019,7 @@ TkTextRelayoutWindow( * could change the way lines wrap. */ - if (textPtr->topIndex.byteIndex != 0) { + if (!IsStartOfNotMergedLine(textPtr, &textPtr->topIndex)) { TkTextFindDisplayLineEnd(textPtr, &textPtr->topIndex, 0, NULL); } @@ -5151,7 +5132,9 @@ TkTextSetYView( */ textPtr->topIndex = *indexPtr; - TkTextFindDisplayLineEnd(textPtr, &textPtr->topIndex, 0, NULL); + if (!IsStartOfNotMergedLine(textPtr, indexPtr)) { + TkTextFindDisplayLineEnd(textPtr, &textPtr->topIndex, 0, NULL); + } dInfoPtr->newTopPixelOffset = pickPlace; goto scheduleUpdate; } @@ -6287,7 +6270,6 @@ GetYPixelCount( * index. */ { TkTextLine *linePtr = dlPtr->index.linePtr; - TkTextIndex tmpIndex = dlPtr->index; int count; /* @@ -6303,9 +6285,7 @@ GetYPixelCount( * line, we can return right away. */ - TkTextIndexBackBytes(textPtr, &tmpIndex, 1, &tmpIndex); - if ((dlPtr->index.byteIndex == 0) - && !TkTextIsElided(textPtr, &tmpIndex, NULL)) { + if (IsStartOfNotMergedLine(textPtr, &dlPtr->index)) { return count; } @@ -6645,6 +6625,56 @@ FindDLine( /* *---------------------------------------------------------------------- * + * IsStartOfNotMergedLine -- + * + * This function checks whether the given index is the start of a + * logical line that is not merged with the previous logical line + * (due to elision of the eol of the previous line). + * + * Results: + * Returns whether the given index denotes the first index of a +* logical line not merged with its previous line. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +static int +IsStartOfNotMergedLine( + TkText *textPtr, /* Widget record for text widget. */ + CONST TkTextIndex *indexPtr) /* Index to check. */ +{ + TkTextIndex indexPtr2; + + if (indexPtr->byteIndex != 0) { + /* + * Not the start of a logical line. + */ + return 0; + } + + if (TkTextIndexBackBytes(textPtr, indexPtr, 1, &indexPtr2)) { + /* + * indexPtr is the first index of the text widget. + */ + return 1; + } + + if (!TkTextIsElided(textPtr, &indexPtr2, NULL)) { + /* + * The eol of the line just before indexPtr is elided. + */ + return 1; + } + + return 0; +} + +/* + *---------------------------------------------------------------------- + * * TkTextPixelIndex -- * * Given an (x,y) coordinate on the screen, find the location of the -- cgit v0.12 From 5a1150dd51bd8b6c5819c041e607057296c42619 Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Fri, 2 Jan 2015 14:29:46 +0000 Subject: Reverted [13d2fcd25d] and [8dfc0f1731] since they are no longer needed thanks to [8d7a4443f7]. --- tests/textWind.test | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tests/textWind.test b/tests/textWind.test index 537076f..79dca50 100644 --- a/tests/textWind.test +++ b/tests/textWind.test @@ -444,7 +444,6 @@ test textWind-10.4 {EmbWinLayoutProc procedure, error in creating window} {textf .t delete 1.0 end .t insert 1.0 "Some sample text" catch {destroy .t.f} - update set msg {} after idle { .t window create 1.5 -create { @@ -462,7 +461,6 @@ test textWind-10.4.1 {EmbWinLayoutProc procedure, error in creating window} {tex .t delete 1.0 end .t insert 1.0 "Some sample text" catch {destroy .t.f} - update .t window create 1.5 -create { frame .t.f frame .t.f.f -width 10 -height 20 -bg $color @@ -475,7 +473,6 @@ catch {destroy .t.f} test textWind-10.5 {EmbWinLayoutProc procedure, error in creating window} {textfonts} { .t delete 1.0 end .t insert 1.0 "Some sample text" - update .t window create 1.5 -create { concat .t } @@ -487,7 +484,6 @@ test textWind-10.6 {EmbWinLayoutProc procedure, error in creating window} {textf .t delete 1.0 end .t insert 1.0 "Some sample text" catch {destroy .t2} - update .t window create 1.5 -create { toplevel .t2 -width 100 -height 150 wm geom .t2 +0+0 @@ -501,7 +497,6 @@ test textWind-10.6.1 {EmbWinLayoutProc procedure, error in creating window} { .t delete 1.0 end .t insert 1.0 "Some sample text" catch {destroy .t2} - update .t window create 1.5 -create { toplevel .t2 -width 100 -height 150 wm geom .t2 +0+0 @@ -600,8 +595,6 @@ test textWind-11.2 {EmbWinDisplayProc procedure, geometry transforms} { .t insert 1.0 "Some sample text" pack forget .t place .t -x 30 -y 50 - catch {destroy .t.f} - update frame .t.f -width 30 -height 20 -bg $color .t window create 1.12 -window .t.f update -- cgit v0.12 From 15901359c66507fe9c9a5e1c353a33fd1d4004ad Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Mon, 12 Jan 2015 21:50:14 +0000 Subject: Fixed typo in comment --- generic/tkTextDisp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 6cf78fb..dbed9c8 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -3544,8 +3544,8 @@ CalculateDisplayLineHeight( * failure of a test suite test, that checks that lines are rendered * exactly once. TkTextFindDisplayLineEnd is used here for checking * indexPtr but it calls LayoutDLine/FreeDLine which makes the - * counting wrong. The debug mode shall threfore be switched off when - * calling TkTextFindDisplayLineEnd. + * counting wrong. The debug mode shall therefore be switched off + * when calling TkTextFindDisplayLineEnd. */ TkTextIndex indexPtr2 = *indexPtr; -- cgit v0.12 From f816244547589106633225aeb07f4b71b01749b5 Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Fri, 16 Jan 2015 20:59:06 +0000 Subject: More accurate comment --- generic/tkTextDisp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index bddfa0e..be3c7d9 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -3646,7 +3646,7 @@ TkTextIndexYPixels( /* * Shortcut to avoid layout of a superfluous display line. We know there * is nothing more to add up to the height if the index we were given was - * already the start of a logical line. + * already on the first display line of a logical line. */ if (alreadyStartOfLine) { -- cgit v0.12 From c320b51ca710d690037560ed5a0b53211e06ec53 Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Fri, 16 Jan 2015 22:07:54 +0000 Subject: Factorized the code a bit more, making use of function IsStartOfNotMergedLine. Also, tried to better explain in comments. --- generic/tkTextDisp.c | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index be3c7d9..a6ab13c 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -5418,21 +5418,21 @@ MeasureUp( for (dlPtr = lowestPtr; dlPtr != NULL; dlPtr = dlPtr->nextPtr) { distance -= dlPtr->height; if (distance <= 0) { - TkTextIndex tmpIndex = dlPtr->index; *dstPtr = dlPtr->index; /* - * Adjust index to the start of the display line. This is - * needed because the start of a logical line is not always - * the start of a display line (this is however true if the - * eol is not elided). + * dstPtr is the start of a display line that is or is not + * the start of a logical line. If it is the start of a + * logical line, we must check whether this line is merged + * with the previous logical line, and if so we must adjust + * dstPtr to the start of the display line since a display + * line start needs to be returned. */ - - TkTextIndexBackBytes(textPtr, &tmpIndex, 1, &tmpIndex); - if (TkTextIsElided(textPtr, &tmpIndex, NULL)) { + if (!IsStartOfNotMergedLine(textPtr, dstPtr)) { TkTextFindDisplayLineEnd(textPtr, dstPtr, 0, NULL); } - if (overlap != NULL) { + + if (overlap != NULL) { *overlap = -distance; } break; @@ -5823,22 +5823,26 @@ YScrollByLines( for (dlPtr = lowestPtr; dlPtr != NULL; dlPtr = dlPtr->nextPtr) { offset++; if (offset == 0) { - TkTextIndex tmpIndex = dlPtr->index; textPtr->topIndex = dlPtr->index; /* - * Adjust index to the start of the display line. This is - * needed because the start of a logical line is not - * always the start of a display line (this is however - * true if the eol is not elided). + * topIndex is the start of a logical line. However, if + * the eol of the previous logical line is elided, then + * topIndex may be elsewhere than the first character of + * a display line, which is unwanted. Adjust to the start + * of the display line, if needed. + * topIndex is the start of a display line that is or is + * not the start of a logical line. If it is the start of + * a logical line, we must check whether this line is + * merged with the previous logical line, and if so we + * must adjust topIndex to the start of the display line. */ - - TkTextIndexBackBytes(textPtr, &tmpIndex, 1, &tmpIndex); - if (TkTextIsElided(textPtr, &tmpIndex, NULL)) { - TkTextFindDisplayLineEnd(textPtr, &textPtr->topIndex, 0, - NULL); + if (!IsStartOfNotMergedLine(textPtr, &textPtr->topIndex)) { + TkTextFindDisplayLineEnd(textPtr, &textPtr->topIndex, + 0, NULL); } - break; + + break; } } -- cgit v0.12 From ea43a59d78e134c9e2fcf6bc8c47337bbc28b5e5 Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Sat, 24 Jan 2015 14:58:03 +0000 Subject: TkTextIndexCount is counting chars. Fix these calls where bytes counting is needed. Among other issues, this fixes horizontal scrolling when typing text at the end of a line containing multi-byte characters. --- generic/tkText.h | 3 ++ generic/tkTextDisp.c | 10 +++--- generic/tkTextIndex.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/textDisp.test | 23 ++++++++++++++ 4 files changed, 117 insertions(+), 6 deletions(-) diff --git a/generic/tkText.h b/generic/tkText.h index 4ffdc8a..6f5f153 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -1071,6 +1071,9 @@ MODULE_SCOPE void TkTextIndexBackChars(const TkText *textPtr, TkTextIndex *dstPtr, TkTextCountType type); MODULE_SCOPE int TkTextIndexCmp(const TkTextIndex *index1Ptr, const TkTextIndex *index2Ptr); +MODULE_SCOPE int TkTextIndexCountBytes(const TkText *textPtr, + const TkTextIndex *index1Ptr, + const TkTextIndex *index2Ptr); MODULE_SCOPE int TkTextIndexCount(const TkText *textPtr, const TkTextIndex *index1Ptr, const TkTextIndex *index2Ptr, diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index a6ab13c..34202bd 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -3465,8 +3465,8 @@ TkTextFindDisplayLineEnd( */ *xOffset = DlineXOfIndex(textPtr, dlPtr, - TkTextIndexCount(textPtr, &dlPtr->index, indexPtr, - COUNT_INDICES)); + TkTextIndexCountBytes(textPtr, &dlPtr->index, + indexPtr)); } if (end) { /* @@ -5549,8 +5549,7 @@ TkTextSeeCmd( * they are elided. */ - byteCount = TkTextIndexCount(textPtr, &dlPtr->index, &index, - COUNT_INDICES); + byteCount = TkTextIndexCountBytes(textPtr, &dlPtr->index, &index); for (chunkPtr = dlPtr->chunkPtr; chunkPtr != NULL ; chunkPtr = chunkPtr->nextPtr) { if (byteCount < chunkPtr->numBytes) { @@ -7078,8 +7077,7 @@ TkTextIndexBbox( * they are elided. */ - byteCount = TkTextIndexCount(textPtr, &dlPtr->index, indexPtr, - COUNT_INDICES); + byteCount = TkTextIndexCountBytes(textPtr, &dlPtr->index, indexPtr); for (chunkPtr = dlPtr->chunkPtr; ; chunkPtr = chunkPtr->nextPtr) { if (chunkPtr == NULL) { return -1; diff --git a/generic/tkTextIndex.c b/generic/tkTextIndex.c index 70c94db..25b4666 100644 --- a/generic/tkTextIndex.c +++ b/generic/tkTextIndex.c @@ -40,6 +40,9 @@ static CONST char * StartEnd(TkText *textPtr, CONST char *string, static int GetIndex(Tcl_Interp *interp, TkSharedText *sharedPtr, TkText *textPtr, CONST char *string, TkTextIndex *indexPtr, int *canCachePtr); +static int IndexCountBytesOrdered(CONST TkText *textPtr, + CONST TkTextIndex *indexPtr1, + CONST TkTextIndex *indexPtr2); /* * The "textindex" Tcl_Obj definition: @@ -1628,6 +1631,90 @@ TkTextIndexForwChars( /* *--------------------------------------------------------------------------- * + * TkTextIndexCountBytes -- + * + * Given a pair of indices in a text widget, this function counts how + * many bytes are between the two indices. The two indices do not need + * to be ordered. + * + * Results: + * The number of bytes in the given range. + * + * Side effects: + * None. + * + *--------------------------------------------------------------------------- + */ + +int +TkTextIndexCountBytes( + CONST TkText *textPtr, + CONST TkTextIndex *indexPtr1, /* Index describing one location. */ + CONST TkTextIndex *indexPtr2) /* Index describing second location. */ +{ + int compare = TkTextIndexCmp(indexPtr1, indexPtr2); + + if (compare == 0) { + return 0; + } else if (compare > 0) { + return IndexCountBytesOrdered(textPtr, indexPtr2, indexPtr1); + } else { + return IndexCountBytesOrdered(textPtr, indexPtr1, indexPtr2); + } +} + +static int +IndexCountBytesOrdered( + CONST TkText *textPtr, + CONST TkTextIndex *indexPtr1, + /* Index describing location of character from + * which to count. */ + CONST TkTextIndex *indexPtr2) + /* Index describing location of last character + * at which to stop the count. */ +{ + int byteCount, offset; + TkTextSegment *segPtr, *segPtr1; + TkTextLine *linePtr; + + if (indexPtr1->linePtr == indexPtr2->linePtr) { + return indexPtr2->byteIndex - indexPtr1->byteIndex; + } + + /* + * indexPtr2 is on a line strictly after the line containing indexPtr1. + * Add up: + * bytes between indexPtr1 and end of its line + * bytes in lines strictly between indexPtr1 and indexPtr2 + * bytes between start of the indexPtr2 line and indexPtr2 + */ + + segPtr1 = TkTextIndexToSeg(indexPtr1, &offset); + byteCount = -offset; + for (segPtr = segPtr1; segPtr != NULL; segPtr = segPtr->nextPtr) { + byteCount += segPtr->size; + } + + linePtr = indexPtr1->linePtr->nextPtr; + while (linePtr != indexPtr2->linePtr) { + for (segPtr = linePtr->segPtr; segPtr != NULL; + segPtr = segPtr->nextPtr) { + byteCount += segPtr->size; + } + linePtr = TkBTreeNextLine(textPtr, linePtr); + if (linePtr == NULL) { + Tcl_Panic("TextIndexCountBytesOrdered ran out of lines"); + } + } + + byteCount += indexPtr2->byteIndex; + + return byteCount; +} + +/* + *--------------------------------------------------------------------------- + * * TkTextIndexCount -- * * Given an ordered pair of indices in a text widget, this function diff --git a/tests/textDisp.test b/tests/textDisp.test index 1f85117..44a45b2 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -1664,6 +1664,29 @@ test textDisp-13.10 {TkTextSeeCmd procedure} {} { destroy $w set res } {} +test textDisp-13.11 {TkTextSeeCmd procedure} {} { + # insertion of a character at end of a line containing multi-byte + # characters and calling see at the line end shall actually show + # this character + toplevel .top2 + pack [text .top2.t2 -wrap none] + for {set i 1} {$i < 5} {incr i} { + .top2.t2 insert end [string repeat "Line $i: éèàçù" 5]\n + + } + wm geometry .top2 300x200+0+0 + update + .top2.t2 see "1.0 lineend" + update + set ref [.top2.t2 index @0,0] + .top2.t2 insert "1.0 lineend" ç + .top2.t2 see "1.0 lineend" + update + set new [.top2.t2 index @0,0] + set res [.top2.t2 compare $ref == $new] + destroy .top2 + set res +} {0} wm geom . {} .t configure -wrap none -- cgit v0.12 From 3d08dbf0c9d80d384d1a8bd1f8a4d351e98f48df Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Sun, 25 Jan 2015 13:55:34 +0000 Subject: Fixed disappearing cursor when moving up one line at the boundary of elided lines. Factorized the code again in the process, using function IsStartOfNotMergedLine when possible. --- generic/tkTextDisp.c | 14 +++++--------- tests/textDisp.test | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 34202bd..e21b76b 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -4668,12 +4668,11 @@ TextChanged( */ rounded = *index1Ptr; - do { - rounded.byteIndex = 0; + rounded.byteIndex = 0; + notBegin = 0; + while (!IsStartOfNotMergedLine(textPtr, &rounded) && notBegin) { notBegin = !TkTextIndexBackBytes(textPtr, &rounded, 1, &rounded); - } while (TkTextIsElided(textPtr, &rounded, NULL) && notBegin); - if (notBegin) { - TkTextIndexForwBytes(textPtr, &rounded, 1, &rounded); + rounded.byteIndex = 0; } /* @@ -4703,14 +4702,11 @@ TextChanged( } rounded.linePtr = linePtr; rounded.byteIndex = 0; - TkTextIndexBackBytes(textPtr, &rounded, 1, &rounded); - } while (TkTextIsElided(textPtr, &rounded, NULL)); + } while (!IsStartOfNotMergedLine(textPtr, &rounded)); if (linePtr == NULL) { lastPtr = NULL; } else { - TkTextIndexForwBytes(textPtr, &rounded, 1, &rounded); - /* * 'rounded' now points to the start of a display line as well as the * start of a logical line not merged with its previous line, and diff --git a/tests/textDisp.test b/tests/textDisp.test index 44a45b2..12a20c6 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -1152,6 +1152,41 @@ test textDisp-8.11 {TkTextChanged, scrollbar notification when changes are off-s .t configure -yscrollcommand "" set scrollInfo } {0.0 0.625} +test textDisp-8.12 {TkTextChanged, moving the insert cursor redraws only past and new lines} { + .t delete 1.0 end + .t configure -wrap none + for {set i 1} {$i < 25} {incr i} { + .t insert end "Line $i Line $i\n" + } + .t tag add hidden 5.0 8.0 + .t tag configure hidden -elide true + .t mark set insert 9.0 + update + .t mark set insert 8.0 ; # up one line + update + set res [list $tk_textRedraw] + .t mark set insert 12.2 ; # in the visible text + update + lappend res $tk_textRedraw + .t mark set insert 6.5 ; # in the hidden text + update + lappend res $tk_textRedraw + .t mark set insert 3.5 ; # in the visible text again + update + lappend res $tk_textRedraw + .t mark set insert 3.8 ; # within the same line + update + lappend res $tk_textRedraw + # This last one is tricky: correct result really is {2.0 3.0} when + # calling .t mark set insert, two calls to TkTextChanged are done: + # (a) to redraw the line of the past position of the cursor + # (b) to redraw the line of the new position of the cursor + # During (a) the display line showing the cursor gets unlinked, + # which leads TkTextChanged in (b) to schedule a redraw starting + # one line _before_ the line containing the insert cursor. This is + # because during (b) findDLine cannot return the display line the + # cursor is in since this display line was just unlinked in (a). +} {{8.0 9.0} {8.0 12.0} {8.0 12.0} {3.0 8.0} {2.0 3.0}} test textDisp-9.1 {TkTextRedrawTag} { .t configure -wrap char -- cgit v0.12 From d8ec6a3f99994eafd5d2cc198b5028cd8392cdba Mon Sep 17 00:00:00 2001 From: "dgp@users.sourceforge.net" Date: Thu, 5 Feb 2015 20:11:30 +0000 Subject: [d186605d05] Stop invalid read beyond objv. --- generic/tkFont.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tkFont.c b/generic/tkFont.c index 9eaaf94..5d2ad43 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -3015,7 +3015,6 @@ ConfigAttributesObj( for (i = 0; i < objc; i += 2) { optionPtr = objv[i]; - valuePtr = objv[i + 1]; if (Tcl_GetIndexFromObj(interp, optionPtr, fontOpt, "option", 1, &index) != TCL_OK) { @@ -3034,6 +3033,7 @@ ConfigAttributesObj( } return TCL_ERROR; } + valuePtr = objv[i + 1]; switch (index) { case FONT_FAMILY: -- cgit v0.12 From b650a1e2196f0dcc5e19604d2911b5f12081b1b3 Mon Sep 17 00:00:00 2001 From: "dgp@users.sourceforge.net" Date: Fri, 6 Feb 2015 14:09:24 +0000 Subject: [a6c2807c13] Don't let forgotten slave trick us into layout computations outside the layout grid. --- generic/tkGrid.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generic/tkGrid.c b/generic/tkGrid.c index c6a00d5..ccdde19 100644 --- a/generic/tkGrid.c +++ b/generic/tkGrid.c @@ -1991,7 +1991,7 @@ ResolveConstraints( if (slavePtr->numCols > 1) { slavePtr->binNextPtr = layoutPtr[rightEdge].binNextPtr; layoutPtr[rightEdge].binNextPtr = slavePtr; - } else { + } else if (rightEdge >= 0) { int size = slavePtr->size + layoutPtr[rightEdge].pad; if (size > layoutPtr[rightEdge].minSize) { @@ -2010,7 +2010,7 @@ ResolveConstraints( if (slavePtr->numRows > 1) { slavePtr->binNextPtr = layoutPtr[rightEdge].binNextPtr; layoutPtr[rightEdge].binNextPtr = slavePtr; - } else { + } else if (rightEdge >= 0) { int size = slavePtr->size + layoutPtr[rightEdge].pad; if (size > layoutPtr[rightEdge].minSize) { -- cgit v0.12 From 130eb9d897b55374d4f2175ed3a029cc11b55885 Mon Sep 17 00:00:00 2001 From: "dgp@users.sourceforge.net" Date: Fri, 6 Feb 2015 15:44:23 +0000 Subject: [2b6778efe8] handle sscanf() EOF errors. --- generic/tkEntry.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generic/tkEntry.c b/generic/tkEntry.c index 816b7fa..6683cdc 100644 --- a/generic/tkEntry.c +++ b/generic/tkEntry.c @@ -1330,7 +1330,7 @@ ConfigureEntry( double dvalue; - if (sscanf(entryPtr->string, "%lf", &dvalue) == 0) { + if (sscanf(entryPtr->string, "%lf", &dvalue) <= 0) { /* Scan failure */ dvalue = sbPtr->fromValue; } else { @@ -4231,7 +4231,7 @@ SpinboxInvoke( } else if (!DOUBLES_EQ(sbPtr->fromValue, sbPtr->toValue)) { double dvalue; - if (sscanf(entryPtr->string, "%lf", &dvalue) == 0) { + if (sscanf(entryPtr->string, "%lf", &dvalue) <= 0) { /* * If the string doesn't scan as a double value, just * use the -from value -- cgit v0.12 From e71be7e6e688fbbc02bd57284cc5109a8000dc0d Mon Sep 17 00:00:00 2001 From: "dgp@users.sourceforge.net" Date: Fri, 6 Feb 2015 16:03:10 +0000 Subject: [c9535cd7ce] GetIndex() failed to route all successful exits through code that writes a result through the canCachePtr. --- generic/tkTextIndex.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generic/tkTextIndex.c b/generic/tkTextIndex.c index 70c94db..1b9d2a5 100644 --- a/generic/tkTextIndex.c +++ b/generic/tkTextIndex.c @@ -771,11 +771,11 @@ GetIndex( } if (TkTextWindowIndex(textPtr, string, indexPtr) != 0) { - return TCL_OK; + goto done; } if (TkTextImageIndex(textPtr, string, indexPtr) != 0) { - return TCL_OK; + goto done; } /* -- cgit v0.12 From 0176bc533c3d3e892cbf86633fb08089f14f4e41 Mon Sep 17 00:00:00 2001 From: Joe Mistachkin Date: Fri, 6 Feb 2015 21:46:44 +0000 Subject: Modify bind tests for '%M' to save/restore the 'Key' bindings for both 'All' and 'Entry'. Fix for [6b13bf5ebf]. --- tests/bind.test | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/tests/bind.test b/tests/bind.test index de9da70..3abb615 100644 --- a/tests/bind.test +++ b/tests/bind.test @@ -1573,24 +1573,42 @@ test bind-16.44 {ExpandPercents procedure} { event gen .b.f set x } {?? ??} -test bind-16.45 {ExpandPercents procedure} { +test bind-16.45 {ExpandPercents procedure} -setup { + set savedBind(Entry) [bind Entry ] + set savedBind(All) [bind all ] + setup2 + bind .b.e {set x "%M"} bind Entry {set y "%M"} bind all {set z "%M"} +} -body { set x none; set y none; set z none event gen .b.e list $x $y $z -} {0 1 2} -test bind-16.46 {ExpandPercents procedure} { +} -cleanup { + bind all $savedBind(All) + bind Entry $savedBind(Entry) + unset savedBind +} -result {0 1 2} +test bind-16.46 {ExpandPercents procedure} -setup { + set savedBind(Entry) [bind Entry ] + set savedBind(All) [bind all ] + setup2 + bind all {set z "%M"} bind Entry {set y "%M"} bind .b.e {set x "%M"} +} -body { set x none; set y none; set z none event gen .b.e list $x $y $z -} {0 1 2} +} -cleanup { + bind Entry $savedBind(Entry) + bind all $savedBind(All) + unset savedBind +} -result {0 1 2} test bind-17.1 {event command} { -- cgit v0.12 From a967db77036ccc04ba6a7fd72b2fd035b06358de Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Sun, 8 Feb 2015 19:11:43 +0000 Subject: Stop panic (Bad tag priority being toggled on) - Bug [382da038c9] --- generic/tkTextBTree.c | 14 -------------- tests/textBTree.test | 10 ++++++++++ 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/generic/tkTextBTree.c b/generic/tkTextBTree.c index 92164fc..36f0ef3 100644 --- a/generic/tkTextBTree.c +++ b/generic/tkTextBTree.c @@ -3615,20 +3615,6 @@ TkTextIsElided( infoPtr->elidePriority = -1; for (i = infoPtr->numTags-1; i >=0; i--) { if (infoPtr->tagCnts[i] & 1) { - /* - * Who would make the selection elided? - */ - - if ((tagPtr == textPtr->selTagPtr) - && !(textPtr->flags & GOT_FOCUS) - && (textPtr->inactiveSelBorder == NULL -#ifdef MAC_OSX_TK - /* Don't show inactive selection in disabled widgets. */ - || textPtr->state == TK_TEXT_STATE_DISABLED -#endif - )) { - continue; - } infoPtr->elide = infoPtr->tagPtrs[i]->elide; /* diff --git a/tests/textBTree.test b/tests/textBTree.test index 3a89e55..1eb7c75 100644 --- a/tests/textBTree.test +++ b/tests/textBTree.test @@ -664,6 +664,16 @@ test btree-14.1 {check tag presence} { .t tag add x 141.3 .t tag names 141.1 } {x y z} +test btree-14.2 {TkTextIsElided} { + .t delete 1.0 end + .t tag config hidden -elide 1 + .t insert end "Line1\nLine2\nLine3\n" + .t tag add hidden 2.0 3.0 + .t tag add sel 1.2 3.2 + # next line used to panic because of "Bad tag priority being toggled on" + # (see bug [382da038c9]) + .t index "2.0 - 1 display line linestart" +} {1.0} test btree-15.1 {rebalance with empty node} { catch {destroy .t} -- cgit v0.12 From ffbd43a5c4412a2ed41584afc389aaf9b512be01 Mon Sep 17 00:00:00 2001 From: "fvogelnew1@free.fr" Date: Mon, 9 Feb 2015 22:26:26 +0000 Subject: Fixed crash in 'text see' - Bug [e0f1c380bd] --- generic/tkTextDisp.c | 43 +++++++++++++++++++++++-------------------- tests/textDisp.test | 12 ++++++++++++ 2 files changed, 35 insertions(+), 20 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 49a35f5..f718e2a 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -5546,32 +5546,35 @@ TkTextSeeCmd( /* * Call a chunk-specific function to find the horizontal range of the - * character within the chunk. + * character within the chunk. chunkPtr is NULL if trying to see in elided + * region. */ - (*chunkPtr->bboxProc)(textPtr, chunkPtr, byteCount, - dlPtr->y + dlPtr->spaceAbove, - dlPtr->height - dlPtr->spaceAbove - dlPtr->spaceBelow, - dlPtr->baseline - dlPtr->spaceAbove, &x, &y, &width, - &height); - delta = x - dInfoPtr->curXPixelOffset; - oneThird = lineWidth/3; - if (delta < 0) { - if (delta < -oneThird) { - dInfoPtr->newXPixelOffset = (x - lineWidth/2); - } else { - dInfoPtr->newXPixelOffset -= ((-delta) ); - } - } else { - delta -= (lineWidth - width); - if (delta > 0) { - if (delta > oneThird) { + if (chunkPtr != NULL) { + (*chunkPtr->bboxProc)(textPtr, chunkPtr, byteCount, + dlPtr->y + dlPtr->spaceAbove, + dlPtr->height - dlPtr->spaceAbove - dlPtr->spaceBelow, + dlPtr->baseline - dlPtr->spaceAbove, &x, &y, &width, + &height); + delta = x - dInfoPtr->curXPixelOffset; + oneThird = lineWidth/3; + if (delta < 0) { + if (delta < -oneThird) { dInfoPtr->newXPixelOffset = (x - lineWidth/2); } else { - dInfoPtr->newXPixelOffset += (delta ); + dInfoPtr->newXPixelOffset -= ((-delta) ); } } else { - return TCL_OK; + delta -= (lineWidth - width); + if (delta > 0) { + if (delta > oneThird) { + dInfoPtr->newXPixelOffset = (x - lineWidth/2); + } else { + dInfoPtr->newXPixelOffset += (delta ); + } + } else { + return TCL_OK; + } } } dInfoPtr->flags |= DINFO_OUT_OF_DATE; diff --git a/tests/textDisp.test b/tests/textDisp.test index 12a20c6..aed842c 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -1558,6 +1558,18 @@ test textDisp-11.19 {TkTextSetYView, see in elided lines} { set ind3 [.top.t index @0,0] list [expr {$ind1 == $ind2}] [expr {$ind1 == $ind3}] } {1 1} +test textDisp-11.20 {TkTextSetYView, see in elided lines} { + .top.t delete 1.0 end + .top.t configure -wrap none + for {set i 1} {$i < 5} {incr i} { + .top.t insert end [string repeat "Line $i " 50] + .top.t insert end "\n" + } + .top.t delete 3.11 3.14 + .top.t tag add hidden 3.0 4.0 + # this shall not crash (null chunkPtr in TkTextSeeCmd is tested) + .top.t see 3.0 +} {} .t configure -wrap word .t delete 50.0 51.0 -- cgit v0.12 From 1ca91e30ef275f81665856aa8f72c62143f78629 Mon Sep 17 00:00:00 2001 From: "dgp@users.sourceforge.net" Date: Tue, 10 Feb 2015 20:21:27 +0000 Subject: Restore build of backported scrollbar work. --- macosx/tkMacOSXScrlbr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index d591436..a9d8469 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.c @@ -43,7 +43,7 @@ typedef struct MacScrollbar { * variable is declared at this scope. */ -const Tk_ClassProcs tkpScrollbarProcs = { +Tk_ClassProcs tkpScrollbarProcs = { sizeof(Tk_ClassProcs), /* size */ NULL, /* worldChangedProc */ NULL, /* createProc */ -- cgit v0.12 From 427dae5aef4a039b921374d7d1877093104b494a Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Wed, 11 Feb 2015 01:56:44 +0000 Subject: Adjust metrics in buttons to remove extraneous padding in Cocoa checkbuttons with images --- macosx/tkMacOSXButton.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c index fbad20d..40780a6 100644 --- a/macosx/tkMacOSXButton.c +++ b/macosx/tkMacOSXButton.c @@ -305,7 +305,7 @@ TkpComputeButtonGeometry( break; case TYPE_CHECK_BUTTON: width = butPtr->width; - width += 50; + width +=0; break; case TYPE_BUTTON: width = butPtr->width; -- cgit v0.12 From d3b1b883ccd3c7abc191e9dab88d28f18c33cf2d Mon Sep 17 00:00:00 2001 From: "dgp@users.sourceforge.net" Date: Wed, 11 Feb 2015 13:40:01 +0000 Subject: [6286e04179] Backport [5f8258ad2a] to stop `make test` segfaults. --- generic/tkTextDisp.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index f718e2a..8cd5a9a 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -3938,8 +3938,17 @@ RedisplayText( { register TkText *textPtr = (TkText *) clientData; TextDInfo *dInfoPtr = textPtr->dInfoPtr; - TkRegion damageRegion = TkCreateRegion(); - XRectangle rectangle = {0, 0, dInfoPtr->maxX, dInfoPtr->maxY}; + TkRegion damageRegion; + XRectangle rectangle; + + if (dInfoPtr == NULL) { + return; + } + damageRegion = TkCreateRegion(); + rectangle.x = 0; + rectangle.y = 0; + rectangle.width = dInfoPtr->maxX; + rectangle.height = dInfoPtr->maxY; TkUnionRectWithRegion(&rectangle, damageRegion, damageRegion); TextInvalidateRegion(textPtr, damageRegion); -- cgit v0.12 From 6e42628f844addeeb932ba390e5a916ceb83d3ab Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Thu, 12 Feb 2015 01:38:03 +0000 Subject: Further refinement of checkbutton metrics in Cocoa --- macosx/tkMacOSXButton.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c index 40780a6..5cdfb3c 100644 --- a/macosx/tkMacOSXButton.c +++ b/macosx/tkMacOSXButton.c @@ -305,7 +305,7 @@ TkpComputeButtonGeometry( break; case TYPE_CHECK_BUTTON: width = butPtr->width; - width +=0; + width +=50; break; case TYPE_BUTTON: width = butPtr->width; -- cgit v0.12 From 23b861da7c42b883907d12454de19573dd0fbcf8 Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Thu, 12 Feb 2015 01:56:47 +0000 Subject: Further refinement of button metrics in Cocoa --- macosx/tkMacOSXButton.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c index 5cdfb3c..117d77c 100644 --- a/macosx/tkMacOSXButton.c +++ b/macosx/tkMacOSXButton.c @@ -309,7 +309,7 @@ TkpComputeButtonGeometry( break; case TYPE_BUTTON: width = butPtr->width; - width += 0; + width += 30; break; } } -- cgit v0.12 From 0bd6214e40d7c07c67d102b3134a7e5eca358111 Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Thu, 12 Feb 2015 02:52:59 +0000 Subject: Further refinement of button metrics in Cocoa --- macosx/tkMacOSXButton.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c index 117d77c..5cdfb3c 100644 --- a/macosx/tkMacOSXButton.c +++ b/macosx/tkMacOSXButton.c @@ -309,7 +309,7 @@ TkpComputeButtonGeometry( break; case TYPE_BUTTON: width = butPtr->width; - width += 30; + width += 0; break; } } -- cgit v0.12 From d92a8d3e309eb91ffc4cc9d1bde68a65bacbf05e Mon Sep 17 00:00:00 2001 From: "dgp@users.sourceforge.net" Date: Thu, 12 Feb 2015 12:51:10 +0000 Subject: Silence some compiler warnings --- generic/tkBitmap.c | 2 +- generic/tkInt.decls | 3 +++ generic/tkIntDecls.h | 14 +++++++++++--- generic/tkStubInit.c | 2 +- generic/tkTextDisp.c | 2 +- generic/ttk/ttkLabel.c | 2 ++ macosx/tkMacOSXButton.c | 3 --- macosx/tkMacOSXDraw.c | 1 - macosx/tkMacOSXEmbed.c | 2 +- macosx/tkMacOSXKeyEvent.c | 8 +++++--- macosx/tkMacOSXMenubutton.c | 4 ---- macosx/tkMacOSXScrlbr.c | 11 ++++------- macosx/tkMacOSXWm.c | 5 ++--- unix/tkUnixButton.c | 2 +- 14 files changed, 32 insertions(+), 29 deletions(-) diff --git a/generic/tkBitmap.c b/generic/tkBitmap.c index 09545d6..f7df546 100644 --- a/generic/tkBitmap.c +++ b/generic/tkBitmap.c @@ -304,7 +304,7 @@ GetBitmap( TkBitmap *bitmapPtr, *existingBitmapPtr; TkPredefBitmap *predefPtr; Pixmap bitmap; - int isNew, width, height, dummy2; + int isNew, width = 0, height = 0, dummy2; TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); diff --git a/generic/tkInt.decls b/generic/tkInt.decls index 17f39ba..4cbdb60 100644 --- a/generic/tkInt.decls +++ b/generic/tkInt.decls @@ -568,6 +568,9 @@ declare 180 { char *TkSmoothPrintProc(ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr) } +declare 181 { + int TkpScanWindowId(Tcl_Interp *interp, const char *string, Window *idPtr) +} declare 184 { void TkUnusedStubEntry(void) } diff --git a/generic/tkIntDecls.h b/generic/tkIntDecls.h index 9dea8d4..b31bbd4 100644 --- a/generic/tkIntDecls.h +++ b/generic/tkIntDecls.h @@ -966,7 +966,12 @@ EXTERN char * TkSmoothPrintProc(ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); #endif -/* Slot 181 is reserved */ +#ifndef TkpScanWindowId_TCL_DECLARED +#define TkpScanWindowId_TCL_DECLARED +/* 181 */ +EXTERN int TkpScanWindowId(Tcl_Interp *interp, + CONST char *string, Window *idPtr); +#endif /* Slot 182 is reserved */ /* Slot 183 is reserved */ #ifndef TkUnusedStubEntry_TCL_DECLARED @@ -1187,7 +1192,7 @@ typedef struct TkIntStubs { char * (*tkOrientPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 178 */ int (*tkSmoothParseProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, CONST char *value, char *widgRec, int offset); /* 179 */ char * (*tkSmoothPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 180 */ - VOID *reserved181; + int (*tkpScanWindowId) (Tcl_Interp *interp, CONST char *string, Window *idPtr); /* 181 */ VOID *reserved182; VOID *reserved183; void (*tkUnusedStubEntry) (void); /* 184 */ @@ -1860,7 +1865,10 @@ extern TkIntStubs *tkIntStubsPtr; #define TkSmoothPrintProc \ (tkIntStubsPtr->tkSmoothPrintProc) /* 180 */ #endif -/* Slot 181 is reserved */ +#ifndef TkpScanWindowId +#define TkpScanWindowId \ + (tkIntStubsPtr->tkpScanWindowId) /* 181 */ +#endif /* Slot 182 is reserved */ /* Slot 183 is reserved */ #ifndef TkUnusedStubEntry diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c index 79edc4d..b2e6314 100644 --- a/generic/tkStubInit.c +++ b/generic/tkStubInit.c @@ -478,7 +478,7 @@ TkIntStubs tkIntStubs = { TkOrientPrintProc, /* 178 */ TkSmoothParseProc, /* 179 */ TkSmoothPrintProc, /* 180 */ - NULL, /* 181 */ + TkpScanWindowId, /* 181 */ NULL, /* 182 */ NULL, /* 183 */ TkUnusedStubEntry, /* 184 */ diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 8cd5a9a..3edd5dc 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -6968,7 +6968,7 @@ DlineXOfIndex( * coordinate. */ { register TkTextDispChunk *chunkPtr = dlPtr->chunkPtr; - int x; + int x = 0; if (byteIndex == 0 || chunkPtr == NULL) { return 0; diff --git a/generic/ttk/ttkLabel.c b/generic/ttk/ttkLabel.c index d51388b..1037840 100644 --- a/generic/ttk/ttkLabel.c +++ b/generic/ttk/ttkLabel.c @@ -293,6 +293,7 @@ static void ImageCleanup(ImageElement *image) TtkFreeImageSpec(image->imageSpec); } +#ifndef MAC_OSX_TK /* * StippleOver -- * Draw a stipple over the image area, to make it look "grayed-out" @@ -317,6 +318,7 @@ static void StippleOver( Tk_FreeBitmapFromObj(tkwin, image->stippleObj); } } +#endif static void ImageDraw( ImageElement *image, Tk_Window tkwin,Drawable d,Ttk_Box b,Ttk_State state) diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c index 5cdfb3c..763f544 100644 --- a/macosx/tkMacOSXButton.c +++ b/macosx/tkMacOSXButton.c @@ -471,7 +471,6 @@ TkpComputeButtonGeometry( } /* -/* *---------------------------------------------------------------------- * * DrawButtonImageAndText -- @@ -966,12 +965,10 @@ ButtonContentDrawCB ( { TkButton *butPtr = (TkButton *)ptr; Tk_Window tkwin = butPtr->tkwin; - HIRect * bounds; if (tkwin == NULL || !Tk_IsMapped(tkwin)) { return; } - MacDrawable *macWin = (MacDrawable *) Tk_WindowId(tkwin); /*Overlay Tk elements over button native region: drawing elements within button boundaries/native region causes unpredictable metrics.*/ DrawButtonImageAndText( butPtr); diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 8fe9a95..0b39cb4 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -1477,7 +1477,6 @@ TkScrollWindow( CGRect srcRect, dstRect; HIShapeRef dmgRgn = NULL, extraRgn; NSRect bounds, visRect, scrollSrc, scrollDst; - NSPoint delta = NSMakePoint(dx, dy); int result; if ( view ) { diff --git a/macosx/tkMacOSXEmbed.c b/macosx/tkMacOSXEmbed.c index ef83276..bd7e0a8 100644 --- a/macosx/tkMacOSXEmbed.c +++ b/macosx/tkMacOSXEmbed.c @@ -200,7 +200,7 @@ TkpScanWindowId( Tcl_Obj obj; obj.refCount = 1; - obj.bytes = string; + obj.bytes = (char *) string; /* DANGER?! */ obj.length = strlen(string); obj.typePtr = NULL; diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c index 0cfb663..c9ad9f1 100644 --- a/macosx/tkMacOSXKeyEvent.c +++ b/macosx/tkMacOSXKeyEvent.c @@ -272,8 +272,9 @@ static unsigned isFunctionKey(unsigned int code); NSString *str = [aString respondsToSelector: @selector (string)] ? [aString string] : aString; if (NS_KEYLOG) - NSLog (@"setMarkedText '%@' len =%d range %d from %d", str, [str length], - selRange.length, selRange.location); + NSLog (@"setMarkedText '%@' len =%lu range %lu from %lu", str, + (unsigned long) [str length], (unsigned long) selRange.length, + (unsigned long) selRange.location); if (privateWorkingText != nil) [self deleteWorkingText]; @@ -293,7 +294,8 @@ static unsigned isFunctionKey(unsigned int code); if (privateWorkingText == nil) return; if (NS_KEYLOG) - NSLog(@"deleteWorkingText len = %d\n", [privateWorkingText length]); + NSLog(@"deleteWorkingText len = %lu\n", + (unsigned long)[privateWorkingText length]); [privateWorkingText release]; privateWorkingText = nil; processingCompose = NO; diff --git a/macosx/tkMacOSXMenubutton.c b/macosx/tkMacOSXMenubutton.c index a1c3138..05b553e 100644 --- a/macosx/tkMacOSXMenubutton.c +++ b/macosx/tkMacOSXMenubutton.c @@ -597,10 +597,8 @@ TkMacOSXDrawMenuButton( if (useNewerHITools == 1) { - HIRect hirec; HIRect contHIRec; static HIThemeButtonDrawInfo hiinfo; - Rect contRect; MenuButtonBackgroundDrawCB((MacMenuButton*) mbPtr, 32, true); @@ -694,12 +692,10 @@ MenuButtonContentDrawCB ( { TkMenuButton *butPtr = (TkMenuButton *)ptr; Tk_Window tkwin = butPtr->tkwin; - Rect bounds; if (tkwin == NULL || !Tk_IsMapped(tkwin)) { return; } - MacDrawable *macWin = (MacDrawable *) Tk_WindowId(tkwin); DrawMenuButtonImageAndText( butPtr); } diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index a9d8469..efa0f38 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.c @@ -102,12 +102,10 @@ TkpCreateScrollbar( Tk_Window tkwin) { - static int initialized = 0; - MacScrollbar *scrollPtr = ckalloc(sizeof(MacScrollbar)); + MacScrollbar *scrollPtr = (MacScrollbar *)ckalloc(sizeof(MacScrollbar)); scrollPtr->troughGC = None; scrollPtr->copyGC = None; - TkWindow *winPtr = (TkWindow *)tkwin; Tk_CreateEventHandler(tkwin,ExposureMask|StructureNotifyMask|FocusChangeMask|ButtonPressMask|VisibilityChangeMask, ScrollbarEventProc, scrollPtr); @@ -144,7 +142,6 @@ TkpDisplayScrollbar( return; } - MacScrollbar *macScrollPtr = clientData; TkWindow *winPtr = (TkWindow *) tkwin; MacDrawable *macWin = (MacDrawable *) winPtr->window; TkMacOSXDrawingContext dc; @@ -220,7 +217,7 @@ TkpComputeScrollbarGeometry( * changed. */ { - int width, height, variant, fieldLength; + int variant, fieldLength; if (scrollPtr->highlightWidth < 0) { scrollPtr->highlightWidth = 0; @@ -432,7 +429,7 @@ UpdateControlValues( MacDrawable *macWin = (MacDrawable *) Tk_WindowId(scrollPtr->tkwin); double dViewSize; HIRect contrlRect; - int variant, active; + int variant; short width, height; NSView *view = TkMacOSXDrawableView(macWin); @@ -511,8 +508,8 @@ ScrollbarPress(TkScrollbar *scrollPtr, XEvent *eventPtr) if (eventPtr->type == ButtonPress) { UpdateControlValues(scrollPtr); - return TCL_OK; } + return TCL_OK; } diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index b834766..210fd6f 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -1652,8 +1652,8 @@ WmForgetCmd( MacDrawable *macWin; - Tk_MakeWindowExist(winPtr); - Tk_MakeWindowExist(winPtr->parentPtr); + Tk_MakeWindowExist(frameWin); + Tk_MakeWindowExist((Tk_Window)winPtr->parentPtr); macWin = (MacDrawable *) winPtr->window; @@ -2403,7 +2403,6 @@ WmManageCmd( register Tk_Window frameWin = (Tk_Window)winPtr; register WmInfo *wmPtr = winPtr->wmInfoPtr; - char *oldClass = (char*)Tk_Class(frameWin); if (!Tk_IsTopLevel(frameWin)) { MacDrawable *macWin = (MacDrawable *) winPtr->window; diff --git a/unix/tkUnixButton.c b/unix/tkUnixButton.c index 373f2e3..2101fda 100644 --- a/unix/tkUnixButton.c +++ b/unix/tkUnixButton.c @@ -360,7 +360,7 @@ TkpDisplayButton( * warning. */ int y, relief; Tk_Window tkwin = butPtr->tkwin; - int width, height, fullWidth, fullHeight; + int width = 0, height = 0, fullWidth, fullHeight; int textXOffset, textYOffset; int haveImage = 0, haveText = 0; int offset; /* 1 means this is a button widget, so we -- cgit v0.12 From 1c1b81981040a4e1c56218886077a1b208efedbd Mon Sep 17 00:00:00 2001 From: "dgp@users.sourceforge.net" Date: Thu, 12 Feb 2015 13:19:25 +0000 Subject: Different approach to stubs for the TkpScanWindowId() declaration. Man, what an inflexible maintenance chore this stuff is. --- generic/tkBind.c | 38 +++++++++++++++++++------------------- generic/tkInt.decls | 6 +++--- generic/tkIntDecls.h | 14 +++----------- generic/tkIntPlatDecls.h | 11 +++++++++++ generic/tkStubInit.c | 3 ++- 5 files changed, 38 insertions(+), 34 deletions(-) diff --git a/generic/tkBind.c b/generic/tkBind.c index d7c8c04..c4f8226 100644 --- a/generic/tkBind.c +++ b/generic/tkBind.c @@ -16,9 +16,9 @@ #ifdef __WIN32__ #include "tkWinInt.h" -#endif - -#if !(defined(__WIN32__) || defined(MAC_OSX_TK)) /* UNIX */ +#elif defined(MAC_OSX_TK) +#include "tkMacOSXInt.h" +#else #include "tkUnixInt.h" #endif @@ -156,7 +156,7 @@ typedef struct PatternTableKey { * events as part of the process of converting X events into Tcl commands. */ -typedef struct Pattern { +typedef struct TkPattern { int eventType; /* Type of X event, e.g. ButtonPress. */ int needMods; /* Mask of modifiers that must be present (0 * means no modifiers are required). */ @@ -170,7 +170,7 @@ typedef struct Pattern { * button (0 means any buttons are OK). For * virtual events, specifies the Tk_Uid of the * virtual event name (never 0). */ -} Pattern; +} TkPattern; /* * The following structure defines a pattern sequence, which consists of one @@ -223,7 +223,7 @@ typedef struct PatSeq { * for end of list). Needed to implement * Tk_DeleteAllBindings. In a virtual event * table, always NULL. */ - Pattern pats[1]; /* Array of "numPats" patterns. Only one + TkPattern pats[1]; /* Array of "numPats" patterns. Only one * element is declared here but in actuality * enough space will be allocated for * "numPats" patterns. To match, pats[0] must @@ -685,7 +685,7 @@ static PatSeq * MatchPatterns(TkDisplay *dispPtr, static int NameToWindow(Tcl_Interp *interp, Tk_Window main, Tcl_Obj *objPtr, Tk_Window *tkwinPtr); static int ParseEventDescription(Tcl_Interp *interp, - const char **eventStringPtr, Pattern *patPtr, + const char **eventStringPtr, TkPattern *patPtr, unsigned long *eventMaskPtr); static void DoWarp(ClientData clientData); @@ -1960,7 +1960,7 @@ MatchPatterns( for ( ; psPtr != NULL; psPtr = psPtr->nextSeqPtr) { XEvent *eventPtr = &bindPtr->eventRing[bindPtr->curEvent]; Detail *detailPtr = &bindPtr->detailRing[bindPtr->curEvent]; - Pattern *patPtr = psPtr->pats; + TkPattern *patPtr = psPtr->pats; Window window = eventPtr->xany.window; int patCount, ringCount, flags, state, modMask, i; @@ -2174,7 +2174,7 @@ MatchPatterns( */ if (bestPtr != NULL) { - Pattern *patPtr2; + TkPattern *patPtr2; if (matchPtr->numPats != bestPtr->numPats) { if (bestPtr->numPats > matchPtr->numPats) { @@ -3259,7 +3259,7 @@ HandleEventGenerate( char *name, *windowName; int count, flags, synch, i, number, warp; Tcl_QueuePosition pos; - Pattern pat; + TkPattern pat; Tk_Window tkwin, tkwin2; TkWindow *mainPtr; unsigned long eventMask; @@ -3961,10 +3961,10 @@ FindSequence( unsigned long *maskPtr) /* *maskPtr is filled in with the event types * on which this pattern sequence depends. */ { - Pattern pats[EVENT_BUFFER_SIZE]; + TkPattern pats[EVENT_BUFFER_SIZE]; int numPats, virtualFound; const char *p; - Pattern *patPtr; + TkPattern *patPtr; PatSeq *psPtr; Tcl_HashEntry *hPtr; int flags, count, isNew; @@ -4044,7 +4044,7 @@ FindSequence( key.type = patPtr->eventType; key.detail = patPtr->detail; hPtr = Tcl_CreateHashEntry(patternTablePtr, (char *) &key, &isNew); - sequenceSize = numPats*sizeof(Pattern); + sequenceSize = numPats*sizeof(TkPattern); if (!isNew) { for (psPtr = (PatSeq *) Tcl_GetHashValue(hPtr); psPtr != NULL; psPtr = psPtr->nextSeqPtr) { @@ -4072,7 +4072,7 @@ FindSequence( return NULL; } psPtr = (PatSeq *) ckalloc((unsigned) (sizeof(PatSeq) - + (numPats-1)*sizeof(Pattern))); + + (numPats-1)*sizeof(TkPattern))); psPtr->numPats = numPats; psPtr->eventProc = NULL; psPtr->freeProc = NULL; @@ -4119,7 +4119,7 @@ ParseEventDescription( const char **eventStringPtr,/* On input, holds a pointer to start of event * string. On exit, gets pointer to rest of * string after parsed event. */ - Pattern *patPtr, /* Filled with the pattern parsed from the + TkPattern *patPtr, /* Filled with the pattern parsed from the * event string. */ unsigned long *eventMaskPtr)/* Filled with event mask of matched event. */ { @@ -4397,7 +4397,7 @@ GetPatternString( PatSeq *psPtr, Tcl_DString *dsPtr) { - Pattern *patPtr; + TkPattern *patPtr; char c, buffer[TCL_INTEGER_SPACE]; int patsLeft, needMods; ModInfo *modPtr; @@ -4447,15 +4447,15 @@ GetPatternString( if ((psPtr->flags & PAT_NEARBY) && (patsLeft > 1) && (memcmp((char *) patPtr, (char *) (patPtr-1), - sizeof(Pattern)) == 0)) { + sizeof(TkPattern)) == 0)) { patsLeft--; patPtr--; if ((patsLeft > 1) && (memcmp((char *) patPtr, - (char *) (patPtr-1), sizeof(Pattern)) == 0)) { + (char *) (patPtr-1), sizeof(TkPattern)) == 0)) { patsLeft--; patPtr--; if ((patsLeft > 1) && (memcmp((char *) patPtr, - (char *) (patPtr-1), sizeof(Pattern)) == 0)) { + (char *) (patPtr-1), sizeof(TkPattern)) == 0)) { patsLeft--; patPtr--; Tcl_DStringAppend(dsPtr, "Quadruple-", 10); diff --git a/generic/tkInt.decls b/generic/tkInt.decls index 4cbdb60..ab56bed 100644 --- a/generic/tkInt.decls +++ b/generic/tkInt.decls @@ -568,9 +568,6 @@ declare 180 { char *TkSmoothPrintProc(ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr) } -declare 181 { - int TkpScanWindowId(Tcl_Interp *interp, const char *string, Window *idPtr) -} declare 184 { void TkUnusedStubEntry(void) } @@ -974,6 +971,9 @@ declare 53 aqua { declare 54 aqua { void *TkMacOSXDrawable(Drawable drawable) } +declare 55 aqua { + int TkpScanWindowId(Tcl_Interp *interp, const char *string, Window *idPtr) +} ############################################################################## diff --git a/generic/tkIntDecls.h b/generic/tkIntDecls.h index b31bbd4..9dea8d4 100644 --- a/generic/tkIntDecls.h +++ b/generic/tkIntDecls.h @@ -966,12 +966,7 @@ EXTERN char * TkSmoothPrintProc(ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); #endif -#ifndef TkpScanWindowId_TCL_DECLARED -#define TkpScanWindowId_TCL_DECLARED -/* 181 */ -EXTERN int TkpScanWindowId(Tcl_Interp *interp, - CONST char *string, Window *idPtr); -#endif +/* Slot 181 is reserved */ /* Slot 182 is reserved */ /* Slot 183 is reserved */ #ifndef TkUnusedStubEntry_TCL_DECLARED @@ -1192,7 +1187,7 @@ typedef struct TkIntStubs { char * (*tkOrientPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 178 */ int (*tkSmoothParseProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, CONST char *value, char *widgRec, int offset); /* 179 */ char * (*tkSmoothPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 180 */ - int (*tkpScanWindowId) (Tcl_Interp *interp, CONST char *string, Window *idPtr); /* 181 */ + VOID *reserved181; VOID *reserved182; VOID *reserved183; void (*tkUnusedStubEntry) (void); /* 184 */ @@ -1865,10 +1860,7 @@ extern TkIntStubs *tkIntStubsPtr; #define TkSmoothPrintProc \ (tkIntStubsPtr->tkSmoothPrintProc) /* 180 */ #endif -#ifndef TkpScanWindowId -#define TkpScanWindowId \ - (tkIntStubsPtr->tkpScanWindowId) /* 181 */ -#endif +/* Slot 181 is reserved */ /* Slot 182 is reserved */ /* Slot 183 is reserved */ #ifndef TkUnusedStubEntry diff --git a/generic/tkIntPlatDecls.h b/generic/tkIntPlatDecls.h index 9b800f3..b377173 100644 --- a/generic/tkIntPlatDecls.h +++ b/generic/tkIntPlatDecls.h @@ -531,6 +531,12 @@ EXTERN unsigned long TkpGetMS(void); /* 54 */ EXTERN VOID * TkMacOSXDrawable(Drawable drawable); #endif +#ifndef TkpScanWindowId_TCL_DECLARED +#define TkpScanWindowId_TCL_DECLARED +/* 55 */ +EXTERN int TkpScanWindowId(Tcl_Interp *interp, + CONST char *string, Window *idPtr); +#endif #endif /* AQUA */ #if !(defined(__WIN32__) || defined(__CYGWIN__) || defined(MAC_OSX_TK)) /* X11 */ #ifndef TkCreateXEventSource_TCL_DECLARED @@ -716,6 +722,7 @@ typedef struct TkIntPlatStubs { VOID *reserved52; unsigned long (*tkpGetMS) (void); /* 53 */ VOID * (*tkMacOSXDrawable) (Drawable drawable); /* 54 */ + int (*tkpScanWindowId) (Tcl_Interp *interp, CONST char *string, Window *idPtr); /* 55 */ #endif /* AQUA */ #if !(defined(__WIN32__) || defined(__CYGWIN__) || defined(MAC_OSX_TK)) /* X11 */ void (*tkCreateXEventSource) (void); /* 0 */ @@ -1127,6 +1134,10 @@ extern TkIntPlatStubs *tkIntPlatStubsPtr; #define TkMacOSXDrawable \ (tkIntPlatStubsPtr->tkMacOSXDrawable) /* 54 */ #endif +#ifndef TkpScanWindowId +#define TkpScanWindowId \ + (tkIntPlatStubsPtr->tkpScanWindowId) /* 55 */ +#endif #endif /* AQUA */ #if !(defined(__WIN32__) || defined(__CYGWIN__) || defined(MAC_OSX_TK)) /* X11 */ #ifndef TkCreateXEventSource diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c index b2e6314..3ee54dd 100644 --- a/generic/tkStubInit.c +++ b/generic/tkStubInit.c @@ -478,7 +478,7 @@ TkIntStubs tkIntStubs = { TkOrientPrintProc, /* 178 */ TkSmoothParseProc, /* 179 */ TkSmoothPrintProc, /* 180 */ - TkpScanWindowId, /* 181 */ + NULL, /* 181 */ NULL, /* 182 */ NULL, /* 183 */ TkUnusedStubEntry, /* 184 */ @@ -591,6 +591,7 @@ TkIntPlatStubs tkIntPlatStubs = { NULL, /* 52 */ TkpGetMS, /* 53 */ TkMacOSXDrawable, /* 54 */ + TkpScanWindowId, /* 55 */ #endif /* AQUA */ #if !(defined(__WIN32__) || defined(__CYGWIN__) || defined(MAC_OSX_TK)) /* X11 */ TkCreateXEventSource, /* 0 */ -- cgit v0.12