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/ttk | |
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/ttk')
-rw-r--r-- | generic/ttk/ttkEntry.c | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c index 96f3cf2..05b4c3b 100644 --- a/generic/ttk/ttkEntry.c +++ b/generic/ttk/ttkEntry.c @@ -1274,16 +1274,27 @@ static void EntryDisplay(void *clientData, Drawable d) /* Draw the text: */ gc = EntryGetGC(entryPtr, es.foregroundObj, clipRegion); - Tk_DrawTextLayout( - Tk_Display(tkwin), d, gc, entryPtr->entry.textLayout, - entryPtr->entry.layoutX, entryPtr->entry.layoutY, - leftIndex, rightIndex); - XSetClipMask(Tk_Display(tkwin), gc, None); - Tk_FreeGC(Tk_Display(tkwin), gc); - - /* Overwrite the selected portion (if any) in the -selectforeground color: - */ if (showSelection) { + + /* Draw the selected and unselected portions separately. + */ + if (leftIndex < selFirst) { + Tk_DrawTextLayout( + Tk_Display(tkwin), d, gc, entryPtr->entry.textLayout, + entryPtr->entry.layoutX, entryPtr->entry.layoutY, + leftIndex, selFirst); + } + if (selLast < rightIndex) { + Tk_DrawTextLayout( + Tk_Display(tkwin), d, gc, entryPtr->entry.textLayout, + entryPtr->entry.layoutX, entryPtr->entry.layoutY, + selLast, rightIndex); + } + XSetClipMask(Tk_Display(tkwin), gc, None); + Tk_FreeGC(Tk_Display(tkwin), gc); + + /* Draw the selected portion in the -selectforeground color: + */ gc = EntryGetGC(entryPtr, es.selForegroundObj, clipRegion); Tk_DrawTextLayout( Tk_Display(tkwin), d, gc, entryPtr->entry.textLayout, @@ -1291,6 +1302,16 @@ static void EntryDisplay(void *clientData, Drawable d) selFirst, selLast); XSetClipMask(Tk_Display(tkwin), gc, None); Tk_FreeGC(Tk_Display(tkwin), gc); + } else { + + /* Draw the entire visible text + */ + Tk_DrawTextLayout( + Tk_Display(tkwin), d, gc, entryPtr->entry.textLayout, + entryPtr->entry.layoutX, entryPtr->entry.layoutY, + leftIndex, rightIndex); + XSetClipMask(Tk_Display(tkwin), gc, None); + Tk_FreeGC(Tk_Display(tkwin), gc); } /* Drop the region. Note that we have to manually remove the reference to |