ide: save/load/edit debugger event log options

git-svn-id: trunk@30534 -
This commit is contained in:
paul 2011-05-03 05:34:26 +00:00
parent a031fab2fc
commit 64f78f5265
3 changed files with 120 additions and 44 deletions

View File

@ -2005,6 +2005,24 @@ const
'DisableGroup'
);
DBGEventNames: array[TDBGEventType] of string = (
{ etDefault } 'Default Color',
{ etBreakpointEvaluation } 'Breakpoint Evaluation',
{ etBreakpointHit } 'Breakpoint Hit',
{ etBreakpointMessage } 'Breakpoint Message',
{ etBreakpointStackDump } 'Breakpoint Stack Dump',
{ etExceptionRaised } 'Exception Raised',
{ etModuleLoad } 'Module Load',
{ etModuleUnload } 'Module Unload',
{ etOutputDebugString } 'Output Debug String',
{ etProcessExit } 'Process Exit',
{ etProcessStart } 'Process Start',
{ etThreadExit } 'Thread Exit',
{ etThreadStart } 'Thread Start',
{ etWindowsMessagePosted } 'Windows Message Posted',
{ etWindowsMessageSent } 'Windows Message Sent');
function DBGCommandNameToCommand(const s: string): TDBGCommand;
function DBGStateNameToState(const s: string): TDBGState;
function DBGBreakPointActionNameToAction(const s: string): TIDEBreakPointAction;

View File

