Ignore:
Timestamp:
Feb 28, 2019, 4:17:24 AM (6 years ago)
Author:
ataylor
Message:

Improve DBCS string width calculations, other small tweaks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Components/RichTextDocumentUnit.pas

    r418 r420  
    143143                           const Codepage: LongInt ): boolean;
    144144
    145 // Adjusts the character position to the beginning of any multi-byte character.
     145// Adjusts the character position to the beginning or end of any multi-byte
     146// character.
    146147procedure MoveToCharacterBoundary(     TextPointer: PChar;
    147148                                   var Index:       LongInt;
    148149                                   var Offset:      LongInt;
    149150                                       RowStart:    LongInt;
    150                                        Codepage:    LongInt );
     151                                       Codepage:    LongInt;
     152                                       Advance:     Boolean; );
    151153//
    152154// ALT ends
     
    967969                                   var Offset:      LongInt;
    968970                                       RowStart:    LongInt;
    969                                        Codepage:    LongInt  );
     971                                       Codepage:    LongInt;
     972                                       Advance:     Boolean; );
    970973var
    971974  P:         PChar;
     
    989992      inc( RowStart );
    990993    end;
    991 {
     994
    992995    // We've reached the target position, and the current parsing state should
    993996    // be correctly set. So now we can safely determine the target byte's type.
    994997    Element := ExtractNextTextElement( P, NextP );
    995998    CheckSpecialElementType( Element.Character, Element.ElementType, InsideDBC, Codepage );
    996 }
    997999    if InsideDBC then
    9981000    begin
    999       // If this the first byte of a double byte character, move back by one.
    1000       dec( Index );
    1001       dec( Offset );
     1001      // If this the first byte of a double byte character, move position by one.
     1002      if Advance Then
     1003      Begin
     1004        inc( Index );
     1005        inc( Offset );
     1006      End
     1007      Else
     1008      Begin
     1009        dec( Index );
     1010        dec( Offset );
     1011      End
    10021012    end;
    10031013  end;
Note: See TracChangeset for help on using the changeset viewer.