mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 03:59:13 +02:00
IDE: sourceeditor: update ifdef node states on input less idle
git-svn-id: trunk@41205 -
This commit is contained in:
parent
241045c4cb
commit
c40294c9d2
@ -1090,6 +1090,7 @@ type
|
|||||||
function SomethingModified(Verbose: boolean = false): boolean;
|
function SomethingModified(Verbose: boolean = false): boolean;
|
||||||
procedure HideHint;
|
procedure HideHint;
|
||||||
procedure OnIdle(Sender: TObject; var Done: Boolean);
|
procedure OnIdle(Sender: TObject; var Done: Boolean);
|
||||||
|
procedure OnUserInput(Sender: TObject; Msg: Cardinal);
|
||||||
procedure LockAllEditorsInSourceChangeCache;
|
procedure LockAllEditorsInSourceChangeCache;
|
||||||
procedure UnlockAllEditorsInSourceChangeCache;
|
procedure UnlockAllEditorsInSourceChangeCache;
|
||||||
procedure BeginGlobalUpdate;
|
procedure BeginGlobalUpdate;
|
||||||
@ -1107,6 +1108,8 @@ type
|
|||||||
ASynAutoComplete: TCustomSynAutoComplete;
|
ASynAutoComplete: TCustomSynAutoComplete;
|
||||||
Index: integer);
|
Index: integer);
|
||||||
protected
|
protected
|
||||||
|
CodeToolsToSrcEditTimer: TTimer;
|
||||||
|
procedure CodeToolsToSrcEditTimerTimer(Sender: TObject);
|
||||||
procedure OnWordCompletionGetSource(var Source: TStrings; SourceIndex: integer);
|
procedure OnWordCompletionGetSource(var Source: TStrings; SourceIndex: integer);
|
||||||
procedure OnSourceCompletionTimer(Sender: TObject);
|
procedure OnSourceCompletionTimer(Sender: TObject);
|
||||||
// marks
|
// marks
|
||||||
@ -1326,7 +1329,7 @@ const
|
|||||||
SoftCenterMaximum = 8;
|
SoftCenterMaximum = 8;
|
||||||
|
|
||||||
var
|
var
|
||||||
SourceCompletionTimer: TIdleTimer = nil;
|
AutoStartCompletionBoxTimer: TIdleTimer = nil;
|
||||||
SourceCompletionCaretXY: TPoint;
|
SourceCompletionCaretXY: TPoint;
|
||||||
AWordCompletion: TWordCompletion = nil;
|
AWordCompletion: TWordCompletion = nil;
|
||||||
PasBeautifier: TSynBeautifierPascal;
|
PasBeautifier: TSynBeautifierPascal;
|
||||||
@ -1335,6 +1338,7 @@ function dbgs(AFlag: TSourceNotebookUpdateFlag): string; overload;
|
|||||||
begin
|
begin
|
||||||
WriteStr(Result, AFlag);
|
WriteStr(Result, AFlag);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function dbgs(AFlags: TSourceNotebookUpdateFlags): string; overload;
|
function dbgs(AFlags: TSourceNotebookUpdateFlags): string; overload;
|
||||||
var i: TSourceNotebookUpdateFlag;
|
var i: TSourceNotebookUpdateFlag;
|
||||||
begin
|
begin
|
||||||
@ -1886,7 +1890,7 @@ Begin
|
|||||||
if (KeyChar='.') and (OldCompletionType=ctIdentCompletion) then
|
if (KeyChar='.') and (OldCompletionType=ctIdentCompletion) then
|
||||||
begin
|
begin
|
||||||
SourceCompletionCaretXY:=Editor.CaretXY;
|
SourceCompletionCaretXY:=Editor.CaretXY;
|
||||||
SourceCompletionTimer.AutoEnabled:=true;
|
AutoStartCompletionBoxTimer.AutoEnabled:=true;
|
||||||
end;
|
end;
|
||||||
{$IFDEF VerboseIDECompletionBox}
|
{$IFDEF VerboseIDECompletionBox}
|
||||||
finally
|
finally
|
||||||
@ -3194,7 +3198,7 @@ var
|
|||||||
begin
|
begin
|
||||||
//DebugLn('TSourceEditor.ProcessCommand Command=',dbgs(Command));
|
//DebugLn('TSourceEditor.ProcessCommand Command=',dbgs(Command));
|
||||||
FSharedValues.SetActiveSharedEditor(Self);
|
FSharedValues.SetActiveSharedEditor(Self);
|
||||||
SourceCompletionTimer.AutoEnabled:=false;
|
AutoStartCompletionBoxTimer.AutoEnabled:=false;
|
||||||
|
|
||||||
if (Command=ecChar) and (AChar=#27) then begin
|
if (Command=ecChar) and (AChar=#27) then begin
|
||||||
// close hint windows
|
// close hint windows
|
||||||
@ -3280,7 +3284,7 @@ begin
|
|||||||
ecChar:
|
ecChar:
|
||||||
begin
|
begin
|
||||||
AddChar:=true;
|
AddChar:=true;
|
||||||
//debugln(['TSourceEditor.ProcessCommand AChar="',AChar,'" AutoIdentifierCompletion=',dbgs(EditorOpts.AutoIdentifierCompletion),' Interval=',SourceCompletionTimer.Interval,' ',Dbgs(FEditor.CaretXY),' ',FEditor.IsIdentChar(aChar)]);
|
//debugln(['TSourceEditor.ProcessCommand AChar="',AChar,'" AutoIdentifierCompletion=',dbgs(EditorOpts.AutoIdentifierCompletion),' Interval=',AutoStartCompletionBoxTimer.Interval,' ',Dbgs(FEditor.CaretXY),' ',FEditor.IsIdentChar(aChar)]);
|
||||||
if (aChar=' ') and AutoCompleteChar(aChar,AddChar,acoSpace) then begin
|
if (aChar=' ') and AutoCompleteChar(aChar,AddChar,acoSpace) then begin
|
||||||
// completed
|
// completed
|
||||||
end
|
end
|
||||||
@ -3292,7 +3296,7 @@ begin
|
|||||||
SourceCompletionCaretXY:=FEditor.CaretXY;
|
SourceCompletionCaretXY:=FEditor.CaretXY;
|
||||||
// add the char
|
// add the char
|
||||||
inc(SourceCompletionCaretXY.x,length(AChar));
|
inc(SourceCompletionCaretXY.x,length(AChar));
|
||||||
SourceCompletionTimer.AutoEnabled:=true;
|
AutoStartCompletionBoxTimer.AutoEnabled:=true;
|
||||||
end;
|
end;
|
||||||
//DebugLn(['TSourceEditor.ProcessCommand ecChar AddChar=',AddChar]);
|
//DebugLn(['TSourceEditor.ProcessCommand ecChar AddChar=',AddChar]);
|
||||||
if not AddChar then Command:=ecNone;
|
if not AddChar then Command:=ecNone;
|
||||||
@ -3332,7 +3336,7 @@ begin
|
|||||||
Manager.AddJumpPointClicked(Self);
|
Manager.AddJumpPointClicked(Self);
|
||||||
|
|
||||||
end;
|
end;
|
||||||
//debugln('TSourceEditor.ProcessCommand B IdentCompletionTimer.AutoEnabled=',dbgs(SourceCompletionTimer.AutoEnabled));
|
//debugln('TSourceEditor.ProcessCommand B IdentCompletionTimer.AutoEnabled=',dbgs(AutoStartCompletionBoxTimer.AutoEnabled));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSourceEditor.ProcessUserCommand(Sender: TObject;
|
procedure TSourceEditor.ProcessUserCommand(Sender: TObject;
|
||||||
@ -7217,8 +7221,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
if FMouseHideHintTimer <> nil then
|
if FMouseHideHintTimer <> nil then
|
||||||
FMouseHideHintTimer.Enabled := False;
|
FMouseHideHintTimer.Enabled := False;
|
||||||
if SourceCompletionTimer<>nil then
|
if AutoStartCompletionBoxTimer<>nil then
|
||||||
SourceCompletionTimer.Enabled:=false;
|
AutoStartCompletionBoxTimer.Enabled:=false;
|
||||||
if FHintWindow<>nil then begin
|
if FHintWindow<>nil then begin
|
||||||
FHintWindow.Visible:=false;
|
FHintWindow.Visible:=false;
|
||||||
FHintWindow.DisableAutoSizing;
|
FHintWindow.DisableAutoSizing;
|
||||||
@ -9495,7 +9499,7 @@ begin
|
|||||||
for i := FSourceWindowList.Count - 1 downto 0 do
|
for i := FSourceWindowList.Count - 1 downto 0 do
|
||||||
SourceWindows[i].ReloadEditorOptions;
|
SourceWindows[i].ReloadEditorOptions;
|
||||||
|
|
||||||
SourceCompletionTimer.Interval:=EditorOpts.AutoDelayInMSec;
|
AutoStartCompletionBoxTimer.Interval:=EditorOpts.AutoDelayInMSec;
|
||||||
// reload code templates
|
// reload code templates
|
||||||
with CodeTemplateModul do begin
|
with CodeTemplateModul do begin
|
||||||
if FileExistsUTF8(EditorOpts.CodeTemplateFilename) then
|
if FileExistsUTF8(EditorOpts.CodeTemplateFilename) then
|
||||||
@ -9875,6 +9879,8 @@ var
|
|||||||
j: Integer;
|
j: Integer;
|
||||||
Markling: TSourceMarkling;
|
Markling: TSourceMarkling;
|
||||||
begin
|
begin
|
||||||
|
CodeToolsToSrcEditTimer.Enabled:=true;
|
||||||
|
|
||||||
SrcEdit:=ActiveEditor;
|
SrcEdit:=ActiveEditor;
|
||||||
if (SrcEdit<>nil)
|
if (SrcEdit<>nil)
|
||||||
and (not SrcEdit.FSharedValues.FMarklingsValid) then
|
and (not SrcEdit.FSharedValues.FMarklingsValid) then
|
||||||
@ -9904,6 +9910,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TSourceEditorManager.OnUserInput(Sender: TObject; Msg: Cardinal);
|
||||||
|
begin
|
||||||
|
CodeToolsToSrcEditTimer.Enabled:=false;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TSourceEditorManager.LockAllEditorsInSourceChangeCache;
|
procedure TSourceEditorManager.LockAllEditorsInSourceChangeCache;
|
||||||
// lock all sourceeditors that are to be modified by the CodeToolBoss
|
// lock all sourceeditors that are to be modified by the CodeToolBoss
|
||||||
var
|
var
|
||||||
@ -10025,6 +10036,24 @@ begin
|
|||||||
ASynAutoComplete.IndentToTokenStart);
|
ASynAutoComplete.IndentToTokenStart);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TSourceEditorManager.CodeToolsToSrcEditTimerTimer(Sender: TObject);
|
||||||
|
{$IFDEF WithSynMarkupIfDef}
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
SrcEdit: TSourceEditor;
|
||||||
|
{$ENDIF}
|
||||||
|
begin
|
||||||
|
CodeToolsToSrcEditTimer.Enabled:=false;
|
||||||
|
|
||||||
|
{$IFDEF WithSynMarkupIfDef}
|
||||||
|
for i:=0 to SourceEditorCount-1 do begin
|
||||||
|
SrcEdit:=SourceEditors[i];
|
||||||
|
if not SrcEdit.EditorComponent.IsVisible then continue;
|
||||||
|
SrcEdit.UpdateIfDefNodeStates;
|
||||||
|
end;
|
||||||
|
{$ENDIF}
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TSourceEditorManager.OnWordCompletionGetSource(var Source: TStrings;
|
procedure TSourceEditorManager.OnWordCompletionGetSource(var Source: TStrings;
|
||||||
SourceIndex: integer);
|
SourceIndex: integer);
|
||||||
var TempEditor: TSourceEditor;
|
var TempEditor: TSourceEditor;
|
||||||
@ -10110,8 +10139,8 @@ procedure TSourceEditorManager.OnSourceCompletionTimer(Sender: TObject);
|
|||||||
var
|
var
|
||||||
TempEditor: TSourceEditor;
|
TempEditor: TSourceEditor;
|
||||||
begin
|
begin
|
||||||
SourceCompletionTimer.Enabled:=false;
|
AutoStartCompletionBoxTimer.Enabled:=false;
|
||||||
SourceCompletionTimer.AutoEnabled:=false;
|
AutoStartCompletionBoxTimer.AutoEnabled:=false;
|
||||||
TempEditor := ActiveEditor;
|
TempEditor := ActiveEditor;
|
||||||
if (TempEditor <> nil) and TempEditor.EditorComponent.Focused and
|
if (TempEditor <> nil) and TempEditor.EditorComponent.Focused and
|
||||||
(ComparePoints(TempEditor.EditorComponent.CaretXY, SourceCompletionCaretXY) = 0)
|
(ComparePoints(TempEditor.EditorComponent.CaretXY, SourceCompletionCaretXY) = 0)
|
||||||
@ -10171,15 +10200,28 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// identifier completion
|
// timer for auto start identifier completion
|
||||||
SourceCompletionTimer := TIdleTimer.Create(Self);
|
AutoStartCompletionBoxTimer := TIdleTimer.Create(Self);
|
||||||
with SourceCompletionTimer do begin
|
with AutoStartCompletionBoxTimer do begin
|
||||||
|
Name:='AutoStartCompletionBoxTimer';
|
||||||
AutoEnabled := False;
|
AutoEnabled := False;
|
||||||
Enabled := false;
|
Enabled := false;
|
||||||
Interval := EditorOpts.AutoDelayInMSec;
|
Interval := EditorOpts.AutoDelayInMSec;
|
||||||
OnTimer := @OnSourceCompletionTimer;
|
OnTimer := @OnSourceCompletionTimer;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// timer for syncing codetools changes to synedit
|
||||||
|
// started on idle
|
||||||
|
// ended on user input
|
||||||
|
// when triggered updates ifdef node states
|
||||||
|
CodeToolsToSrcEditTimer:=TTimer.Create(Self);
|
||||||
|
with CodeToolsToSrcEditTimer do begin
|
||||||
|
Name:='CodeToolsToSrcEditTimer';
|
||||||
|
Interval:=1000; // one second without user input
|
||||||
|
Enabled:=false;
|
||||||
|
OnTimer:=@CodeToolsToSrcEditTimerTimer;
|
||||||
|
end;
|
||||||
|
|
||||||
// marks
|
// marks
|
||||||
SourceEditorMarks:=TSourceMarks.Create(Self);
|
SourceEditorMarks:=TSourceMarks.Create(Self);
|
||||||
SourceEditorMarks.OnGetFilename:=@OnSourceMarksGetFilename;
|
SourceEditorMarks.OnGetFilename:=@OnSourceMarksGetFilename;
|
||||||
@ -10209,6 +10251,7 @@ begin
|
|||||||
true,@GetDefaultLayout);
|
true,@GetDefaultLayout);
|
||||||
|
|
||||||
Application.AddOnIdleHandler(@OnIdle);
|
Application.AddOnIdleHandler(@OnIdle);
|
||||||
|
Application.AddOnUserInputHandler(@OnUserInput);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TSourceEditorManager.Destroy;
|
destructor TSourceEditorManager.Destroy;
|
||||||
|
Loading…
Reference in New Issue
Block a user