From 37c5b1bdef50e5f82c896ce6008b00a9d0e5bc5c Mon Sep 17 00:00:00 2001 From: vincentdarley Date: Mon, 31 Oct 2005 23:21:08 +0000 Subject: fix for count displaylines bug --- ChangeLog | 6 ++++++ generic/tkText.c | 11 ++++++++++- tests/textDisp.test | 27 ++++++++++++++++++++++++++- 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 70f6388..27bff99 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-10-31 Vince Darley + + * generic/tkText.c + * tests/textDisp.test: fix and test for [Bug 1333951] in + '.text count -displaylines'. + 2005-10-18 Don Porter * generic/tkMain.c: Rewrote code that sets the ::argv value diff --git a/generic/tkText.c b/generic/tkText.c index 5313ed3..1a6477f 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -13,7 +13,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkText.c,v 1.60 2005/10/10 10:36:35 vincentdarley Exp $ + * RCS: @(#) $Id: tkText.c,v 1.61 2005/10/31 23:21:08 vincentdarley Exp $ */ #include "default.h" @@ -904,6 +904,15 @@ TextWidgetObjCmd(clientData, interp, objc, objv) */ index = *indexFromPtr; + index.byteIndex = 0; + + /* + * 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 what from 'from' + * and add on what we didn't count from 'to. + */ while (index.linePtr != indexToPtr->linePtr) { value += TkTextUpdateOneLine(textPtr, fromPtr, 0,&index,0); diff --git a/tests/textDisp.test b/tests/textDisp.test index cd52fe0..b523e20 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -6,7 +6,7 @@ # Copyright (c) 1998-1999 by Scriptics Corporation. # All rights reserved. # -# RCS: @(#) $Id: textDisp.test,v 1.38 2005/10/10 10:36:35 vincentdarley Exp $ +# RCS: @(#) $Id: textDisp.test,v 1.39 2005/10/31 23:21:08 vincentdarley Exp $ package require tcltest 2.1 eval tcltest::configure $argv @@ -2603,6 +2603,31 @@ test textDisp-21.3 {TkTextPixelIndex, horizontal scrolling} {textfonts} { .t xview scroll 2 units list [.t index @-5,7] [.t index @5,7] [.t index @33,20] } {1.2 1.2 2.6} +test textDisp-21.4 {count -displaylines regression} { + set message { + QOTW: "C/C++, which is used by 16% of users, is the most popular programming language, but Tcl, used by 0%, seems to be the language of choice for the highest scoring users." +(new line) +Use the Up (cursor) key to scroll up one line at a time. At the second press, the cursor either gets locked or jumps several lines. + +Connect with Tkcon. The command +.u count -displaylines \ +3.10 2.173 +should give answer -1; it gives me 5. + +Using 8.5a4 (ActiveState beta 4) under Linux. No problem with ActiveState beta 3. +} + +toplevel .tt +pack [text .tt.u] -side right +.tt.u configure -width 30 -height 27 -wrap word -bg #FFFFFF +.tt.u insert end $message +.tt.u mark set insert 3.10 +tkwait visibility .tt.u +set res [.tt.u count -displaylines 3.10 2.173] +destroy .tt +unset message +set res +} {-1} .t delete 1.0 end .t insert end "Line 1" -- cgit v0.12