diff options
Diffstat (limited to 'generic/tkTextDisp.c')
| -rw-r--r-- | generic/tkTextDisp.c | 50 |
1 files changed, 40 insertions, 10 deletions
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index c8df68b..93e9c26 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -1170,7 +1170,8 @@ LayoutDLine( * numBytes > 0. Used to drop 0-sized chunks * from the end of the line. */ Tcl_Size byteOffset; - int ascent, descent, code, elide, elidesize; + int ascent, descent, code, elidesize; + bool elide; StyleValues *sValuePtr; TkTextElideInfo info; /* Keep track of elide state. */ @@ -7357,15 +7358,24 @@ TkTextIndexBbox( * coordinate. */ int *widthPtr, int *heightPtr, /* Filled in with index's dimensions. */ - int *charWidthPtr) /* If the 'index' is at the end of a display + int *charWidthPtr, /* If the 'index' is at the end of a display * line and therefore takes up a very large * width, this is used to return the smaller * width actually desired by the index. */ + int *cursorWidthPtr) /* Receives the same value as 'charWidthPtr' + * except when indexPtr points to a Tab. Then + * 'cursorWidthPtr' gets reduced to the width + * of a single space. */ { TextDInfo *dInfoPtr = textPtr->dInfoPtr; DLine *dlPtr; TkTextDispChunk *chunkPtr; Tcl_Size byteCount; + int dummy; + + if (charWidthPtr == NULL) { + charWidthPtr = &dummy; + } /* * Make sure that all of the screen layout information is up to date. @@ -7431,20 +7441,16 @@ TkTextIndexBbox( * line. */ - if (charWidthPtr != NULL) { - *charWidthPtr = dInfoPtr->maxX - *xPtr; - if (*charWidthPtr > textPtr->charWidth) { - *charWidthPtr = textPtr->charWidth; - } + *charWidthPtr = dInfoPtr->maxX - *xPtr; + if (*charWidthPtr > textPtr->charWidth) { + *charWidthPtr = textPtr->charWidth; } if (*xPtr > dInfoPtr->maxX) { *xPtr = dInfoPtr->maxX; } *widthPtr = dInfoPtr->maxX - *xPtr; } else { - if (charWidthPtr != NULL) { - *charWidthPtr = *widthPtr; - } + *charWidthPtr = *widthPtr; } if (*widthPtr == 0) { /* @@ -7472,6 +7478,30 @@ TkTextIndexBbox( return -1; } } + + /* + * For a block cursor on a tab, cursorWidthPtr is the whitespace width. + */ + + if (cursorWidthPtr != NULL) { + *cursorWidthPtr = *charWidthPtr; + if (chunkPtr->bboxProc == CharBboxProc) { + CharInfo *ciPtr = (CharInfo*)chunkPtr->clientData; +#ifdef TK_LAYOUT_WITH_BASE_CHUNKS + BaseCharInfo *bciPtr = + (BaseCharInfo*)ciPtr->baseChunkPtr->clientData; + char *chars = Tcl_DStringValue(&bciPtr->baseChars); + + if (chars[ciPtr->baseOffset + byteCount] == '\t') +#else + if (ciPtr->chars[byteCount] == '\t') +#endif + { + CharChunkMeasureChars(chunkPtr, " ", 1, 0, 1, + 0, -1, 0, cursorWidthPtr); + } + } + } return 0; } |
