diff options
author | fvogel <fvogelnew1@free.fr> | 2020-04-19 09:34:18 (GMT) |
---|---|---|
committer | fvogel <fvogelnew1@free.fr> | 2020-04-19 09:34:18 (GMT) |
commit | a485a445252972c78b1296013f221f7f838c438b (patch) | |
tree | 4f67cb0cd868a3cd786babaef5feb3f0125915bf /generic/tkEntry.c | |
parent | 0cd29bb998be0312bd2230570521fa68c55fc6fa (diff) | |
download | tk-a485a445252972c78b1296013f221f7f838c438b.zip tk-a485a445252972c78b1296013f221f7f838c438b.tar.gz tk-a485a445252972c78b1296013f221f7f838c438b.tar.bz2 |
Fix [7655f65ae7]: text positioning issues in entry widgets. This is a patch from Christopher Chavez, slightly modified, and addresses the bug for Windows, Linux and macOS.
Diffstat (limited to 'generic/tkEntry.c')
-rw-r--r-- | generic/tkEntry.c | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/generic/tkEntry.c b/generic/tkEntry.c index 9c53769..27bcfe1 100644 --- a/generic/tkEntry.c +++ b/generic/tkEntry.c @@ -1727,18 +1727,14 @@ DisplayEntry( } } - /* - * Draw the text in two pieces: first the unselected portion, then the - * selected portion on top of it. - */ - - Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->textGC, - entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY, - entryPtr->leftIndex, entryPtr->numChars); - if (showSelection && (entryPtr->state != STATE_DISABLED) && (entryPtr->selTextGC != entryPtr->textGC) && (entryPtr->selectFirst < entryPtr->selectLast)) { + + /* + * Draw the selected and unselected portions separately. + */ + int selFirst; if (entryPtr->selectFirst < entryPtr->leftIndex) { @@ -1746,9 +1742,28 @@ DisplayEntry( } else { selFirst = entryPtr->selectFirst; } + if (entryPtr->leftIndex < selFirst) { + Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->textGC, + entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY, + entryPtr->leftIndex, selFirst); + } Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->selTextGC, entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY, selFirst, entryPtr->selectLast); + if (entryPtr->selectLast < entryPtr->numChars) { + Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->textGC, + entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY, + entryPtr->selectLast, entryPtr->numChars); + } + } else { + + /* + * Draw the entire visible text + */ + + Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->textGC, + entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY, + entryPtr->leftIndex, entryPtr->numChars); } if (entryPtr->type == TK_SPINBOX) { |