mirror of
https://github.com/moparisthebest/Simba
synced 2024-12-24 00:08:52 -05:00
Revert "First code for Simba with only one script thread."
This reverts commit f38da4bc8c
.
This commit is contained in:
parent
65610a3c6e
commit
b1d5943c02
@ -78,12 +78,13 @@ type
|
||||
ScriptName : string;//The name of the currently opened/saved file.
|
||||
ScriptDefault : string;//The default script e.g. program new; begin end.
|
||||
ScriptChanged : boolean;//We need this for that little * (edited star).
|
||||
// ScriptThread : TMThread;//Just one thread for now..
|
||||
// FScriptState : TScriptState;//Stores the ScriptState, if you want the Run/Pause/Start buttons to change accordingly, acces through Form1
|
||||
ScriptThread : TMThread;//Just one thread for now..
|
||||
FScriptState : TScriptState;//Stores the ScriptState, if you want the Run/Pause/Start buttons to change accordingly, acces through Form1
|
||||
procedure undo;
|
||||
procedure redo;
|
||||
procedure HandleErrorData;
|
||||
procedure MakeActiveScriptFrame;
|
||||
procedure ScriptThreadTerminate(Sender: TObject);
|
||||
constructor Create(TheOwner: TComponent); override;
|
||||
{ public declarations }
|
||||
end;
|
||||
@ -581,6 +582,11 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TScriptFrame.ScriptThreadTerminate(Sender: TObject);
|
||||
begin
|
||||
FScriptState:= ss_None;
|
||||
SimbaForm.RefreshTab;
|
||||
end;
|
||||
procedure AddKey(const SynEdit : TSynEdit; const ACmd: TSynEditorCommand; const AKey: word;const AShift: TShiftState);
|
||||
begin
|
||||
with SynEdit.KeyStrokes.Add do
|
||||
@ -606,7 +612,7 @@ begin
|
||||
ScriptDefault:= StartText;
|
||||
ScriptName:= 'Untitled';
|
||||
ScriptChanged := false;
|
||||
|
||||
FScriptState:= ss_None;
|
||||
ScriptErrorLine:= -1;
|
||||
OwnerSheet.Caption:= ScriptName;
|
||||
SynEdit.Highlighter := SimbaForm.CurrHighlighter;
|
||||
|
@ -396,7 +396,6 @@ type
|
||||
Picker: TMColorPicker;
|
||||
Selector: TMWindowSelector;
|
||||
OnScriptStart : TScriptStartEvent;
|
||||
FScriptState: TScriptState;
|
||||
{$ifdef mswindows}
|
||||
ConsoleVisible : boolean;
|
||||
procedure ShowConsole( ShowIt : boolean);
|
||||
@ -411,7 +410,6 @@ type
|
||||
function SaveCurrentScriptAsDefault : boolean;
|
||||
function CanExitOrOpen : boolean;
|
||||
function ClearScript : boolean;
|
||||
procedure ScriptThreadTerminate(Sender: TObject);
|
||||
procedure RunScript;
|
||||
procedure PauseScript;
|
||||
procedure StopScript;
|
||||
@ -854,21 +852,13 @@ end;
|
||||
|
||||
//{$ENDIF}
|
||||
|
||||
procedure TSimbaForm.ScriptThreadTerminate(Sender: TObject);
|
||||
begin
|
||||
mDebugLn('Thread terminated');
|
||||
ScriptState := ss_None;
|
||||
CurrThread := nil;
|
||||
end;
|
||||
|
||||
procedure TSimbaForm.RunScript;
|
||||
begin
|
||||
with CurrScript do
|
||||
begin
|
||||
if ScriptState = ss_Paused then
|
||||
begin;
|
||||
CurrThread.Resume;
|
||||
// ScriptThread.Resume;
|
||||
ScriptThread.Resume;
|
||||
ScriptState := ss_Running;
|
||||
Exit;
|
||||
end else
|
||||
@ -877,13 +867,13 @@ begin
|
||||
FormWritelnEx('The script hasn''t stopped yet, so we cannot start a new one.');
|
||||
exit;
|
||||
end;
|
||||
InitalizeTMThread(CurrThread);
|
||||
CurrThread.CompileOnly:= false;
|
||||
CurrThread.OnTerminate:=@ScriptThreadTerminate;
|
||||
InitalizeTMThread(scriptthread);
|
||||
ScriptThread.CompileOnly:= false;
|
||||
ScriptThread.OnTerminate:=@ScriptThreadTerminate;
|
||||
ScriptState:= ss_Running;
|
||||
FirstRun := false;
|
||||
//Lets run it!
|
||||
CurrThread.Resume;
|
||||
ScriptThread.Resume;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -894,14 +884,14 @@ begin
|
||||
if ScriptState = ss_Running then
|
||||
begin;
|
||||
{$ifdef MSWindows}
|
||||
CurrThread.Suspended:= True;
|
||||
ScriptThread.Suspended:= True;
|
||||
ScriptState:= ss_Paused;
|
||||
{$else}
|
||||
mDebugLn('Linux users are screwed, no pause button for u!');
|
||||
{$endif}
|
||||
end else if ScriptState = ss_Paused then
|
||||
begin;
|
||||
CurrThread.Resume;
|
||||
ScriptThread.Resume;
|
||||
ScriptState := ss_Running;
|
||||
end;
|
||||
end;
|
||||
@ -915,20 +905,20 @@ begin
|
||||
ss_Stopping:
|
||||
begin //Terminate the thread the tough way.
|
||||
mDebugLn('Terminating the Scriptthread');
|
||||
mDebugLn('Exit code terminate: ' +inttostr(KillThread(CurrThread.Handle)));
|
||||
WaitForThreadTerminate(CurrThread.Handle, 0);
|
||||
CurrThread.Free;
|
||||
mDebugLn('Exit code terminate: ' +inttostr(KillThread(ScriptThread.Handle)));
|
||||
WaitForThreadTerminate(ScriptThread.Handle, 0);
|
||||
ScriptThread.Free;
|
||||
ScriptState := ss_None;
|
||||
end;
|
||||
ss_Running:
|
||||
begin
|
||||
CurrThread.Terminate;
|
||||
ScriptThread.Terminate;
|
||||
ScriptState := ss_Stopping;
|
||||
end;
|
||||
ss_Paused:
|
||||
begin
|
||||
CurrThread.Resume;
|
||||
CurrThread.Terminate;
|
||||
ScriptThread.Resume;
|
||||
ScriptThread.Terminate;
|
||||
ScriptState:= ss_Stopping;
|
||||
end;
|
||||
end;
|
||||
@ -1146,11 +1136,7 @@ begin
|
||||
end;
|
||||
StatusBar.Panels[Panel_ScriptName].Text:= Script.ScriptName;
|
||||
StatusBar.Panels[Panel_ScriptPath].text:= Script.ScriptFile;
|
||||
|
||||
{ XXX: No longer update buttons }
|
||||
// SetScriptState(Tab.ScriptFrame.FScriptState);//To set the buttons right
|
||||
|
||||
|
||||
SetScriptState(Tab.ScriptFrame.FScriptState);//To set the buttons right
|
||||
if Self.Showing then
|
||||
if Tab.TabSheet.TabIndex = Self.PageControl1.TabIndex then
|
||||
if CurrScript.SynEdit.CanFocus then
|
||||
@ -2636,7 +2622,7 @@ end;
|
||||
|
||||
function TSimbaForm.GetScriptState: TScriptState;
|
||||
begin
|
||||
result := FScriptState;
|
||||
result := CurrScript.FScriptState;
|
||||
end;
|
||||
|
||||
function TSimbaForm.GetShowParamHintAuto: boolean;
|
||||
@ -2699,7 +2685,7 @@ end;
|
||||
|
||||
procedure TSimbaForm.SetScriptState(const State: TScriptState);
|
||||
begin
|
||||
FScriptState:= State;
|
||||
CurrScript.FScriptState:= State;
|
||||
with Self.StatusBar.panels[Panel_State] do
|
||||
case state of
|
||||
ss_Running : begin Text := 'Running'; TB_Run.Enabled:= False; {$ifdef MSWindows}TB_Pause.Enabled:= True; {$endif}
|
||||
@ -2892,7 +2878,7 @@ begin
|
||||
LocalCopy := CurrentSyncInfo;
|
||||
mDebugLn('Executing : ' + LocalCopy.MethodName);
|
||||
thread:= TMThread(LocalCopy.OldThread);
|
||||
//mmlpsthread.CurrThread:= thread;
|
||||
mmlpsthread.CurrThread:= thread;
|
||||
try
|
||||
if thread is TPSThread then
|
||||
begin
|
||||
@ -2907,7 +2893,7 @@ begin
|
||||
raise Exception.Create('ThreadSafeCall not implemented on this client');
|
||||
end;
|
||||
finally
|
||||
//mmlpsthread.CurrThread:= nil;
|
||||
mmlpsthread.CurrThread:= nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -188,10 +188,8 @@ type
|
||||
procedure AddMethod(meth: TExpMethod); override;
|
||||
end;
|
||||
|
||||
|
||||
var
|
||||
threadvar
|
||||
CurrThread : TMThread;
|
||||
|
||||
var
|
||||
PluginsGlob: TMPlugins;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user