IDE: external tools: started options ShowConsole and HideWindow

git-svn-id: trunk@53016 -
This commit is contained in:
mattias 2016-09-22 08:44:36 +00:00
parent b934d7aa02
commit e2ac7a9645
5 changed files with 156 additions and 98 deletions

View File

@ -652,10 +652,12 @@ type
FCustomMacroFunction: TETMacroFunction;
FEnvironmentOverrides: TStringList;
FExecutable: string;
FHideWindow: boolean;
FHint: string;
FQuiet: boolean;
FResolveMacros: boolean;
FScanners: TStrings;
FShowConsole: boolean;
fTitle: string;
fWorkingDirectory: string;
procedure SetEnvironmentOverrides(AValue: TStringList);
@ -675,6 +677,8 @@ type
property WorkingDirectory: string read fWorkingDirectory write fWorkingDirectory;
property EnvironmentOverrides: TStringList read FEnvironmentOverrides write SetEnvironmentOverrides;
property Scanners: TStrings read FScanners write SetScanners;
property ShowConsole: boolean read FShowConsole write FShowConsole default false; // sets poNoConsole/poNewConsole, works only on MSWindows
property HideWindow: boolean read FHideWindow write FHideWindow default true; // sets/unsets swoHide/swoShow, works only on MSWindows
property ResolveMacros: boolean read FResolveMacros write FResolveMacros default true;
property CustomMacroFunction: TETMacroFunction read FCustomMacroFunction write FCustomMacroFunction;
property Quiet: boolean read FQuiet write FQuiet; // no user dialogs about errors
@ -810,6 +814,8 @@ begin
WorkingDirectory:=Source.WorkingDirectory;
EnvironmentOverrides:=Source.EnvironmentOverrides;
Scanners:=Source.Scanners;
ShowConsole:=Source.ShowConsole;
HideWindow:=Source.HideWindow;
ResolveMacros:=Source.ResolveMacros;
CustomMacroFunction:=Source.CustomMacroFunction;
Quiet:=Source.Quiet;
@ -828,6 +834,8 @@ begin
and (WorkingDirectory=Source.WorkingDirectory)
and EnvironmentOverrides.Equals(Source.EnvironmentOverrides)
and Scanners.Equals(Source.Scanners)
and (ShowConsole=Source.ShowConsole)
and (HideWindow=Source.HideWindow)
and (ResolveMacros=Source.ResolveMacros)
and CompareMethods(TMethod(CustomMacroFunction),TMethod(Source.CustomMacroFunction))
and (Quiet=Source.Quiet);
@ -841,6 +849,8 @@ begin
FCustomMacroFunction:=nil;
FEnvironmentOverrides.Clear;
FExecutable:='';
FShowConsole:=false;
FHideWindow:=true;
FResolveMacros:=true;
FScanners.Clear;
fTitle:='';

View File

