# HG changeset patch # User Frank Benoit # Date 1219410919 -7200 # Node ID 1973f21c5c6fe00a0fb0eab9345d183bc374e50d # Parent 810b16d6559bd5d7f6beb13700c54b20b9910ea8 Fix: mouse selection for TextLayout diff -r 810b16d6559b -r 1973f21c5c6f dwt/graphics/TextLayout.d --- a/dwt/graphics/TextLayout.d Fri Aug 22 09:12:35 2008 +0200 +++ b/dwt/graphics/TextLayout.d Fri Aug 22 15:15:19 2008 +0200 @@ -734,7 +734,7 @@ if (run.lineBreak && !run.softBreak) { if (selectionStart <= run.start && run.start <= selectionEnd) extents = true; } else { - int endOffset = run.start + run.length - 1; + int endOffset = segmentsText.getAbsoluteCodePointOffset( run.start + run.length, -1 ); if (selectionStart <= endOffset && endOffset < selectionEnd && (flags & DWT.FULL_SELECTION) !is 0) { extents = true; } @@ -799,17 +799,17 @@ } bool partialSelection = hasSelection && !(selectionStart > end || run.start > selectionEnd); if (partialSelection) { - int selStart = Math.max(selectionStart, run.start) - run.start; - int selEnd = Math.min(selectionEnd, end) - run.start; + int selStart = index8to16[ Math.max(selectionStart, run.start) ] - index8to16[run.start]; + int selEnd = index8to16[ Math.min(selectionEnd, end) ] - index8to16[ run.start ]; int cChars = index8to16[run.start+run.length] - index8to16[run.start]; // make it wchar int gGlyphs = run.glyphCount; int piX; int* advances = run.justify !is null ? run.justify : run.advances; - OS.ScriptCPtoX(index8to16[selStart], false, cChars, gGlyphs, run.clusters, run.visAttrs, advances, &run.analysis, &piX); + OS.ScriptCPtoX(selStart, false, cChars, gGlyphs, run.clusters, run.visAttrs, advances, &run.analysis, &piX); int runX = (orientation & DWT.RIGHT_TO_LEFT) !is 0 ? run.width - piX : piX; rect.left = drawX + runX; rect.top = drawY; - OS.ScriptCPtoX(index8to16[selEnd], true, cChars, gGlyphs, run.clusters, run.visAttrs, advances, &run.analysis, &piX); + OS.ScriptCPtoX(selEnd, true, cChars, gGlyphs, run.clusters, run.visAttrs, advances, &run.analysis, &piX); runX = (orientation & DWT.RIGHT_TO_LEFT) !is 0 ? run.width - piX : piX; rect.right = drawX + runX; rect.bottom = drawY + lineHeight;