mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 19:39:17 +02:00
IDE: fpdoc editor: fixed updating after hide/show
git-svn-id: trunk@35547 -
This commit is contained in:
parent
3d1a570a3c
commit
95cb0b3e47
@ -62,7 +62,8 @@ type
|
|||||||
fpdefValueControlsNeedsUpdate,
|
fpdefValueControlsNeedsUpdate,
|
||||||
fpdefInheritedControlsNeedsUpdate,
|
fpdefInheritedControlsNeedsUpdate,
|
||||||
fpdefTopicSettingUp,
|
fpdefTopicSettingUp,
|
||||||
fpdefTopicNeedsUpdate
|
fpdefTopicNeedsUpdate,
|
||||||
|
fpdefWasHidden
|
||||||
);
|
);
|
||||||
TFPDocEditorFlags = set of TFPDocEditorFlag;
|
TFPDocEditorFlags = set of TFPDocEditorFlag;
|
||||||
|
|
||||||
@ -191,15 +192,22 @@ type
|
|||||||
function GUIModified: boolean;
|
function GUIModified: boolean;
|
||||||
procedure DoEditorUpdate(Sender: TObject);
|
procedure DoEditorUpdate(Sender: TObject);
|
||||||
private
|
private
|
||||||
|
FFollowCursor: boolean;
|
||||||
|
FIdleConnected: boolean;
|
||||||
FLastTopicControl: TControl;
|
FLastTopicControl: TControl;
|
||||||
FCurrentTopic: String;
|
FCurrentTopic: String;
|
||||||
|
procedure SetFollowCursor(AValue: boolean);
|
||||||
|
procedure SetIdleConnected(AValue: boolean);
|
||||||
procedure UpdateTopicCombo;
|
procedure UpdateTopicCombo;
|
||||||
procedure ClearTopicControls;
|
procedure ClearTopicControls;
|
||||||
procedure UpdateTopic;
|
procedure UpdateTopic;
|
||||||
|
protected
|
||||||
|
procedure UpdateShowing; override;
|
||||||
public
|
public
|
||||||
procedure Reset;
|
procedure Reset;
|
||||||
procedure InvalidateChain;
|
procedure InvalidateChain;
|
||||||
procedure UpdateFPDocEditor(const SrcFilename: string; const Caret: TPoint);
|
procedure LoadIdentifierAt(const SrcFilename: string; const Caret: TPoint);
|
||||||
|
procedure LoadIdentifierAtCursor;
|
||||||
procedure BeginUpdate;
|
procedure BeginUpdate;
|
||||||
procedure EndUpdate;
|
procedure EndUpdate;
|
||||||
procedure ClearEntry(DoSave: Boolean);
|
procedure ClearEntry(DoSave: Boolean);
|
||||||
@ -208,6 +216,8 @@ type
|
|||||||
property SourceFilename: string read GetSourceFilename;
|
property SourceFilename: string read GetSourceFilename;
|
||||||
property CaretXY: TPoint read FCaretXY;
|
property CaretXY: TPoint read FCaretXY;
|
||||||
property Modified: boolean read FModified write SetModified;
|
property Modified: boolean read FModified write SetModified;
|
||||||
|
property IdleConnected: boolean read FIdleConnected write SetIdleConnected;
|
||||||
|
property FollowCursor: boolean read FFollowCursor write SetFollowCursor;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -287,8 +297,7 @@ begin
|
|||||||
|
|
||||||
CodeHelpBoss.AddHandlerOnChanging(@OnFPDocChanging);
|
CodeHelpBoss.AddHandlerOnChanging(@OnFPDocChanging);
|
||||||
CodeHelpBoss.AddHandlerOnChanged(@OnFPDocChanged);
|
CodeHelpBoss.AddHandlerOnChanged(@OnFPDocChanged);
|
||||||
Application.AddOnIdleHandler(@ApplicationIdle);
|
|
||||||
|
|
||||||
Name := NonModalIDEWindowNames[nmiwFPDocEditorName];
|
Name := NonModalIDEWindowNames[nmiwFPDocEditorName];
|
||||||
|
|
||||||
BoldFormatButton.LoadGlyphFromLazarusResource('formatbold');
|
BoldFormatButton.LoadGlyphFromLazarusResource('formatbold');
|
||||||
@ -302,10 +311,14 @@ begin
|
|||||||
|
|
||||||
SourceEditorManagerIntf.RegisterChangeEvent(semEditorActivate, @DoEditorUpdate);
|
SourceEditorManagerIntf.RegisterChangeEvent(semEditorActivate, @DoEditorUpdate);
|
||||||
SourceEditorManagerIntf.RegisterChangeEvent(semEditorStatus, @DoEditorUpdate);
|
SourceEditorManagerIntf.RegisterChangeEvent(semEditorStatus, @DoEditorUpdate);
|
||||||
|
|
||||||
|
FollowCursor:=true;
|
||||||
|
IdleConnected:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TFPDocEditor.FormDestroy(Sender: TObject);
|
procedure TFPDocEditor.FormDestroy(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
|
IdleConnected:=false;
|
||||||
Reset;
|
Reset;
|
||||||
FreeAndNil(fChain);
|
FreeAndNil(fChain);
|
||||||
if assigned(CodeHelpBoss) then
|
if assigned(CodeHelpBoss) then
|
||||||
@ -436,7 +449,11 @@ begin
|
|||||||
DebugLn(['WARNING: TFPDocEditor.ApplicationIdle fUpdateLock>0']);
|
DebugLn(['WARNING: TFPDocEditor.ApplicationIdle fUpdateLock>0']);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
if not IsVisible then exit;
|
if not IsVisible then begin
|
||||||
|
Include(FFlags,fpdefWasHidden);
|
||||||
|
IdleConnected:=false;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
ActiveForm:=Screen.ActiveCustomForm;
|
ActiveForm:=Screen.ActiveCustomForm;
|
||||||
if (ActiveForm<>nil) and (fsModal in ActiveForm.FormState) then exit;
|
if (ActiveForm<>nil) and (fsModal in ActiveForm.FormState) then exit;
|
||||||
Done:=false;
|
Done:=false;
|
||||||
@ -452,8 +469,11 @@ begin
|
|||||||
UpdateInheritedControls
|
UpdateInheritedControls
|
||||||
else if fpdefTopicNeedsUpdate in FFlags then
|
else if fpdefTopicNeedsUpdate in FFlags then
|
||||||
UpdateTopicCombo
|
UpdateTopicCombo
|
||||||
else
|
else begin
|
||||||
|
//debugln(['TFPDocEditor.ApplicationIdle updated']);
|
||||||
Done:=true;
|
Done:=true;
|
||||||
|
IdleConnected:=false;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TFPDocEditor.MoveToInheritedButtonClick(Sender: TObject);
|
procedure TFPDocEditor.MoveToInheritedButtonClick(Sender: TObject);
|
||||||
@ -1061,14 +1081,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TFPDocEditor.DoEditorUpdate(Sender: TObject);
|
procedure TFPDocEditor.DoEditorUpdate(Sender: TObject);
|
||||||
var
|
|
||||||
SrcEdit: TSourceEditorInterface;
|
|
||||||
CaretPos: TPoint;
|
|
||||||
begin
|
begin
|
||||||
SrcEdit:= SourceEditorManagerIntf.ActiveEditor;
|
if FollowCursor then
|
||||||
if SrcEdit=nil then exit;
|
LoadIdentifierAtCursor;
|
||||||
CaretPos := SrcEdit.CursorScreenXY;
|
|
||||||
UpdateFPDocEditor(SrcEdit.FileName, CaretPos);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TFPDocEditor.UpdateTopicCombo;
|
procedure TFPDocEditor.UpdateTopicCombo;
|
||||||
@ -1096,6 +1111,24 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TFPDocEditor.SetIdleConnected(AValue: boolean);
|
||||||
|
begin
|
||||||
|
if FIdleConnected=AValue then Exit;
|
||||||
|
FIdleConnected:=AValue;
|
||||||
|
if IdleConnected then
|
||||||
|
Application.AddOnIdleHandler(@ApplicationIdle)
|
||||||
|
else
|
||||||
|
Application.RemoveOnIdleHandler(@ApplicationIdle);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TFPDocEditor.SetFollowCursor(AValue: boolean);
|
||||||
|
begin
|
||||||
|
if FFollowCursor=AValue then Exit;
|
||||||
|
FFollowCursor:=AValue;
|
||||||
|
if FollowCursor then
|
||||||
|
LoadIdentifierAtCursor;
|
||||||
|
end;
|
||||||
|
|
||||||
function TFPDocEditor.GetDefaultDocFile(CreateIfNotExists: Boolean): TLazFPDocFile;
|
function TFPDocEditor.GetDefaultDocFile(CreateIfNotExists: Boolean): TLazFPDocFile;
|
||||||
var
|
var
|
||||||
CacheWasUsed : Boolean;
|
CacheWasUsed : Boolean;
|
||||||
@ -1149,18 +1182,18 @@ begin
|
|||||||
FFlags:=FFlags+[fpdefCodeCacheNeedsUpdate,
|
FFlags:=FFlags+[fpdefCodeCacheNeedsUpdate,
|
||||||
fpdefChainNeedsUpdate,fpdefCaptionNeedsUpdate,
|
fpdefChainNeedsUpdate,fpdefCaptionNeedsUpdate,
|
||||||
fpdefValueControlsNeedsUpdate,fpdefInheritedControlsNeedsUpdate];
|
fpdefValueControlsNeedsUpdate,fpdefInheritedControlsNeedsUpdate];
|
||||||
|
IdleConnected:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TFPDocEditor.UpdateFPDocEditor(const SrcFilename: string;
|
procedure TFPDocEditor.LoadIdentifierAt(const SrcFilename: string;
|
||||||
const Caret: TPoint);
|
const Caret: TPoint);
|
||||||
var
|
var
|
||||||
NewSrcFilename: String;
|
NewSrcFilename: String;
|
||||||
begin
|
begin
|
||||||
|
//debugln(['TFPDocEditor.LoadIdentifierAt START ',SrcFilename,' ',dbgs(Caret)]);
|
||||||
// save the current changes to documentation
|
// save the current changes to documentation
|
||||||
Save(IsVisible);
|
Save(IsVisible);
|
||||||
// check if visible
|
|
||||||
if not IsVisible then exit;
|
|
||||||
|
|
||||||
NewSrcFilename:=TrimAndExpandFilename(SrcFilename);
|
NewSrcFilename:=TrimAndExpandFilename(SrcFilename);
|
||||||
if (NewSrcFilename=SourceFilename) and (CompareCaret(Caret,CaretXY)=0)
|
if (NewSrcFilename=SourceFilename) and (CompareCaret(Caret,CaretXY)=0)
|
||||||
and (fChain<>nil) and fChain.IsValid
|
and (fChain<>nil) and fChain.IsValid
|
||||||
@ -1175,6 +1208,20 @@ begin
|
|||||||
InvalidateChain;
|
InvalidateChain;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TFPDocEditor.LoadIdentifierAtCursor;
|
||||||
|
var
|
||||||
|
SrcEdit: TSourceEditorInterface;
|
||||||
|
begin
|
||||||
|
if SourceEditorManagerIntf=nil then exit;
|
||||||
|
if csDestroying in ComponentState then exit;
|
||||||
|
if FFlags*[fpdefReading,fpdefWriting]<>[] then exit;
|
||||||
|
SrcEdit:=SourceEditorManagerIntf.ActiveEditor;
|
||||||
|
if SrcEdit=nil then
|
||||||
|
Reset
|
||||||
|
else
|
||||||
|
LoadIdentifierAt(SrcEdit.FileName,SrcEdit.CursorTextXY);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TFPDocEditor.BeginUpdate;
|
procedure TFPDocEditor.BeginUpdate;
|
||||||
begin
|
begin
|
||||||
inc(fUpdateLock);
|
inc(fUpdateLock);
|
||||||
@ -1338,6 +1385,15 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TFPDocEditor.UpdateShowing;
|
||||||
|
begin
|
||||||
|
inherited UpdateShowing;
|
||||||
|
if IsVisible and (fpdefWasHidden in FFlags) then begin
|
||||||
|
Exclude(FFlags,fpdefWasHidden);
|
||||||
|
LoadIdentifierAtCursor;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TFPDocEditor.WriteNode(Element: TCodeHelpElement;
|
function TFPDocEditor.WriteNode(Element: TCodeHelpElement;
|
||||||
Values: TFPDocElementValues; Interactive: Boolean): Boolean;
|
Values: TFPDocElementValues; Interactive: Boolean): Boolean;
|
||||||
var
|
var
|
||||||
|
Loading…
Reference in New Issue
Block a user