@ -1,7 +1,7 @@
object ExternalToolOptionDlg: TExternalToolOptionDlg
Left = 348
Left = 350
Height = 592
Top = 119
Top = 163
Width = 661
Caption = 'ExternalToolOptionDlg'
ClientHeight = 592
@ -12,15 +12,15 @@ object ExternalToolOptionDlg: TExternalToolOptionDlg
OnCreate = FormCreate
OnDestroy = FormDestroy
Position = poScreenCenter
LCLVersion = '1.5'
LCLVersion = '1.7'
object TitleLabel: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = TitleEdit
AnchorSideTop.Side = asrCenter
Left = 6
Height = 15
Top = 10
Width = 51
Height = 13
Top = 11
Width = 54
BorderSpacing.Left = 6
Caption = 'TitleLabel'
ParentColor = False
@ -30,9 +30,9 @@ object ExternalToolOptionDlg: TExternalToolOptionDlg
AnchorSideTop.Control = FileNameEdit
AnchorSideTop.Side = asrCenter
Left = 6
Height = 15
Top = 39
Width = 76
Height = 13
Top = 40
Width = 78
BorderSpacing.Left = 6
Caption = 'FilenameLabel'
ParentColor = False
@ -42,9 +42,9 @@ object ExternalToolOptionDlg: TExternalToolOptionDlg
AnchorSideTop.Control = MemoParameters
AnchorSideTop.Side = asrCenter
Left = 6
Height = 15
Top = 102
Width = 87
Height = 13
Top = 103
Width = 92
BorderSpacing.Left = 6
Caption = 'ParametersLabel'
ParentColor = False
@ -54,9 +54,9 @@ object ExternalToolOptionDlg: TExternalToolOptionDlg
AnchorSideTop.Control = WorkingDirEdit
AnchorSideTop.Side = asrCenter
Left = 6
Height = 15
Top = 164
Width = 88
Height = 13
Top = 165
Width = 92
BorderSpacing.Left = 6
Caption = 'WorkingDirLabel'
ParentColor = False
@ -67,10 +67,10 @@ object ExternalToolOptionDlg: TExternalToolOptionDlg
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 112
Left = 114
Height = 23
Top = 6
Width = 543
Width = 541
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 24
BorderSpacing.Around = 6
@ -84,7 +84,7 @@ object ExternalToolOptionDlg: TExternalToolOptionDlg
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 6
Height = 107
Height = 112
Top = 189
Width = 649
Anchors = [akTop, akLeft, akRight]
@ -92,54 +92,60 @@ object ExternalToolOptionDlg: TExternalToolOptionDlg
BorderSpacing.Around = 6
Caption = 'OptionsGroupBox'
ChildSizing.Layout = cclTopToBottomThenLeftToRight
ChildSizing.ControlsPerLine = 5
ClientHeight = 87
ChildSizing.ControlsPerLine = 3
ClientHeight = 97
ClientWidth = 645
TabOrder = 4
object OptionScanOutputForFPCMessagesCheckBox: TCheckBox
object ScanOutputForFPCMessagesCheckBox: TCheckBox
AnchorSideTop.Side = asrBottom
Left = 6
Height = 19
Height = 24
Top = 6
Width = 269
Width = 244
BorderSpacing.Around = 6
Caption = 'OptionScanOutputForFPCMessagesCheckBox'
Caption = 'ScanOutputForFPCMessagesCheckBox'
TabOrder = 0
end
object OptionScanOutputForMakeMessagesCheckBox: TCheckBox
object ScanOutputForMakeMessagesCheckBox: TCheckBox
AnchorSideTop.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 19
Top = 31
Width = 269
Height = 24
Top = 36
Width = 244
BorderSpacing.Around = 6
Caption = 'OptionScanOutputForMakeMessagesCheckBox'
Caption = 'ScanOutputForMakeMessagesCheckBox'
TabOrder = 1
end
object ScannersButton: TButton
AnchorSideLeft.Control = OptionsGroupBox
AnchorSideTop.Control = OptionScanOutputForMakeMessagesCheckBox
AnchorSideTop.Side = asrBottom
Left = 6
Height = 25
Top = 56
Width = 323
Top = 66
Width = 244
AutoSize = True
BorderSpacing.Around = 6
Caption = 'ScannersButton'
TabOrder = 3
end
object chkHideMainForm: TCheckBox
AnchorSideLeft.Control = OptionScanOutputForFPCMessagesCheckBox
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = OptionScanOutputForFPCMessagesCheckBox
Left = 281
Height = 19
Top = 6
Width = 119
BorderSpacing.Left = 6
Caption = 'chkHideMainForm'
TabOrder = 2
end
object ShowConsoleCheckBox: TCheckBox
Left = 256
Height = 24
Top = 6
Width = 152
Caption = 'ShowConsoleCheckBox'
TabOrder = 3
Visible = False
end
object HideWindowCheckBox: TCheckBox
Left = 256
Height = 24
Top = 36
Width = 152
Caption = 'HideWindowCheckBox'
TabOrder = 4
Visible = False
end
end
object KeyGroupBox: TGroupBox
AnchorSideLeft.Control = OptionsGroupBox
@ -149,7 +155,7 @@ object ExternalToolOptionDlg: TExternalToolOptionDlg
AnchorSideRight.Side = asrBottom
Left = 6
Height = 25
Top = 302
Top = 307
Width = 649
Anchors = [akTop, akLeft, akRight]
AutoSize = True
@ -166,13 +172,13 @@ object ExternalToolOptionDlg: TExternalToolOptionDlg
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ButtonPanel
Left = 6
Height = 221
Top = 333
Height = 214
Top = 338
Width = 649
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Around = 6
Caption = 'MacrosGroupbox'
ClientHeight = 201
ClientHeight = 199
ClientWidth = 645
TabOrder = 6
object MacrosListbox: TListBox
@ -182,9 +188,9 @@ object ExternalToolOptionDlg: TExternalToolOptionDlg
AnchorSideBottom.Control = MacrosGroupbox
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 193
Height = 191
Top = 2
Width = 497
Width = 505
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 6
BorderSpacing.Right = 6
@ -192,16 +198,18 @@ object ExternalToolOptionDlg: TExternalToolOptionDlg
ItemHeight = 0
OnClick = MacrosListboxClick
OnDblClick = MacrosListboxDblClick
ScrollWidth = 503
TabOrder = 0
TopIndex = -1
end
object MacrosInsertButton: TButton
AnchorSideTop.Control = MacrosGroupbox
AnchorSideRight.Control = MacrosGroupbox
AnchorSideRight.Side = asrBottom
Left = 509
Left = 517
Height = 25
Top = 2
Width = 130
Width = 122
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Top = 2
@ -214,8 +222,8 @@ object ExternalToolOptionDlg: TExternalToolOptionDlg
end
object ButtonPanel: TButtonPanel
Left = 6
Height = 26
Top = 560
Height = 28
Top = 558
Width = 649
OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True
@ -238,10 +246,10 @@ object ExternalToolOptionDlg: TExternalToolOptionDlg
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = TitleEdit
AnchorSideRight.Side = asrBottom
Left = 112
Left = 114
Height = 90
Top = 64
Width = 543
Width = 541
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
ScrollBars = ssAutoBoth
@ -254,10 +262,10 @@ object ExternalToolOptionDlg: TExternalToolOptionDlg
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = TitleEdit
AnchorSideRight.Side = asrBottom
Left = 112
Left = 114
Height = 23
Top = 35
Width = 543
Width = 541
DialogOptions = [ofPathMustExist, ofFileMustExist, ofEnableSizing, ofViewDetail]
FilterIndex = 1
HideDirectories = False
@ -277,10 +285,10 @@ object ExternalToolOptionDlg: TExternalToolOptionDlg
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = TitleEdit
AnchorSideRight.Side = asrBottom
Left = 112
Left = 114
Height = 23
Top = 160
Width = 543
Width = 541
ShowHidden = False
ButtonWidth = 45
NumGlyphs = 1

View File

@ -61,10 +61,11 @@ type
fCmdLineParams: string;
FEnvironmentOverrides: TStringList;
fFilename: string;
FHideMainForm: boolean;
FHideWindow: boolean;
FKey: word;
FScanners: TStrings;
FShift: TShiftState;
FShowConsole: boolean;
fTitle: string;
fWorkingDirectory: string;
fSavedChangeStamp: integer;
@ -75,9 +76,10 @@ type
procedure SetEnvironmentOverrides(AValue: TStringList);
procedure SetFilename(AValue: string);
procedure SetHasScanner(aName: string; AValue: boolean);
procedure SetHideMainForm(AValue: boolean);
procedure SetHideWindow(AValue: boolean);
procedure SetModified(AValue: boolean);
procedure SetScanners(AValue: TStrings);
procedure SetShowConsole(AValue: boolean);
procedure SetTitle(AValue: string);
procedure SetWorkingDirectory(AValue: string);
public
@ -88,17 +90,18 @@ type
procedure Assign(Source: TPersistent); override;
function Load(Config: TConfigStorage; CfgVersion: integer): TModalResult; virtual;
function Save(Config: TConfigStorage): TModalResult; virtual;
procedure IncreaseChangeStamp; inline;
property CmdLineParams: string read fCmdLineParams write SetCmdLineParams;
property Filename: string read fFilename write SetFilename;
property Title: string read fTitle write SetTitle;
property WorkingDirectory: string read fWorkingDirectory write SetWorkingDirectory;
property EnvironmentOverrides: TStringList read FEnvironmentOverrides write SetEnvironmentOverrides;
property HideMainForm: boolean read FHideMainForm write SetHideMainForm default true;
property Scanners: TStrings read FScanners write SetScanners;
property HasScanner[aName: string]: boolean read GetHasScanner write SetHasScanner;
property ShowConsole: boolean read FShowConsole write SetShowConsole;
property HideWindow: boolean read FHideWindow write SetHideWindow;
property Modified: boolean read GetModified write SetModified;
property ChangeStamp: integer read FChangeStamp write SetChangeStamp;
procedure IncreaseChangeStamp; inline;
public
// these properties are saved in the keymappings, not in the config
property Key: word read FKey write FKey;
@ -144,23 +147,24 @@ type
TExternalToolOptionDlg = class(TForm)
ButtonPanel: TButtonPanel;
WorkingDirEdit: TDirectoryEdit;
FileNameEdit: TFileNameEdit;
MemoParameters: TMemo;
ScannersButton: TButton;
TitleLabel: TLabel;
TitleEdit: TEdit;
FilenameLabel: TLabel;
ParametersLabel: TLabel;
WorkingDirLabel: TLabel;
OptionsGroupBox: TGroupBox;
OptionScanOutputForFPCMessagesCheckBox: TCheckBox;
OptionScanOutputForMakeMessagesCheckBox: TCheckBox;
HideWindowCheckBox: TCheckBox;
KeyGroupBox: TGroupBox;
MacrosGroupbox: TGroupbox;
MacrosListbox: TListbox;
MacrosInsertButton: TButton;
chkHideMainForm: TCheckBox;
MacrosListbox: TListbox;
MemoParameters: TMemo;
OptionsGroupBox: TGroupBox;
ParametersLabel: TLabel;
ScannersButton: TButton;
ScanOutputForFPCMessagesCheckBox: TCheckBox;
ScanOutputForMakeMessagesCheckBox: TCheckBox;
ShowConsoleCheckBox: TCheckBox;
TitleEdit: TEdit;
TitleLabel: TLabel;
WorkingDirEdit: TDirectoryEdit;
WorkingDirLabel: TLabel;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure HelpButtonClick(Sender: TObject);
@ -280,10 +284,10 @@ begin
IncreaseChangeStamp;
end;
procedure TExternalUserTool.SetHideMainForm(AValue: boolean);
procedure TExternalUserTool.SetHideWindow(AValue: boolean);
begin
if FHideMainForm=AValue then Exit;
FHideMainForm:=AValue;
if FHideWindow=AValue then Exit;
FHideWindow:=AValue;
IncreaseChangeStamp;
end;
@ -302,6 +306,13 @@ begin
IncreaseChangeStamp;
end;
procedure TExternalUserTool.SetShowConsole(AValue: boolean);
begin
if FShowConsole=AValue then Exit;
FShowConsole:=AValue;
IncreaseChangeStamp;
end;
procedure TExternalUserTool.SetTitle(AValue: string);
begin
AValue:=UTF8Trim(AValue,[]);
@ -343,7 +354,6 @@ begin
FEnvironmentOverrides.Clear;
end;
Filename:='';
HideMainForm:=true;
if FScanners.Count>0 then
begin
FScanners.Clear;
@ -351,6 +361,8 @@ begin
end;
Title:='';
WorkingDirectory:='';
ShowConsole:=false;
HideWindow:=true;
end;
function TExternalUserTool.Equals(Obj: TObject): boolean;
@ -362,8 +374,9 @@ begin
Result:=(CmdLineParams=Src.CmdLineParams)
and EnvironmentOverrides.Equals(Src.EnvironmentOverrides)
and (Filename=Src.Filename)
and (HideMainForm=Src.HideMainForm)
and Scanners.Equals(Src.Scanners)
and (ShowConsole=Src.ShowConsole)
and (HideWindow=Src.HideWindow)
and (Title=Src.Title)
and (WorkingDirectory=Src.WorkingDirectory)
and (Key=Src.Key)
@ -383,8 +396,9 @@ begin
WorkingDirectory:=Src.WorkingDirectory;
EnvironmentOverrides:=Src.EnvironmentOverrides;
Filename:=Src.Filename;
HideMainForm:=Src.HideMainForm;
Scanners:=Src.Scanners;
ShowConsole:=Src.ShowConsole;
HideWindow:=Src.HideWindow;
Title:=Src.Title;
Key:=Src.Key;
Shift:=Src.Shift;
@ -401,7 +415,8 @@ begin
fCmdLineParams:=Config.GetValue('CmdLineParams/Value','');
fWorkingDirectory:=Config.GetValue('WorkingDirectory/Value','');
Config.GetValue('EnvironmentOverrides/',FEnvironmentOverrides);
HideMainForm:=Config.GetValue('HideMainForm/Value',true);
ShowConsole:=Config.GetValue('ShowConsole/Value',false);
HideWindow:=Config.GetValue('HideWindow/Value',true);
if CfgVersion<3 then
begin
@ -426,7 +441,8 @@ begin
Config.SetDeleteValue('WorkingDirectory/Value',WorkingDirectory,'');
Config.SetValue('EnvironmentOverrides/',FEnvironmentOverrides);
Config.SetValue('Scanners/',FScanners);
Config.SetDeleteValue('HideMainForm/Value',HideMainForm,true);
Config.SetDeleteValue('ShowConsole/Value',ShowConsole,false);
Config.SetDeleteValue('HideWindow/Value',HideWindow,true);
Modified:=false;
Result:=mrOk;
end;
@ -535,6 +551,8 @@ begin
Tool.CmdLineParams:=Item.CmdLineParams;
Tool.EnvironmentOverrides:=Item.EnvironmentOverrides;
Tool.Scanners:=Item.Scanners;
Tool.ShowConsole:=Item.ShowConsole;
Tool.HideWindow:=Item.HideWindow;
Tool.ResolveMacros:=true;
if not RunExternalTool(Tool) then exit;
finally
@ -660,9 +678,10 @@ begin
WorkingDirEdit.Text:=fOptions.WorkingDirectory;
fKeyBox.Key:=fOptions.Key;
fKeyBox.ShiftState:=fOptions.Shift;
OptionScanOutputForFPCMessagesCheckBox.Checked:=fOptions.HasScanner[SubToolFPC];
OptionScanOutputForMakeMessagesCheckBox.Checked:=fOptions.HasScanner[SubToolMake];
chkHideMainForm.Checked:=FOptions.HideMainForm;
ScanOutputForFPCMessagesCheckBox.Checked:=fOptions.HasScanner[SubToolFPC];
ScanOutputForMakeMessagesCheckBox.Checked:=fOptions.HasScanner[SubToolMake];
ShowConsoleCheckBox.Checked:=FOptions.ShowConsole;
HideWindowCheckBox.Checked:=FOptions.HideWindow;
fScanners.Assign(fOptions.Scanners);
UpdateButtons;
end;
@ -675,14 +694,21 @@ begin
fOptions.WorkingDirectory:=WorkingDirEdit.Text;
fOptions.Key:=fKeyBox.Key;
fOptions.Shift:=fKeyBox.ShiftState;
FOptions.HideMainForm := chkHideMainForm.Checked;
fOptions.HasScanner[SubToolFPC]:=OptionScanOutputForFPCMessagesCheckBox.Checked;
fOptions.HasScanner[SubToolMake]:=OptionScanOutputForMakeMessagesCheckBox.Checked;
FOptions.ShowConsole := ShowConsoleCheckBox.Checked;
FOptions.HideWindow := HideWindowCheckBox.Checked;
fOptions.HasScanner[SubToolFPC]:=ScanOutputForFPCMessagesCheckBox.Checked;
fOptions.HasScanner[SubToolMake]:=ScanOutputForMakeMessagesCheckBox.Checked;
end;
procedure TExternalToolOptionDlg.UpdateButtons;
begin
ScannersButton.Visible:=false;
{$IFDEF EnableDetach}
{$IFDEF Windows}
HideWindowCheckBox.Visible:=true;
ShowConsoleCheckBox.Visible:=true;
{$ENDIF}
{$ENDIF}
end;
function TExternalToolOptionDlg.ScannersToString(List: TStrings): string;
@ -721,13 +747,13 @@ begin
WorkingDirLabel.Caption:=lisEdtExtToolWorkingDirectory;
OptionsGroupBox.Caption:=lisLazBuildOptions;
with OptionScanOutputForFPCMessagesCheckBox do
// ToDo: add hints
with ScanOutputForFPCMessagesCheckBox do
Caption:=lisEdtExtToolScanOutputForFreePascalCompilerMessages;
with OptionScanOutputForMakeMessagesCheckBox do
with ScanOutputForMakeMessagesCheckBox do
Caption:=lisEdtExtToolScanOutputForMakeMessages;
chkHideMainForm.Caption := lisEdtExtToolHideMainForm;
ShowConsoleCheckBox.Caption:='Show console';
HideWindowCheckBox.Caption:='Hide window';
with KeyGroupBox do
Caption:=lisEdtExtToolKey;

