1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-04 16:35:15 -05:00

Added a basic OnFindInclude for the codecompletion, it can now parse (the latest) SRL succesfully ;-).

This commit is contained in:
Raymond 2010-03-27 14:10:16 +01:00
parent a0ba655c1d
commit 980e801f50
3 changed files with 44 additions and 24 deletions

View File

@ -326,7 +326,9 @@ type
FirstRun : boolean;//Only show the warnings the first run (path not existing one's) FirstRun : boolean;//Only show the warnings the first run (path not existing one's)
SearchStart : TPoint; SearchStart : TPoint;
LastTab : integer; LastTab : integer;
function GetIncludePath: String;
function GetScriptState: TScriptState; function GetScriptState: TScriptState;
procedure SetIncludePath(const AValue: String);
procedure SetScriptState(const State: TScriptState); procedure SetScriptState(const State: TScriptState);
function LoadSettingDef(Key : string; Def : string) : string; function LoadSettingDef(Key : string; Def : string) : string;
function CreateSetting(Key : string; Value : string) : string; function CreateSetting(Key : string; Value : string) : string;
@ -374,6 +376,7 @@ type
procedure InitalizeTMThread(var Thread : TMThread); procedure InitalizeTMThread(var Thread : TMThread);
procedure HandleParameters; procedure HandleParameters;
procedure OnSaveScript(const Filename : string); procedure OnSaveScript(const Filename : string);
property IncludePath : String read GetIncludePath write SetIncludePath;
end; end;
procedure ClearDebug; procedure ClearDebug;
@ -406,6 +409,7 @@ uses
lclintf, lclintf,
syncobjs, // for the critical sections syncobjs, // for the critical sections
debugimage, debugimage,
files,
extensionmanagergui, extensionmanagergui,
colourhistory, colourhistory,
math; math;
@ -464,8 +468,16 @@ begin
end; end;
function TForm1.OnCCFindInclude(Sender: TObject; var FileName: string): Boolean; function TForm1.OnCCFindInclude(Sender: TObject; var FileName: string): Boolean;
var
Temp : string;
begin begin
Result := False; Temp := FindFile(filename,[MainDir+DS,IncludePath]);
if temp <> '' then
begin;
filename := temp;
result := true;
end else
result := false;
end; end;
procedure TForm1.ProcessDebugStream(Sender: TObject); procedure TForm1.ProcessDebugStream(Sender: TObject);
@ -945,7 +957,7 @@ end;
procedure TForm1.CreateDefaultEnvironment; procedure TForm1.CreateDefaultEnvironment;
var var
IncludePath,FontPath,PluginsPath,extensionsPath : string; FontPath,PluginsPath,extensionsPath : string;
begin begin
CreateSetting('Settings/Updater/CheckForUpdates','True'); CreateSetting('Settings/Updater/CheckForUpdates','True');
CreateSetting('Settings/Updater/CheckEveryXMinutes','30'); CreateSetting('Settings/Updater/CheckEveryXMinutes','30');
@ -989,7 +1001,6 @@ begin
{$ENDIF} {$ENDIF}
); );
{Creates the paths and returns the path} {Creates the paths and returns the path}
includePath:= CreateSetting('Settings/Includes/Path', ExpandFileName(MainDir+DS+'Includes' + DS));
fontPath := CreateSetting('Settings/Fonts/Path', ExpandFileName(MainDir+DS+ 'Fonts' + DS)); fontPath := CreateSetting('Settings/Fonts/Path', ExpandFileName(MainDir+DS+ 'Fonts' + DS));
PluginsPath := CreateSetting('Settings/Plugins/Path', ExpandFileName(MainDir+ DS+ 'Plugins' + DS)); PluginsPath := CreateSetting('Settings/Plugins/Path', ExpandFileName(MainDir+ DS+ 'Plugins' + DS));
extensionsPath := CreateSetting('Settings/Extensions/Path',ExpandFileName(MainDir +DS + 'Extensions' + DS)); extensionsPath := CreateSetting('Settings/Extensions/Path',ExpandFileName(MainDir +DS + 'Extensions' + DS));
@ -1147,7 +1158,6 @@ procedure TForm1.InitalizeTMThread(var Thread: TMThread);
var var
DbgImgInfo : TDbgImgInfo; DbgImgInfo : TDbgImgInfo;
fontPath: String; fontPath: String;
includePath : string;
AppPath : string; AppPath : string;
pluginspath: string; pluginspath: string;
ScriptPath : string; ScriptPath : string;
@ -1156,7 +1166,6 @@ var
loadFontsOnScriptStart: boolean; loadFontsOnScriptStart: boolean;
begin begin
AppPath:= MainDir + DS; AppPath:= MainDir + DS;
includePath:= IncludeTrailingPathDelimiter(LoadSettingDef('Settings/Includes/Path', ExpandFileName(MainDir+DS+'Includes' + DS)));
fontPath := IncludeTrailingPathDelimiter(LoadSettingDef('Settings/Fonts/Path', ExpandFileName(MainDir+DS+ 'Fonts' + DS))); fontPath := IncludeTrailingPathDelimiter(LoadSettingDef('Settings/Fonts/Path', ExpandFileName(MainDir+DS+ 'Fonts' + DS)));
PluginsPath := IncludeTrailingPathDelimiter(LoadSettingDef('Settings/Plugins/Path', ExpandFileName(MainDir+ DS+ 'Plugins' + DS))); PluginsPath := IncludeTrailingPathDelimiter(LoadSettingDef('Settings/Plugins/Path', ExpandFileName(MainDir+ DS+ 'Plugins' + DS)));
CurrScript.ScriptErrorLine:= -1; CurrScript.ScriptErrorLine:= -1;
@ -1757,7 +1766,6 @@ procedure TForm1.FormCreate(Sender: TObject);
a.OnCompImport := OnCompImport; a.OnCompImport := OnCompImport;
a.OnExecImport := OnExecImport; a.OnExecImport := OnExecImport;
end; end;
a.GetValueDefs(b); a.GetValueDefs(b);
SetLength(CoreBuffer, 1); SetLength(CoreBuffer, 1);
@ -2239,6 +2247,16 @@ begin
result := CurrScript.FScriptState; result := CurrScript.FScriptState;
end; end;
function TForm1.GetIncludePath: String;
begin
Result := IncludeTrailingPathDelimiter(LoadSettingDef('Settings/Includes/Path', ExpandFileName(MainDir+DS+'Includes' + DS)));
end;
procedure TForm1.SetIncludePath(const AValue: String);
begin
CreateSetting('Settings/Includes/Path',AValue);
end;
procedure TForm1.SetScriptState(const State: TScriptState); procedure TForm1.SetScriptState(const State: TScriptState);
begin begin
CurrScript.FScriptState:= State; CurrScript.FScriptState:= State;

