SynEdit: ecChar fix typing none latin at EOL / and file missing from enable BiDi

git-svn-id: trunk@39110 -
This commit is contained in:
martin 2012-10-17 11:12:51 +00:00
parent 4297f14991
commit 4828ed9f53
4 changed files with 17 additions and 20 deletions

View File

@ -286,7 +286,7 @@ type
function LogicPosAddChars(const ALine: String; ALogicalPos, ACount: integer; AllowPastEOL: Boolean = False): Integer; virtual; abstract; function LogicPosAddChars(const ALine: String; ALogicalPos, ACount: integer; AllowPastEOL: Boolean = False): Integer; virtual; abstract;
function LogicPosIsAtChar(const ALine: String; ALogicalPos: integer): Boolean; virtual; abstract; function LogicPosIsAtChar(const ALine: String; ALogicalPos: integer): Boolean; virtual; abstract;
function LogicPosAdjustToChar(const ALine: String; ALogicalPos: integer; function LogicPosAdjustToChar(const ALine: String; ALogicalPos: integer;
ANext: Boolean = False): Integer; virtual; abstract; ANext: Boolean = False; AllowPastEOL: Boolean = False): Integer; virtual; abstract;
// CharWidths // CharWidths
function GetPhysicalCharWidths(Index: Integer): TPhysicalCharWidths; function GetPhysicalCharWidths(Index: Integer): TPhysicalCharWidths;
function GetPhysicalCharWidths(Line: PChar; LineLen, Index: Integer): TPhysicalCharWidths; function GetPhysicalCharWidths(Line: PChar; LineLen, Index: Integer): TPhysicalCharWidths;
@ -408,7 +408,7 @@ type
function LogicPosAddChars(const ALine: String; ALogicalPos, ACount: integer; AllowPastEOL: Boolean = False): Integer; override; function LogicPosAddChars(const ALine: String; ALogicalPos, ACount: integer; AllowPastEOL: Boolean = False): Integer; override;
function LogicPosIsAtChar(const ALine: String; ALogicalPos: integer): Boolean; override; function LogicPosIsAtChar(const ALine: String; ALogicalPos: integer): Boolean; override;
function LogicPosAdjustToChar(const ALine: String; ALogicalPos: integer; function LogicPosAdjustToChar(const ALine: String; ALogicalPos: integer;
ANext: Boolean = False): Integer; override; ANext: Boolean = False; AllowPastEOL: Boolean = False): Integer; override;
// LogX, LogY are 1-based // LogX, LogY are 1-based
procedure EditInsert(LogX, LogY: Integer; AText: String); override; procedure EditInsert(LogX, LogY: Integer; AText: String); override;
function EditDelete(LogX, LogY, ByteLen: Integer): String; override; function EditDelete(LogX, LogY, ByteLen: Integer): String; override;
@ -606,15 +606,13 @@ function TSynLogicalPhysicalConvertor.PhysicalToLogical(AIndex, AColumn: Integer
AColOffset: Integer; ACharSide: TSynPhysCharSide): Integer; AColOffset: Integer; ACharSide: TSynPhysCharSide): Integer;
var var
BytePos, ScreenPos, ScreenPosOld: integer; BytePos, ScreenPos, ScreenPosOld: integer;
{$IFDEF WithSynBiDi }
RtlPos, RtlScreen: Integer; RtlPos, RtlScreen: Integer;
{$ENDIF}
begin begin
PrepareWidthsForLine(AIndex); PrepareWidthsForLine(AIndex);
ScreenPos := 1; ScreenPos := 1;
BytePos := 0; BytePos := 0;
{$IFDEF WithSynBiDi } {$IFnDEF WithOutSynBiDi }
while BytePos < FCurrentWidthsLen do begin while BytePos < FCurrentWidthsLen do begin
if ((FCurrentWidths[BytePos] and PCWMask) = 0) then begin if ((FCurrentWidths[BytePos] and PCWMask) = 0) then begin
inc(BytePos); inc(BytePos);
@ -725,9 +723,7 @@ function TSynLogicalPhysicalConvertor.LogicalToPhysical(AIndex, ABytePos: Intege
var AColOffset: Integer; ACharSide: TSynLogCharSide): Integer; var AColOffset: Integer; ACharSide: TSynLogCharSide): Integer;
var var
i: integer; i: integer;
{$IFDEF WithSynBiDi }
RtlLen: Integer; RtlLen: Integer;
{$ENDIF}
begin begin
{$IFDEF AssertSynMemIndex} {$IFDEF AssertSynMemIndex}
if (ABytePos <= 0) then if (ABytePos <= 0) then
@ -735,7 +731,7 @@ begin
{$ENDIF} {$ENDIF}
assert(ABytePos > 0, 'What uses abytepos = 0 ?'); assert(ABytePos > 0, 'What uses abytepos = 0 ?');
{$IFDEF WithSynBiDi } {$IFnDEF WithOutSynBiDi}
if (ABytePos = 0) or ((ABytePos = 1) and (AColOffset=0) and (ACharSide in [cslBefore, cslFollowLtr])) then if (ABytePos = 0) or ((ABytePos = 1) and (AColOffset=0) and (ACharSide in [cslBefore, cslFollowLtr])) then
exit(ABytePos); exit(ABytePos);
{$ELSE} {$ELSE}
@ -760,13 +756,11 @@ begin
end; end;
{$IFDEF WithSynBiDi }
RtlLen := 0; RtlLen := 0;
{$ENDIF}
for i := 0 to ABytePos - 1 do begin for i := 0 to ABytePos - 1 do begin
if ((FCurrentWidths[i] and PCWMask) = 0) then if ((FCurrentWidths[i] and PCWMask) = 0) then
continue; continue;
{$IFDEF WithSynBiDi } {$IFnDEF WithOutSynBiDi}
If ((FCurrentWidths[i] and PCWFlagRTL) <> 0) then If ((FCurrentWidths[i] and PCWFlagRTL) <> 0) then
RtlLen := RtlLen + (FCurrentWidths[i] and PCWMask) RtlLen := RtlLen + (FCurrentWidths[i] and PCWMask)
else begin else begin
@ -777,7 +771,7 @@ begin
Result := Result + (FCurrentWidths[i] and PCWMask); Result := Result + (FCurrentWidths[i] and PCWMask);
{$ENDIF} {$ENDIF}
end; end;
{$IFDEF WithSynBiDi } {$IFnDEF WithOutSynBiDi}
if (ABytePos < FCurrentWidthsLen) and if (ABytePos < FCurrentWidthsLen) and
((FCurrentWidths[ABytePos] and PCWFlagRTL) <> 0) and // Next Char is Rtl ((FCurrentWidths[ABytePos] and PCWFlagRTL) <> 0) and // Next Char is Rtl
@ -1284,7 +1278,7 @@ end;
function TSynEditStringsLinked.LogicPosAddChars(const ALine: String; function TSynEditStringsLinked.LogicPosAddChars(const ALine: String;
ALogicalPos, ACount: integer; AllowPastEOL: Boolean): Integer; ALogicalPos, ACount: integer; AllowPastEOL: Boolean): Integer;
begin begin
Result := fSynStrings.LogicPosAddChars(ALine, ALogicalPos, ACount); Result := fSynStrings.LogicPosAddChars(ALine, ALogicalPos, ACount, AllowPastEOL);
end; end;
function TSynEditStringsLinked.LogicPosIsAtChar(const ALine: String; function TSynEditStringsLinked.LogicPosIsAtChar(const ALine: String;
@ -1294,9 +1288,9 @@ begin
end; end;
function TSynEditStringsLinked.LogicPosAdjustToChar(const ALine: String; ALogicalPos: integer; function TSynEditStringsLinked.LogicPosAdjustToChar(const ALine: String; ALogicalPos: integer;
ANext: Boolean): Integer; ANext: Boolean; AllowPastEOL: Boolean): Integer;
begin begin
Result := fSynStrings.LogicPosAdjustToChar(ALine, ALogicalPos, ANext); Result := fSynStrings.LogicPosAdjustToChar(ALine, ALogicalPos, ANext, AllowPastEOL);
end; end;
procedure TSynEditStringsLinked.IgnoreSendNotification(AReason: TSynEditNotifyReason; procedure TSynEditStringsLinked.IgnoreSendNotification(AReason: TSynEditNotifyReason;

View File

@ -6396,7 +6396,7 @@ begin
{$ENDIF} {$ENDIF}
//CaretX := CaretX + 1; //CaretX := CaretX + 1;
FCaret.BytePos := LogCaretXY.X + 1; FCaret.BytePos := LogCaretXY.X + length(AChar);
if CaretX >= LeftChar + CharsInWindow then if CaretX >= LeftChar + CharsInWindow then
LeftChar := LeftChar + Min(25, CharsInWindow - 1); LeftChar := LeftChar + Min(25, CharsInWindow - 1);
finally finally

View File

@ -697,7 +697,7 @@ end;
procedure TSynEditCaret.SetBytePos(const AValue: Integer); procedure TSynEditCaret.SetBytePos(const AValue: Integer);
begin begin
CharPos := FLines.LogicalToPhysicalPos(Point(FLines.LogicPosAdjustToChar CharPos := FLines.LogicalToPhysicalPos(Point(FLines.LogicPosAdjustToChar
(LineText, AValue, FAdjustToNextChar or (FForceAdjustToNextChar > 0)), (LineText, AValue, FAdjustToNextChar or (FForceAdjustToNextChar > 0), True),
LinePos)).X; LinePos)).X;
end; end;

View File

@ -238,7 +238,7 @@ type
function LogicPosAddChars(const ALine: String; ALogicalPos, ACount: integer; AllowPastEOL: Boolean = False): Integer; override; function LogicPosAddChars(const ALine: String; ALogicalPos, ACount: integer; AllowPastEOL: Boolean = False): Integer; override;
function LogicPosIsAtChar(const ALine: String; ALogicalPos: integer): Boolean; override; function LogicPosIsAtChar(const ALine: String; ALogicalPos: integer): Boolean; override;
function LogicPosAdjustToChar(const ALine: String; ALogicalPos: integer; function LogicPosAdjustToChar(const ALine: String; ALogicalPos: integer;
ANext: Boolean = False): Integer; override; ANext: Boolean = False; AllowPastEOL: Boolean = False): Integer; override;
property UndoList: TSynEditUndoList read GetUndoList write fUndoList; property UndoList: TSynEditUndoList read GetUndoList write fUndoList;
property RedoList: TSynEditUndoList read GetRedoList write fRedoList; property RedoList: TSynEditUndoList read GetRedoList write fRedoList;
procedure EditInsert(LogX, LogY: Integer; AText: String); override; procedure EditInsert(LogX, LogY: Integer; AText: String); override;
@ -1101,19 +1101,22 @@ begin
end; end;
function TSynEditStringList.LogicPosAdjustToChar(const ALine: String; ALogicalPos: integer; function TSynEditStringList.LogicPosAdjustToChar(const ALine: String; ALogicalPos: integer;
ANext: Boolean): Integer; ANext: Boolean; AllowPastEOL: Boolean): Integer;
begin begin
// UTF8 handing of chars // UTF8 handing of chars
Result := ALogicalPos; Result := ALogicalPos;
if (ALogicalPos < 1) or (ALogicalPos > length(ALine)) then exit; if (ALogicalPos < 1) or (ALogicalPos > length(ALine)) then exit;
if ANext then begin if ANext then begin
while (Result < length(ALine)) and while (Result <= length(ALine)) and
( (not(ALine[Result] in [#0..#127, #192..#255])) or LogicPosIsCombining(ALine, Result) ) ( (not(ALine[Result] in [#0..#127, #192..#255])) or LogicPosIsCombining(ALine, Result) )
do do
inc(Result); inc(Result);
end; end;
if (not AllowPastEOL) and (Result > length(ALine)) then
Result := length(ALine);
while (Result > 1) and while (Result > 1) and
( (not(ALine[Result] in [#0..#127, #192..#255])) or LogicPosIsCombining(ALine, Result) ) ( (not(ALine[Result] in [#0..#127, #192..#255])) or LogicPosIsCombining(ALine, Result) )
do do