summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-rw-r--r--generic/tkText.c29
-rw-r--r--generic/tkText.h14
-rw-r--r--generic/tkTextBTree.c118
-rw-r--r--generic/tkTextDisp.c111
-rw-r--r--generic/tkTextTag.c136
5 files changed, 167 insertions, 241 deletions
diff --git a/generic/tkText.c b/generic/tkText.c
index 16fb043..ace48be 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.9 1999/12/14 06:52:31 hobbs Exp $
+ * RCS: @(#) $Id: tkText.c,v 1.10 2000/01/06 02:18:58 hobbs Exp $
*/
#include "default.h"
@@ -34,8 +34,7 @@
static Tk_CustomOption stateOption = {
(Tk_OptionParseProc *) TkStateParseProc,
- TkStatePrintProc,
- (ClientData) NULL /* only "normal" and "disabled" */
+ TkStatePrintProc, (ClientData) NULL /* only "normal" and "disabled" */
};
/*
@@ -969,8 +968,8 @@ ConfigureText(interp, textPtr, argc, argv, flags)
|| (textPtr->selTagPtr->spacing2String != NULL)
|| (textPtr->selTagPtr->spacing3String != NULL)
|| (textPtr->selTagPtr->tabString != NULL)
- || (textPtr->selTagPtr->state != TK_STATE_NULL)
|| (textPtr->selTagPtr->underlineString != NULL)
+ || (textPtr->selTagPtr->elideString != NULL)
|| (textPtr->selTagPtr->wrapMode != TEXT_WRAPMODE_NULL)) {
textPtr->selTagPtr->affectsDisplay = 1;
}
@@ -1519,7 +1518,8 @@ TextFetchSelection(clientData, offset, buffer, maxBytes)
}
}
}
- if (segPtr->typePtr == &tkTextCharType && !TkTextIsElided(textPtr, &textPtr->selIndex)) {
+ if ((segPtr->typePtr == &tkTextCharType)
+ && !TkTextIsElided(textPtr, &textPtr->selIndex)) {
memcpy((VOID *) buffer, (VOID *) (segPtr->body.chars
+ offsetInSeg), (size_t) chunkSize);
buffer += chunkSize;
@@ -1695,7 +1695,7 @@ TextSearchCmd(textPtr, interp, argc, argv)
badSwitch:
Tcl_AppendResult(interp, "bad switch \"", arg,
"\": must be -forward, -backward, -exact, -regexp, ",
- "-nocase, -count, -hidden, or --", (char *) NULL);
+ "-nocase, -count, -elide, or --", (char *) NULL);
return TCL_ERROR;
}
c = arg[1];
@@ -1709,9 +1709,17 @@ TextSearchCmd(textPtr, interp, argc, argv)
}
i++;
varName = argv[i];
- } else if ((c == 'e') && (strncmp(argv[i], "-exact", length) == 0)) {
+ } else if ((c == 'e') && (length > 2)
+ && (strncmp(argv[i], "-exact", length) == 0)) {
exact = 1;
- } else if ((c == 'e') && (strncmp(argv[i], "-elide", length) == 0)) {
+ } else if ((c == 'e') && (length > 2)
+ && (strncmp(argv[i], "-elide", length) == 0)) {
+ searchElide = 1;
+ } else if ((c == 'h') && (strncmp(argv[i], "-hidden", length) == 0)) {
+ /*
+ * -hidden is kept around for backwards compatibility with
+ * the dash patch, but -elide is the official option
+ */
searchElide = 1;
} else if ((c == 'f') && (strncmp(argv[i], "-forwards", length) == 0)) {
backwards = 0;
@@ -1719,8 +1727,6 @@ TextSearchCmd(textPtr, interp, argc, argv)
noCase = 1;
} else if ((c == 'r') && (strncmp(argv[i], "-regexp", length) == 0)) {
exact = 0;
- } else if ((c == 'h') && (strncmp(argv[i], "-hidden", length) == 0)) {
- searchElide = 1;
} else if ((c == '-') && (strncmp(argv[i], "--", length) == 0)) {
i++;
break;
@@ -1818,7 +1824,8 @@ TextSearchCmd(textPtr, interp, argc, argv)
curIndex.linePtr = linePtr; curIndex.byteIndex = 0;
for (segPtr = linePtr->segPtr; segPtr != NULL;
curIndex.byteIndex += segPtr->size, segPtr = segPtr->nextPtr) {
- if (segPtr->typePtr != &tkTextCharType || (!searchElide && TkTextIsElided(textPtr, &curIndex))) {
+ if ((segPtr->typePtr != &tkTextCharType)
+ || (!searchElide && TkTextIsElided(textPtr, &curIndex))) {
continue;
}
Tcl_DStringAppend(&line, segPtr->body.chars, segPtr->size);
diff --git a/generic/tkText.h b/generic/tkText.h
index bec8ef7..f89c18f 100644
--- a/generic/tkText.h
+++ b/generic/tkText.h
@@ -10,7 +10,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.h,v 1.6 1999/12/14 06:52:32 hobbs Exp $
+ * RCS: @(#) $Id: tkText.h,v 1.7 2000/01/06 02:18:58 hobbs Exp $
*/
#ifndef _TKTEXT
@@ -382,11 +382,13 @@ typedef struct TkTextTag {
* TEXT_WRAPMODE_NONE, TEXT_WRAPMODE_WORD,
* or TEXT_WRAPMODE_NULL to use wrapmode for
* whole widget. */
+ char *elideString; /* -elide option string (malloc-ed).
+ * NULL means option not specified. */
+ int elide; /* Non-zero means that data under this tag
+ * should not be displayed. */
int affectsDisplay; /* Non-zero means that this tag affects the
* way information is displayed on the screen
* (so need to redisplay if tag changes). */
- int state; /* Must be STATE_NULL, STATE_NORMAL,
- * STATE_HIDDEN or STATE_DISABLED. */
} TkTextTag;
#define TK_TAG_AFFECTS_DISPLAY 0x1
@@ -484,8 +486,8 @@ typedef struct TkText {
* image segment doesn't yet have an
* associated image, there is no entry for
* it here. */
- int state; /* Either STATE_NORMAL or STATE_DISABLED. A text
- * widget is read-only when disabled. */
+ int state; /* Either STATE_NORMAL or STATE_DISABLED. A
+ * text widget is read-only when disabled. */
/*
* Default information for displaying (may be overridden by tags
@@ -820,7 +822,7 @@ EXTERN void TkTextLostSelection _ANSI_ARGS_((
EXTERN TkTextIndex * TkTextMakeCharIndex _ANSI_ARGS_((TkTextBTree tree,
int lineIndex, int charIndex,
TkTextIndex *indexPtr));
-extern int TkTextIsElided _ANSI_ARGS_((TkText *textPtr,
+EXTERN int TkTextIsElided _ANSI_ARGS_((TkText *textPtr,
TkTextIndex *indexPtr));
EXTERN TkTextIndex * TkTextMakeByteIndex _ANSI_ARGS_((TkTextBTree tree,
int lineIndex, int byteIndex,
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;
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c
index f9cef40..e0d1d57 100644
--- a/generic/tkTextDisp.c
+++ b/generic/tkTextDisp.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: tkTextDisp.c,v 1.8 1999/12/14 06:52:32 hobbs Exp $
+ * RCS: @(#) $Id: tkTextDisp.c,v 1.9 2000/01/06 02:18:59 hobbs Exp $
*/
#include "tkPort.h"
@@ -502,7 +502,7 @@ GetStyle(textPtr, indexPtr)
int borderPrio, borderWidthPrio, reliefPrio, bgStipplePrio;
int fgPrio, fontPrio, fgStipplePrio;
- int underlinePrio, statePrio, justifyPrio, offsetPrio;
+ int underlinePrio, elidePrio, justifyPrio, offsetPrio;
int lMargin1Prio, lMargin2Prio, rMarginPrio;
int spacing1Prio, spacing2Prio, spacing3Prio;
int overstrikePrio, tabPrio, wrapPrio;
@@ -517,7 +517,7 @@ GetStyle(textPtr, indexPtr)
tagPtrs = TkBTreeGetTags(indexPtr, &numTags);
borderPrio = borderWidthPrio = reliefPrio = bgStipplePrio = -1;
fgPrio = fontPrio = fgStipplePrio = -1;
- underlinePrio = statePrio = justifyPrio = offsetPrio = -1;
+ underlinePrio = elidePrio = justifyPrio = offsetPrio = -1;
lMargin1Prio = lMargin2Prio = rMarginPrio = -1;
spacing1Prio = spacing2Prio = spacing3Prio = -1;
overstrikePrio = tabPrio = wrapPrio = -1;
@@ -531,7 +531,7 @@ GetStyle(textPtr, indexPtr)
styleValues.spacing3 = textPtr->spacing3;
styleValues.tabArrayPtr = textPtr->tabArrayPtr;
styleValues.wrapMode = textPtr->wrapMode;
- styleValues.elide = (textPtr->state == TK_STATE_HIDDEN);
+ styleValues.elide = 0;
for (i = 0 ; i < numTags; i++) {
tagPtr = tagPtrs[i];
@@ -636,10 +636,10 @@ GetStyle(textPtr, indexPtr)
styleValues.underline = tagPtr->underline;
underlinePrio = tagPtr->priority;
}
- if ((tagPtr->state != TK_STATE_NULL)
- && (tagPtr->priority > statePrio)) {
- styleValues.elide = (tagPtr->state == TK_STATE_HIDDEN);
- statePrio = tagPtr->priority;
+ if ((tagPtr->elideString != NULL)
+ && (tagPtr->priority > elidePrio)) {
+ styleValues.elide = tagPtr->elide;
+ elidePrio = tagPtr->priority;
}
if ((tagPtr->wrapMode != TEXT_WRAPMODE_NULL)
&& (tagPtr->priority > wrapPrio)) {
@@ -821,33 +821,36 @@ LayoutDLine(textPtr, indexPtr)
dlPtr->nextPtr = NULL;
dlPtr->flags = NEW_LAYOUT;
-
/*
- * special case entirely elide line as there may be 1000s or more
- */
- elide = TkTextIsElided(textPtr, indexPtr); /* save a malloc */
- if (elide && indexPtr->byteIndex==0) {
- maxBytes = 0;
- for (segPtr = indexPtr->linePtr->segPtr; elide && segPtr!=NULL; segPtr = segPtr->nextPtr) {
- if ((elidesize = segPtr->size) > 0) {
- maxBytes += elidesize;
-
- /* if have tag toggle, chance that invisibility state changed, so bail out */
- } else if (segPtr->typePtr == &tkTextToggleOffType || segPtr->typePtr == &tkTextToggleOnType) {
- if (segPtr->body.toggle.tagPtr->state!=TK_STATE_NULL) {
- elide = (segPtr->typePtr == &tkTextToggleOffType) ^ (segPtr->body.toggle.tagPtr->state==TK_STATE_HIDDEN);
- }
- }
- }
-
- if (elide) {
- dlPtr->byteCount = maxBytes;
- dlPtr->spaceAbove = dlPtr->spaceBelow = dlPtr->length = 0;
- return dlPtr;
+ * Special case entirely elide line as there may be 1000s or more
+ */
+ elide = TkTextIsElided(textPtr, indexPtr); /* save a malloc */
+ if (elide && indexPtr->byteIndex==0) {
+ maxBytes = 0;
+ for (segPtr = indexPtr->linePtr->segPtr;
+ elide && (segPtr != NULL);
+ segPtr = segPtr->nextPtr) {
+ if ((elidesize = segPtr->size) > 0) {
+ maxBytes += elidesize;
+ /*
+ * If have we have a tag toggle, there is a chance
+ * that invisibility state changed, so bail out
+ */
+ } else if ((segPtr->typePtr == &tkTextToggleOffType)
+ || (segPtr->typePtr == &tkTextToggleOnType)) {
+ if (segPtr->body.toggle.tagPtr->elideString != NULL) {
+ elide = (segPtr->typePtr == &tkTextToggleOffType)
+ ^ segPtr->body.toggle.tagPtr->elide;
}
+ }
}
-
+ if (elide) {
+ dlPtr->byteCount = maxBytes;
+ dlPtr->spaceAbove = dlPtr->spaceBelow = dlPtr->length = 0;
+ return dlPtr;
+ }
+ }
/*
* Each iteration of the loop below creates one TkTextDispChunk for
@@ -879,38 +882,44 @@ LayoutDLine(textPtr, indexPtr)
*/
for (byteOffset = curIndex.byteIndex, segPtr = curIndex.linePtr->segPtr;
- (byteOffset > 0) && (byteOffset >= segPtr->size);
- byteOffset -= segPtr->size, segPtr = segPtr->nextPtr) {
+ (byteOffset > 0) && (byteOffset >= segPtr->size);
+ byteOffset -= segPtr->size, segPtr = segPtr->nextPtr) {
/* Empty loop body. */
}
while (segPtr != NULL) {
-
- /* every line still gets at least one chunk due to expectations in rest of code,
- but able to skip elided portions of line quickly */
- /* if current chunk elided and last chunk was too, coalese */
- if (elide && lastChunkPtr!=NULL && lastChunkPtr->displayProc == NULL/*ElideDisplayProc*/) {
+ /*
+ * Every line still gets at least one chunk due to expectations
+ * in the rest of the code, but we are able to skip elided portions
+ * of the line quickly.
+ * If current chunk is elided and last chunk was too, coalese
+ */
+ if (elide && (lastChunkPtr != NULL)
+ && (lastChunkPtr->displayProc == NULL /*ElideDisplayProc*/)) {
if ((elidesize = segPtr->size - byteOffset) > 0) {
- curIndex.byteIndex += elidesize;
- lastChunkPtr->numBytes += elidesize;
- breakByteOffset = lastChunkPtr->breakIndex = lastChunkPtr->numBytes;
-
- /* if have tag toggle, chance that invisibility state changed */
- } else if (segPtr->typePtr == &tkTextToggleOffType || segPtr->typePtr == &tkTextToggleOnType) {
- if (segPtr->body.toggle.tagPtr->state!=TK_STATE_NULL) {
- elide = (segPtr->typePtr == &tkTextToggleOffType) ^
- (segPtr->body.toggle.tagPtr->state==TK_STATE_HIDDEN);
- }
+ curIndex.byteIndex += elidesize;
+ lastChunkPtr->numBytes += elidesize;
+ breakByteOffset = lastChunkPtr->breakIndex = lastChunkPtr->numBytes;
+ /*
+ * If have we have a tag toggle, there is a chance
+ * that invisibility state changed, so bail out
+ */
+ } else if ((segPtr->typePtr == &tkTextToggleOffType)
+ || (segPtr->typePtr == &tkTextToggleOnType)) {
+ if (segPtr->body.toggle.tagPtr->elideString != NULL) {
+ elide = (segPtr->typePtr == &tkTextToggleOffType)
+ ^ segPtr->body.toggle.tagPtr->elide;
+ }
}
byteOffset = 0;
segPtr = segPtr->nextPtr;
- if (segPtr == NULL && chunkPtr != NULL) ckfree((char *) chunkPtr);
-
+ if (segPtr == NULL && chunkPtr != NULL) {
+ ckfree((char *) chunkPtr);
+ }
continue;
}
-
if (segPtr->typePtr->layoutProc == NULL) {
segPtr = segPtr->nextPtr;
byteOffset = 0;
diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c
index 00723ab..c126fcc 100644
--- a/generic/tkTextTag.c
+++ b/generic/tkTextTag.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: tkTextTag.c,v 1.4 1999/12/14 06:52:33 hobbs Exp $
+ * RCS: @(#) $Id: tkTextTag.c,v 1.5 2000/01/06 02:18:59 hobbs Exp $
*/
#include "default.h"
@@ -19,32 +19,6 @@
#include "tkInt.h"
#include "tkText.h"
-/*
- * Information used for parsing tag configuration information:
- */
-
-static Tk_CustomOption stateOption = {
- (Tk_OptionParseProc *) TkStateParseProc,
- TkStatePrintProc, (ClientData) 2
-};
-
-/* The "-elide" is only provided for compatibility with TkMan 2.0,
- * but might be removed in the future. The option "-state" provides
- * the same functionality and is preferred.
- */
-
-static int ElideParseProc _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, Tk_Window tkwin,
- CONST char *value, char *widgRec, int offset));
-static char * ElidePrintProc _ANSI_ARGS_((ClientData clientData,
- Tk_Window tkwin, char *widgRec, int offset,
- Tcl_FreeProc **freeProcPtr));
-
-static Tk_CustomOption elideOption = {
- (Tk_OptionParseProc *) ElideParseProc,
- ElidePrintProc, (ClientData) 0
-};
-
static Tk_ConfigSpec tagConfigSpecs[] = {
{TK_CONFIG_BORDER, "-background", (char *) NULL, (char *) NULL,
(char *) NULL, Tk_Offset(TkTextTag, border), TK_CONFIG_NULL_OK},
@@ -52,10 +26,10 @@ static Tk_ConfigSpec tagConfigSpecs[] = {
(char *) NULL, Tk_Offset(TkTextTag, bgStipple), TK_CONFIG_NULL_OK},
{TK_CONFIG_STRING, "-borderwidth", (char *) NULL, (char *) NULL,
"0", Tk_Offset(TkTextTag, bdString),
- TK_CONFIG_DONT_SET_DEFAULT|TK_CONFIG_NULL_OK},
- {TK_CONFIG_CUSTOM, "-elide", (char *) NULL, (char *) NULL,
- (char *) NULL, Tk_Offset(TkTextTag, state),
- TK_CONFIG_NULL_OK, &elideOption},
+ TK_CONFIG_DONT_SET_DEFAULT|TK_CONFIG_NULL_OK},
+ {TK_CONFIG_STRING, "-elide", (char *) NULL, (char *) NULL,
+ "0", Tk_Offset(TkTextTag, elideString),
+ TK_CONFIG_DONT_SET_DEFAULT|TK_CONFIG_NULL_OK},
{TK_CONFIG_BITMAP, "-fgstipple", (char *) NULL, (char *) NULL,
(char *) NULL, Tk_Offset(TkTextTag, fgStipple), TK_CONFIG_NULL_OK},
{TK_CONFIG_FONT, "-font", (char *) NULL, (char *) NULL,
@@ -83,9 +57,6 @@ static Tk_ConfigSpec tagConfigSpecs[] = {
(char *) NULL, Tk_Offset(TkTextTag, spacing2String), TK_CONFIG_NULL_OK},
{TK_CONFIG_STRING, "-spacing3", (char *) NULL, (char *) NULL,
(char *) NULL, Tk_Offset(TkTextTag, spacing3String), TK_CONFIG_NULL_OK},
- {TK_CONFIG_CUSTOM, "-state", (char *) NULL, (char *) NULL,
- (char *) NULL, Tk_Offset(TkTextTag, state),
- TK_CONFIG_NULL_OK, &stateOption},
{TK_CONFIG_STRING, "-tabs", (char *) NULL, (char *) NULL,
(char *) NULL, Tk_Offset(TkTextTag, tabString), TK_CONFIG_NULL_OK},
{TK_CONFIG_STRING, "-underline", (char *) NULL, (char *) NULL,
@@ -419,6 +390,12 @@ TkTextTagCmd(textPtr, interp, argc, argv)
return TCL_ERROR;
}
}
+ if (tagPtr->elideString != NULL) {
+ if (Tcl_GetBoolean(interp, tagPtr->elideString,
+ &tagPtr->elide) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ }
/*
* If the "sel" tag was changed, be sure to mirror information
@@ -451,7 +428,7 @@ TkTextTagCmd(textPtr, interp, argc, argv)
|| (tagPtr->spacing3String != NULL)
|| (tagPtr->tabString != NULL)
|| (tagPtr->underlineString != NULL)
- || (tagPtr->state != TK_STATE_NULL)
+ || (tagPtr->elideString != NULL)
|| (tagPtr->wrapMode != TEXT_WRAPMODE_NULL)) {
tagPtr->affectsDisplay = 1;
}
@@ -844,7 +821,8 @@ TkTextCreateTag(textPtr, tagName)
tagPtr->tabArrayPtr = NULL;
tagPtr->underlineString = NULL;
tagPtr->underline = 0;
- tagPtr->state = TK_STATE_NULL;
+ tagPtr->elideString = NULL;
+ tagPtr->elide = 0;
tagPtr->wrapMode = TEXT_WRAPMODE_NULL;
tagPtr->affectsDisplay = 0;
textPtr->numTags++;
@@ -1408,89 +1386,3 @@ TkTextPickCurrent(textPtr, eventPtr)
ckfree((char *) copyArrayPtr);
}
}
-
-/*
- *--------------------------------------------------------------
- *
- * ElideParseProc --
- *
- * This procedure is invoked during option processing to handle
- * the "-elide" option. This option is an obsolete equivalent
- * of the "-state" option. It is only added for compatibility
- * with TkMan 2.0, but will be removed in the future.
- *
- * Results:
- * A standard Tcl return value.
- *
- * Side effects:
- * The state for a given item gets replaced by the state
- * indicated in the value argument.
- *
- *--------------------------------------------------------------
- */
-
-static int
-ElideParseProc(clientData, interp, tkwin, value, widgRec, offset)
- ClientData clientData; /* some flags.*/
- Tcl_Interp *interp; /* Used for reporting errors. */
- Tk_Window tkwin; /* Window containing canvas widget. */
- CONST char *value; /* Value of option. */
- char *widgRec; /* Pointer to record for item. */
- int offset; /* Offset into item. */
-{
- int b;
- register Tk_State *statePtr = (Tk_State *) (widgRec + offset);
-
- if(value == NULL || *value == 0) {
- *statePtr = TK_STATE_NULL;
- return TCL_OK;
- }
- if (Tcl_GetBoolean(interp, (char *) value, &b) != TCL_OK) {
- *statePtr = TK_STATE_NULL;
- return TCL_ERROR;
- }
- *statePtr = b?TK_STATE_HIDDEN:TK_STATE_NORMAL;
- return TCL_OK;
-}
-/*
- *--------------------------------------------------------------
- *
- * ElidePrintProc --
- *
- * This procedure is invoked by the Tk configuration code
- * to produce a printable string for the "-elide"
- * configuration option.
- *
- * Results:
- * The return value is a string describing the state for
- * the item referred to by "widgRec". In addition, *freeProcPtr
- * is filled in with the address of a procedure to call to free
- * the result string when it's no longer needed (or NULL to
- * indicate that the string doesn't need to be freed).
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-static char *
-ElidePrintProc(clientData, tkwin, widgRec, offset, freeProcPtr)
- ClientData clientData; /* Ignored. */
- Tk_Window tkwin; /* Window containing text widget. */
- char *widgRec; /* Pointer to record for item. */
- int offset; /* Offset into item. */
- Tcl_FreeProc **freeProcPtr; /* Pointer to variable to fill in with
- * information about how to reclaim
- * storage for return string. */
-{
- register Tk_State *statePtr = (Tk_State *) (widgRec + offset);
-
- if (*statePtr==TK_STATE_HIDDEN) {
- return "1";
- } else if (*statePtr==TK_STATE_NULL) {
- return "";
- } else {
- return "0";
- }
-}