mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-06 06:39:42 +02:00
SynEdit: ecLeft/Right for future bidi support
git-svn-id: trunk@39102 -
This commit is contained in:
parent
70d1556197
commit
d5617322c3
@ -530,8 +530,8 @@ function TSynEditMarkupManager.GetMarkupAttributeAtRowCol(const aRow: Integer;
|
|||||||
const aStartCol: TLazSynDisplayTokenBound; const AnRtlInfo: TLazSynDisplayRtlInfo) : TSynSelectedColor;
|
const aStartCol: TLazSynDisplayTokenBound; const AnRtlInfo: TLazSynDisplayRtlInfo) : TSynSelectedColor;
|
||||||
begin
|
begin
|
||||||
assert(false);
|
assert(false);
|
||||||
//Result := MarkupInfo;
|
Result := MarkupInfo;
|
||||||
//Result.Clear;
|
Result.Clear;
|
||||||
//MergeMarkupAttributeAtRowCol(aRow, aCol, GetNextMarkupColAfterRowCol(aRow, aCol) - 1, Result);
|
//MergeMarkupAttributeAtRowCol(aRow, aCol, GetNextMarkupColAfterRowCol(aRow, aCol) - 1, Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -232,6 +232,7 @@ type
|
|||||||
function WasAtLineChar(aPoint: TPoint): Boolean;
|
function WasAtLineChar(aPoint: TPoint): Boolean;
|
||||||
function WasAtLineByte(aPoint: TPoint): Boolean;
|
function WasAtLineByte(aPoint: TPoint): Boolean;
|
||||||
function IsAtPos(aCaret: TSynEditCaret): Boolean;
|
function IsAtPos(aCaret: TSynEditCaret): Boolean;
|
||||||
|
function MoveHoriz(ACount: Integer): Boolean; // Logical
|
||||||
|
|
||||||
property OldLinePos: Integer read FOldLinePos;
|
property OldLinePos: Integer read FOldLinePos;
|
||||||
property OldCharPos: Integer read FOldCharPos;
|
property OldCharPos: Integer read FOldCharPos;
|
||||||
@ -492,6 +493,67 @@ begin
|
|||||||
Result := IsAtLineChar(aCaret.LineCharPos);
|
Result := IsAtLineChar(aCaret.LineCharPos);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TSynEditCaret.MoveHoriz(ACount: Integer): Boolean;
|
||||||
|
var
|
||||||
|
L: String;
|
||||||
|
CharWidths: TPhysicalCharWidths;
|
||||||
|
GotCharWidths: Boolean;
|
||||||
|
MaxOffs: Integer;
|
||||||
|
|
||||||
|
function GetMaxOffs(AlogPos: Integer): Integer;
|
||||||
|
begin
|
||||||
|
if not GotCharWidths then
|
||||||
|
CharWidths := FLines.GetPhysicalCharWidths(Pchar(L), length(L), FLinePos-1);
|
||||||
|
GotCharWidths := True;
|
||||||
|
Result := CharWidths[AlogPos-1];
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
GotCharWidths := False;
|
||||||
|
L := LineText;
|
||||||
|
UpdateBytePos;
|
||||||
|
|
||||||
|
If ACount > 0 then begin
|
||||||
|
if (FBytePos <= length(L)) and (L[FBytePos] = #9) and (not FSkipTabs) then
|
||||||
|
MaxOffs := GetMaxOffs(FBytePos) - 1
|
||||||
|
else
|
||||||
|
MaxOffs := 0;
|
||||||
|
|
||||||
|
while ACount > 0 do begin
|
||||||
|
if FBytePosOffset < MaxOffs then
|
||||||
|
inc(FBytePosOffset)
|
||||||
|
else begin
|
||||||
|
FBytePos := FLines.LogicPosAddChars(L, FBytePos, 1, True);
|
||||||
|
FBytePosOffset := 0;
|
||||||
|
if (FBytePos <= length(L)) and (L[FBytePos] = #9) and (not FSkipTabs) then
|
||||||
|
MaxOffs := GetMaxOffs(FBytePos) - 1
|
||||||
|
else
|
||||||
|
MaxOffs := 0;
|
||||||
|
end;
|
||||||
|
dec(ACount);
|
||||||
|
end;
|
||||||
|
Result := FBytePos <= length(L) + 1;
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
while ACount < 0 do begin
|
||||||
|
if FBytePosOffset > 0 then
|
||||||
|
dec(FBytePosOffset)
|
||||||
|
else begin
|
||||||
|
if FBytePos = 1 then
|
||||||
|
break;
|
||||||
|
FBytePos := FLines.LogicPosAddChars(L, FBytePos, -1, True);
|
||||||
|
if (FBytePos <= length(L)) and (L[FBytePos] = #9) and (not FSkipTabs) then
|
||||||
|
FBytePosOffset := GetMaxOffs(FBytePos) - 1
|
||||||
|
else
|
||||||
|
FBytePosOffset := 0;
|
||||||
|
end;
|
||||||
|
inc(ACount);
|
||||||
|
end;
|
||||||
|
Result := ACount = 0;
|
||||||
|
end;
|
||||||
|
CharPos := FLines.LogPhysConvertor.LogicalToPhysical(FLinePos - 1, FBytePos, FBytePosOffset);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TSynEditCaret.setLinePos(const AValue : Integer);
|
procedure TSynEditCaret.setLinePos(const AValue : Integer);
|
||||||
begin
|
begin
|
||||||
InternalSetLineCharPos(AValue, FLastCharPos, True);
|
InternalSetLineCharPos(AValue, FLastCharPos, True);
|
||||||
|
@ -1057,15 +1057,14 @@ end;
|
|||||||
|
|
||||||
function TSynEditStringList.LogicPosAddChars(const ALine: String; ALogicalPos,
|
function TSynEditStringList.LogicPosAddChars(const ALine: String; ALogicalPos,
|
||||||
ACount: integer; AllowPastEOL: Boolean): Integer;
|
ACount: integer; AllowPastEOL: Boolean): Integer;
|
||||||
|
var
|
||||||
|
l: Integer;
|
||||||
begin
|
begin
|
||||||
// UTF8 handing of chars
|
// UTF8 handing of chars
|
||||||
Result := ALogicalPos;
|
Result := ALogicalPos;
|
||||||
if (ALogicalPos < 1) or (ALogicalPos > length(ALine)) then begin
|
l := length(ALine);
|
||||||
Result := Result + ACount;
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
if ACount > 0 then begin;
|
if ACount > 0 then begin;
|
||||||
while (Result < length(ALine)) and (ACount > 0) do begin
|
while (Result < l) and (ACount > 0) do begin
|
||||||
inc(Result);
|
inc(Result);
|
||||||
if (ALine[Result] in [#0..#127, #192..#255]) and (not LogicPosIsCombining(ALine, Result)) then
|
if (ALine[Result] in [#0..#127, #192..#255]) and (not LogicPosIsCombining(ALine, Result)) then
|
||||||
dec(ACount);
|
dec(ACount);
|
||||||
@ -1073,7 +1072,7 @@ begin
|
|||||||
if AllowPastEOL then
|
if AllowPastEOL then
|
||||||
Result := Result + ACount;
|
Result := Result + ACount;
|
||||||
|
|
||||||
if (Result <= length(ALine)) then
|
if (Result <= l) then
|
||||||
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
|
||||||
@ -1081,7 +1080,9 @@ begin
|
|||||||
end else begin
|
end else begin
|
||||||
while (Result > 1) and (ACount < 0) do begin
|
while (Result > 1) and (ACount < 0) do begin
|
||||||
dec(Result);
|
dec(Result);
|
||||||
if (ALine[Result] in [#0..#127, #192..#255]) and (not LogicPosIsCombining(ALine, Result)) then
|
if (Result > l) or
|
||||||
|
( (ALine[Result] in [#0..#127, #192..#255]) and (not LogicPosIsCombining(ALine, Result)) )
|
||||||
|
then
|
||||||
inc(ACount);
|
inc(ACount);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -558,7 +558,7 @@ procedure TTestSynNavigation.TestCaretLeftRight;
|
|||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
begin
|
begin // TODO EOL/BOL at first/last (visible) line (with folding)
|
||||||
SetTextLeftRight;
|
SetTextLeftRight;
|
||||||
|
|
||||||
{%region ecRight}
|
{%region ecRight}
|
||||||
|
Loading…
Reference in New Issue
Block a user