added file action compile file and run outside

like runnable moduled but when redirection of the output is not wanted
This commit is contained in:
Basile Burg 2015-03-07 14:57:30 +01:00
parent ee091c7578
commit 912749c45c
2 changed files with 70 additions and 40 deletions

View File

@ -494,6 +494,9 @@ object CEMainForm: TCEMainForm
07FFB47A07FFB47A08FFB57C0AFFB67F0FFFB88114FFBA851B23
}
end
object MenuItem65: TMenuItem
Action = actFileCompileAndRunOut
end
object MenuItem63: TMenuItem
Action = actFileUnittest
Bitmap.Data = {
@ -1701,6 +1704,9 @@ object CEMainForm: TCEMainForm
07FFB47A07FFB47A08FFB57C0AFFB67F0FFFB88114FFBA851B23
}
end
object MenuItem66: TMenuItem
Action = actFileCompileAndRunOut
end
object MenuItem64: TMenuItem
Action = actFileUnittest
Bitmap.Data = {
@ -1990,6 +1996,7 @@ object CEMainForm: TCEMainForm
Images = imgList
OnUpdate = ActionsUpdate
left = 32
top = 1
object actEdCopy: TAction
Category = 'Edit'
Caption = 'Copy'
@ -2082,31 +2089,11 @@ object CEMainForm: TCEMainForm
end
object actFileCompAndRun: TAction
Category = 'File'
Caption = 'Compile and run file'
Caption = 'Compile file and run'
ImageIndex = 22
OnExecute = actFileCompAndRunExecute
ShortCut = 16503
end
object ActFileCompAndRunWithArgs: TAction
Category = 'File'
Caption = 'Compile and run file...'
ImageIndex = 22
OnExecute = ActFileCompAndRunWithArgsExecute
ShortCut = 24695
end
object actFileSaveAll: TAction
Category = 'File'
Caption = 'Save all'
ImageIndex = 26
OnExecute = actFileSaveAllExecute
end
object actFileClose: TAction
Category = 'File'
Caption = 'Close file'
ImageIndex = 27
OnExecute = actFileCloseExecute
ShortCut = 16471
end
object actProjSave: TAction
Category = 'Project'
Caption = 'Save project'
@ -2178,14 +2165,14 @@ object CEMainForm: TCEMainForm
end
object actProjCompileAndRun: TAction
Category = 'Project'
Caption = 'Compile and run project'
Caption = 'Compile project and run'
ImageIndex = 21
OnExecute = actProjCompileAndRunExecute
ShortCut = 24696
end
object actProjCompAndRunWithArgs: TAction
Category = 'Project'
Caption = 'Compile and run project...'
Caption = 'Compile project and run...'
ImageIndex = 21
OnExecute = actProjCompAndRunWithArgsExecute
end
@ -2216,12 +2203,6 @@ object CEMainForm: TCEMainForm
OnExecute = actEdFindNextExecute
ShortCut = 114
end
object actFileOpenContFold: TAction
Category = 'File'
Caption = 'View in mini explorer'
ImageIndex = 29
OnExecute = actFileOpenContFoldExecute
end
object actProjOpenContFold: TAction
Category = 'Project'
Caption = 'View in mini explorer'
@ -2234,6 +2215,38 @@ object CEMainForm: TCEMainForm
ImageIndex = 30
OnExecute = actLayoutSaveExecute
end
object actFileCompileAndRunOut: TAction
Category = 'File'
Caption = 'Compile file and run outside'
ImageIndex = 22
OnExecute = actFileCompileAndRunOutExecute
end
object ActFileCompAndRunWithArgs: TAction
Category = 'File'
Caption = 'Compile file and run...'
ImageIndex = 22
OnExecute = ActFileCompAndRunWithArgsExecute
ShortCut = 24695
end
object actFileSaveAll: TAction
Category = 'File'
Caption = 'Save all'
ImageIndex = 26
OnExecute = actFileSaveAllExecute
end
object actFileClose: TAction
Category = 'File'
Caption = 'Close file'
ImageIndex = 27
OnExecute = actFileCloseExecute
ShortCut = 16471
end
object actFileOpenContFold: TAction
Category = 'File'
Caption = 'View in mini explorer'
ImageIndex = 29
OnExecute = actFileOpenContFoldExecute
end
object actFileHtmlExport: TAction
Category = 'File'
Caption = 'Export to html...'

View File

@ -18,6 +18,8 @@ type
// TODO-cfeature: options
{ TCEMainForm }
TCEMainForm = class(TForm, ICEMultiDocObserver, ICESessionOptionsObserver, ICEEditableShortCut)
actFileCompAndRun: TAction;
actFileSaveAll: TAction;
@ -34,6 +36,7 @@ type
actFileOpenContFold: TAction;
actFileHtmlExport: TAction;
actFileUnittest: TAction;
actFileCompileAndRunOut: TAction;
actLayoutSave: TAction;
actProjOpenContFold: TAction;
actProjOptView: TAction;
@ -120,6 +123,8 @@ type
MenuItem62: TMenuItem;
MenuItem63: TMenuItem;
MenuItem64: TMenuItem;
MenuItem65: TMenuItem;
MenuItem66: TMenuItem;
mnuLayout: TMenuItem;
mnuItemMruFile: TMenuItem;
mnuItemMruProj: TMenuItem;
@ -130,6 +135,7 @@ type
MenuItem7: TMenuItem;
MenuItem8: TMenuItem;
MenuItem9: TMenuItem;
procedure actFileCompileAndRunOutExecute(Sender: TObject);
procedure actEdFindExecute(Sender: TObject);
procedure actEdFindNextExecute(Sender: TObject);
procedure actFileAddToProjExecute(Sender: TObject);
@ -257,7 +263,8 @@ type
// run & exec sub routines
procedure asyncprocOutput(sender: TObject);
procedure asyncprocTerminate(sender: TObject);
procedure compileAndRunFile(unittest: boolean = false; const runArgs: string = '');
procedure compileAndRunFile(unittest: boolean = false; redirect: boolean = true;
const runArgs: string = '');
// file sub routines
procedure newFile;
@ -1276,7 +1283,8 @@ begin
if (inph <> nil) then (inph as ICEProcInputHandler).removeProcess(proc);
end;
procedure TCEMainForm.compileAndRunFile(unittest: boolean; const runArgs: string = '');
procedure TCEMainForm.compileAndRunFile(unittest: boolean = false; redirect: boolean = true;
const runArgs: string = '');
var
dmdproc: TProcess;
fname: string;
@ -1286,10 +1294,13 @@ begin
if fDoc = nil then exit;
fRunProc := TCheckedAsyncProcess.Create(nil);
fRunProc.Options := [poStderrToOutPut, poUsePipes];
fRunProc.ShowWindow := swoHIDE;
fRunProc.OnReadData := @asyncprocOutput;
fRunProc.OnTerminate:= @asyncprocTerminate;
if redirect then
begin
fRunProc.Options := [poStderrToOutPut, poUsePipes];
fRunProc.ShowWindow := swoHIDE;
fRunProc.OnReadData := @asyncprocOutput;
fRunProc.OnTerminate:= @asyncprocTerminate;
end;
dmdproc := TProcess.Create(nil);
try
@ -1326,12 +1337,12 @@ begin
begin
fMsgs.message(shortenPath(fDoc.fileName, 25) + ' successfully compiled',
fDoc, amcEdit, amkInf);
fRunProc.CurrentDirectory := extractFilePath(fRunProc.Executable);
if runArgs <> '' then
fRunProc.Parameters.DelimitedText := symbolExpander.get(runArgs);
fRunProc.Executable := fname + exeExt;
getprocInputHandler.addProcess(fRunProc);
if redirect then
getprocInputHandler.addProcess(fRunProc);
fRunProc.Execute;
sysutils.DeleteFile(fname + objExt);
end
@ -1348,13 +1359,19 @@ end;
procedure TCEMainForm.actFileUnittestExecute(Sender: TObject);
begin
if fDoc = nil then exit;
compileAndRunFile(true, '');
compileAndRunFile(true);
end;
procedure TCEMainForm.actFileCompAndRunExecute(Sender: TObject);
begin
if fDoc = nil then exit;
compileAndRunFile(false, '');
compileAndRunFile(false);
end;
procedure TCEMainForm.actFileCompileAndRunOutExecute(Sender: TObject);
begin
if fDoc = nil then exit;
compileAndRunFile(false, false);
end;
procedure TCEMainForm.actFileCompAndRunWithArgsExecute(Sender: TObject);
@ -1364,7 +1381,7 @@ begin
if fDoc = nil then exit;
runargs := '';
if InputQuery('Execution arguments', '', runargs) then
compileAndRunFile(false, runargs);
compileAndRunFile(false, true, runargs);
end;
procedure TCEMainForm.actFileOpenContFoldExecute(Sender: TObject);