View File

@ -192,6 +192,7 @@ uses
stringutil, //String st00f stringutil, //String st00f
uPSR_std, uPSR_controls,uPSR_classes,uPSR_graphics,uPSR_stdctrls,uPSR_forms, uPSR_std, uPSR_controls,uPSR_classes,uPSR_graphics,uPSR_stdctrls,uPSR_forms,
uPSR_menus, uPSR_menus,
files,
uPSR_extctrls, //Runtime-libs uPSR_extctrls, //Runtime-libs
Graphics, //For Graphics types Graphics, //For Graphics types
math, //Maths! math, //Maths!
@ -325,24 +326,6 @@ procedure TMThread.AddMethod(meth: TExpMethod);
begin begin
end; end;
function FindFile(filename : string; Dirs : array of string) : string; //Results '' if not found
var
i : integer;
begin;
if fileexists(filename) then
result := filename
else
begin
for i := 0 to high(Dirs) do
if DirectoryExists(dirs[i]) then
if fileexists(dirs[i] + filename) then
begin
result := dirs[i] + filename;
exit;
end;
end;
end;
function TMThread.LoadFile(ParentFile : string; var filename, contents: string): boolean; function TMThread.LoadFile(ParentFile : string; var filename, contents: string): boolean;
var var
path: string; path: string;

View File

@ -66,6 +66,7 @@ type
// We don't need one per object. :-) // We don't need one per object. :-)
function GetFiles(Path, Ext: string): TStringArray; function GetFiles(Path, Ext: string): TStringArray;
function GetDirectories(Path: string): TstringArray; function GetDirectories(Path: string): TstringArray;
function FindFile(filename : string; Dirs : array of string) : string; //Results '' if not found
implementation implementation
uses uses
@ -109,6 +110,24 @@ begin
end; end;
end; end;
function FindFile(filename : string; Dirs : array of string) : string; //Results '' if not found
var
i : integer;
begin;
if fileexists(filename) then
result := filename
else
begin
for i := 0 to high(Dirs) do
if DirectoryExists(dirs[i]) then
if fileexists(dirs[i] + filename) then
begin
result := dirs[i] + filename;
exit;
end;
end;
end;
constructor TMFiles.Create(Owner : TObject); constructor TMFiles.Create(Owner : TObject);
begin begin
inherited Create; inherited Create;