diff options
author | fvogel <fvogelnew1@free.fr> | 2022-01-05 20:33:39 (GMT) |
---|---|---|
committer | fvogel <fvogelnew1@free.fr> | 2022-01-05 20:33:39 (GMT) |
commit | 5d20906695103bcff6e8b250372db81d240ac320 (patch) | |
tree | 45afac43dc944567608f67106a234a9ba3b1733d /generic/tkTextDisp.c | |
parent | 7bd95f1d4f8ac4e2de1aaf5f769cefd4da481cbf (diff) | |
parent | 8a3569b1a0838f8f500218837c0ff6ef13ac93cd (diff) | |
download | tk-5d20906695103bcff6e8b250372db81d240ac320.zip tk-5d20906695103bcff6e8b250372db81d240ac320.tar.gz tk-5d20906695103bcff6e8b250372db81d240ac320.tar.bz2 |
merge 8.6
Diffstat (limited to 'generic/tkTextDisp.c')
-rw-r--r-- | generic/tkTextDisp.c | 79 |
1 files changed, 41 insertions, 38 deletions
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index e80e024..6645912 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -153,7 +153,7 @@ typedef struct StyleValues { int spacing3; /* Spacing below last dline in text line. */ TkTextTabArray *tabArrayPtr;/* Locations and types of tab stops (may be * NULL). */ - int tabStyle; /* One of TABULAR or WORDPROCESSOR. */ + int tabStyle; /* One of TK_TEXT_TABSTYLE_TABULAR or TK_TEXT_TABSTYLE_WORDPROCESSOR. */ int underline; /* Non-zero means draw underline underneath * text. */ XColor *underlineColor; /* Foreground color for underline underneath @@ -440,7 +440,7 @@ typedef struct TextDInfo { * points to one of the following structures: */ -#if !TK_LAYOUT_WITH_BASE_CHUNKS +#ifndef TK_LAYOUT_WITH_BASE_CHUNKS typedef struct CharInfo { int numBytes; /* Number of bytes to display. */ @@ -552,7 +552,7 @@ static void CharDisplayProc(TkText *textPtr, static int CharMeasureProc(TkTextDispChunk *chunkPtr, int x); static void CharUndisplayProc(TkText *textPtr, TkTextDispChunk *chunkPtr); -#if TK_LAYOUT_WITH_BASE_CHUNKS +#ifdef TK_LAYOUT_WITH_BASE_CHUNKS static void FinalizeBaseChunk(TkTextDispChunk *additionalChunkPtr); static void FreeBaseChunk(TkTextDispChunk *baseChunkPtr); static int IsSameFGStyle(TextStyle *style1, TextStyle *style2); @@ -965,7 +965,8 @@ GetStyle( styleValues.tabArrayPtr = tagPtr->tabArrayPtr; tabPrio = tagPtr->priority; } - if ((tagPtr->tabStyle != TK_TEXT_TABSTYLE_NONE) + if (((tagPtr->tabStyle == TK_TEXT_TABSTYLE_TABULAR) + || (tagPtr->tabStyle == TK_TEXT_TABSTYLE_WORDPROCESSOR)) && (tagPtr->priority > tabStylePrio)) { styleValues.tabStyle = tagPtr->tabStyle; tabStylePrio = tagPtr->priority; @@ -985,7 +986,9 @@ GetStyle( styleValues.elide = tagPtr->elide; elidePrio = tagPtr->priority; } - if ((tagPtr->wrapMode != TEXT_WRAPMODE_NULL) + if (((tagPtr->wrapMode == TEXT_WRAPMODE_CHAR) + || (tagPtr->wrapMode == TEXT_WRAPMODE_NONE) + || (tagPtr->wrapMode == TEXT_WRAPMODE_WORD)) && (tagPtr->priority > wrapPrio)) { styleValues.wrapMode = tagPtr->wrapMode; wrapPrio = tagPtr->priority; @@ -1170,7 +1173,7 @@ LayoutDLine( * chunk. */ TkTextTabArray *tabArrayPtr;/* Tab stops for line; taken from style for * the first character on line. */ - int tabStyle; /* One of TABULAR or WORDPROCESSOR. */ + int tabStyle; /* One of TK_TEXT_TABSTYLE_TABULAR or TK_TEXT_TABSTYLE_WORDPROCESSOR. */ int tabSize; /* Number of pixels consumed by current tab * stop. */ TkTextDispChunk *lastCharChunkPtr; @@ -1507,7 +1510,7 @@ LayoutDLine( } } -#if TK_LAYOUT_WITH_BASE_CHUNKS +#ifdef TK_LAYOUT_WITH_BASE_CHUNKS if (baseCharChunkPtr != NULL) { int expectedX = ((BaseCharInfo *) baseCharChunkPtr->clientData)->width @@ -1649,7 +1652,7 @@ LayoutDLine( chunkPtr = NULL; } -#if TK_LAYOUT_WITH_BASE_CHUNKS +#ifdef TK_LAYOUT_WITH_BASE_CHUNKS FinalizeBaseChunk(NULL); #endif /* TK_LAYOUT_WITH_BASE_CHUNKS */ if (noCharsYet) { @@ -1708,7 +1711,7 @@ LayoutDLine( segPtr->typePtr->layoutProc(textPtr, &breakIndex, segPtr, byteOffset, maxX, breakByteOffset, 0, wrapMode, breakChunkPtr); -#if TK_LAYOUT_WITH_BASE_CHUNKS +#ifdef TK_LAYOUT_WITH_BASE_CHUNKS FinalizeBaseChunk(NULL); #endif /* TK_LAYOUT_WITH_BASE_CHUNKS */ } @@ -7625,7 +7628,7 @@ TkTextCharLayoutProc( char *p; TkTextSegment *nextPtr; Tk_FontMetrics fm; -#if TK_LAYOUT_WITH_BASE_CHUNKS +#ifdef TK_LAYOUT_WITH_BASE_CHUNKS const char *line; int lineOffset; BaseCharInfo *bciPtr; @@ -7650,18 +7653,18 @@ TkTextCharLayoutProc( p = segPtr->body.chars + byteOffset; tkfont = chunkPtr->stylePtr->sValuePtr->tkfont; -#if TK_LAYOUT_WITH_BASE_CHUNKS +#ifdef 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; } @@ -7687,7 +7690,7 @@ TkTextCharLayoutProc( int ch; int chLen = TkUtfToUniChar(p, &ch); -#if TK_LAYOUT_WITH_BASE_CHUNKS +#ifdef TK_LAYOUT_WITH_BASE_CHUNKS bytesThatFit = CharChunkMeasureChars(chunkPtr, line, lineOffset+chLen, lineOffset, -1, chunkPtr->x, -1, 0, &nextX); @@ -7731,7 +7734,7 @@ TkTextCharLayoutProc( bytesThatFit++; } if (bytesThatFit == 0) { -#if TK_LAYOUT_WITH_BASE_CHUNKS +#ifdef TK_LAYOUT_WITH_BASE_CHUNKS chunkPtr->clientData = NULL; if (chunkPtr == baseCharChunkPtr) { baseCharChunkPtr = NULL; @@ -7764,7 +7767,7 @@ TkTextCharLayoutProc( chunkPtr->width = nextX - chunkPtr->x; chunkPtr->breakIndex = -1; -#if !TK_LAYOUT_WITH_BASE_CHUNKS +#ifndef TK_LAYOUT_WITH_BASE_CHUNKS ciPtr = (CharInfo *)ckalloc((Tk_Offset(CharInfo, chars) + 1) + bytesThatFit); chunkPtr->clientData = ciPtr; memcpy(ciPtr->chars, p, bytesThatFit); @@ -7775,7 +7778,7 @@ TkTextCharLayoutProc( ciPtr->numBytes--; } -#if TK_LAYOUT_WITH_BASE_CHUNKS +#ifdef TK_LAYOUT_WITH_BASE_CHUNKS /* * Final update for the current base chunk data. */ @@ -7880,7 +7883,7 @@ CharChunkMeasureChars( Tk_Font tkfont = chunkPtr->stylePtr->sValuePtr->tkfont; CharInfo *ciPtr = (CharInfo *)chunkPtr->clientData; -#if !TK_LAYOUT_WITH_BASE_CHUNKS +#ifndef TK_LAYOUT_WITH_BASE_CHUNKS if (chars == NULL) { chars = ciPtr->chars; charsLen = ciPtr->numBytes; @@ -7972,7 +7975,7 @@ CharDisplayProc( TextStyle *stylePtr; StyleValues *sValuePtr; int numBytes, offsetBytes, offsetX; -#if TK_DRAW_IN_CONTEXT +#ifdef TK_DRAW_IN_CONTEXT BaseCharInfo *bciPtr; #endif /* TK_DRAW_IN_CONTEXT */ @@ -7984,12 +7987,12 @@ CharDisplayProc( return; } -#if TK_DRAW_IN_CONTEXT - bciPtr = ciPtr->baseChunkPtr->clientData; +#ifdef TK_DRAW_IN_CONTEXT + bciPtr = (BaseCharInfo *)ciPtr->baseChunkPtr->clientData; numBytes = Tcl_DStringLength(&bciPtr->baseChars); string = Tcl_DStringValue(&bciPtr->baseChars); -#elif TK_LAYOUT_WITH_BASE_CHUNKS +#elif defined(TK_LAYOUT_WITH_BASE_CHUNKS) if (ciPtr->baseChunkPtr != chunkPtr) { /* * Without context drawing only base chunks display their foreground. @@ -8030,7 +8033,7 @@ CharDisplayProc( if (!sValuePtr->elide && (numBytes > offsetBytes) && (stylePtr->fgGC != NULL)) { -#if TK_DRAW_IN_CONTEXT +#ifdef TK_DRAW_IN_CONTEXT int start = ciPtr->baseOffset + offsetBytes; int len = ciPtr->numBytes - offsetBytes; int xDisplacement = x - chunkPtr->x; @@ -8121,7 +8124,7 @@ CharUndisplayProc( CharInfo *ciPtr = (CharInfo *)chunkPtr->clientData; if (ciPtr) { -#if TK_LAYOUT_WITH_BASE_CHUNKS +#ifdef TK_LAYOUT_WITH_BASE_CHUNKS if (chunkPtr == ciPtr->baseChunkPtr) { /* * Basechunks are undisplayed first, when DLines are freed or @@ -8703,7 +8706,7 @@ MeasureChars( if ((maxX >= 0) && (curX >= maxX)) { break; } -#if TK_DRAW_IN_CONTEXT +#ifdef TK_DRAW_IN_CONTEXT start += TkpMeasureCharsInContext(tkfont, source, maxBytes, start - source, special - start, maxX >= 0 ? maxX - curX : -1, flags, &width); @@ -8833,7 +8836,7 @@ TextGetScrollInfoObj( return TKTEXT_SCROLL_ERROR; } -#if TK_LAYOUT_WITH_BASE_CHUNKS +#ifdef TK_LAYOUT_WITH_BASE_CHUNKS /* *---------------------------------------------------------------------- * @@ -8864,7 +8867,7 @@ FinalizeBaseChunk( const char *baseChars; TkTextDispChunk *chunkPtr; CharInfo *ciPtr; -#if TK_DRAW_IN_CONTEXT +#ifdef TK_DRAW_IN_CONTEXT int widthAdjust = 0; int newwidth; #endif /* TK_DRAW_IN_CONTEXT */ @@ -8878,20 +8881,20 @@ FinalizeBaseChunk( for (chunkPtr = baseCharChunkPtr; chunkPtr != NULL; chunkPtr = chunkPtr->nextPtr) { -#if TK_DRAW_IN_CONTEXT +#ifdef TK_DRAW_IN_CONTEXT chunkPtr->x += widthAdjust; #endif /* TK_DRAW_IN_CONTEXT */ if (chunkPtr->displayProc != CharDisplayProc) { continue; } - ciPtr = chunkPtr->clientData; + ciPtr = (CharInfo *)chunkPtr->clientData; if (ciPtr->baseChunkPtr != baseCharChunkPtr) { break; } ciPtr->chars = baseChars + ciPtr->baseOffset; -#if TK_DRAW_IN_CONTEXT +#ifdef TK_DRAW_IN_CONTEXT newwidth = 0; CharChunkMeasureChars(chunkPtr, NULL, 0, 0, -1, 0, -1, 0, &newwidth); if (newwidth < chunkPtr->width) { @@ -8902,10 +8905,10 @@ FinalizeBaseChunk( } if (addChunkPtr != NULL) { - ciPtr = addChunkPtr->clientData; + ciPtr = (CharInfo *)addChunkPtr->clientData; ciPtr->chars = baseChars + ciPtr->baseOffset; -#if TK_DRAW_IN_CONTEXT +#ifdef TK_DRAW_IN_CONTEXT addChunkPtr->x += widthAdjust; CharChunkMeasureChars(addChunkPtr, NULL, 0, 0, -1, 0, -1, 0, &addChunkPtr->width); @@ -8953,7 +8956,7 @@ FreeBaseChunk( if (chunkPtr->undisplayProc != CharUndisplayProc) { continue; } - ciPtr = chunkPtr->clientData; + ciPtr = (CharInfo *)chunkPtr->clientData; if (ciPtr->baseChunkPtr != baseChunkPtr) { break; } @@ -9003,7 +9006,7 @@ IsSameFGStyle( return 1; } -#if !TK_DRAW_IN_CONTEXT +#ifndef TK_DRAW_IN_CONTEXT if ( #ifdef MAC_OSX_TK !TkMacOSXCompareColors(style1->fgGC->foreground, @@ -9019,7 +9022,7 @@ IsSameFGStyle( sv1 = style1->sValuePtr; sv2 = style2->sValuePtr; -#if TK_DRAW_IN_CONTEXT +#ifdef TK_DRAW_IN_CONTEXT return sv1->tkfont == sv2->tkfont && sv1->offset == sv2->offset; #else return sv1->tkfont == sv2->tkfont @@ -9073,14 +9076,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; #ifdef DEBUG_LAYOUT_WITH_BASE_CHUNKS if ((ciPtr->baseOffset + ciPtr->numBytes) |