Mercurial > projects > dwt-win
diff dwt/custom/StyledText.d @ 275:9c5ba1f00519
Fix: delete the whole codepoint for backspace.
Fix: getPointAtPosition handle whole codepoints correctly.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Tue, 05 Aug 2008 00:51:33 +0200 |
parents | 62a03a4c21c8 |
children |
line wrap: on
line diff
--- a/dwt/custom/StyledText.d Sun Aug 03 23:40:57 2008 +0200 +++ b/dwt/custom/StyledText.d Tue Aug 05 00:51:33 2008 +0200 @@ -2240,12 +2240,13 @@ int lineIndex = content.getLineAtOffset(caretOffset); int lineOffset = content.getOffsetAtLine(lineIndex); if (caretOffset is lineOffset) { + // DWT: on line start, delete line break lineOffset = content.getOffsetAtLine(lineIndex - 1); event.start = lineOffset + content.getLine(lineIndex - 1).length; event.end = caretOffset; } else { TextLayout layout = renderer.getTextLayout(lineIndex); - int start = layout.getPreviousOffset(caretOffset - lineOffset, DWT.MOVEMENT_CHAR); + int start = layout.getPreviousOffset(caretOffset - lineOffset, DWT.MOVEMENT_CLUSTER); renderer.disposeTextLayout(layout); event.start = start + lineOffset; event.end = caretOffset; @@ -3987,7 +3988,7 @@ int getOffsetAtPoint(int x, int y, int lineIndex) { TextLayout layout = renderer.getTextLayout(lineIndex); x += horizontalScrollOffset - leftMargin; - int[] trailing = new int[1]; + int[1] trailing; int offsetInLine = layout.getOffset(x, y, trailing); caretAlignment = OFFSET_LEADING; if (trailing[0] !is 0) { @@ -4909,7 +4910,9 @@ TextLayout layout = renderer.getTextLayout(lineIndex); if (lineLength !is 0 && offsetInLine <= lineLength) { if (offsetInLine is lineLength) { - point = layout.getLocation(offsetInLine - 1, true); + // DWT: Instead of go back one byte, go back one codepoint + int offsetInLine_m1 = layout.getPreviousOffset(offsetInLine, DWT.MOVEMENT_CLUSTER); + point = layout.getLocation(offsetInLine_m1, true); } else { switch (caretAlignment) { case OFFSET_LEADING: @@ -4920,7 +4923,9 @@ if (offsetInLine is 0) { point = layout.getLocation(offsetInLine, false); } else { - point = layout.getLocation(offsetInLine - 1, true); + // DWT: Instead of go back one byte, go back one codepoint + int offsetInLine_m1 = layout.getPreviousOffset(offsetInLine, DWT.MOVEMENT_CLUSTER); + point = layout.getLocation(offsetInLine_m1, true); } break; } @@ -8323,6 +8328,7 @@ setCaretLocation(); super.redraw(); } +// DWT: If necessary, scroll to show the location bool showLocation(Rectangle rect, bool scrollPage) { int clientAreaWidth = this.clientAreaWidth - leftMargin - rightMargin; int clientAreaHeight = this.clientAreaHeight - topMargin - bottomMargin;