mirror of https://gitlab.com/basile.b/dexed.git
changed runnable module TProcess to TAsyncProcess.
This commit is contained in:
parent
9a24bf0075
commit
4e9259371c
|
@ -0,0 +1,14 @@
|
||||||
|
module runnable;
|
||||||
|
|
||||||
|
import std.stdio;
|
||||||
|
|
||||||
|
void main(string args[])
|
||||||
|
{
|
||||||
|
writeln("use <<Process input>> widget to continue: just click 'Send'");
|
||||||
|
stdout.flush;
|
||||||
|
readln;
|
||||||
|
writeln("type <kbd>ENTER</kbd> in the field");
|
||||||
|
stdout.flush;
|
||||||
|
readln;
|
||||||
|
writeln("it was not possible when the process was declared as a local variable...");
|
||||||
|
}
|
|
@ -3185,10 +3185,4 @@ object CEMainForm: TCEMainForm
|
||||||
OnShowHint = ApplicationProperties1ShowHint
|
OnShowHint = ApplicationProperties1ShowHint
|
||||||
left = 96
|
left = 96
|
||||||
end
|
end
|
||||||
object OutputTimer: TIdleTimer
|
|
||||||
Interval = 100
|
|
||||||
OnTimer = OutputTimerTimer
|
|
||||||
left = 128
|
|
||||||
top = 1
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -60,7 +60,6 @@ type
|
||||||
actEdUnIndent: TAction;
|
actEdUnIndent: TAction;
|
||||||
Actions: TActionList;
|
Actions: TActionList;
|
||||||
ApplicationProperties1: TApplicationProperties;
|
ApplicationProperties1: TApplicationProperties;
|
||||||
OutputTimer: TIdleTimer;
|
|
||||||
imgList: TImageList;
|
imgList: TImageList;
|
||||||
mainMenu: TMainMenu;
|
mainMenu: TMainMenu;
|
||||||
MenuItem1: TMenuItem;
|
MenuItem1: TMenuItem;
|
||||||
|
@ -171,7 +170,6 @@ type
|
||||||
var CanShow: Boolean; var HintInfo: THintInfo);
|
var CanShow: Boolean; var HintInfo: THintInfo);
|
||||||
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
|
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
|
||||||
procedure FormDropFiles(Sender: TObject; const FileNames: array of String);
|
procedure FormDropFiles(Sender: TObject; const FileNames: array of String);
|
||||||
procedure OutputTimerTimer(Sender: TObject);
|
|
||||||
private
|
private
|
||||||
|
|
||||||
fDoc: TCESynMemo;
|
fDoc: TCESynMemo;
|
||||||
|
@ -194,7 +192,7 @@ type
|
||||||
fPrInpWidg: TCEProcInputWidget;
|
fPrInpWidg: TCEProcInputWidget;
|
||||||
fTools: TCETools;
|
fTools: TCETools;
|
||||||
|
|
||||||
fRunProc: TProcess;// TAsyncProcess;
|
fRunProc: TAsyncProcess;
|
||||||
|
|
||||||
// ICEMultiDocObserver
|
// ICEMultiDocObserver
|
||||||
procedure docNew(const aDoc: TCESynMemo);
|
procedure docNew(const aDoc: TCESynMemo);
|
||||||
|
@ -237,6 +235,7 @@ type
|
||||||
|
|
||||||
// run & exec sub routines
|
// run & exec sub routines
|
||||||
procedure asyncprocOutput(sender: TObject);
|
procedure asyncprocOutput(sender: TObject);
|
||||||
|
procedure asyncprocTerminate(sender: TObject);
|
||||||
procedure ProcessOutputToMsg(const aProcess: TProcess;aCtxt: TMessageContext = mcUnknown);
|
procedure ProcessOutputToMsg(const aProcess: TProcess;aCtxt: TMessageContext = mcUnknown);
|
||||||
procedure compileAndRunFile(const edIndex: NativeInt; const runArgs: string = '');
|
procedure compileAndRunFile(const edIndex: NativeInt; const runArgs: string = '');
|
||||||
procedure compileProject(const aProject: TCEProject);
|
procedure compileProject(const aProject: TCEProject);
|
||||||
|
@ -1243,29 +1242,38 @@ begin
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCEMainForm.OutputTimerTimer(Sender: TObject);
|
procedure TCEMainForm.asyncprocOutput(sender: TObject);
|
||||||
|
var
|
||||||
|
proc: TProcess;
|
||||||
begin
|
begin
|
||||||
if fRunProc <> nil then
|
proc := TProcess(sender);
|
||||||
ProcessOutputToMsg(fRunProc, mcEditor);
|
if proc = fRunProc then
|
||||||
|
ProcessOutputToMsg(TAsyncProcess(sender), mcEditor);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCEMainForm.asyncprocOutput(sender: TObject);
|
procedure TCEMainForm.asyncprocTerminate(sender: TObject);
|
||||||
|
var
|
||||||
|
proc: TProcess;
|
||||||
begin
|
begin
|
||||||
//ProcessOutputToMsg(TAsyncProcess(sender), mcEditor);
|
proc := TProcess(sender);
|
||||||
|
ProcessOutputToMsg(TAsyncProcess(sender), mcEditor);
|
||||||
|
if proc = fRunProc then
|
||||||
|
FreeRunnableProc;
|
||||||
|
if proc = fPrInpWidg.process then
|
||||||
|
fPrInpWidg.process := nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCEMainForm.compileAndRunFile(const edIndex: NativeInt; const runArgs: string = '');
|
procedure TCEMainForm.compileAndRunFile(const edIndex: NativeInt; const runArgs: string = '');
|
||||||
var
|
var
|
||||||
editor: TCESynMemo;
|
editor: TCESynMemo;
|
||||||
dmdproc: TProcess;
|
dmdproc: TProcess;
|
||||||
//runproc: TProcess;
|
|
||||||
fname: string;
|
fname: string;
|
||||||
begin
|
begin
|
||||||
|
|
||||||
FreeRunnableProc;
|
FreeRunnableProc;
|
||||||
fRunProc := TProcess.Create(nil);
|
fRunProc := TAsyncProcess.Create(nil);
|
||||||
//fRunProc := TAsyncProcess.Create(nil);
|
fRunProc.OnReadData := @asyncprocOutput;
|
||||||
//fRunProc.OnReadData := @asyncprocOutput;
|
fRunProc.OnTerminate:= @asyncprocTerminate;
|
||||||
|
|
||||||
dmdproc := TProcess.Create(nil);
|
dmdproc := TProcess.Create(nil);
|
||||||
editor := fEditWidg.editor[edIndex];
|
editor := fEditWidg.editor[edIndex];
|
||||||
|
@ -1296,17 +1304,12 @@ begin
|
||||||
begin
|
begin
|
||||||
ProcessOutputToMsg(dmdproc, mcEditor);
|
ProcessOutputToMsg(dmdproc, mcEditor);
|
||||||
fMesgWidg.addCeInf(editor.fileName + ' successfully compiled', mcEditor );
|
fMesgWidg.addCeInf(editor.fileName + ' successfully compiled', mcEditor );
|
||||||
fRunProc.Options := fRunProc.Options + [poStderrToOutPut, poUsePipes];
|
fRunProc.Options := fRunProc.Options + [poNoConsole, poStderrToOutPut, poUsePipes];
|
||||||
fRunProc.CurrentDirectory := extractFilePath(fRunProc.Executable);
|
fRunProc.CurrentDirectory := extractFilePath(fRunProc.Executable);
|
||||||
fRunProc.Parameters.DelimitedText := expandSymbolicString(runArgs);
|
fRunProc.Parameters.DelimitedText := expandSymbolicString(runArgs);
|
||||||
fRunProc.Executable := fname + exeExt;
|
fRunProc.Executable := fname + exeExt;
|
||||||
fPrInpWidg.process := fRunProc;
|
fPrInpWidg.process := fRunProc;
|
||||||
fRunProc.Execute;
|
fRunProc.Execute;
|
||||||
|
|
||||||
//ProcessOutputToMsg(fRunProc, mcEditor);
|
|
||||||
|
|
||||||
//repeat ProcessOutputToMsg(runproc, mcEditor) until not runproc.Running;
|
|
||||||
//sysutils.DeleteFile(fname + exeExt);
|
|
||||||
sysutils.DeleteFile(fname + objExt);
|
sysutils.DeleteFile(fname + objExt);
|
||||||
end
|
end
|
||||||
else begin
|
else begin
|
||||||
|
@ -1314,11 +1317,8 @@ begin
|
||||||
fMesgWidg.addCeErr(editor.fileName + ' has not been compiled', mcEditor );
|
fMesgWidg.addCeErr(editor.fileName + ' has not been compiled', mcEditor );
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//fPrInpWidg.process := nil;
|
|
||||||
|
|
||||||
finally
|
finally
|
||||||
dmdproc.Free;
|
dmdproc.Free;
|
||||||
//runproc.Free;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue