From 86b00770219e58520e10c3194733b26866fd3d9b Mon Sep 17 00:00:00 2001 From: Niels Date: Tue, 18 May 2010 15:50:21 +0200 Subject: [PATCH] Added a Sleep(1) to the Idle handler in param hint, so CPU usage gets cut down to ~1% --- Projects/Simba/framescript.pas | 41 ++++++++++++++++--------------- Units/Misc/v_autocompleteform.pas | 10 ++++++-- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/Projects/Simba/framescript.pas b/Projects/Simba/framescript.pas index 2d4976c..6eddaff 100644 --- a/Projects/Simba/framescript.pas +++ b/Projects/Simba/framescript.pas @@ -219,12 +219,31 @@ procedure TScriptFrame.SynEditCommandProcessed(Sender: TObject; var Command: TSynEditorCommand; var AChar: TUTF8Char; Data: pointer); var Command2 : TSynEditorCommand; + s: string; + sp, ep: Integer; begin if (Command = ecChar) and (AChar = '(') and (SimbaForm.ParamHint.Visible = false) and (SimbaForm.ShowHintAuto) then begin Command2:= ecCodeHints; SynEditProcessUserCommand(sender,command2,achar,nil); end; + + if SimbaForm.CodeCompletionForm.Visible then + case Command of + ecDeleteChar, ecDeleteWord, ecDeleteEOL: + begin + if (SynEdit.CaretY = SimbaForm.CodeCompletionStart.y) then + begin + s := WordAtCaret(SynEdit, sp, ep, SimbaForm.CodeCompletionStart.x); + if (SynEdit.CaretX >= SimbaForm.CodeCompletionStart.x) and (SynEdit.CaretX <= ep) then + begin + SimbaForm.CodeCompletionForm.ListBox.Filter := s; + Exit; + end; + end; + SimbaForm.CodeCompletionForm.Hide; + end; + end; end; procedure TScriptFrame.SynEditDragDrop(Sender, Source: TObject; X, Y: Integer); @@ -454,23 +473,6 @@ begin //Do not free the MP, we need to use this. end; end; - if SimbaForm.CodeCompletionForm.Visible then - case Command of - ecDeleteChar, ecDeleteWord, ecDeleteEOL: - begin - if (SynEdit.CaretY = SimbaForm.CodeCompletionStart.y) then - begin - //e.GetWordBoundsAtRowCol(acp_start, sp, ep); - s := WordAtCaret(SynEdit, sp, ep, SimbaForm.CodeCompletionStart.x); - if (SynEdit.CaretX >= SimbaForm.CodeCompletionStart.x) and (SynEdit.CaretX <= ep) then - begin - SimbaForm.CodeCompletionForm.ListBox.Filter := s; - Exit; - end; - end; - SimbaForm.CodeCompletionForm.Hide; - end; - end; end; procedure TScriptFrame.SynEditSpecialLineColors(Sender: TObject; @@ -484,8 +486,7 @@ begin end; end; -procedure TScriptFrame.SynEditStatusChange(Sender: TObject; - Changes: TSynStatusChanges); +procedure TScriptFrame.SynEditStatusChange(Sender: TObject; Changes: TSynStatusChanges); var sp, ep: Integer; s: string; @@ -501,7 +502,7 @@ begin if SimbaForm.CodeCompletionForm.Visible then if (scAll in Changes) or (scTopLine in Changes) then - SimbaForm.CodeCompletionForm.Visible := False + SimbaForm.CodeCompletionForm.Hide else if (scCaretX in Changes) or (scCaretY in Changes) or (scSelection in Changes) or (scModified in Changes) then begin if (SynEdit.CaretY = SimbaForm.CodeCompletionStart.y) then diff --git a/Units/Misc/v_autocompleteform.pas b/Units/Misc/v_autocompleteform.pas index b622e87..dbf88f5 100644 --- a/Units/Misc/v_autocompleteform.pas +++ b/Units/Misc/v_autocompleteform.pas @@ -82,8 +82,6 @@ type property InsertProc: TInsertProc read getInsertProc write setInsertProc; end; - { TParamHint } - TParamHint = class(THintWindow) private fPreparedString : string; @@ -341,6 +339,13 @@ begin begin Font.Style := []; Font.Color := clBlack; + + if (Index = Count - 1) and (ARect.Bottom < ClientHeight - 1) then + begin + Brush.Color := clWhite; + FillRect(Rect(0, ARect.Bottom + 1, ClientWidth, ClientHeight)); + end; + if (odSelected in State) then Brush.Color := clHighlight else if (odHotLight in State) then @@ -970,6 +975,7 @@ procedure TParamHint.ApplicationIdle(Sender: TObject; var Done: Boolean); begin if not Visible then exit; UpdateHint; + Sleep(1); end; end.