mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 08:19:29 +02:00
IdeIntf, IDE: Revert r50029 #c87cf550f3 and improve the command update timer and its naming. From Ondrej Pokorny.
git-svn-id: trunk@50031 -
This commit is contained in:
parent
c9bfb53489
commit
b1942fb168
@ -598,9 +598,9 @@ type
|
||||
TIDECommands = class
|
||||
private
|
||||
FCustomUpdateEvents: TMethodList;
|
||||
FLateUpdateTimer: TTimer;
|
||||
FUpdateTimer: TTimer;
|
||||
|
||||
procedure FLateUpdateTimerTimer(Sender: TObject);
|
||||
procedure UpdateTimerTimer(Sender: TObject);
|
||||
protected
|
||||
function GetCategory(Index: integer): TIDECommandCategory; virtual; abstract;
|
||||
public
|
||||
@ -623,10 +623,11 @@ type
|
||||
IDEWindowClass: TCustomFormClass = nil): TFPList; virtual; abstract; // list of TIDECommand
|
||||
function CategoryCount: integer; virtual; abstract;
|
||||
public
|
||||
procedure StartUpdateHandler;
|
||||
procedure StartUpdateTimer;
|
||||
procedure StopUpdateTimer;
|
||||
|
||||
procedure ExecuteUpdateEvents;
|
||||
procedure LateExecuteUpdateEvents;
|
||||
procedure PostponeUpdateEvents;
|
||||
|
||||
procedure AddCustomUpdateEvent(const aEvent: TNotifyEvent);
|
||||
procedure RemoveCustomUpdateEvent(const aEvent: TNotifyEvent);
|
||||
@ -1420,16 +1421,17 @@ begin
|
||||
|
||||
FCustomUpdateEvents := TMethodList.Create;
|
||||
|
||||
//Updating the events needs a lot of CPU power, use TTimer for late updating
|
||||
FLateUpdateTimer := TTimer.Create(nil);
|
||||
FLateUpdateTimer.Interval := 800;
|
||||
FLateUpdateTimer.OnTimer := @FLateUpdateTimerTimer;
|
||||
FLateUpdateTimer.Enabled := False;
|
||||
//Updating the commands needs time and CPU power (codetools are called for some commands)
|
||||
// -> use TTimer with a reasonable interval and not Application.OnIdle
|
||||
FUpdateTimer := TTimer.Create(nil);
|
||||
FUpdateTimer.Interval := 500;
|
||||
FUpdateTimer.OnTimer := @UpdateTimerTimer;
|
||||
FUpdateTimer.Enabled := False;
|
||||
end;
|
||||
|
||||
destructor TIDECommands.Destroy;
|
||||
begin
|
||||
FLateUpdateTimer.Free;
|
||||
FUpdateTimer.Free;
|
||||
FCustomUpdateEvents.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
@ -1450,16 +1452,18 @@ begin
|
||||
Categories[i].DoOnUpdate;
|
||||
end;
|
||||
|
||||
procedure TIDECommands.FLateUpdateTimerTimer(Sender: TObject);
|
||||
procedure TIDECommands.UpdateTimerTimer(Sender: TObject);
|
||||
begin
|
||||
ExecuteUpdateEvents;
|
||||
FLateUpdateTimer.Enabled := False;
|
||||
end;
|
||||
|
||||
procedure TIDECommands.LateExecuteUpdateEvents;
|
||||
procedure TIDECommands.PostponeUpdateEvents;
|
||||
begin
|
||||
FLateUpdateTimer.Enabled := False;
|
||||
FLateUpdateTimer.Enabled := True;
|
||||
if FUpdateTimer.Enabled then
|
||||
begin
|
||||
FUpdateTimer.Enabled := False;
|
||||
FUpdateTimer.Enabled := True;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TIDECommands.RemoveCustomUpdateEvent(const aEvent: TNotifyEvent);
|
||||
@ -1467,9 +1471,14 @@ begin
|
||||
FCustomUpdateEvents.Remove(TMethod(aEvent));
|
||||
end;
|
||||
|
||||
procedure TIDECommands.StartUpdateHandler;
|
||||
procedure TIDECommands.StartUpdateTimer;
|
||||
begin
|
||||
FLateUpdateTimer.Enabled := True;
|
||||
FUpdateTimer.Enabled := True;
|
||||
end;
|
||||
|
||||
procedure TIDECommands.StopUpdateTimer;
|
||||
begin
|
||||
FUpdateTimer.Enabled := False;
|
||||
end;
|
||||
|
||||
{ TIDESpecialCommand }
|
||||
|
@ -1577,7 +1577,7 @@ begin
|
||||
MainIDEBar.ApplicationIsActivate:=true;
|
||||
IDECommandList.AddCustomUpdateEvent(@UpdateMainIDECommands);
|
||||
LazIDEInstances.StartListening(@LazInstancesStartNewInstance);
|
||||
IDECommandList.StartUpdateHandler;
|
||||
IDECommandList.StartUpdateTimer;
|
||||
FIDEStarted:=true;
|
||||
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TMainIDE.StartIDE END');{$ENDIF}
|
||||
end;
|
||||
@ -1973,6 +1973,7 @@ procedure TMainIDE.MainIDEFormClose(Sender: TObject;
|
||||
var CloseAction: TCloseAction);
|
||||
begin
|
||||
LazIDEInstances.StopServer;
|
||||
IDECommandList.StopUpdateTimer;
|
||||
DoCallNotifyHandler(lihtIDEClose);
|
||||
SaveEnvironment(true);
|
||||
if IDEDockMaster<>nil then
|
||||
|
@ -5247,7 +5247,7 @@ begin
|
||||
// can trigger the old editor to be refocused (while not visible)
|
||||
end;
|
||||
|
||||
IDECommandList.LateExecuteUpdateEvents;
|
||||
IDECommandList.ExecuteUpdateEvents;
|
||||
end;
|
||||
|
||||
procedure TSourceEditor.EditorActivateSyncro(Sender: TObject);
|
||||
@ -5334,12 +5334,15 @@ begin
|
||||
// debugln('MouseMove in Editor',X,',',Y);
|
||||
if Assigned(OnMouseMove) then
|
||||
OnMouseMove(Self,Shift,X,Y);
|
||||
if Shift*[ssLeft,ssRight]<>[] then
|
||||
IDECommandList.PostponeUpdateEvents;
|
||||
end;
|
||||
|
||||
procedure TSourceEditor.EditorMouseUp(Sender: TObject; Button: TMouseButton;
|
||||
Shift: TShiftState; X, Y: Integer);
|
||||
begin
|
||||
IDECommandList.LateExecuteUpdateEvents;
|
||||
if Button=mbLeft then
|
||||
IDECommandList.ExecuteUpdateEvents;
|
||||
end;
|
||||
|
||||
procedure TSourceEditor.EditorMouseWheel(Sender: TObject; Shift: TShiftState;
|
||||
@ -5366,7 +5369,7 @@ begin
|
||||
if Assigned(OnKeyDown) then
|
||||
OnKeyDown(Sender, Key, Shift);
|
||||
|
||||
IDECommandList.LateExecuteUpdateEvents;
|
||||
IDECommandList.PostponeUpdateEvents;
|
||||
end;
|
||||
|
||||
procedure TSourceEditor.EditorKeyUp(Sender: TObject; var Key: Word;
|
||||
@ -5376,7 +5379,7 @@ begin
|
||||
if Assigned(OnKeyUp) then
|
||||
OnKeyUp(Sender, Key, Shift);
|
||||
|
||||
IDECommandList.LateExecuteUpdateEvents;
|
||||
IDECommandList.PostponeUpdateEvents;
|
||||
end;
|
||||
|
||||
{-------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user