Ignore:
Timestamp:
Feb 25, 2019, 8:34:42 PM (6 years ago)
Author:
ataylor
Message:

Experimental new logic to try and fix DBCS text wrapping.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Components/RichTextView.PAS

    r395 r418  
    459459
    460460Procedure TRichTextView.SetSelectionStartInternal( SelectionStart: longint );
     461var
     462  Offset: longint;     // ALT
    461463begin
    462464  if SelectionStart = FSelectionStart then
     
    468470      ClearSelection;
    469471
     472  // ALT
     473  Offset := FCursorOffset;
     474  MovetoCharacterBoundary( FText, SelectionStart, FCursorOffset, Offset, FLayout.Codepage );
     475
    470476  FSelectionStart := SelectionStart;
    471477  if FSelectionEnd = -1 then
     
    479485  StartRedrawLine: longint;
    480486  EndRedrawLine: longint;
     487  Offset: longint;         // ALT
    481488  OldClip: TRect;
    482489begin
    483490  if SelectionEnd = FSelectionEnd then
    484491    exit;
     492
     493  // ALT
     494  Offset := FCursorOffset;
     495  MovetoCharacterBoundary( FText, SelectionEnd, FCursorOffset, Offset, FLayout.Codepage );
    485496
    486497  if FSelectionStart = -1 then
     
    797808    // we haven't yet done a layout
    798809    Layout;
     810
    799811
    800812end;
     
    20182030                                           PreserveSelection: boolean );
    20192031var
     2032//  P: PChar;                 // ALT
     2033//  NextP: PChar;             // ALT
     2034//  Element: TTextElement;    // ALT
     2035//  InsideDBC: boolean;       // ALT
     2036  RowStart: longint;        // ALT
    20202037  Index: longint;
    20212038begin
    20222039  RemoveCursor;
     2040
     2041  Index := FLayout.GetCharIndex( FLayout.FLines[ Row ].Text ) + Offset;
     2042
     2043// ALT
     2044{
     2045  if ( Offset > 0 ) and
     2046     ( FLayout.Codepage in [ 932, 936, 942, 943, 949, 950, 1381, 1386 ]) then
     2047  begin
     2048    RowStart := FLayout.GetCharIndex( FLayout.FLines[ Row ].Text );
     2049    P := FText + RowStart;
     2050    InsideDBC := false;
     2051    while RowStart < Index do
     2052    begin
     2053      Element := ExtractNextTextElement( P, NextP );
     2054      CheckSpecialElementType( Element.Character, Element.ElementType, InsideDBC, FLayout.Codepage );
     2055      P := NextP;
     2056      inc( RowStart );
     2057    end;
     2058    Element := ExtractNextTextElement( P, NextP );
     2059    CheckSpecialElementType( Element.Character, Element.ElementType, InsideDBC, FLayout.Codepage );
     2060    if InsideDBC then
     2061    begin
     2062      dec( Index );
     2063      dec( Offset );
     2064    end;
     2065  end;
     2066}
     2067
     2068  RowStart := FLayout.GetCharIndex( FLayout.FLines[ Row ].Text );
     2069  MoveToCharacterBoundary( FText, Index, Offset, RowStart, FLayout.Codepage );  // ALT
     2070
    20232071  FCursorOffset := Offset;
    20242072  FCursorRow := Row;
    2025   Index := FLayout.GetCharIndex( FLayout.FLines[ Row ].Text ) + Offset;
     2073
    20262074  if PreserveSelection then
    20272075  begin
     
    20472095
    20482096  Element := ExtractNextTextElement( P, NextP );
     2097
    20492098  P := NextP;
    20502099  while Element.ElementType = teStyle do
Note: See TracChangeset for help on using the changeset viewer.