ide: added compiler messages frame

git-svn-id: trunk@23320 -
This commit is contained in:
dmitry 2009-12-30 11:17:28 +00:00
parent b08a1b3733
commit 61f6219bdd
6 changed files with 317 additions and 1 deletions

3
.gitattributes vendored
View File

@ -3459,6 +3459,9 @@ ide/frames/project_i18n_options.pas svneol=native#text/plain
ide/frames/project_lazdoc_options.lfm svneol=native#text/plain
ide/frames/project_lazdoc_options.lrs svneol=native#text/plain
ide/frames/project_lazdoc_options.pas svneol=native#text/plain
ide/frames/project_messages_options.lfm svneol=native#text/plain
ide/frames/project_messages_options.lrs svneol=native#text/plain
ide/frames/project_messages_options.pas svneol=native#text/plain
ide/frames/project_misc_options.lfm svneol=native#text/plain
ide/frames/project_misc_options.lrs svneol=native#text/plain
ide/frames/project_misc_options.pas svneol=native#text/plain

View File

@ -0,0 +1,85 @@
inherited ProjectMessagesOptionsFrame: TProjectMessagesOptionsFrame
Height = 455
Width = 626
ClientHeight = 455
ClientWidth = 626
DesignLeft = 364
DesignTop = 347
object grpCompilerMessages: TGroupBox[0]
Left = 6
Height = 443
Top = 6
Width = 614
Align = alClient
BorderSpacing.Around = 6
Caption = 'grpCompilerMessages'
ClientHeight = 421
ClientWidth = 606
TabOrder = 0
object chkUseMsgFile: TCheckBox
AnchorSideLeft.Control = grpCompilerMessages
AnchorSideTop.Control = editMsgFileName
AnchorSideTop.Side = asrCenter
Left = 6
Height = 18
Top = 8
Width = 113
BorderSpacing.Around = 6
Caption = 'chkUseMsgFile'
OnChange = chkUseMsgFileChange
TabOrder = 0
end
object editMsgFileName: TEdit
AnchorSideLeft.Control = chkUseMsgFile
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = grpCompilerMessages
AnchorSideRight.Control = btnBrowseMsg
Left = 127
Height = 22
Top = 6
Width = 395
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8
BorderSpacing.Top = 6
BorderSpacing.Right = 8
TabOrder = 1
Text = 'editMsgFileName'
end
object btnBrowseMsg: TButton
AnchorSideTop.Control = editMsgFileName
AnchorSideRight.Control = grpCompilerMessages
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = editMsgFileName
AnchorSideBottom.Side = asrBottom
Left = 530
Height = 22
Top = 6
Width = 70
Anchors = [akTop, akRight, akBottom]
AutoSize = True
BorderSpacing.Right = 6
Caption = '...'
OnClick = btnBrowseMsgClick
TabOrder = 2
end
object chklistCompMsg: TCheckListBox
AnchorSideLeft.Control = grpCompilerMessages
AnchorSideTop.Control = editMsgFileName
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = grpCompilerMessages
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = grpCompilerMessages
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 381
Top = 34
Width = 594
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Around = 6
ItemHeight = 0
OnClick = chklistCompMsgClick
Sorted = True
TabOrder = 3
end
end
end

View File

