SynEdit: begin refactor SynEdit.Marks (use tree for storage).

git-svn-id: trunk@27764 -
This commit is contained in:
martin 2010-10-19 21:48:29 +00:00
parent 58ea9148ea
commit 7e8ea9c121
2 changed files with 23 additions and 18 deletions

View File

@ -7402,11 +7402,11 @@ var
ASrcEdit: TSourceEditor; ASrcEdit: TSourceEditor;
ASynEdit: TSynEdit; ASynEdit: TSynEdit;
EditCaret: TPoint; EditCaret: TPoint;
LineMarks: TSynEditMarks;
AMark: TSourceMark; AMark: TSourceMark;
i: integer; i: integer;
HintStr: String; HintStr: String;
CurHint: String; CurHint: String;
MLine: TSynEditMarkLine;
begin begin
// hide other hints // hide other hints
//debugln('TSourceNotebook.ShowSynEditHint A'); //debugln('TSourceNotebook.ShowSynEditHint A');
@ -7422,17 +7422,25 @@ begin
if EditPos.X<ASynEdit.Gutter.Width then begin if EditPos.X<ASynEdit.Gutter.Width then begin
// hint for a gutter item // hint for a gutter item
if EditorOpts.ShowGutterHints then begin if EditorOpts.ShowGutterHints then begin
ASynEdit.Marks.GetMarksForLine(EditCaret.Y,LineMarks);
HintStr:=''; HintStr:='';
for i:=Low(TSynEditMarks) to High(TSynEditMarks) do begin MLine := ASynEdit.Marks.Line[EditCaret.Y];
if not (LineMarks[i] is TSourceSynMark) then continue; if MLine <> nil then begin
AMark := TSourceSynMark(LineMarks[i]).SourceMark; if ASynEdit.BookMarkOptions.DrawBookmarksFirst then
MLine.Sort(smsoBookmarkFirst, smsoColumn)
else
MLine.Sort(smsoBookMarkLast, smsoColumn);
for i := 0 to MLine.Count - 1 do begin
if not (MLine[i] is TSourceSynMark) then continue;
AMark := TSourceSynMark(MLine[i]).SourceMark;
if AMark = nil then continue; if AMark = nil then continue;
CurHint:=AMark.GetHint; CurHint:=AMark.GetHint;
if CurHint='' then continue; if CurHint='' then continue;
if HintStr<>'' then HintStr:=HintStr+LineEnding; if HintStr<>'' then HintStr:=HintStr+LineEnding;
HintStr:=HintStr+CurHint; HintStr:=HintStr+CurHint;
end; end;
end;
if HintStr<>'' then if HintStr<>'' then
ActivateHint(MousePos,'',HintStr); ActivateHint(MousePos,'',HintStr);
end; end;

View File

@ -63,7 +63,7 @@ type
public public
constructor Create(AOwner: TSourceMark; AEditor: TSourceEditorInterface); constructor Create(AOwner: TSourceMark; AEditor: TSourceEditorInterface);
destructor Destroy; override; destructor Destroy; override;
function GetEdit: TSynEdit; override; function GetEdit: TSynEdit;
property SourceMark: TSourceMark read FSourceMark write FSourceMark; property SourceMark: TSourceMark read FSourceMark write FSourceMark;
end; end;
@ -88,7 +88,7 @@ type
function Add(Item: TSourceSynMark): Integer; function Add(Item: TSourceSynMark): Integer;
property Items[Index: Integer]: TSourceSynMark read GetSM write PutSM; default; property Items[Index: Integer]: TSourceSynMark read GetSM write PutSM; default;
property OnChange: TNotifyEvent read FOnChange write FOnChange; property OnChange: TNotifyEvent read FOnChange write FOnChange;
procedure InvalidateLine(ALine: Integer); procedure DoChange(AChanges: TSynEditMarkChangeReasons);
procedure DeleteWithSourceEditor(ASrcEditor: TSourceEditorInterface); procedure DeleteWithSourceEditor(ASrcEditor: TSourceEditorInterface);
function IndexOfSourceEditor(AEditor: TSourceEditorInterface): Integer; function IndexOfSourceEditor(AEditor: TSourceEditorInterface): Integer;
procedure IncChangeLock; procedure IncChangeLock;
@ -460,12 +460,12 @@ begin
Result := inherited Add(Item); Result := inherited Add(Item);
end; end;
procedure TSourceSynMarkList.InvalidateLine(ALine: Integer); procedure TSourceSynMarkList.DoChange(AChanges: TSynEditMarkChangeReasons);
var var
i: Integer; i: Integer;
begin begin
for i := 0 to Count - 1 do for i := 0 to Count - 1 do
Items[i].GetEdit.InvalidateLine(ALine); Items[i].DoChange(AChanges);
end; end;
procedure TSourceSynMarkList.DeleteWithSourceEditor( procedure TSourceSynMarkList.DeleteWithSourceEditor(
@ -609,7 +609,6 @@ begin
FVisible := AValue; FVisible := AValue;
if FSynMarkLock = 0 then if FSynMarkLock = 0 then
FSynMarks.Visible := AValue; FSynMarks.Visible := AValue;
if EditorUpdateRequired then DoLineUpdate(True);
Changed; Changed;
end; end;
@ -626,7 +625,7 @@ procedure TSourceMark.DoLineUpdate(Force: Boolean = False);
begin begin
if Line <= 0 then Exit; if Line <= 0 then Exit;
if Visible or Force then if Visible or Force then
FSynMarks.InvalidateLine(Line); FSynMarks.DoChange([smcrChanged]);
end; end;
procedure TSourceMark.SetData(const AValue: TObject); procedure TSourceMark.SetData(const AValue: TObject);
@ -674,14 +673,12 @@ end;
procedure TSourceMark.SetLine(const Value: Integer); procedure TSourceMark.SetLine(const Value: Integer);
begin begin
if Line=Value then exit; if Line=Value then exit;
if EditorUpdateRequired then DoLineUpdate;
if FSourceMarks<>nil then FSourceMarks.fSortedItems.Remove(Self); if FSourceMarks<>nil then FSourceMarks.fSortedItems.Remove(Self);
FLine := Value; FLine := Value;
if FSynMarkLock = 0 then if FSynMarkLock = 0 then
FSynMarks.Line := Value; FSynMarks.Line := Value;
if FSourceMarks<>nil then FSourceMarks.fSortedItems.Add(Self); if FSourceMarks<>nil then FSourceMarks.fSortedItems.Add(Self);
DoPositionChanged; DoPositionChanged;
if EditorUpdateRequired then DoLineUpdate;
Changed; Changed;
end; end;