1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-21 16:55:01 -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;
end;
procedure TFunctionListFrame.FrameEndDock(Sender, Target: TObject; X, Y: Integer
);
procedure TFunctionListFrame.FrameEndDock(Sender, Target: TObject; X, Y: Integer);
begin
if Target is TPanel then
if (Target is TPanel) then
begin
SimbaForm.SplitterFunctionList.Visible := true;
CloseButton.Visible:= true;
end
else if Target is TCustomDockForm then
else if (Target is TCustomDockForm) then
begin
TCustomDockForm(Target).Caption := 'Functionlist';
TCustomDockForm(Target).OnClose := @DockFormOnClose;
@ -120,30 +119,25 @@ begin
Node := FilterTree.Selected
else
node := FunctionList.Selected;
if node<> nil then
if node.Level > 0 then
if node.Data <> nil then
if InCodeCompletion then
if (node<> nil) and (node.Level > 0) and (node.Data <> nil) then
if InCodeCompletion then
begin
SimbaForm.CurrScript.SynEdit.InsertTextAtCaret( GetMethodName(PMethodInfo(node.Data)^.MethodStr,true));
SimbaForm.RefreshTab;
end
else
begin
MethodInfo := PMethodInfo(node.Data)^;
if (DraggingNode = node) and (MethodInfo.BeginPos > 0) then
if (MethodInfo.Filename <> nil) and ((MethodInfo.Filename = '') xor FileExistsUTF8(MethodInfo.Filename)) then
begin
SimbaForm.CurrScript.SynEdit.InsertTextAtCaret( GetMethodName(PMethodInfo(node.Data)^.MethodStr,true));
SimbaForm.RefreshTab;
end
else
begin
MethodInfo := PMethodInfo(node.Data)^;
if DraggingNode = node then
if (MethodInfo.BeginPos > 0) then
begin;
if MethodInfo.Filename <> nil then
if MethodInfo.Filename <> '' then
begin;
// Writeln(MethodInfo.filename);
SimbaForm.LoadScriptFile(MethodInfo.Filename,true,true);
end;
SimbaForm.CurrScript.SynEdit.SelStart := MethodInfo.BeginPos + 1;
SimbaForm.CurrScript.SynEdit.SelEnd := MethodInfo.EndPos + 1;
end;
if (MethodInfo.Filename <> '') then
SimbaForm.LoadScriptFile(MethodInfo.Filename,true,true);
SimbaForm.CurrScript.SynEdit.SelStart := MethodInfo.BeginPos + 1;
SimbaForm.CurrScript.SynEdit.SelEnd := MethodInfo.EndPos + 1;
end;
end;
end;
procedure TFunctionListFrame.FunctionListDeletion(Sender: TObject;

View File

@ -652,9 +652,13 @@ end;
function TPSThread.RequireFile(Sender: TObject;
const OriginFileName: String; var FileName, OutPut: string): Boolean;
begin
Result:= LoadFile(OriginFileName,FileName,OutPut);
Result := LoadFile(OriginFileName,FileName,OutPut);
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;
procedure SIRegister_Mufasa(cl: TPSPascalCompiler);

View File

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