@ -0,0 +1,35 @@
{ This is an automatically generated lazarus resource file }
LazarusResources.Add('TProjectMessagesOptionsFrame','FORMDATA',[
'TPF0'#241#28'TProjectMessagesOptionsFrame'#27'ProjectMessagesOptionsFrame'#6
+'Height'#3#199#1#5'Width'#3'r'#2#12'ClientHeight'#3#199#1#11'ClientWidth'#3
+'r'#2#10'DesignLeft'#3'l'#1#9'DesignTop'#3'['#1#0#242#2#0#9'TGroupBox'#19'gr'
+'pCompilerMessages'#4'Left'#2#6#6'Height'#3#187#1#3'Top'#2#6#5'Width'#3'f'#2
+#5'Align'#7#8'alClient'#20'BorderSpacing.Around'#2#6#7'Caption'#6#19'grpComp'
+'ilerMessages'#12'ClientHeight'#3#165#1#11'ClientWidth'#3'^'#2#8'TabOrder'#2
+#0#0#9'TCheckBox'#13'chkUseMsgFile'#22'AnchorSideLeft.Control'#7#19'grpCompi'
+'lerMessages'#21'AnchorSideTop.Control'#7#15'editMsgFileName'#18'AnchorSideT'
+'op.Side'#7#9'asrCenter'#4'Left'#2#6#6'Height'#2#18#3'Top'#2#8#5'Width'#2'q'
+#20'BorderSpacing.Around'#2#6#7'Caption'#6#13'chkUseMsgFile'#8'OnChange'#7#19
+'chkUseMsgFileChange'#8'TabOrder'#2#0#0#0#5'TEdit'#15'editMsgFileName'#22'An'
+'chorSideLeft.Control'#7#13'chkUseMsgFile'#19'AnchorSideLeft.Side'#7#9'asrBo'
+'ttom'#21'AnchorSideTop.Control'#7#19'grpCompilerMessages'#23'AnchorSideRigh'
+'t.Control'#7#12'btnBrowseMsg'#4'Left'#2#127#6'Height'#2#22#3'Top'#2#6#5'Wid'
+'th'#3#139#1#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#18'BorderSpacing.'
+'Left'#2#8#17'BorderSpacing.Top'#2#6#19'BorderSpacing.Right'#2#8#8'TabOrder'
+#2#1#4'Text'#6#15'editMsgFileName'#0#0#7'TButton'#12'btnBrowseMsg'#21'Anchor'
+'SideTop.Control'#7#15'editMsgFileName'#23'AnchorSideRight.Control'#7#19'grp'
+'CompilerMessages'#20'AnchorSideRight.Side'#7#9'asrBottom'#24'AnchorSideBott'
+'om.Control'#7#15'editMsgFileName'#21'AnchorSideBottom.Side'#7#9'asrBottom'#4
+'Left'#3#18#2#6'Height'#2#22#3'Top'#2#6#5'Width'#2'F'#7'Anchors'#11#5'akTop'
+#7'akRight'#8'akBottom'#0#8'AutoSize'#9#19'BorderSpacing.Right'#2#6#7'Captio'
+'n'#6#3'...'#7'OnClick'#7#17'btnBrowseMsgClick'#8'TabOrder'#2#2#0#0#13'TChec'
+'kListBox'#14'chklistCompMsg'#22'AnchorSideLeft.Control'#7#19'grpCompilerMes'
+'sages'#21'AnchorSideTop.Control'#7#15'editMsgFileName'#18'AnchorSideTop.Sid'
+'e'#7#9'asrBottom'#23'AnchorSideRight.Control'#7#19'grpCompilerMessages'#20
+'AnchorSideRight.Side'#7#9'asrBottom'#24'AnchorSideBottom.Control'#7#19'grpC'
+'ompilerMessages'#21'AnchorSideBottom.Side'#7#9'asrBottom'#4'Left'#2#6#6'Hei'
+'ght'#3'}'#1#3'Top'#2'"'#5'Width'#3'R'#2#7'Anchors'#11#5'akTop'#6'akLeft'#7
+'akRight'#8'akBottom'#0#20'BorderSpacing.Around'#2#6#10'ItemHeight'#2#0#7'On'
+'Click'#7#19'chklistCompMsgClick'#6'Sorted'#9#8'TabOrder'#2#3#0#0#0#0
]);

View File