@ -30,13 +30,6 @@ uses
IDEOptionsIntf, EnvironmentOpts;
type
TEventLogColor = record
Name: String;
Foreground: TColor;
Background: TColor;
end;
PEventLogColor = ^TEventLogColor;
{ TDebuggerEventLogOptionsFrame }
TDebuggerEventLogOptionsFrame = class(TAbstractIDEOptionsEditor)
@ -61,6 +54,7 @@ type
procedure ColorTreeClick(Sender: TObject);
procedure ForegroundColorBoxChange(Sender: TObject);
private
FColors: array[TDBGEventType] of TDebuggerEventLogColor;
class function GetCategoryStr(ACategory: TDBGEventCategory): String;
procedure UpdateSelectedColor;
public
@ -78,22 +72,6 @@ implementation
const
COLOR_NODE_PREFIX = ' abc ';
TestColors: array[0..12] of TEventLogColor = (
(Name: 'Default Color'; Foreground: clWindowText; Background: clWindow),
(Name: 'Breakpoint Evaluation';Foreground: clRed; Background: clWindow),
(Name: 'Breakpoint Hit'; Foreground: clRed; Background: clWindow),
(Name: 'Breakpoint Message'; Foreground: clRed; Background: clWindow),
(Name: 'Breakpoint Stack Dump';Foreground: clRed; Background: clWindow),
(Name: 'Exception Raised'; Foreground: clTeal; Background: clWindow),
(Name: 'Module Load'; Foreground: clBlue; Background: clWindow),
(Name: 'Module Unload'; Foreground: clBlue; Background: clWindow),
(Name: 'Output Debug String'; Foreground: clNavy; Background: clWindow),
(Name: 'Process Exit'; Foreground: clGray; Background: clWindow),
(Name: 'Process Start'; Foreground: clGray; Background: clWindow),
(Name: 'Thread Exit'; Foreground: clMaroon; Background: clWindow),
(Name: 'Thread Start'; Foreground: clMaroon; Background: clWindow)
);
{ TDebuggerEventLogOptionsFrame }
procedure TDebuggerEventLogOptionsFrame.ColorTreeAdvancedCustomDrawItem(
@ -105,7 +83,7 @@ var
TextY, OldHeight: Integer;
s: String;
begin
DefaultDraw := (Node.Data = nil) or not (Stage = cdPostPaint);
DefaultDraw := Stage <> cdPostPaint;
if DefaultDraw then
Exit;
@ -124,14 +102,14 @@ begin
FullAbcWidth := Sender.Canvas.TextExtent(COLOR_NODE_PREFIX).cx;
TextY := (NodeRect.Top + NodeRect.Bottom - Sender.Canvas.TextHeight(Node.Text)) div 2;
Sender.Canvas.FillRect(NodeRect);
Sender.Canvas.TextOut(NodeRect.Left + FullAbcWidth, TextY, PEventLogColor(Node.Data)^.Name);
Sender.Canvas.TextOut(NodeRect.Left + FullAbcWidth, TextY, Node.Text);
// Draw preview box - Background
Sender.Canvas.Brush.Color := PEventLogColor(Node.Data)^.Background;
Sender.Canvas.Brush.Color := FColors[TDBGEventType(Node.Index)].Background;
Sender.Canvas.FillRect(NodeRect.Left + 2, NodeRect.Top + 2, NodeRect.Left+FullAbcWidth - 2, NodeRect.Bottom - 2);
s := 'abc';
Sender.Canvas.Font.Color := PEventLogColor(Node.Data)^.Foreground;
Sender.Canvas.Font.Color := FColors[TDBGEventType(Node.Index)].Foreground;
OldHeight := Sender.Canvas.Font.Height;
Sender.Canvas.Font.Height := -(NodeRect.Bottom - NodeRect.Top - 7);
TextY := (NodeRect.Top + NodeRect.Bottom - canvas.TextHeight(s)) div 2;
@ -158,9 +136,9 @@ begin
if Assigned(ColorTree.Selected) then
begin
if (Sender = ForegroundColorBox) then
PEventLogColor(ColorTree.Selected.Data)^.Foreground := ForeGroundColorBox.Selected;
FColors[TDBGEventType(ColorTree.Selected.Index)].Foreground := ForeGroundColorBox.Selected;
if Sender = BackGroundColorBox then
PEventLogColor(ColorTree.Selected.Data)^.Background := BackGroundColorBox.Selected;
FColors[TDBGEventType(ColorTree.Selected.Index)].Background := BackGroundColorBox.Selected;
ColorTree.Invalidate;
end;
end;
@ -195,8 +173,8 @@ begin
BackGroundColorBox.Enabled := Assigned(ColorTree.Selected);
if Assigned(ColorTree.Selected) then
begin
ForegroundColorBox.Selected := PEventLogColor(ColorTree.Selected.Data)^.Foreground;
BackgroundColorBox.Selected := PEventLogColor(ColorTree.Selected.Data)^.Background;
ForegroundColorBox.Selected := FColors[TDBGEventType(ColorTree.Selected.Index)].Foreground;
BackgroundColorBox.Selected := FColors[TDBGEventType(ColorTree.Selected.Index)].Background;
end;
end;
@ -208,8 +186,7 @@ end;
procedure TDebuggerEventLogOptionsFrame.Setup(ADialog: TAbstractOptionsEditorDialog);
var
Category: TDBGEventCategory;
i: integer;
Node: TTreeNode;
i: TDBGEventType;
begin
// general
gbGeneral.Caption := lisGeneral;
@ -226,13 +203,8 @@ begin
chkUseEventLogColors.Caption := lisDebugOptionsFrmUseEventLogColors;
ForeGroundLabel.Caption := dlgForecolor;
BackGroundLabel.Caption := dlgBackColor;
// TODO: colors
// add test colors to check functionality for now
for i := Low(TestColors) to High(TestColors) do
begin
Node := ColorTree.Items.Add(nil, TestColors[i].Name);
Node.Data := @TestColors[i];
end;
for i := Low(DebuggerDefaultColors) to High(DebuggerDefaultColors) do
ColorTree.Items.Add(nil, DBGEventNames[i]);
end;
procedure TDebuggerEventLogOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions);
@ -242,6 +214,8 @@ procedure TDebuggerEventLogOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptio
cbMessages.Checked[Ord(ACategory)] := AChecked;
end;
var
EventType: TDBGEventType;
begin
with AOptions as TEnvironmentOptions do
begin
@ -255,7 +229,11 @@ begin
SetChecked(ecOutput, DebuggerEventLogShowOutput);
SetChecked(ecWindows, DebuggerEventLogShowWindows);
SetChecked(ecDebugger, DebuggerEventLogShowDebugger);
chkUseEventLogColors.Checked := DebuggerEventLogUseColors;
for EventType := Low(TDBGEventType) to High(TDBGEventType) do
FColors[EventType] := DebuggerEventLogColors[EventType];
end;
//chkUseEventLogColorsChange(chkUseEventLogColors);
end;
procedure TDebuggerEventLogOptionsFrame.WriteSettings(AOptions: TAbstractIDEOptions);
@ -265,6 +243,8 @@ procedure TDebuggerEventLogOptionsFrame.WriteSettings(AOptions: TAbstractIDEOpti
Result := cbMessages.Checked[Ord(ACategory)];
end;
var
EventType: TDBGEventType;
begin
with AOptions as TEnvironmentOptions do
begin
@ -278,6 +258,9 @@ begin
DebuggerEventLogShowOutput := GetChecked(ecOutput);
DebuggerEventLogShowWindows := GetChecked(ecWindows);
DebuggerEventLogShowDebugger := GetChecked(ecDebugger);
DebuggerEventLogUseColors := chkUseEventLogColors.Checked;
for EventType := Low(TDBGEventType) to High(TDBGEventType) do
DebuggerEventLogColors[EventType] := FColors[EventType];
end;
end;

View File

@ -37,7 +37,7 @@ uses
{$ifdef Windows}
ShlObj,
{$endif}
Classes, SysUtils, Graphics, Controls, Forms, LCLProc, FileProcs, Dialogs,
Classes, SysUtils, TypInfo, Graphics, Controls, Forms, LCLProc, FileProcs, Dialogs,
Laz_XMLCfg, LazConfigStorage,
// IDEIntf
ProjectIntf, ObjectInspector, IDEWindowIntf, IDEOptionsIntf,
@ -80,8 +80,32 @@ const
'(None)','GNU debugger (gdb)', 'GNU debugger through SSH (gdb)'
);
type
TDebuggerEventLogColor = record
Foreground: TColor;
Background: TColor;
end;
{ Naming }
const
DebuggerDefaultColors: array[TDBGEventType] of TDebuggerEventLogColor = (
{ etDefault } (Foreground: clWindowText; Background: clWindow),
{ etBreakpointEvaluation } (Foreground: clRed; Background: clWindow),
{ etBreakpointHit } (Foreground: clRed; Background: clWindow),
{ etBreakpointMessage } (Foreground: clRed; Background: clWindow),
{ etBreakpointStackDump } (Foreground: clRed; Background: clWindow),
{ etExceptionRaised } (Foreground: clTeal; Background: clWindow),
{ etModuleLoad } (Foreground: clBlue; Background: clWindow),
{ etModuleUnload } (Foreground: clBlue; Background: clWindow),
{ etOutputDebugString } (Foreground: clNavy; Background: clWindow),
{ etProcessExit } (Foreground: clGray; Background: clWindow),
{ etProcessStart } (Foreground: clGray; Background: clWindow),
{ etThreadExit } (Foreground: clMaroon; Background: clWindow),
{ etThreadStart } (Foreground: clMaroon; Background: clWindow),
{ etWindowsMessagePosted } (Foreground: clWhite; Background: clGray),
{ etWindowsMessageSent } (Foreground: clSkyBlue; Background: clWindow)
);
{ Naming }
type
TPascalExtType = (petNone, petPAS, petPP, petP);
@ -261,6 +285,8 @@ type
FDebuggerEventLogShowProcess: Boolean;
FDebuggerEventLogShowThread: Boolean;
FDebuggerEventLogShowWindows: Boolean;
FDebuggerEventLogUseColors: Boolean;
FDebuggerEventLogColors: array[TDBGEventType] of TDebuggerEventLogColor;
// recent files and directories
FRecentOpenFiles: TStringList;
@ -295,7 +321,11 @@ type
FNewFormTemplate: string;
FNewUnitTemplate: string;
function GetDebuggerEventLogColors(AIndex: TDBGEventType
): TDebuggerEventLogColor;
procedure SetCompilerFilename(const AValue: string);
procedure SetDebuggerEventLogColors(AIndex: TDBGEventType;
const AValue: TDebuggerEventLogColor);
procedure SetDebuggerSearchPath(const AValue: string);
procedure SetMakeFilename(const AValue: string);
procedure SetDebuggerFilename(const AValue: string);
@ -476,6 +506,9 @@ type
property DebuggerEventLogShowOutput: Boolean read FDebuggerEventLogShowOutput write FDebuggerEventLogShowOutput;
property DebuggerEventLogShowWindows: Boolean read FDebuggerEventLogShowWindows write FDebuggerEventLogShowWindows;
property DebuggerEventLogShowDebugger: Boolean read FDebuggerEventLogShowDebugger write FDebuggerEventLogShowDebugger;
property DebuggerEventLogUseColors: Boolean read FDebuggerEventLogUseColors write FDebuggerEventLogUseColors;
property DebuggerEventLogColors[AIndex: TDBGEventType]: TDebuggerEventLogColor read GetDebuggerEventLogColors write SetDebuggerEventLogColors;
property CompilerMessagesFilename: string read FCompilerMessagesFilename
write FCompilerMessagesFilename;
property CompilerMessagesFileHistory: TStringList read FCompilerMessagesFileHistory
@ -767,6 +800,8 @@ begin
FDebuggerFileHistory:=TStringList.Create;
FDebuggerProperties := TStringList.Create;
FDebuggerSearchPath:='';
FDebuggerEventLogColors:=DebuggerDefaultColors;
TestBuildDirectory:=GetDefaultTestBuildDirectory;
FTestBuildDirHistory:=TStringList.Create;
CompilerMessagesFilename:='';
@ -877,7 +912,8 @@ begin
end;
procedure TEnvironmentOptions.Load(OnlyDesktop:boolean);
var XMLConfig: TXMLConfig;
var
XMLConfig: TXMLConfig;
FileVersion: integer;
CurDebuggerClass: String;
OldDebuggerType: TDebuggerType;
@ -887,6 +923,7 @@ var XMLConfig: TXMLConfig;
name: String;
Rec: PIDEOptionsGroupRec;
Cfg: TXMLOptionsStorage;
EventType: TDBGEventType;
procedure LoadBackupInfo(var BackupInfo: TBackupInfo; const Path:string);
var i:integer;
@ -1124,6 +1161,19 @@ begin
Path+'Debugger/EventLogShowWindows', False);
FDebuggerEventLogShowDebugger := XMLConfig.GetValue(
Path+'Debugger/EventLogShowDebugger', True);
FDebuggerEventLogUseColors := XMLConfig.GetValue(
Path+'Debugger/EventLogUseColors', True);
for EventType := Low(TDBGEventType) to High(TDBGEventType) do
begin
FDebuggerEventLogColors[EventType].Background :=
XMLConfig.GetValue(Path+'Debugger/EventLogColors/' +
GetEnumName(TypeInfo(EventType), Ord(EventType)) + '/Background',
DebuggerDefaultColors[EventType].Background);
FDebuggerEventLogColors[EventType].Foreground :=
XMLConfig.GetValue(Path+'Debugger/EventLogColors/' +
GetEnumName(TypeInfo(EventType), Ord(EventType)) + '/Foreground',
DebuggerDefaultColors[EventType].Foreground);
end;
end;
// hints
@ -1227,12 +1277,14 @@ begin
end;
procedure TEnvironmentOptions.Save(OnlyDesktop: boolean);
var XMLConfig: TXMLConfig;
var
XMLConfig: TXMLConfig;
Path: String;
i, j: Integer;
name: String;
Rec: PIDEOptionsGroupRec;
Cfg: TXMLOptionsStorage;
EventType: TDBGEventType;
procedure SaveBackupInfo(var BackupInfo: TBackupInfo; Path:string);
var i:integer;
@ -1423,6 +1475,19 @@ begin
FDebuggerEventLogShowWindows, False);
XMLConfig.SetDeleteValue(Path+'Debugger/EventLogShowDebugger',
FDebuggerEventLogShowDebugger, True);
XMLConfig.SetDeleteValue(Path+'Debugger/EventLogUseColors',
FDebuggerEventLogUseColors, True);
for EventType := Low(TDBGEventType) to High(TDBGEventType) do
begin
XMLConfig.SetDeleteValue(Path+'Debugger/EventLogColors/' +
GetEnumName(TypeInfo(EventType), Ord(EventType)) + '/Background',
FDebuggerEventLogColors[EventType].Background,
DebuggerDefaultColors[EventType].Background);
XMLConfig.SetDeleteValue(Path+'Debugger/EventLogColors/' +
GetEnumName(TypeInfo(EventType), Ord(EventType)) + '/Foreground',
FDebuggerEventLogColors[EventType].Foreground,
DebuggerDefaultColors[EventType].Foreground);
end;
end;
// hints
@ -1758,6 +1823,16 @@ begin
FCompilerFilenameParsedStamp:=InvalidParseStamp;
end;
function TEnvironmentOptions.GetDebuggerEventLogColors(AIndex: TDBGEventType): TDebuggerEventLogColor;
begin
Result := FDebuggerEventLogColors[AIndex];
end;
procedure TEnvironmentOptions.SetDebuggerEventLogColors(AIndex: TDBGEventType; const AValue: TDebuggerEventLogColor);
begin
FDebuggerEventLogColors[AIndex] := AValue;
end;
procedure TEnvironmentOptions.SetDebuggerSearchPath(const AValue: string);
var
NewValue: String;