diff options
author | hobbs <hobbs> | 2000-01-06 02:18:54 (GMT) |
---|---|---|
committer | hobbs <hobbs> | 2000-01-06 02:18:54 (GMT) |
commit | 0bcb96bc6cddb09417aaa0ca4ad48469d0194255 (patch) | |
tree | 30b59fdcebfe145f313d150bf31fb58700da5e51 /generic/tkTextBTree.c | |
parent | 099514fd0cbd6126e4515620fe46382607c8755d (diff) | |
download | tk-0bcb96bc6cddb09417aaa0ca4ad48469d0194255.zip tk-0bcb96bc6cddb09417aaa0ca4ad48469d0194255.tar.gz tk-0bcb96bc6cddb09417aaa0ca4ad48469d0194255.tar.bz2 |
* doc/text.n:
* generic/tkText.c:
* generic/tkText.h:
* generic/tkTextBTree.c:
* generic/tkTextDisp.c:
* generic/tkTextTag.c: removed the -state option for text tags,
and reoriented it around -elide, as -state disabled was never
implemented, and -state hidden is better as -elide.
Diffstat (limited to 'generic/tkTextBTree.c')
-rw-r--r-- | generic/tkTextBTree.c | 118 |
1 files changed, 67 insertions, 51 deletions
diff --git a/generic/tkTextBTree.c b/generic/tkTextBTree.c index c20a0db..07a209b 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.4 1999/12/14 06:52:32 hobbs Exp $ + * RCS: @(#) $Id: tkTextBTree.c,v 1.5 2000/01/06 02:18:58 hobbs Exp $ */ #include "tkInt.h" @@ -2427,13 +2427,28 @@ TkBTreeGetTags(indexPtr, numTagsPtr) } return tagInfo.tagPtrs; } - - + /* - special case to just return information about elided attribute - specialized from TkBTreeGetTags(indexPtr, numTagsPtr) and GetStyle(textPtr, indexPtr) - just need to keep track of invisibility settings for each priority, pick highest one active at end -*/ + *---------------------------------------------------------------------- + * + * TkTextIsElided -- + * + * Special case to just return information about elided attribute. + * Specialized from TkBTreeGetTags(indexPtr, numTagsPtr) + * and GetStyle(textPtr, indexPtr). + * Just need to keep track of invisibility settings for each priority, + * pick highest one active at end + * + * Results: + * Returns whether this text should be elided or not. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + + /* ARGSUSED */ int TkTextIsElided(textPtr, indexPtr) TkText *textPtr; /* Overall information about text widget. */ @@ -2441,13 +2456,13 @@ TkTextIsElided(textPtr, indexPtr) * display information is wanted. */ { #define LOTSA_TAGS 1000 - int elide = 0; /* if nobody says otherwise, it's visible */ + int elide = 0; /* if nobody says otherwise, it's visible */ - int deftagCnts[LOTSA_TAGS]; - int *tagCnts = deftagCnts; - TkTextTag *deftagPtrs[LOTSA_TAGS]; - TkTextTag **tagPtrs = deftagPtrs; - int numTags = textPtr->numTags; + int deftagCnts[LOTSA_TAGS]; + int *tagCnts = deftagCnts; + TkTextTag *deftagPtrs[LOTSA_TAGS]; + TkTextTag **tagPtrs = deftagPtrs; + int numTags = textPtr->numTags; register Node *nodePtr; register TkTextLine *siblingLinePtr; register TkTextSegment *segPtr; @@ -2455,13 +2470,14 @@ TkTextIsElided(textPtr, indexPtr) register int i, index; /* almost always avoid malloc, so stay out of system calls */ - if (LOTSA_TAGS < numTags) { - tagCnts = (int *)ckalloc((unsigned)sizeof(int) * numTags); - tagPtrs = (TkTextTag **)ckalloc((unsigned)sizeof(TkTextTag *) * numTags); - } + if (LOTSA_TAGS < numTags) { + tagCnts = (int *)ckalloc((unsigned)sizeof(int) * numTags); + tagPtrs = (TkTextTag **)ckalloc((unsigned)sizeof(TkTextTag *) * numTags); + } - for (i=0; i<numTags; i++) tagCnts[i]=0; - + for (i=0; i<numTags; i++) { + tagCnts[i] = 0; + } /* * Record tag toggles within the line of indexPtr but preceding @@ -2469,14 +2485,14 @@ TkTextIsElided(textPtr, indexPtr) */ for (index = 0, segPtr = indexPtr->linePtr->segPtr; - (index + segPtr->size) <= indexPtr->byteIndex; - index += segPtr->size, segPtr = segPtr->nextPtr) { + (index + segPtr->size) <= indexPtr->byteIndex; + index += segPtr->size, segPtr = segPtr->nextPtr) { if ((segPtr->typePtr == &tkTextToggleOnType) - || (segPtr->typePtr == &tkTextToggleOffType)) { + || (segPtr->typePtr == &tkTextToggleOffType)) { tagPtr = segPtr->body.toggle.tagPtr; - if (tagPtr->state != TK_STATE_NULL) { - tagPtrs[tagPtr->priority] = tagPtr; - tagCnts[tagPtr->priority]++; + if (tagPtr->elideString != NULL) { + tagPtrs[tagPtr->priority] = tagPtr; + tagCnts[tagPtr->priority]++; } } } @@ -2487,17 +2503,17 @@ TkTextIsElided(textPtr, indexPtr) */ for (siblingLinePtr = indexPtr->linePtr->parentPtr->children.linePtr; - siblingLinePtr != indexPtr->linePtr; - siblingLinePtr = siblingLinePtr->nextPtr) { + siblingLinePtr != indexPtr->linePtr; + siblingLinePtr = siblingLinePtr->nextPtr) { for (segPtr = siblingLinePtr->segPtr; segPtr != NULL; - segPtr = segPtr->nextPtr) { + segPtr = segPtr->nextPtr) { if ((segPtr->typePtr == &tkTextToggleOnType) - || (segPtr->typePtr == &tkTextToggleOffType)) { - tagPtr = segPtr->body.toggle.tagPtr; - if (tagPtr->state != TK_STATE_NULL) { - tagPtrs[tagPtr->priority] = tagPtr; - tagCnts[tagPtr->priority]++; - } + || (segPtr->typePtr == &tkTextToggleOffType)) { + tagPtr = segPtr->body.toggle.tagPtr; + if (tagPtr->elideString != NULL) { + tagPtrs[tagPtr->priority] = tagPtr; + tagCnts[tagPtr->priority]++; + } } } } @@ -2508,47 +2524,47 @@ TkTextIsElided(textPtr, indexPtr) */ for (nodePtr = indexPtr->linePtr->parentPtr; nodePtr->parentPtr != NULL; - nodePtr = nodePtr->parentPtr) { + nodePtr = nodePtr->parentPtr) { register Node *siblingPtr; register Summary *summaryPtr; for (siblingPtr = nodePtr->parentPtr->children.nodePtr; - siblingPtr != nodePtr; siblingPtr = siblingPtr->nextPtr) { + siblingPtr != nodePtr; siblingPtr = siblingPtr->nextPtr) { for (summaryPtr = siblingPtr->summaryPtr; summaryPtr != NULL; - summaryPtr = summaryPtr->nextPtr) { + summaryPtr = summaryPtr->nextPtr) { if (summaryPtr->toggleCount & 1) { tagPtr = summaryPtr->tagPtr; - if (tagPtr->state != TK_STATE_NULL) { - tagPtrs[tagPtr->priority] = tagPtr; - tagCnts[tagPtr->priority] += summaryPtr->toggleCount; + if (tagPtr->elideString != NULL) { + tagPtrs[tagPtr->priority] = tagPtr; + tagCnts[tagPtr->priority] += summaryPtr->toggleCount; } } } } } - /* * Now traverse from highest priority to lowest, * take elided value from first odd count (= on) */ for (i = numTags-1; i >=0; i--) { - if (tagCnts[i] & 1) { + if (tagCnts[i] & 1) { #ifndef ALWAYS_SHOW_SELECTION - /* who would make the selection elided? */ - if ((tagPtr == textPtr->selTagPtr) && !(textPtr->flags & GOT_FOCUS)) { - continue; - } + /* who would make the selection elided? */ + if ((tagPtr == textPtr->selTagPtr) + && !(textPtr->flags & GOT_FOCUS)) { + continue; + } #endif - elide = (tagPtrs[i]->state == TK_STATE_HIDDEN); - break; - } + elide = tagPtrs[i]->elide; + break; + } } if (LOTSA_TAGS < numTags) { - ckfree((char *) tagCnts); - ckfree((char *) tagPtrs); + ckfree((char *) tagCnts); + ckfree((char *) tagPtrs); } return elide; |