@ -0,0 +1,184 @@
unit project_messages_options;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, StdCtrls, CheckLst,
Dialogs,
IDEOptionsIntf, Project,
LazarusIDEStrConsts,
CompilerOptions;
type
{ TProjectMessagesOptionsFrame }
TProjectMessagesOptionsFrame = class(TAbstractIDEOptionsEditor)
btnBrowseMsg: TButton;
chklistCompMsg: TCheckListBox;
chkUseMsgFile: TCheckBox;
editMsgFileName: TEdit;
grpCompilerMessages: TGroupBox;
procedure btnBrowseMsgClick(Sender: TObject);
procedure chklistCompMsgClick(Sender: TObject);
procedure chkUseMsgFileChange(Sender: TObject);
private
{ private declarations }
TempMessages: TCompilerMessagesList;
procedure UpdateMessages;
public
{ public declarations }
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
function GetTitle: String; override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
end;
implementation
{ TProjectMessagesOptionsFrame }
procedure TProjectMessagesOptionsFrame.chkUseMsgFileChange(Sender: TObject);
begin
UpdateMessages;
end;
procedure TProjectMessagesOptionsFrame.chklistCompMsgClick(Sender: TObject);
var
i : Integer;
begin
for i := 0 to chklistCompMsg.Count - 1 do
TCompilerMessageConfig(chklistCompMsg.Items.Objects[i]).Ignored := not chklistCompMsg.Checked[i];
end;
procedure TProjectMessagesOptionsFrame.btnBrowseMsgClick(Sender: TObject);
var
dlg : TOpenDialog;
begin
dlg := TOpenDialog.Create(Self);
try
dlg.Filter := dlgBrowseMsgFilter;
if not dlg.Execute then Exit;
editMsgFileName.Caption := dlg.FileName;
UpdateMessages;
finally
dlg.Free
end;
end;
procedure TProjectMessagesOptionsFrame.UpdateMessages;
const
MaxIndexLen = 5;
var
i : Integer;
j : Integer;
topidx : Integer;
m : TCompilerMessageConfig;
function IntToStrLen(idx, strlen: integer): string;
var
s : string;
begin
Result := IntToStr(idx);
if length(Result) < strlen then begin
SetLength(s, strlen - length(Result));
FillChar(s[1], length(s), '0');
Result := s + Result;
end;
end;
begin
topidx := chklistCompMsg.TopIndex;
chklistCompMsg.Items.BeginUpdate;
try
if chkUseMsgFile.Checked and FileExistsUTF8(editMsgFileName.Caption) and (editMsgFileName.Caption <> '') then begin
try
// FPC messages file is expected to be UTF8 encoded, no matter for the current code page is
TempMessages.LoadMsgFile(editMsgFileName.Caption, true);
except
TempMessages.SetDefault;
end;
end else
TempMessages.SetDefault;
chklistCompMsg.Clear;
chklistCompMsg.Items.Clear;
for i := 0 to TempMessages.Count - 1 do begin
m := TempMessages.Msg[i];
j := chklistCompMsg.Items.AddObject( Format('(%s) %s', [m.MsgType, m.GetUserText]), m);
chklistCompMsg.Checked[j] := not m.Ignored;
end;
finally
chklistCompMsg.Items.EndUpdate;
chkListCompMsg.TopIndex := topidx;
end;
end;
constructor TProjectMessagesOptionsFrame.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
TempMessages:=TCompilerMessagesList.Create;
end;
destructor TProjectMessagesOptionsFrame.Destroy;
begin
TempMessages.Free;
inherited Destroy;
end;
function TProjectMessagesOptionsFrame.GetTitle: String;
begin
Result:=dlgCOCfgCmpMessages;
end;
procedure TProjectMessagesOptionsFrame.Setup(ADialog: TAbstractOptionsEditorDialog);
begin
grpCompilerMessages.Caption := dlgCompilerMessage;
chkUseMsgFile.Caption := dlgUseMsgFile;
editMsgFileName.Caption := '';
end;
procedure TProjectMessagesOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions);
begin
chkUseMsgFile.OnChange := nil;
try
with AOptions as TProject do begin
chkUseMsgFile.Checked := CompilerOptions.UseMsgFile;
editMsgFileName.Caption := CompilerOptions.MsgFileName;
TempMessages.Assign(CompilerOptions.CompilerMessages);
UpdateMessages;
end;
finally
chkUseMsgFile.OnChange := @chkUseMsgFileChange;
end;
end;
procedure TProjectMessagesOptionsFrame.WriteSettings(AOptions: TAbstractIDEOptions);
begin
with AOptions as TProject do
begin
CompilerOptions.UseMsgFile := chkUseMsgFile.Checked;
CompilerOptions.MsgFileName := editMsgFileName.Caption;
CompilerOptions.CompilerMessages.Assign(TempMessages);
end;
end;
class function TProjectMessagesOptionsFrame.SupportedOptionsClass: TAbstractIDEOptionsClass;
begin
Result:=TProject;
end;
initialization
{$I project_messages_options.lrs}
RegisterIDEOptionsEditor(GroupCompiler, TProjectMessagesOptionsFrame, 500{todo: CompilerOptionsMessages});
end.

View File

@ -43,7 +43,7 @@
<PackageName Value="SynEdit"/>
</Item4>
</RequiredPackages>
<Units Count="59">
<Units Count="60">
<Unit0>
<Filename Value="lazarus.pp"/>
<IsPartOfProject Value="True"/>
@ -449,6 +449,13 @@
<ResourceBaseClass Value="Frame"/>
<UnitName Value="project_misc_options"/>
</Unit58>
<Unit59>
<Filename Value="frames/project_messages_options.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="ProjectMessagesOptionsFrame"/>
<ResourceBaseClass Value="Frame"/>
<UnitName Value="project_messages_options"/>
</Unit59>
</Units>
</ProjectOptions>
<CompilerOptions>

View File

@ -125,6 +125,8 @@ uses
project_application_options, project_forms_options, project_lazdoc_options,
project_save_options, project_versioninfo_options, project_i18n_options,
project_misc_options,
// project compiler options
project_messages_options,
PublishModule, EnvironmentOpts, TransferMacros, KeyMapping, IDETranslations,
IDEProcs, ExtToolDialog, ExtToolEditDlg, OutputFilter, JumpHistoryView,