Changeset 275:9c5ba1f00519

Show
Ignore:
Timestamp:
08/04/08 18:51:33 (5 months ago)
Author:
Frank Benoit <benoit@tionex.de>
branch:
default
Message:

Fix: delete the whole codepoint for backspace.
Fix: getPointAtPosition handle whole codepoints correctly.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dwt/custom/StyledText.d

    r274 r275  
    22412241        int lineOffset = content.getOffsetAtLine(lineIndex); 
    22422242        if (caretOffset is lineOffset) { 
     2243            // DWT: on line start, delete line break 
    22432244            lineOffset = content.getOffsetAtLine(lineIndex - 1); 
    22442245            event.start = lineOffset + content.getLine(lineIndex - 1).length; 
     
    22462247        } else { 
    22472248            TextLayout layout = renderer.getTextLayout(lineIndex); 
    2248             int start = layout.getPreviousOffset(caretOffset - lineOffset, DWT.MOVEMENT_CHAR); 
     2249            int start = layout.getPreviousOffset(caretOffset - lineOffset, DWT.MOVEMENT_CLUSTER); 
    22492250            renderer.disposeTextLayout(layout); 
    22502251            event.start = start + lineOffset; 
     
    39883989    TextLayout layout = renderer.getTextLayout(lineIndex); 
    39893990    x += horizontalScrollOffset - leftMargin; 
    3990     int[] trailing = new int[1]
     3991    int[1] trailing
    39913992    int offsetInLine = layout.getOffset(x, y, trailing); 
    39923993    caretAlignment = OFFSET_LEADING; 
     
    49104911    if (lineLength !is 0  && offsetInLine <= lineLength) { 
    49114912        if (offsetInLine is lineLength) { 
    4912             point = layout.getLocation(offsetInLine - 1, true); 
     4913            // DWT: Instead of go back one byte, go back one codepoint 
     4914            int offsetInLine_m1 = layout.getPreviousOffset(offsetInLine, DWT.MOVEMENT_CLUSTER); 
     4915            point = layout.getLocation(offsetInLine_m1, true); 
    49134916        } else { 
    49144917            switch (caretAlignment) { 
     
    49214924                        point = layout.getLocation(offsetInLine, false); 
    49224925                    } else { 
    4923                         point = layout.getLocation(offsetInLine - 1, true); 
     4926                        // DWT: Instead of go back one byte, go back one codepoint 
     4927                        int offsetInLine_m1 = layout.getPreviousOffset(offsetInLine, DWT.MOVEMENT_CLUSTER); 
     4928                        point = layout.getLocation(offsetInLine_m1, true); 
    49244929                    } 
    49254930                    break; 
     
    83248329    super.redraw(); 
    83258330} 
     8331// DWT: If necessary, scroll to show the location 
    83268332bool showLocation(Rectangle rect, bool scrollPage) { 
    83278333    int clientAreaWidth = this.clientAreaWidth - leftMargin - rightMargin;