mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 19:39:17 +02:00
Codecompletion changes.
Added code to Uniteditor for code completion. Also, added code to gtkobject.inc so forms now get keypress events. Shane git-svn-id: trunk@166 -
This commit is contained in:
parent
a60f0a22ae
commit
bf2acd12f4
@ -269,6 +269,7 @@ begin
|
|||||||
TStringList(FItemList).OnChange := {$IFDEF FPC}@{$ENDIF}StringListChange;
|
TStringList(FItemList).OnChange := {$IFDEF FPC}@{$ENDIF}StringListChange;
|
||||||
bitmap := TBitmap.Create;
|
bitmap := TBitmap.Create;
|
||||||
NbLinesInWindow := 6;
|
NbLinesInWindow := 6;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSynBaseCompletionForm.Deactivate;
|
procedure TSynBaseCompletionForm.Deactivate;
|
||||||
@ -289,6 +290,7 @@ procedure TSynBaseCompletionForm.KeyDown(var Key: Word;
|
|||||||
var
|
var
|
||||||
i: integer;
|
i: integer;
|
||||||
begin
|
begin
|
||||||
|
Writeln('[TSynBaseCompletionForm] KeyDown');
|
||||||
case Key of
|
case Key of
|
||||||
// added the VK_XXX codes to make it more readable / maintainable
|
// added the VK_XXX codes to make it more readable / maintainable
|
||||||
VK_RETURN:
|
VK_RETURN:
|
||||||
@ -351,6 +353,8 @@ end;
|
|||||||
procedure TSynBaseCompletionForm.Paint;
|
procedure TSynBaseCompletionForm.Paint;
|
||||||
var
|
var
|
||||||
i: integer;
|
i: integer;
|
||||||
|
S1,S2 : String;
|
||||||
|
|
||||||
function Min(a, b: integer): integer;
|
function Min(a, b: integer): integer;
|
||||||
begin
|
begin
|
||||||
if a < b then
|
if a < b then
|
||||||
@ -389,14 +393,27 @@ Writeln('[TSynBaseCompletionForm.Paint]');
|
|||||||
Canvas.Pen.Color := clSelect;
|
Canvas.Pen.Color := clSelect;
|
||||||
Canvas.Rectangle(0, FFontHeight * i, width, FFontHeight * (i + 1));
|
Canvas.Rectangle(0, FFontHeight * i, width, FFontHeight * (i + 1));
|
||||||
Canvas.Pen.Color := clBlack;
|
Canvas.Pen.Color := clBlack;
|
||||||
end else
|
Canvas.Font.Color := clWhite;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Begin
|
||||||
Canvas.Brush.Color := Color;
|
Canvas.Brush.Color := Color;
|
||||||
|
Canvas.Font.Color := clBlack;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
if not Assigned(OnPaintItem)
|
if not Assigned(OnPaintItem)
|
||||||
or not OnPaintItem(ItemList[Scroll.Position + i], Canvas, 0, FFontHeight * i)
|
or not OnPaintItem(ItemList[Scroll.Position + i], Canvas, 0, FFontHeight * i)
|
||||||
then
|
then
|
||||||
Begin
|
Begin
|
||||||
Writeln('Drawing to canvas');
|
Writeln('Drawing to canvas');
|
||||||
|
// Canvas.Font.Color := clBlack;
|
||||||
|
{ S1 := Copy(ItemList[Scroll.Position + i],pos('.',ItemList[Scroll.Position + i])+1,pos(':',ItemList[Scroll.Position + i])-1);
|
||||||
|
Canvas.TextOut(2, FFontHeight * i, S1);
|
||||||
|
|
||||||
|
Canvas.Font.Color := clLtGray;
|
||||||
|
Canvas.TextOut(2+(9*length(S1)), FFontHeight * i, Copy(ItemList[Scroll.Position + i],pos(':',ItemList[Scroll.Position + i]),255));
|
||||||
|
}
|
||||||
Canvas.TextOut(2, FFontHeight * i, ItemList[Scroll.Position + i]);
|
Canvas.TextOut(2, FFontHeight * i, ItemList[Scroll.Position + i]);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -48,6 +48,8 @@ or use TPropertyType
|
|||||||
Function GetPropName(Index : Integer) : String; virtual; abstract;
|
Function GetPropName(Index : Integer) : String; virtual; abstract;
|
||||||
Function GetPropTypebyName(Name : String) : TTypeKind; virtual; abstract;
|
Function GetPropTypebyName(Name : String) : TTypeKind; virtual; abstract;
|
||||||
// Function GetPropTypebyName(Name : String) : TPropertyType; virtual; abstract;
|
// Function GetPropTypebyName(Name : String) : TPropertyType; virtual; abstract;
|
||||||
|
Function GetPropTypeName(Index : Integer) : String; virtual; abstract;
|
||||||
|
|
||||||
|
|
||||||
Function GetPropValue(Index : Integer; var Value) : Boolean; virtual; abstract;
|
Function GetPropValue(Index : Integer; var Value) : Boolean; virtual; abstract;
|
||||||
Function GetPropValuebyName(Name: String; var Value) : Boolean; virtual; abstract;
|
Function GetPropValuebyName(Name: String; var Value) : Boolean; virtual; abstract;
|
||||||
|
@ -59,7 +59,9 @@ each control that's dropped onto the form
|
|||||||
Function IsTControl : Boolean; override;
|
Function IsTControl : Boolean; override;
|
||||||
Function GetPropCount : Integer; override;
|
Function GetPropCount : Integer; override;
|
||||||
Function GetPropType(Index : Integer) : TTypeKind; override;
|
Function GetPropType(Index : Integer) : TTypeKind; override;
|
||||||
|
Function GetPropTypeInfo(Index : Integer) : PTypeInfo;
|
||||||
Function GetPropName(Index : Integer) : String; override;
|
Function GetPropName(Index : Integer) : String; override;
|
||||||
|
Function GetPropTypeName(Index : Integer) : String; override;
|
||||||
Function GetPropTypebyName(Name : String) : TTypeKind; override;
|
Function GetPropTypebyName(Name : String) : TTypeKind; override;
|
||||||
|
|
||||||
Function GetPropValue(Index : Integer; var Value) : Boolean; override;
|
Function GetPropValue(Index : Integer; var Value) : Boolean; override;
|
||||||
@ -67,6 +69,7 @@ each control that's dropped onto the form
|
|||||||
Function SetProp(Index : Integer; const Value) : Boolean; override;
|
Function SetProp(Index : Integer; const Value) : Boolean; override;
|
||||||
Function SetPropbyName(Name : String; const Value) : Boolean; override;
|
Function SetPropbyName(Name : String; const Value) : Boolean; override;
|
||||||
|
|
||||||
|
|
||||||
Function GetControlCount: Integer; override;
|
Function GetControlCount: Integer; override;
|
||||||
Function GetControl(Index : Integer): TIComponentInterface; override;
|
Function GetControl(Index : Integer): TIComponentInterface; override;
|
||||||
|
|
||||||
@ -322,7 +325,27 @@ Begin
|
|||||||
freemem(PP);
|
freemem(PP);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function TComponentInterface.GetPropName(Index : Integer) : String;
|
Function TComponentInterface.GetPropTypeInfo(Index : Integer) : PTypeInfo;
|
||||||
|
var
|
||||||
|
PT : PTypeData;
|
||||||
|
PP : PPropList;
|
||||||
|
PI : PTypeInfo;
|
||||||
|
Num : Integer;
|
||||||
|
Begin
|
||||||
|
PI:=FControl.ClassInfo;
|
||||||
|
PT:=GetTypeData(PI);
|
||||||
|
GetMem (PP,PT^.PropCount*SizeOf(Pointer));
|
||||||
|
GetPropInfos(PI,PP);
|
||||||
|
if Index < PT^.PropCount then
|
||||||
|
Result := PP^[Index]^.PropType
|
||||||
|
else
|
||||||
|
Result := nil;
|
||||||
|
freemem(PP);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
{This returns "Integer" or "Boolean"}
|
||||||
|
Function TComponentInterface.GetPropTypeName(Index : Integer) : String;
|
||||||
var
|
var
|
||||||
PT : PTypeData;
|
PT : PTypeData;
|
||||||
PP : PPropList;
|
PP : PPropList;
|
||||||
@ -340,6 +363,27 @@ Begin
|
|||||||
freemem(PP);
|
freemem(PP);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
{This returns "Left" "Align" "Visible"}
|
||||||
|
Function TComponentInterface.GetPropName(Index : Integer) : String;
|
||||||
|
var
|
||||||
|
PT : PTypeData;
|
||||||
|
PP : PPropList;
|
||||||
|
PI : PTypeInfo;
|
||||||
|
Num : Integer;
|
||||||
|
Begin
|
||||||
|
PI:=FControl.ClassInfo;
|
||||||
|
PT:=GetTypeData(PI);
|
||||||
|
GetMem (PP,PT^.PropCount*SizeOf(Pointer));
|
||||||
|
GetPropInfos(PI,PP);
|
||||||
|
if Index < PT^.PropCount then
|
||||||
|
// Result := PP^[Index]^.PropType^.Name
|
||||||
|
Result := PP^[Index]^.Name
|
||||||
|
else
|
||||||
|
Result := '';
|
||||||
|
freemem(PP);
|
||||||
|
end;
|
||||||
|
|
||||||
Function TComponentInterface.GetPropTypebyName(Name : String) : TTypeKind;
|
Function TComponentInterface.GetPropTypebyName(Name : String) : TTypeKind;
|
||||||
var
|
var
|
||||||
PT : PTypeData;
|
PT : PTypeData;
|
||||||
|
@ -839,13 +839,27 @@ Begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TSourceEditor.ccExecute(Sender : TObject);
|
Procedure TSourceEditor.ccExecute(Sender : TObject);
|
||||||
|
type
|
||||||
|
|
||||||
|
TMethodRec = record
|
||||||
|
Flags : TParamFlags;
|
||||||
|
ParamName : ShortString;
|
||||||
|
TypeName : ShortString;
|
||||||
|
end;
|
||||||
var
|
var
|
||||||
scompl : TSynBaseCompletion;
|
scompl : TSynBaseCompletion;
|
||||||
S : TStrings;
|
S : TStrings;
|
||||||
CompInt : TComponentInterface;
|
CompInt : TComponentInterface;
|
||||||
CompName : String;
|
CompName : String;
|
||||||
I : Integer;
|
I,X : Integer;
|
||||||
propKind : TTypeKind;
|
propKind : TTypeKind;
|
||||||
|
TypeInfo : PTypeInfo;
|
||||||
|
TypeData : PTypeData;
|
||||||
|
NewStr : String;
|
||||||
|
aName : String;
|
||||||
|
Count : Integer;
|
||||||
|
MethodRec : TMethodRec;
|
||||||
|
Temp : String;
|
||||||
Begin
|
Begin
|
||||||
CompInt := nil;
|
CompInt := nil;
|
||||||
Writeln('[ccExecute]');
|
Writeln('[ccExecute]');
|
||||||
@ -856,8 +870,9 @@ Begin
|
|||||||
CompName := Copy(CompName,1,pos('.',Compname)-1);
|
CompName := Copy(CompName,1,pos('.',Compname)-1);
|
||||||
CompInt := TComponentInterface(FormEditor1.FindComponentByName(CompName));
|
CompInt := TComponentInterface(FormEditor1.FindComponentByName(CompName));
|
||||||
if CompInt = nil then Exit;
|
if CompInt = nil then Exit;
|
||||||
|
aName := CompName+'.';
|
||||||
//get all methods
|
//get all methods
|
||||||
|
NewStr := '';
|
||||||
for I := 0 to CompInt.GetPropCount-1 do
|
for I := 0 to CompInt.GetPropCount-1 do
|
||||||
Begin
|
Begin
|
||||||
Writeln('I = '+Inttostr(i));
|
Writeln('I = '+Inttostr(i));
|
||||||
@ -865,18 +880,88 @@ Begin
|
|||||||
PropKind := CompInt.GetPropType(i);
|
PropKind := CompInt.GetPropType(i);
|
||||||
case PropKind of
|
case PropKind of
|
||||||
tkMethod : Begin
|
tkMethod : Begin
|
||||||
Writeln('Property type is TKMETHOD');
|
TypeInfo := CompInt.GetPropTypeInfo(I);
|
||||||
// Writeln('
|
TypeData := GetTypeData(TypeInfo);
|
||||||
end;
|
NewStr := CompInt.GetPropName(I);
|
||||||
tkObject : Writeln('Property type is TKObject');
|
case TypeData^.MethodKind of
|
||||||
tkInteger : Writeln('Property type is TKINTEGER');
|
mkProcedure : NewStr := 'property '+CompInt.GetPropName(I)+' :'+CompInt.GetPropTypeName(I);
|
||||||
tkBool : Writeln('Property type is TKBool');
|
mkFunction : NewStr := 'property '+CompInt.GetPropName(I)+' :'+CompInt.GetPropTypeName(I);
|
||||||
end;
|
mkClassFunction : NewStr := CompInt.GetPropName(I) + ' '+'Function ';
|
||||||
end;
|
mkClassPRocedure : NewStr := CompInt.GetPropName(I) + ' '+'Procedure ';
|
||||||
{
|
mkConstructor : NewStr := 'constructor '+CompInt.GetPropName(I) + ' '+'procedure ';
|
||||||
S.Add('constructor Create(aOwner : TComponent);');
|
mkDestructor : NewStr := 'destructor '+CompInt.GetPropName(I) + ' '+'procedure ';
|
||||||
S.Add('OnActivate');
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
//check for parameters
|
||||||
|
Writeln('ParamCount = '+inttostr(TypeData^.ParamCount));
|
||||||
|
if TypeData^.ParamCount > 0 then
|
||||||
|
Begin
|
||||||
|
Writeln('----');
|
||||||
|
for Count := 0 to sizeof(TypeData^.ParamList)-1 do
|
||||||
|
if TypeData^.ParamList[4+Count] in ['a'..'z','A'..'Z','0'..'9'] then
|
||||||
|
Write(TypeData^.ParamList[Count])
|
||||||
|
else
|
||||||
|
Begin
|
||||||
|
Writeln('----');
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ NewStr := NewStr+'(';
|
||||||
|
for Count := 0 to TypeData^.ParamCount-1 do
|
||||||
|
begin
|
||||||
|
MethodRec.Flags := [];
|
||||||
|
Temp := '';
|
||||||
|
For X := 0 to Sizeof(MethodRec.Flags)-1 do
|
||||||
|
begin
|
||||||
|
Writeln('-->'+TypeData^.ParamList[Sizeof(MethodRec)*Count]);
|
||||||
|
Temp := Temp +TypeData^.ParamList[X+((Sizeof(MethodRec)-1)*Count)];
|
||||||
|
end;
|
||||||
|
Writeln('TEMP is <'+temp+'>');
|
||||||
|
MethodRec.ParamName := '';
|
||||||
|
For X := 0 to Sizeof(MethodRec.ParamName)-1 do
|
||||||
|
if TypeData^.ParamList[(Sizeof(MethodRec.Flags)-1)+((Sizeof(MethodRec)-1)*Count)+x] in ['a'..'z','A'..'Z','0'..'9'] then
|
||||||
|
MethodRec.ParamName := MethodRec.ParamName+TypeData^.ParamList[(Sizeof(MethodRec.Flags)-1)+((Sizeof(MethodRec)-1)*Count)+x]
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
|
||||||
|
Writeln('ParamName is '+MethodRec.ParamName);
|
||||||
|
MethodRec.TypeName := '';
|
||||||
|
For X := 0 to Sizeof(MethodRec.TypeName)-1 do
|
||||||
|
if TypeData^.ParamList[(Sizeof(MethodRec.Paramname)-1)+Sizeof(MethodRec.Flags)+((Sizeof(MethodRec)-1)*Count)+x] in ['a'..'z','A'..'Z','0'..'9'] then
|
||||||
|
MethodRec.TypeName := MethodRec.TypeName+TypeData^.ParamList[Sizeof(MethodRec.Paramname)+Sizeof(MethodRec.Flags)+((Sizeof(MethodRec)-1)*Count)+x]
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
Writeln('TypeName is '+MethodRec.TypeName);
|
||||||
|
|
||||||
|
// TParamFlags = set of (pfVar,pfConst,pfArray,pfAddress,pfReference,pfOut);
|
||||||
|
if (pfVar in MethodRec.Flags) then NewStr := NewStr+'var ';
|
||||||
|
if (pfConst in MethodRec.Flags) then NewStr := NewStr+'const ';
|
||||||
|
if (pfOut in MethodRec.Flags) then NewStr := NewStr+'out ';
|
||||||
|
if MethodRec.Typename <> 'void' then
|
||||||
|
NewStr := NewStr+MethodRec.ParamName+' :'+MethodRec.TypeName;
|
||||||
|
|
||||||
|
end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
end;
|
||||||
|
tkObject : NewStr := 'tkobject '+CompInt.GetPropName(I) +' :'+CompInt.GetPropTypeName(I);
|
||||||
|
tkInteger,tkChar,tkEnumeration,tkWChar : NewStr := 'property ' +CompInt.GetPropName(I) +' :'+CompInt.GetPropTypeName(I);
|
||||||
|
tkBool : NewStr := 'property '+CompInt.GetPropName(I) +' :'+CompInt.GetPropTypeName(I);
|
||||||
|
tkClass : NewStr := 'property '+CompInt.GetPropName(I) +' :'+CompInt.GetPropTypeName(I);
|
||||||
|
tkFloat : NewStr := 'property '+CompInt.GetPropName(I) +' :'+CompInt.GetPropTypeName(I);
|
||||||
|
tkSString : NewStr := 'property '+CompInt.GetPropName(I) +' :'+CompInt.GetPropTypeName(I);
|
||||||
|
tkUnKnown,tkLString,tkWString,tkAString,tkVariant : NewStr := 'property '+CompInt.GetPropName(I) +' :'+CompInt.GetPropTypeName(I);
|
||||||
|
end;
|
||||||
|
|
||||||
|
if NewStr <> '' then
|
||||||
|
S.Add(NewStr);
|
||||||
|
NewStr := '';
|
||||||
|
end;
|
||||||
|
|
||||||
sCompl.ItemList := S;
|
sCompl.ItemList := S;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
|
@ -362,7 +362,6 @@ var
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
// Assert(False, 'Trace:-----------------IN TCUSTOMFORM WNDPROC-------------------');
|
// Assert(False, 'Trace:-----------------IN TCUSTOMFORM WNDPROC-------------------');
|
||||||
|
|
||||||
with Message do
|
with Message do
|
||||||
case Msg of
|
case Msg of
|
||||||
LM_ACTIVATE, LM_SETFOCUS, LM_KILLFOCUS:
|
LM_ACTIVATE, LM_SETFOCUS, LM_KILLFOCUS:
|
||||||
@ -838,6 +837,13 @@ end;
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.11 2001/02/02 20:13:39 lazarus
|
||||||
|
Codecompletion changes.
|
||||||
|
Added code to Uniteditor for code completion.
|
||||||
|
|
||||||
|
Also, added code to gtkobject.inc so forms now get keypress events.
|
||||||
|
Shane
|
||||||
|
|
||||||
Revision 1.10 2001/02/01 16:45:20 lazarus
|
Revision 1.10 2001/02/01 16:45:20 lazarus
|
||||||
Started the code completion.
|
Started the code completion.
|
||||||
Shane
|
Shane
|
||||||
|
@ -1294,7 +1294,13 @@ begin
|
|||||||
ConnectSignal(PgtkObject(PgtkCombo(TComboBox(sender).handle)^.entry), 'key-press-event', @GTKKeyUpDown, GDK_KEY_PRESS_MASK);
|
ConnectSignal(PgtkObject(PgtkCombo(TComboBox(sender).handle)^.entry), 'key-press-event', @GTKKeyUpDown, GDK_KEY_PRESS_MASK);
|
||||||
ConnectSignal(PgtkObject(PgtkCombo(TComboBox(sender).handle)^.entry), 'key-release-event', @GTKKeyUpDown, GDK_KEY_RELEASE_MASK);
|
ConnectSignal(PgtkObject(PgtkCombo(TComboBox(sender).handle)^.entry), 'key-release-event', @GTKKeyUpDown, GDK_KEY_RELEASE_MASK);
|
||||||
|
|
||||||
end;
|
end
|
||||||
|
else
|
||||||
|
if (sender is TCustomForm) then
|
||||||
|
Begin
|
||||||
|
ConnectSignal(PgtkObject(TCustomForm(sender).handle), 'key-press-event', @GTKKeyUpDown, GDK_KEY_PRESS_MASK);
|
||||||
|
ConnectSignal(PgtkObject(TCustomForm(sender).handle), 'key-release-event', @GTKKeyUpDown, GDK_KEY_RELEASE_MASK);
|
||||||
|
end;
|
||||||
ConnectSignal(gFixed, 'key-press-event', @GTKKeyUpDown, GDK_KEY_PRESS_MASK);
|
ConnectSignal(gFixed, 'key-press-event', @GTKKeyUpDown, GDK_KEY_PRESS_MASK);
|
||||||
ConnectSignal(gFixed, 'key-release-event', @GTKKeyUpDown, GDK_KEY_RELEASE_MASK);
|
ConnectSignal(gFixed, 'key-release-event', @GTKKeyUpDown, GDK_KEY_RELEASE_MASK);
|
||||||
end;
|
end;
|
||||||
@ -2661,6 +2667,13 @@ end;
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.26 2001/02/02 20:13:39 lazarus
|
||||||
|
Codecompletion changes.
|
||||||
|
Added code to Uniteditor for code completion.
|
||||||
|
|
||||||
|
Also, added code to gtkobject.inc so forms now get keypress events.
|
||||||
|
Shane
|
||||||
|
|
||||||
Revision 1.25 2001/02/01 19:34:50 lazarus
|
Revision 1.25 2001/02/01 19:34:50 lazarus
|
||||||
TScrollbar created and a lot of code added.
|
TScrollbar created and a lot of code added.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user