mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-24 15:19:21 +02:00
IDE: identifier completion hint: update via idle timer
git-svn-id: trunk@31319 -
This commit is contained in:
parent
a1d7624a88
commit
e748b7b37e
@ -32,6 +32,7 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, Math, SysUtils, LCLProc, LCLType, LCLIntf, Forms, Controls, Graphics,
|
Classes, Math, SysUtils, LCLProc, LCLType, LCLIntf, Forms, Controls, Graphics,
|
||||||
|
ExtCtrls,
|
||||||
SynEdit, SynEditKeyCmds,
|
SynEdit, SynEditKeyCmds,
|
||||||
SrcEditorIntf;
|
SrcEditorIntf;
|
||||||
|
|
||||||
@ -53,11 +54,13 @@ type
|
|||||||
{ TSrcEditHintWindow }
|
{ TSrcEditHintWindow }
|
||||||
|
|
||||||
TSrcEditHintWindow = class(THintWindow)
|
TSrcEditHintWindow = class(THintWindow)
|
||||||
|
IdleTimer1: TIdleTimer;
|
||||||
procedure ApplicationIdle(Sender: TObject; var Done: Boolean);
|
procedure ApplicationIdle(Sender: TObject; var Done: Boolean);
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
procedure FormDestroy(Sender: TObject);
|
procedure FormDestroy(Sender: TObject);
|
||||||
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||||
procedure FormUTF8KeyPress(Sender: TObject; var UTF8Key: TUTF8Char);
|
procedure FormUTF8KeyPress(Sender: TObject; var UTF8Key: TUTF8Char);
|
||||||
|
procedure IdleTimer1Timer(Sender: TObject);
|
||||||
private
|
private
|
||||||
FAnchorForm: TCustomForm;
|
FAnchorForm: TCustomForm;
|
||||||
FHelpEnabled: boolean;
|
FHelpEnabled: boolean;
|
||||||
@ -74,7 +77,7 @@ type
|
|||||||
constructor Create(TheOwner: TComponent); override;
|
constructor Create(TheOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
procedure Paint; override;
|
procedure Paint; override;
|
||||||
procedure UpdateHints;// update content
|
procedure UpdateHints(Immediately: boolean = false);// update content
|
||||||
function NeedVisible: boolean;
|
function NeedVisible: boolean;
|
||||||
property AnchorForm: TCustomForm read FAnchorForm write SetAnchorForm;
|
property AnchorForm: TCustomForm read FAnchorForm write SetAnchorForm;
|
||||||
property HelpEnabled: boolean read FHelpEnabled write SetHelpEnabled;
|
property HelpEnabled: boolean read FHelpEnabled write SetHelpEnabled;
|
||||||
@ -97,11 +100,8 @@ type
|
|||||||
procedure TSrcEditHintWindow.ApplicationIdle(Sender: TObject; var Done: Boolean);
|
procedure TSrcEditHintWindow.ApplicationIdle(Sender: TObject; var Done: Boolean);
|
||||||
begin
|
begin
|
||||||
//DebugLn(['TCodeHintFrm.ApplicationIdle NeedVisible=',NeedVisible]);
|
//DebugLn(['TCodeHintFrm.ApplicationIdle NeedVisible=',NeedVisible]);
|
||||||
if not NeedVisible then begin
|
if Visible and (not NeedVisible) then
|
||||||
Hide;
|
Hide;
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
UpdatePosition;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSrcEditHintWindow.FormCreate(Sender: TObject);
|
procedure TSrcEditHintWindow.FormCreate(Sender: TObject);
|
||||||
@ -147,6 +147,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TSrcEditHintWindow.IdleTimer1Timer(Sender: TObject);
|
||||||
|
begin
|
||||||
|
UpdateHints(true);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TSrcEditHintWindow.SetAnchorForm(const AValue: TCustomForm);
|
procedure TSrcEditHintWindow.SetAnchorForm(const AValue: TCustomForm);
|
||||||
begin
|
begin
|
||||||
if FAnchorForm=AValue then exit;
|
if FAnchorForm=AValue then exit;
|
||||||
@ -155,13 +160,14 @@ begin
|
|||||||
FAnchorForm:=AValue;
|
FAnchorForm:=AValue;
|
||||||
if FAnchorForm<>nil then
|
if FAnchorForm<>nil then
|
||||||
FAnchorForm.AddHandlerOnChangeBounds(@OnAnchorFormChangeBounds);
|
FAnchorForm.AddHandlerOnChangeBounds(@OnAnchorFormChangeBounds);
|
||||||
UpdatePosition;
|
UpdateHints;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSrcEditHintWindow.OnAnchorFormChangeBounds(Sender: TObject);
|
procedure TSrcEditHintWindow.OnAnchorFormChangeBounds(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
//DebugLn(['TCodeHintFrm.OnAnchorFormChangeBounds ',dbgs(BoundsRect),' Sender=',dbgsName(Sender),' SenderVisible=',TControl(Sender).Visible,' SenderBounds=',dbgs(TControl(Sender).BoundsRect)]);
|
//DebugLn(['TCodeHintFrm.OnAnchorFormChangeBounds ',dbgs(BoundsRect),' Sender=',dbgsName(Sender),' SenderVisible=',TControl(Sender).Visible,' SenderBounds=',dbgs(TControl(Sender).BoundsRect)]);
|
||||||
UpdatePosition;
|
if Visible then
|
||||||
|
UpdatePosition;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSrcEditHintWindow.SetHelpEnabled(const AValue: boolean);
|
procedure TSrcEditHintWindow.SetHelpEnabled(const AValue: boolean);
|
||||||
@ -170,7 +176,7 @@ begin
|
|||||||
FHelpEnabled:=AValue;
|
FHelpEnabled:=AValue;
|
||||||
if not HelpEnabled then
|
if not HelpEnabled then
|
||||||
Visible:=false;
|
Visible:=false;
|
||||||
UpdatePosition;
|
UpdateHints;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSrcEditHintWindow.SetProvider(const AValue: TCodeHintProvider);
|
procedure TSrcEditHintWindow.SetProvider(const AValue: TCodeHintProvider);
|
||||||
@ -275,7 +281,6 @@ begin
|
|||||||
//DebugLn(['TCodeHintFrm.UpdatePosition NewBounds=',dbgs(NewBounds),' BoundsRect=',dbgs(BoundsRect)]);
|
//DebugLn(['TCodeHintFrm.UpdatePosition NewBounds=',dbgs(NewBounds),' BoundsRect=',dbgs(BoundsRect)]);
|
||||||
BoundsRect:=NewBounds;
|
BoundsRect:=NewBounds;
|
||||||
Visible:=true;
|
Visible:=true;
|
||||||
UpdateHints;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSrcEditHintWindow.Paint;
|
procedure TSrcEditHintWindow.Paint;
|
||||||
@ -291,6 +296,11 @@ begin
|
|||||||
OnUTF8KeyPress:=@FormUTF8KeyPress;
|
OnUTF8KeyPress:=@FormUTF8KeyPress;
|
||||||
FPreferredWidth:=400;
|
FPreferredWidth:=400;
|
||||||
FPreferredHeight:=200;
|
FPreferredHeight:=200;
|
||||||
|
|
||||||
|
IdleTimer1:=TIdleTimer.Create(Self);
|
||||||
|
IdleTimer1.Interval:=400;
|
||||||
|
IdleTimer1.OnTimer:=@IdleTimer1Timer;
|
||||||
|
|
||||||
FormCreate(Self);
|
FormCreate(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -302,10 +312,21 @@ begin
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSrcEditHintWindow.UpdateHints;
|
procedure TSrcEditHintWindow.UpdateHints(Immediately: boolean);
|
||||||
begin
|
begin
|
||||||
|
if Visible and not NeedVisible then begin
|
||||||
|
// hide immediately
|
||||||
|
Hide;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
if not Immediately then begin
|
||||||
|
IdleTimer1.AutoEnabled:=true;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
//DebugLn(['TCodeHintFrm.UpdateHints Visible=',Visible]);
|
//DebugLn(['TCodeHintFrm.UpdateHints Visible=',Visible]);
|
||||||
if not Visible then exit;
|
IdleTimer1.AutoEnabled:=false;
|
||||||
|
IdleTimer1.Enabled:=false;
|
||||||
|
UpdatePosition;
|
||||||
if Provider<>nil then Provider.UpdateHint;
|
if Provider<>nil then Provider.UpdateHint;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user