diff --git a/app/formconsole.pas b/app/formconsole.pas index 7a62e821561..5bca2da9ee7 100644 --- a/app/formconsole.pas +++ b/app/formconsole.pas @@ -13,7 +13,7 @@ interface uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls, - StrUtils, Menus, LclType, + StrUtils, Menus, LclType, Math, PythonEngine, ATStrings, ATSynEdit, @@ -102,6 +102,7 @@ TfmConsole = class(TFormDummy) procedure SetFocus; override; procedure ApplyTheme; procedure ApplyCaretView; + procedure FlushConsole; end; var @@ -285,6 +286,8 @@ procedure TfmConsole.DoRunLine(Str: string); finally Py_DECREF(Obj); end; + + FlushConsole; except end; end; @@ -592,6 +595,28 @@ procedure TfmConsole.ApplyCaretView; EditorCaretShapeFromString(EdMemo.CaretShapeReadonly, EditorOps.OpCaretViewReadonly); end; +procedure TfmConsole.FlushConsole; +var + S: UnicodeString; + NCnt, i: integer; +begin + if not AppConsoleQueue.IsEmpty() then + begin + //avoid output of huge items count at once + NCnt:= Min(AppConsoleQueue.Size, 300); + for i:= 1 to NCnt do + begin + S:= AppConsoleQueue.Front(); + AppConsoleQueue.Pop(); + DoAddLine(S); + if UiOps.LogConsole then + MsgLogToFilename(S, AppFile_LogConsole, false); + end; + + DoUpdateMemo; + end; +end; + finalization if Assigned(fmConsole) then FreeAndNil(fmConsole); diff --git a/app/formmain.pas b/app/formmain.pas index 457a73a16da..d02f3d0233e 100644 --- a/app/formmain.pas +++ b/app/formmain.pas @@ -739,7 +739,6 @@ TfmMain = class(TForm) procedure FindAndMarkAll(var NCounter: integer); procedure FindAndReplaceInAllFrames(FramePrev: TEditorFrame; var NCounter: integer); procedure FindAndExtractRegexMatches; - procedure FlushConsole; function GetFileOpenOptionsString(AFileCount: integer): string; procedure HandleTimerCommand(Ed: TATSynEdit; CmdCode: integer; CmdInvoke: TATCommandInvoke); procedure InvalidateMouseoverDependantControls; @@ -2275,28 +2274,6 @@ procedure TfmMain.StatusPanelClick(Sender: TObject; AIndex: Integer); end; end; -procedure TfmMain.FlushConsole; -var - S: UnicodeString; - NCnt, i: integer; -begin - if Assigned(fmConsole) and not AppConsoleQueue.IsEmpty() then - begin - //avoid output of huge items count at once - NCnt:= Min(AppConsoleQueue.Size, 300); - for i:= 1 to NCnt do - begin - S:= AppConsoleQueue.Front(); - AppConsoleQueue.Pop(); - fmConsole.DoAddLine(S); - if UiOps.LogConsole then - MsgLogToFilename(S, AppFile_LogConsole, false); - end; - - fmConsole.DoUpdateMemo; - end; -end; - procedure TfmMain.TimerAppIdleTimer(Sender: TObject); var STemp: string; @@ -2336,7 +2313,8 @@ procedure TfmMain.TimerAppIdleTimer(Sender: TObject); end; //flush saved Python "print" results to console - FlushConsole; + if Assigned(fmConsole) then + fmConsole.FlushConsole; AppUpdateWatcherFrames; if AppCommandHandlerIsBusy then exit; @@ -3748,7 +3726,8 @@ procedure TfmMain.FormShow(Sender: TObject); end; AppFormShowCompleted:= true; - FlushConsole; + if Assigned(fmConsole) then + fmConsole.FlushConsole; end; procedure TfmMain.FormWindowStateChange(Sender: TObject);