1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-12-23 15:58:51 -05:00

Added Save as Default

This commit is contained in:
Niels 2010-05-19 14:56:10 +02:00
parent f31af1d628
commit 7f874b710b
3 changed files with 42 additions and 7 deletions

View File

@ -92,7 +92,7 @@ type
implementation implementation
uses uses
SimbaUnit, SynEditTypes, LCLIntF, StrUtils,framefunctionlist; SimbaUnit, MufasaTypes, SynEditTypes, LCLIntF, StrUtils,framefunctionlist;
function WordAtCaret(e: TSynEdit; var sp, ep: Integer; Start: Integer = -1; Offset: Integer = 0): string; function WordAtCaret(e: TSynEdit; var sp, ep: Integer; Start: Integer = -1; Offset: Integer = 0): string;
var var
@ -585,6 +585,9 @@ begin
inherited Create(TheOwner); inherited Create(TheOwner);
OwnerSheet := TTabSheet(TheOwner); OwnerSheet := TTabSheet(TheOwner);
OwnerPage := TPageControl(OwnerSheet.Owner); OwnerPage := TPageControl(OwnerSheet.Owner);
if FileExists(MainDir + DS + 'default.simba') then
SynEdit.Lines.LoadFromFile(MainDir + DS + 'default.simba');
StartText:= SynEdit.Lines.text; StartText:= SynEdit.Lines.text;
ScriptDefault:= StartText; ScriptDefault:= StartText;
ScriptName:= 'Untitled'; ScriptName:= 'Untitled';

View File

@ -592,6 +592,10 @@ object SimbaForm: TSimbaForm
Caption = 'Save as...' Caption = 'Save as...'
OnClick = ActionSaveAsExecute OnClick = ActionSaveAsExecute
end end
object MenuItemSaveDef: TMenuItem
Action = ActionSaveDef
OnClick = ActionSaveDefExecute
end
object MenuItemSaveAll: TMenuItem object MenuItemSaveAll: TMenuItem
Action = ActionSaveAll Action = ActionSaveAll
Enabled = False Enabled = False
@ -2693,6 +2697,16 @@ object SimbaForm: TSimbaForm
Caption = 'Save as..' Caption = 'Save as..'
OnExecute = ActionSaveAsExecute OnExecute = ActionSaveAsExecute
end end
object ActionSaveDef: TAction
Caption = 'Save as Default'
OnExecute = ActionSaveDefExecute
end
object ActionSaveAll: TAction
Caption = 'Save All'
ImageIndex = 21
OnExecute = ActionSaveAllExecute
ShortCut = 24659
end
object ActionRunScript: TAction object ActionRunScript: TAction
Caption = '&Run' Caption = '&Run'
OnExecute = ActionRunExecute OnExecute = ActionRunExecute
@ -2707,12 +2721,6 @@ object SimbaForm: TSimbaForm
OnExecute = ActionStopExecute OnExecute = ActionStopExecute
ShortCut = 113 ShortCut = 113
end end
object ActionSaveAll: TAction
Caption = 'Save All'
ImageIndex = 21
OnExecute = ActionSaveAllExecute
ShortCut = 24659
end
object ActionClearDebug: TAction object ActionClearDebug: TAction
Caption = 'Clear' Caption = 'Clear'
ImageIndex = 4 ImageIndex = 4

View File

@ -67,6 +67,7 @@ type
{ TSimbaForm } { TSimbaForm }
TSimbaForm = class(TForm) TSimbaForm = class(TForm)
ActionSaveDef: TAction;
ActionConsole: TAction; ActionConsole: TAction;
ActionNormalSize: TAction; ActionNormalSize: TAction;
ActionCompileScript: TAction; ActionCompileScript: TAction;
@ -104,6 +105,7 @@ type
MenuFile: TMenuItem; MenuFile: TMenuItem;
MenuEdit: TMenuItem; MenuEdit: TMenuItem;
MenuHelp: TMenuItem; MenuHelp: TMenuItem;
MenuItemSaveDef: TMenuItem;
MenuItemBitmapConv: TMenuItem; MenuItemBitmapConv: TMenuItem;
MenuItemExtensions: TMenuItem; MenuItemExtensions: TMenuItem;
MenuItemSettingsButton: TMenuItem; MenuItemSettingsButton: TMenuItem;
@ -240,6 +242,7 @@ type
procedure ActionRunExecute(Sender: TObject); procedure ActionRunExecute(Sender: TObject);
procedure ActionSaveAllExecute(Sender: TObject); procedure ActionSaveAllExecute(Sender: TObject);
procedure ActionSaveAsExecute(Sender: TObject); procedure ActionSaveAsExecute(Sender: TObject);
procedure ActionSaveDefExecute(Sender: TObject);
procedure ActionSaveExecute(Sender: TObject); procedure ActionSaveExecute(Sender: TObject);
procedure ActionSelectAllExecute(Sender: TObject); procedure ActionSelectAllExecute(Sender: TObject);
procedure ActionStopExecute(Sender: TObject); procedure ActionStopExecute(Sender: TObject);
@ -400,6 +403,7 @@ type
function LoadScriptFile(filename : string; AlwaysOpenInNewTab : boolean = false; CheckOtherTabs : boolean = true) : boolean; function LoadScriptFile(filename : string; AlwaysOpenInNewTab : boolean = false; CheckOtherTabs : boolean = true) : boolean;
function SaveCurrentScript : boolean; function SaveCurrentScript : boolean;
function SaveCurrentScriptAs : boolean; function SaveCurrentScriptAs : boolean;
function SaveCurrentScriptAsDefault : boolean;
function CanExitOrOpen : boolean; function CanExitOrOpen : boolean;
function ClearScript : boolean; function ClearScript : boolean;
procedure RunScript; procedure RunScript;
@ -1695,6 +1699,11 @@ begin
Self.SaveCurrentScriptAs; Self.SaveCurrentScriptAs;
end; end;
procedure TSimbaForm.ActionSaveDefExecute(Sender: TObject);
begin
Self.SaveCurrentScriptAsDefault;
end;
procedure TSimbaForm.ActionSaveExecute(Sender: TObject); procedure TSimbaForm.ActionSaveExecute(Sender: TObject);
begin begin
Self.SaveCurrentScript; Self.SaveCurrentScript;
@ -2966,6 +2975,21 @@ begin
end; end;
end; end;
function TSimbaForm.SaveCurrentScriptAsDefault : boolean;
begin
with CurrScript do
begin
try
SynEdit.Lines.SaveToFile(MainDir + DS + 'default.simba');
mDebugLn('Script saved as default.');
Result := True;
except
mDebugLn('Cannot save script as default.');
Result := False;
end;
end;
end;
function TSimbaForm.CanExitOrOpen: boolean; function TSimbaForm.CanExitOrOpen: boolean;
begin; begin;
Self.Enabled := False;//We HAVE to answer the popup Self.Enabled := False;//We HAVE to answer the popup