From e07823a099b2f221c1d72228a7efe473061f2b62 Mon Sep 17 00:00:00 2001 From: lazarus Date: Sat, 3 Feb 2001 02:33:07 +0000 Subject: [PATCH] CodeCompletion works pretty well. Shane git-svn-id: trunk@167 - --- components/synedit/syncompletion.pas | 3 ++- ide/customformeditor.pp | 10 ++++------ ide/uniteditor.pp | 25 +++++++++++++++++++++++-- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/components/synedit/syncompletion.pas b/components/synedit/syncompletion.pas index 270cd725ff..2fc05d22e7 100644 --- a/components/synedit/syncompletion.pas +++ b/components/synedit/syncompletion.pas @@ -38,7 +38,6 @@ Known Issues: unit SynCompletion; {$I SynEdit.inc} - interface uses @@ -262,6 +261,8 @@ begin Scroll.OnChange := {$IFDEF FPC}@{$ENDIF}ScrollChange; Scroll.Parent := self; Scroll.OnEnter := {$IFDEF FPC}@{$ENDIF}ScrollGetFocus; + Scroll.Width := 10; + Scroll.Visible := TRue; //shane Visible := false; FFontHeight := Canvas.TextHeight('Cyrille de Brebisson'); Color := clWindow; diff --git a/ide/customformeditor.pp b/ide/customformeditor.pp index 269974f3cf..4ddf0d0a7e 100644 --- a/ide/customformeditor.pp +++ b/ide/customformeditor.pp @@ -240,8 +240,7 @@ Begin else Result := nil; -//does freeing this kill my result? Check this... -// Freemem(PP); + Freemem(PP); end; Function TComponentInterface.GetPPropInfoByName(Name:String): PPropInfo; @@ -266,13 +265,11 @@ Begin else Result := nil; -//does freeing this kill my result? Check this... -// Freemem(PP); + Freemem(PP); end; Function TComponentInterface.GetComponentType : String; Begin -//???What do I return? TObject's Classtype? Result:=FControl.ClassName; end; @@ -495,7 +492,8 @@ end; Function TComponentInterface.Focus : Boolean; Begin // XXX Todo: - + if (FCOntrol is TWinControl) {and (TWinControl(FControl).CanFocus)} then + TWinControl(FControl).SetFocus; end; Function TComponentInterface.Delete : Boolean; diff --git a/ide/uniteditor.pp b/ide/uniteditor.pp index 7eaef27008..cd1baf6b24 100644 --- a/ide/uniteditor.pp +++ b/ide/uniteditor.pp @@ -137,7 +137,7 @@ type Procedure BookMarkGoto(Value : Integer); Procedure ccExecute(Sender : TObject); - + procedure ccComplete(var Value: ansistring; Shift: TShiftState); Procedure ProcessUserCommand(Sender: TObject; var Command: TSynEditorCommand; var AChar: char; Data: pointer); @@ -280,6 +280,8 @@ var Editor_Num : Integer; aHighlighter: TSynPasSyn; aCompletion : TSynCompletion; +scompl : TSynBaseCompletion; //used in ccexecute and cccomplete + { TSourceEditor } @@ -838,6 +840,25 @@ Begin EditorOpts.GetSynEditSettings(FEditor); end; +procedure TSourceEditor.ccComplete(var Value: ansistring; Shift: TShiftState); +var + S1,S2 : String; +Begin +Writeln('ccComplete. Value = '+Value); +Writeln('FEditor.seltext = '+FEditor.Seltext); + S1 := Copy(Value,1,pos(' ',Value)-1); + Delete(Value,1,pos(' ',Value)); + S2 := Copy(Value,1,pos(' ',Value)-1); + +if S1 = 'property' then Value := S2 + else +if S1 = 'procedure' then Value := S2+'('; + +Value := Feditor.SelText + Value; +scompl.Deactivate; +End; + + Procedure TSourceEditor.ccExecute(Sender : TObject); type @@ -847,7 +868,6 @@ type TypeName : ShortString; end; var - scompl : TSynBaseCompletion; S : TStrings; CompInt : TComponentInterface; CompName : String; @@ -1006,6 +1026,7 @@ Begin RefreshEditorSettings; aCompletion.Editor := FEditor; aCompletion.OnExecute := @ccExecute; + aCompletion.OnCodeCompletion := @ccComplete; FEditor.Lines.Assign(FSource); FEditor.Setfocus end;