mirror of
https://github.com/moparisthebest/Simba
synced 2024-11-25 18:52:15 -05:00
Merge branch 'master' of ssh://villavu.com:54367/simba
This commit is contained in:
commit
f736f3c7cf
@ -16,7 +16,7 @@ type
|
||||
function RegCreateKeyEx(
|
||||
Key: LongWord; lpSubKey: TCharArray{PChar}; Reserved: LongInt; lpClass: 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';
|
||||
|
||||
function RegCloseKeyEx(
|
||||
@ -107,11 +107,10 @@ end;
|
||||
function RegOpenKey(KeyName: string; Root: LongWord; out Key: LongWord): Boolean;
|
||||
var
|
||||
s: TCharArray;
|
||||
disp: TIntegerArray;
|
||||
disp: Integer;
|
||||
begin
|
||||
Result := False;
|
||||
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
|
||||
ERROR_SUCCESS: Result := True;
|
||||
ERROR_ACCESS_DENIED: WriteLn('Access denied');
|
||||
@ -122,7 +121,7 @@ begin
|
||||
ERROR_KEY_DELETED: WriteLn('Key marked for deletion');
|
||||
end;
|
||||
|
||||
case disp[0] of
|
||||
case disp of
|
||||
1: WriteLn('Key "'+KeyName+'" did not exist and was created.');
|
||||
2: WriteLn('Key "'+KeyName+'" existed and was simply opened without being changed.');
|
||||
end;
|
||||
|
@ -363,9 +363,9 @@ begin
|
||||
s := mp.GetExpressionAtPos;
|
||||
if (s <> '') then
|
||||
begin
|
||||
sp := LastDelimiter('.', s);
|
||||
if (sp > 0) then
|
||||
Delete(s, sp, Length(s) - sp + 1)
|
||||
ep := LastDelimiter('.', s);
|
||||
if (ep > 0) then
|
||||
Delete(s, ep, Length(s) - ep + 1)
|
||||
else
|
||||
s := '';
|
||||
end;
|
||||
@ -377,7 +377,7 @@ begin
|
||||
if (Data = nil) then
|
||||
begin
|
||||
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;
|
||||
SimbaForm.CodeCompletionForm.Show(p, ItemList, InsertList, Filter, SynEdit);
|
||||
end;
|
||||
@ -410,11 +410,15 @@ begin
|
||||
s := mp.GetExpressionAtPos(bcc, bck, cc,posi, true);
|
||||
|
||||
bracketpos := posi + length(s);
|
||||
if pos('(',s) > 0 then
|
||||
cc := LastDelimiter('(',s);
|
||||
if cc > 0 then
|
||||
begin;
|
||||
bracketpos := pos('(',s) + posi;
|
||||
delete(s,pos('(',s),length(s) - pos('(',s) + 1);
|
||||
bracketpos := cc + posi;
|
||||
delete(s, cc, length(s) - cc + 1);
|
||||
end;
|
||||
cc := LastDelimiter('.',s);
|
||||
if cc > 0 then
|
||||
posi := posi + cc;
|
||||
d := mp.FindVarBase(s);
|
||||
dd := nil;
|
||||
//Find the declaration -> For example if one uses var x : TNotifyEvent..
|
||||
@ -426,7 +430,7 @@ begin
|
||||
if (d <> nil) then
|
||||
begin
|
||||
d := TciTypeKind(d).GetRealType;
|
||||
if (d is TciReturnType) then
|
||||
if (d <> nil) and (d is TciReturnType) then
|
||||
d := d.Owner;
|
||||
end;
|
||||
if (d <> nil) and (d.Owner <> nil) and (not ((d is TciProcedureDeclaration) or (d.Owner is TciProcedureDeclaration))) then
|
||||
|
@ -1794,7 +1794,7 @@ end;
|
||||
}
|
||||
procedure TSimbaForm.doOnHide(Sender: TObject);
|
||||
begin
|
||||
if DebugImgForm.Visible then
|
||||
if (not (csDestroying in ComponentState)) and (DebugImgForm <> nil) and DebugImgForm.Showing then
|
||||
DebugImgForm.Hide;
|
||||
end;
|
||||
|
||||
|
@ -361,7 +361,7 @@ begin
|
||||
Includes.Add(path);
|
||||
|
||||
try
|
||||
f:= TFileStream.Create(UTF8ToSys(Path), fmOpenRead or fmShareDenyWrite);
|
||||
f:= TFileStream.Create(UTF8ToSys(Path), fmOpenRead);
|
||||
SetLength(contents, f.Size);
|
||||
f.Read(contents[1], Length(contents));
|
||||
result:= true;
|
||||
|
@ -75,8 +75,8 @@ var
|
||||
angle : extended;
|
||||
begin
|
||||
angle := ArcTan2(pt.y-my,pt.x-mx);
|
||||
result.y := round(sin(angle) * newdist) + mx;
|
||||
result.x := round(cos(angle) * newdist) + my;
|
||||
result.x := round(cos(angle) * newdist) + mx;
|
||||
result.y := round(sin(angle) * newdist) + my;
|
||||
end;
|
||||
|
||||
function ChangeDistTPA(var TPA : TPointArray; mx,my : integer; newdist : extended) : boolean;
|
||||
@ -92,8 +92,8 @@ begin
|
||||
for i := high(TPA) downto 0 do
|
||||
begin
|
||||
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) + my;
|
||||
TPA[i].x := round(cos(angle) * newdist) + mx;
|
||||
TPA[i].y := round(sin(angle) * newdist) + my;
|
||||
end;
|
||||
except
|
||||
result := false;
|
||||
|
@ -582,6 +582,8 @@ var
|
||||
i : integer;
|
||||
begin;
|
||||
result := '';
|
||||
if (Strings = nil) then
|
||||
exit;
|
||||
if endpos.y < beginpos.y then
|
||||
exit;
|
||||
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);
|
||||
for i := beginpos.y + 1 to endpos.y-1 do
|
||||
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;
|
||||
|
||||
function TParamHint.PrepareParamString(out Str: string; out MustHide : boolean): Integer;
|
||||
@ -611,36 +613,42 @@ var
|
||||
i,ii :integer;
|
||||
CursorXY : TPoint;
|
||||
begin
|
||||
result := -1;
|
||||
Result := -1;
|
||||
MustHide := True;
|
||||
if (FSynEdit = nil) then
|
||||
Exit;
|
||||
Parser := TmwPasLex.Create; //The position of the bracket
|
||||
parser.Origin:= PChar(StringListPartToText(Point(FBracketPoint.x,FBracketPoint.y-1),
|
||||
point(min(FSynEdit.CaretX,length(FSynEdit.Lines[FSynEdit.CaretY - 1])+1),FSynEdit.CaretY-1),
|
||||
FSynEdit.lines));
|
||||
bracketcount := 0;
|
||||
ParameterIndex := -1;
|
||||
while parser.TokenID <> tkNull do
|
||||
begin
|
||||
case parser.tokenID of
|
||||
tkRoundOpen,tkSquareOpen:
|
||||
begin
|
||||
inc(BracketCount);
|
||||
if BracketCount = 1 then
|
||||
ParameterIndex := 0;
|
||||
try
|
||||
Parser.Origin:= PChar(StringListPartToText(Point(FBracketPoint.x,FBracketPoint.y-1),
|
||||
Point(min(FSynEdit.CaretX,length(FSynEdit.Lines[FSynEdit.CaretY - 1])+1),FSynEdit.CaretY-1),
|
||||
FSynEdit.lines));
|
||||
bracketcount := 0;
|
||||
ParameterIndex := -1;
|
||||
while parser.TokenID <> tkNull do
|
||||
begin
|
||||
case parser.tokenID of
|
||||
tkRoundOpen,tkSquareOpen:
|
||||
begin
|
||||
inc(BracketCount);
|
||||
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;
|
||||
tkRoundClose, tkSquareClose:
|
||||
begin
|
||||
dec(BracketCount);
|
||||
if bracketcount =0 then
|
||||
exit;
|
||||
end;
|
||||
tkComma:
|
||||
begin
|
||||
if bracketcount = 1 then
|
||||
inc(parameterIndex);
|
||||
end;
|
||||
end;
|
||||
parser.NextNoJunk;
|
||||
parser.NextNoJunk;
|
||||
end;
|
||||
finally
|
||||
Parser.Free;
|
||||
end;
|
||||
if parameterindex = -1 then
|
||||
exit;
|
||||
@ -653,11 +661,11 @@ begin
|
||||
end;
|
||||
str := '';
|
||||
ParamC := 0;
|
||||
typedecl := FDecl.Name;
|
||||
{typedecl := FDecl.Name;
|
||||
if typedecl = nil then
|
||||
exit;
|
||||
if typedecl.shorttext = '' then
|
||||
exit;
|
||||
exit;}
|
||||
for i := 0 to high(FParameters) do
|
||||
begin
|
||||
if (FParameters[i] is TciConstParameter) then
|
||||
@ -703,17 +711,22 @@ begin
|
||||
else
|
||||
str := s + params + typestr;
|
||||
end;
|
||||
TypeDecl := FDecl.Items.GetFirstItemOfClass(TciReturnType);
|
||||
if (FDecl <> nil) then
|
||||
TypeDecl := FDecl.Items.GetFirstItemOfClass(TciReturnType)
|
||||
else
|
||||
TypeDecl := nil;
|
||||
if TypeDecl <> nil then
|
||||
TypeStr := ': ' + typedecl.ShortText
|
||||
else
|
||||
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\
|
||||
MustHide := False;
|
||||
Result := parameterindex;
|
||||
fPreparedString := str;
|
||||
Parser.Free;
|
||||
end;
|
||||
|
||||
destructor TParamHint.Destroy;
|
||||
@ -732,6 +745,10 @@ begin
|
||||
OnHide:=@ParamHintHide;
|
||||
LastParameterIndex:= -1;
|
||||
Application.AddOnIdleHandler(@ApplicationIdle);
|
||||
|
||||
Fmp := nil;
|
||||
FDecl := nil;
|
||||
FSynEdit := nil;
|
||||
end;
|
||||
|
||||
procedure TParamHint.CalculateBounds;
|
||||
@ -742,6 +759,8 @@ var
|
||||
ClientXY: TPoint;
|
||||
ScreenXY: TPoint;
|
||||
begin
|
||||
if (FSynEdit = nil) then
|
||||
Exit;
|
||||
ScreenTextXY := FSynEdit.LogicalToPhysicalPos(FStartPoint);
|
||||
ClientXY := FSynEdit.RowColumnToPixels(ScreenTextXY);
|
||||
DrawWidth := FSynEdit.ClientWidth; //Maximum width it can have..
|
||||
@ -797,8 +816,10 @@ end;
|
||||
|
||||
procedure TParamHint.ParamHintHide(Sender: TObject);
|
||||
begin
|
||||
if FMP <> nil then
|
||||
freeandnil(Fmp);
|
||||
if Fmp <> nil then
|
||||
FreeAndNil(Fmp);
|
||||
FDecl := nil;
|
||||
FSynEdit := nil;
|
||||
end;
|
||||
|
||||
procedure TParamHint.DrawHints(var MaxWidth, MaxHeight: Integer;
|
||||
@ -853,7 +874,7 @@ var
|
||||
continue;
|
||||
end;
|
||||
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
|
||||
while ((Pos < length(line)) and (Line[Pos + 1] in ['a'..'z', 'A'..'Z', '0'..'9', '_'])) do
|
||||
inc(pos);
|
||||
@ -958,14 +979,19 @@ procedure TParamHint.Show(StartPoint,BracketPoint: TPoint;Decl : TciProcedureDec
|
||||
begin
|
||||
if self.Visible then
|
||||
self.hide;
|
||||
FDecl := Decl;
|
||||
|
||||
Fmp := mp;
|
||||
FParameters:= Decl.GetParamDeclarations;
|
||||
if Length(FParameters) = 0 then //Method has no Parameters
|
||||
exit;
|
||||
begin
|
||||
FreeAndNil(Fmp);
|
||||
Exit;
|
||||
end;
|
||||
FDecl := Decl;
|
||||
FSynEdit := Editor;
|
||||
FStartPoint:= StartPoint;
|
||||
FBracketPoint:= BracketPoint;
|
||||
|
||||
CalculateBounds; //Calculate the size we need!
|
||||
self.Visible := true;
|
||||
end;
|
||||
|
@ -153,7 +153,6 @@ begin
|
||||
end
|
||||
else if DefineMatch then
|
||||
begin
|
||||
|
||||
//if (IncludeBuffer[i].LastChanged = lc) then
|
||||
begin
|
||||
ci.Lexer.LoadDefines(IncludeBuffer[i].DefinesOut);
|
||||
@ -182,13 +181,16 @@ begin
|
||||
//Lexer.CloneDefinesFrom(ci.Lexer);
|
||||
|
||||
if (ci.Lexer.Defines.IndexOf('IS_INCLUDE') < 0) then
|
||||
i := ci.Lexer.Defines.Add('IS_INCLUDE')
|
||||
i := ci.Lexer.Defines.Add('IS_INCLUDE');
|
||||
else
|
||||
i := -1;
|
||||
Run;
|
||||
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
|
||||
ci.Lexer.CloneDefinesFrom(Lexer);
|
||||
end;
|
||||
@ -475,7 +477,7 @@ begin
|
||||
c[3] := nil;
|
||||
end;
|
||||
else
|
||||
Continue;
|
||||
Break;
|
||||
end;
|
||||
if (i = High(InFunc) + 1) then
|
||||
a := fItems.GetItemsOfClass(c[1])
|
||||
@ -664,7 +666,7 @@ begin
|
||||
Dec(StartPos);
|
||||
while (StartPos > 0) and (s[StartPos] in [#10, #11, #13, #32]) do
|
||||
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
|
||||
StartPos := i - BracketCount - BraceCount;
|
||||
Break;
|
||||
|
@ -112,8 +112,7 @@ type
|
||||
private
|
||||
fProcType: string;
|
||||
fParams: string;
|
||||
fSynParams: string;
|
||||
fName : TciProcedureName;
|
||||
fName: TciProcedureName;
|
||||
fCleanDecl : string;
|
||||
|
||||
function GetCleanDeclaration: string;
|
||||
@ -356,7 +355,7 @@ function TDeclarationList.GetItemsOfClass(AClass: TDeclarationClass; SubSearch:
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
if (Item is AClass) then
|
||||
if ((Item = nil) and (AClass = nil)) or (Item is AClass) then
|
||||
begin
|
||||
SetLength(Res, ResIndex + 1);
|
||||
Res[ResIndex] := Item;
|
||||
@ -384,7 +383,7 @@ function TDeclarationList.GetFirstItemOfClass(AClass: TDeclarationClass; SubSear
|
||||
i: Integer;
|
||||
begin
|
||||
Result := False;
|
||||
if (Item is AClass) then
|
||||
if ((Item = nil) and (AClass = nil)) or (Item is AClass) then
|
||||
begin
|
||||
Res := Item;
|
||||
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;
|
||||
begin
|
||||
if (Item.Owner is AClass) then
|
||||
if ((AClass = nil) and (Item.Owner = nil)) or (Item.Owner is AClass) then
|
||||
begin
|
||||
Result := True;
|
||||
Decl := Item.Owner;
|
||||
@ -576,7 +575,7 @@ function TDeclaration.GetOwnersOfClass(AClass: TDeclarationClass): TDeclarationA
|
||||
var Res: TDeclarationArray;
|
||||
var ResIndex: Integer);
|
||||
begin
|
||||
if (Item.Owner is AClass) then
|
||||
if ((AClass = nil) and (Item.Owner = nil)) or (Item.Owner is AClass) then
|
||||
begin
|
||||
SetLength(Res, ResIndex + 1);
|
||||
Res[ResIndex] := Item.Owner;
|
||||
@ -597,6 +596,8 @@ end;
|
||||
|
||||
constructor TDeclaration.Create(AParser: TmwSimplePasPar; AOwner: TDeclaration; AOrigin: PAnsiChar; AStart, AEnd: Integer);
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
fParser := AParser;
|
||||
fOwner := AOwner;
|
||||
fOrigin := AOrigin;
|
||||
@ -797,7 +798,7 @@ begin
|
||||
if (LowerCase(fProcType) = 'class') then
|
||||
begin
|
||||
Delete(s, 1, 6);
|
||||
fProcType := GetFirstWord(s);
|
||||
fProcType := 'class ' + GetFirstWord(s);
|
||||
end;
|
||||
|
||||
if (fProcType = '') then
|
||||
@ -811,19 +812,13 @@ begin
|
||||
end;
|
||||
|
||||
function TciProcedureDeclaration.GetName: TciProcedureName;
|
||||
var
|
||||
ProcedureName : TciProcedureName;
|
||||
begin
|
||||
if (fName <> nil) then
|
||||
result := fName
|
||||
Result := fName
|
||||
else
|
||||
begin
|
||||
ProcedureName := TciProcedureName(fItems.GetFirstItemOfClass(TciProcedureName));
|
||||
if ProcedureName <> nil then
|
||||
result := ProcedureName
|
||||
else
|
||||
Result := nil;
|
||||
fName := result;
|
||||
fName := TciProcedureName(fItems.GetFirstItemOfClass(TciProcedureName));
|
||||
Result := fName;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -835,11 +830,10 @@ begin
|
||||
result := fCleanDecl
|
||||
else
|
||||
begin
|
||||
result := '';
|
||||
if Name = nil then
|
||||
exit;
|
||||
result := proctype + ' ' + Name.ShortText;
|
||||
if Params <> '' then
|
||||
result := proctype;
|
||||
if (Name <> nil) then
|
||||
result := result + ' ' + Name.ShortText;
|
||||
if (Params <> '') then
|
||||
result := result + '(' + params + ')';
|
||||
Return := fItems.GetFirstItemOfClass(TciReturnType) as TciReturnType;
|
||||
if (Return <> nil) then
|
||||
@ -849,7 +843,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
function TciProcedureDeclaration.GetParams: string;
|
||||
var
|
||||
i: Integer;
|
||||
|
Loading…
Reference in New Issue
Block a user