summaryrefslogtreecommitdiffstats
path: root/generic/tkTextBTree.c
diff options
context:
space:
mode:
authorvincentdarley <vincentdarley>2006-03-26 17:52:39 (GMT)
committervincentdarley <vincentdarley>2006-03-26 17:52:39 (GMT)
commit5f87593323244e86ce48d4aa8c21ad14f5d91db3 (patch)
treefa2d32110894ce98d8ef904e86749aa9d72f1442 /generic/tkTextBTree.c
parentfdcd47db9dfd574392d0ef615177b3435fd923c8 (diff)
downloadtk-5f87593323244e86ce48d4aa8c21ad14f5d91db3.zip
tk-5f87593323244e86ce48d4aa8c21ad14f5d91db3.tar.gz
tk-5f87593323244e86ce48d4aa8c21ad14f5d91db3.tar.bz2
fix for text dump -command callbacks which modify the text widget
Diffstat (limited to 'generic/tkTextBTree.c')
-rw-r--r--generic/tkTextBTree.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/generic/tkTextBTree.c b/generic/tkTextBTree.c
index 153c780..908a557 100644
--- a/generic/tkTextBTree.c
+++ b/generic/tkTextBTree.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkTextBTree.c,v 1.20 2005/11/17 16:21:56 dkf Exp $
+ * RCS: @(#) $Id: tkTextBTree.c,v 1.21 2006/03/26 17:52:40 vincentdarley Exp $
*/
#include "tkInt.h"
@@ -108,6 +108,8 @@ typedef struct BTree {
int clients; /* Number of clients of this B-tree. */
int pixelReferences; /* Number of clients of this B-tree which care
* about pixel heights. */
+ int stateEpoch; /* Updated each time any aspect of the B-tree
+ * changes. */
TkSharedText *sharedTextPtr;/* Used to find tagTable in consistency
* checking code, and to access list of all
* B-tree clients. */
@@ -323,6 +325,7 @@ TkBTreeCreate(sharedTextPtr)
treePtr->sharedTextPtr = sharedTextPtr;
treePtr->rootPtr = rootPtr;
treePtr->clients = 0;
+ treePtr->stateEpoch = 0;
treePtr->pixelReferences = 0;
treePtr->startEndCount = 0;
treePtr->startEnd = NULL;
@@ -491,6 +494,31 @@ TkBTreeDestroy(tree)
/*
*----------------------------------------------------------------------
*
+ * TkBTreeEpoch --
+ *
+ * Return the epoch for the B-tree. This number is incremented
+ * any time anything changes in the tree.
+ *
+ * Results:
+ * The epoch number.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+TkBTreeEpoch(tree)
+ TkTextBTree tree; /* Tree to get epoch for */
+{
+ BTree *treePtr = (BTree *) tree;
+ return treePtr->stateEpoch;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* TkBTreeRemoveClient --
*
* Remove a client widget from its B-tree, cleaning up the pixel arrays
@@ -1012,6 +1040,7 @@ TkBTreeInsertChars(tree, indexPtr, string)
int pixels[PIXEL_CLIENTS];
BTree *treePtr = (BTree*)tree;
+ treePtr->stateEpoch++;
prevPtr = SplitSeg(indexPtr);
linePtr = indexPtr->linePtr;
curPtr = prevPtr;
@@ -1306,6 +1335,7 @@ TkBTreeDeleteIndexRange(tree, index1Ptr, index2Ptr)
int changeToLineCount = 0;
int ref;
BTree *treePtr = (BTree*)tree;
+ treePtr->stateEpoch++;
/*
* Tricky point: split at index2Ptr first; otherwise the split at
@@ -2006,6 +2036,7 @@ TkBTreeLinkSegment(segPtr, indexPtr)
if (tkBTreeDebug) {
TkBTreeCheck(indexPtr->tree);
}
+ ((BTree*)indexPtr->tree)->stateEpoch++;
}
/*
@@ -2201,6 +2232,7 @@ TkBTreeTag(index1Ptr, index2Ptr, tagPtr, add)
if (cleanupLinePtr != index2Ptr->linePtr) {
CleanupLine(index2Ptr->linePtr);
}
+ ((BTree*)index1Ptr->tree)->stateEpoch++;
}
if (tkBTreeDebug) {