File: ps_debugger_page.cpp

package info (click to toggle)
codelite 12.0+dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 95,112 kB
  • sloc: cpp: 424,040; ansic: 18,284; php: 9,569; lex: 4,186; yacc: 2,820; python: 2,294; sh: 312; makefile: 51; xml: 13
file content (180 lines) | stat: -rw-r--r-- 6,599 bytes parent folder | download | duplicates (2)
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
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// copyright            : (C) 2014 Eran Ifrah
// file name            : ps_debugger_page.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 "ps_debugger_page.h"
#include <wx/filename.h>
#include <wx/filedlg.h>
#include <wx/dirdlg.h>
#include <project.h>
#include <workspace.h>
#include <wx/filedlg.h>
#include "globals.h"

PSDebuggerPage::PSDebuggerPage( wxWindow* parent, ProjectSettingsDlg* dlg )
    : PSDebuggerPageBase( parent )
    , m_dlg(dlg)
{
}

void PSDebuggerPage::OnCmdEvtVModified( wxCommandEvent& event )
{
    wxUnusedVar(event);
    m_dlg->SetIsDirty(true);
}

void PSDebuggerPage::OnRemoteDebugUI( wxUpdateUIEvent& event )
{
    event.Enable(m_checkBoxDbgRemote->IsChecked());
}

void PSDebuggerPage::Load(BuildConfigPtr buildConf)
{
    Clear();
    m_textCtrlDbgCmds->ChangeValue(buildConf->GetDebuggerStartupCmds());
    m_textCtrlDbgPostConnectCmds->ChangeValue(buildConf->GetDebuggerPostRemoteConnectCmds());
    m_checkBoxDbgRemote->SetValue(buildConf->GetIsDbgRemoteTarget());
    m_textCtrl1DbgHost->ChangeValue(buildConf->GetDbgHostName());
    m_textCtrlDbgPort->ChangeValue(buildConf->GetDbgHostPort());
    m_textCtrlDebuggerPath->ChangeValue(buildConf->GetDebuggerPath());
    m_checkBoxDbgRemoteExt->SetValue(buildConf->GetIsDbgRemoteExtended());

    const wxArrayString &searchPaths = buildConf->GetDebuggerSearchPaths();
    for(size_t i=0; i<searchPaths.GetCount(); ++i) {
        wxVector<wxVariant> cols;
        cols.push_back( searchPaths.Item(i) );
        m_dvListCtrlDebuggerSearchPaths->AppendItem( cols , (wxUIntPtr)NULL );
    }
}

void PSDebuggerPage::Save(BuildConfigPtr buildConf, ProjectSettingsPtr projSettingsPtr)
{
    buildConf->SetDebuggerStartupCmds(m_textCtrlDbgCmds->GetValue());
    buildConf->SetDebuggerPostRemoteConnectCmds(m_textCtrlDbgPostConnectCmds->GetValue());
    buildConf->SetIsDbgRemoteTarget(m_checkBoxDbgRemote->IsChecked());
    buildConf->SetDbgHostName(m_textCtrl1DbgHost->GetValue());
    buildConf->SetDbgHostPort(m_textCtrlDbgPort->GetValue());
    buildConf->SetDebuggerPath(m_textCtrlDebuggerPath->GetValue());
    buildConf->SetIsDbgRemoteExtended(m_checkBoxDbgRemoteExt->IsChecked());

    wxArrayString searchPaths;
    int nCount = m_dvListCtrlDebuggerSearchPaths->GetItemCount();
    for(int i=0; i<nCount; ++i) {
        wxVariant colValue;
        m_dvListCtrlDebuggerSearchPaths->GetValue(colValue, i, 0);
        if ( !colValue.IsNull() ) {
            searchPaths.Add( colValue.GetString() );
        }
    }
    buildConf->SetDebuggerSearchPaths(searchPaths);
}

void PSDebuggerPage::Clear()
{
    m_textCtrlDebuggerPath->Clear();
    m_textCtrl1DbgHost->Clear();
    m_textCtrlDbgCmds->Clear();
    m_textCtrlDbgPort->Clear();
    m_textCtrlDbgPostConnectCmds->Clear();
    m_dvListCtrlDebuggerSearchPaths->DeleteAllItems();
    m_checkBoxDbgRemote->SetValue(false);
}

void PSDebuggerPage::OnBrowseForDebuggerPath(wxCommandEvent& event)
{
    wxString debugger_path = ::wxFileSelector(_("Select debugger:"));

    if ( !debugger_path.IsEmpty() ) {
        wxString errMsg;
        ProjectPtr proj = clCxxWorkspaceST::Get()->FindProjectByName(m_dlg->GetProjectName(), errMsg);
        if ( proj ) {
            wxFileName fnDebuggerPath( debugger_path );
            wxString project_path = proj->GetFileName().GetPath();
            if ( fnDebuggerPath.MakeRelativeTo( project_path ) ) {
                debugger_path = fnDebuggerPath.GetFullPath();
            }
        }
        m_textCtrlDebuggerPath->ChangeValue( debugger_path );
        m_dlg->SetIsDirty(true);
    }
}
void PSDebuggerPage::OnAddDebuggerSearchPath(wxCommandEvent& event)
{
    wxString path = ::wxDirSelector();
    if ( !path.IsEmpty() ) {
        wxVector<wxVariant> cols;
        cols.push_back( path );
        m_dvListCtrlDebuggerSearchPaths->AppendItem(cols, (wxUIntPtr)NULL);
        m_dlg->SetIsDirty(true);
    }
}

void PSDebuggerPage::OnDeleteDebuggerSearchPath(wxCommandEvent& event)
{
    wxDataViewItemArray items;
    m_dvListCtrlDebuggerSearchPaths->GetSelections( items );
    if ( items.IsEmpty() )
        return;

    for(size_t i=0; i<items.GetCount(); ++i) {
        m_dvListCtrlDebuggerSearchPaths->DeleteItem( m_dvListCtrlDebuggerSearchPaths->ItemToRow( items.Item(i) ) );
    }
    m_dlg->SetIsDirty(true);
}

void PSDebuggerPage::OnDeleteDebuggerSearchPathUI(wxUpdateUIEvent& event)
{
    event.Enable( m_dvListCtrlDebuggerSearchPaths->GetSelectedItemsCount() );
}

void PSDebuggerPage::OnItemActivated(wxDataViewEvent& event)
{
    wxVariant value;
    m_dvListCtrlDebuggerSearchPaths->GetValue(value, m_dvListCtrlDebuggerSearchPaths->ItemToRow(event.GetItem()), 0);

    if ( !value.IsNull() ) {

        wxString path = value.GetString();
        path = ::wxDirSelector(_("Select a folder"), path);

        if ( !path.IsEmpty() ) {
            m_dvListCtrlDebuggerSearchPaths->DeleteItem( m_dvListCtrlDebuggerSearchPaths->ItemToRow(event.GetItem()) );
            ::PostCall(this, (clEventFunc_t) &PSDebuggerPage::DoAddPath, new wxStringClientData(path));

        }
    }
}

void PSDebuggerPage::DoAddPath(wxStringClientData* path)
{
    wxVector<wxVariant> cols;
    cols.push_back( path->GetData() );
    m_dvListCtrlDebuggerSearchPaths->AppendItem(cols, (wxUIntPtr)NULL);
    m_dlg->SetIsDirty(true);
}

void PSDebuggerPage::OnProjectEnabledUI(wxUpdateUIEvent& event)
{
    event.Enable( m_dlg->IsProjectEnabled() );
}