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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
|
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// copyright : (C) 2008 by Eran Ifrah
// file name : debuggersettingsdlg.cpp
//
// -------------------------------------------------------------------------
// A
// _____ _ _ _ _
// / __ \ | | | | (_) |
// | / \/ ___ __| | ___| | _| |_ ___
// | | / _ \ / _ |/ _ \ | | | __/ _ )
// | \__/\ (_) | (_| | __/ |___| | || __/
// \____/\___/ \__,_|\___\_____/_|\__\___|
//
// F i l e
//
// This program 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.
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
#include "debuggersettingsdlg.h"
#include "windowattrmanager.h"
#include "editor_config.h"
#include "debuggermanager.h"
#include "macros.h"
#include "manager.h"
#include "globals.h"
#include "dbgcommanddlg.h"
#include "debuggerconfigtool.h"
//-------------------------------------------------------------------
DebuggerPage::DebuggerPage(wxWindow *parent, wxString title)
: DebuggerPageBase(parent)
, m_title(title)
{
DebuggerInformation info;
if(DebuggerMgr::Get().GetDebuggerInformation(m_title, info)){
m_textCtrDbgPath->SetValue(info.path);
m_checkBoxEnableLog->SetValue(info.enableDebugLog);
m_checkBoxEnablePendingBreakpoints->SetValue(info.enablePendingBreakpoints);
m_checkBreakAtWinMain->SetValue(info.breakAtWinMain);
m_checkShowTerminal->SetValue(info.showTerminal);
m_checkUseRelativePaths->SetValue(info.useRelativeFilePaths);
m_catchThrow->SetValue(info.catchThrow);
m_spinCtrlNumElements->SetValue(info.maxDisplayStringSize);
m_showTooltips->SetValue(info.showTooltips);
m_textCtrlStartupCommands->SetValue( info.startupCommands );
m_checkBoxExpandLocals->SetValue(info.resolveLocals);
#ifdef __WXMSW__
m_checkBoxDebugAssert->SetValue(info.debugAsserts);
#endif
}
#ifndef __WXMSW__
m_checkBoxDebugAssert->SetValue(false);
m_checkBoxDebugAssert->Enable(false);
#endif
}
DebuggerPage::~DebuggerPage()
{
}
void DebuggerPage::OnBrowse(wxCommandEvent& e)
{
wxUnusedVar(e);
wxString newfilepath, filepath(m_textCtrDbgPath->GetValue());
if ((!filepath.IsEmpty()) && wxFileName::FileExists(filepath)) {
newfilepath = wxFileSelector(wxT("Select file:"), filepath.c_str());
} else {
newfilepath = wxFileSelector(wxT("Select file:"));
}
if (!newfilepath.IsEmpty()) {
m_textCtrDbgPath->SetValue(newfilepath);
}
}
void DebuggerPage::OnDebugAssert(wxCommandEvent& e)
{
if ( e.IsChecked() ) {
m_checkBoxEnablePendingBreakpoints->SetValue(true);
}
}
//-------------------------------------------------------------------
DebuggerSettingsDlg::DebuggerSettingsDlg( wxWindow* parent )
:DebuggerSettingsBaseDlg( parent )
, m_selectedItem(wxNOT_FOUND)
{
//fill the notebook with the available debuggers
Initialize();
ConnectButton(m_buttonOK, DebuggerSettingsDlg::OnOk);
// center the dialog
Centre();
m_listCtrl1->SetFocus();
GetSizer()->Fit(this);
WindowAttrManager::Load(this, wxT("DbgSettingsDlg"), NULL);
}
void DebuggerSettingsDlg::Initialize()
{
DebuggerMgr &mgr = DebuggerMgr::Get();
wxArrayString debuggers = mgr.GetAvailableDebuggers();
for (size_t i=0; i<debuggers.GetCount(); i++) {
//create page per-debugger
m_book->AddPage(new DebuggerPage(m_book, debuggers.Item(i)), debuggers.Item(i), true);
}
m_listCtrl1->InsertColumn(0, wxT("Type"));
m_listCtrl1->InsertColumn(1, wxT("Expression"));
m_listCtrl1->InsertColumn(2, wxT("Debugger Command"));
//add items from the saved items
DebuggerConfigTool::Get()->ReadObject(wxT("DebuggerCommands"), &m_data);
//Populate the list with the items from the configuration file
std::vector<DebuggerCmdData> cmds = m_data.GetCmds();
for (size_t i=0; i<cmds.size(); i++) {
DebuggerCmdData cmd = cmds.at(i);
long item = AppendListCtrlRow(m_listCtrl1);
SetColumnText(m_listCtrl1, item, 0, cmd.GetName());
SetColumnText(m_listCtrl1, item, 1, cmd.GetCommand());
SetColumnText(m_listCtrl1, item, 2, cmd.GetDbgCommand());
}
m_listCtrl1->SetColumnWidth(0, 100);
m_listCtrl1->SetColumnWidth(1, 200);
}
void DebuggerSettingsDlg::OnOk(wxCommandEvent &e)
{
wxUnusedVar(e);
//go over the debuggers and set the debugger path
for (size_t i=0; i<(size_t)m_book->GetPageCount(); i++) {
DebuggerPage *page = (DebuggerPage *)m_book->GetPage(i);
//find the debugger
DebuggerInformation info;
DebuggerMgr::Get().GetDebuggerInformation(page->m_title, info);
//populate the information and save it
info.enableDebugLog = page->m_checkBoxEnableLog->GetValue();
info.enablePendingBreakpoints = page->m_checkBoxEnablePendingBreakpoints->GetValue();
info.path = page->m_textCtrDbgPath->GetValue();
info.name = page->m_title;
info.breakAtWinMain = page->m_checkBreakAtWinMain->IsChecked();
info.showTerminal = page->m_checkShowTerminal->IsChecked();
info.consoleCommand = EditorConfigST::Get()->GetOptions()->GetProgramConsoleCommand();
info.useRelativeFilePaths = page->m_checkUseRelativePaths->IsChecked();
info.catchThrow = page->m_catchThrow->IsChecked();
info.showTooltips = page->m_showTooltips->IsChecked();
info.startupCommands = page->m_textCtrlStartupCommands->GetValue();
info.maxDisplayStringSize = page->m_spinCtrlNumElements->GetValue();
info.resolveLocals = page->m_checkBoxExpandLocals->IsChecked();
#ifdef __WXMSW__
info.debugAsserts = page->m_checkBoxDebugAssert->IsChecked();
#endif
DebuggerMgr::Get().SetDebuggerInformation(page->m_title, info);
}
//copy the commands the serialized object m_data
int count = m_listCtrl1->GetItemCount();
std::vector<DebuggerCmdData> cmdArr;
for(int i=0; i<count; i++){
DebuggerCmdData cmd;
cmd.SetName ( GetColumnText(m_listCtrl1, i, 0) );
cmd.SetCommand ( GetColumnText(m_listCtrl1, i, 1) );
cmd.SetDbgCommand( GetColumnText(m_listCtrl1, i, 2) );
cmdArr.push_back(cmd);
}
m_data.SetCmds(cmdArr);
//save the debugger commands
DebuggerConfigTool::Get()->WriteObject(wxT("DebuggerCommands"), &m_data);
EndModal(wxID_OK);
}
void DebuggerSettingsDlg::OnButtonCancel(wxCommandEvent &e)
{
wxUnusedVar(e);
EndModal(wxID_CANCEL);
}
void DebuggerSettingsDlg::OnNewShortcut(wxCommandEvent &e)
{
wxUnusedVar(e);
DbgCommandDlg *dlg = new DbgCommandDlg(this);
if (dlg->ShowModal() == wxID_OK) {
//add new command to the table
wxString name = dlg->GetName();
wxString expression = dlg->GetExpression();
wxString dbgCmd = dlg->GetDbgCommand();
long item;
wxListItem info;
//make sure that the expression does not exist
int count = m_listCtrl1->GetItemCount();
for(int i=0; i<count; i++){
wxString existingName = GetColumnText(m_listCtrl1, i, 0);
if(name == existingName){
dlg->Destroy();
wxMessageBox(_("Debugger type with the same name already exist"), wxT("CodeLite"), wxOK | wxICON_INFORMATION);
return;
}
}
// Set the item display name
info.SetColumn(0);
item = m_listCtrl1->InsertItem(info);
SetColumnText(m_listCtrl1, item, 0, name );
SetColumnText(m_listCtrl1, item, 1, expression );
SetColumnText(m_listCtrl1, item, 2, dbgCmd);
m_listCtrl1->SetColumnWidth(0, 100);
m_listCtrl1->SetColumnWidth(1, 200);
m_listCtrl1->SetColumnWidth(1, 200);
}
dlg->Destroy();
}
void DebuggerSettingsDlg::OnItemSelected(wxListEvent &e)
{
m_selectedItem = e.m_itemIndex;
}
void DebuggerSettingsDlg::OnItemDeselected(wxListEvent &e)
{
wxUnusedVar(e);
m_selectedItem = wxNOT_FOUND;
}
void DebuggerSettingsDlg::OnEditShortcut(wxCommandEvent &e)
{
wxUnusedVar(e);
DoEditItem();
}
void DebuggerSettingsDlg::OnDeleteShortcut(wxCommandEvent &e)
{
wxUnusedVar(e);
DoDeleteItem();
}
void DebuggerSettingsDlg::OnItemActivated(wxListEvent &e)
{
m_selectedItem = e.m_itemIndex;
DoEditItem();
}
void DebuggerSettingsDlg::DoEditItem()
{
//Edit the selection
if (m_selectedItem == wxNOT_FOUND) {
return;
}
//popup edit dialog
DbgCommandDlg dlg(this);
wxString name = GetColumnText(m_listCtrl1, m_selectedItem, 0);
wxString expr = GetColumnText(m_listCtrl1, m_selectedItem, 1);
wxString dbgCmd= GetColumnText(m_listCtrl1, m_selectedItem, 2);
dlg.SetName(name);
dlg.SetExpression(expr);
dlg.SetDbgCommand(dbgCmd);
if (dlg.ShowModal() == wxID_OK) {
SetColumnText(m_listCtrl1, m_selectedItem, 0, dlg.GetName());
SetColumnText(m_listCtrl1, m_selectedItem, 1, dlg.GetExpression());
SetColumnText(m_listCtrl1, m_selectedItem, 2, dlg.GetDbgCommand());
}
}
void DebuggerSettingsDlg::DoDeleteItem()
{
if (m_selectedItem == wxNOT_FOUND) {
return;
}
m_listCtrl1->DeleteItem(m_selectedItem);
m_selectedItem = wxNOT_FOUND;
}
DebuggerSettingsDlg::~DebuggerSettingsDlg()
{
WindowAttrManager::Save(this, wxT("DbgSettingsDlg"), NULL);
}
|