From ca42fb6e8a854824ce4a721366545f93b4922b7c Mon Sep 17 00:00:00 2001 From: vincentdarley Date: Fri, 13 May 2005 13:46:11 +0000 Subject: fix to two text widget bugs --- ChangeLog | 8 ++++++++ generic/tkTextDisp.c | 19 +++++++++++-------- library/text.tcl | 4 ++-- tests/textIndex.test | 13 ++++++++++++- 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 978618f..ee02eb3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2005-05-10 Vince Darley + + * library/text.tcl: test and fix to TextPrevPara to avoid infinite loop + * tests/textIndex.test: at start of widget [Bug 1191895] + + * generic/tkTextDisp.c: better synchronisation between + explicit and implicit pixel line-height calculations [Bug 1186558] + 2005-05-10 Don Porter * generic/tkTextDisp.c (GetXView): Improved numerical precision diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 21f9e4b..6e6da31 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.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: tkTextDisp.c,v 1.49 2005/05/10 21:36:37 dgp Exp $ + * RCS: @(#) $Id: tkTextDisp.c,v 1.50 2005/05/13 13:46:12 vincentdarley Exp $ */ #include "tkPort.h" @@ -1539,6 +1539,7 @@ LayoutDLine(textPtr, indexPtr) */ dlPtr->length = lastChunkPtr->x + lastChunkPtr->width; + return dlPtr; } @@ -1745,16 +1746,18 @@ UpdateDisplayInfo(textPtr) } if ((lineHeight != -1) - && (lineHeight > TkBTreeLinePixelCount(textPtr, + && (lineHeight != TkBTreeLinePixelCount(textPtr, prevPtr->index.linePtr))) { /* - * The logical line height we just calculated is actually - * larger than the currently cached height of the - * text line. That is fine (the text line heights + * The logical line height we just calculated is + * actually differnt to the currently cached height of + * the text line. That is fine (the text line heights * are only calculated asynchronously), but we must - * update the cached height so that any counts made - * with DLine pointers do not exceed counts made - * through the BTree. + * update the cached height so that any counts made with + * DLine pointers are the same as counts made through the + * BTree. This helps to ensure that the scrollbar size + * corresponds accurately to that displayed contents, + * even as the window is re-sized. */ TkBTreeAdjustPixelHeight(textPtr, prevPtr->index.linePtr, diff --git a/library/text.tcl b/library/text.tcl index 40973e7..a6c1c1f 100644 --- a/library/text.tcl +++ b/library/text.tcl @@ -3,7 +3,7 @@ # This file defines the default bindings for Tk text widgets and provides # procedures that help in implementing the bindings. # -# RCS: @(#) $Id: text.tcl,v 1.36 2005/04/18 11:34:41 vincentdarley Exp $ +# RCS: @(#) $Id: text.tcl,v 1.37 2005/05/13 13:46:12 vincentdarley Exp $ # # Copyright (c) 1992-1994 The Regents of the University of California. # Copyright (c) 1994-1997 Sun Microsystems, Inc. @@ -909,7 +909,7 @@ proc ::tk::TextPrevPara {w pos} { dummy index]} { set pos [$w index "$pos + [lindex $index 0] chars"] } - if {[$w compare $pos != insert] || [string equal $pos 1.0]} { + if {[$w compare $pos != insert] || [lindex [split $pos .] 0] == 1} { return $pos } } diff --git a/tests/textIndex.test b/tests/textIndex.test index 6527349..e88da10 100644 --- a/tests/textIndex.test +++ b/tests/textIndex.test @@ -6,7 +6,7 @@ # Copyright (c) 1998-1999 by Scriptics Corporation. # All rights reserved. # -# RCS: @(#) $Id: textIndex.test,v 1.15 2005/02/14 23:03:26 vincentdarley Exp $ +# RCS: @(#) $Id: textIndex.test,v 1.16 2005/05/13 13:46:13 vincentdarley Exp $ package require tcltest 2.1 eval tcltest::configure $argv @@ -886,6 +886,17 @@ test textIndex-22.13 {text index wordstart, unicode} { text_test_word wordstart "\uc700\uc700 abc" 8 } 3 +test textIndex-23.1 {text index wordstart, unicode} { + pack [text .t2] + .t2 insert end " Text" + set res 2.0 + for {set i 0} {$i < 2} {incr i} { + lappend res [::tk::TextPrevPara .t2 [lindex $res end]] + } + destroy .t2 + set res +} {2.0 1.1 1.1} + # cleanup rename textimage {} -- cgit v0.12