summaryrefslogtreecommitdiffstats
path: root/generic/tkText.c
diff options
context:
space:
mode:
authorericm <ericm>2000-07-21 23:44:11 (GMT)
committerericm <ericm>2000-07-21 23:44:11 (GMT)
commit5649a675dfb76712afa08a8711459fc263bdbeb3 (patch)
tree972ef52cd15e825d853c81e50d7fb3be9ef8d63e /generic/tkText.c
parent531de37de6e419357d2eee46ebcfcbec5ad70974 (diff)
downloadtk-5649a675dfb76712afa08a8711459fc263bdbeb3.zip
tk-5649a675dfb76712afa08a8711459fc263bdbeb3.tar.gz
tk-5649a675dfb76712afa08a8711459fc263bdbeb3.tar.bz2
* tests/text.test: Added tests for searching when text is elided.
* generic/tkText.c (TextSearchCmd): Text search was not returning the correct index when the search covered (but did not search) elided characters; corrected this by adjusting the match index by the number of elided characters preceeding the start of the match, just as is done with embedded windows, etc. [Bug: 5470].
Diffstat (limited to 'generic/tkText.c')
-rw-r--r--generic/tkText.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/generic/tkText.c b/generic/tkText.c
index f4ebda7..cd5cac0 100644
--- a/generic/tkText.c
+++ b/generic/tkText.c
@@ -14,7 +14,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.15 2000/07/19 18:13:50 ericm Exp $
+ * RCS: @(#) $Id: tkText.c,v 1.16 2000/07/21 23:44:11 ericm Exp $
*/
#include "default.h"
@@ -1952,7 +1952,8 @@ TextSearchCmd(textPtr, interp, argc, argv)
/*
* The index information returned by the regular expression
* parser only considers textual information: it doesn't
- * account for embedded windows or any other non-textual info.
+ * account for embedded windows, elided text (when we are not
+ * searching elided text) or any other non-textual info.
* Scan through the line's segments again to adjust both
* matchChar and matchCount.
*
@@ -1961,13 +1962,16 @@ TextSearchCmd(textPtr, interp, argc, argv)
* of the line.
*/
+ curIndex.linePtr = linePtr; curIndex.byteIndex = 0;
for (segPtr = linePtr->segPtr, leftToScan = matchByte;
leftToScan >= 0 && segPtr; segPtr = segPtr->nextPtr) {
- if (segPtr->typePtr != &tkTextCharType) {
+ if (segPtr->typePtr != &tkTextCharType || \
+ (!searchElide && TkTextIsElided(textPtr, &curIndex))) {
matchByte += segPtr->size;
- continue;
+ } else {
+ leftToScan -= segPtr->size;
}
- leftToScan -= segPtr->size;
+ curIndex.byteIndex += segPtr->size;
}
for (leftToScan += matchLength; leftToScan > 0;
segPtr = segPtr->nextPtr) {