1
0
mirror of https://github.com/moparisthebest/Simba synced 2025-02-16 15:20:09 -05:00

Merge branch 'master' of ssh://villavu.com:54367/simba

This commit is contained in:
Merlijn Wajer 2010-05-24 12:08:42 +02:00
commit f736f3c7cf
8 changed files with 108 additions and 84 deletions

View File

@ -16,7 +16,7 @@ type
function RegCreateKeyEx( function RegCreateKeyEx(
Key: LongWord; lpSubKey: TCharArray{PChar}; Reserved: LongInt; lpClass: Integer; Key: LongWord; lpSubKey: TCharArray{PChar}; Reserved: LongInt; lpClass: Integer;
dwOptions: LongInt; samDesired: LongWord; SecurityAttributes: Integer; dwOptions: LongInt; samDesired: LongWord; SecurityAttributes: Integer;
var pResult: LongWord; dwDisposition: TIntegerArray{PInteger} var pResult: LongWord; var dwDisposition: Integer
): LongInt; external 'RegCreateKeyExA@advapi32.dll stdcall'; ): LongInt; external 'RegCreateKeyExA@advapi32.dll stdcall';
function RegCloseKeyEx( function RegCloseKeyEx(
@ -107,11 +107,10 @@ end;
function RegOpenKey(KeyName: string; Root: LongWord; out Key: LongWord): Boolean; function RegOpenKey(KeyName: string; Root: LongWord; out Key: LongWord): Boolean;
var var
s: TCharArray; s: TCharArray;
disp: TIntegerArray; disp: Integer;
begin begin
Result := False; Result := False;
s := StringToCharArray(KeyName); //Conversion to "PChar" s := StringToCharArray(KeyName); //Conversion to "PChar"
SetLength(disp, 1);
case RegCreateKeyEx(Root, s, 0, 0, REG_OPTION_NON_VOLATILE, KEY_WRITE, 0, Key, disp) of case RegCreateKeyEx(Root, s, 0, 0, REG_OPTION_NON_VOLATILE, KEY_WRITE, 0, Key, disp) of
ERROR_SUCCESS: Result := True; ERROR_SUCCESS: Result := True;
ERROR_ACCESS_DENIED: WriteLn('Access denied'); ERROR_ACCESS_DENIED: WriteLn('Access denied');
@ -122,7 +121,7 @@ begin
ERROR_KEY_DELETED: WriteLn('Key marked for deletion'); ERROR_KEY_DELETED: WriteLn('Key marked for deletion');
end; end;
case disp[0] of case disp of
1: WriteLn('Key "'+KeyName+'" did not exist and was created.'); 1: WriteLn('Key "'+KeyName+'" did not exist and was created.');
2: WriteLn('Key "'+KeyName+'" existed and was simply opened without being changed.'); 2: WriteLn('Key "'+KeyName+'" existed and was simply opened without being changed.');
end; end;

View File

@ -363,9 +363,9 @@ begin
s := mp.GetExpressionAtPos; s := mp.GetExpressionAtPos;
if (s <> '') then if (s <> '') then
begin begin
sp := LastDelimiter('.', s); ep := LastDelimiter('.', s);
if (sp > 0) then if (ep > 0) then
Delete(s, sp, Length(s) - sp + 1) Delete(s, ep, Length(s) - ep + 1)
else else
s := ''; s := '';
end; end;
@ -377,7 +377,7 @@ begin
if (Data = nil) then if (Data = nil) then
begin begin
mp.FillSynCompletionProposal(ItemList, InsertList, s); mp.FillSynCompletionProposal(ItemList, InsertList, s);
p := SynEdit.ClientToScreen(SynEdit.RowColumnToPixels(Point(ep, SynEdit.CaretY))); p := SynEdit.ClientToScreen(SynEdit.RowColumnToPixels(Point(sp, SynEdit.CaretY)));
p.y := p.y + SynEdit.LineHeight; p.y := p.y + SynEdit.LineHeight;
SimbaForm.CodeCompletionForm.Show(p, ItemList, InsertList, Filter, SynEdit); SimbaForm.CodeCompletionForm.Show(p, ItemList, InsertList, Filter, SynEdit);
end; end;
@ -410,11 +410,15 @@ begin
s := mp.GetExpressionAtPos(bcc, bck, cc,posi, true); s := mp.GetExpressionAtPos(bcc, bck, cc,posi, true);
bracketpos := posi + length(s); bracketpos := posi + length(s);
if pos('(',s) > 0 then cc := LastDelimiter('(',s);
if cc > 0 then
begin; begin;
bracketpos := pos('(',s) + posi; bracketpos := cc + posi;
delete(s,pos('(',s),length(s) - pos('(',s) + 1); delete(s, cc, length(s) - cc + 1);
end; end;
cc := LastDelimiter('.',s);
if cc > 0 then
posi := posi + cc;
d := mp.FindVarBase(s); d := mp.FindVarBase(s);
dd := nil; dd := nil;
//Find the declaration -> For example if one uses var x : TNotifyEvent.. //Find the declaration -> For example if one uses var x : TNotifyEvent..
@ -426,7 +430,7 @@ begin
if (d <> nil) then if (d <> nil) then
begin begin
d := TciTypeKind(d).GetRealType; d := TciTypeKind(d).GetRealType;
if (d is TciReturnType) then if (d <> nil) and (d is TciReturnType) then
d := d.Owner; d := d.Owner;
end; end;
if (d <> nil) and (d.Owner <> nil) and (not ((d is TciProcedureDeclaration) or (d.Owner is TciProcedureDeclaration))) then if (d <> nil) and (d.Owner <> nil) and (not ((d is TciProcedureDeclaration) or (d.Owner is TciProcedureDeclaration))) then

View File

@ -1794,7 +1794,7 @@ end;
} }
procedure TSimbaForm.doOnHide(Sender: TObject); procedure TSimbaForm.doOnHide(Sender: TObject);
begin begin
if DebugImgForm.Visible then if (not (csDestroying in ComponentState)) and (DebugImgForm <> nil) and DebugImgForm.Showing then
DebugImgForm.Hide; DebugImgForm.Hide;
end; end;