View File

@ -1212,7 +1212,14 @@ begin
{$IF FPC_FULLVERSION<20604}
Proc.InheritHandles:=false;
{$ENDIF}
Proc.Options:=Proc.Options+[poNoConsole];
if ToolOptions.ShowConsole then
Proc.Options:=Proc.Options+[poNewConsole]-[poNoConsole]
else
Proc.Options:=Proc.Options-[poNewConsole]+[poNoConsole];
if ToolOptions.HideWindow then
Proc.ShowWindow:=swoHide
else
Proc.ShowWindow:=swoShow;
try
Proc.Execute;
except
@ -1236,6 +1243,14 @@ begin
if ExtToolConsole=nil then
for i:=0 to ToolOptions.Scanners.Count-1 do
Tool.AddParsers(ToolOptions.Scanners[i]);
if ToolOptions.ShowConsole then
Tool.Process.Options:=Proc.Options+[poNewConsole]-[poNoConsole]
else
Tool.Process.Options:=Proc.Options-[poNewConsole]+[poNoConsole];
if ToolOptions.HideWindow then
Tool.Process.ShowWindow:=swoHide
else
Tool.Process.ShowWindow:=swoShow;
if ToolOptions.ResolveMacros then begin
if not Tool.ResolveMacros then begin
debugln(['Error: (lazarus) [TExternalTools.OnRunExternalTool] failed to resolve macros']);

View File

@ -4031,7 +4031,6 @@ resourcestring
lisEdtExtToolScanOutputForFreePascalCompilerMessages = 'Scan output for '
+'Free Pascal Compiler messages';
lisEdtExtToolScanOutputForMakeMessages = 'Scan output for make messages';
lisEdtExtToolHideMainForm = 'Hide main form';
lisEdtExtToolKey = 'Key';
lisAlternativeKey = 'Alternative key';
lisEdtExtToolMacros = 'Macros';