SynEdit: Fixed LineOverviewGutter for new shared marks code

git-svn-id: trunk@27913 -
This commit is contained in:
martin 2010-10-27 22:57:04 +00:00
parent 1cd4b77593
commit 7af59a81a6
3 changed files with 34 additions and 0 deletions

View File

@ -5262,6 +5262,7 @@ var
i: Integer;
TempPlugins: TList;
begin
FLines.SendNotification(senrTextBufferChanging, FLines); // Send the old buffer
DestroyMarkList;
// Remember all Plugins; Detach from Lines

View File

@ -54,6 +54,7 @@ type
senrDecPaintLock,
senrAfterIncPaintLock, // For plugins, etc...
senrBeforeDecPaintLock,
senrTextBufferChanging, // About to change
senrTextBufferChanged
);

View File

@ -250,6 +250,8 @@ type
procedure DoMarkChange(Sender: TSynEditMark; Changes: TSynEditMarkChangeReasons);
function CreateGutterMark(ASynMark: TSynEditMark): TSynGutterLOvMark;
function IndexOfSynMark(ASynMark: TSynEditMark): Integer;
procedure BufferChanging(Sender: TObject);
procedure BufferChanged(Sender: TObject);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
@ -1146,17 +1148,47 @@ begin
while Result >= 0 do begin;
if FMarkList[Result].FData = Pointer(ASynMark) then exit;
dec(Result);
end;
end;
procedure TSynGutterLOvProviderBookmarks.BufferChanging(Sender: TObject);
begin
TSynEdit(SynEdit).Marks.UnRegisterChangeHandler({$IFDEF FPC}@{$ENDIF}DoMarkChange);
end;
procedure TSynGutterLOvProviderBookmarks.BufferChanged(Sender: TObject);
var
i: Integer;
begin
TSynEditStringList(Sender).RemoveHanlders(self);
TSynEditStringList(TextBuffer).AddGenericHandler(senrTextBufferChanging, TMethod({$IFDEF FPC}@{$ENDIF}BufferChanging));
TSynEditStringList(TextBuffer).AddGenericHandler(senrTextBufferChanged, TMethod({$IFDEF FPC}@{$ENDIF}BufferChanged));
TSynEdit(SynEdit).Marks.RegisterChangeHandler({$IFDEF FPC}@{$ENDIF}DoMarkChange,
[smcrAdded, smcrRemoved, smcrLine, smcrVisible, smcrChanged]);
while FMarkList.Count > 0 do begin
FMarkList[0].Destroy;
FMarkList.Delete(0);
end;
for i := 0 to TSynEdit(SynEdit).Marks.Count - 1 do
if TSynEdit(SynEdit).Marks[i].Visible then
CreateGutterMark(TSynEdit(SynEdit).Marks[i]);
end;
constructor TSynGutterLOvProviderBookmarks.Create(AOwner: TComponent);
var
i: Integer;
begin
inherited Create(AOwner);
Color := clBlue;
TSynEditStringList(TextBuffer).AddGenericHandler(senrTextBufferChanging, TMethod({$IFDEF FPC}@{$ENDIF}BufferChanging));
TSynEditStringList(TextBuffer).AddGenericHandler(senrTextBufferChanged, TMethod({$IFDEF FPC}@{$ENDIF}BufferChanged));
TSynEdit(SynEdit).Marks.RegisterChangeHandler({$IFDEF FPC}@{$ENDIF}DoMarkChange,
[smcrAdded, smcrRemoved, smcrLine, smcrVisible, smcrChanged]);
for i := 0 to TSynEdit(SynEdit).Marks.Count - 1 do
if TSynEdit(SynEdit).Marks[i].Visible then
CreateGutterMark(TSynEdit(SynEdit).Marks[i]);