SynEdit: MacroRecorder: allow Stop method to interrupt playback

git-svn-id: trunk@37737 -
This commit is contained in:
martin 2012-06-22 23:58:19 +00:00
parent c5ebe15fc6
commit 7754174512

View File

@ -207,6 +207,7 @@ type
fMacroName: string;
fSaveMarkerPos: boolean;
FStartPlayBack: boolean;
FStopRequested: Boolean;
function GetCommandIDs(Index: integer): TSynEditorCommand;
function GetEvent(aIndex: integer): TSynMacroEvent;
function GetEventCount: integer;
@ -655,13 +656,17 @@ var
begin
if State <> msStopped then
Error( sCannotPlay );
FStopRequested := False;
fState := msPlaying;
try
StateChanged;
for cEvent := 0 to EventCount -1 do
for cEvent := 0 to EventCount -1 do begin
Events[ cEvent ].Playback( aEditor );
if FStopRequested then break;
end;
finally
fState := msStopped;
FStopRequested := False;
StateChanged;
end;
end;
@ -735,6 +740,10 @@ procedure TCustomSynMacroRecorder.Stop;
begin
if fState = msStopped then
Exit;
if fState = msPlaying then begin
FStopRequested := True;
Exit;
end;
fState := msStopped;
fCurrentEditor := nil;
if fEvents.Count = 0 then