1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
|
{
***************************************************************************
* *
* This source is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This code is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* General Public License for more details. *
* *
* A copy of the GNU General Public License is available on the World *
* Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
* obtain it by writing to the Free Software Foundation, *
* Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1335, USA. *
* *
***************************************************************************
}
unit debugger_language_exceptions_options;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils,
// LCL
Forms, Controls, StdCtrls, CheckLst, Buttons, Dialogs,
// IdeIntf
IDEImagesIntf, IDEOptionsIntf, IDEOptEditorIntf,
// IDE
LazarusIDEStrConsts, Debugger, BaseDebugManager;
type
{ TDebuggerLanguageExceptionsOptions }
TDebuggerLanguageExceptionsOptions = class(TAbstractIDEOptionsEditor)
bgIgnoreExceptions: TGroupBox;
chkNotifyOnException: TCheckBox;
clbExceptions: TCheckListBox;
cmdExceptionAdd: TBitBtn;
cmdExceptionRemove: TBitBtn;
DbgLangExceptHint: TLabel;
procedure clbExceptionsClick(Sender: TObject);
procedure cmdExceptionAddClick(Sender: TObject);
procedure cmdExceptionRemoveClick(Sender: TObject);
private
FExceptionDeleteList: TStringList;
procedure AddExceptionLine(const AException: TIDEException; AName: String);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function GetTitle: String; override;
procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings({%H-}AOptions: TAbstractIDEOptions); override;
procedure WriteSettings({%H-}AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
end;
implementation
{$R *.lfm}
{ TDebuggerLanguageExceptionsOptions }
procedure TDebuggerLanguageExceptionsOptions.cmdExceptionAddClick(
Sender: TObject);
var
idx: Integer;
S: String;
begin
S:='';
if not InputQuery(lisDebugOptionsFrmAddException, lisDebugOptionsFrmEnterExceptionName, S)
then Exit;
if clbExceptions.Items.IndexOf(S) = -1
then begin
idx := FExceptionDeleteList.IndexOf(S);
if idx = -1
then begin
AddExceptionLine(nil, S);
end
else begin
AddExceptionLine(TIDEException(FExceptionDeleteList.Objects[idx]), S);
FExceptionDeleteList.Delete(idx);
end;
end
else begin
MessageDlg(lisDebugOptionsFrmDuplicateExceptionName, mtError, [mbOK], 0);
end;
end;
procedure TDebuggerLanguageExceptionsOptions.clbExceptionsClick(Sender: TObject);
begin
cmdExceptionRemove.Enabled := clbExceptions.ItemIndex <> -1;
end;
procedure TDebuggerLanguageExceptionsOptions.cmdExceptionRemoveClick(
Sender: TObject);
var
idx: Integer;
obj: TObject;
begin
idx := clbExceptions.ItemIndex;
if idx <> -1
then begin
obj := clbExceptions.Items.Objects[idx];
if obj <> nil
then FExceptionDeleteList.AddObject(clbExceptions.Items[idx], obj);
clbExceptions.Items.Delete(idx);
end;
cmdExceptionRemove.Enabled := clbExceptions.ItemIndex <> -1;
end;
procedure TDebuggerLanguageExceptionsOptions.AddExceptionLine(
const AException: TIDEException; AName: String);
var
idx: Integer;
begin
if (AName = '') and (AException <> nil)
then AName := AException.Name;
if AName = '' then Exit;
idx := clbExceptions.Items.AddObject(AName, AException);
clbExceptions.Checked[idx] := (AException = nil) or AException.Enabled;
end;
constructor TDebuggerLanguageExceptionsOptions.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FExceptionDeleteList := TStringList.Create;
FExceptionDeleteList.Sorted := True;
end;
destructor TDebuggerLanguageExceptionsOptions.Destroy;
begin
FreeAndNil(FExceptionDeleteList);
inherited Destroy;
end;
function TDebuggerLanguageExceptionsOptions.GetTitle: String;
begin
Result := lisDebugOptionsFrmLanguageExceptions;
end;
procedure TDebuggerLanguageExceptionsOptions.Setup(
ADialog: TAbstractOptionsEditorDialog);
begin
bgIgnoreExceptions.Caption := lisDebugOptionsFrmIgnoreTheseExceptions;
DbgLangExceptHint.Caption := lisTheseSettingsAreStoredWithTheProject;
cmdExceptionRemove.Caption := lisRemove;
cmdExceptionAdd.Caption := lisAdd;
IDEImages.AssignImage(cmdExceptionRemove, 'laz_delete');
IDEImages.AssignImage(cmdExceptionAdd, 'laz_add');
chkNotifyOnException.Caption := lisDebugOptionsFrmNotifyOnLazarusExceptions;
end;
procedure TDebuggerLanguageExceptionsOptions.ReadSettings(
AOptions: TAbstractIDEOptions);
var
n: integer;
begin
chkNotifyOnException.Checked := not DebugBoss.Exceptions.IgnoreAll;
for n := 0 to DebugBoss.Exceptions.Count - 1 do
AddExceptionLine(DebugBoss.Exceptions[n], '');
end;
procedure TDebuggerLanguageExceptionsOptions.WriteSettings(
AOptions: TAbstractIDEOptions);
var
n: integer;
ie: TIDEException;
begin
for n := 0 to FExceptionDeleteList.Count - 1 do
FExceptionDeleteList.Objects[n].Free;
for n := 0 to clbExceptions.Items.Count - 1 do
begin
ie := TIDEException(clbExceptions.Items.Objects[n]);
if ie = nil
then begin
ie := DebugBoss.Exceptions.Add(clbExceptions.Items[n]);
ie.Enabled := clbExceptions.Checked[n];
end
else begin
ie.BeginUpdate;
try
ie.Name := clbExceptions.Items[n];
ie.Enabled := clbExceptions.Checked[n];
finally
ie.EndUpdate;
end;
end;
end;
DebugBoss.Exceptions.IgnoreAll := not chkNotifyOnException.Checked;
end;
class function TDebuggerLanguageExceptionsOptions.SupportedOptionsClass: TAbstractIDEOptionsClass;
begin
Result := TDebuggerOptions;
end;
initialization
RegisterIDEOptionsEditor(GroupDebugger, TDebuggerLanguageExceptionsOptions, DbgOptionsLanguageExceptions);
end.
|