1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-28 03:52:23 -05:00

Merge branch 'RunScript' of https://github.com/Dgby714/Simba into Dgby714-RunScript

This commit is contained in:
Merlijn Wajer 2011-01-03 18:35:45 +01:00
commit d39c056108
4 changed files with 17 additions and 10 deletions

View File

@ -244,7 +244,7 @@ var
s: TStringList; s: TStringList;
begin begin
a := TMenuItem(Sender).Hint; a := TMenuItem(Sender).Hint;
Delete(a, Length(a) - Length('.'+Extension) + 1, Length('.'+Extension)); Delete(a, Length(a) - Length('.' + Extension) + 1, Length('.' + Extension));
SplitRecoverInfo(a, a, b, c); SplitRecoverInfo(a, a, b, c);
if (not ForceSave) then if (not ForceSave) then
@ -252,7 +252,7 @@ begin
s := TStringList.Create; s := TStringList.Create;
try try
s.LoadFromFile(TMenuItem(Sender).Hint); s.LoadFromFile(TMenuItem(Sender).Hint);
OpenScript(a, s.Text); OpenScript(a, s.Text, False);
finally finally
s.Free; s.Free;
end; end;

View File

@ -92,7 +92,7 @@ begin
end; end;
WriteLn('Opening Paste #' + GetJSONValue(Data, 'paste_id') + ' in a new tab!'); WriteLn('Opening Paste #' + GetJSONValue(Data, 'paste_id') + ' in a new tab!');
OpenScript('Paste #' + GetJSONValue(Data, 'paste_id'), GetJSONValue(Data, 'code')); OpenScript('Paste #' + GetJSONValue(Data, 'paste_id'), GetJSONValue(Data, 'code'), False);
Result := True; Result := True;
end; end;
end; end;

View File

@ -192,8 +192,8 @@ begin
AddFunction(@ext_MessageDlg,'function MessageDlg(const aCaption, aMsg: string; DlgType: TMsgDlgType;Buttons: TMsgDlgButtons; HelpCtx: Longint): Integer;'); AddFunction(@ext_MessageDlg,'function MessageDlg(const aCaption, aMsg: string; DlgType: TMsgDlgType;Buttons: TMsgDlgButtons; HelpCtx: Longint): Integer;');
AddFunction(@ext_InputQuery,'function InputQuery(const ACaption, APrompt : String; var Value : String) : Boolean;'); AddFunction(@ext_InputQuery,'function InputQuery(const ACaption, APrompt : String; var Value : String) : Boolean;');
AddFunction(@ext_ScriptText,'function ScriptText: string;'); AddFunction(@ext_ScriptText,'function ScriptText: string;');
AddFunction(@ext_OpenScript,'procedure OpenScript(Name, Data: string);'); AddFunction(@ext_OpenScript,'procedure OpenScript(Name, Data: string; Run: boolean);');
AddFunction(@ext_OpenScriptEx,'procedure OpenScriptEx(FileName: string);'); AddFunction(@ext_OpenScriptEx,'procedure OpenScriptEx(FileName: string; Run: boolean);');
AddRegisteredPTRVariable('Settings','TMMLSettingsSandbox'); AddRegisteredPTRVariable('Settings','TMMLSettingsSandbox');
AddFunction(@ext_GetPageEx,'function GetPageEx(const URL, PostData, MimeType: string): string;'); AddFunction(@ext_GetPageEx,'function GetPageEx(const URL, PostData, MimeType: string): string;');
AddFunction(@ext_GetJSONValue,'function GetJSONValue(const Data, Value: string): string;'); AddFunction(@ext_GetJSONValue,'function GetJSONValue(const Data, Value: string): string;');

View File

@ -129,10 +129,10 @@ begin
Result := ReplaceRegExpr('([N|n][A|a][M|m][E|e]|[P|p][A|a][S|s]{2}|[P|p][I|i][N|n])\s*\:\=\s*\''.*?\'';', Result, '$1 := ''*********'';', True); Result := ReplaceRegExpr('([N|n][A|a][M|m][E|e]|[P|p][A|a][S|s]{2}|[P|p][I|i][N|n])\s*\:\=\s*\''.*?\'';', Result, '$1 := ''*********'';', True);
end; end;
procedure ext_OpenScript(Name, Data: string); procedure ext_OpenScript(vName, Data: string; Run: boolean);
begin begin
if (Name = '') then if (vName = '') then
Name := 'Untitled'; vName := 'Untitled';
with SimbaForm do with SimbaForm do
begin begin
@ -140,14 +140,18 @@ begin
with CurrScript do with CurrScript do
begin begin
SynEdit.Lines.Text := Data; SynEdit.Lines.Text := Data;
ScriptName := Name; ScriptName := vName;
ScriptChanged := True;
end; end;
RefreshTab(); RefreshTab();
UpdateTitle(); UpdateTitle();
end; end;
if (Run) then
SimbaForm.RunScript();
end; end;
procedure ext_OpenScriptEx(FileName: string); procedure ext_OpenScriptEx(FileName: string; Run: boolean);
begin begin
FileName := SetDirSeparators(FileName); FileName := SetDirSeparators(FileName);
with SimbaForm do with SimbaForm do
@ -164,6 +168,9 @@ begin
RefreshTab(); RefreshTab();
UpdateTitle(); UpdateTitle();
end; end;
if (Run) then
SimbaForm.RunScript();
end; end;
function ext_GetPageEx(const URL, PostData, MimeType: string): string; function ext_GetPageEx(const URL, PostData, MimeType: string): string;