1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-22 01:02:17 -05:00

Made sure you can't open files that don't exist in function list (for libraries), also added IS_INCLUDE to the parser.

This commit is contained in:
Niels 2010-05-18 15:01:08 +02:00
parent 9eef7669c6
commit 7c49e4b9f7
3 changed files with 39 additions and 31 deletions

View File

@ -94,15 +94,14 @@ begin
FillThread := nil; FillThread := nil;
end; end;
procedure TFunctionListFrame.FrameEndDock(Sender, Target: TObject; X, Y: Integer procedure TFunctionListFrame.FrameEndDock(Sender, Target: TObject; X, Y: Integer);
);
begin begin
if Target is TPanel then if (Target is TPanel) then
begin begin
SimbaForm.SplitterFunctionList.Visible := true; SimbaForm.SplitterFunctionList.Visible := true;
CloseButton.Visible:= true; CloseButton.Visible:= true;
end end
else if Target is TCustomDockForm then else if (Target is TCustomDockForm) then
begin begin
TCustomDockForm(Target).Caption := 'Functionlist'; TCustomDockForm(Target).Caption := 'Functionlist';
TCustomDockForm(Target).OnClose := @DockFormOnClose; TCustomDockForm(Target).OnClose := @DockFormOnClose;
@ -120,9 +119,8 @@ begin
Node := FilterTree.Selected Node := FilterTree.Selected
else else
node := FunctionList.Selected; node := FunctionList.Selected;
if node<> nil then
if node.Level > 0 then if (node<> nil) and (node.Level > 0) and (node.Data <> nil) then
if node.Data <> nil then
if InCodeCompletion then if InCodeCompletion then
begin begin
SimbaForm.CurrScript.SynEdit.InsertTextAtCaret( GetMethodName(PMethodInfo(node.Data)^.MethodStr,true)); SimbaForm.CurrScript.SynEdit.InsertTextAtCaret( GetMethodName(PMethodInfo(node.Data)^.MethodStr,true));
@ -131,15 +129,11 @@ begin
else else
begin begin
MethodInfo := PMethodInfo(node.Data)^; MethodInfo := PMethodInfo(node.Data)^;
if DraggingNode = node then if (DraggingNode = node) and (MethodInfo.BeginPos > 0) then
if (MethodInfo.BeginPos > 0) then if (MethodInfo.Filename <> nil) and ((MethodInfo.Filename = '') xor FileExistsUTF8(MethodInfo.Filename)) then
begin; begin
if MethodInfo.Filename <> nil then if (MethodInfo.Filename <> '') then
if MethodInfo.Filename <> '' then
begin;
// Writeln(MethodInfo.filename);
SimbaForm.LoadScriptFile(MethodInfo.Filename,true,true); SimbaForm.LoadScriptFile(MethodInfo.Filename,true,true);
end;
SimbaForm.CurrScript.SynEdit.SelStart := MethodInfo.BeginPos + 1; SimbaForm.CurrScript.SynEdit.SelStart := MethodInfo.BeginPos + 1;
SimbaForm.CurrScript.SynEdit.SelEnd := MethodInfo.EndPos + 1; SimbaForm.CurrScript.SynEdit.SelEnd := MethodInfo.EndPos + 1;
end; end;

View File

@ -653,8 +653,12 @@ function TPSThread.RequireFile(Sender: TObject;
const OriginFileName: String; var FileName, OutPut: string): Boolean; const OriginFileName: String; var FileName, OutPut: string): Boolean;
begin begin
Result := LoadFile(OriginFileName,FileName,OutPut); Result := LoadFile(OriginFileName,FileName,OutPut);
if Result then if Result then
Output := '{$DEFINE IS_INCLUDE}'+LineEnding+Output+LineEnding+'{$UNDEF IS_INCLUDE}'; Output :=
'{$IFNDEF IS_INCLUDE}{$DEFINE IS_INCLUDE}{$DEFINE __REMOVE_IS_INCLUDE}{$ENDIF}' + LineEnding +
Output + LineEnding +
'{$IFDEF __REMOVE_IS_INCLUDE}{$UNDEF IS_INCLUDE}{$ENDIF}';
end; end;
procedure SIRegister_Mufasa(cl: TPSPascalCompiler); procedure SIRegister_Mufasa(cl: TPSPascalCompiler);

View File

@ -180,7 +180,15 @@ begin
begin begin
Assign(ci); Assign(ci);
//Lexer.CloneDefinesFrom(ci.Lexer); //Lexer.CloneDefinesFrom(ci.Lexer);
if (ci.Lexer.Defines.IndexOf('IS_INCLUDE') < 0) then
i := ci.Lexer.Defines.Add('IS_INCLUDE')
else
i := -1;
Run; Run;
if (i > -1) then
ci.Lexer.Defines.Delete(i);
//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;
@ -274,7 +282,7 @@ end;
procedure TCodeInsight.OnInclude(Sender: TmwBasePasLex); procedure TCodeInsight.OnInclude(Sender: TmwBasePasLex);
var var
Param: string; Param: string;
i: Integer; i, p: Integer;
begin begin
Param := Sender.DirectiveParamOriginal; Param := Sender.DirectiveParamOriginal;
{$IFDEF FPC} {$IFDEF FPC}
@ -284,14 +292,16 @@ begin
{$ENDIF} {$ENDIF}
if (not Sender.IsJunk) and (Param <> '') then if (not Sender.IsJunk) and (Param <> '') then
begin begin
if (Pos('loaddll', LowerCase(Sender.Token)) <= 3) then p := Pos('loaddll', LowerCase(Sender.Token));
if (p > 0) and (p <= 3) then
begin begin
if LoadLibrary(Param) then if LoadLibrary(Param) then
Param := ''; Param := '';
end end
else if FindInclude(Param) then else if FindInclude(Param) then
begin begin
if (Pos('include_once', LowerCase(Sender.Token)) <= 3) then p := Pos('include_once', LowerCase(Sender.Token));
if (p > 0) and (p <= 3) then
for i := High(fIncludes) downto 0 do for i := High(fIncludes) downto 0 do
if (fIncludes[i].FileName = Param) then if (fIncludes[i].FileName = Param) then
begin begin