summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorvincentdarley <vincentdarley>2003-11-15 02:33:47 (GMT)
committervincentdarley <vincentdarley>2003-11-15 02:33:47 (GMT)
commitb741ab86e1086cfbf3dcbd567e7f8e137462a69c (patch)
treeba9e32dbe2f68359525d8a6970e094993a73e5c4 /generic
parent39fcc54153d2d1c3f582c7801f4361e39b85cbff (diff)
downloadtk-b741ab86e1086cfbf3dcbd567e7f8e137462a69c.zip
tk-b741ab86e1086cfbf3dcbd567e7f8e137462a69c.tar.gz
tk-b741ab86e1086cfbf3dcbd567e7f8e137462a69c.tar.bz2
fix two more old text widget bugs
Diffstat (limited to 'generic')
-rw-r--r--generic/tkText.c11
-rw-r--r--generic/tkText.h4
-rw-r--r--generic/tkTextDisp.c115
-rw-r--r--generic/tkTextTag.c91
-rw-r--r--generic/tkTextWind.c19
5 files changed, 138 insertions, 102 deletions
diff --git a/generic/tkText.c b/generic/tkText.c
index dc738a1..133d88d 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.43 2003/11/12 17:38:48 vincentdarley Exp $
+ * RCS: @(#) $Id: tkText.c,v 1.44 2003/11/15 02:33:50 vincentdarley Exp $
*/
#include "default.h"
@@ -451,7 +451,7 @@ Tk_TextObjCmd(clientData, interp, objc, objv)
textPtr->selBorderWidth = 0;
textPtr->selBorderWidthPtr = NULL;
textPtr->selFgColorPtr = NULL;
- textPtr->selTagPtr = TkTextCreateTag(textPtr, "sel");
+ textPtr->selTagPtr = TkTextCreateTag(textPtr, "sel", NULL);
textPtr->selTagPtr->reliefString =
(char *) ckalloc(sizeof(DEF_TEXT_SELECT_RELIEF));
strcpy(textPtr->selTagPtr->reliefString, DEF_TEXT_SELECT_RELIEF);
@@ -1778,7 +1778,7 @@ TextEventProc(clientData, eventPtr)
|| (textPtr->prevHeight != Tk_Height(textPtr->tkwin))) {
int mask = 0;
if (textPtr->prevWidth != Tk_Width(textPtr->tkwin)) {
- mask = 1;
+ mask = TK_TEXT_LINE_GEOMETRY;
}
TkTextRelayoutWindow(textPtr, mask);
textPtr->prevWidth = Tk_Width(textPtr->tkwin);
@@ -2690,8 +2690,9 @@ TextInsertCmd(textPtr, interp, objc, objv, indexPtr, noViewUpdate)
for (i = 0; i < numTags; i++) {
TkBTreeTag(&index1, &index2,
- TkTextCreateTag(textPtr,
- Tcl_GetString(tagNamePtrs[i])), 1);
+ TkTextCreateTag(textPtr,
+ Tcl_GetString(tagNamePtrs[i]), NULL),
+ 1);
}
index1 = index2;
}
diff --git a/generic/tkText.h b/generic/tkText.h
index 6ca5084..ee19ad2 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.20 2003/11/12 17:19:18 vincentdarley Exp $
+ * RCS: @(#) $Id: tkText.h,v 1.21 2003/11/15 02:33:50 vincentdarley Exp $
*/
#ifndef _TKTEXT
@@ -951,7 +951,7 @@ EXTERN void TkTextEmbWinDisplayProc _ANSI_ARGS_((
int lineHeight, int baseline, Display *display,
Drawable dst, int screenY));
EXTERN TkTextTag * TkTextCreateTag _ANSI_ARGS_((TkText *textPtr,
- CONST char *tagName));
+ CONST char *tagName, int *newTag));
EXTERN void TkTextFreeDInfo _ANSI_ARGS_((TkText *textPtr));
EXTERN void TkTextFreeTag _ANSI_ARGS_((TkText *textPtr,
TkTextTag *tagPtr));
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c
index e47a19d..e1a3fee 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.28 2003/11/14 17:21:03 dkf Exp $
+ * RCS: @(#) $Id: tkTextDisp.c,v 1.29 2003/11/15 02:33:50 vincentdarley Exp $
*/
#include "tkPort.h"
@@ -232,10 +232,9 @@ typedef struct TextDInfo {
* Information used for scrolling:
*/
- int newXByteOffset; /* Desired x scroll position, measured as the
- * number of average-size characters off-screen
- * to the left for a line with no left
- * margin. */
+ int newXPixelOffset; /* Desired x scroll position, measured as the
+ * number of pixels off-screen to the left
+ * for a line with no left margin. */
int curXPixelOffset; /* Actual x scroll position, measured as the
* number of pixels off-screen to the left. */
int maxLength; /* Length in pixels of longest line that's
@@ -255,9 +254,8 @@ typedef struct TextDInfo {
* The following information is used to implement scanning:
*/
- int scanMarkIndex; /* Byte index of character that was at the
- * left edge of the window when the scan
- * started. */
+ int scanMarkXPixel; /* Pixel index of left edge of the window
+ * when the scan started. */
int scanMarkX; /* X-position of mouse at time scan started. */
int scanTotalYScroll; /* Total scrolling (in screen pixels) that has
* occurred since scanMarkY was set. */
@@ -495,14 +493,14 @@ TkTextCreateDInfo(textPtr)
dInfoPtr->scrollGC = Tk_GetGC(textPtr->tkwin, GCGraphicsExposures,
&gcValues);
dInfoPtr->topOfEof = 0;
- dInfoPtr->newXByteOffset = 0;
+ dInfoPtr->newXPixelOffset = 0;
dInfoPtr->curXPixelOffset = 0;
dInfoPtr->maxLength = 0;
dInfoPtr->xScrollFirst = -1;
dInfoPtr->xScrollLast = -1;
dInfoPtr->yScrollFirst = -1;
dInfoPtr->yScrollLast = -1;
- dInfoPtr->scanMarkIndex = 0;
+ dInfoPtr->scanMarkXPixel = 0;
dInfoPtr->scanMarkX = 0;
dInfoPtr->scanTotalYScroll = 0;
dInfoPtr->scanMarkY = 0;
@@ -1861,15 +1859,29 @@ UpdateDisplayInfo(textPtr)
dInfoPtr->maxLength = dlPtr->length;
}
}
- maxOffset = (dInfoPtr->maxLength - (dInfoPtr->maxX - dInfoPtr->x)
- + textPtr->charWidth - 1)/textPtr->charWidth;
- if (dInfoPtr->newXByteOffset > maxOffset) {
- dInfoPtr->newXByteOffset = maxOffset;
+ maxOffset = dInfoPtr->maxLength - (dInfoPtr->maxX - dInfoPtr->x);
+
+ xPixelOffset = dInfoPtr->newXPixelOffset;
+ if (xPixelOffset > maxOffset) {
+ xPixelOffset = maxOffset;
+ }
+ if (xPixelOffset < 0) {
+ xPixelOffset = 0;
}
- if (dInfoPtr->newXByteOffset < 0) {
- dInfoPtr->newXByteOffset = 0;
+
+ /*
+ * Here's a problem: see the tests textDisp-29.2.1-4
+ *
+ * If the widget is being created, but has not yet been configured
+ * it will have a maxY of 1 above, and we we won't have examined
+ * all the lines (just the first line, in fact), and so maxOffset
+ * will not be a true reflection of the widget's lines. Therefore
+ * we must not overwrite the original newXPixelOffset in this case.
+ */
+ if (!(((Tk_FakeWin *) (textPtr->tkwin))->flags & TK_NEED_CONFIG_NOTIFY)) {
+ dInfoPtr->newXPixelOffset = xPixelOffset;
}
- xPixelOffset = dInfoPtr->newXByteOffset * textPtr->charWidth;
+
if (xPixelOffset != dInfoPtr->curXPixelOffset) {
dInfoPtr->curXPixelOffset = xPixelOffset;
for (dlPtr = dInfoPtr->dLinePtr; dlPtr != NULL;
@@ -2689,7 +2701,7 @@ TkTextInvalidateLineMetrics(textPtr, linePtr, lineCount, action)
fromLine = TkBTreeLineIndex(linePtr);
/*
- * Invalid the height calculations of each line in the
+ * Invalidate the height calculations of each line in the
* given range.
*/
linePtr->pixelCalculationEpoch = 0;
@@ -3923,7 +3935,7 @@ TkTextRedrawTag(textPtr, index1Ptr, index2Ptr, tagPtr, withTag)
lineCount -= TkBTreeLineIndex(startLine);
}
TkTextInvalidateLineMetrics(textPtr, startLine, lineCount,
- TK_TEXT_INVALIDATE_ONLY);
+ TK_TEXT_INVALIDATE_ONLY);
}
/*
@@ -4124,6 +4136,9 @@ TkTextRelayoutWindow(textPtr, mask)
if (dInfoPtr->maxX <= dInfoPtr->x) {
dInfoPtr->maxX = dInfoPtr->x + 1;
}
+ /*
+ * This is the only place where dInfoPtr->maxY is set.
+ */
dInfoPtr->maxY = Tk_Height(textPtr->tkwin) - textPtr->highlightWidth
- textPtr->borderWidth - textPtr->padY;
if (dInfoPtr->maxY <= dInfoPtr->y) {
@@ -4630,21 +4645,17 @@ TkTextSeeCmd(textPtr, interp, objc, objv)
oneThird = lineWidth/3;
if (delta < 0) {
if (delta < -oneThird) {
- dInfoPtr->newXByteOffset = (x - lineWidth/2)
- / textPtr->charWidth;
+ dInfoPtr->newXPixelOffset = (x - lineWidth/2);
} else {
- dInfoPtr->newXByteOffset -= ((-delta) + textPtr->charWidth - 1)
- / textPtr->charWidth;
+ dInfoPtr->newXPixelOffset -= ((-delta) );
}
} else {
delta -= (lineWidth - width);
if (delta > 0) {
if (delta > oneThird) {
- dInfoPtr->newXByteOffset = (x - lineWidth/2)
- / textPtr->charWidth;
+ dInfoPtr->newXPixelOffset = (x - lineWidth/2);
} else {
- dInfoPtr->newXByteOffset +=
- (delta+textPtr->charWidth-1) / textPtr->charWidth;
+ dInfoPtr->newXPixelOffset += (delta );
}
} else {
return TCL_OK;
@@ -4699,34 +4710,36 @@ TkTextXviewCmd(textPtr, interp, objc, objv)
return TCL_OK;
}
- newOffset = dInfoPtr->newXByteOffset;
- type = Tk_GetScrollInfoObj(interp, objc, objv, &fraction, &count);
+ newOffset = dInfoPtr->newXPixelOffset;
+ type = TextGetScrollInfoObj(interp, textPtr, objc, objv,
+ &fraction, &count);
switch (type) {
- case TK_SCROLL_ERROR:
+ case TKTEXT_SCROLL_ERROR:
return TCL_ERROR;
- case TK_SCROLL_MOVETO:
+ case TKTEXT_SCROLL_MOVETO:
if (fraction > 1.0) {
fraction = 1.0;
}
if (fraction < 0) {
fraction = 0;
}
- newOffset = (int) (((fraction * dInfoPtr->maxLength)
- / textPtr->charWidth) + 0.5);
+ newOffset = (int) (fraction * dInfoPtr->maxLength + 0.5);
break;
- case TK_SCROLL_PAGES:
+ case TKTEXT_SCROLL_PAGES:
charsPerPage = (dInfoPtr->maxX-dInfoPtr->x)/textPtr->charWidth - 2;
if (charsPerPage < 1) {
charsPerPage = 1;
}
- newOffset += charsPerPage * count;
+ newOffset += charsPerPage * count * textPtr->charWidth;
+ break;
+ case TKTEXT_SCROLL_UNITS:
+ newOffset += count * textPtr->charWidth;
break;
- case TK_SCROLL_UNITS:
+ case TKTEXT_SCROLL_PIXELS:
newOffset += count;
break;
}
-
- dInfoPtr->newXByteOffset = newOffset;
+ dInfoPtr->newXPixelOffset = newOffset;
dInfoPtr->flags |= DINFO_OUT_OF_DATE;
if (!(dInfoPtr->flags & REDRAW_PENDING)) {
dInfoPtr->flags |= REDRAW_PENDING;
@@ -5106,7 +5119,7 @@ TkTextScanCmd(textPtr, interp, objc, objv)
{
TextDInfo *dInfoPtr = textPtr->dInfoPtr;
TkTextIndex index;
- int c, x, y, totalScroll, newByte, maxByte, gain=10;
+ int c, x, y, totalScroll, gain=10;
size_t length;
if ((objc != 5) && (objc != 6)) {
@@ -5128,6 +5141,8 @@ TkTextScanCmd(textPtr, interp, objc, objv)
c = Tcl_GetString(objv[2])[0];
length = strlen(Tcl_GetString(objv[2]));
if (c=='d' && strncmp(Tcl_GetString(objv[2]), "dragto", length)==0) {
+ int newX, maxX;
+
/*
* Amplify the difference between the current position and the
* mark position to compute how much the view should shift, then
@@ -5140,20 +5155,18 @@ TkTextScanCmd(textPtr, interp, objc, objv)
* moving again).
*/
- newByte = dInfoPtr->scanMarkIndex + (gain*(dInfoPtr->scanMarkX - x))
- / (textPtr->charWidth);
- maxByte = 1 + (dInfoPtr->maxLength - (dInfoPtr->maxX - dInfoPtr->x)
- + textPtr->charWidth - 1)/textPtr->charWidth;
- if (newByte < 0) {
- newByte = 0;
- dInfoPtr->scanMarkIndex = 0;
+ newX = dInfoPtr->scanMarkXPixel + gain*(dInfoPtr->scanMarkX - x);
+ maxX = 1 + dInfoPtr->maxLength - (dInfoPtr->maxX - dInfoPtr->x);
+ if (newX < 0) {
+ newX = 0;
+ dInfoPtr->scanMarkXPixel = 0;
dInfoPtr->scanMarkX = x;
- } else if (newByte > maxByte) {
- newByte = maxByte;
- dInfoPtr->scanMarkIndex = maxByte;
+ } else if (newX > maxX) {
+ newX = maxX;
+ dInfoPtr->scanMarkXPixel = maxX;
dInfoPtr->scanMarkX = x;
}
- dInfoPtr->newXByteOffset = newByte;
+ dInfoPtr->newXPixelOffset = newX;
totalScroll = gain*(dInfoPtr->scanMarkY - y);
if (totalScroll != dInfoPtr->scanTotalYScroll) {
@@ -5167,7 +5180,7 @@ TkTextScanCmd(textPtr, interp, objc, objv)
}
}
} else if (c=='m' && strncmp(Tcl_GetString(objv[2]), "mark", length)==0) {
- dInfoPtr->scanMarkIndex = dInfoPtr->newXByteOffset;
+ dInfoPtr->scanMarkXPixel = dInfoPtr->newXPixelOffset;
dInfoPtr->scanMarkX = x;
dInfoPtr->scanTotalYScroll = 0;
dInfoPtr->scanMarkY = y;
diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c
index dc9ae86..c56b217 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.13 2003/11/12 17:19:18 vincentdarley Exp $
+ * RCS: @(#) $Id: tkTextTag.c,v 1.14 2003/11/15 02:33:51 vincentdarley Exp $
*/
#include "default.h"
@@ -160,7 +160,7 @@ TkTextTagCmd(textPtr, interp, objc, objv)
"tagName index1 ?index2 index1 index2 ...?");
return TCL_ERROR;
}
- tagPtr = TkTextCreateTag(textPtr, Tcl_GetString(objv[3]));
+ tagPtr = TkTextCreateTag(textPtr, Tcl_GetString(objv[3]), NULL);
for (i = 4; i < objc; i += 2) {
if (TkTextGetObjIndex(interp, textPtr, objv[i],
&index1) != TCL_OK) {
@@ -176,7 +176,8 @@ TkTextTagCmd(textPtr, interp, objc, objv)
}
} else {
index2 = index1;
- TkTextIndexForwChars(NULL,&index2, 1, &index2, COUNT_INDICES);
+ TkTextIndexForwChars(NULL,&index2, 1, &index2,
+ COUNT_INDICES);
}
if (tagPtr->affectsDisplay) {
@@ -208,11 +209,13 @@ TkTextTagCmd(textPtr, interp, objc, objv)
memset((VOID *) &event, 0, sizeof(event));
event.xany.type = VirtualEvent;
- event.xany.serial = NextRequest(Tk_Display(textPtr->tkwin));
+ event.xany.serial =
+ NextRequest(Tk_Display(textPtr->tkwin));
event.xany.send_event = False;
event.xany.window = Tk_WindowId(textPtr->tkwin);
event.xany.display = Tk_Display(textPtr->tkwin);
- ((XVirtualEvent *) &event)->name = Tk_GetUid("Selection");
+ ((XVirtualEvent *) &event)->name =
+ Tk_GetUid("Selection");
Tk_HandleEvent(&event);
if (addTag && textPtr->exportSelection
@@ -229,10 +232,11 @@ TkTextTagCmd(textPtr, interp, objc, objv)
}
case TAG_BIND: {
if ((objc < 4) || (objc > 6)) {
- Tcl_WrongNumArgs(interp, 3, objv, "tagName ?sequence? ?command?");
+ Tcl_WrongNumArgs(interp, 3, objv,
+ "tagName ?sequence? ?command?");
return TCL_ERROR;
}
- tagPtr = TkTextCreateTag(textPtr, Tcl_GetString(objv[3]));
+ tagPtr = TkTextCreateTag(textPtr, Tcl_GetString(objv[3]), NULL);
/*
* Make a binding table if the widget doesn't already have
@@ -271,8 +275,8 @@ TkTextTagCmd(textPtr, interp, objc, objv)
(ClientData) tagPtr, Tcl_GetString(objv[4]));
Tcl_ResetResult(interp);
Tcl_AppendResult(interp, "requested illegal events; ",
- "only key, button, motion, enter, leave, and virtual ",
- "events may be used", (char *) NULL);
+ "only key, button, motion, enter, leave, and virtual ",
+ "events may be used", (char *) NULL);
return TCL_ERROR;
}
} else if (objc == 5) {
@@ -315,7 +319,8 @@ TkTextTagCmd(textPtr, interp, objc, objv)
return TCL_ERROR;
}
objPtr = Tk_GetOptionValue(interp, (char *) tagPtr,
- tagPtr->optionTable, objv[4], textPtr->tkwin);
+ tagPtr->optionTable, objv[4],
+ textPtr->tkwin);
if (objPtr == NULL) {
return TCL_ERROR;
} else {
@@ -326,11 +331,13 @@ TkTextTagCmd(textPtr, interp, objc, objv)
break;
}
case TAG_CONFIGURE: {
+ int newTag;
if (objc < 4) {
- Tcl_WrongNumArgs(interp, 3, objv, "tagName ?option? ?value? ?option value ...?");
+ Tcl_WrongNumArgs(interp, 3, objv,
+ "tagName ?option? ?value? ?option value ...?");
return TCL_ERROR;
}
- tagPtr = TkTextCreateTag(textPtr, Tcl_GetString(objv[3]));
+ tagPtr = TkTextCreateTag(textPtr, Tcl_GetString(objv[3]), &newTag);
if (objc <= 5) {
Tcl_Obj* objPtr = Tk_GetOptionInfo(interp, (char *) tagPtr,
tagPtr->optionTable,
@@ -373,18 +380,19 @@ TkTextTagCmd(textPtr, interp, objc, objv)
}
if (tagPtr->lMargin1String != NULL) {
if (Tk_GetPixels(interp, textPtr->tkwin,
- tagPtr->lMargin1String, &tagPtr->lMargin1) != TCL_OK) {
+ tagPtr->lMargin1String, &tagPtr->lMargin1) != TCL_OK) {
return TCL_ERROR;
}
}
if (tagPtr->lMargin2String != NULL) {
if (Tk_GetPixels(interp, textPtr->tkwin,
- tagPtr->lMargin2String, &tagPtr->lMargin2) != TCL_OK) {
+ tagPtr->lMargin2String, &tagPtr->lMargin2) != TCL_OK) {
return TCL_ERROR;
}
}
if (tagPtr->offsetString != NULL) {
- if (Tk_GetPixels(interp, textPtr->tkwin, tagPtr->offsetString,
+ if (Tk_GetPixels(interp, textPtr->tkwin,
+ tagPtr->offsetString,
&tagPtr->offset) != TCL_OK) {
return TCL_ERROR;
}
@@ -397,13 +405,13 @@ TkTextTagCmd(textPtr, interp, objc, objv)
}
if (tagPtr->rMarginString != NULL) {
if (Tk_GetPixels(interp, textPtr->tkwin,
- tagPtr->rMarginString, &tagPtr->rMargin) != TCL_OK) {
+ tagPtr->rMarginString, &tagPtr->rMargin) != TCL_OK) {
return TCL_ERROR;
}
}
if (tagPtr->spacing1String != NULL) {
if (Tk_GetPixels(interp, textPtr->tkwin,
- tagPtr->spacing1String, &tagPtr->spacing1) != TCL_OK) {
+ tagPtr->spacing1String, &tagPtr->spacing1) != TCL_OK) {
return TCL_ERROR;
}
if (tagPtr->spacing1 < 0) {
@@ -412,7 +420,7 @@ TkTextTagCmd(textPtr, interp, objc, objv)
}
if (tagPtr->spacing2String != NULL) {
if (Tk_GetPixels(interp, textPtr->tkwin,
- tagPtr->spacing2String, &tagPtr->spacing2) != TCL_OK) {
+ tagPtr->spacing2String, &tagPtr->spacing2) != TCL_OK) {
return TCL_ERROR;
}
if (tagPtr->spacing2 < 0) {
@@ -421,7 +429,7 @@ TkTextTagCmd(textPtr, interp, objc, objv)
}
if (tagPtr->spacing3String != NULL) {
if (Tk_GetPixels(interp, textPtr->tkwin,
- tagPtr->spacing3String, &tagPtr->spacing3) != TCL_OK) {
+ tagPtr->spacing3String, &tagPtr->spacing3) != TCL_OK) {
return TCL_ERROR;
}
if (tagPtr->spacing3 < 0) {
@@ -492,14 +500,15 @@ TkTextTagCmd(textPtr, interp, objc, objv)
|| (tagPtr->underlineString != NULL)) {
tagPtr->affectsDisplay = 1;
}
- /*
- * This line is totally unnecessary if this is a new
- * tag, since it can't possibly have been applied to
- * anything yet. We might wish to test for that
- * case specially
- */
- TkTextRedrawTag(textPtr, (TkTextIndex *) NULL,
- (TkTextIndex *) NULL, tagPtr, 1);
+ if (!newTag) {
+ /*
+ * This line is not necessary if this is a new tag,
+ * since it can't possibly have been applied to
+ * anything yet.
+ */
+ TkTextRedrawTag(textPtr, (TkTextIndex *) NULL,
+ (TkTextIndex *) NULL, tagPtr, 1);
+ }
return result;
}
break;
@@ -512,7 +521,8 @@ TkTextTagCmd(textPtr, interp, objc, objv)
return TCL_ERROR;
}
for (i = 3; i < objc; i++) {
- hPtr = Tcl_FindHashEntry(&textPtr->tagTable, Tcl_GetString(objv[i]));
+ hPtr = Tcl_FindHashEntry(&textPtr->tagTable,
+ Tcl_GetString(objv[i]));
if (hPtr == NULL) {
continue;
}
@@ -525,8 +535,9 @@ TkTextTagCmd(textPtr, interp, objc, objv)
(TkTextIndex *) NULL, tagPtr, 1);
}
TkTextMakeByteIndex(textPtr->tree, 0, 0, &first);
- TkTextMakeByteIndex(textPtr->tree, TkBTreeNumLines(textPtr->tree),
- 0, &last),
+ TkTextMakeByteIndex(textPtr->tree,
+ TkBTreeNumLines(textPtr->tree),
+ 0, &last),
TkBTreeTag(&first, &last, tagPtr, 0);
if (tagPtr == textPtr->selTagPtr) {
@@ -589,8 +600,9 @@ TkTextTagCmd(textPtr, interp, objc, objv)
prio = 0;
}
ChangeTagPriority(textPtr, tagPtr, prio);
- TkTextRedrawTag(textPtr, (TkTextIndex *) NULL, (TkTextIndex *) NULL,
- tagPtr, 1);
+ TkTextRedrawTag(textPtr, (TkTextIndex *) NULL,
+ (TkTextIndex *) NULL,
+ tagPtr, 1);
break;
}
case TAG_NAMES: {
@@ -608,7 +620,8 @@ TkTextTagCmd(textPtr, interp, objc, objv)
arrayPtr = (TkTextTag **) ckalloc((unsigned)
(textPtr->numTags * sizeof(TkTextTag *)));
- for (i = 0, hPtr = Tcl_FirstHashEntry(&textPtr->tagTable, &search);
+ for (i = 0, hPtr = Tcl_FirstHashEntry(&textPtr->tagTable,
+ &search);
hPtr != NULL; i++, hPtr = Tcl_NextHashEntry(&search)) {
arrayPtr[i] = (TkTextTag *) Tcl_GetHashValue(hPtr);
}
@@ -747,8 +760,9 @@ TkTextTagCmd(textPtr, interp, objc, objv)
}
if (tSearch.segPtr->typePtr == &tkTextToggleOnType) {
TkTextPrintIndex(&tSearch.curIndex, position1);
- TkTextMakeByteIndex(textPtr->tree, TkBTreeNumLines(textPtr->tree),
- 0, &last);
+ TkTextMakeByteIndex(textPtr->tree,
+ TkBTreeNumLines(textPtr->tree),
+ 0, &last);
TkBTreeStartSearch(&tSearch.curIndex, &last, tagPtr, &tSearch);
TkBTreeNextTag(&tSearch);
TkTextPrintIndex(&tSearch.curIndex, position2);
@@ -844,15 +858,20 @@ TkTextTagCmd(textPtr, interp, objc, objv)
*/
TkTextTag *
-TkTextCreateTag(textPtr, tagName)
+TkTextCreateTag(textPtr, tagName, newTag)
TkText *textPtr; /* Widget in which tag is being used. */
CONST char *tagName; /* Name of desired tag. */
+ int *newTag; /* If non-NULL, then return 1 if new,
+ * or 0 if already exists. */
{
register TkTextTag *tagPtr;
Tcl_HashEntry *hPtr;
int new;
hPtr = Tcl_CreateHashEntry(&textPtr->tagTable, tagName, &new);
+ if (newTag != NULL) {
+ *newTag = new;
+ }
if (!new) {
return (TkTextTag *) Tcl_GetHashValue(hPtr);
}
diff --git a/generic/tkTextWind.c b/generic/tkTextWind.c
index dd829a8..ab0a4e9 100644
--- a/generic/tkTextWind.c
+++ b/generic/tkTextWind.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: tkTextWind.c,v 1.9 2003/11/07 15:36:27 vincentdarley Exp $
+ * RCS: @(#) $Id: tkTextWind.c,v 1.10 2003/11/15 02:33:51 vincentdarley Exp $
*/
#include "tk.h"
@@ -870,18 +870,21 @@ TkTextEmbWinDisplayProc(chunkPtr, x, y, lineHeight, baseline,
TkTextSegment *ewPtr = (TkTextSegment *) chunkPtr->clientData;
int lineX, windowX, windowY, width, height;
Tk_Window tkwin;
-
+ TkText *textPtr;
+
tkwin = ewPtr->body.ew.tkwin;
if (tkwin == NULL) {
return;
}
+
+ textPtr = ewPtr->body.ew.textPtr;
if ((x + chunkPtr->width) <= 0) {
/*
* The window is off-screen; just unmap it.
*/
- if (ewPtr->body.ew.textPtr->tkwin != Tk_Parent(tkwin)) {
- Tk_UnmaintainGeometry(tkwin, ewPtr->body.ew.textPtr->tkwin);
+ if (textPtr->tkwin != Tk_Parent(tkwin)) {
+ Tk_UnmaintainGeometry(tkwin, textPtr->tkwin);
} else {
Tk_UnmapWindow(tkwin);
}
@@ -894,10 +897,10 @@ TkTextEmbWinDisplayProc(chunkPtr, x, y, lineHeight, baseline,
*/
EmbWinBboxProc(chunkPtr, 0, screenY, lineHeight, baseline, &lineX,
- &windowY, &width, &height);
+ &windowY, &width, &height);
windowX = lineX - chunkPtr->x + x;
- if (ewPtr->body.ew.textPtr->tkwin == Tk_Parent(tkwin)) {
+ if (textPtr->tkwin == Tk_Parent(tkwin)) {
if ((windowX != Tk_X(tkwin)) || (windowY != Tk_Y(tkwin))
|| (Tk_ReqWidth(tkwin) != Tk_Width(tkwin))
|| (height != Tk_Height(tkwin))) {
@@ -905,8 +908,8 @@ TkTextEmbWinDisplayProc(chunkPtr, x, y, lineHeight, baseline,
}
Tk_MapWindow(tkwin);
} else {
- Tk_MaintainGeometry(tkwin, ewPtr->body.ew.textPtr->tkwin,
- windowX, windowY, width, height);
+ Tk_MaintainGeometry(tkwin, textPtr->tkwin,
+ windowX, windowY, width, height);
}
/*