From 63e0c71c47b8b2810823614fc64a0d9969906f15 Mon Sep 17 00:00:00 2001 From: lazarus Date: Fri, 22 Feb 2002 14:25:02 +0000 Subject: [PATCH] MG: fixed completion box for templates and identifiers git-svn-id: trunk@1453 - --- components/synedit/syneditautocomplete.pp | 4 + ide/main.pp | 5 +- ide/uniteditor.pp | 190 +++++++++++----------- 3 files changed, 105 insertions(+), 94 deletions(-) diff --git a/components/synedit/syneditautocomplete.pp b/components/synedit/syneditautocomplete.pp index 8ffc2cf45b..4758e2dd17 100644 --- a/components/synedit/syneditautocomplete.pp +++ b/components/synedit/syneditautocomplete.pp @@ -239,6 +239,10 @@ begin if not fParsed then ParseCompletionList; Len := Length(AToken); + {$IFDEF SYN_LAZARUS} + if (Len=0) and Assigned(fOnTokenNotFound) then + fOnTokenNotFound(Self,AToken,AEditor,i); + {$ENDIF} if (Len > 0) and (AEditor <> nil) and not AEditor.ReadOnly and (fCompletions.Count > 0) then begin diff --git a/ide/main.pp b/ide/main.pp index 07ffcb6bf7..d513c24c89 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -6085,7 +6085,7 @@ begin if FCodeLastActivated then begin // send command to source editor if ActiveSourceEditor=nil then exit; - ActiveSourceEditor.DoEditorBasicAction(EditorCommand); + ActiveSourceEditor.DoEditorExecuteCommand(EditorCommand); end else begin // send command to form editor if ActiveUnitInfo=nil then exit; @@ -6107,6 +6107,9 @@ end. { ============================================================================= $Log$ + Revision 1.229 2002/02/22 14:25:00 lazarus + MG: fixed completion box for templates and identifiers + Revision 1.228 2002/02/22 14:05:55 lazarus MG: edit menu reconnected to source editor diff --git a/ide/uniteditor.pp b/ide/uniteditor.pp index 7a85e5fb66..7ab845a45d 100644 --- a/ide/uniteditor.pp +++ b/ide/uniteditor.pp @@ -194,7 +194,7 @@ type procedure GetDialogPosition(Width, Height:integer; var Left,Top:integer); // editor commands - procedure DoEditorBasicAction(EditorCommand: integer); + procedure DoEditorExecuteCommand(EditorCommand: integer); //used to get the word at the mouse cursor Function GetWordAtPosition(Position : TPoint) : String; @@ -1494,7 +1494,7 @@ begin FVisible:=Value; end; -procedure TSourceEditor.DoEditorBasicAction(EditorCommand: integer); +procedure TSourceEditor.DoEditorExecuteCommand(EditorCommand: integer); begin EditorComponent.ExecuteCommand(EditorCommand,' ',nil); end; @@ -1752,6 +1752,7 @@ procedure TSourceNotebook.OnCodeTemplateTokenNotFound(Sender: TObject; AToken: string; AnEditor: TCustomSynEdit; var Index:integer); var P:TPoint; begin +writeln('RRRRRRRRRRR ',AToken,',',AnEditor.ReadOnly,',',CurrentCompletionType=ctNone); if (AnEditor.ReadOnly=false) and (CurrentCompletionType=ctNone) then begin CurrentCompletionType:=ctTemplateCompletion; with AnEditor do @@ -1901,98 +1902,101 @@ Begin while (X2>0) and (CurLine[X2] in ['A'..'Z','a'..'z','0'..'9','_']) do dec(X2); CompName:=copy(CurLine,X2+1,X1-X2-1); CompInt := TComponentInterface(FormEditor1.FindComponentByName(CompName)); - if CompInt = nil then Exit; - //get all methods - NewStr := ''; - for I := 0 to CompInt.GetPropCount-1 do - Begin - PropName:=#3'B'+CompInt.GetPropName(I)+#3'b'; - PropKind := CompInt.GetPropType(i); - case PropKind of - tkMethod : - Begin - TypeInfo := CompInt.GetPropTypeInfo(I); - TypeData := GetTypeData(TypeInfo); - - //check for parameters - if TypeData^.ParamCount > 0 then - Begin - {Writeln('----'); - for Count := 0 to 60 do - if TypeData^.ParamList[Count] in ['a'..'z','A'..'Z','0'..'9'] then - Write(TypeData^.ParamList[Count]) - else - Begin - Write('$',HexStr(ord(TypeData^.ParamList[Count]),3),' '); - end; - } - ParamStr := ''; - Offset:=0; - for Count := 0 to TypeData^.ParamCount-1 do - begin - Len:=1; // strange: SizeOf(TParamFlags) is 4, but the data is only 1 byte - Move(TypeData^.ParamList[Offset],MethodRec.Flags,Len); - inc(Offset,Len); - - Len:=ord(TypeData^.ParamList[Offset]); - inc(Offset); - SetLength(MethodRec.ParamName,Len); - Move(TypeData^.ParamList[Offset],MethodRec.ParamName[1],Len); - inc(Offset,Len); - - Len:=ord(TypeData^.ParamList[Offset]); - inc(Offset); - SetLength(MethodRec.TypeName,Len); - Move(TypeData^.ParamList[Offset],MethodRec.TypeName[1],Len); - inc(Offset,Len); - - if ParamStr<>'' then ParamStr:=';'+ParamStr; - if MethodRec.ParamName='' then - ParamStr:=MethodRec.TypeName+ParamStr - else - ParamStr:=MethodRec.ParamName+':'+MethodRec.TypeName+ParamStr; - if (pfVar in MethodRec.Flags) then ParamStr := 'var '+ParamStr; - if (pfConst in MethodRec.Flags) then ParamStr := 'const '+ParamStr; - if (pfOut in MethodRec.Flags) then ParamStr := 'out '+ParamStr; - end; - NewStr:='('+ParamStr+')'; - end else NewStr:=''; - case TypeData^.MethodKind of - mkProcedure : - NewStr := 'procedure '+PropName+' :'+CompInt.GetPropTypeName(I); - mkFunction : - NewStr := 'function '+PropName+' :'+CompInt.GetPropTypeName(I); - mkClassFunction : - NewStr := 'function '+PropName+' :'+'Function '+NewStr; - mkClassProcedure : - NewStr := 'procedure '+PropName+' :'+'Procedure '+NewStr; - mkConstructor : - NewStr := 'constructor '+PropName+' '+'procedure '; - mkDestructor : - NewStr := 'destructor '+PropName+' '+'procedure '; - end; - end; - - - tkObject : - NewStr := 'object '+PropName+' :'+CompInt.GetPropTypeName(I); - tkInteger,tkChar,tkEnumeration,tkWChar : - NewStr := 'var '+PropName+' :'+CompInt.GetPropTypeName(I); - tkBool : - NewStr := 'var '+PropName+' :'+CompInt.GetPropTypeName(I); - tkClass : - NewStr := 'class '+PropName+' :'+CompInt.GetPropTypeName(I); - tkFloat : - NewStr := 'var '+PropName+' :'+CompInt.GetPropTypeName(I); - tkSString : - NewStr := 'var '+PropName+' :'+CompInt.GetPropTypeName(I); - tkUnKnown,tkLString,tkWString,tkAString,tkVariant : - NewStr := 'var '+PropName+' :'+CompInt.GetPropTypeName(I); - end; - - if NewStr <> '' then S.Add(NewStr); + if CompInt = nil then begin + ccSelection:=''; + end else begin + //get all methods NewStr := ''; - end; // end for + for I := 0 to CompInt.GetPropCount-1 do + Begin + PropName:=#3'B'+CompInt.GetPropName(I)+#3'b'; + PropKind := CompInt.GetPropType(i); + case PropKind of + tkMethod : + Begin + TypeInfo := CompInt.GetPropTypeInfo(I); + TypeData := GetTypeData(TypeInfo); + + //check for parameters + if TypeData^.ParamCount > 0 then + Begin + {Writeln('----'); + for Count := 0 to 60 do + if TypeData^.ParamList[Count] in ['a'..'z','A'..'Z','0'..'9'] then + Write(TypeData^.ParamList[Count]) + else + Begin + Write('$',HexStr(ord(TypeData^.ParamList[Count]),3),' '); + end; + } + ParamStr := ''; + Offset:=0; + for Count := 0 to TypeData^.ParamCount-1 do + begin + Len:=1; // strange: SizeOf(TParamFlags) is 4, but the data is only 1 byte + Move(TypeData^.ParamList[Offset],MethodRec.Flags,Len); + inc(Offset,Len); + + Len:=ord(TypeData^.ParamList[Offset]); + inc(Offset); + SetLength(MethodRec.ParamName,Len); + Move(TypeData^.ParamList[Offset],MethodRec.ParamName[1],Len); + inc(Offset,Len); + + Len:=ord(TypeData^.ParamList[Offset]); + inc(Offset); + SetLength(MethodRec.TypeName,Len); + Move(TypeData^.ParamList[Offset],MethodRec.TypeName[1],Len); + inc(Offset,Len); + + if ParamStr<>'' then ParamStr:=';'+ParamStr; + if MethodRec.ParamName='' then + ParamStr:=MethodRec.TypeName+ParamStr + else + ParamStr:=MethodRec.ParamName+':'+MethodRec.TypeName+ParamStr; + if (pfVar in MethodRec.Flags) then ParamStr := 'var '+ParamStr; + if (pfConst in MethodRec.Flags) then ParamStr := 'const '+ParamStr; + if (pfOut in MethodRec.Flags) then ParamStr := 'out '+ParamStr; + end; + NewStr:='('+ParamStr+')'; + end else NewStr:=''; + case TypeData^.MethodKind of + mkProcedure : + NewStr := 'procedure '+PropName+' :'+CompInt.GetPropTypeName(I); + mkFunction : + NewStr := 'function '+PropName+' :'+CompInt.GetPropTypeName(I); + mkClassFunction : + NewStr := 'function '+PropName+' :'+'Function '+NewStr; + mkClassProcedure : + NewStr := 'procedure '+PropName+' :'+'Procedure '+NewStr; + mkConstructor : + NewStr := 'constructor '+PropName+' '+'procedure '; + mkDestructor : + NewStr := 'destructor '+PropName+' '+'procedure '; + end; + end; + + + tkObject : + NewStr := 'object '+PropName+' :'+CompInt.GetPropTypeName(I); + tkInteger,tkChar,tkEnumeration,tkWChar : + NewStr := 'var '+PropName+' :'+CompInt.GetPropTypeName(I); + tkBool : + NewStr := 'var '+PropName+' :'+CompInt.GetPropTypeName(I); + tkClass : + NewStr := 'class '+PropName+' :'+CompInt.GetPropTypeName(I); + tkFloat : + NewStr := 'var '+PropName+' :'+CompInt.GetPropTypeName(I); + tkSString : + NewStr := 'var '+PropName+' :'+CompInt.GetPropTypeName(I); + tkUnKnown,tkLString,tkWString,tkAString,tkVariant : + NewStr := 'var '+PropName+' :'+CompInt.GetPropTypeName(I); + end; + + if NewStr <> '' then S.Add(NewStr); + NewStr := ''; + end; // end for + end; end; ctWordCompletion: