1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-24 18:22:25 -05:00

Simba: USE_EXTENSTIONS Define.

This commit is contained in:
John P (Dgby714) 2011-06-30 05:37:15 -04:00 committed by Merlijn Wajer
parent 1d447bb668
commit 1f21fb2769
4 changed files with 86 additions and 43 deletions

View File

@ -30,7 +30,7 @@
//{$DEFINE USE_CPASCAL} // TODO
//{$DEFINE USE_LAPE} // TODO
//{$DEFINE USE_EXTENSIONS} // TODO
//{$DEFINE USE_EXTENSIONS}
//{$DEFINE USE_CODECOMPLETION} // TODO
//{$DEFINE TERMINALWRITELN} // Only used once. Remove from SimbaUnit?

View File

@ -265,7 +265,7 @@ begin
begin
{$I ../../Units/MMLAddon/PSInc/pscompile.inc}
AddTypes('TStringArray','Array of String');
AddConstantN('ExtPath','string').SetString(ExtPath);
AddConstantN('ExtPath', 'string').SetString({$IFDEF USE_EXTENSIONS}ExtPath{$ELSE}''{$ENDIF});
for i := 0 to high(VirtualKeys) do
AddConstantN(Format('VK_%S',[VirtualKeys[i].Str]),'Byte').SetInt(VirtualKeys[i].Key);
end;

View File

@ -5,7 +5,7 @@ object SimbaForm: TSimbaForm
Width = 660
AllowDropFiles = True
Caption = 'THA FUKING Simba'
ClientHeight = 598
ClientHeight = 603
ClientWidth = 660
KeyPreview = True
Menu = MainMenu
@ -207,8 +207,8 @@ object SimbaForm: TSimbaForm
end
object StatusBar: TStatusBar
Left = 0
Height = 21
Top = 577
Height = 23
Top = 580
Width = 660
Panels = <
item
@ -230,7 +230,7 @@ object SimbaForm: TSimbaForm
object PanelMemo: TPanel
Left = 0
Height = 154
Top = 423
Top = 426
Width = 660
Align = alBottom
ClientHeight = 154
@ -253,19 +253,19 @@ object SimbaForm: TSimbaForm
Cursor = crVSplit
Left = 0
Height = 5
Top = 418
Top = 421
Width = 660
Align = alBottom
ResizeAnchor = akBottom
end
object ScriptPanel: TPanel
Left = 0
Height = 394
Height = 397
Top = 24
Width = 660
Align = alClient
BevelOuter = bvNone
ClientHeight = 394
ClientHeight = 397
ClientWidth = 660
DockSite = True
TabOrder = 4
@ -273,7 +273,7 @@ object SimbaForm: TSimbaForm
OnDockOver = ScriptPanelDockOver
object PageControl1: TPageControl
Left = 155
Height = 359
Height = 362
Top = 0
Width = 505
Align = alClient
@ -292,7 +292,7 @@ object SimbaForm: TSimbaForm
object SearchPanel: TPanel
Left = 0
Height = 35
Top = 359
Top = 362
Width = 660
Align = alBottom
BevelOuter = bvSpace
@ -387,7 +387,7 @@ object SimbaForm: TSimbaForm
end
object LabeledEditSearch: TLabeledEdit
Left = 104
Height = 27
Height = 23
Top = 6
Width = 80
EditLabel.AnchorSideLeft.Control = LabeledEditSearch
@ -395,10 +395,10 @@ object SimbaForm: TSimbaForm
EditLabel.AnchorSideTop.Side = asrCenter
EditLabel.AnchorSideRight.Control = LabeledEditSearch
EditLabel.AnchorSideBottom.Control = LabeledEditSearch
EditLabel.Left = 66
EditLabel.Height = 18
EditLabel.Top = 10
EditLabel.Width = 35
EditLabel.Left = 71
EditLabel.Height = 16
EditLabel.Top = 9
EditLabel.Width = 30
EditLabel.Caption = 'Find: '
EditLabel.ParentColor = False
LabelPosition = lpLeft
@ -413,7 +413,7 @@ object SimbaForm: TSimbaForm
Left = 320
Height = 19
Top = 7
Width = 93
Width = 80
Caption = 'Match case'
OnClick = CheckBoxMatchCaseClick
TabOrder = 1
@ -421,38 +421,38 @@ object SimbaForm: TSimbaForm
end
object SplitterFunctionList: TSplitter
Left = 150
Height = 359
Height = 362
Top = 0
Width = 5
OnCanResize = SplitterFunctionListCanResize
Visible = False
end
inline frmFunctionList: TFunctionListFrame
Height = 359
Height = 362
Width = 150
ClientHeight = 359
ClientHeight = 362
ClientWidth = 150
OnEndDock = nil
TabOrder = 3
inherited FunctionList: TTreeView
Height = 310
Top = 22
Height = 319
Top = 20
Width = 150
DefaultItemHeight = 19
DefaultItemHeight = 17
OnChange = FunctionListChange
OnEnter = FunctionListEnter
OnExit = FunctionListExit
end
inherited editSearchList: TEdit
Height = 27
Top = 332
Height = 23
Top = 339
Width = 150
OnExit = editSearchListExit
OnKeyDown = editSearchListKeyDown
OnKeyPress = editSearchListKeyPress
end
inherited FunctionListLabel: TLabel
Height = 18
Height = 16
Width = 146
end
end
@ -3006,6 +3006,7 @@ object SimbaForm: TSimbaForm
Caption = '&Extensions'
OnExecute = ActionExtensionsExecute
OnUpdate = ActionExtensionsUpdate
Visible = False
end
object ActionPascalScript: TAction
Caption = 'PascalScript'

View File

@ -51,8 +51,9 @@ uses
SynExportHTML, SynEditKeyCmds, SynEditHighlighter,
SynEditMarkupHighAll, LMessages, Buttons,
mmisc, stringutil,mufasatypesutil, mufasabase,
about, framefunctionlist, ocr, updateform, Simbasettings, psextension, virtualextension,
extensionmanager, settingssandbox,
about, framefunctionlist, ocr, updateform, Simbasettings,
{$IFDEF USE_EXTENSIONS}psextension, virtualextension, extensionmanager,{$ENDIF}
settingssandbox,
v_ideCodeParser, v_ideCodeInsight, CastaliaPasLexTypes, // Code completion units
CastaliaSimplePasPar, v_AutoCompleteForm, // Code completion units
@ -418,7 +419,7 @@ type
function GetInterpreter: Integer;
function GetDefScriptPath: string;
function GetScriptPath : string;
function GetExtPath: string;
{$IFDEF USE_EXTENSIONS}function GetExtPath: string;{$ENDIF}
function GetFontPath: String;
function GetHighlighter: TSynCustomHighlighter;
function GetIncludePath: String;
@ -428,7 +429,7 @@ type
function GetShowCodeCompletionAuto: Boolean;
function GetSimbaNews: String;
procedure SetDefScriptPath(const AValue: string);
procedure SetExtPath(const AValue: string);
{$IFDEF USE_EXTENSIONS}procedure SetExtPath(const AValue: string);{$ENDIF}
procedure SetFontPath(const AValue: String);
procedure SetIncludePath(const AValue: String);
procedure SetInterpreter(const AValue: Integer);
@ -501,7 +502,7 @@ type
property IncludePath : String read GetIncludePath write SetIncludePath;
property FontPath : String read GetFontPath write SetFontPath;
property PluginPath : string read GetPluginPath write SetPluginPath;
property ExtPath : string read GetExtPath write SetExtPath;
{$IFDEF USE_EXTENSIONS}property ExtPath : string read GetExtPath write SetExtPath;{$ENDIF}
property ScriptDir : string read GetScriptPath write SetScriptPath;
property DefScriptPath : string read GetDefScriptPath write SetDefScriptPath;
property CurrHighlighter : TSynCustomHighlighter read GetHighlighter;
@ -545,7 +546,7 @@ uses
InterfaceBase,
bitmapconv,
bitmaps,
extensionmanagergui,
{$IFDEF USE_EXTENSIONS}extensionmanagergui,{$ENDIF}
colourhistory,
math
@ -744,6 +745,7 @@ begin
end;
procedure TSimbaForm.HandleConnectionData;
{$IFDEF USE_EXTENSIONS}
var
Args : TVariantArray;
begin
@ -758,6 +760,9 @@ begin
on e : Exception do
mDebugLn('ERROR in HandleConnectiondata: ' + e.message);
end;
{$ELSE}
begin
{$ENDIF}
end;
function TSimbaForm.GetInterpreter: Integer;
@ -781,6 +786,7 @@ begin
end;
procedure TSimbaForm.HandleOpenFileData;
{$IFDEF USE_EXTENSIONS}
var
Args : TVariantArray;
begin
@ -795,9 +801,13 @@ begin
on e : Exception do
mDebugLn('ERROR in HandleOpenFileData: ' + e.message);
end;
{$ELSE}
begin
{$ENDIF}
end;
procedure TSimbaForm.HandleWriteFileData;
{$IFDEF USE_EXTENSIONS}
var
Args : TVariantArray;
begin
@ -812,9 +822,13 @@ begin
on e : Exception do
mDebugLn('ERROR in HandleWriteFileData: ' + e.message);
end;
{$ELSE}
begin
{$ENDIF}
end;
procedure TSimbaForm.HandleScriptStartData;
{$IFDEF USE_EXTENSIONS}
var
Args : TVariantArray;
begin
@ -829,6 +843,9 @@ begin
on e : Exception do
mDebugLn('ERROR in HandleScriptStartData: ' + e.message);
end;
{$ELSE}
begin
{$ENDIF}
end;
procedure TSimbaForm.ProcessDebugStream(Sender: TObject);
@ -1361,7 +1378,7 @@ begin
CreateSetting('Settings/CodeHints/ShowAutomatically','True');
CreateSetting('Settings/CodeCompletion/ShowAutomatically','True');
CreateSetting('Settings/SourceEditor/LazColors','True');
CreateSetting('Settings/Extensions/FileExtension','sex');
{$IFDEF USE_EXTENSIONS}CreateSetting('Settings/Extensions/FileExtension','sex');{$ENDIF}
CreateSetting('Settings/Updater/RemoteLink',SimbaURL + 'Simba'{$IFDEF WINDOWS} +'.exe'{$ENDIF});
CreateSetting('Settings/Updater/RemoteVersionLink',SimbaURL + 'Version');
@ -1372,8 +1389,10 @@ begin
{Creates the paths and returns the path}
PluginsPath := CreateSetting('Settings/Plugins/Path', ExpandFileName(MainDir+ DS+ 'Plugins' + DS));
{$IFDEF USE_EXTENSIONS}
extensionsPath := CreateSetting('Settings/Extensions/Path',ExpandFileName(MainDir +DS + 'Extensions' + DS));
CreateSetting('Extensions/ExtensionCount','0');
{$ENDIF}
CreateSetting('LastConfig/MainForm/Position','');
CreateSetting('LastConfig/MainForm/State','Normal');
{$ifdef MSWindows}
@ -1387,10 +1406,12 @@ begin
CreateDir(FontPath);
if not DirectoryExists(PluginsPath) then
CreateDir(PluginsPath);
{$IFDEF USE_EXTENSIONS}
if not DirectoryExists(extensionsPath) then
CreateDir(extensionsPath);
if not DirectoryExists(ExtPath) then
CreateDir(ExtPath);
{$ENDIF}
if not DirectoryExists(ScriptDir) then
CreateDir(ScriptDir);
SettingsForm.SettingsTreeView.Items.GetFirstNode.Expand(false);
@ -1491,19 +1512,21 @@ begin
else
SetSetting('LastConfig/Console/Visible','False');
{$endif}
{$IFDEF USE_EXTENSIONS}
SetSetting('Extensions/ExtensionCount',inttostr(ExtManager.Extensions.Count));
for i := 0 to ExtManager.Extensions.Count-1 do
begin;
path :='Extensions/Extension' + inttostr(I);
SetSetting(Path + '/Path',TVirtualSimbaExtension(ExtManager.Extensions[i]).Filename);
SetSetting(Path + '/Enabled',BoolToStr(TVirtualSimbaExtension(ExtManager.Extensions[i]).Enabled,True));
end;
{$ENDIF}
SaveToXML(SimbaSettingsFile);
end;
end;
procedure TSimbaForm.LoadExtensions;
{$IFDEF USE_EXTENSIONS}
var
extCount : integer;
function LoadExtension(Number : integer) : boolean;
@ -1551,6 +1574,9 @@ begin
str := LoadSettingDef('Settings/Extensions/Path',ExpandFileName(MainDir +DS + 'Extensions' + DS));
str2 := LoadSettingDef('Settings/Extensions/FileExtension','sex');
ExtManager.LoadPSExtensionsDir(str,str2);
{$ELSE}
begin
{$ENDIF}
end;
procedure TSimbaForm.AddRecentFile(const filename: string);
@ -1834,15 +1860,17 @@ end;
procedure TSimbaForm.ActionExtensionsExecute(Sender: TObject);
begin
{$IFDEF USE_EXTENSIONS}
if not ExtensionsForm.Showing then
ExtensionsForm.Show
else
ExtensionsForm.Hide;
{$ENDIF}
end;
procedure TSimbaForm.ActionExtensionsUpdate(Sender: TObject);
begin
TAction(Sender).Checked := ExtensionsForm.Showing;
{$IFDEF USE_EXTENSIONS}TAction(Sender).Checked := ExtensionsForm.Showing;{$ENDIF}
end;
procedure TSimbaForm.ActionFindNextExecute(Sender: TObject);
@ -2312,7 +2340,7 @@ begin
end;
FunctionListTimer.Enabled:= false;
CloseAction := caFree;
FreeAndNil(ExtManager);
{$IFDEF USE_EXTENSIONS}FreeAndNil(ExtManager);{$ENDIF}
end;
procedure CCFillCore;
@ -2414,6 +2442,7 @@ begin
UpdateTimer.OnTimer:= @UpdateTimerCheck;
Application.CreateForm(TSimbaUpdateForm, SimbaUpdateForm);
{$IFDEF USE_EXTENSIONS}Application.CreateForm(TExtensionsForm, ExtensionsForm);{$ENDIF}
if FileExistsUTF8(SimbaSettingsFile) then
begin
@ -2468,13 +2497,15 @@ begin
FillThread.Resume;
//Load the extensions
LoadExtensions;
{$IFDEF USE_EXTENSIONS}LoadExtensions;{$ENDIF}
UpdateTitle;
{$IFNDEF USE_RUTIS}
MenuItemRUTIS.Enabled:=False;
{$ENDIF}
{$IFDEF USE_EXTENSIONS}ActionExtensions.Visible := True;{$ENDIF}
self.EndFormUpdate;
if SettingsForm.Oops then
@ -2492,8 +2523,10 @@ begin
for i := 0 to high(RecentFileItems) do
RecentFileItems[i].Free;
{$IFDEF USE_EXTENSIONS}
if ExtManager <> nil then
FreeAndNil(extmanager);
{$ENDIF}
Tabs.Free;
@ -2803,10 +2836,12 @@ begin
SetSetting('Settings/SourceEditor/DefScriptPath',AValue,True);
end;
{$IFDEF USE_EXTENSIONS}
procedure TSimbaForm.SetExtPath(const AValue: string);
begin
SetSetting('Settings/Extensions/Path',AValue,true);
end;
{$ENDIF}
procedure TSimbaForm.NewsTimerTimer(Sender: TObject);
var
@ -2936,6 +2971,7 @@ end;
procedure TSimbaForm.PickerPick(Sender: TObject; const Colour, colourx,
coloury: integer);
{$IFDEF USE_EXTENSIONS}
var
Args : TVariantArray;
begin
@ -2944,6 +2980,9 @@ begin
Args[1] := Colourx;
Args[2] := Coloury;
ExtManager.HandleHook(EventHooks[SExt_OnColourPick].HookName,Args);
{$ELSE}
begin
{$ENDIF}
end;
procedure TSimbaForm.PopupItemFindClick(Sender: TObject);
@ -2977,10 +3016,12 @@ begin
Result := IncludeTrailingPathDelimiter(LoadSettingDef('Settings/Fonts/Path', ExpandFileName(MainDir+DS+'Fonts' + DS)));
end;
{$IFDEF USE_EXTENSIONS}
function TSimbaForm.GetExtPath: string;
begin
result :=IncludeTrailingPathDelimiter(LoadSettingDef('Settings/Extensions/Path', ExpandFileName(MainDir+DS+'Extensions' + DS)));
Result := IncludeTrailingPathDelimiter(LoadSettingDef('Settings/Extensions/Path', ExpandFileName(MainDir+DS+'Extensions' + DS)));
end;
{$ENDIF}
function TSimbaForm.GetHighlighter: TSynCustomHighlighter;
begin
@ -3299,7 +3340,8 @@ begin
else
InitialDir := ScriptDir;
Options := [ofAllowMultiSelect, ofExtensionDifferent, ofPathMustExist, ofFileMustExist, ofEnableSizing, ofViewDetail];
Filter:= 'Simba Files|*.simba;*.simb;*.cogat;*.mufa;*.txt;*.' +LoadSettingDef('Settings/Extensions/FileExtension','sex')+
Filter:= 'Simba Files|*.simba;*.simb;*.cogat;*.mufa;*.txt' +
{$IFDEF USE_EXTENSIONS}';*.' + LoadSettingDef('Settings/Extensions/FileExtension', 'sex') + {$ENDIF}
'|Any files|*.*';
if Execute then
begin
@ -3406,8 +3448,8 @@ begin
InitialDir := ExtractFileDir(CurrScript.ScriptFile)
else
InitialDir := ScriptDir;
filter := 'Simba Files|*.simba;*.simb;*.cogat;*.mufa;*.txt;*.' +
LoadSettingDef('Settings/Extensions/FileExtension','sex')+
filter := 'Simba Files|*.simba;*.simb;*.cogat;*.mufa;*.txt' +
{$IFDEF USE_EXTENSIONS}';*.' + LoadSettingDef('Settings/Extensions/FileExtension','sex') + {$ENDIF}
'|Any files|*.*';
if Execute then
begin;