View File

@ -361,7 +361,7 @@ begin
Includes.Add(path); Includes.Add(path);
try try
f:= TFileStream.Create(UTF8ToSys(Path), fmOpenRead or fmShareDenyWrite); f:= TFileStream.Create(UTF8ToSys(Path), fmOpenRead);
SetLength(contents, f.Size); SetLength(contents, f.Size);
f.Read(contents[1], Length(contents)); f.Read(contents[1], Length(contents));
result:= true; result:= true;

View File

@ -75,8 +75,8 @@ var
angle : extended; angle : extended;
begin begin
angle := ArcTan2(pt.y-my,pt.x-mx); angle := ArcTan2(pt.y-my,pt.x-mx);
result.y := round(sin(angle) * newdist) + mx; result.x := round(cos(angle) * newdist) + mx;
result.x := round(cos(angle) * newdist) + my; result.y := round(sin(angle) * newdist) + my;
end; end;
function ChangeDistTPA(var TPA : TPointArray; mx,my : integer; newdist : extended) : boolean; function ChangeDistTPA(var TPA : TPointArray; mx,my : integer; newdist : extended) : boolean;
@ -92,8 +92,8 @@ begin
for i := high(TPA) downto 0 do for i := high(TPA) downto 0 do
begin begin
angle := ArcTan2(TPA[i].y-my,TPA[i].x-mx); angle := ArcTan2(TPA[i].y-my,TPA[i].x-mx);
TPA[i].y := round(sin(angle) * newdist) + mx; TPA[i].x := round(cos(angle) * newdist) + mx;
TPA[i].x := round(cos(angle) * newdist) + my; TPA[i].y := round(sin(angle) * newdist) + my;
end; end;
except except
result := false; result := false;

View File

