CodeCompletion works pretty well.

Shane

git-svn-id: trunk@167 -
This commit is contained in:
lazarus 2001-02-03 02:33:07 +00:00
parent bf2acd12f4
commit e07823a099
3 changed files with 29 additions and 9 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;