summaryrefslogtreecommitdiffstats
path: root/generic/tkTextDisp.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tkTextDisp.c')
-rw-r--r--generic/tkTextDisp.c634
1 files changed, 305 insertions, 329 deletions
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c
index 5bd69a3..2516e1c 100644
--- a/generic/tkTextDisp.c
+++ b/generic/tkTextDisp.c
@@ -415,8 +415,8 @@ typedef struct TextDInfo {
typedef struct CharInfo {
int numBytes; /* Number of bytes to display. */
- char chars[1]; /* UTF characters to display. Actual size will
- * be numBytes, not 1. THIS MUST BE THE LAST
+ char chars[4]; /* UTF characters to display. Actual size will
+ * be numBytes, not 4. THIS MUST BE THE LAST
* FIELD IN THE STRUCTURE. */
} CharInfo;
@@ -446,7 +446,6 @@ typedef struct BaseCharInfo {
* LayoutDLine(). */
} BaseCharInfo;
-/* TODO: Thread safety */
static TkTextDispChunk *baseCharChunkPtr = NULL;
#endif /* TK_LAYOUT_WITH_BASE_CHUNKS */
@@ -543,23 +542,23 @@ static void DisplayDLine(TkText *textPtr, DLine *dlPtr,
static void DisplayLineBackground(TkText *textPtr, DLine *dlPtr,
DLine *prevPtr, Pixmap pixmap);
static void DisplayText(ClientData clientData);
-static DLine * FindDLine(DLine *dlPtr, const TkTextIndex *indexPtr);
+static DLine * FindDLine(DLine *dlPtr, CONST TkTextIndex *indexPtr);
static void FreeDLines(TkText *textPtr, DLine *firstPtr,
DLine *lastPtr, int action);
static void FreeStyle(TkText *textPtr, TextStyle *stylePtr);
-static TextStyle * GetStyle(TkText *textPtr, const TkTextIndex *indexPtr);
+static TextStyle * GetStyle(TkText *textPtr, CONST TkTextIndex *indexPtr);
static void GetXView(Tcl_Interp *interp, TkText *textPtr,
int report);
static void GetYView(Tcl_Interp *interp, TkText *textPtr,
int report);
static int GetYPixelCount(TkText *textPtr, DLine *dlPtr);
static DLine * LayoutDLine(TkText *textPtr,
- const TkTextIndex *indexPtr);
-static int MeasureChars(Tk_Font tkfont, const char *source,
+ CONST TkTextIndex *indexPtr);
+static int MeasureChars(Tk_Font tkfont, CONST char *source,
int maxBytes, int rangeStart, int rangeLength,
int startX, int maxX, int flags, int *nextXPtr);
static void MeasureUp(TkText *textPtr,
- const TkTextIndex *srcPtr, int distance,
+ CONST TkTextIndex *srcPtr, int distance,
TkTextIndex *dstPtr, int *overlap);
static int NextTabStop(Tk_Font tkfont, int x, int tabOrigin);
static void UpdateDisplayInfo(TkText *textPtr);
@@ -569,8 +568,8 @@ static int SizeOfTab(TkText *textPtr, int tabStyle,
TkTextTabArray *tabArrayPtr, int *indexPtr, int x,
int maxX);
static void TextChanged(TkText *textPtr,
- const TkTextIndex *index1Ptr,
- const TkTextIndex *index2Ptr);
+ CONST TkTextIndex *index1Ptr,
+ CONST TkTextIndex *index2Ptr);
static void TextInvalidateRegion(TkText *textPtr, TkRegion region);
static void TextRedrawTag(TkText *textPtr,
TkTextIndex *index1Ptr, TkTextIndex *index2Ptr,
@@ -578,7 +577,7 @@ static void TextRedrawTag(TkText *textPtr,
static void TextInvalidateLineMetrics(TkText *textPtr,
TkTextLine *linePtr, int lineCount, int action);
static int CalculateDisplayLineHeight(TkText *textPtr,
- const TkTextIndex *indexPtr, int *byteCountPtr,
+ CONST TkTextIndex *indexPtr, int *byteCountPtr,
int *mergedLinePtr);
static void DlineIndexOfX(TkText *textPtr,
DLine *dlPtr, int x, TkTextIndex *indexPtr);
@@ -586,7 +585,7 @@ static int DlineXOfIndex(TkText *textPtr,
DLine *dlPtr, int byteIndex);
static int TextGetScrollInfoObj(Tcl_Interp *interp,
TkText *textPtr, int objc,
- Tcl_Obj *const objv[], double *dblPtr,
+ Tcl_Obj *CONST objv[], double *dblPtr,
int *intPtr);
static void AsyncUpdateLineMetrics(ClientData clientData);
static void AsyncUpdateYScrollbar(ClientData clientData);
@@ -626,7 +625,7 @@ TkTextCreateDInfo(
register TextDInfo *dInfoPtr;
XGCValues gcValues;
- dInfoPtr = ckalloc(sizeof(TextDInfo));
+ dInfoPtr = (TextDInfo *) ckalloc(sizeof(TextDInfo));
Tcl_InitHashTable(&dInfoPtr->styleTable, sizeof(StyleValues)/sizeof(int));
dInfoPtr->dLinePtr = NULL;
dInfoPtr->copyGC = None;
@@ -662,10 +661,10 @@ TkTextCreateDInfo(
textPtr->refCount++;
dInfoPtr->lineUpdateTimer = Tcl_CreateTimerHandler(0,
- AsyncUpdateLineMetrics, textPtr);
+ AsyncUpdateLineMetrics, (ClientData) textPtr);
textPtr->refCount++;
dInfoPtr->scrollbarTimer = Tcl_CreateTimerHandler(200,
- AsyncUpdateYScrollbar, textPtr);
+ AsyncUpdateYScrollbar, (ClientData) textPtr);
textPtr->dInfoPtr = dInfoPtr;
}
@@ -707,7 +706,7 @@ TkTextFreeDInfo(
}
Tk_FreeGC(textPtr->display, dInfoPtr->scrollGC);
if (dInfoPtr->flags & REDRAW_PENDING) {
- Tcl_CancelIdleCall(DisplayText, textPtr);
+ Tcl_CancelIdleCall(DisplayText, (ClientData) textPtr);
}
if (dInfoPtr->lineUpdateTimer != NULL) {
Tcl_DeleteTimerHandler(dInfoPtr->lineUpdateTimer);
@@ -719,7 +718,7 @@ TkTextFreeDInfo(
textPtr->refCount--;
dInfoPtr->scrollbarTimer = NULL;
}
- ckfree(dInfoPtr);
+ ckfree((char *) dInfoPtr);
}
/*
@@ -743,7 +742,7 @@ TkTextFreeDInfo(
static TextStyle *
GetStyle(
TkText *textPtr, /* Overall information about text widget. */
- const TkTextIndex *indexPtr)/* The character in the text for which display
+ CONST TkTextIndex *indexPtr)/* The character in the text for which display
* information is wanted. */
{
TkTextTag **tagPtrs;
@@ -923,7 +922,7 @@ GetStyle(
}
}
if (tagPtrs != NULL) {
- ckfree(tagPtrs);
+ ckfree((char *) tagPtrs);
}
/*
@@ -933,7 +932,7 @@ GetStyle(
hPtr = Tcl_CreateHashEntry(&textPtr->dInfoPtr->styleTable,
(char *) &styleValues, &isNew);
if (!isNew) {
- stylePtr = Tcl_GetHashValue(hPtr);
+ stylePtr = (TextStyle *) Tcl_GetHashValue(hPtr);
stylePtr->refCount++;
return stylePtr;
}
@@ -942,7 +941,7 @@ GetStyle(
* No existing style matched. Make a new one.
*/
- stylePtr = ckalloc(sizeof(TextStyle));
+ stylePtr = (TextStyle *) ckalloc(sizeof(TextStyle));
stylePtr->refCount = 1;
if (styleValues.border != NULL) {
gcValues.foreground = Tk_3DBorderColor(styleValues.border)->pixel;
@@ -1007,7 +1006,7 @@ FreeStyle(
Tk_FreeGC(textPtr->display, stylePtr->fgGC);
}
Tcl_DeleteHashEntry(stylePtr->hPtr);
- ckfree(stylePtr);
+ ckfree((char *) stylePtr);
}
}
@@ -1048,7 +1047,7 @@ FreeStyle(
static DLine *
LayoutDLine(
TkText *textPtr, /* Overall information about text widget. */
- const TkTextIndex *indexPtr)/* Beginning of display line. May not
+ CONST TkTextIndex *indexPtr)/* Beginning of display line. May not
* necessarily point to a character
* segment. */
{
@@ -1106,7 +1105,7 @@ LayoutDLine(
* Create and initialize a new DLine structure.
*/
- dlPtr = ckalloc(sizeof(DLine));
+ dlPtr = (DLine *) ckalloc(sizeof(DLine));
dlPtr->index = *indexPtr;
dlPtr->byteCount = 0;
dlPtr->y = 0;
@@ -1266,14 +1265,14 @@ LayoutDLine(
*/
TkTextLine *linePtr = TkBTreeNextLine(NULL, curIndex.linePtr);
- if (linePtr == NULL) {
+ if (linePtr != NULL) {
+ dlPtr->logicalLinesMerged++;
+ curIndex.byteIndex = 0;
+ curIndex.linePtr = linePtr;
+ segPtr = curIndex.linePtr->segPtr;
+ } else {
break;
}
-
- dlPtr->logicalLinesMerged++;
- curIndex.byteIndex = 0;
- curIndex.linePtr = linePtr;
- segPtr = curIndex.linePtr->segPtr;
}
}
@@ -1337,7 +1336,7 @@ LayoutDLine(
* into a single display line.
*
if (segPtr == NULL && chunkPtr != NULL) {
- ckfree(chunkPtr);
+ ckfree((char *) chunkPtr);
chunkPtr = NULL;
}
*/
@@ -1351,7 +1350,7 @@ LayoutDLine(
continue;
}
if (chunkPtr == NULL) {
- chunkPtr = ckalloc(sizeof(TkTextDispChunk));
+ chunkPtr = (TkTextDispChunk *) ckalloc(sizeof(TkTextDispChunk));
chunkPtr->nextPtr = NULL;
chunkPtr->clientData = NULL;
}
@@ -1460,7 +1459,7 @@ LayoutDLine(
code = 1;
} else {
- code = segPtr->typePtr->layoutProc(textPtr, &curIndex, segPtr,
+ code = (*segPtr->typePtr->layoutProc)(textPtr, &curIndex, segPtr,
byteOffset, maxX-tabSize, maxBytes, noCharsYet, wrapMode,
chunkPtr);
}
@@ -1483,7 +1482,7 @@ LayoutDLine(
*/
if (chunkPtr != NULL) {
- ckfree(chunkPtr);
+ ckfree((char *) chunkPtr);
}
break;
}
@@ -1612,18 +1611,18 @@ LayoutDLine(
FreeStyle(textPtr, chunkPtr->stylePtr);
breakChunkPtr->nextPtr = chunkPtr->nextPtr;
if (chunkPtr->undisplayProc != NULL) {
- chunkPtr->undisplayProc(textPtr, chunkPtr);
+ (*chunkPtr->undisplayProc)(textPtr, chunkPtr);
}
- ckfree(chunkPtr);
+ ckfree((char *) chunkPtr);
}
if (breakByteOffset != breakChunkPtr->numBytes) {
if (breakChunkPtr->undisplayProc != NULL) {
- breakChunkPtr->undisplayProc(textPtr, breakChunkPtr);
+ (*breakChunkPtr->undisplayProc)(textPtr, breakChunkPtr);
}
segPtr = TkTextIndexToSeg(&breakIndex, &byteOffset);
- segPtr->typePtr->layoutProc(textPtr, &breakIndex, segPtr,
- byteOffset, maxX, breakByteOffset, 0, wrapMode,
- breakChunkPtr);
+ (*segPtr->typePtr->layoutProc)(textPtr, &breakIndex,
+ segPtr, byteOffset, maxX, breakByteOffset, 0,
+ wrapMode, breakChunkPtr);
#if TK_LAYOUT_WITH_BASE_CHUNKS
FinalizeBaseChunk(NULL);
#endif /* TK_LAYOUT_WITH_BASE_CHUNKS */
@@ -2308,13 +2307,13 @@ FreeDLines(
for (chunkPtr = firstPtr->chunkPtr; chunkPtr != NULL;
chunkPtr = nextChunkPtr) {
if (chunkPtr->undisplayProc != NULL) {
- chunkPtr->undisplayProc(textPtr, chunkPtr);
+ (*chunkPtr->undisplayProc)(textPtr, chunkPtr);
}
FreeStyle(textPtr, chunkPtr->stylePtr);
nextChunkPtr = chunkPtr->nextPtr;
- ckfree(chunkPtr);
+ ckfree((char *) chunkPtr);
}
- ckfree(firstPtr);
+ ckfree((char *) firstPtr);
firstPtr = nextDLinePtr;
}
if (action != DLINE_FREE_TEMP) {
@@ -2406,7 +2405,7 @@ DisplayDLine(
if (chunkPtr->displayProc == TkTextInsertDisplayProc) {
int x = chunkPtr->x + dInfoPtr->x - dInfoPtr->curXPixelOffset;
- chunkPtr->displayProc(textPtr, chunkPtr, x,
+ (*chunkPtr->displayProc)(textPtr, chunkPtr, x,
y + dlPtr->spaceAbove,
dlPtr->height - dlPtr->spaceAbove - dlPtr->spaceBelow,
dlPtr->baseline - dlPtr->spaceAbove, display, pixmap,
@@ -2454,7 +2453,7 @@ DisplayDLine(
x = -chunkPtr->width;
}
- chunkPtr->displayProc(textPtr, chunkPtr, x,
+ (*chunkPtr->displayProc)(textPtr, chunkPtr, x,
y + dlPtr->spaceAbove, dlPtr->height - dlPtr->spaceAbove -
dlPtr->spaceBelow, dlPtr->baseline - dlPtr->spaceAbove,
display, pixmap, dlPtr->y + dlPtr->spaceAbove);
@@ -2728,7 +2727,7 @@ DisplayLineBackground(
rightX2 + xOffset, y, sValuePtr->borderWidth,
sValuePtr->borderWidth, 1, sValuePtr->relief);
Tk_3DHorizontalBevel(textPtr->tkwin, pixmap, sValuePtr->border,
- leftX + xOffset, y, rightX2 + sValuePtr->borderWidth -
+ leftX + xOffset, y, rightX2 + sValuePtr->borderWidth -
leftX, sValuePtr->borderWidth, leftXIn, 0, 1,
sValuePtr->relief);
}
@@ -2880,7 +2879,7 @@ static void
AsyncUpdateLineMetrics(
ClientData clientData) /* Information about widget. */
{
- register TkText *textPtr = clientData;
+ register TkText *textPtr = (TkText *) clientData;
TextDInfo *dInfoPtr = textPtr->dInfoPtr;
int lineNum;
@@ -2892,7 +2891,7 @@ AsyncUpdateLineMetrics(
*/
if (--textPtr->refCount == 0) {
- ckfree(textPtr);
+ ckfree((char *) textPtr);
}
return;
}
@@ -2903,11 +2902,6 @@ AsyncUpdateLineMetrics(
return;
}
- /*
- * Reify where we end or all hell breaks loose with the calculations when
- * we try to update. [Bug 2677890]
- */
-
lineNum = dInfoPtr->currentMetricUpdateLine;
if (dInfoPtr->lastMetricUpdateLine == -1) {
dInfoPtr->lastMetricUpdateLine =
@@ -2944,7 +2938,7 @@ AsyncUpdateLineMetrics(
textPtr->refCount--;
if (textPtr->refCount == 0) {
- ckfree(textPtr);
+ ckfree((char *) textPtr);
}
return;
}
@@ -2956,7 +2950,7 @@ AsyncUpdateLineMetrics(
*/
dInfoPtr->lineUpdateTimer = Tcl_CreateTimerHandler(1,
- AsyncUpdateLineMetrics, textPtr);
+ AsyncUpdateLineMetrics, (ClientData) textPtr);
}
/*
@@ -3057,82 +3051,86 @@ TkTextUpdateLineMetrics(
*/
if (TkBTreeLinePixelEpoch(textPtr, linePtr)
- == textPtr->dInfoPtr->lineMetricUpdateEpoch) {
- /*
- * This line is already up to date. That means there's nothing
- * to do here.
- */
- } else if (doThisMuch == -1) {
- count += 8 * TkTextUpdateOneLine(textPtr, linePtr, 0,NULL,0);
- } else {
- TkTextIndex index;
- TkTextIndex *indexPtr;
- int pixelHeight;
-
- /*
- * If the metric epoch is the same as the widget's epoch, then
- * we know that indexPtrs are still valid, and if the cached
- * metricIndex (if any) is for the same line as we wish to
- * examine, then we are looking at a long line wrapped many
- * times, which we will examine in pieces.
- */
-
- if (textPtr->dInfoPtr->metricEpoch ==
- textPtr->sharedTextPtr->stateEpoch &&
- textPtr->dInfoPtr->metricIndex.linePtr==linePtr) {
- indexPtr = &textPtr->dInfoPtr->metricIndex;
- pixelHeight = textPtr->dInfoPtr->metricPixelHeight;
+ != textPtr->dInfoPtr->lineMetricUpdateEpoch) {
+ if (doThisMuch == -1) {
+ count += 8 * TkTextUpdateOneLine(textPtr, linePtr, 0,
+ NULL, 0);
} else {
+ TkTextIndex index;
+ TkTextIndex *indexPtr;
+ int pixelHeight;
+
/*
- * We must reset the partial line height calculation data
- * here, so we don't use it when it is out of date.
+ * If the metric epoch is the same as the widget's epoch,
+ * then we know that indexPtrs are still valid, and if the
+ * cached metricIndex (if any) is for the same line as we
+ * wish to examine, then we are looking at a long line
+ * wrapped many times, which we will examine in pieces.
*/
- textPtr->dInfoPtr->metricEpoch = -1;
- index.tree = textPtr->sharedTextPtr->tree;
- index.linePtr = linePtr;
- index.byteIndex = 0;
- index.textPtr = NULL;
- indexPtr = &index;
- pixelHeight = 0;
- }
-
- /*
- * Update the line and update the counter, counting 8 for each
- * display line we actually re-layout.
- */
+ if (textPtr->dInfoPtr->metricEpoch ==
+ textPtr->sharedTextPtr->stateEpoch &&
+ textPtr->dInfoPtr->metricIndex.linePtr==linePtr) {
+ indexPtr = &textPtr->dInfoPtr->metricIndex;
+ pixelHeight = textPtr->dInfoPtr->metricPixelHeight;
+ } else {
+ /*
+ * We must reset the partial line height calculation
+ * data here, so we don't use it when it is out of
+ * date.
+ */
- count += 8 * TkTextUpdateOneLine(textPtr, linePtr,
- pixelHeight, indexPtr, 1);
+ textPtr->dInfoPtr->metricEpoch = -1;
+ index.tree = textPtr->sharedTextPtr->tree;
+ index.linePtr = linePtr;
+ index.byteIndex = 0;
+ index.textPtr = NULL;
+ indexPtr = &index;
+ pixelHeight = 0;
+ }
- if (indexPtr->linePtr == linePtr) {
/*
- * We didn't complete the logical line, because it
- * produced very many display lines, which must be because
- * it must be a long line wrapped many times. So we must
- * cache as far as we got for next time around.
+ * Update the line and update the counter, counting 8 for
+ * each display line we actually re-layout.
*/
- if (pixelHeight == 0) {
+ count += 8 * TkTextUpdateOneLine(textPtr, linePtr,
+ pixelHeight, indexPtr, 1);
+
+ if (indexPtr->linePtr == linePtr) {
+ /*
+ * We didn't complete the logical line, because it
+ * produced very many display lines - it must be a
+ * long line wrapped many times. So we must cache as
+ * far as we got for next time around.
+ */
+
+ if (pixelHeight == 0) {
+ /*
+ * These have already been stored, unless we just
+ * started the new line.
+ */
+
+ textPtr->dInfoPtr->metricIndex = index;
+ textPtr->dInfoPtr->metricEpoch =
+ textPtr->sharedTextPtr->stateEpoch;
+ }
+ textPtr->dInfoPtr->metricPixelHeight =
+ TkBTreeLinePixelCount(textPtr, linePtr);
+ break;
+ } else {
/*
- * These have already been stored, unless we just
- * started the new line.
+ * We're done with this long line.
*/
- textPtr->dInfoPtr->metricIndex = index;
- textPtr->dInfoPtr->metricEpoch =
- textPtr->sharedTextPtr->stateEpoch;
+ textPtr->dInfoPtr->metricEpoch = -1;
}
- textPtr->dInfoPtr->metricPixelHeight =
- TkBTreeLinePixelCount(textPtr, linePtr);
- break;
}
-
+ } else {
/*
- * We're done with this long line.
+ * This line is already up to date. That means there's nothing
+ * to do here.
*/
-
- textPtr->dInfoPtr->metricEpoch = -1;
}
} else {
/*
@@ -3333,7 +3331,7 @@ TextInvalidateLineMetrics(
if (dInfoPtr->lineUpdateTimer == NULL) {
textPtr->refCount++;
dInfoPtr->lineUpdateTimer = Tcl_CreateTimerHandler(1,
- AsyncUpdateLineMetrics, textPtr);
+ AsyncUpdateLineMetrics, (ClientData) textPtr);
}
}
@@ -3383,8 +3381,6 @@ TkTextFindDisplayLineEnd(
* of the original index within its display
* line. */
{
- TkTextIndex index;
-
if (!end && indexPtr->byteIndex == 0) {
/*
* Nothing to do.
@@ -3394,93 +3390,95 @@ TkTextFindDisplayLineEnd(
*xOffset = 0;
}
return;
- }
+ } else {
+ TkTextIndex index = *indexPtr;
- index = *indexPtr;
- index.byteIndex = 0;
- index.textPtr = NULL;
+ index.byteIndex = 0;
+ index.textPtr = NULL;
- while (1) {
- TkTextIndex endOfLastLine;
+ while (1) {
+ TkTextIndex endOfLastLine;
- if (TkTextIndexBackBytes(textPtr, &index, 1, &endOfLastLine)) {
- /*
- * Reached beginning of text.
- */
+ if (TkTextIndexBackBytes(textPtr, &index, 1, &endOfLastLine)) {
+ /*
+ * Reached beginning of text.
+ */
- break;
- }
+ break;
+ }
+
+ if (!TkTextIsElided(textPtr, &endOfLastLine, NULL)) {
+ /*
+ * The eol is not elided, so 'index' points to the start of a
+ * display line (as well as logical line).
+ */
+
+ break;
+ }
- if (!TkTextIsElided(textPtr, &endOfLastLine, NULL)) {
/*
- * The eol is not elided, so 'index' points to the start of a
- * display line (as well as logical line).
+ * indexPtr's logical line is actually merged with the previous
+ * logical line whose eol is elided. Continue searching back to
+ * get a real line start.
*/
- break;
+ index = endOfLastLine;
+ index.byteIndex = 0;
}
- /*
- * indexPtr's logical line is actually merged with the previous
- * logical line whose eol is elided. Continue searching back to get a
- * real line start.
- */
-
- index = endOfLastLine;
- index.byteIndex = 0;
- }
-
- while (1) {
- DLine *dlPtr;
- int byteCount;
- TkTextIndex nextLineStart;
-
- dlPtr = LayoutDLine(textPtr, &index);
- byteCount = dlPtr->byteCount;
+ while (1) {
+ DLine *dlPtr;
+ int byteCount;
+ TkTextIndex nextLineStart;
- TkTextIndexForwBytes(textPtr, &index, byteCount, &nextLineStart);
+ dlPtr = LayoutDLine(textPtr, &index);
+ byteCount = dlPtr->byteCount;
- /*
- * 'byteCount' goes up to the beginning of the next display line, so
- * equality here says we need one more line. We try to perform a quick
- * comparison which is valid for the case where the logical line is
- * the same, but otherwise fall back on a full TkTextIndexCmp.
- */
+ TkTextIndexForwBytes(textPtr, &index, byteCount, &nextLineStart);
- if (((index.linePtr == indexPtr->linePtr)
- && (index.byteIndex + byteCount > indexPtr->byteIndex))
- || (dlPtr->logicalLinesMerged > 0
- && TkTextIndexCmp(&nextLineStart, indexPtr) > 0)) {
/*
- * It's on this display line.
+ * 'byteCount' goes up to the beginning of the next display line,
+ * so equality here says we need one more line. We try to perform
+ * a quick comparison which is valid for the case where the
+ * logical line is the same, but otherwise fall back on a full
+ * TkTextIndexCmp.
*/
- if (xOffset != NULL) {
+ if (((index.linePtr == indexPtr->linePtr)
+ && (index.byteIndex + byteCount > indexPtr->byteIndex))
+ || (dlPtr->logicalLinesMerged > 0
+ && TkTextIndexCmp(&nextLineStart, indexPtr) > 0)) {
/*
- * This call takes a byte index relative to the start of the
- * current _display_ line, not logical line. We are about to
- * overwrite indexPtr->byteIndex, so we must do this now.
+ * It's on this display line.
*/
- *xOffset = DlineXOfIndex(textPtr, dlPtr,
- indexPtr->byteIndex - dlPtr->index.byteIndex);
- }
- if (end) {
- /*
- * The index we want is one less than the number of bytes in
- * the display line.
- */
+ if (xOffset != NULL) {
+ /*
+ * This call takes a byte index relative to the start of
+ * the current _display_ line, not logical line. We are
+ * about to overwrite indexPtr->byteIndex, so we must do
+ * this now.
+ */
- TkTextIndexBackBytes(textPtr, &nextLineStart, 1, indexPtr);
- } else {
- *indexPtr = index;
+ *xOffset = DlineXOfIndex(textPtr, dlPtr,
+ indexPtr->byteIndex - dlPtr->index.byteIndex);
+ }
+ if (end) {
+ /*
+ * The index we want is one less than the number of bytes
+ * in the display line.
+ */
+
+ TkTextIndexBackBytes(textPtr, &nextLineStart, 1, indexPtr);
+ } else {
+ *indexPtr = index;
+ }
+ FreeDLines(textPtr, dlPtr, NULL, DLINE_FREE_TEMP);
+ return;
}
FreeDLines(textPtr, dlPtr, NULL, DLINE_FREE_TEMP);
- return;
+ index = nextLineStart;
}
-
- FreeDLines(textPtr, dlPtr, NULL, DLINE_FREE_TEMP);
- index = nextLineStart;
}
}
@@ -3522,7 +3520,7 @@ TkTextFindDisplayLineEnd(
static int
CalculateDisplayLineHeight(
TkText *textPtr, /* Widget record for text widget. */
- const TkTextIndex *indexPtr,/* The index at the beginning of the display
+ CONST TkTextIndex *indexPtr,/* The index at the beginning of the display
* line of interest. */
int *byteCountPtr, /* NULL or used to return the number of byte
* indices on the given display line. */
@@ -3593,7 +3591,7 @@ CalculateDisplayLineHeight(
int
TkTextIndexYPixels(
TkText *textPtr, /* Widget record for text widget. */
- const TkTextIndex *indexPtr)/* The index of which we want the pixel
+ CONST TkTextIndex *indexPtr)/* The index of which we want the pixel
* distance from top of logical line to top of
* index. */
{
@@ -3864,7 +3862,7 @@ TkTextUpdateOneLine(
if (textPtr->dInfoPtr->scrollbarTimer == NULL) {
textPtr->refCount++;
textPtr->dInfoPtr->scrollbarTimer = Tcl_CreateTimerHandler(200,
- AsyncUpdateYScrollbar, textPtr);
+ AsyncUpdateYScrollbar, (ClientData) textPtr);
}
return displayLines;
}
@@ -3890,7 +3888,7 @@ static void
DisplayText(
ClientData clientData) /* Information about widget. */
{
- register TkText *textPtr = clientData;
+ register TkText *textPtr = (TkText *) clientData;
TextDInfo *dInfoPtr = textPtr->dInfoPtr;
register DLine *dlPtr;
DLine *prevPtr;
@@ -3909,7 +3907,7 @@ DisplayText(
}
interp = textPtr->interp;
- Tcl_Preserve(interp);
+ Tcl_Preserve((ClientData) interp);
if (tkTextDebug) {
Tcl_SetVar2(interp, "tk_textRelayout", NULL, "", TCL_GLOBAL_ONLY);
@@ -3955,7 +3953,7 @@ DisplayText(
dInfoPtr->flags &= ~REPICK_NEEDED;
TkTextPickCurrent(textPtr, &textPtr->pickEvent);
if (--textPtr->refCount == 0) {
- ckfree(textPtr);
+ ckfree((char *) textPtr);
goto end;
}
if ((textPtr->tkwin == NULL) || (textPtr->flags & DESTROYED)) {
@@ -4347,7 +4345,7 @@ DisplayText(
}
end:
- Tcl_Release(interp);
+ Tcl_Release((ClientData) interp);
}
/*
@@ -4376,7 +4374,7 @@ TkTextEventuallyRepick(
dInfoPtr->flags |= REPICK_NEEDED;
if (!(dInfoPtr->flags & REDRAW_PENDING)) {
dInfoPtr->flags |= REDRAW_PENDING;
- Tcl_DoWhenIdle(DisplayText, textPtr);
+ Tcl_DoWhenIdle(DisplayText, (ClientData) textPtr);
}
}
@@ -4420,7 +4418,7 @@ TkTextRedrawRegion(
if (!(dInfoPtr->flags & REDRAW_PENDING)) {
dInfoPtr->flags |= REDRAW_PENDING;
- Tcl_DoWhenIdle(DisplayText, textPtr);
+ Tcl_DoWhenIdle(DisplayText, (ClientData) textPtr);
}
TkDestroyRegion(damageRgn);
}
@@ -4514,8 +4512,8 @@ void
TkTextChanged(
TkSharedText *sharedTextPtr,/* Shared widget section, or NULL. */
TkText *textPtr, /* Widget record for text widget, or NULL. */
- const TkTextIndex*index1Ptr,/* Index of first character to redisplay. */
- const TkTextIndex*index2Ptr)/* Index of character just after last one to
+ CONST TkTextIndex*index1Ptr,/* Index of first character to redisplay. */
+ CONST TkTextIndex*index2Ptr)/* Index of character just after last one to
* redisplay. */
{
if (sharedTextPtr == NULL) {
@@ -4532,8 +4530,8 @@ TkTextChanged(
static void
TextChanged(
TkText *textPtr, /* Widget record for text widget, or NULL. */
- const TkTextIndex*index1Ptr,/* Index of first character to redisplay. */
- const TkTextIndex*index2Ptr)/* Index of character just after last one to
+ CONST TkTextIndex*index1Ptr,/* Index of first character to redisplay. */
+ CONST TkTextIndex*index2Ptr)/* Index of character just after last one to
* redisplay. */
{
TextDInfo *dInfoPtr = textPtr->dInfoPtr;
@@ -4557,7 +4555,7 @@ TextChanged(
*/
if (!(dInfoPtr->flags & REDRAW_PENDING)) {
- Tcl_DoWhenIdle(DisplayText, textPtr);
+ Tcl_DoWhenIdle(DisplayText, (ClientData) textPtr);
}
dInfoPtr->flags |= REDRAW_PENDING|DINFO_OUT_OF_DATE|REPICK_NEEDED;
@@ -4739,7 +4737,7 @@ TextRedrawTag(
*/
if (!(dInfoPtr->flags & REDRAW_PENDING)) {
- Tcl_DoWhenIdle(DisplayText, textPtr);
+ Tcl_DoWhenIdle(DisplayText, (ClientData) textPtr);
}
dInfoPtr->flags |= REDRAW_PENDING|DINFO_OUT_OF_DATE|REPICK_NEEDED;
@@ -4844,7 +4842,7 @@ TkTextRelayoutWindow(
*/
if (!(dInfoPtr->flags & REDRAW_PENDING)) {
- Tcl_DoWhenIdle(DisplayText, textPtr);
+ Tcl_DoWhenIdle(DisplayText, (ClientData) textPtr);
}
dInfoPtr->flags |= REDRAW_PENDING|REDRAW_BORDERS|DINFO_OUT_OF_DATE
|REPICK_NEEDED;
@@ -4939,7 +4937,7 @@ TkTextRelayoutWindow(
if (dInfoPtr->lineUpdateTimer == NULL) {
textPtr->refCount++;
dInfoPtr->lineUpdateTimer = Tcl_CreateTimerHandler(1,
- AsyncUpdateLineMetrics, textPtr);
+ AsyncUpdateLineMetrics, (ClientData) textPtr);
}
}
}
@@ -5123,7 +5121,7 @@ TkTextSetYView(
scheduleUpdate:
if (!(dInfoPtr->flags & REDRAW_PENDING)) {
- Tcl_DoWhenIdle(DisplayText, textPtr);
+ Tcl_DoWhenIdle(DisplayText, (ClientData) textPtr);
}
dInfoPtr->flags |= REDRAW_PENDING|DINFO_OUT_OF_DATE|REPICK_NEEDED;
}
@@ -5213,7 +5211,7 @@ TkTextMeasureDown(
static void
MeasureUp(
TkText *textPtr, /* Text widget in which to measure. */
- const TkTextIndex *srcPtr, /* Index of character from which to start
+ CONST TkTextIndex *srcPtr, /* Index of character from which to start
* measuring. */
int distance, /* Vertical distance in pixels measured from
* the pixel just below the lowest one in
@@ -5317,7 +5315,7 @@ TkTextSeeCmd(
TkText *textPtr, /* Information about text widget. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *const objv[]) /* Argument objects. Someone else has already
+ Tcl_Obj *CONST objv[]) /* Argument objects. Someone else has already
* parsed this command enough to know that
* objv[1] is "see". */
{
@@ -5389,7 +5387,7 @@ TkTextSeeCmd(
*/
if (chunkPtr != NULL) {
- chunkPtr->bboxProc(textPtr, chunkPtr, byteCount,
+ (*chunkPtr->bboxProc)(textPtr, chunkPtr, byteCount,
dlPtr->y + dlPtr->spaceAbove,
dlPtr->height - dlPtr->spaceAbove - dlPtr->spaceBelow,
dlPtr->baseline - dlPtr->spaceAbove, &x, &y, &width,
@@ -5398,25 +5396,27 @@ TkTextSeeCmd(
oneThird = lineWidth/3;
if (delta < 0) {
if (delta < -oneThird) {
- dInfoPtr->newXPixelOffset = x - lineWidth/2;
+ dInfoPtr->newXPixelOffset = (x - lineWidth/2);
} else {
- dInfoPtr->newXPixelOffset += delta;
+ dInfoPtr->newXPixelOffset -= ((-delta) );
}
} else {
- delta -= lineWidth - width;
- if (delta <= 0) {
- return TCL_OK;
- } else if (delta > oneThird) {
- dInfoPtr->newXPixelOffset = x - lineWidth/2;
+ delta -= (lineWidth - width);
+ if (delta > 0) {
+ if (delta > oneThird) {
+ dInfoPtr->newXPixelOffset = (x - lineWidth/2);
+ } else {
+ dInfoPtr->newXPixelOffset += (delta );
+ }
} else {
- dInfoPtr->newXPixelOffset += delta;
+ return TCL_OK;
}
}
}
dInfoPtr->flags |= DINFO_OUT_OF_DATE;
if (!(dInfoPtr->flags & REDRAW_PENDING)) {
dInfoPtr->flags |= REDRAW_PENDING;
- Tcl_DoWhenIdle(DisplayText, textPtr);
+ Tcl_DoWhenIdle(DisplayText, (ClientData) textPtr);
}
return TCL_OK;
}
@@ -5444,7 +5444,7 @@ TkTextXviewCmd(
TkText *textPtr, /* Information about text widget. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *const objv[]) /* Argument objects. Someone else has already
+ Tcl_Obj *CONST objv[]) /* Argument objects. Someone else has already
* parsed this command enough to know that
* objv[1] is "xview". */
{
@@ -5497,7 +5497,7 @@ TkTextXviewCmd(
dInfoPtr->flags |= DINFO_OUT_OF_DATE;
if (!(dInfoPtr->flags & REDRAW_PENDING)) {
dInfoPtr->flags |= REDRAW_PENDING;
- Tcl_DoWhenIdle(DisplayText, textPtr);
+ Tcl_DoWhenIdle(DisplayText, (ClientData) textPtr);
}
return TCL_OK;
}
@@ -5582,7 +5582,7 @@ YScrollByPixels(
return;
}
if (!(dInfoPtr->flags & REDRAW_PENDING)) {
- Tcl_DoWhenIdle(DisplayText, textPtr);
+ Tcl_DoWhenIdle(DisplayText, (ClientData) textPtr);
}
dInfoPtr->flags |= REDRAW_PENDING|DINFO_OUT_OF_DATE|REPICK_NEEDED;
}
@@ -5699,7 +5699,7 @@ YScrollByLines(
scheduleUpdate:
if (!(dInfoPtr->flags & REDRAW_PENDING)) {
- Tcl_DoWhenIdle(DisplayText, textPtr);
+ Tcl_DoWhenIdle(DisplayText, (ClientData) textPtr);
}
dInfoPtr->flags |= REDRAW_PENDING|DINFO_OUT_OF_DATE|REPICK_NEEDED;
}
@@ -5727,7 +5727,7 @@ TkTextYviewCmd(
TkText *textPtr, /* Information about text widget. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *const objv[]) /* Argument objects. Someone else has already
+ Tcl_Obj *CONST objv[]) /* Argument objects. Someone else has already
* parsed this command enough to know that
* objv[1] is "yview". */
{
@@ -5753,7 +5753,7 @@ TkTextYviewCmd(
pickPlace = 0;
if (Tcl_GetString(objv[2])[0] == '-') {
- register const char *switchStr =
+ register CONST char *switchStr =
Tcl_GetStringFromObj(objv[2], &switchLength);
if ((switchLength >= 2) && (strncmp(switchStr, "-pickplace",
@@ -5908,7 +5908,7 @@ TkTextScanCmd(
register TkText *textPtr, /* Information about text widget. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *const objv[]) /* Argument objects. Someone else has already
+ Tcl_Obj *CONST objv[]) /* Argument objects. Someone else has already
* parsed this command enough to know that
* objv[1] is "scan". */
{
@@ -5979,7 +5979,7 @@ TkTextScanCmd(
dInfoPtr->flags |= DINFO_OUT_OF_DATE;
if (!(dInfoPtr->flags & REDRAW_PENDING)) {
dInfoPtr->flags |= REDRAW_PENDING;
- Tcl_DoWhenIdle(DisplayText, textPtr);
+ Tcl_DoWhenIdle(DisplayText, (ClientData) textPtr);
}
} else if (c=='m' && strncmp(Tcl_GetString(objv[2]), "mark", length)==0) {
dInfoPtr->scanMarkXPixel = dInfoPtr->newXPixelOffset;
@@ -5987,11 +5987,8 @@ TkTextScanCmd(
dInfoPtr->scanTotalYScroll = 0;
dInfoPtr->scanMarkY = y;
} else {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "bad scan option \"%s\": must be mark or dragto",
- Tcl_GetString(objv[2])));
- Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "INDEX", "scan option",
- Tcl_GetString(objv[2]), NULL);
+ Tcl_AppendResult(interp, "bad scan option \"", Tcl_GetString(objv[2]),
+ "\": must be mark or dragto", NULL);
return TCL_ERROR;
}
return TCL_OK;
@@ -6064,22 +6061,16 @@ GetXView(
if (textPtr->xScrollCmd != NULL) {
char buf1[TCL_DOUBLE_SPACE+1];
char buf2[TCL_DOUBLE_SPACE+1];
- Tcl_DString buf;
buf1[0] = ' ';
buf2[0] = ' ';
Tcl_PrintDouble(NULL, first, buf1+1);
Tcl_PrintDouble(NULL, last, buf2+1);
- Tcl_DStringInit(&buf);
- Tcl_DStringAppend(&buf, textPtr->xScrollCmd, -1);
- Tcl_DStringAppend(&buf, buf1, -1);
- Tcl_DStringAppend(&buf, buf2, -1);
- code = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, 0);
- Tcl_DStringFree(&buf);
+ code = Tcl_VarEval(interp, textPtr->xScrollCmd, buf1, buf2, NULL);
if (code != TCL_OK) {
Tcl_AddErrorInfo(interp,
"\n (horizontal scrolling command executed by text)");
- Tcl_BackgroundException(interp, code);
+ Tcl_BackgroundError(interp);
}
}
}
@@ -6201,8 +6192,9 @@ GetYPixelCount(
notFirst = 1;
}
break;
+ } else {
+ dlPtr = dlPtr->nextPtr;
}
- dlPtr = dlPtr->nextPtr;
} while (dlPtr->index.linePtr == linePtr);
return count;
@@ -6352,22 +6344,16 @@ GetYView(
if (textPtr->yScrollCmd != NULL) {
char buf1[TCL_DOUBLE_SPACE+1];
char buf2[TCL_DOUBLE_SPACE+1];
- Tcl_DString buf;
buf1[0] = ' ';
buf2[0] = ' ';
Tcl_PrintDouble(NULL, first, buf1+1);
Tcl_PrintDouble(NULL, last, buf2+1);
- Tcl_DStringInit(&buf);
- Tcl_DStringAppend(&buf, textPtr->yScrollCmd, -1);
- Tcl_DStringAppend(&buf, buf1, -1);
- Tcl_DStringAppend(&buf, buf2, -1);
- code = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, 0);
- Tcl_DStringFree(&buf);
+ code = Tcl_VarEval(interp, textPtr->yScrollCmd, buf1, buf2, NULL);
if (code != TCL_OK) {
Tcl_AddErrorInfo(interp,
"\n (vertical scrolling command executed by text)");
- Tcl_BackgroundException(interp, code);
+ Tcl_BackgroundError(interp);
}
}
}
@@ -6394,7 +6380,7 @@ static void
AsyncUpdateYScrollbar(
ClientData clientData) /* Information about widget. */
{
- register TkText *textPtr = clientData;
+ register TkText *textPtr = (TkText *) clientData;
textPtr->dInfoPtr->scrollbarTimer = NULL;
@@ -6403,7 +6389,7 @@ AsyncUpdateYScrollbar(
}
if (--textPtr->refCount == 0) {
- ckfree(textPtr);
+ ckfree((char *) textPtr);
}
}
@@ -6430,7 +6416,7 @@ static DLine *
FindDLine(
register DLine *dlPtr, /* Pointer to first in list of DLines to
* search. */
- const TkTextIndex *indexPtr)/* Index of desired character. */
+ CONST TkTextIndex *indexPtr)/* Index of desired character. */
{
TkTextLine *linePtr;
@@ -6559,26 +6545,25 @@ TkTextPixelIndex(
}
*indexPtr = textPtr->topIndex;
return;
- }
- for (dlPtr = validDlPtr = dInfoPtr->dLinePtr;
- y >= (dlPtr->y + dlPtr->height);
- dlPtr = dlPtr->nextPtr) {
- if (dlPtr->chunkPtr != NULL) {
- validDlPtr = dlPtr;
- }
- if (dlPtr->nextPtr == NULL) {
- /*
- * Y-coordinate is off the bottom of the displayed text. Use the
- * last character on the last line.
- */
+ } else {
+ for (dlPtr = validDlPtr = dInfoPtr->dLinePtr;
+ y >= (dlPtr->y + dlPtr->height);
+ dlPtr = dlPtr->nextPtr) {
+ if (dlPtr->chunkPtr != NULL) {
+ validDlPtr = dlPtr;
+ }
+ if (dlPtr->nextPtr == NULL) {
+ /*
+ * Y-coordinate is off the bottom of the displayed text. Use
+ * the last character on the last line.
+ */
- x = dInfoPtr->maxX - 1;
- nearby = 1;
- break;
+ x = dInfoPtr->maxX - 1;
+ nearby = 1;
+ break;
+ }
}
- }
- if (dlPtr->chunkPtr == NULL) {
- dlPtr = validDlPtr;
+ if (dlPtr->chunkPtr == NULL) dlPtr = validDlPtr;
}
if (nearest != NULL) {
@@ -6671,7 +6656,7 @@ DlineIndexOfX(
*/
if (chunkPtr->numBytes > 1) {
- indexPtr->byteIndex += chunkPtr->measureProc(chunkPtr, x);
+ indexPtr->byteIndex += (*chunkPtr->measureProc)(chunkPtr, x);
}
}
@@ -6743,10 +6728,10 @@ DlineXOfIndex(
* coordinate. */
{
register TkTextDispChunk *chunkPtr = dlPtr->chunkPtr;
- int x = 0;
+ int x;
if (byteIndex == 0 || chunkPtr == NULL) {
- return x;
+ return 0;
}
/*
@@ -6759,14 +6744,15 @@ DlineXOfIndex(
if (byteIndex < chunkPtr->numBytes) {
int y, width, height;
- chunkPtr->bboxProc(textPtr, chunkPtr, byteIndex,
+ (*chunkPtr->bboxProc)(textPtr, chunkPtr, byteIndex,
dlPtr->y + dlPtr->spaceAbove,
dlPtr->height - dlPtr->spaceAbove - dlPtr->spaceBelow,
dlPtr->baseline - dlPtr->spaceAbove, &x, &y, &width,
&height);
break;
+ } else {
+ byteIndex -= chunkPtr->numBytes;
}
- byteIndex -= chunkPtr->numBytes;
if (chunkPtr->nextPtr == NULL || byteIndex == 0) {
x = chunkPtr->x + chunkPtr->width;
break;
@@ -6800,7 +6786,7 @@ DlineXOfIndex(
int
TkTextIndexBbox(
TkText *textPtr, /* Widget record for text widget. */
- const TkTextIndex *indexPtr,/* Index whose bounding box is desired. */
+ CONST TkTextIndex *indexPtr,/* Index whose bounding box is desired. */
int *xPtr, int *yPtr, /* Filled with index's upper-left
* coordinate. */
int *widthPtr, int *heightPtr,
@@ -6854,7 +6840,7 @@ TkTextIndexBbox(
* coordinate on the screen. Translate it to reflect horizontal scrolling.
*/
- chunkPtr->bboxProc(textPtr, chunkPtr, byteIndex,
+ (*chunkPtr->bboxProc)(textPtr, chunkPtr, byteIndex,
dlPtr->y + dlPtr->spaceAbove,
dlPtr->height - dlPtr->spaceAbove - dlPtr->spaceBelow,
dlPtr->baseline - dlPtr->spaceAbove, xPtr, yPtr, widthPtr,
@@ -6933,7 +6919,7 @@ TkTextIndexBbox(
int
TkTextDLineInfo(
TkText *textPtr, /* Widget record for text widget. */
- const TkTextIndex *indexPtr,/* Index of character whose bounding box is
+ CONST TkTextIndex *indexPtr,/* Index of character whose bounding box is
* desired. */
int *xPtr, int *yPtr, /* Filled with line's upper-left
* coordinate. */
@@ -7091,22 +7077,22 @@ TkTextCharLayoutProc(
#if TK_LAYOUT_WITH_BASE_CHUNKS
if (baseCharChunkPtr == NULL) {
baseCharChunkPtr = chunkPtr;
- bciPtr = ckalloc(sizeof(BaseCharInfo));
+ bciPtr = (BaseCharInfo *) ckalloc(sizeof(BaseCharInfo));
baseString = &bciPtr->baseChars;
Tcl_DStringInit(baseString);
bciPtr->width = 0;
ciPtr = &bciPtr->ci;
} else {
- bciPtr = baseCharChunkPtr->clientData;
- ciPtr = ckalloc(sizeof(CharInfo));
+ bciPtr = (BaseCharInfo *) baseCharChunkPtr->clientData;
+ ciPtr = (CharInfo *) ckalloc(sizeof(CharInfo));
baseString = &bciPtr->baseChars;
}
lineOffset = Tcl_DStringLength(baseString);
line = Tcl_DStringAppend(baseString,p,maxBytes);
- chunkPtr->clientData = ciPtr;
+ chunkPtr->clientData = (ClientData) ciPtr;
ciPtr->baseChunkPtr = baseCharChunkPtr;
ciPtr->baseOffset = lineOffset;
ciPtr->chars = NULL;
@@ -7162,7 +7148,7 @@ TkTextCharLayoutProc(
} else {
Tcl_DStringSetLength(baseString,lineOffset);
}
- ckfree(ciPtr);
+ ckfree((char *) ciPtr);
#endif /* TK_LAYOUT_WITH_BASE_CHUNKS */
return 0;
}
@@ -7188,8 +7174,9 @@ TkTextCharLayoutProc(
chunkPtr->breakIndex = -1;
#if !TK_LAYOUT_WITH_BASE_CHUNKS
- ciPtr = ckalloc((Tk_Offset(CharInfo, chars) + 1) + bytesThatFit);
- chunkPtr->clientData = ciPtr;
+ ciPtr = (CharInfo *)
+ ckalloc((unsigned) bytesThatFit + Tk_Offset(CharInfo, chars) + 1);
+ chunkPtr->clientData = (ClientData) ciPtr;
memcpy(ciPtr->chars, p, (unsigned) bytesThatFit);
#endif /* TK_LAYOUT_WITH_BASE_CHUNKS */
@@ -7227,21 +7214,11 @@ TkTextCharLayoutProc(
} else {
for (count = bytesThatFit, p += bytesThatFit - 1; count > 0;
count--, p--) {
- /*
- * Don't use isspace(); effects are unpredictable and can lead to
- * odd word-wrapping problems on some platforms. Also don't use
- * Tcl_UniCharIsSpace here either, as it identifies non-breaking
- * spaces as places to break. What we actually want is only the
- * ASCII space characters, so use them explicitly...
- */
-
- switch (*p) {
- case '\t': case '\n': case '\v': case '\f': case '\r': case ' ':
+ if (UCHAR(*p) < 0x80 && isspace(UCHAR(*p))) {
chunkPtr->breakIndex = count;
- goto checkForNextChunk;
+ break;
}
}
- checkForNextChunk:
if ((bytesThatFit + byteOffset) == segPtr->size) {
for (nextPtr = segPtr->nextPtr; nextPtr != NULL;
nextPtr = nextPtr->nextPtr) {
@@ -7301,7 +7278,7 @@ CharChunkMeasureChars(
* here. */
{
Tk_Font tkfont = chunkPtr->stylePtr->sValuePtr->tkfont;
- CharInfo *ciPtr = chunkPtr->clientData;
+ CharInfo *ciPtr = (CharInfo *) chunkPtr->clientData;
#if !TK_LAYOUT_WITH_BASE_CHUNKS
if (chars == NULL) {
@@ -7314,7 +7291,7 @@ CharChunkMeasureChars(
return MeasureChars(tkfont, chars, charsLen, start, end-start,
startX, maxX, flags, nextXPtr);
-#else /* TK_LAYOUT_WITH_BASE_CHUNKS */
+#else
{
int xDisplacement;
int fit, bstart = start, bend = end;
@@ -7354,7 +7331,7 @@ CharChunkMeasureChars(
return fit - bstart;
}
}
-#endif /* TK_LAYOUT_WITH_BASE_CHUNKS */
+#endif
}
/*
@@ -7390,7 +7367,7 @@ CharDisplayProc(
int screenY) /* Y-coordinate in text window that
* corresponds to y. */
{
- CharInfo *ciPtr = chunkPtr->clientData;
+ CharInfo *ciPtr = (CharInfo *) chunkPtr->clientData;
const char *string;
TextStyle *stylePtr;
StyleValues *sValuePtr;
@@ -7408,7 +7385,7 @@ CharDisplayProc(
}
#if TK_DRAW_IN_CONTEXT
- bciPtr = ciPtr->baseChunkPtr->clientData;
+ bciPtr = (BaseCharInfo *) ciPtr->baseChunkPtr->clientData;
numBytes = Tcl_DStringLength(&bciPtr->baseChars);
string = Tcl_DStringValue(&bciPtr->baseChars);
@@ -7541,7 +7518,7 @@ CharUndisplayProc(
TkText *textPtr, /* Overall information about text widget. */
TkTextDispChunk *chunkPtr) /* Chunk that is about to be freed. */
{
- CharInfo *ciPtr = chunkPtr->clientData;
+ CharInfo *ciPtr = (CharInfo *) chunkPtr->clientData;
if (ciPtr) {
#if TK_LAYOUT_WITH_BASE_CHUNKS
@@ -7568,7 +7545,7 @@ CharUndisplayProc(
ciPtr->numBytes = 0;
#endif /* TK_LAYOUT_WITH_BASE_CHUNKS */
- ckfree(ciPtr);
+ ckfree((char *) ciPtr);
chunkPtr->clientData = NULL;
}
}
@@ -7644,7 +7621,7 @@ CharBboxProc(
int *heightPtr) /* Gets filled in with height of character, in
* pixels. */
{
- CharInfo *ciPtr = chunkPtr->clientData;
+ CharInfo *ciPtr = (CharInfo *) chunkPtr->clientData;
int maxX;
maxX = chunkPtr->width + chunkPtr->x;
@@ -7807,7 +7784,7 @@ AdjustForTab(
if (chunkPtr2->displayProc != CharDisplayProc) {
continue;
}
- ciPtr = chunkPtr2->clientData;
+ ciPtr = (CharInfo *) chunkPtr2->clientData;
for (p = ciPtr->chars, i = 0; i < ciPtr->numBytes; p++, i++) {
if (isdigit(UCHAR(*p))) {
gotDigit = 1;
@@ -7828,23 +7805,23 @@ AdjustForTab(
if (decimalChunkPtr != NULL) {
int curX;
- ciPtr = decimalChunkPtr->clientData;
+ ciPtr = (CharInfo *) decimalChunkPtr->clientData;
CharChunkMeasureChars(decimalChunkPtr, NULL, 0, 0, decimal,
decimalChunkPtr->x, -1, 0, &curX);
desired = tabX - (curX - x);
goto update;
- }
-
- /*
- * There wasn't a decimal point. Right justify the text.
- */
+ } else {
+ /*
+ * There wasn't a decimal point. Right justify the text.
+ */
- width = 0;
- for (chunkPtr2 = chunkPtr->nextPtr; chunkPtr2 != NULL;
- chunkPtr2 = chunkPtr2->nextPtr) {
- width += chunkPtr2->width;
+ width = 0;
+ for (chunkPtr2 = chunkPtr->nextPtr; chunkPtr2 != NULL;
+ chunkPtr2 = chunkPtr2->nextPtr) {
+ width += chunkPtr2->width;
+ }
+ desired = tabX - width;
}
- desired = tabX - width;
/*
* Shift all of the chunks to the right so that the left edge is at the
@@ -8082,7 +8059,7 @@ NextTabStop(
static int
MeasureChars(
Tk_Font tkfont, /* Font in which to draw characters. */
- const char *source, /* Characters to be displayed. Need not be
+ CONST char *source, /* Characters to be displayed. Need not be
* NULL-terminated. */
int maxBytes, /* Maximum # of bytes to consider from
* source. */
@@ -8097,7 +8074,7 @@ MeasureChars(
* here. */
{
int curX, width, ch;
- const char *special, *end, *start;
+ CONST char *special, *end, *start;
ch = 0; /* lint. */
curX = startX;
@@ -8144,10 +8121,11 @@ MeasureChars(
break;
}
if (special < end) {
- if (ch != '\t') {
+ if (ch == '\t') {
+ start++;
+ } else {
break;
}
- start++;
}
}
@@ -8188,19 +8166,19 @@ TextGetScrollInfoObj(
Tcl_Interp *interp, /* Used for error reporting. */
TkText *textPtr, /* Information about the text widget. */
int objc, /* # arguments for command. */
- Tcl_Obj *const objv[], /* Arguments for command. */
+ Tcl_Obj *CONST objv[], /* Arguments for command. */
double *dblPtr, /* Filled in with argument "moveto" option, if
* any. */
int *intPtr) /* Filled in with number of pages or lines or
* pixels to scroll, if any. */
{
- static const char *const subcommands[] = {
+ static CONST char *subcommands[] = {
"moveto", "scroll", NULL
};
enum viewSubcmds {
VIEW_MOVETO, VIEW_SCROLL
};
- static const char *const units[] = {
+ static CONST char *units[] = {
"units", "pages", "pixels", NULL
};
enum viewUnits {
@@ -8208,8 +8186,8 @@ TextGetScrollInfoObj(
};
int index;
- if (Tcl_GetIndexFromObjStruct(interp, objv[2], subcommands,
- sizeof(char *), "option", 0, &index) != TCL_OK) {
+ if (Tcl_GetIndexFromObj(interp, objv[2], subcommands, "option", 0,
+ &index) != TCL_OK) {
return TKTEXT_SCROLL_ERROR;
}
@@ -8228,8 +8206,8 @@ TextGetScrollInfoObj(
Tcl_WrongNumArgs(interp, 3, objv, "number units|pages|pixels");
return TKTEXT_SCROLL_ERROR;
}
- if (Tcl_GetIndexFromObjStruct(interp, objv[4], units,
- sizeof(char *), "argument", 0, &index) != TCL_OK) {
+ if (Tcl_GetIndexFromObj(interp, objv[4], units, "argument", 0,
+ &index) != TCL_OK) {
return TKTEXT_SCROLL_ERROR;
}
switch ((enum viewUnits) index) {
@@ -8307,7 +8285,7 @@ FinalizeBaseChunk(
if (chunkPtr->displayProc != CharDisplayProc) {
continue;
}
- ciPtr = chunkPtr->clientData;
+ ciPtr = (CharInfo *)chunkPtr->clientData;
if (ciPtr->baseChunkPtr != baseCharChunkPtr) {
break;
}
@@ -8324,7 +8302,7 @@ FinalizeBaseChunk(
}
if (addChunkPtr != NULL) {
- ciPtr = addChunkPtr->clientData;
+ ciPtr = (CharInfo *)addChunkPtr->clientData;
ciPtr->chars = baseChars + ciPtr->baseOffset;
#if TK_DRAW_IN_CONTEXT
@@ -8375,7 +8353,7 @@ FreeBaseChunk(
if (chunkPtr->undisplayProc != CharUndisplayProc) {
continue;
}
- ciPtr = chunkPtr->clientData;
+ ciPtr = (CharInfo *) chunkPtr->clientData;
if (ciPtr->baseChunkPtr != baseChunkPtr) {
break;
}
@@ -8384,9 +8362,7 @@ FreeBaseChunk(
ciPtr->chars = NULL;
}
- if (baseChunkPtr) {
- Tcl_DStringFree(&((BaseCharInfo *) baseChunkPtr->clientData)->baseChars);
- }
+ Tcl_DStringFree(&((BaseCharInfo *) baseChunkPtr->clientData)->baseChars);
}
/*
@@ -8495,14 +8471,14 @@ RemoveFromBaseChunk(
* Reinstitute this base chunk for re-layout.
*/
- ciPtr = chunkPtr->clientData;
+ ciPtr = (CharInfo *) chunkPtr->clientData;
baseCharChunkPtr = ciPtr->baseChunkPtr;
/*
* Remove the chunk data from the base chunk data.
*/
- bciPtr = baseCharChunkPtr->clientData;
+ bciPtr = (BaseCharInfo *) baseCharChunkPtr->clientData;
if ((ciPtr->baseOffset + ciPtr->numBytes)
!= Tcl_DStringLength(&bciPtr->baseChars)) {