diff options
author | fvogel <fvogelnew1@free.fr> | 2020-07-13 16:48:27 (GMT) |
---|---|---|
committer | fvogel <fvogelnew1@free.fr> | 2020-07-13 16:48:27 (GMT) |
commit | e3c3dc8cec595c0593949fa1a690e842ae88df76 (patch) | |
tree | 5cd95ac9a88a4f35c5067b2238a9e2b39b4308e4 /generic/ttk | |
parent | 056dad5a85b3eb0404c0a805562fd207c8eb8217 (diff) | |
parent | 3513bf85582d9033914baf40f8e8a1fb42270d93 (diff) | |
download | tk-e3c3dc8cec595c0593949fa1a690e842ae88df76.zip tk-e3c3dc8cec595c0593949fa1a690e842ae88df76.tar.gz tk-e3c3dc8cec595c0593949fa1a690e842ae88df76.tar.bz2 |
Fix [7655f65ae7]: text positioning issues in entry widgets. Patch from Christopher Chavez.
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 cbc3b3f..4314a83 100644 --- a/generic/ttk/ttkEntry.c +++ b/generic/ttk/ttkEntry.c @@ -1317,16 +1317,27 @@ static void EntryDisplay(void *clientData, Drawable d) foregroundObj = es.foregroundObj; } gc = EntryGetGC(entryPtr, 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, @@ -1334,6 +1345,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 |