SynEdit: Make BIDI default / ecDeleteChar fix half tab del

git-svn-id: trunk@39104 -
This commit is contained in:
martin 2012-10-16 14:17:53 +00:00
parent b48bd1be53
commit 8afb351bd1
3 changed files with 24 additions and 9 deletions

View File

@ -1871,12 +1871,12 @@ begin
FDoubleWidthChrLinesView := SynEditStringDoubleWidthChars.Create
(FTrimmedLinesView);
{$IFDEF WithSynBiDi }
{$IFnDEF WithOutSynBiDi}
FBidiChrLinesView := TSynEditStringBidiChars.Create(FDoubleWidthChrLinesView);
{$ENDIF}
// ftab, currently has LengthOfLongestLine, therefore must be after DoubleWidthChar
{$IFDEF WithSynBiDi }
{$IFnDEF WithOutSynBiDi }
FTabbedLinesView := TSynEditStringTabExpander.Create(FBidiChrLinesView);
{$ELSE}
FTabbedLinesView := TSynEditStringTabExpander.Create(FDoubleWidthChrLinesView);
@ -2343,7 +2343,7 @@ begin
FreeAndNil(FStrings);
FreeAndNil(FTabbedLinesView);
FreeAndNil(FTrimmedLinesView); // has reference to caret
{$IFDEF WithSynBiDi }
{$IFnDEF WithOutSynBiDi}
FreeAndNil(FBidiChrLinesView);
{$ENDIF}
FreeAndNil(FDoubleWidthChrLinesView);
@ -6215,7 +6215,7 @@ begin
else begin
Temp := LineText;
Len := Length(Temp);
LogCaretXY:=LogicalCaretXY;
LogCaretXY := FCaret.LineBytePos;
Caret := CaretXY;
//debugln('ecDeleteLastChar B Temp="',DbgStr(Temp),'" CaretX=',dbgs(CaretX),' LogCaretXY=',dbgs(LogCaretXY));
if LogCaretXY.X > Len +1
@ -6239,8 +6239,12 @@ begin
FTheLinesView.EditDelete(CaretX, LogCaretXY.Y, 1);
{$ELSE USE_UTF8BIDI_LCL}
LogCounter := LogCaretXY.X;
LogCaretXY.X := FTheLinesView.LogicPosAddChars(Temp, LogCaretXY.X, -1);
LogCounter := LogCounter - LogCaretXY.X;
if FCaret.BytePosOffset = 0 then begin
LogCaretXY.X := FTheLinesView.LogicPosAddChars(Temp, LogCaretXY.X, -1);
LogCounter := LogCounter - LogCaretXY.X;
end
else
LogCounter := GetCharLen(Temp, LogCaretXY.X);
FTheLinesView.EditDelete(LogCaretXY.X, LogCaretXY.Y, LogCounter);
FCaret.BytePos := LogCaretXY.X;
{$ENDIF USE_UTF8BIDI_LCL}

View File

@ -203,6 +203,7 @@ type
procedure setLinePos(const AValue: Integer);
function GetLineCharPos: TPoint;
procedure SetLineCharPos(AValue: TPoint);
function GetBytePosOffset: Integer;
function GetBytePos: Integer;
procedure SetBytePos(const AValue: Integer);
function GetLineBytePos: TPoint;
@ -243,6 +244,7 @@ type
property CharPos: Integer read fCharPos write setCharPos;
property LineCharPos: TPoint read GetLineCharPos write SetLineCharPos;
property BytePos: Integer read GetBytePos write SetBytePos;
property BytePosOffset: Integer read GetBytePosOffset;
property LineBytePos: TPoint read GetLineBytePos write SetLineBytePos;
property LineText: string read GetLineText write SetLineText;
@ -451,7 +453,7 @@ end;
procedure TSynEditCaret.IncAutoMoveOnEdit;
begin
if FAutoMoveOnEdit =0 then
UpdateBytePos;;
UpdateBytePos;
inc(FAutoMoveOnEdit);
end;
@ -588,6 +590,14 @@ begin
end;
end;
function TSynEditCaret.GetBytePosOffset: Integer;
begin
FLines.LogPhysConvertor.PhysicalToLogical(FLinePos-1, FCharPos, Result);
// TODO: the below, will interfere with auto-move caret
//UpdateBytePos;
//Result := FBytePosOffset;
end;
procedure TSynEditCaret.UpdateBytePos;
begin
FBytePos := FLines.LogPhysConvertor.PhysicalToLogical(FLinePos-1, FCharPos, FBytePosOffset);
@ -694,6 +704,9 @@ end;
function TSynEditCaret.GetLineBytePos: TPoint;
begin
Result := FLines.PhysicalToLogicalPos(LineCharPos);
// TODO: the below, will interfere with auto-move caret
//UpdateBytePos;
//Result := Point(FBytePos, FLinePos);
end;
procedure TSynEditCaret.SetLineBytePos(const AValue: TPoint);

View File

@ -343,7 +343,6 @@ begin
TestPhysLog('line with double-width/3byte', 7, 4, 4, 1);
TestPhysLog('line with double-width/3byte', 7, 5, 7, 0);
{$IFDEF WithSynBiDi }
//abc def ghi // 2bytes per char
(* Order in String "123" / Order on Screen "321"
@ -409,7 +408,6 @@ begin
TestPhysLog('bidi line (mixed arab/latin)',2, 1, 1, 0, 1, 0, 1, 0, 1, 0);
TestPhysLog('bidi line (mixed arab/latin)',2, 4, 4, 0, 24, 0, 4, 0, 24, 0);
TestPhysLog('bidi line (mixed arab/latin)',2, 15, 4, 0, 24, 0, 24, 0, 4, 0);
{$ENDIF}
end;
procedure TTestBasicSynEdit.TestCaretAutoMove;