mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 16:19:28 +02:00
synedit: some changes for marks
- move marks compare functions to the SynEditMarks - return marks sorted by drawing order in GetMarksForLine - increase default gutter width for marks (we did not include LeftOffset of the bookmark options) git-svn-id: trunk@18952 -
This commit is contained in:
parent
d999a5db3b
commit
0103c56f6a
@ -76,6 +76,8 @@ type
|
|||||||
property OnChange: TNotifyEvent read FOnChange write FOnChange;
|
property OnChange: TNotifyEvent read FOnChange write FOnChange;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function DoMarksCompareBookmarksFirst(Item1, Item2: Pointer): Integer;
|
||||||
|
function DoMarksCompareBookmarksLast(Item1, Item2: Pointer): Integer;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
uses SynEdit;
|
uses SynEdit;
|
||||||
@ -83,6 +85,73 @@ uses SynEdit;
|
|||||||
type // This is until InvalidateGutterLines, can be moved to an accessible place
|
type // This is until InvalidateGutterLines, can be moved to an accessible place
|
||||||
SynEditAccess = Class(TCustomSynEdit);
|
SynEditAccess = Class(TCustomSynEdit);
|
||||||
|
|
||||||
|
function DoMarksCompareBookmarksFirst(Item1, Item2: Pointer): Integer;
|
||||||
|
var
|
||||||
|
Mark1: TSynEditMark absolute Item1;
|
||||||
|
Mark2: TSynEditMark absolute Item2;
|
||||||
|
begin
|
||||||
|
Result := 0;
|
||||||
|
if Mark1 = Mark2 then Exit;
|
||||||
|
|
||||||
|
if Mark1.IsBookmark then
|
||||||
|
Result := -1
|
||||||
|
else
|
||||||
|
if Mark2.IsBookmark then
|
||||||
|
Result := 1
|
||||||
|
else
|
||||||
|
if Mark1.Priority < Mark2.Priority then
|
||||||
|
Result := 1
|
||||||
|
else
|
||||||
|
if Mark1.Priority > Mark2.Priority then
|
||||||
|
Result := -1;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function DoMarksCompareBookmarksLast(Item1, Item2: Pointer): Integer;
|
||||||
|
var
|
||||||
|
Mark1: TSynEditMark absolute Item1;
|
||||||
|
Mark2: TSynEditMark absolute Item2;
|
||||||
|
begin
|
||||||
|
Result := 0;
|
||||||
|
if Mark1 = Mark2 then Exit;
|
||||||
|
|
||||||
|
if Mark1.IsBookmark then
|
||||||
|
Result := 1
|
||||||
|
else
|
||||||
|
if Mark2.IsBookmark then
|
||||||
|
Result := -1
|
||||||
|
else
|
||||||
|
if Mark1.Priority < Mark2.Priority then
|
||||||
|
Result := 1
|
||||||
|
else
|
||||||
|
if Mark1.Priority > Mark2.Priority then
|
||||||
|
Result := -1;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure SortMarks(var Marks: TSynEditMarks; Compare: TListSortCompare);
|
||||||
|
var
|
||||||
|
i, j, LastMark: Integer;
|
||||||
|
P: Pointer;
|
||||||
|
begin
|
||||||
|
for i := Low(Marks) to High(Marks) do
|
||||||
|
if Marks[i] = nil then
|
||||||
|
begin
|
||||||
|
LastMark := i - 1;
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
// insert sort is the best for our items count
|
||||||
|
for i := Low(Marks) + 1 to LastMark do
|
||||||
|
begin
|
||||||
|
P := Marks[i];
|
||||||
|
j := i - 1;
|
||||||
|
while (j >= Low(Marks)) and (Compare(P, Marks[j]) < 1) do
|
||||||
|
begin
|
||||||
|
Marks[j + 1] := Marks[j];
|
||||||
|
j := j - 1;
|
||||||
|
end;
|
||||||
|
Marks[j + 1] := TSynEditMark(P);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TSynEditMark }
|
{ TSynEditMark }
|
||||||
|
|
||||||
procedure TSynEditMark.SetPriority(const AValue: integer);
|
procedure TSynEditMark.SetPriority(const AValue: integer);
|
||||||
@ -227,6 +296,11 @@ begin
|
|||||||
if cnt = maxMarks then break;
|
if cnt = maxMarks then break;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
if Assigned(FEdit) then
|
||||||
|
if TSynEdit(FEdit).BookMarkOptions.DrawBookmarksFirst then
|
||||||
|
SortMarks(marks, @DoMarksCompareBookmarksFirst)
|
||||||
|
else
|
||||||
|
SortMarks(marks, @DoMarksCompareBookmarksLast);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSynEditMarkList.Insert(Index: Integer; Item: TSynEditMark);
|
procedure TSynEditMarkList.Insert(Index: Integer; Item: TSynEditMark);
|
||||||
|
@ -38,7 +38,7 @@ uses
|
|||||||
procedure TSynGutterMarks.DoChange(Sender: TObject);
|
procedure TSynGutterMarks.DoChange(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
if AutoSize then
|
if AutoSize then
|
||||||
FWidth := 22;
|
FWidth := RealGutterWidth(0);
|
||||||
inherited DoChange(Sender);
|
inherited DoChange(Sender);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ begin
|
|||||||
FBookMarkOpt := TSynEdit(SynEdit).BookMarkOptions;
|
FBookMarkOpt := TSynEdit(SynEdit).BookMarkOptions;
|
||||||
FInternalImage := nil;
|
FInternalImage := nil;
|
||||||
|
|
||||||
FWidth := 22;
|
FWidth := 23;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TSynGutterMarks.Destroy;
|
destructor TSynGutterMarks.Destroy;
|
||||||
@ -58,60 +58,17 @@ begin
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TSynGutterMarks.RealGutterWidth(CharWidth : integer) : integer;
|
function TSynGutterMarks.RealGutterWidth(CharWidth: integer) : integer;
|
||||||
begin
|
begin
|
||||||
If Visible then
|
if Visible then
|
||||||
Result := Width
|
Result := 22 + FBookMarkOpt.LeftMargin
|
||||||
else
|
else
|
||||||
Result := 0;
|
Result := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function DoMarksCompareBookmarksFirst(Item1, Item2: Pointer): Integer;
|
|
||||||
var
|
|
||||||
Mark1: TSynEditMark absolute Item1;
|
|
||||||
Mark2: TSynEditMark absolute Item2;
|
|
||||||
begin
|
|
||||||
Result := 0;
|
|
||||||
if Mark1 = Mark2 then Exit;
|
|
||||||
|
|
||||||
if Mark1.IsBookmark then
|
|
||||||
Result := -1
|
|
||||||
else
|
|
||||||
if Mark2.IsBookmark then
|
|
||||||
Result := 1
|
|
||||||
else
|
|
||||||
if Mark1.Priority < Mark2.Priority then
|
|
||||||
Result := 1
|
|
||||||
else
|
|
||||||
if Mark1.Priority > Mark2.Priority then
|
|
||||||
Result := -1;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function DoMarksCompareBookmarksLast(Item1, Item2: Pointer): Integer;
|
|
||||||
var
|
|
||||||
Mark1: TSynEditMark absolute Item1;
|
|
||||||
Mark2: TSynEditMark absolute Item2;
|
|
||||||
begin
|
|
||||||
Result := 0;
|
|
||||||
if Mark1 = Mark2 then Exit;
|
|
||||||
|
|
||||||
if Mark1.IsBookmark then
|
|
||||||
Result := 1
|
|
||||||
else
|
|
||||||
if Mark2.IsBookmark then
|
|
||||||
Result := -1
|
|
||||||
else
|
|
||||||
if Mark1.Priority < Mark2.Priority then
|
|
||||||
Result := 1
|
|
||||||
else
|
|
||||||
if Mark1.Priority > Mark2.Priority then
|
|
||||||
Result := -1;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TSynGutterMarks.Paint(Canvas : TCanvas; AClip : TRect; FirstLine, LastLine : integer);
|
procedure TSynGutterMarks.Paint(Canvas : TCanvas; AClip : TRect; FirstLine, LastLine : integer);
|
||||||
var
|
var
|
||||||
i: integer;
|
i: integer;
|
||||||
bHasOtherMarks: boolean;
|
|
||||||
aGutterOffs: PIntArray;
|
aGutterOffs: PIntArray;
|
||||||
dc: HDC;
|
dc: HDC;
|
||||||
LineHeight: Integer;
|
LineHeight: Integer;
|
||||||
|
Loading…
Reference in New Issue
Block a user