@ -582,6 +582,8 @@ var
i : integer; i : integer;
begin; begin;
result := ''; result := '';
if (Strings = nil) then
exit;
if endpos.y < beginpos.y then if endpos.y < beginpos.y then
exit; exit;
if endpos.y >= strings.Count then if endpos.y >= strings.Count then
@ -598,7 +600,7 @@ begin;
result := copy(strings[beginpos.y],beginpos.x, length(strings[beginpos.y]) - beginpos.x + 1); result := copy(strings[beginpos.y],beginpos.x, length(strings[beginpos.y]) - beginpos.x + 1);
for i := beginpos.y + 1 to endpos.y-1 do for i := beginpos.y + 1 to endpos.y-1 do
result := result + strings[i]; result := result + strings[i];
result := result + copy(strings[endpos.y],0,endpos.x-1); //Position <> count! result := result + copy(strings[endpos.y],0,endpos.x-1); //Position <> count!
end; end;
function TParamHint.PrepareParamString(out Str: string; out MustHide : boolean): Integer; function TParamHint.PrepareParamString(out Str: string; out MustHide : boolean): Integer;
@ -611,36 +613,42 @@ var
i,ii :integer; i,ii :integer;
CursorXY : TPoint; CursorXY : TPoint;
begin begin
result := -1; Result := -1;
MustHide := True; MustHide := True;
if (FSynEdit = nil) then
Exit;
Parser := TmwPasLex.Create; //The position of the bracket Parser := TmwPasLex.Create; //The position of the bracket
parser.Origin:= PChar(StringListPartToText(Point(FBracketPoint.x,FBracketPoint.y-1), try
point(min(FSynEdit.CaretX,length(FSynEdit.Lines[FSynEdit.CaretY - 1])+1),FSynEdit.CaretY-1), Parser.Origin:= PChar(StringListPartToText(Point(FBracketPoint.x,FBracketPoint.y-1),
FSynEdit.lines)); Point(min(FSynEdit.CaretX,length(FSynEdit.Lines[FSynEdit.CaretY - 1])+1),FSynEdit.CaretY-1),
bracketcount := 0; FSynEdit.lines));
ParameterIndex := -1; bracketcount := 0;
while parser.TokenID <> tkNull do ParameterIndex := -1;
begin while parser.TokenID <> tkNull do
case parser.tokenID of begin
tkRoundOpen,tkSquareOpen: case parser.tokenID of
begin tkRoundOpen,tkSquareOpen:
inc(BracketCount); begin
if BracketCount = 1 then inc(BracketCount);
ParameterIndex := 0; if BracketCount = 1 then
ParameterIndex := 0;
end;
tkRoundClose, tkSquareClose:
begin
dec(BracketCount);
if bracketcount =0 then
exit;
end;
tkComma:
begin
if bracketcount = 1 then
inc(parameterIndex);
end;
end; end;
tkRoundClose, tkSquareClose: parser.NextNoJunk;
begin end;
dec(BracketCount); finally
if bracketcount =0 then Parser.Free;
exit;
end;
tkComma:
begin
if bracketcount = 1 then
inc(parameterIndex);
end;
end;
parser.NextNoJunk;
end; end;
if parameterindex = -1 then if parameterindex = -1 then
exit; exit;
@ -653,11 +661,11 @@ begin
end; end;
str := ''; str := '';
ParamC := 0; ParamC := 0;
typedecl := FDecl.Name; {typedecl := FDecl.Name;
if typedecl = nil then if typedecl = nil then
exit; exit;
if typedecl.shorttext = '' then if typedecl.shorttext = '' then
exit; exit;}
for i := 0 to high(FParameters) do for i := 0 to high(FParameters) do
begin begin
if (FParameters[i] is TciConstParameter) then if (FParameters[i] is TciConstParameter) then
@ -703,17 +711,22 @@ begin
else else
str := s + params + typestr; str := s + params + typestr;
end; end;
TypeDecl := FDecl.Items.GetFirstItemOfClass(TciReturnType); if (FDecl <> nil) then
TypeDecl := FDecl.Items.GetFirstItemOfClass(TciReturnType)
else
TypeDecl := nil;
if TypeDecl <> nil then if TypeDecl <> nil then
TypeStr := ': ' + typedecl.ShortText TypeStr := ': ' + typedecl.ShortText
else else
TypeStr := ''; TypeStr := '';
str := FDecl.Name.ShortText + '(' + str + ')' + TypeStr + ';';
str := '(' + str + ')' + TypeStr + ';';
if (FDecl <> nil) and (FDecl.Name <> nil) then
str := FDecl.Name.ShortText + str;
str := StringReplace(str,'\\','',[rfReplaceAll]); //Delete all the \\, something like \const \\x\ is the same as \const x\ str := StringReplace(str,'\\','',[rfReplaceAll]); //Delete all the \\, something like \const \\x\ is the same as \const x\
MustHide := False; MustHide := False;
Result := parameterindex; Result := parameterindex;
fPreparedString := str; fPreparedString := str;
Parser.Free;
end; end;
destructor TParamHint.Destroy; destructor TParamHint.Destroy;
@ -732,6 +745,10 @@ begin
OnHide:=@ParamHintHide; OnHide:=@ParamHintHide;
LastParameterIndex:= -1; LastParameterIndex:= -1;
Application.AddOnIdleHandler(@ApplicationIdle); Application.AddOnIdleHandler(@ApplicationIdle);
Fmp := nil;
FDecl := nil;
FSynEdit := nil;
end; end;
procedure TParamHint.CalculateBounds; procedure TParamHint.CalculateBounds;
@ -742,6 +759,8 @@ var
ClientXY: TPoint; ClientXY: TPoint;
ScreenXY: TPoint; ScreenXY: TPoint;
begin begin
if (FSynEdit = nil) then
Exit;
ScreenTextXY := FSynEdit.LogicalToPhysicalPos(FStartPoint); ScreenTextXY := FSynEdit.LogicalToPhysicalPos(FStartPoint);
ClientXY := FSynEdit.RowColumnToPixels(ScreenTextXY); ClientXY := FSynEdit.RowColumnToPixels(ScreenTextXY);
DrawWidth := FSynEdit.ClientWidth; //Maximum width it can have.. DrawWidth := FSynEdit.ClientWidth; //Maximum width it can have..
@ -797,8 +816,10 @@ end;
procedure TParamHint.ParamHintHide(Sender: TObject); procedure TParamHint.ParamHintHide(Sender: TObject);
begin begin
if FMP <> nil then if Fmp <> nil then
freeandnil(Fmp); FreeAndNil(Fmp);
FDecl := nil;
FSynEdit := nil;
end; end;
procedure TParamHint.DrawHints(var MaxWidth, MaxHeight: Integer; procedure TParamHint.DrawHints(var MaxWidth, MaxHeight: Integer;
@ -853,7 +874,7 @@ var
continue; continue;
end; end;
StartPos := Pos; StartPos := Pos;
if (Line[Pos] in ['a'..'z', 'A'..'Z', '0'..'9', '_']) then //We are in a word, lets draw that completely ;) if (Pos <= Length(Line)) and (Line[Pos] in ['a'..'z', 'A'..'Z', '0'..'9', '_']) then //We are in a word, lets draw that completely ;)
begin begin
while ((Pos < length(line)) and (Line[Pos + 1] in ['a'..'z', 'A'..'Z', '0'..'9', '_'])) do while ((Pos < length(line)) and (Line[Pos + 1] in ['a'..'z', 'A'..'Z', '0'..'9', '_'])) do
inc(pos); inc(pos);
@ -958,14 +979,19 @@ procedure TParamHint.Show(StartPoint,BracketPoint: TPoint;Decl : TciProcedureDec
begin begin
if self.Visible then if self.Visible then
self.hide; self.hide;
FDecl := Decl;
Fmp := mp; Fmp := mp;
FParameters:= Decl.GetParamDeclarations; FParameters:= Decl.GetParamDeclarations;
if Length(FParameters) = 0 then //Method has no Parameters if Length(FParameters) = 0 then //Method has no Parameters
exit; begin
FreeAndNil(Fmp);
Exit;
end;
FDecl := Decl;
FSynEdit := Editor; FSynEdit := Editor;
FStartPoint:= StartPoint; FStartPoint:= StartPoint;
FBracketPoint:= BracketPoint; FBracketPoint:= BracketPoint;
CalculateBounds; //Calculate the size we need! CalculateBounds; //Calculate the size we need!
self.Visible := true; self.Visible := true;
end; end;

View File

@ -153,7 +153,6 @@ begin
end end
else if DefineMatch then else if DefineMatch then
begin begin
//if (IncludeBuffer[i].LastChanged = lc) then //if (IncludeBuffer[i].LastChanged = lc) then
begin begin
ci.Lexer.LoadDefines(IncludeBuffer[i].DefinesOut); ci.Lexer.LoadDefines(IncludeBuffer[i].DefinesOut);
@ -182,13 +181,16 @@ begin
//Lexer.CloneDefinesFrom(ci.Lexer); //Lexer.CloneDefinesFrom(ci.Lexer);
if (ci.Lexer.Defines.IndexOf('IS_INCLUDE') < 0) then if (ci.Lexer.Defines.IndexOf('IS_INCLUDE') < 0) then
i := ci.Lexer.Defines.Add('IS_INCLUDE') i := ci.Lexer.Defines.Add('IS_INCLUDE');
else else
i := -1; i := -1;
Run; Run;
if (i > -1) then if (i > -1) then
ci.Lexer.Defines.Delete(i); begin
i := ci.Lexer.Defines.IndexOf('IS_INCLUDE');
if (i > -1) then
ci.Lexer.Defines.Delete(i);
end;
//DefinesOut := Lexer.SaveDefines; Weird bug, so moved out of the with statement //DefinesOut := Lexer.SaveDefines; Weird bug, so moved out of the with statement
ci.Lexer.CloneDefinesFrom(Lexer); ci.Lexer.CloneDefinesFrom(Lexer);
end; end;
@ -475,7 +477,7 @@ begin
c[3] := nil; c[3] := nil;
end; end;
else else
Continue; Break;
end; end;
if (i = High(InFunc) + 1) then if (i = High(InFunc) + 1) then
a := fItems.GetItemsOfClass(c[1]) a := fItems.GetItemsOfClass(c[1])
@ -664,7 +666,7 @@ begin
Dec(StartPos); Dec(StartPos);
while (StartPos > 0) and (s[StartPos] in [#10, #11, #13, #32]) do while (StartPos > 0) and (s[StartPos] in [#10, #11, #13, #32]) do
Dec(StartPos); Dec(StartPos);
if not ((LastWasDot and (s[StartPos] in ['a'..'z', 'A'..'Z', '0'..'9', '_', ']', ')'])) or ((not LastWasDot) and (s[StartPos] = '.'))) then if (StartPos > 0) and (not ((LastWasDot and (s[StartPos] in ['a'..'z', 'A'..'Z', '0'..'9', '_', ']', ')'])) or ((not LastWasDot) and (s[StartPos] = '.')))) then
begin begin
StartPos := i - BracketCount - BraceCount; StartPos := i - BracketCount - BraceCount;
Break; Break;

View File

@ -112,8 +112,7 @@ type
private private
fProcType: string; fProcType: string;
fParams: string; fParams: string;
fSynParams: string; fName: TciProcedureName;
fName : TciProcedureName;
fCleanDecl : string; fCleanDecl : string;
function GetCleanDeclaration: string; function GetCleanDeclaration: string;
@ -356,7 +355,7 @@ function TDeclarationList.GetItemsOfClass(AClass: TDeclarationClass; SubSearch:
var var
i: Integer; i: Integer;
begin begin
if (Item is AClass) then if ((Item = nil) and (AClass = nil)) or (Item is AClass) then
begin begin
SetLength(Res, ResIndex + 1); SetLength(Res, ResIndex + 1);
Res[ResIndex] := Item; Res[ResIndex] := Item;
@ -384,7 +383,7 @@ function TDeclarationList.GetFirstItemOfClass(AClass: TDeclarationClass; SubSear
i: Integer; i: Integer;
begin begin
Result := False; Result := False;
if (Item is AClass) then if ((Item = nil) and (AClass = nil)) or (Item is AClass) then
begin begin
Res := Item; Res := Item;
Result := True; Result := True;
@ -549,7 +548,7 @@ function TDeclaration.HasOwnerClass(AClass: TDeclarationClass; out Declaration:
function IsOwner(Item: TDeclaration; AClass: TDeclarationClass; out Decl: TDeclaration; Recursive: Boolean): Boolean; function IsOwner(Item: TDeclaration; AClass: TDeclarationClass; out Decl: TDeclaration; Recursive: Boolean): Boolean;
begin begin
if (Item.Owner is AClass) then if ((AClass = nil) and (Item.Owner = nil)) or (Item.Owner is AClass) then
begin begin
Result := True; Result := True;
Decl := Item.Owner; Decl := Item.Owner;
@ -576,7 +575,7 @@ function TDeclaration.GetOwnersOfClass(AClass: TDeclarationClass): TDeclarationA
var Res: TDeclarationArray; var Res: TDeclarationArray;
var ResIndex: Integer); var ResIndex: Integer);
begin begin
if (Item.Owner is AClass) then if ((AClass = nil) and (Item.Owner = nil)) or (Item.Owner is AClass) then
begin begin
SetLength(Res, ResIndex + 1); SetLength(Res, ResIndex + 1);
Res[ResIndex] := Item.Owner; Res[ResIndex] := Item.Owner;
@ -597,6 +596,8 @@ end;
constructor TDeclaration.Create(AParser: TmwSimplePasPar; AOwner: TDeclaration; AOrigin: PAnsiChar; AStart, AEnd: Integer); constructor TDeclaration.Create(AParser: TmwSimplePasPar; AOwner: TDeclaration; AOrigin: PAnsiChar; AStart, AEnd: Integer);
begin begin
inherited Create;
fParser := AParser; fParser := AParser;
fOwner := AOwner; fOwner := AOwner;
fOrigin := AOrigin; fOrigin := AOrigin;
@ -797,7 +798,7 @@ begin
if (LowerCase(fProcType) = 'class') then if (LowerCase(fProcType) = 'class') then
begin begin
Delete(s, 1, 6); Delete(s, 1, 6);
fProcType := GetFirstWord(s); fProcType := 'class ' + GetFirstWord(s);
end; end;
if (fProcType = '') then if (fProcType = '') then
@ -811,19 +812,13 @@ begin
end; end;
function TciProcedureDeclaration.GetName: TciProcedureName; function TciProcedureDeclaration.GetName: TciProcedureName;
var
ProcedureName : TciProcedureName;
begin begin
if (fName <> nil) then if (fName <> nil) then
result := fName Result := fName
else else
begin begin
ProcedureName := TciProcedureName(fItems.GetFirstItemOfClass(TciProcedureName)); fName := TciProcedureName(fItems.GetFirstItemOfClass(TciProcedureName));
if ProcedureName <> nil then Result := fName;
result := ProcedureName
else
Result := nil;
fName := result;
end; end;
end; end;
@ -835,11 +830,10 @@ begin
result := fCleanDecl result := fCleanDecl
else else
begin begin
result := ''; result := proctype;
if Name = nil then if (Name <> nil) then
exit; result := result + ' ' + Name.ShortText;
result := proctype + ' ' + Name.ShortText; if (Params <> '') then
if Params <> '' then
result := result + '(' + params + ')'; result := result + '(' + params + ')';
Return := fItems.GetFirstItemOfClass(TciReturnType) as TciReturnType; Return := fItems.GetFirstItemOfClass(TciReturnType) as TciReturnType;
if (Return <> nil) then if (Return <> nil) then
@ -849,7 +843,6 @@ begin
end; end;
end; end;
function TciProcedureDeclaration.GetParams: string; function TciProcedureDeclaration.GetParams: string;
var var
i: Integer; i: Integer;