SynEdit: add ViewToTextIndexEx / rename param for TextIndexToView...

git-svn-id: trunk@63201 -
This commit is contained in:
martin 2020-05-21 18:04:10 +00:00
parent 34099573b4
commit 88b4e037a4
3 changed files with 42 additions and 21 deletions

View File

@ -218,10 +218,9 @@ type
function GetLinesCount: Integer; virtual;
function GetDrawDividerInfo: TSynDividerDrawConfigSetting; virtual;
function TextToViewIndex(AIndex: TLineIdx): TLineRange; virtual;
function ViewToTextIndex(AIndex: TLineIdx): TLineIdx; virtual;
//function ViewToTextIndexEx(AIndex: TLineIdx; out AScreenRange: TLineRange): TLineIdx;
// todo: gutter info
function TextToViewIndex(ATextIndex: TLineIdx): TLineRange; virtual;
function ViewToTextIndex(AViewIndex: TLineIdx): TLineIdx; virtual;
function ViewToTextIndexEx(AViewIndex: TLineIdx; out AViewRange: TLineRange): TLineIdx; virtual;
end;
{ TLazSynDisplayViewEx }
@ -622,14 +621,20 @@ begin
Result.Color := clNone;
end;
function TLazSynDisplayView.TextToViewIndex(AIndex: TLineIdx): TLineRange;
function TLazSynDisplayView.TextToViewIndex(ATextIndex: TLineIdx): TLineRange;
begin
Result := NextView.TextToViewIndex(AIndex);
Result := NextView.TextToViewIndex(ATextIndex);
end;
function TLazSynDisplayView.ViewToTextIndex(AIndex: TLineIdx): TLineIdx;
function TLazSynDisplayView.ViewToTextIndex(AViewIndex: TLineIdx): TLineIdx;
begin
Result := NextView.ViewToTextIndex(AIndex);
Result := NextView.ViewToTextIndex(AViewIndex);
end;
function TLazSynDisplayView.ViewToTextIndexEx(AViewIndex: TLineIdx; out
AViewRange: TLineRange): TLineIdx;
begin
Result := NextView.ViewToTextIndexEx(AViewIndex, AViewRange);
end;
{ TSynLogicalPhysicalConvertor }

View File

@ -358,8 +358,9 @@ type
function GetNextHighlighterToken(out ATokenInfo: TLazSynDisplayTokenInfo): Boolean; override;
function GetLinesCount: Integer; override;
function TextToViewIndex(AIndex: TLineIdx): TLineRange; override;
function ViewToTextIndex(AIndex: TLineIdx): TLineIdx; override;
function TextToViewIndex(ATextIndex: TLineIdx): TLineRange; override;
function ViewToTextIndex(AViewIndex: TLineIdx): TLineIdx; override;
function ViewToTextIndexEx(AViewIndex: TLineIdx; out AViewRange: TLineRange): TLineIdx; override;
end;
{ TSynTextFoldedView
@ -832,10 +833,10 @@ begin
Result := FFoldView.ViewedCount;
end;
function TLazSynDisplayFold.TextToViewIndex(AIndex: TLineIdx): TLineRange;
function TLazSynDisplayFold.TextToViewIndex(ATextIndex: TLineIdx): TLineRange;
begin
// TODO: inherited AFTER fold mapping?
Result := inherited TextToViewIndex(AIndex);
Result := inherited TextToViewIndex(ATextIndex);
if Result.Top = Result.Bottom then begin
Result.Top := FFoldView.InternTextToViewIndex(Result.Top);
Result.Bottom := Result.Top;
@ -846,9 +847,15 @@ begin
end;
end;
function TLazSynDisplayFold.ViewToTextIndex(AIndex: TLineIdx): TLineIdx;
function TLazSynDisplayFold.ViewToTextIndex(AViewIndex: TLineIdx): TLineIdx;
begin
Result := FFoldView.InternViewToTextIndex(inherited ViewToTextIndex(AIndex));
Result := FFoldView.InternViewToTextIndex(inherited ViewToTextIndex(AViewIndex));
end;
function TLazSynDisplayFold.ViewToTextIndexEx(AViewIndex: TLineIdx; out
AViewRange: TLineRange): TLineIdx;
begin
Result := FFoldView.InternViewToTextIndex(inherited ViewToTextIndexEx(AViewIndex, AViewRange));
end;
{ TSynEditFoldExportStream }

View File

@ -131,8 +131,9 @@ type
function GetDrawDividerInfo: TSynDividerDrawConfigSetting; override;
function GetLinesCount: Integer; override;
function TextToViewIndex(AIndex: TLineIdx): TLineRange; override;
function ViewToTextIndex(AIndex: TLineIdx): TLineIdx; override;
function TextToViewIndex(ATextIndex: TLineIdx): TLineRange; override;
function ViewToTextIndex(AViewIndex: TLineIdx): TLineIdx; override;
function ViewToTextIndexEx(AViewIndex: TLineIdx; out AViewRange: TLineRange): TLineIdx; override;
end;
{ TSynEditStringList }
@ -414,15 +415,23 @@ begin
Result := FBuffer.Count;
end;
function TLazSynDisplayBuffer.TextToViewIndex(AIndex: TLineIdx): TLineRange;
function TLazSynDisplayBuffer.TextToViewIndex(ATextIndex: TLineIdx): TLineRange;
begin
Result.Top := AIndex;
Result.Bottom := AIndex;
Result.Top := ATextIndex;
Result.Bottom := ATextIndex;
end;
function TLazSynDisplayBuffer.ViewToTextIndex(AIndex: TLineIdx): TLineIdx;
function TLazSynDisplayBuffer.ViewToTextIndex(AViewIndex: TLineIdx): TLineIdx;
begin
Result := AIndex;
Result := AViewIndex;
end;
function TLazSynDisplayBuffer.ViewToTextIndexEx(AViewIndex: TLineIdx; out
AViewRange: TLineRange): TLineIdx;
begin
Result := AViewIndex;
AViewRange.Top := AViewIndex;
AViewRange.Bottom := AViewIndex;
end;
{ TSynEditUndoTxtInsert }