~quadrispro/codelite/trunk

1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1
//////////////////////////////////////////////////////////////////////////////
2
//////////////////////////////////////////////////////////////////////////////
3
//
4
// copyright            : (C) 2008 by Eran Ifrah
5
// file name            : manager.cpp
6
//
7
// -------------------------------------------------------------------------
8
// A
9
//              _____           _      _     _ _
10
//             /  __ \         | |    | |   (_) |
11
//             | /  \/ ___   __| | ___| |    _| |_ ___
12
//             | |    / _ \ / _  |/ _ \ |   | | __/ _ )
13
//             | \__/\ (_) | (_| |  __/ |___| | ||  __/
14
//              \____/\___/ \__,_|\___\_____/_|\__\___|
15
//
16
//                                                  F i l e
17
//
18
//    This program is free software; you can redistribute it and/or modify
19
//    it under the terms of the GNU General Public License as published by
20
//    the Free Software Foundation; either version 2 of the License, or
21
//    (at your option) any later version.
22
//
23
//////////////////////////////////////////////////////////////////////////////
24
//////////////////////////////////////////////////////////////////////////////
25
#include "precompiled_header.h"
2651 by eranif
- Environment variables: Workspace without a environment set will use the global one
26
#include "environmentconfig.h"
27
#include "evnvarlist.h"
2472 by eranif
- moved incldue finder code to differnt lexer to avoid clashing
28
#include "crawler_include.h"
2470 by eranif
- Code Refactoring: moved code from Builder interface to the Builder GNU make
29
#include "renamefiledlg.h"
3211 by eranif
- completed the clang code, codelite can now use clang for its code completion (disabled for now until it will get sablized and more tested). In any case, the clang will not replace the current completion, it will only be as second code completion that will be triggered incase the primary code completion fails
30
#include "clang_code_completion.h"
2350 by eranif
- Debugger: 'Locals' now uses table instead of tree. This new method is much more stable and accurtate than the previous one used. d-clicking on an item, will automatically show the 'display variable' dialog with the item de-referenced
31
#include "localstable.h"
2324 by eranif
- added support for new quick watch dialog (not yet enabled)
32
#include "new_quick_watch_dlg.h"
2109 by eranif
- Fixed regression: 'New Class' from context virtual folder context menu now working again
33
#include "debuggerconfigtool.h"
34
#include "debuggersettings.h"
1991 by eranif
- Fixed: auto adding of closing brace { on Windows format editors (\r\n) failed to work on some cases
35
#include "debuggerasciiviewer.h"
1735 by eranif
- Fixed: build compilation on Windows
36
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
37
#include <vector>
38
#include <algorithm>
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
39
#include <wx/stdpaths.h>
40
#include <wx/busyinfo.h>
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
41
#include <wx/progdlg.h>
42
#include <wx/file.h>
43
#include <wx/dir.h>
44
#include <wx/arrstr.h>
45
#include <wx/tokenzr.h>
46
#include <wx/regex.h>
47
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
48
#include "jobqueue.h"
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
49
#include "parse_thread.h"
50
#include "search_thread.h"
51
#include "pluginmanager.h"
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
52
#include "ctags_manager.h"
53
#include "language.h"
54
#include "context_manager.h"
55
#include "buildmanager.h"
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
56
#include "build_settings_config.h"
57
#include "menumanager.h"
58
#include "editor_config.h"
59
#include "environmentconfig.h"
60
#include "frame.h"
61
#include "sessionmanager.h"
62
#include "globals.h"
63
#include "vcimporter.h"
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
64
#include "macros.h"
65
#include "dirsaver.h"
66
#include "workspace_pane.h"
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
67
#include "workspacetab.h"
68
#include "dockablepanemenumanager.h"
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
69
#include "breakpointdlg.h"
70
#include "exelocator.h"
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
71
#include "simpletable.h"
72
#include "threadlistpanel.h"
73
#include "memoryview.h"
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
74
#include "attachdbgprocdlg.h"
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
75
#include "listctrlpanel.h"
76
#include "cl_editor.h"
77
#include "custombuildrequest.h"
78
#include "compile_request.h"
79
#include "clean_request.h"
2490 by eranif
- Fixed BUG#2909844: Failed build doesn't prevent launch
80
#include "buidltab.h"
3098 by eranif
- Fixed: Tabsgroup: on Mac use the 'Alt' key for DnD instead of Ctrl (DavidGH)
81
#include "tabgroupmanager.h"
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
82
#include "manager.h"
83
2034 by eranif
84
const wxEventType wxEVT_CMD_RESTART_CODELITE = wxNewEventType();
85
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
86
//---------------------------------------------------------------
87
// Menu accelerators helper methods
88
//---------------------------------------------------------------
89
90
static wxString StripAccelAndNemonics ( const wxString &text )
91
{
92
	//possible mnemonics:
93
	//_ and &
94
	wxString stripedText ( text );
95
	stripedText.Replace ( wxT ( "_" ), wxEmptyString );
96
	stripedText.Replace ( wxT ( "&" ), wxEmptyString );
97
	return stripedText.BeforeFirst ( wxT ( '\t' ) );
98
}
99
100
static wxString StripAccel ( const wxString &text )
101
{
102
	return text.BeforeFirst ( wxT ( '\t' ) );
103
}
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
104
105
//---------------------------------------------------------------
2109 by eranif
- Fixed regression: 'New Class' from context virtual folder context menu now working again
106
// Debugger helper method
107
//---------------------------------------------------------------
108
static wxArrayString DoGetTemplateTypes(const wxString& tmplDecl)
109
{
110
	wxArrayString types;
111
	int           depth (0);
112
	wxString      type;
113
114
	wxString tmpstr ( tmplDecl );
115
	tmpstr.Trim().Trim(false);
116
117
	if ( tmpstr.StartsWith(wxT("<")) ) {
118
		tmpstr.Remove(0, 1);
119
	}
120
121
	if ( tmpstr.EndsWith(wxT(">")) ) {
122
		tmpstr.RemoveLast();
123
	}
124
	tmpstr.Trim().Trim(false);
125
126
	for (size_t i=0; i<tmpstr.Length(); i++) {
2852 by eranif
- Removed wxPropertyGrid completly from the SymbolView plugnin
127
		wxChar ch = tmpstr.GetChar(i);
128
		switch (ch) {
2109 by eranif
- Fixed regression: 'New Class' from context virtual folder context menu now working again
129
		case wxT(','):
130
						if ( depth > 0 ) {
131
					type << wxT(",");
132
				} else {
133
					type.Trim().Trim(false);
134
					if ( type.Contains(wxT("std::basic_string<char")) ) {
135
						type = wxT("string");
136
					} else if ( type.Contains(wxT("std::basic_string<wchar_t")) ) {
137
						type = wxT("wstring");
138
					}
139
					types.Add( type );
140
					type.Empty();
141
				}
142
			break;
143
		case wxT('<'):
144
						depth ++;
145
			type << wxT("<");
146
			break;
147
		case wxT('>'):
148
						depth--;
149
			type << wxT(">");
150
			break;
151
		default:
152
			type << tmpstr.GetChar(i);
153
			break;
154
		}
155
	}
156
157
	if ( depth == 0 && type.IsEmpty() == false ) {
158
		type.Trim().Trim(false);
159
		if ( type.Contains(wxT("std::basic_string<char")) ) {
160
			type = wxT("string");
161
		} else if ( type.Contains(wxT("std::basic_string<wchar_t")) ) {
162
			type = wxT("wstring");
163
		}
164
		types.Add( type );
165
	}
166
167
	return types;
168
}
169
170
//---------------------------------------------------------------
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
171
//
172
// The CodeLite manager class
173
//
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
174
//---------------------------------------------------------------
175
176
Manager::Manager ( void )
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
177
		: m_shellProcess ( NULL )
178
		, m_asyncExeCmd ( NULL )
179
		, m_breakptsmgr( new BreakptMgr )
180
		, m_isShutdown ( false )
181
		, m_workspceClosing ( false )
182
		, m_dbgCanInteract ( false )
183
		, m_useTipWin ( false )
184
		, m_tipWinPos ( wxNOT_FOUND )
185
		, m_frameLineno ( wxNOT_FOUND )
3053 by eranif
- Reverted back to use debugger tip based on wxDialog (to remove the constraint of the tip being confined to the editor area)
186
		, m_watchDlg (NULL)
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
187
{
2030 by eranif
- Added "auto-restart" mechanism for windows & Linux
188
	m_codeliteLauncher = wxFileName(wxT("codelite_launcher"));
2592 by eranif
- code-completion: when retagging workspace, the 'scanning for includes files' is now done in a background thread
189
	Connect(wxEVT_CMD_RESTART_CODELITE,            wxCommandEventHandler(Manager::OnRestart),              NULL, this);
190
	Connect(wxEVT_PARSE_THREAD_SCAN_INCLUDES_DONE, wxCommandEventHandler(Manager::OnIncludeFilesScanDone), NULL, this);
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
191
}
192
193
Manager::~Manager ( void )
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
194
{
1527 by sdolim
Partial refactor of MainBook, Frame, and Manager to conceal the internal Notebook (for later support of splitting editor pane).
195
	//stop background processes
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
196
	DbgStop();
1527 by sdolim
Partial refactor of MainBook, Frame, and Manager to conceal the internal Notebook (for later support of splitting editor pane).
197
	JobQueueSingleton::Instance()->Stop();
198
	ParseThreadST::Get()->Stop();
1571 by eranif
- Remote debugging: Added the ability to send commands to the debugger after attaching to the remote target and before the 'continue' command. The commands can be set from project settings -> debugger
199
	SearchThreadST::Get()->Stop();
200
201
	//free all plugins
1527 by sdolim
Partial refactor of MainBook, Frame, and Manager to conceal the internal Notebook (for later support of splitting editor pane).
202
	PluginManager::Get()->UnLoad();
1571 by eranif
- Remote debugging: Added the ability to send commands to the debugger after attaching to the remote target and before the 'continue' command. The commands can be set from project settings -> debugger
203
1527 by sdolim
Partial refactor of MainBook, Frame, and Manager to conceal the internal Notebook (for later support of splitting editor pane).
204
	// release singleton objects
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
205
	DebuggerMgr::Free();
206
	JobQueueSingleton::Release();
1527 by sdolim
Partial refactor of MainBook, Frame, and Manager to conceal the internal Notebook (for later support of splitting editor pane).
207
	ParseThreadST::Free();  //since the parser is making use of the TagsManager,
208
	TagsManagerST::Free();  //it is important to release it *before* the TagsManager
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
209
	LanguageST::Free();
210
	WorkspaceST::Free();
211
	ContextManager::Free();
212
	BuildManagerST::Free();
213
	BuildSettingsConfigST::Free();
214
	SearchThreadST::Free();
215
	MenuManager::Free();
216
	EnvironmentConfig::Release();
3211 by eranif
- completed the clang code, codelite can now use clang for its code completion (disabled for now until it will get sablized and more tested). In any case, the clang will not replace the current completion, it will only be as second code completion that will be triggered incase the primary code completion fails
217
	ClangCodeCompletion::Release();
218
	
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
219
	if ( m_shellProcess ) {
220
		delete m_shellProcess;
221
		m_shellProcess = NULL;
222
	}
223
	delete m_breakptsmgr;
3098 by eranif
- Fixed: Tabsgroup: on Mac use the 'Alt' key for DnD instead of Ctrl (DavidGH)
224
225
	TabGroupsManager::Free();
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
226
}
227
228
229
//--------------------------- Workspace Loading -----------------------------
230
231
bool Manager::IsWorkspaceOpen() const
232
{
233
	return WorkspaceST::Get()->GetName().IsEmpty() == false;
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
234
}
235
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
236
void Manager::CreateWorkspace ( const wxString &name, const wxString &path )
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
237
{
3211 by eranif
- completed the clang code, codelite can now use clang for its code completion (disabled for now until it will get sablized and more tested). In any case, the clang will not replace the current completion, it will only be as second code completion that will be triggered incase the primary code completion fails
238
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
239
	// make sure that the workspace pane is visible
1497 by eranif
- Code refactoring (Scott Dolim)
240
	ShowWorkspacePane (Frame::Get()->GetWorkspaceTab()->GetCaption());
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
241
242
	wxString errMsg;
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
243
	bool res = WorkspaceST::Get()->CreateWorkspace ( name, path, errMsg );
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
244
	if ( !res ) {
245
		wxMessageBox(errMsg, wxT("Error"), wxOK | wxICON_HAND);
246
		return;
247
	}
1735 by eranif
- Fixed: build compilation on Windows
248
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
249
	OpenWorkspace ( path + PATH_SEP + name + wxT ( ".workspace" ) );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
250
}
251
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
252
void Manager::OpenWorkspace ( const wxString &path )
253
{
2655 by eranif
- Subversion: the subversion tab now remembers its position after restart
254
	wxLogNull noLog;
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
255
	CloseWorkspace();
256
257
	wxString errMsg;
258
	bool res = WorkspaceST::Get()->OpenWorkspace ( path, errMsg );
259
	if ( !res ) {
260
		// in case part of the workspace was opened, close the workspace
261
		CloseWorkspace();
262
		wxMessageBox ( errMsg, wxT ( "Error" ), wxOK | wxICON_HAND );
263
		return;
264
	}
3017 by eranif
- When retagging, show a 'wait cursor' for better user hinting
265
2780 by eranif
- When codelite fails to load a project, it will now remove it from the workspace and will prompt the user about it
266
	// OpenWorkspace returned true, but errMsg is not empty
267
	// this could only mean that we removed a fauly project
268
	if(errMsg.IsEmpty() == false) {
2801 by eranif
- Fixed BUG#2952124: CodeLite Tags can not accept to have no include paths for the code-completion parser
269
		Frame::Get()->GetMainBook()->ShowMessage(errMsg, true, wxXmlResource::Get()->LoadBitmap(wxT("message_pane_warning")));
2780 by eranif
- When codelite fails to load a project, it will now remove it from the workspace and will prompt the user about it
270
	}
3017 by eranif
- When retagging, show a 'wait cursor' for better user hinting
271
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
272
	DoSetupWorkspace ( path );
273
}
274
275
void Manager::ReloadWorkspace()
276
{
1735 by eranif
- Fixed: build compilation on Windows
277
	if ( !IsWorkspaceOpen() )
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
278
		return;
279
	DbgStop();
280
	WorkspaceST::Get()->ReloadWorkspace();
281
	DoSetupWorkspace ( WorkspaceST::Get()->GetWorkspaceFileName().GetFullPath() );
282
}
283
284
void Manager::DoSetupWorkspace ( const wxString &path )
285
{
286
	wxString errMsg;
287
	wxString dbfile = WorkspaceST::Get()->GetStringProperty ( wxT ( "Database" ), errMsg );
288
	wxFileName fn ( dbfile );
289
	wxBusyCursor cursor;
290
	AddToRecentlyOpenedWorkspaces ( path );
291
	SendCmdEvent ( wxEVT_WORKSPACE_LOADED );
292
	if ( Frame::Get()->GetFrameGeneralInfo().GetFlags() & CL_LOAD_LAST_SESSION ) {
293
		SessionEntry session;
294
		if ( SessionManager::Get().FindSession ( path, session ) ) {
295
			SessionManager::Get().SetLastWorkspaceName ( path );
296
			Frame::Get()->GetMainBook()->RestoreSession(session);
1929 by eranif
- debugger breakpoints are now persistent between workspaces (they are saved as part of the 'sessions.xml' file)
297
			GetBreakpointsMgr()->LoadSession(session);
2271 by eranif
- Debugger: if gdb fails to set a breakpoint (due to various reasons) a new button will show up in the 'Breakpoints' tab, 'Set Pending' by clicking it, codelite will interrupt the debuggee and re-apply it. If it succeeded, the button will dissappear and a the breakpoint will appear in the editor. Otherwise, no marker is set and the button remains
298
			Frame::Get()->GetDebuggerPane()->GetBreakpointView()->Initialize();
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
299
		}
300
	}
1812 by eranif
- opening a workspace will trigger a re-tag of the workspace (this is true only when 'use full retagging' is OFF settings -> tags settings...->advance)
301
2453 by eranif
- Added new option to set include / exclude parser paths per workspace. This is done from:
302
	// Update the parser search paths
303
	UpdateParserPaths();
2668 by eranif
- Added new builder to codelite: 'One step makefile' (by hops)
304
	Frame::Get()->SetEnvStatusMessage();
2655 by eranif
- Subversion: the subversion tab now remembers its position after restart
305
1812 by eranif
- opening a workspace will trigger a re-tag of the workspace (this is true only when 'use full retagging' is OFF settings -> tags settings...->advance)
306
	// send an event to the main frame indicating that a re-tag is required
307
	// we do this only if the "smart retagging" is on
2243 by eranif
fixed: in some cases the number of tags were not consisted in the database due to codelite_indexer restart
308
	TagsOptionsData tagsopt = TagsManagerST::Get()->GetCtagsOptions();
2346 by eranif
- Debugger: d-clicking an 'expandable' entry in the 'watches' table will now places the display variable dialog in the centre of the screen
309
	if ( tagsopt.GetFlags() & CC_RETAG_WORKSPACE_ON_STARTUP ) {
2288 by eranif
310
		wxCommandEvent e(wxEVT_COMMAND_MENU_SELECTED, XRCID("retag_workspace"));
2852 by eranif
- Removed wxPropertyGrid completly from the SymbolView plugnin
311
		Frame::Get()->GetEventHandler()->AddPendingEvent(e);
2288 by eranif
312
	}
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
313
}
314
315
void Manager::CloseWorkspace()
316
{
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
317
	m_workspceClosing = true;
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
318
1839 by eranif
- Implemented FR#2623376: Remember watch expression. CodeLite now restores watches from the previous debug session
319
	DbgClearWatches();
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
320
	DbgStop();
321
322
	//save the current session before closing
323
	SessionEntry session;
324
	session.SetWorkspaceName ( WorkspaceST::Get()->GetWorkspaceFileName().GetFullPath() );
2373 by eranif
- New: added the ability to save/load group of tabs on demand via the 'File' menu
325
	wxArrayInt unused; Frame::Get()->GetMainBook()->SaveSession(session, unused);
1929 by eranif
- debugger breakpoints are now persistent between workspaces (they are saved as part of the 'sessions.xml' file)
326
	GetBreakpointsMgr()->SaveSession(session);
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
327
	SessionManager::Get().Save ( WorkspaceST::Get()->GetWorkspaceFileName().GetFullPath(), session );
328
2001 by eranif
- Fixed: codelite will not longer set breakpoints from different workspaces. BUG ID: 2856768
329
	// Delete any breakpoints belong to the current workspace
330
	GetBreakpointsMgr()->DelAllBreakpoints();
2271 by eranif
- Debugger: if gdb fails to set a breakpoint (due to various reasons) a new button will show up in the 'Breakpoints' tab, 'Set Pending' by clicking it, codelite will interrupt the debuggee and re-apply it. If it succeeded, the button will dissappear and a the breakpoint will appear in the editor. Otherwise, no marker is set and the button remains
331
	// Then remove them from the debugger pane, in case that's visible
332
	Frame::Get()->GetDebuggerPane()->GetBreakpointView()->Initialize();
2001 by eranif
- Fixed: codelite will not longer set breakpoints from different workspaces. BUG ID: 2856768
333
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
334
	// since we closed the workspace, we also need to set the 'LastActiveWorkspaceName' to be
335
	// default
336
	SessionManager::Get().SetLastWorkspaceName ( wxT ( "Default" ) );
337
338
	WorkspaceST::Get()->CloseWorkspace();
339
	if ( !IsShutdownInProgress() ) {
340
		SendCmdEvent ( wxEVT_WORKSPACE_CLOSED );
341
	}
342
343
#ifdef __WXMSW__
344
	// Under Windows, and in order to avoid locking the directory set the working directory back to the start up directory
345
	wxSetWorkingDirectory ( GetStarupDirectory() );
346
#endif
347
3144 by eranif
- Fixed: environment variables: when workspace is closed, always revert back to the "Default" set
348
	/////////////////////////////////////////////////////////////////
349
	// set back the "Default" environment variable as the active set
350
	/////////////////////////////////////////////////////////////////
351
352
	EvnVarList vars = EnvironmentConfig::Instance()->GetSettings();
353
	if(vars.IsSetExist(wxT("Default"))) {
354
		vars.SetActiveSet(wxT("Default"));
355
	}
356
	EnvironmentConfig::Instance()->SetSettings(vars);
357
	Frame::Get()->SetEnvStatusMessage();
358
2453 by eranif
- Added new option to set include / exclude parser paths per workspace. This is done from:
359
	UpdateParserPaths();
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
360
	m_workspceClosing = false;
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
361
}
362
363
void Manager::AddToRecentlyOpenedWorkspaces ( const wxString &fileName )
364
{
365
	// Add this workspace to the history. Don't check for uniqueness:
366
	// if it's already on the list, wxFileHistory will move it to the top
2117 by eranif
- Changed the 'Welcome Page' layout
367
	wxString short_name;
2346 by eranif
- Debugger: d-clicking an 'expandable' entry in the 'watches' table will now places the display variable dialog in the centre of the screen
368
	if ( fileName.EndsWith(wxT(".workspace"), &short_name) ) {
2117 by eranif
- Changed the 'Welcome Page' layout
369
		m_recentWorkspaces.AddFileToHistory ( short_name );
370
371
	} else {
372
		m_recentWorkspaces.AddFileToHistory ( fileName );
373
	}
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
374
375
	//sync between the history object and the configuration file
376
	wxArrayString files;
377
	m_recentWorkspaces.GetFiles ( files );
2117 by eranif
- Changed the 'Welcome Page' layout
378
2346 by eranif
- Debugger: d-clicking an 'expandable' entry in the 'watches' table will now places the display variable dialog in the centre of the screen
379
	for ( size_t i=0; i<files.GetCount(); i++ ) {
380
		if (files.Item(i).EndsWith(wxT(".workspace")) == false) {
2117 by eranif
- Changed the 'Welcome Page' layout
381
			files.Item(i).Append(wxT(".workspace"));
382
		}
383
	}
384
2373 by eranif
- New: added the ability to save/load group of tabs on demand via the 'File' menu
385
	EditorConfigST::Get()->SetRecentItems( files, wxT("RecentWorkspaces") );
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
386
}
387
388
void Manager::ClearWorkspaceHistory()
389
{
390
	size_t count = m_recentWorkspaces.GetCount();
391
	for ( size_t i=0; i<count; i++ ) {
392
		m_recentWorkspaces.RemoveFileFromHistory ( 0 );
393
	}
394
	wxArrayString files;
2373 by eranif
- New: added the ability to save/load group of tabs on demand via the 'File' menu
395
	EditorConfigST::Get()->SetRecentItems( files, wxT("RecentWorkspaces") );
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
396
}
397
398
void Manager::GetRecentlyOpenedWorkspaces ( wxArrayString &files )
399
{
2373 by eranif
- New: added the ability to save/load group of tabs on demand via the 'File' menu
400
	EditorConfigST::Get()->GetRecentItems( files, wxT("RecentWorkspaces") );
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
401
}
402
403
404
//--------------------------- Workspace Projects Mgmt -----------------------------
405
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
406
void Manager::CreateProject ( ProjectData &data )
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
407
{
1258 by eranif
- Implemented multiple custom targets for the 'Custom Build' option. This allows users to define N targets other than the built-in (Build, Clean) for example: make clean all, make distclean etc.
408
	if ( IsWorkspaceOpen() == false ) {
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
409
		//create a workspace before creating a project
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
410
		CreateWorkspace ( data.m_name, data.m_path );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
411
	}
412
413
	wxString errMsg;
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
414
	bool res = WorkspaceST::Get()->CreateProject ( data.m_name,
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
415
	           data.m_path,
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
416
	           data.m_srcProject->GetSettings()->GetProjectType ( wxEmptyString ),
1139 by eranif
- Implemented [ codelite-Feature Requests-2092921 ] A new workspace should have a release configuration as well
417
	           false,
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
418
	           errMsg );
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
419
	if ( !res ) {
420
		wxMessageBox(errMsg, wxT("Error"), wxOK | wxICON_HAND);
421
		return;
422
	}
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
423
	ProjectPtr proj = WorkspaceST::Get()->FindProjectByName ( data.m_name, errMsg );
1215 by eranif
- Fixed crash when switching/closing workspace and CodeLite saves any modified files from the previous/closed workspace
424
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
425
	//copy the project settings to the new one
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
426
	proj->SetSettings ( data.m_srcProject->GetSettings() );
1215 by eranif
- Fixed crash when switching/closing workspace and CodeLite saves any modified files from the previous/closed workspace
427
1809 by eranif
- Re-design of the UnitTest++ plugin
428
	proj->SetProjectInternalType(data.m_srcProject->GetProjectInternalType());
429
1139 by eranif
- Implemented [ codelite-Feature Requests-2092921 ] A new workspace should have a release configuration as well
430
	// now add the new project to the build matrix
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
431
	WorkspaceST::Get()->AddProjectToBuildMatrix ( proj );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
432
	ProjectSettingsPtr settings = proj->GetSettings();
433
1901 by eranif
434
	// set the compiler type
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
435
	ProjectSettingsCookie cookie;
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
436
	BuildConfigPtr bldConf = settings->GetFirstBuildConfiguration ( cookie );
437
	while ( bldConf ) {
438
		bldConf->SetCompilerType ( data.m_cmpType );
439
		bldConf = settings->GetNextBuildConfiguration ( cookie );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
440
	}
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
441
	proj->SetSettings ( settings );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
442
1901 by eranif
443
	// copy the files as they appear in the source project
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
444
	proj->SetFiles ( data.m_srcProject );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
445
1902 by eranif
- Contniued work on the qmake plugin
446
	// copy plugins data
447
	std::map<wxString, wxString> pluginsData;
448
	data.m_srcProject->GetAllPluginsData( pluginsData );
449
	proj->SetAllPluginsData( pluginsData );
450
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
451
	{
452
		// copy the actual files from the template directory to the new project path
453
		DirSaver ds;
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
454
		wxSetWorkingDirectory ( proj->GetFileName().GetPath() );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
455
456
		// get list of files
457
		std::vector<wxFileName> files;
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
458
		data.m_srcProject->GetFiles ( files, true );
459
		for ( size_t i=0; i<files.size(); i++ ) {
460
			wxFileName f ( files.at ( i ) );
461
			wxCopyFile ( f.GetFullPath(), f.GetFullName() );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
462
		}
463
	}
1571 by eranif
- Remote debugging: Added the ability to send commands to the debugger after attaching to the remote target and before the 'continue' command. The commands can be set from project settings -> debugger
464
465
	wxString projectName = proj->GetName();
2286 by eranif
- Removed the option 'Full retagging' from the tags options dialog
466
	RetagProject ( projectName, true );
1571 by eranif
- Remote debugging: Added the ability to send commands to the debugger after attaching to the remote target and before the 'continue' command. The commands can be set from project settings -> debugger
467
	SendCmdEvent ( wxEVT_PROJ_ADDED, ( void* ) &projectName );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
468
}
469
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
470
void Manager::AddProject ( const wxString & path )
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
471
{
1911 by eranif
- Added QMake wizard to add qmake based projects
472
	// create a workspace if there is non
473
	if ( IsWorkspaceOpen() == false ) {
474
475
		wxFileName fn(path);
476
477
		//create a workspace before creating a project
478
		CreateWorkspace ( fn.GetName(), fn.GetPath() );
479
	}
480
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
481
	wxString errMsg;
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
482
	bool res = WorkspaceST::Get()->AddProject ( path, errMsg );
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
483
	if ( !res ) {
484
		wxMessageBox(errMsg, wxT("Error"), wxOK | wxICON_HAND);
485
		return;
486
	}
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
487
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
488
	wxFileName fn ( path );
489
	wxString projectName ( fn.GetName() );
2286 by eranif
- Removed the option 'Full retagging' from the tags options dialog
490
	RetagProject ( projectName, true );
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
491
	SendCmdEvent ( wxEVT_PROJ_ADDED, ( void* ) &projectName );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
492
}
493
2867 by eranif
- Improved VS import code to correctly set the project type per build configuration.
494
void Manager::ImportMSVSSolution ( const wxString &path, const wxString &defaultCompiler )
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
495
{
496
	wxFileName fn ( path );
497
	if ( fn.FileExists() == false ) {
498
		return;
499
	}
3017 by eranif
- When retagging, show a 'wait cursor' for better user hinting
500
2869 by eranif
- Improved MSVC importer tool further: notification messages are now shown while solution is imported + the newly created workspace will be retagged.
501
	// Show some messages to the user
502
	wxBusyCursor busyCursor;
503
	wxBusyInfo info(_("Importing MS solution..."), Frame::Get());
3017 by eranif
- When retagging, show a 'wait cursor' for better user hinting
504
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
505
	wxString errMsg;
2867 by eranif
- Improved VS import code to correctly set the project type per build configuration.
506
	VcImporter importer ( path, defaultCompiler );
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
507
	if ( importer.Import ( errMsg ) ) {
508
		wxString wspfile;
509
		wspfile << fn.GetPath() << wxT ( "/" ) << fn.GetName() << wxT ( ".workspace" );
510
		OpenWorkspace ( wspfile );
3017 by eranif
- When retagging, show a 'wait cursor' for better user hinting
511
2869 by eranif
- Improved MSVC importer tool further: notification messages are now shown while solution is imported + the newly created workspace will be retagged.
512
		// Retag workspace
513
		wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, XRCID("retag_workspace") );
514
		Frame::Get()->GetEventHandler()->AddPendingEvent( event );
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
515
	}
516
}
517
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
518
bool Manager::RemoveProject ( const wxString &name )
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
519
{
1258 by eranif
- Implemented multiple custom targets for the 'Custom Build' option. This allows users to define N targets other than the built-in (Build, Clean) for example: make clean all, make distclean etc.
520
	if ( name.IsEmpty() ) {
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
521
		return false;
522
	}
523
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
524
	ProjectPtr proj = GetProject ( name );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
525
526
	wxString errMsg;
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
527
	bool res = WorkspaceST::Get()->RemoveProject ( name, errMsg );
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
528
	if ( !res ) {
529
		wxMessageBox(errMsg, wxT("Error"), wxOK | wxICON_HAND);
530
		return false;
531
	}
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
532
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
533
	if ( proj ) {
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
534
		//remove symbols from the database
535
		std::vector<wxFileName> projectFiles;
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
536
		proj->GetFiles ( projectFiles, true );
537
		TagsManagerST::Get()->DeleteFilesTags ( projectFiles );
538
		wxArrayString prjfls;
539
		for ( size_t i = 0; i < projectFiles.size(); i++ ) {
540
			prjfls.Add ( projectFiles[i].GetFullPath() );
541
		}
542
		SendCmdEvent ( wxEVT_PROJ_FILE_REMOVED, ( void* ) &prjfls );
543
	} // if(proj)
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
544
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
545
	SendCmdEvent ( wxEVT_PROJ_REMOVED, ( void* ) &name );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
546
547
	return true;
548
}
549
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
550
void Manager::GetProjectList ( wxArrayString &list )
551
{
552
	WorkspaceST::Get()->GetProjectList ( list );
553
}
554
555
ProjectPtr Manager::GetProject ( const wxString &name ) const
556
{
2481 by eranif
- Fixed: on some cases, when clicking an error in the 'Build' tab, portion of the text is selected
557
	wxString projectName ( name );
558
	projectName.Trim().Trim(false);
559
560
	if(projectName.IsEmpty())
561
		return NULL;
562
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
563
	wxString errMsg;
564
	ProjectPtr proj = WorkspaceST::Get()->FindProjectByName ( name, errMsg );
565
	if ( !proj ) {
566
		wxLogMessage ( errMsg );
567
		return NULL;
568
	}
569
	return proj;
570
}
571
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
572
wxString Manager::GetActiveProjectName()
573
{
2243 by eranif
fixed: in some cases the number of tags were not consisted in the database due to codelite_indexer restart
574
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
575
	return WorkspaceST::Get()->GetActiveProjectName();
576
}
577
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
578
void Manager::SetActiveProject ( const wxString &name )
579
{
580
	WorkspaceST::Get()->SetActiveProject ( WorkspaceST::Get()->GetActiveProjectName(), false );
581
	WorkspaceST::Get()->SetActiveProject ( name, true );
582
}
583
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
584
BuildMatrixPtr Manager::GetWorkspaceBuildMatrix() const
585
{
586
	return WorkspaceST::Get()->GetBuildMatrix();
587
}
588
589
void Manager::SetWorkspaceBuildMatrix ( BuildMatrixPtr matrix )
590
{
591
	WorkspaceST::Get()->SetBuildMatrix ( matrix );
592
	SendCmdEvent(wxEVT_WORKSPACE_CONFIG_CHANGED);
593
}
594
595
596
//--------------------------- Workspace Files Mgmt -----------------------------
597
598
void Manager::GetWorkspaceFiles ( wxArrayString &files )
599
{
600
	if ( !IsWorkspaceOpen() ) {
601
		return;
602
	}
603
604
	wxArrayString projects;
605
	GetProjectList ( projects );
606
607
	for ( size_t i=0; i<projects.GetCount(); i++ ) {
608
		GetProjectFiles ( projects.Item ( i ), files );
609
	}
610
}
611
612
void Manager::GetWorkspaceFiles ( std::vector<wxFileName> &files, bool absPath )
613
{
614
	wxArrayString projects;
615
	GetProjectList ( projects );
616
	for ( size_t i=0; i<projects.GetCount(); i++ ) {
617
		ProjectPtr p = GetProject ( projects.Item ( i ) );
618
		p->GetFiles ( files, absPath );
619
	}
620
}
621
622
bool Manager::IsFileInWorkspace ( const wxString &fileName )
623
{
624
	wxFileName findme ( fileName );
625
	std::vector<wxFileName> files;
626
627
	GetWorkspaceFiles ( files, true );
628
	std::vector<wxFileName>::const_iterator iter = std::find ( files.begin(), files.end(), findme );
629
	return iter != files.end();
630
}
631
632
wxFileName Manager::FindFile ( const wxString &filename, const wxString &project )
633
{
2418 by eranif
- Improved performance when parsing compiler errors and the pattern does not include file name index
634
	wxString tmpfile(filename);
635
	tmpfile.Trim().Trim(false);
636
637
	if(tmpfile.IsEmpty()) {
638
		return wxFileName();
639
	}
640
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
641
	wxFileName fn ( filename );
642
	if ( !fn.FileExists() ) {
643
		// try to open the file as is
644
		fn.Clear();
645
	}
646
	if ( !fn.IsOk() && !project.IsEmpty() ) {
647
		// try to open the file in context of its project
648
		wxArrayString project_files;
649
		GetProjectFiles ( project, project_files );
650
		fn = FindFile ( project_files, filename );
651
	}
652
	if ( !fn.IsOk() ) {
653
		// no luck there.  try the whole workspace
654
		wxArrayString workspace_files;
655
		GetWorkspaceFiles ( workspace_files );
656
		fn = FindFile ( workspace_files, filename );
657
	}
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
658
	if (!fn.IsAbsolute()) {
659
		fn.MakeAbsolute();
660
	}
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
661
	return fn;
662
}
663
664
// ATTN: Please do not change this code!
665
wxFileName Manager::FindFile ( const wxArrayString& files, const wxFileName &fn )
666
{
667
	// Iterate over the files twice:
668
	// first, try to full path
669
	// if the first iteration failes, iterate the files again
670
	// and compare full name only
671
	if ( fn.IsAbsolute() && !fn.GetFullPath().Contains ( wxT ( ".." ) ) ) {
672
		return fn;
673
	}
2453 by eranif
- Added new option to set include / exclude parser paths per workspace. This is done from:
674
2431 by eranif
- changed the 'FindFile' in the build tab logic to first try to detect files from the workspace
675
	std::vector<wxFileName> matches;
676
	// Try to find a match in the workspace (by comparing full paths)
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
677
	for ( size_t i=0; i< files.GetCount(); i++ ) {
678
		wxFileName tmpFileName ( files.Item ( i ) );
1967 by eranif
- Added support for compiler Annotations which replaces the compiler error tooltips
679
		if ( tmpFileName.GetFullPath().CmpNoCase(fn.GetFullPath()) == 0 ) {
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
680
			wxFileName tt ( tmpFileName );
681
			if ( tt.MakeAbsolute() ) {
682
				return tt;
683
			} else {
684
				return tmpFileName;
685
			}
686
		}
687
		if ( tmpFileName.GetFullName() == fn.GetFullName() ) {
688
			matches.push_back ( tmpFileName );
689
		}
690
	}
2453 by eranif
- Added new option to set include / exclude parser paths per workspace. This is done from:
691
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
692
	wxString lastDir;
693
	wxArrayString dirs = fn.GetDirs();
694
	if ( dirs.GetCount() > 0 ) {
695
		lastDir = dirs.Last();
696
	}
697
698
	if ( matches.size() == 1 ) {
699
		wxFileName tt ( matches.at ( 0 ) );
700
		if ( tt.MakeAbsolute() ) {
701
			return tt;
702
		} else {
703
			return matches.at ( 0 );
704
		}
705
706
	} else if ( matches.size() > 1 ) {
707
		// take the best match
708
		std::vector<wxFileName> betterMatches;
709
		for ( size_t i=0; i<matches.size(); i++ ) {
710
711
			wxFileName filename ( matches.at ( i ) );
712
			wxArrayString tmpdirs = filename.GetDirs();
713
			if ( tmpdirs.GetCount() > 0 ) {
714
				if ( tmpdirs.Last() == lastDir ) {
715
					betterMatches.push_back ( filename );
716
				}
717
			}
718
		}
719
720
		if ( betterMatches.size() == 1 ) {
721
			wxFileName tt ( betterMatches.at ( 0 ) );
722
			if ( tt.MakeAbsolute() ) {
723
				return tt;
724
			} else {
725
				return betterMatches.at ( 0 );
726
			}
727
		} else {
728
			// open the first match
729
			wxFileName tt ( matches.at ( 0 ) );
730
			if ( tt.MakeAbsolute() ) {
731
				return tt;
732
			} else {
733
				return matches.at ( 0 );
734
			}
735
		}
2431 by eranif
- changed the 'FindFile' in the build tab logic to first try to detect files from the workspace
736
	} else {
737
		// try to convert it to absolute path
738
		wxFileName f1 ( fn );
739
		if ( f1.MakeAbsolute() /*&& f1.FileExists()*/ && !f1.GetFullPath().Contains ( wxT ( ".." ) ) ) {
740
			return f1;
741
		}
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
742
	}
743
	return wxFileName();
744
}
745
2286 by eranif
- Removed the option 'Full retagging' from the tags options dialog
746
void Manager::RetagWorkspace(bool quickRetag)
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
747
{
1774 by eranif
- New: retagging workspace / project now uses "quick retagging" which only retag files which were modified since the last retag. This functionality can be turned on/off from settings -> tags settings -> advance -> Use full re-tagging
748
	// in the case of re-tagging the entire workspace and full re-tagging is enabled
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
749
	// it is faster to drop the tables instead of deleting
2346 by eranif
- Debugger: d-clicking an 'expandable' entry in the 'watches' table will now places the display variable dialog in the centre of the screen
750
	if ( !quickRetag )
1774 by eranif
- New: retagging workspace / project now uses "quick retagging" which only retag files which were modified since the last retag. This functionality can be turned on/off from settings -> tags settings -> advance -> Use full re-tagging
751
		TagsManagerST::Get()->GetDatabase()->RecreateDatabase();
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
752
753
	wxArrayString projects;
754
	GetProjectList ( projects );
1735 by eranif
- Fixed: build compilation on Windows
755
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
756
	std::vector<wxFileName> projectFiles;
757
	for ( size_t i=0; i<projects.GetCount(); i++ ) {
758
		ProjectPtr proj = GetProject ( projects.Item ( i ) );
759
		if ( proj ) {
2592 by eranif
- code-completion: when retagging workspace, the 'scanning for includes files' is now done in a background thread
760
			proj->GetFiles( projectFiles, true );
761
		}
762
	}
763
764
	// Create a parsing request
765
	ParseRequest *parsingRequest = new ParseRequest();
2346 by eranif
- Debugger: d-clicking an 'expandable' entry in the 'watches' table will now places the display variable dialog in the centre of the screen
766
	for (size_t i=0; i<projectFiles.size(); i++) {
2811 by eranif
- Fixed: BUG#2952123: Retag Workspace will freeze codelite, when bmp-files in proj
767
		// filter any non valid coding file
768
		if(!TagsManagerST::Get()->IsValidCtagsFile(projectFiles.at(i)))
769
			continue;
2592 by eranif
- code-completion: when retagging workspace, the 'scanning for includes files' is now done in a background thread
770
		parsingRequest->_workspaceFiles.push_back( projectFiles.at(i).GetFullPath().mb_str(wxConvUTF8).data() );
771
	}
772
773
	parsingRequest->setType(ParseRequest::PR_PARSEINCLUDES);
774
	parsingRequest->_evtHandler = this;
775
	parsingRequest->_quickRetag = quickRetag;
776
	ParseThreadST::Get()->Add ( parsingRequest );
777
778
	Frame::Get()->SetStatusMessage(wxT("Scanning for include files to parse..."), 0);
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
779
}
780
781
void Manager::RetagFile ( const wxString& filename )
782
{
783
	if ( IsWorkspaceClosing() ) {
784
		wxLogMessage ( wxString::Format ( wxT ( "Workspace in being closed, skipping re-tag for file %s" ), filename.c_str() ) );
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
785
		return;
786
	}
787
	if ( !TagsManagerST::Get()->IsValidCtagsFile ( wxFileName ( filename ) ) ) {
788
		wxLogMessage ( wxT ( "Not a valid C tags file type: %s. Skipping." ), filename.c_str() );
789
		return;
790
	}
791
792
	wxFileName absFile ( filename );
793
	absFile.MakeAbsolute();
794
2233 by eranif
- the parse thread now will also parse system include files when parsing a workspace
795
	// Put a request to the parsing thread
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
796
	ParseRequest *req = new ParseRequest();
2198 by eranif
- Tags Cache: is now disabled until all problems will be fixed
797
	req->setDbFile   ( TagsManagerST::Get()->GetDatabase()->GetDatabaseFileName().GetFullPath().c_str() );
798
	req->setFile     ( absFile.GetFullPath().c_str() );
2233 by eranif
- the parse thread now will also parse system include files when parsing a workspace
799
	req->setType     ( ParseRequest::PR_FILESAVED );
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
800
	ParseThreadST::Get()->Add ( req );
801
802
	wxString msg = wxString::Format(wxT( "Re-tagging file %s..." ), absFile.GetFullName().c_str());
803
	Frame::Get()->SetStatusMessage(msg, 0, XRCID("retag_file"));
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
804
}
805
806
//--------------------------- Project Files Mgmt -----------------------------
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
807
808
void Manager::AddVirtualDirectory ( const wxString &virtualDirFullPath )
809
{
810
	wxString errMsg;
811
	bool res = WorkspaceST::Get()->CreateVirtualDirectory ( virtualDirFullPath, errMsg );
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
812
	if ( !res ) {
813
		wxMessageBox(errMsg, wxT("Error"), wxOK | wxICON_HAND);
814
		return;
815
	}
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
816
}
817
818
void Manager::RemoveVirtualDirectory ( const wxString &virtualDirFullPath )
819
{
820
	wxString errMsg;
821
	wxString project = virtualDirFullPath.BeforeFirst ( wxT ( ':' ) );
822
	ProjectPtr p = WorkspaceST::Get()->FindProjectByName ( project, errMsg );
1258 by eranif
- Implemented multiple custom targets for the 'Custom Build' option. This allows users to define N targets other than the built-in (Build, Clean) for example: make clean all, make distclean etc.
823
	if ( !p ) {
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
824
		return;
825
	}
826
827
	// Update symbol tree and database
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
828
	wxString vdPath = virtualDirFullPath.AfterFirst ( wxT ( ':' ) );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
829
	wxArrayString files;
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
830
	p->GetFilesByVirtualDir ( vdPath, files );
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
831
	wxFileName tagsDb = TagsManagerST::Get()->GetDatabase()->GetDatabaseFileName();
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
832
	for ( size_t i=0; i<files.Count(); i++ ) {
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
833
		TagsManagerST::Get()->Delete ( tagsDb, files.Item ( i ) );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
834
	}
835
836
	//and finally, remove the virtual dir from the workspace
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
837
	bool res = WorkspaceST::Get()->RemoveVirtualDirectory ( virtualDirFullPath, errMsg );
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
838
	if ( !res ) {
839
		wxMessageBox(errMsg, wxT("Error"), wxOK | wxICON_HAND);
840
		return;
841
	}
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
842
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
843
	SendCmdEvent ( wxEVT_PROJ_FILE_REMOVED, ( void* ) &files );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
844
}
845
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
846
bool Manager::AddNewFileToProject ( const wxString &fileName, const wxString &vdFullPath, bool openIt )
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
847
{
848
	wxFile file;
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
849
	if ( !file.Create ( fileName.GetData(), true ) )
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
850
		return false;
851
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
852
	if ( file.IsOpened() ) {
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
853
		file.Close();
854
	}
855
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
856
	return AddFileToProject ( fileName, vdFullPath, openIt );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
857
}
858
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
859
bool Manager::AddFileToProject ( const wxString &fileName, const wxString &vdFullPath, bool openIt )
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
860
{
861
	wxString project;
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
862
	project = vdFullPath.BeforeFirst ( wxT ( ':' ) );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
863
864
	// Add the file to the project
865
	wxString errMsg;
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
866
	bool res = WorkspaceST::Get()->AddNewFile ( vdFullPath, fileName, errMsg );
867
	if ( !res ) {
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
868
		//file or virtual dir does not exist
869
		return false;
870
	}
871
1258 by eranif
- Implemented multiple custom targets for the 'Custom Build' option. This allows users to define N targets other than the built-in (Build, Clean) for example: make clean all, make distclean etc.
872
	if ( openIt ) {
1728 by sdolim
- Eliminated obsolete functions Manager::GetActiveEditor() and Manager::OpenFile(). All calls now use Mainbook directly.
873
		Frame::Get()->GetMainBook()->OpenFile ( fileName, project );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
874
	}
875
876
	TagTreePtr ttp;
1258 by eranif
- Implemented multiple custom targets for the 'Custom Build' option. This allows users to define N targets other than the built-in (Build, Clean) for example: make clean all, make distclean etc.
877
	if ( project.IsEmpty() == false ) {
2172 by eranif
- Further modification made to the code refactoring
878
		std::vector<CommentPtr> comments;
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
879
		if ( TagsManagerST::Get()->GetParseComments() ) {
880
			ttp = TagsManagerST::Get()->ParseSourceFile ( fileName, &comments );
1258 by eranif
- Implemented multiple custom targets for the 'Custom Build' option. This allows users to define N targets other than the built-in (Build, Clean) for example: make clean all, make distclean etc.
881
		} else {
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
882
			ttp = TagsManagerST::Get()->ParseSourceFile ( fileName );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
883
		}
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
884
		TagsManagerST::Get()->Store ( ttp );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
885
	}
886
887
	//send notification command event that files was added to
888
	//project
889
	wxArrayString files;
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
890
	files.Add ( fileName );
891
	SendCmdEvent ( wxEVT_PROJ_FILE_ADDED, ( void* ) &files );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
892
	return true;
893
}
894
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
895
void Manager::AddFilesToProject ( const wxArrayString &files, const wxString &vdFullPath, wxArrayString &actualAdded )
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
896
{
897
	wxString project;
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
898
	project = vdFullPath.BeforeFirst ( wxT ( ':' ) );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
899
900
	// Add the file to the project
901
	wxString errMsg;
902
	//bool res = true;
903
	size_t i=0;
904
905
	//try to find this file in the workspace
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
906
	for ( i=0; i<files.GetCount(); i++ ) {
907
		wxString projName = this->GetProjectNameByFile ( files.Item ( i ) );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
908
		//allow adding the file, only if it does not already exist under the current project
909
		//(it can be already exist under the different project)
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
910
		if ( projName.IsEmpty() || projName != project ) {
911
			actualAdded.Add ( files.Item ( i ) );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
912
		}
913
	}
914
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
915
	for ( i=0; i<actualAdded.GetCount(); i++ ) {
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
916
		Workspace *wsp = WorkspaceST::Get();
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
917
		wsp->AddNewFile ( vdFullPath, actualAdded.Item ( i ), errMsg );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
918
	}
919
920
	//convert wxArrayString to vector for the ctags api
921
	std::vector<wxFileName> vFiles;
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
922
	for ( size_t i=0; i<actualAdded.GetCount(); i++ ) {
923
		vFiles.push_back ( actualAdded.Item ( i ) );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
924
	}
925
1195 by eranif
- spelling fixes
926
	//re-tag the added files
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
927
	if ( vFiles.empty() == false ) {
2286 by eranif
- Removed the option 'Full retagging' from the tags options dialog
928
		TagsManagerST::Get()->RetagFiles ( vFiles, true );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
929
	}
930
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
931
	if ( !actualAdded.IsEmpty() ) {
932
		SendCmdEvent ( wxEVT_PROJ_FILE_ADDED, ( void* ) &actualAdded );
933
	}
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
934
}
935
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
936
bool Manager::RemoveFile ( const wxString &fileName, const wxString &vdFullPath )
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
937
{
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
938
	wxString project = vdFullPath.BeforeFirst ( wxT ( ':' ) );
939
	wxFileName absPath ( fileName );
940
	absPath.MakeAbsolute ( GetProjectCwd ( project ) );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
941
1571 by eranif
- Remote debugging: Added the ability to send commands to the debugger after attaching to the remote target and before the 'continue' command. The commands can be set from project settings -> debugger
942
	Frame::Get()->GetMainBook()->ClosePage(absPath.GetFullPath());
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
943
944
	wxString errMsg;
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
945
	bool res = WorkspaceST::Get()->RemoveFile ( vdFullPath, fileName, errMsg );
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
946
	if ( !res ) {
2295 by eranif
- Applied patch to avoid empty message box in some scenarios
947
		wxMessageBox(errMsg, _("Error"), wxOK | wxICON_HAND, Frame::Get());
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
948
		return false;
949
	}
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
950
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
951
	TagsManagerST::Get()->Delete ( TagsManagerST::Get()->GetDatabase()->GetDatabaseFileName(), absPath.GetFullPath() );
1571 by eranif
- Remote debugging: Added the ability to send commands to the debugger after attaching to the remote target and before the 'continue' command. The commands can be set from project settings -> debugger
952
	wxArrayString files(1, &fileName);
953
	SendCmdEvent(wxEVT_PROJ_FILE_REMOVED, (void*)&files);
1497 by eranif
- Code refactoring (Scott Dolim)
954
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
955
	return true;
956
}
957
1879 by eranif
- Applied patch by Mattia barbon so that codelite will send 2 events when file is renamed: 1 event for the removal of the file and one for adding new fie
958
bool Manager::RenameFile(const wxString &origName, const wxString &newName, const wxString &vdFullPath)
959
{
2470 by eranif
- Code Refactoring: moved code from Builder interface to the Builder GNU make
960
	// Step: 1
1879 by eranif
- Applied patch by Mattia barbon so that codelite will send 2 events when file is renamed: 1 event for the removal of the file and one for adding new fie
961
	// remove the file from the workspace (this will erase it from the symbol database and will
962
	// also close the editor that it is currently opened in (if any)
963
	if (!RemoveFile(origName, vdFullPath))
964
		return false;
965
2470 by eranif
- Code Refactoring: moved code from Builder interface to the Builder GNU make
966
	// Step: 2
967
	// Notify the plugins, maybe they want to override the
968
	// default behavior (e.g. Subversion plugin)
969
	wxArrayString f;
970
	f.Add(origName);
971
	f.Add(newName);
2514 by eranif
- Completed missing implementation with Subversion2
972
2534 by eranif
973
	if(!SendCmdEvent(wxEVT_FILE_RENAMED, (void*)&f)){
974
		// rename the file on filesystem
2638 by eranif
- Fixed: BUG$2924537: svn will rename a file only if the flag to rename it is enabled in the svn options, in addition, it will test to see if the file is located under svn, if any of the conditions is false, it will skip the renaming and will fall back to the default behavior
975
		wxLogNull noLog;
2534 by eranif
976
		wxRenameFile(origName, newName);
977
	}
2514 by eranif
- Completed missing implementation with Subversion2
978
979
	// read file to project with the new name
1879 by eranif
- Applied patch by Mattia barbon so that codelite will send 2 events when file is renamed: 1 event for the removal of the file and one for adding new fie
980
	wxString projName = vdFullPath.BeforeFirst(wxT(':'));
981
	ProjectPtr proj = GetProject(projName);
982
	proj->FastAddFile(newName, vdFullPath.AfterFirst(wxT(':')));
983
2470 by eranif
- Code Refactoring: moved code from Builder interface to the Builder GNU make
984
	// Step 3: retag the new file
1879 by eranif
- Applied patch by Mattia barbon so that codelite will send 2 events when file is renamed: 1 event for the removal of the file and one for adding new fie
985
	RetagFile(newName);
986
2470 by eranif
- Code Refactoring: moved code from Builder interface to the Builder GNU make
987
	// Step 4: send an event about new file was added
988
	// to the workspace
1879 by eranif
- Applied patch by Mattia barbon so that codelite will send 2 events when file is renamed: 1 event for the removal of the file and one for adding new fie
989
	wxArrayString files;
990
	files.Add(newName);
991
	SendCmdEvent(wxEVT_PROJ_FILE_ADDED, (void*)&files);
992
2470 by eranif
- Code Refactoring: moved code from Builder interface to the Builder GNU make
993
	// Step 5: Change all include files refering to the old
994
	// file
995
	if( !IsWorkspaceOpen() ) {
996
		// if there is no workspace opened, we are done
997
		return true;
998
	}
999
1000
	wxArrayString     workspaceFiles;
1001
	GetWorkspaceFiles(workspaceFiles);
1002
	std::vector<IncludeStatement> includes, matches;
1003
1004
	for(size_t i=0; i<workspaceFiles.GetCount(); i++) {
2472 by eranif
- moved incldue finder code to differnt lexer to avoid clashing
1005
		IncludeFinder(workspaceFiles.Item(i).mb_str(wxConvUTF8).data(), includes);
2470 by eranif
- Code Refactoring: moved code from Builder interface to the Builder GNU make
1006
	}
1007
1008
	// Filter non-relevant matches
1009
	wxString oldName ( origName ) ;
1010
	oldName.Replace(wxT("\\"), wxT("/"));
1011
	for(size_t i=0; i<includes.size(); i++) {
2475 by eranif
1012
2470 by eranif
- Code Refactoring: moved code from Builder interface to the Builder GNU make
1013
		wxString   inclName (includes.at(i).file.c_str(), wxConvUTF8);
1014
		wxFileName inclFn   ( inclName );
1015
1016
		if(oldName.EndsWith(inclFn.GetFullName())) {
1017
			matches.push_back(includes.at(i));
1018
		}
2475 by eranif
1019
2470 by eranif
- Code Refactoring: moved code from Builder interface to the Builder GNU make
1020
	}
1021
1022
	// Prompt the user with the list of files which are about to be modified
1023
	wxFileName newFile(newName);
2475 by eranif
1024
	if(matches.empty() == false){
1025
		RenameFileDlg dlg(Frame::Get(), newFile.GetFullName(), matches);
1026
		if(dlg.ShowModal() == wxID_OK) {
1027
			matches.clear();
1028
			matches     = dlg.GetMatches();
1029
1030
			for(size_t i=0; i<matches.size(); i++) {
1031
				IncludeStatement includeStatement = matches.at(i);
1032
				wxString editorFileName (includeStatement.includedFrom.c_str(), wxConvUTF8);
1033
				wxString findWhat       (includeStatement.pattern.c_str(),      wxConvUTF8);
1034
				wxString oldIncl        (includeStatement.file.c_str(),         wxConvUTF8);
1035
1036
				// We want to keep the original open/close braces
1037
				// "" or <>
1038
				wxFileName strippedOldInc(oldIncl);
1039
				wxString   replaceWith   (findWhat);
1040
1041
				replaceWith.Replace(strippedOldInc.GetFullName(), newFile.GetFullName());
1042
1043
				LEditor *editor = Frame::Get()->GetMainBook()->OpenFile(editorFileName, wxEmptyString, 0);
1044
				if (editor && (editor->GetFileName().GetFullPath().CmpNoCase(editorFileName) == 0) ) {
1045
					editor->ReplaceAllExactMatch(findWhat, replaceWith);
1046
				}
2470 by eranif
- Code Refactoring: moved code from Builder interface to the Builder GNU make
1047
			}
1048
		}
1049
	}
1879 by eranif
- Applied patch by Mattia barbon so that codelite will send 2 events when file is renamed: 1 event for the removal of the file and one for adding new fie
1050
	return true;
1051
}
1052
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1053
bool Manager::MoveFileToVD ( const wxString &fileName, const wxString &srcVD, const wxString &targetVD )
1054
{
1055
	// to move the file between targets, we need to change the file path, we do this
1056
	// by changing the file to be in absolute path related to the src's project
1057
	// and then making it relative to the target's project
1058
	wxString srcProject, targetProject;
1059
	srcProject = srcVD.BeforeFirst ( wxT ( ':' ) );
1060
	targetProject = targetVD.BeforeFirst ( wxT ( ':' ) );
1061
	wxFileName srcProjWd ( GetProjectCwd ( srcProject ), wxEmptyString );
1062
1063
	//set a dir saver point
1064
	wxFileName fn ( fileName );
1934 by eranif
Fixed: compilation error on FC11 (wrong initialization of wxArrayString)
1065
	wxArrayString files;
1066
	files.Add(fn.GetFullPath());
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1067
1068
	//remove the file from the source project
1069
	wxString errMsg;
1070
	bool res = WorkspaceST::Get()->RemoveFile ( srcVD, fileName, errMsg );
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
1071
	if ( !res ) {
1072
		wxMessageBox(errMsg, wxT("Error"), wxOK | wxICON_HAND);
1073
		return false;
1074
	}
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1075
	SendCmdEvent(wxEVT_PROJ_FILE_REMOVED, (void*) &files);
1076
1077
	// Add the file to the project
1078
	res = WorkspaceST::Get()->AddNewFile ( targetVD, fn.GetFullPath(), errMsg );
1079
	if ( !res ) {
1080
		//file or virtual dir does not exist
1081
		return false;
1082
	}
1083
	SendCmdEvent(wxEVT_PROJ_FILE_ADDED, (void*) &files);
1084
	return true;
1085
}
1086
2286 by eranif
- Removed the option 'Full retagging' from the tags options dialog
1087
void Manager::RetagProject ( const wxString &projectName, bool quickRetag )
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1088
{
1089
	ProjectPtr proj = GetProject ( projectName );
1735 by eranif
- Fixed: build compilation on Windows
1090
	if ( !proj )
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
1091
		return;
1092
	std::vector<wxFileName> projectFiles;
1093
	proj->GetFiles ( projectFiles, true );
2286 by eranif
- Removed the option 'Full retagging' from the tags options dialog
1094
	TagsManagerST::Get()->RetagFiles ( projectFiles, quickRetag );
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
1095
	SendCmdEvent ( wxEVT_FILE_RETAGGED, ( void* ) &projectFiles );
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1096
}
1097
1098
void Manager::GetProjectFiles ( const wxString &project, wxArrayString &files )
1099
{
1100
	std::vector<wxFileName> fileNames;
1101
	ProjectPtr p = GetProject ( project );
1102
1103
	if ( p ) {
1104
		p->GetFiles ( fileNames, true );
1105
1106
		//convert std::vector to wxArrayString
1107
		for ( std::vector<wxFileName>::iterator it = fileNames.begin(); it != fileNames.end(); it ++ ) {
1108
			files.Add ( ( *it ).GetFullPath() );
1109
		}
1110
	}
1111
}
1112
1113
wxString Manager::GetProjectNameByFile ( const wxString &fullPathFileName )
1114
{
1115
	wxArrayString projects;
1116
	GetProjectList ( projects );
1117
1118
	std::vector<wxFileName> files;
1119
	for ( size_t i=0; i<projects.GetCount(); i++ ) {
1120
		files.clear();
1121
		ProjectPtr proj = GetProject ( projects.Item ( i ) );
1122
		proj->GetFiles ( files, true );
1123
1124
		for ( size_t xx=0; xx<files.size(); xx++ ) {
1967 by eranif
- Added support for compiler Annotations which replaces the compiler error tooltips
1125
			wxString f (files.at ( xx ).GetFullPath());
1126
			if ( f.CmpNoCase(fullPathFileName) == 0 ) {
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1127
				return proj->GetName();
1128
			}
1129
		}
1130
	}
1131
1132
	return wxEmptyString;
1133
}
1134
1135
1136
//--------------------------- Project Settings Mgmt -----------------------------
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1137
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1138
wxString Manager::GetProjectCwd ( const wxString &project ) const
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1139
{
1140
	wxString errMsg;
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1141
	ProjectPtr p = WorkspaceST::Get()->FindProjectByName ( project, errMsg );
1258 by eranif
- Implemented multiple custom targets for the 'Custom Build' option. This allows users to define N targets other than the built-in (Build, Clean) for example: make clean all, make distclean etc.
1142
	if ( !p ) {
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1143
		return wxGetCwd();
1144
	}
1145
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1146
	wxFileName projectFileName ( p->GetFileName() );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1147
	projectFileName.MakeAbsolute();
1148
	return projectFileName.GetPath();
1149
}
1150
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1151
ProjectSettingsPtr Manager::GetProjectSettings ( const wxString &projectName ) const
1152
{
1153
	wxString errMsg;
1154
	ProjectPtr proj = WorkspaceST::Get()->FindProjectByName ( projectName, errMsg );
1155
	if ( !proj ) {
1156
		wxLogMessage ( errMsg );
1157
		return NULL;
1158
	}
1159
1160
	return proj->GetSettings();
1161
}
1162
1163
void Manager::SetProjectSettings ( const wxString &projectName, ProjectSettingsPtr settings )
1164
{
1165
	wxString errMsg;
1166
	ProjectPtr proj = WorkspaceST::Get()->FindProjectByName ( projectName, errMsg );
1167
	if ( !proj ) {
1168
		wxLogMessage ( errMsg );
1169
		return;
1170
	}
1171
1172
	proj->SetSettings ( settings );
1173
}
1174
1820 by eranif
- New: codelite now supports 'Global Settings' configuration. This configuration allows user to set preprocessor/linker options or compiler options which will be applied to all of your project configuration type (by jfouche)
1175
void Manager::SetProjectGlobalSettings ( const wxString &projectName, BuildConfigCommonPtr settings )
1176
{
1177
	wxString errMsg;
1178
	ProjectPtr proj = WorkspaceST::Get()->FindProjectByName ( projectName, errMsg );
1179
	if ( !proj ) {
1180
		wxLogMessage ( errMsg );
1181
		return;
1182
	}
1183
1184
	proj->SetGlobalSettings ( settings );
1185
}
1186
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1187
wxString Manager::GetProjectExecutionCommand ( const wxString& projectName, wxString &wd, bool considerPauseWhenExecuting )
1188
{
1189
	BuildConfigPtr bldConf = WorkspaceST::Get()->GetProjBuildConf ( projectName, wxEmptyString );
1190
	if ( !bldConf ) {
1191
		wxLogMessage ( wxT ( "failed to find project configuration for project '" ) + projectName + wxT ( "'" ) );
1192
		return wxEmptyString;
1193
	}
1194
1195
	//expand variables
1196
	wxString cmd = bldConf->GetCommand();
1735 by eranif
- Fixed: build compilation on Windows
1197
	cmd = ExpandVariables ( cmd, GetProject ( projectName ), Frame::Get()->GetMainBook()->GetActiveEditor() );
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1198
1199
	wxString cmdArgs = bldConf->GetCommandArguments();
1735 by eranif
- Fixed: build compilation on Windows
1200
	cmdArgs = ExpandVariables ( cmdArgs, GetProject ( projectName ), Frame::Get()->GetMainBook()->GetActiveEditor() );
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1201
1202
	//execute command & cmdArgs
1203
	wxString execLine ( cmd + wxT ( " " ) + cmdArgs );
1204
	wd = bldConf->GetWorkingDirectory();
1735 by eranif
- Fixed: build compilation on Windows
1205
	wd = ExpandVariables ( wd, GetProject ( projectName ), Frame::Get()->GetMainBook()->GetActiveEditor() );
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1206
1207
	//change directory to the working directory
1208
	if ( considerPauseWhenExecuting ) {
1209
		ProjectPtr proj = GetProject ( projectName );
1789 by eranif
- terminals launched from codelite for debugging/programs are now configurable from settings -> editor -> terminal
1210
		OptionsConfigPtr opts = EditorConfigST::Get()->GetOptions();
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1211
1212
#if defined(__WXMAC__)
1789 by eranif
- terminals launched from codelite for debugging/programs are now configurable from settings -> editor -> terminal
1213
1214
		execLine = opts->GetProgramConsoleCommand();
1809 by eranif
- Re-design of the UnitTest++ plugin
1215
1791 by eranif
- Fixed; debugger now uses the same terminal specified in the settings -> editor -> terminal settings page
1216
		wxString tmp_cmd;
2635 by eranif
Fixed: BUG#2876338: Executable fails to load in path with space
1217
		tmp_cmd = wxT("cd \"") + proj->GetFileName().GetPath() + wxT ( "\" && cd \"" ) + wd + wxT ( "\" && " ) + cmd + wxT ( " " ) + cmdArgs;
1809 by eranif
- Re-design of the UnitTest++ plugin
1218
1791 by eranif
- Fixed; debugger now uses the same terminal specified in the settings -> editor -> terminal settings page
1219
		execLine.Replace(wxT("$(CMD)"), tmp_cmd);
1220
		execLine.Replace(wxT("$(TITLE)"), cmd + wxT ( " " ) + cmdArgs);
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1221
1222
#elif defined(__WXGTK__)
1789 by eranif
- terminals launched from codelite for debugging/programs are now configurable from settings -> editor -> terminal
1223
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1224
		//set a console to the execute target
1225
		wxString term;
1789 by eranif
- terminals launched from codelite for debugging/programs are now configurable from settings -> editor -> terminal
1226
		term = opts->GetProgramConsoleCommand();
1227
		term.Replace(wxT("$(TITLE)"), cmd + wxT ( " " ) + cmdArgs);
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1228
1789 by eranif
- terminals launched from codelite for debugging/programs are now configurable from settings -> editor -> terminal
1229
		// build the command
1791 by eranif
- Fixed; debugger now uses the same terminal specified in the settings -> editor -> terminal settings page
1230
		wxString command;
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1231
		if ( bldConf->GetPauseWhenExecEnds() ) {
1232
			wxString ld_lib_path;
1233
			wxFileName exePath ( wxStandardPaths::Get().GetExecutablePath() );
1850 by eranif
- rename various scripts to be codelite_* instead of le_* packaing script updated accordingly
1234
			wxFileName exeWrapper ( exePath.GetPath(), wxT ( "codelite_exec" ) );
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1235
1236
			if ( wxGetEnv ( wxT ( "LD_LIBRARY_PATH" ), &ld_lib_path ) && ld_lib_path.IsEmpty() == false ) {
1792 by eranif
- Fixed: regression bug: On linux it is now possible again to launch GUI application with the flag 'pause when execution terminates' is off
1237
				command << wxT ( "/bin/sh -f " ) << exeWrapper.GetFullPath() << wxT ( " LD_LIBRARY_PATH=" ) << ld_lib_path << wxT ( " " );
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1238
			} else {
1792 by eranif
- Fixed: regression bug: On linux it is now possible again to launch GUI application with the flag 'pause when execution terminates' is off
1239
				command << wxT ( "/bin/sh -f " ) << exeWrapper.GetFullPath() << wxT ( " " );
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1240
			}
1241
		}
1809 by eranif
- Re-design of the UnitTest++ plugin
1242
1792 by eranif
- Fixed: regression bug: On linux it is now possible again to launch GUI application with the flag 'pause when execution terminates' is off
1243
		command << execLine;
1789 by eranif
- terminals launched from codelite for debugging/programs are now configurable from settings -> editor -> terminal
1244
		term.Replace(wxT("$(CMD)"), command);
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1245
		execLine = term;
1789 by eranif
- terminals launched from codelite for debugging/programs are now configurable from settings -> editor -> terminal
1246
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1247
#elif defined (__WXMSW__)
1248
1249
		if ( bldConf->GetPauseWhenExecEnds() ) {
1250
			execLine.Prepend ( wxT ( "le_exec.exe " ) );
1251
		}
1252
#endif
1253
	}
1254
	return execLine;
1255
}
1256
1257
1258
//--------------------------- Top Level Pane Management -----------------------------
1259
1260
bool Manager::IsPaneVisible ( const wxString& pane_name )
1261
{
1262
	wxAuiPaneInfo &info = Frame::Get()->GetDockingManager().GetPane ( pane_name );
1263
	if ( info.IsOk() && info.IsShown() ) {
1264
		return true;
1265
	}
1266
	return false;
1267
}
1268
2909 by eranif
Output pane now restores its size properly when toggled
1269
bool Manager::DoFindDockInfo(const wxString &saved_perspective, const wxString &dock_name, wxString &dock_info)
1270
{
1271
	// search for the 'Output View' perspective
1272
	wxArrayString panes = wxStringTokenize(saved_perspective, wxT("|"), wxTOKEN_STRTOK);
1273
	for (size_t i=0; i<panes.GetCount(); i++) {
1274
		if ( panes.Item(i).StartsWith(dock_name) ) {
1275
			dock_info = panes.Item(i);
1276
			return true;
1277
		}
1278
	}
1279
	return false;
1280
}
1281
1282
void Manager::ToggleOutputPane(bool hide)
1283
{
1284
	static wxString saved_dock_info;
1285
	wxAuiManager *aui = &Frame::Get()->GetDockingManager();
3017 by eranif
- When retagging, show a 'wait cursor' for better user hinting
1286
2909 by eranif
Output pane now restores its size properly when toggled
1287
	if ( aui ) {
1288
		wxAuiPaneInfo &pane_info = aui->GetPane(wxT("Output View"));
1289
		wxString dock_info ( wxString::Format(wxT("dock_size(%d,%d,%d)"), pane_info.dock_direction, pane_info.dock_layer, pane_info.dock_row) );
1290
		if ( hide ) {
1291
			if ( pane_info.IsShown() ) {
1292
				Frame::Get()->Freeze();
1293
1294
				DoFindDockInfo(aui->SavePerspective(), dock_info, saved_dock_info);
1295
				pane_info.Hide();
1296
1297
				aui->Update();
1298
1299
				Frame::Get()->Thaw();
1300
			}
1301
1302
1303
		} else {
1304
			// Show it
1305
			if ( pane_info.IsShown() == false ) {
1306
				Frame::Get()->Freeze();
3017 by eranif
- When retagging, show a 'wait cursor' for better user hinting
1307
2909 by eranif
Output pane now restores its size properly when toggled
1308
				if ( saved_dock_info.IsEmpty() ) {
3017 by eranif
- When retagging, show a 'wait cursor' for better user hinting
1309
2909 by eranif
Output pane now restores its size properly when toggled
1310
					pane_info.Show();
1311
					aui->Update();
3017 by eranif
- When retagging, show a 'wait cursor' for better user hinting
1312
2909 by eranif
Output pane now restores its size properly when toggled
1313
				} else {
1314
					wxString auiPerspective = aui->SavePerspective();
1315
					if ( auiPerspective.Find(dock_info) == wxNOT_FOUND ) {
1316
						// the dock_info does not exist
1317
						auiPerspective << saved_dock_info << wxT("|");
1318
						aui->LoadPerspective(auiPerspective, false);
1319
						pane_info.Show();
1320
						aui->Update();
1321
					} else {
1322
						pane_info.Show();
1323
						aui->Update();
1324
					}
1325
				}
1326
				Frame::Get()->Thaw();
1327
			}
1328
		}
1329
	}
1330
}
1331
1332
1333
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1334
bool Manager::ShowOutputPane ( wxString focusWin, bool commit )
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1335
{
1336
	// make the output pane visible
2909 by eranif
Output pane now restores its size properly when toggled
1337
	ToggleOutputPane( false );
3017 by eranif
- When retagging, show a 'wait cursor' for better user hinting
1338
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1339
	// set the selection to focus win
1340
	OutputPane *pane = Frame::Get()->GetOutputPane();
2907 by eranif
- Replaced output view pane with wxToolbook
1341
	int index(wxNOT_FOUND);
1342
	for(size_t i=0; i<pane->GetNotebook()->GetPageCount(); i++) {
1343
		if(pane->GetNotebook()->GetPageText(i) == focusWin) {
1344
			index = (int)i;
1345
			break;
1346
		}
1347
	}
3017 by eranif
- When retagging, show a 'wait cursor' for better user hinting
1348
2907 by eranif
- Replaced output view pane with wxToolbook
1349
	if ( index != wxNOT_FOUND && index != pane->GetNotebook()->GetSelection() ) {
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
1350
		wxWindow *focus = wxWindow::FindFocus();
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1351
		pane->GetNotebook()->SetSelection ( ( size_t ) index );
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
1352
		if (focus) {
1353
			focus->SetFocus();
1354
		}
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1355
	}
2909 by eranif
Output pane now restores its size properly when toggled
1356
	return true;
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1357
}
1358
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1359
void Manager::ShowDebuggerPane ( bool show )
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1360
{
1361
	// make the output pane visible
1362
	wxArrayString dbgPanes;
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1363
	dbgPanes.Add ( wxT ( "Debugger" ) );
1364
	dbgPanes.Add ( DebuggerPane::LOCALS );
1365
	dbgPanes.Add ( DebuggerPane::FRAMES );
1366
	dbgPanes.Add ( DebuggerPane::WATCHES );
1367
	dbgPanes.Add ( DebuggerPane::BREAKPOINTS );
1368
	dbgPanes.Add ( DebuggerPane::THREADS );
1369
	dbgPanes.Add ( DebuggerPane::MEMORY );
1991 by eranif
- Fixed: auto adding of closing brace { on Windows format editors (\r\n) failed to work on some cases
1370
	dbgPanes.Add ( DebuggerPane::ASCII_VIEWER );
1997 by eranif
- codelite now handles assertions in a similar way of segmantation fault (user notification + call stack available)
1371
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1372
	if ( show ) {
1373
1374
		for ( size_t i=0; i<dbgPanes.GetCount(); i++ ) {
1375
			wxAuiPaneInfo &info = Frame::Get()->GetDockingManager().GetPane ( dbgPanes.Item ( i ) );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1376
			// show all debugger related panes
1258 by eranif
- Implemented multiple custom targets for the 'Custom Build' option. This allows users to define N targets other than the built-in (Build, Clean) for example: make clean all, make distclean etc.
1377
			if ( info.IsOk() && !info.IsShown() ) {
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1378
				info.Show();
1379
			}
1380
		}
1381
1258 by eranif
- Implemented multiple custom targets for the 'Custom Build' option. This allows users to define N targets other than the built-in (Build, Clean) for example: make clean all, make distclean etc.
1382
	} else {
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1383
1384
		// hide all debugger related panes
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1385
		for ( size_t i=0; i<dbgPanes.GetCount(); i++ ) {
1386
			wxAuiPaneInfo &info = Frame::Get()->GetDockingManager().GetPane ( dbgPanes.Item ( i ) );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1387
			// show all debugger related panes
1258 by eranif
- Implemented multiple custom targets for the 'Custom Build' option. This allows users to define N targets other than the built-in (Build, Clean) for example: make clean all, make distclean etc.
1388
			if ( info.IsOk() && info.IsShown() ) {
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1389
				info.Hide();
1390
			}
1391
		}
1392
	}
1393
	Frame::Get()->GetDockingManager().Update();
1394
1395
}
1396
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1397
void Manager::ShowWorkspacePane ( wxString focusWin, bool commit )
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1398
{
1399
	// make the output pane visible
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1400
	wxAuiPaneInfo &info = Frame::Get()->GetDockingManager().GetPane ( wxT ( "Workspace View" ) );
1258 by eranif
- Implemented multiple custom targets for the 'Custom Build' option. This allows users to define N targets other than the built-in (Build, Clean) for example: make clean all, make distclean etc.
1401
	if ( info.IsOk() && !info.IsShown() ) {
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1402
		info.Show();
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1403
		if ( commit ) {
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1404
			Frame::Get()->GetDockingManager().Update();
1405
		}
1406
	}
1407
1408
	// set the selection to focus win
1571 by eranif
- Remote debugging: Added the ability to send commands to the debugger after attaching to the remote target and before the 'continue' command. The commands can be set from project settings -> debugger
1409
	Notebook *book = Frame::Get()->GetWorkspacePane()->GetNotebook();
1493 by eranif
- code refactoring to workspace tab - Scott Dolim
1410
	int index = book->GetPageIndex ( focusWin );
1411
	if ( index != wxNOT_FOUND && ( size_t ) index != book->GetSelection() ) {
1412
		book->SetSelection ( ( size_t ) index );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1413
	}
1414
}
1415
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1416
void Manager::HidePane ( const wxString &paneName, bool commit )
1417
{
1418
	wxAuiPaneInfo &info = Frame::Get()->GetDockingManager().GetPane ( paneName );
1419
	if ( info.IsOk() && info.IsShown() ) {
1420
		info.Hide();
1421
		if ( commit ) {
1422
			Frame::Get()->GetDockingManager().Update();
1423
		}
1424
	}
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1425
}
1426
1427
void Manager::TogglePanes()
1428
{
1429
	static bool toggled = false;
2090 by eranif
- Toggle all panes now restores the panes to the exact size and location
1430
	static wxString savedLayout;
1431
1195 by eranif
- spelling fixes
1432
	// list of panes to be toggled on and off
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1433
	static wxArrayString panes;
1434
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1435
	if ( !toggled ) {
2090 by eranif
- Toggle all panes now restores the panes to the exact size and location
1436
		savedLayout = Frame::Get()->GetDockingManager().SavePerspective();
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1437
		panes.Clear();
1438
		// create the list of panes to be tested
1439
		wxArrayString candidates;
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1440
		candidates.Add ( wxT ( "Output View" ) );
1441
		candidates.Add ( wxT ( "Workspace View" ) );
1442
		candidates.Add ( wxT ( "Debugger" ) );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1443
1444
		// add the detached tabs list
1445
		wxArrayString dynamicPanes = Frame::Get()->GetDockablePaneMenuManager()->GetDeatchedPanesList();
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1446
		for ( size_t i=0; i<dynamicPanes.GetCount(); i++ ) {
1447
			candidates.Add ( dynamicPanes.Item ( i ) );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1448
		}
1449
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1450
		for ( size_t i=0; i<candidates.GetCount(); i++ ) {
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1451
			wxAuiPaneInfo info;
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1452
			info = Frame::Get()->GetDockingManager().GetPane ( candidates.Item ( i ) );
1453
			if ( info.IsOk() && info.IsShown() ) {
1454
				panes.Add ( candidates.Item ( i ) );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1455
			}
1456
		}
2103 by eranif
- Icons update
1457
2135 by eranif
- changed the 'show quick finder' toolbar entry to be toggled tool
1458
		Frame::Get()->GetMainPanel()->Freeze();
1195 by eranif
- spelling fixes
1459
		// hide the matched panes
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1460
		for ( size_t i=0; i<panes.GetCount(); i++ ) {
1461
			HidePane ( panes.Item ( i ), false );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1462
		}
1463
1464
		//update changes
1465
		Frame::Get()->GetDockingManager().Update();
2135 by eranif
- changed the 'show quick finder' toolbar entry to be toggled tool
1466
		Frame::Get()->GetMainPanel()->Thaw();
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1467
		toggled = true;
1468
1258 by eranif
- Implemented multiple custom targets for the 'Custom Build' option. This allows users to define N targets other than the built-in (Build, Clean) for example: make clean all, make distclean etc.
1469
	} else {
2135 by eranif
- changed the 'show quick finder' toolbar entry to be toggled tool
1470
		Frame::Get()->GetMainPanel()->Freeze();
2090 by eranif
- Toggle all panes now restores the panes to the exact size and location
1471
		Frame::Get()->GetDockingManager().LoadPerspective(savedLayout);
2135 by eranif
- changed the 'show quick finder' toolbar entry to be toggled tool
1472
		Frame::Get()->GetMainPanel()->Thaw();
2103 by eranif
- Icons update
1473
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1474
		toggled = false;
2090 by eranif
- Toggle all panes now restores the panes to the exact size and location
1475
		savedLayout.Clear();
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1476
	}
1477
}
1478
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1479
1480
//--------------------------- Menu and Accelerator Mmgt -----------------------------
1481
1482
void Manager::UpdateMenuAccelerators()
1483
{
1484
	MenuItemDataMap menuMap, defAccelMap;
1485
1486
	wxArrayString files;
1487
	DoGetAccelFiles ( files );
1488
1489
	// load user accelerators map
1490
	LoadAcceleratorTable ( files, menuMap );
1491
1492
	// load the default accelerator map
1493
	GetDefaultAcceleratorMap ( defAccelMap );
1494
1495
	// loop over default accelerators map, and search for items that does not exist in the user's list
1496
	std::map< wxString, MenuItemData >::iterator it = defAccelMap.begin();
1497
	for ( ; it != defAccelMap.end(); it++ ) {
1498
		if ( menuMap.find ( it->first ) == menuMap.end() ) {
1499
			// this item does not exist in the users accelerators
1500
			// probably a new accelerator that was added to the default
1501
			// files directly via update/manually modified it
1502
			menuMap[it->first] = it->second;
1503
		}
1504
	}
1505
1506
	wxMenuBar *bar = Frame::Get()->GetMenuBar();
1507
1508
	wxString content;
1509
	std::vector< wxAcceleratorEntry > accelVec;
1510
	size_t count = bar->GetMenuCount();
1511
	for ( size_t i=0; i< count; i++ ) {
1512
		wxMenu * menu = bar->GetMenu ( i );
1513
		UpdateMenu ( menu, menuMap, accelVec );
1514
	}
1515
1516
	//In case we still have items to map, map them. this can happen for items
1517
	//which exist in the list but does not have any menu associated to them in the menu bar (e.g. C++ menu)
1518
	if ( menuMap.empty() == false ) {
1519
//		wxString msg;
1520
//		msg << wxT("Info: UpdateMenuAccelerators: There are still ") << menuMap.size() << wxT(" un-mapped item(s)");
1521
//		wxLogMessage(msg);
1522
1523
		MenuItemDataMap::iterator iter = menuMap.begin();
1524
		for ( ; iter != menuMap.end(); iter++ ) {
1525
			MenuItemData itemData = iter->second;
1526
1527
			wxString txt;
1528
			txt << itemData.action;
1529
			if ( itemData.accel.IsEmpty() == false ) {
1530
				txt << wxT ( "\t" ) << itemData.accel;
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1531
			}
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1532
1533
			wxAcceleratorEntry* a = wxAcceleratorEntry::Create ( txt );
1534
			if ( a ) {
1535
				long commandId ( 0 );
1536
				itemData.id.ToLong ( &commandId );
1537
1538
				//use the resource ID
1539
				if ( commandId == 0 ) {
1540
					commandId = wxXmlResource::GetXRCID ( itemData.id );
1541
				}
1542
1543
				a->Set ( a->GetFlags(), a->GetKeyCode(), commandId );
1544
				accelVec.push_back ( *a );
1545
				delete a;
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
1546
			}
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1547
		}
1548
	}
1549
1550
	if ( content.IsEmpty() == false ) {
1551
		wxFFile f ( GetStarupDirectory() + wxT ( "/config/accelerators.conf" ), wxT ( "w+b" ) );
1552
		f.Write ( content );
1553
		f.Close();
1554
	}
1555
1556
	//update the accelerator table of the main frame
1557
	wxAcceleratorEntry *entries = new wxAcceleratorEntry[accelVec.size() ];
1558
	for ( size_t i=0; i < accelVec.size(); i++ ) {
1559
		entries[i] = accelVec[i];
1560
	}
1561
1562
	wxAcceleratorTable table ( accelVec.size(), entries );
1563
1564
	//update the accelerator table
1565
	Frame::Get()->SetAcceleratorTable ( table );
1566
	delete [] entries;
1567
}
1735 by eranif
- Fixed: build compilation on Windows
1568
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1569
void Manager::LoadAcceleratorTable ( const wxArrayString &files, MenuItemDataMap &accelMap )
1570
{
1571
	wxString content;
1572
	for ( size_t i=0; i<files.GetCount(); i++ ) {
1573
		wxString tmpContent;
1574
		if ( ReadFileWithConversion ( files.Item ( i ), tmpContent ) ) {
1575
			wxLogMessage ( wxString::Format ( wxT ( "Loading accelerators from '%s'" ), files.Item ( i ).c_str() ) );
1576
			content << wxT ( "\n" ) << tmpContent;
1577
		}
1578
	}
1579
1580
	wxArrayString lines = wxStringTokenize ( content, wxT ( "\n" ) );
1581
	for ( size_t i = 0; i < lines.GetCount(); i ++ ) {
1582
		if ( lines.Item ( i ).Trim().Trim ( false ).IsEmpty() ) {
1583
			continue;
1584
		}
1585
1586
		MenuItemData item;
1587
		wxString line = lines.Item ( i );
1588
1589
		item.id = line.BeforeFirst ( wxT ( '|' ) );
1590
		line = line.AfterFirst ( wxT ( '|' ) );
1591
1592
		item.parent = line.BeforeFirst ( wxT ( '|' ) );
1593
		line = line.AfterFirst ( wxT ( '|' ) );
1594
1595
		item.action = line.BeforeFirst ( wxT ( '|' ) );
1596
		line = line.AfterFirst ( wxT ( '|' ) );
1597
1598
		item.accel = line.BeforeFirst ( wxT ( '|' ) );
1599
		line = line.AfterFirst ( wxT ( '|' ) );
1600
1601
		accelMap[item.action] = item;
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
1602
	}
1603
}
1735 by eranif
- Fixed: build compilation on Windows
1604
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1605
void Manager::UpdateMenu ( wxMenu *menu, MenuItemDataMap &accelMap, std::vector< wxAcceleratorEntry > &accelVec )
1606
{
1607
	wxMenuItemList items = menu->GetMenuItems();
1608
	wxMenuItemList::iterator iter = items.begin();
1609
	for ( ; iter != items.end(); iter++ ) {
1610
		wxMenuItem *item =  *iter;
1611
		if ( item->GetSubMenu() ) {
1612
			UpdateMenu ( item->GetSubMenu(), accelMap, accelVec );
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
1613
		} else {
1614
1615
			if ( item->GetId() == wxID_SEPARATOR ) {
1616
				continue;
1617
			}
1618
1619
			//search this item in the accelMap
1620
			wxString labelText = StripAccelAndNemonics ( item->GetText() );
1621
			if ( accelMap.find ( labelText ) != accelMap.end() ) {
1622
				MenuItemData item_data = accelMap.find ( labelText )->second;
1623
1624
				wxString txt;
1625
				txt << StripAccel ( item->GetText() );
1626
1627
				//set the new accelerator
1628
				if ( item_data.accel.IsEmpty() == false ) {
1629
					txt << wxT ( "\t" ) << item_data.accel;
1630
				}
1631
1632
				txt.Replace ( wxT ( "_" ), wxT ( "&" ) );
1633
				item->SetText ( txt );
1634
1635
				wxAcceleratorEntry* a = wxAcceleratorEntry::Create ( txt );
1636
				if ( a ) {
1637
					a->Set ( a->GetFlags(), a->GetKeyCode(), item->GetId() );
1638
					accelVec.push_back ( *a );
1639
					delete a;
1640
				}
1641
1642
				//remove this entry from the map
1643
				accelMap.erase ( labelText );
1644
			}
1735 by eranif
- Fixed: build compilation on Windows
1645
		}
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1646
	}
1647
}
1735 by eranif
- Fixed: build compilation on Windows
1648
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
1649
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1650
void Manager::GetDefaultAcceleratorMap ( MenuItemDataMap& accelMap )
1651
{
1652
	//use the default settings
1653
	wxString fileName = GetStarupDirectory() + wxT ( "/config/accelerators.conf.default" );
1654
	wxArrayString files;
1655
	files.Add ( fileName );
1656
1657
	// append the content of all '*.accelerators' from the plugins
1658
	// resources table
1826 by eranif
- applied changes to use macros fromconfigure script to locate plugins direcotry as well as the installation directory
1659
#ifdef __WXGTK__
1660
	wxString pluginsDir(PLUGINS_DIR, wxConvUTF8);
1661
#else
1662
	wxString pluginsDir(ManagerST::Get()->GetInstallDir() + wxT( "/plugins" ));
1663
#endif
1664
1665
	wxDir::GetAllFiles ( pluginsDir + wxT ( "/resources/" ), &files, wxT ( "*.accelerators" ), wxDIR_FILES );
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1666
	LoadAcceleratorTable ( files, accelMap );
1667
}
1668
1669
void Manager::GetAcceleratorMap ( MenuItemDataMap& accelMap )
1670
{
1671
	wxArrayString files;
1672
	DoGetAccelFiles ( files );
1673
	LoadAcceleratorTable ( files, accelMap );
1674
}
1675
1676
void Manager::DoGetAccelFiles ( wxArrayString& files )
1677
{
1678
	//try to locate the user's settings
1679
	wxString fileName ( GetStarupDirectory() + wxT ( "/config/accelerators.conf" ) );
1680
	if ( !wxFileName::FileExists ( GetStarupDirectory() + wxT ( "/config/accelerators.conf" ) ) ) {
1681
1682
		//use the default settings
1683
		fileName = GetStarupDirectory() + wxT ( "/config/accelerators.conf.default" );
1684
		files.Add ( fileName );
1826 by eranif
- applied changes to use macros fromconfigure script to locate plugins direcotry as well as the installation directory
1685
#ifdef __WXGTK__
1686
		wxString pluginsDir(PLUGINS_DIR, wxConvUTF8);
1687
#else
1688
		wxString pluginsDir(ManagerST::Get()->GetInstallDir() + wxT( "/plugins" ));
1689
#endif
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1690
		// append the content of all '*.accelerators' from the plugins
1691
		// resources table
1826 by eranif
- applied changes to use macros fromconfigure script to locate plugins direcotry as well as the installation directory
1692
		wxDir::GetAllFiles (pluginsDir + wxT ( "/resources/" ), &files, wxT ( "*.accelerators" ), wxDIR_FILES );
1258 by eranif
- Implemented multiple custom targets for the 'Custom Build' option. This allows users to define N targets other than the built-in (Build, Clean) for example: make clean all, make distclean etc.
1693
	} else {
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1694
		files.Add ( fileName );
1695
	}
1696
}
1735 by eranif
- Fixed: build compilation on Windows
1697
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1698
void Manager::DumpMenu ( wxMenu *menu, const wxString &label, wxString &content )
1699
{
1850 by eranif
- rename various scripts to be codelite_* instead of le_* packaing script updated accordingly
1700
#if 0
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1701
	wxMenuItemList items = menu->GetMenuItems();
1702
	wxMenuItemList::iterator iter = items.begin();
1703
	for ( ; iter != items.end(); iter++ ) {
1704
		wxMenuItem *item = *iter;
1705
		if ( item->GetSubMenu() ) {
1706
			DumpMenu ( item->GetSubMenu(), label + wxT ( "::" ) + item->GetLabel(), content );
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
1707
			continue;
1708
		}
1709
		if ( item->GetId() == wxID_SEPARATOR ) {
1710
			continue;
1711
		} else if ( item->GetId() >= RecentFilesSubMenuID && item->GetId() <= RecentFilesSubMenuID + 10 ) {
1712
			continue;
1713
		} else if ( item->GetId() >= RecentWorkspaceSubMenuID && item->GetId() <= RecentWorkspaceSubMenuID + 10 ) {
1714
			continue;
1715
		}
1716
		//dump the content of this menu item
1717
		content << item->GetId() << wxT ( "|" )
1718
		<< label << wxT ( "|" )
1719
		<< wxMenuItem::GetLabelText(item->GetItemLabel()) << wxT ( "|" );
1720
		if ( item->GetAccel() ) {
1721
			content << item->GetAccel()->ToString();
1722
		}
1723
		content << wxT ( "\n" );
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1724
	}
1850 by eranif
- rename various scripts to be codelite_* instead of le_* packaing script updated accordingly
1725
#endif
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1726
}
1735 by eranif
- Fixed: build compilation on Windows
1727
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1728
1729
//--------------------------- Run Program (No Debug) -----------------------------
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1730
1731
bool Manager::IsProgramRunning() const
1732
{
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1733
	return ( m_asyncExeCmd && m_asyncExeCmd->IsBusy() );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1734
}
1735
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1736
void Manager::ExecuteNoDebug ( const wxString &projectName )
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1737
{
1738
	//an instance is already running
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1739
	if ( m_asyncExeCmd && m_asyncExeCmd->IsBusy() ) {
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1740
		return;
1741
	}
1742
	wxString wd;
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1743
1744
	// we call it here once for the 'wd'
1745
	wxString execLine = GetProjectExecutionCommand ( projectName, wd, true );
1746
	ProjectPtr proj = GetProject ( projectName );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1747
1748
	DirSaver ds;
1749
1750
	//print the current directory
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1751
	::wxSetWorkingDirectory ( proj->GetFileName().GetPath() );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1752
1753
	//now set the working directory according to working directory field from the
1754
	//project settings
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1755
	::wxSetWorkingDirectory ( wd );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1756
1757
	//execute the command line
1195 by eranif
- spelling fixes
1758
	//the a sync command is a one time executable object,
1671 by sdolim
- Refactored ShellTab so it derives from OutputTabWindow
1759
	m_asyncExeCmd = new AsyncExeCmd (Frame::Get()->GetOutputPane()->GetOutputWindow());
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1760
1761
	//execute the program:
1762
	//- no hiding the console
1763
	//- no redirection of the stdin/out
2650 by eranif
- Environment variables: Workspace can now uses its own set of environment variable. This is now avaiable from the workspace settings dialog
1764
	EnvSetter env;
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1765
1420 by eranif
- Fixed: CodeLite will now set LD_LIBRARY_PATH when launching command (project settings -> general tab) (Linux only)
1766
	// call it again here to get the actual exection line - we do it here since
1767
	// the environment has been applied
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1768
	execLine = GetProjectExecutionCommand ( projectName, wd, true );
1769
	m_asyncExeCmd->Execute ( execLine, false, false );
1770
1771
	if ( m_asyncExeCmd->GetProcess() ) {
1772
		m_asyncExeCmd->GetProcess()->Connect ( wxEVT_END_PROCESS, wxProcessEventHandler ( Manager::OnProcessEnd ), NULL, this );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1773
	}
1774
}
1775
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1776
void Manager::KillProgram()
1777
{
1778
	if ( !IsProgramRunning() )
1779
		return;
1780
1781
	m_asyncExeCmd->Terminate();
1782
}
1783
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1784
void Manager::OnProcessEnd ( wxProcessEvent &event )
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1785
{
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1786
	m_asyncExeCmd->ProcessEnd ( event );
1787
	m_asyncExeCmd->GetProcess()->Disconnect ( wxEVT_END_PROCESS, wxProcessEventHandler ( Manager::OnProcessEnd ), NULL, this );
2585 by eranif
- Force closing of running application if its launcher terminal window is closed manually by a user
1788
1789
#ifdef __WXMSW__
1790
	// On Windows, sometimes killing the DOS Windows, does not kill the children
1791
	m_asyncExeCmd->Terminate();
1792
#endif
1793
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1794
	delete m_asyncExeCmd;
1795
	m_asyncExeCmd = NULL;
1796
1797
	//return the focus back to the editor
1539 by sdolim
Further refactoring of MainBook. All references to MainBook's Notebook are now private, so it is ready to add the splitter window.
1798
	if ( Frame::Get()->GetMainBook()->GetActiveEditor() ) {
1799
		Frame::Get()->GetMainBook()->GetActiveEditor()->SetActive();
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1800
	}
1801
}
1802
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1803
1804
//--------------------------- Debugger Support -----------------------------
1805
1806
static bool HideDebuggerPane = true;
1735 by eranif
- Fixed: build compilation on Windows
1807
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1808
static void DebugMessage ( wxString msg )
1809
{
1810
	Frame::Get()->GetOutputPane()->GetDebugWindow()->AppendLine(msg);
1811
}
1812
1813
void Manager::UpdateDebuggerPane()
1814
{
1815
	//Update the debugger pane
1816
	DebuggerPane *pane = Frame::Get()->GetDebuggerPane();
1817
2103 by eranif
- Icons update
1818
	if ( ( IsPaneVisible ( wxT ( "Debugger" ) ) && pane->GetNotebook()->GetCurrentPage() == ( wxWindow* ) pane->GetBreakpointView() ) || IsPaneVisible ( DebuggerPane::BREAKPOINTS) ) {
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1819
		pane->GetBreakpointView()->Initialize();
1820
	}
1821
1822
	IDebugger *dbgr = DebuggerMgr::Get().GetActiveDebugger();
1823
	if ( dbgr && dbgr->IsRunning() && DbgCanInteract() ) {
1824
1825
		//--------------------------------------------------------------------
1826
		// Lookup the selected tab in the debugger notebook and update it
1827
		// once this is done, we need to go through the list of detached panes
1828
		// and scan for another debugger tabs which are visible and need to be
1829
		// updated
1830
		//--------------------------------------------------------------------
1831
2350 by eranif
- Debugger: 'Locals' now uses table instead of tree. This new method is much more stable and accurtate than the previous one used. d-clicking on an item, will automatically show the 'display variable' dialog with the item de-referenced
1832
		if ( ( IsPaneVisible ( wxT ( "Debugger" ) ) && pane->GetNotebook()->GetCurrentPage() == pane->GetLocalsTable() ) || IsPaneVisible ( DebuggerPane::LOCALS ) ) {
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1833
1834
			//update the locals tree
1835
			dbgr->QueryLocals();
1836
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
1837
		}
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1838
1839
		if ( ( IsPaneVisible ( wxT ( "Debugger" ) ) && pane->GetNotebook()->GetCurrentPage() == pane->GetWatchesTable() ) || IsPaneVisible ( DebuggerPane::WATCHES ) ) {
1840
1841
			//update the watches table
1842
			wxArrayString expressions = pane->GetWatchesTable()->GetExpressions();
1843
			wxString format = pane->GetWatchesTable()->GetDisplayFormat();
1844
			for ( size_t i=0; i<expressions.GetCount(); i++ ) {
1845
				dbgr->EvaluateExpressionToString ( expressions.Item ( i ), format );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1846
			}
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1847
1848
		}
1849
		if ( ( IsPaneVisible ( wxT ( "Debugger" ) ) && pane->GetNotebook()->GetCurrentPage() == ( wxWindow* ) pane->GetFrameListView() ) || IsPaneVisible ( DebuggerPane::FRAMES ) ) {
1850
1851
			//update the stack call
1852
			dbgr->ListFrames();
1853
1854
		}
1855
		if ( ( IsPaneVisible ( wxT ( "Debugger" ) ) && pane->GetNotebook()->GetCurrentPage() == ( wxWindow* ) pane->GetBreakpointView() ) || IsPaneVisible ( DebuggerPane::BREAKPOINTS ) ) {
1856
1857
			// update the breakpoint view
1858
			pane->GetBreakpointView()->Initialize();
1859
1860
		}
1861
		if ( ( IsPaneVisible ( wxT ( "Debugger" ) ) && pane->GetNotebook()->GetCurrentPage() == ( wxWindow* ) pane->GetThreadsView() ) || IsPaneVisible ( DebuggerPane::THREADS ) ) {
1862
1863
			// update the thread list
2309 by eranif
- GDB plugin no longer uses 'synchronous' commands, only ASYNC commands
1864
			dbgr->ListThreads();
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1865
		}
1997 by eranif
- codelite now handles assertions in a similar way of segmantation fault (user notification + call stack available)
1866
2109 by eranif
- Fixed regression: 'New Class' from context virtual folder context menu now working again
1867
//		if ( ( IsPaneVisible ( wxT ( "Debugger" ) ) && pane->GetNotebook()->GetCurrentPage() == ( wxWindow* ) pane->GetAsciiViewer() ) || IsPaneVisible ( DebuggerPane::ASCII_VIEWER ) ) {
1868
//
1869
//			// re-evaluate the expression
1870
//			pane->GetAsciiViewer()->SetDebugger( dbgr );
1871
//			pane->GetAsciiViewer()->UpdateView();
1872
//
1873
//		}
1997 by eranif
- codelite now handles assertions in a similar way of segmantation fault (user notification + call stack available)
1874
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1875
		if ( ( IsPaneVisible ( wxT ( "Debugger" ) ) && pane->GetNotebook()->GetCurrentPage() == ( wxWindow* ) pane->GetMemoryView() ) || IsPaneVisible ( DebuggerPane::MEMORY ) ) {
1876
1877
			// Update the memory view tab
1878
			MemoryView *memView = pane->GetMemoryView();
1879
			if ( memView->GetExpression().IsEmpty() == false ) {
1880
1881
				wxString output;
2309 by eranif
- GDB plugin no longer uses 'synchronous' commands, only ASYNC commands
1882
				dbgr->WatchMemory ( memView->GetExpression(), memView->GetSize() );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1883
			}
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1884
		}
1885
	}
1886
}
1887
1888
void Manager::SetMemory ( const wxString& address, size_t count, const wxString &hex_value )
1889
{
1890
	IDebugger *dbgr = DebuggerMgr::Get().GetActiveDebugger();
1891
	if ( dbgr && dbgr->IsRunning() && DbgCanInteract() ) {
1892
		dbgr->SetMemory ( address, count, hex_value );
1893
	}
1894
}
1735 by eranif
- Fixed: build compilation on Windows
1895
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
1896
1897
// Debugger API
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1898
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1899
void Manager::DbgStart ( long pid )
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1900
{
1901
	//set the working directory to the project directory
2351 by eranif
- Debugger: New 'locals' view now also displays the function arguments
1902
	DirSaver            ds;
1903
	wxString            errMsg;
1904
	wxString            output;
1905
	wxString            debuggerName;
1906
	wxString            exepath;
1907
	wxString            wd;
1908
	wxString            args;
1909
	BuildConfigPtr      bldConf;
1910
	ProjectPtr          proj;
1952 by eranif
- Applied patch which adds teh following events to the plugins system:
1911
	DebuggerStartupInfo startup_info;
2351 by eranif
- Debugger: New 'locals' view now also displays the function arguments
1912
	long                PID ( -1 );
1249 by eranif
- added option to disable parsing of source file automatically when the file is saved
1913
1243 by eranif
"
1914
#if defined(__WXGTK__)
1915
	wxString where;
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1916
	if ( !ExeLocator::Locate ( wxT ( "xterm" ), where ) ) {
1917
		wxMessageBox ( _ ( "Failed to locate 'xterm' application required by CodeLite, please install it and try again!" ), wxT ( "CodeLite" ), wxOK|wxCENTER|wxICON_WARNING, Frame::Get() );
1243 by eranif
"
1918
		return;
1919
	}
1249 by eranif
- added option to disable parsing of source file automatically when the file is saved
1920
#endif
1139 by eranif
- Implemented [ codelite-Feature Requests-2092921 ] A new workspace should have a release configuration as well
1921
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1922
	if ( pid == 1 ) { //attach to process
1923
		AttachDbgProcDlg *dlg = new AttachDbgProcDlg ( NULL );
1924
		if ( dlg->ShowModal() == wxID_OK ) {
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1925
			wxString processId = dlg->GetProcessId();
1926
			exepath   = dlg->GetExeName();
1927
			debuggerName = dlg->GetDebugger();
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1928
			DebuggerMgr::Get().SetActiveDebugger ( debuggerName );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1929
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1930
			processId.ToLong ( &PID );
1931
			if ( exepath.IsEmpty() == false ) {
1932
				wxFileName fn ( exepath );
1933
				wxSetWorkingDirectory ( fn.GetPath() );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1934
				exepath = fn.GetFullName();
1935
1936
			}
1937
			dlg->Destroy();
1952 by eranif
- Applied patch which adds teh following events to the plugins system:
1938
1939
			startup_info.pid = PID;
1258 by eranif
- Implemented multiple custom targets for the 'Custom Build' option. This allows users to define N targets other than the built-in (Build, Clean) for example: make clean all, make distclean etc.
1940
		} else {
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1941
			dlg->Destroy();
1942
			return;
1943
		}
1944
	}
1945
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1946
	if ( pid == wxNOT_FOUND ) {
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1947
		//need to debug the current project
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1948
		proj = WorkspaceST::Get()->FindProjectByName ( GetActiveProjectName(), errMsg );
1949
		if ( proj ) {
1950
			wxSetWorkingDirectory ( proj->GetFileName().GetPath() );
1951
			bldConf = WorkspaceST::Get()->GetProjBuildConf ( proj->GetName(), wxEmptyString );
1952
			if ( bldConf ) {
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1953
				debuggerName = bldConf->GetDebuggerType();
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1954
				DebuggerMgr::Get().SetActiveDebugger ( debuggerName );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1955
			}
1956
		}
1952 by eranif
- Applied patch which adds teh following events to the plugins system:
1957
1958
		startup_info.project = GetActiveProjectName();
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1959
	}
1960
1961
	//make sure we have an active debugger
1952 by eranif
- Applied patch which adds teh following events to the plugins system:
1962
	IDebugger *dbgr = DebuggerMgr::Get().GetActiveDebugger();
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1963
	if ( !dbgr ) {
1195 by eranif
- spelling fixes
1964
		//No debugger available,
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1965
		wxString message;
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1966
		message << wxT ( "Failed to launch debugger '" ) << debuggerName << wxT ( "': debugger not loaded\n" );
1967
		message << wxT ( "Make sure that you have an open workspace and that the active project is of type 'Executable'" );
1968
		wxMessageBox ( message, wxT ( "CodeLite" ), wxOK|wxICON_WARNING );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1969
		return;
1970
	}
1952 by eranif
- Applied patch which adds teh following events to the plugins system:
1971
	startup_info.debugger = dbgr;
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1972
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1973
	if ( dbgr->IsRunning() ) {
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1974
		//debugger is already running, so issue a 'cont' command
1975
		dbgr->Continue();
1976
		dbgr->QueryFileLine();
1977
		return;
1978
	}
1979
1980
	//set the debugger information
1981
	DebuggerInformation dinfo;
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1982
	DebuggerMgr::Get().GetDebuggerInformation ( debuggerName, dinfo );
1983
1314 by eranif
- New: added option to select debugger binary per project configuration (project settings -> debugger)
1984
	// if user override the debugger path, apply it
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1985
	if ( bldConf ) {
1314 by eranif
- New: added option to select debugger binary per project configuration (project settings -> debugger)
1986
		wxString userDebuggr = bldConf->GetDebuggerPath();
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1987
		userDebuggr.Trim().Trim ( false );
1988
		if ( userDebuggr.IsEmpty() == false ) {
1314 by eranif
- New: added option to select debugger binary per project configuration (project settings -> debugger)
1989
			dinfo.path = userDebuggr;
1990
		}
1991
	}
1791 by eranif
- Fixed; debugger now uses the same terminal specified in the settings -> editor -> terminal settings page
1992
	// read the console command
1993
	dinfo.consoleCommand = EditorConfigST::Get()->GetOptions()->GetProgramConsoleCommand();
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1994
	dbgr->SetDebuggerInformation ( dinfo );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1995
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1996
	if ( pid == wxNOT_FOUND ) {
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
1997
		exepath = bldConf->GetCommand();
1998
		args = bldConf->GetCommandArguments();
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
1999
		exepath.Prepend ( wxT ( "\"" ) );
2000
		exepath.Append ( wxT ( "\"" ) );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2001
		wd = bldConf->GetWorkingDirectory();
2002
2003
		// Expand variables before passing them to the debugger
1735 by eranif
- Fixed: build compilation on Windows
2004
		wd = ExpandVariables ( wd, proj, Frame::Get()->GetMainBook()->GetActiveEditor() );
2005
		exepath = ExpandVariables ( exepath, proj, Frame::Get()->GetMainBook()->GetActiveEditor() );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2006
	}
2007
2008
	//get the debugger path to execute
2009
	DebuggerInformation dbginfo;
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2010
	DebuggerMgr::Get().GetDebuggerInformation ( debuggerName, dbginfo );
2011
1314 by eranif
- New: added option to select debugger binary per project configuration (project settings -> debugger)
2012
	// if user override the debugger path, apply it
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2013
	if ( bldConf ) {
1314 by eranif
- New: added option to select debugger binary per project configuration (project settings -> debugger)
2014
		wxString userDebuggr = bldConf->GetDebuggerPath();
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2015
		userDebuggr.Trim().Trim ( false );
2016
		if ( userDebuggr.IsEmpty() == false ) {
1314 by eranif
- New: added option to select debugger binary per project configuration (project settings -> debugger)
2017
			dbginfo.path = userDebuggr;
2018
		}
2019
	}
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2020
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2021
	wxString dbgname = dbginfo.path;
3020 by eranif
- Environment variables: it is now possible to place an environment variables inside another:
2022
	dbgname = EnvironmentConfig::Instance()->ExpandVariables ( dbgname, true );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2023
2024
	//set ourselves as the observer for the debugger class
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2025
	dbgr->SetObserver ( this );
3017 by eranif
- When retagging, show a 'wait cursor' for better user hinting
2026
2685 by eranif
- Fixed: BUG#2933450: Breakpoints set too early for winedbg remote debugging - When debugging a remote target, the breakpoints will be set after codelite successfully attaches to the debugger server
2027
	// Set the 'Is remote debugging' flag'
2028
	dbgr->SetIsRemoteDebugging(bldConf && bldConf->GetIsDbgRemoteTarget() && PID == wxNOT_FOUND);
3017 by eranif
- When retagging, show a 'wait cursor' for better user hinting
2029
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2030
	// Loop through the open editors and let each editor
1195 by eranif
- spelling fixes
2031
	// a chance to update the debugger manager with any line
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2032
	// changes (i.e. file was edited and breakpoints were moved)
1195 by eranif
- spelling fixes
2033
	// this loop must take place before the debugger start up
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2034
	// or else call to UpdateBreakpoint() will yield an attempt to
2035
	// actually add the breakpoint before Run() is called - this can
1139 by eranif
- Implemented [ codelite-Feature Requests-2092921 ] A new workspace should have a release configuration as well
2036
	// be a problem when adding breakpoint to dll files.
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2037
	if ( wxNOT_FOUND == pid ) {
1571 by eranif
- Remote debugging: Added the ability to send commands to the debugger after attaching to the remote target and before the 'continue' command. The commands can be set from project settings -> debugger
2038
		Frame::Get()->GetMainBook()->UpdateBreakpoints();
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2039
	}
1656 by eranif
- Fixed: debugger now synchronized breakpoints with the UI (when the UI is updated)
2040
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2041
	//We can now get all the gathered breakpoints from the manager
2042
	std::vector<BreakpointInfo> bps;
1656 by eranif
- Fixed: debugger now synchronized breakpoints with the UI (when the UI is updated)
2043
2044
	// since files may have been updated and the breakpoints may have been moved,
2045
	// delete all the information
1638 by eranif
- Applied debugger patch (David Hart)
2046
	GetBreakpointsMgr()->GetBreakpoints ( bps );
2271 by eranif
- Debugger: if gdb fails to set a breakpoint (due to various reasons) a new button will show up in the 'Breakpoints' tab, 'Set Pending' by clicking it, codelite will interrupt the debuggee and re-apply it. If it succeeded, the button will dissappear and a the breakpoint will appear in the editor. Otherwise, no marker is set and the button remains
2047
	// Take the opportunity to store them in the pending array too
2048
	GetBreakpointsMgr()->SetPendingBreakpoints( bps );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2049
1952 by eranif
- Applied patch which adds teh following events to the plugins system:
2050
	// notify plugins that we're about to start debugging
2051
	if (SendCmdEvent(wxEVT_DEBUG_STARTING, &startup_info))
2052
		// plugin stopped debugging
2053
		return;
2054
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2055
	// read
2056
	wxArrayString dbg_cmds;
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2057
	if ( pid == wxNOT_FOUND ) {
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2058
		//it is now OK to start the debugger...
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2059
		dbg_cmds = wxStringTokenize ( bldConf->GetDebuggerStartupCmds(), wxT ( "\n" ), wxTOKEN_STRTOK );
2060
		if ( !dbgr->Start ( dbgname, exepath, wd, bps, dbg_cmds ) ) {
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2061
			wxString errMsg;
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2062
			errMsg << _ ( "Failed to initialize debugger: " ) << dbgname << _ ( "\n" );
2063
			DebugMessage ( errMsg );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2064
			return;
2065
		}
1258 by eranif
- Implemented multiple custom targets for the 'Custom Build' option. This allows users to define N targets other than the built-in (Build, Clean) for example: make clean all, make distclean etc.
2066
	} else {
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2067
		//Attach to process...
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2068
		if ( !dbgr->Start ( dbgname, exepath, PID, bps, dbg_cmds ) ) {
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2069
			wxString errMsg;
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2070
			errMsg << _ ( "Failed to initialize debugger: " ) << dbgname << _ ( "\n" );
2071
			DebugMessage ( errMsg );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2072
			return;
2073
		}
2074
	}
2075
1952 by eranif
- Applied patch which adds teh following events to the plugins system:
2076
	// notify plugins that the debugger just started
2077
	SendCmdEvent(wxEVT_DEBUG_STARTED, &startup_info);
2078
1638 by eranif
- Applied debugger patch (David Hart)
2079
	// Now the debugger has been fed the breakpoints, re-Initialise the breakpt view,
2080
	// so that it uses debugger_ids instead of internal_ids
2271 by eranif
- Debugger: if gdb fails to set a breakpoint (due to various reasons) a new button will show up in the 'Breakpoints' tab, 'Set Pending' by clicking it, codelite will interrupt the debuggee and re-apply it. If it succeeded, the button will dissappear and a the breakpoint will appear in the editor. Otherwise, no marker is set and the button remains
2081
	// Hmm. The above comment is probably no longer true; but it'll do no harm to Initialise() anyway
1638 by eranif
- Applied debugger patch (David Hart)
2082
	Frame::Get()->GetDebuggerPane()->GetBreakpointView()->Initialize();
2083
2351 by eranif
- Debugger: New 'locals' view now also displays the function arguments
2084
	// Initialize the 'Locals' table. We do this for performane reason so we
2085
	// wont need to read from the XML each time perform 'next' step
2086
	Frame::Get()->GetDebuggerPane()->GetLocalsTable()->Initialize();
2087
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2088
	// let the active editor get the focus
1539 by sdolim
Further refactoring of MainBook. All references to MainBook's Notebook are now private, so it is ready to add the splitter window.
2089
	LEditor *editor = Frame::Get()->GetMainBook()->GetActiveEditor();
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2090
	if ( editor ) {
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2091
		editor->SetActive();
2092
	}
2093
2094
	// mark that we are waiting for the first GotControl()
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2095
	DebugMessage ( output );
2096
	DebugMessage ( _ ( "Debug session started successfully!\n" ) );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2097
1674 by eranif
- Fixed: regression: debugging did not setp-in correctly (the entered file was not focused)
2098
	// set the debug tab as active
2099
	ShowOutputPane(OutputPane::OUTPUT_DEBUG);
2100
2685 by eranif
- Fixed: BUG#2933450: Breakpoints set too early for winedbg remote debugging - When debugging a remote target, the breakpoints will be set after codelite successfully attaches to the debugger server
2101
	if ( dbgr->GetIsRemoteDebugging() ) {
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2102
2103
		// debugging remote target
2104
		wxString comm;
2105
		wxString port = bldConf->GetDbgHostPort();
2106
		wxString host = bldConf->GetDbgHostName();
2107
2108
		comm << host;
2109
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2110
		host = host.Trim().Trim ( false );
2111
		port = port.Trim().Trim ( false );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2112
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2113
		if ( port.IsEmpty() == false ) {
2114
			comm << wxT ( ":" ) << port;
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2115
		}
2116
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2117
		dbgr->Run ( args, comm );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2118
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2119
	} else if ( pid == wxNOT_FOUND ) {
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2120
2121
		// debugging local target
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2122
		dbgr->Run ( args, wxEmptyString );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2123
	}
2124
2125
	// and finally make the debugger pane visible
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2126
	wxAuiPaneInfo &info = Frame::Get()->GetDockingManager().GetPane ( wxT ( "Debugger" ) );
2127
	if ( info.IsOk() && !info.IsShown() ) {
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2128
		HideDebuggerPane = true;
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2129
		ShowDebuggerPane ( true );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2130
	}
1839 by eranif
- Implemented FR#2623376: Remember watch expression. CodeLite now restores watches from the previous debug session
2131
2132
	DbgRestoreWatches();
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2133
}
2134
2135
void Manager::DbgStop()
2136
{
3053 by eranif
- Reverted back to use debugger tip based on wxDialog (to remove the constraint of the tip being confined to the editor area)
2137
	if ( m_watchDlg ) {
2138
		m_watchDlg->Destroy();
2139
		m_watchDlg = NULL;
2324 by eranif
- added support for new quick watch dialog (not yet enabled)
2140
	}
2141
1692 by eranif
- Fixed regression where diff file failed to work in case external diff viewer was not set
2142
	// remove all debugger markers
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2143
	DbgUnMarkDebuggerLine();
1692 by eranif
- Fixed regression where diff file failed to work in case external diff viewer was not set
2144
2145
	// Mark the debugger as non interactive
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2146
	m_dbgCanInteract = false;
2147
1839 by eranif
- Implemented FR#2623376: Remember watch expression. CodeLite now restores watches from the previous debug session
2148
	// Keep the current watches for the next debug session
2149
	m_dbgWatchExpressions = Frame::Get()->GetDebuggerPane()->GetWatchesTable()->GetExpressions();
2150
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2151
	//clear the debugger pane
2152
	Frame::Get()->GetDebuggerPane()->Clear();
2153
2478 by eranif
- Debugger: fixed: adding breakpoints from sources other than the editor itself (e.g. enabling the 'break at main' option, or typing 'break foo' at the debugger tab) are now handled and displayed properly by codelite
2154
	// Notify the breakpoint manager that the debugger has stopped
2155
	GetBreakpointsMgr()->DebuggerStopped();
2156
1638 by eranif
- Applied debugger patch (David Hart)
2157
	Frame::Get()->GetDebuggerPane()->GetBreakpointView()->Initialize();
2158
2026 by eranif
- When debugging stopped, the Ascii Viewer is cleared
2159
	// Clear the ascii viewer
2109 by eranif
- Fixed regression: 'New Class' from context virtual folder context menu now working again
2160
	Frame::Get()->GetDebuggerPane()->GetAsciiViewer()->UpdateView(wxT(""), wxT(""));
2026 by eranif
- When debugging stopped, the Ascii Viewer is cleared
2161
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2162
	// update toolbar state
2163
	UpdateStopped();
2164
2165
	// and finally, hide the debugger pane (if we caused it to appear)
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2166
	if ( HideDebuggerPane ) {
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2167
		HideDebuggerPane = false;
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2168
		ShowDebuggerPane ( false );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2169
	}
2170
1692 by eranif
- Fixed regression where diff file failed to work in case external diff viewer was not set
2171
	IDebugger *dbgr =  DebuggerMgr::Get().GetActiveDebugger();
2172
	if ( !dbgr ) {
2173
		return;
2174
	}
2175
2176
	if ( !dbgr->IsRunning() ) {
2177
		return;
2178
	}
2179
1952 by eranif
- Applied patch which adds teh following events to the plugins system:
2180
	// notify plugins that the debugger is about to be stopped
2181
	SendCmdEvent(wxEVT_DEBUG_ENDING);
2182
1692 by eranif
- Fixed regression where diff file failed to work in case external diff viewer was not set
2183
	dbgr->Stop();
2184
	DebuggerMgr::Get().SetActiveDebugger ( wxEmptyString );
2185
	DebugMessage ( _ ( "Debug session ended\n" ) );
1952 by eranif
- Applied patch which adds teh following events to the plugins system:
2186
2187
	// notify plugins that the debugger stopped
2188
	SendCmdEvent(wxEVT_DEBUG_ENDED);
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2189
}
2190
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2191
void Manager::DbgMarkDebuggerLine ( const wxString &fileName, int lineno )
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2192
{
2193
	DbgUnMarkDebuggerLine();
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2194
	if ( lineno < 0 ) {
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2195
		return;
2196
	}
2197
2198
	//try to open the file
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2199
	wxFileName fn ( fileName );
1539 by sdolim
Further refactoring of MainBook. All references to MainBook's Notebook are now private, so it is ready to add the splitter window.
2200
	LEditor *editor = Frame::Get()->GetMainBook()->GetActiveEditor();
2116 by eranif
- Fixed: codelite will no longer crash when double clicking an entry in the 'call stack' tab which does not have line/file information
2201
	if ( editor && editor->GetFileName().GetFullPath().CmpNoCase(fn.GetFullPath()) == 0 && lineno > 0) {
2202
		editor->HighlightLine ( lineno   );
2203
		editor->GotoLine      ( lineno-1 );
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2204
		editor->EnsureVisible ( lineno-1 );
2116 by eranif
- Fixed: codelite will no longer crash when double clicking an entry in the 'call stack' tab which does not have line/file information
2205
	} else if (Frame::Get()->GetMainBook()->OpenFile ( fn.GetFullPath(), wxEmptyString, lineno-1, wxNOT_FOUND) && lineno > 0) {
1539 by sdolim
Further refactoring of MainBook. All references to MainBook's Notebook are now private, so it is ready to add the splitter window.
2206
		editor = Frame::Get()->GetMainBook()->GetActiveEditor();
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2207
		if ( editor ) {
2208
			editor->HighlightLine ( lineno );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2209
		}
2210
	}
2211
}
2212
2213
void Manager::DbgUnMarkDebuggerLine()
2214
{
2215
	//remove all debugger markers from all editors
1571 by eranif
- Remote debugging: Added the ability to send commands to the debugger after attaching to the remote target and before the 'continue' command. The commands can be set from project settings -> debugger
2216
	Frame::Get()->GetMainBook()->UnHighlightAll();
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2217
}
2218
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2219
void Manager::DbgDoSimpleCommand ( int cmd )
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2220
{
3048 by eranif
- Fixed: BUG#2977133: Debugger tool-tip gets in the way
2221
	// Hide tooltip dialog if its ON
3049 by eranif
- Debugger: changed the debugger tip from wxDialog into wxPanel
2222
	if(GetDebuggerTip() && GetDebuggerTip()->IsShown()) {
2223
		GetDebuggerTip()->HideDialog();
3048 by eranif
- Fixed: BUG#2977133: Debugger tool-tip gets in the way
2224
	}
2225
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2226
	IDebugger *dbgr = DebuggerMgr::Get().GetActiveDebugger();
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2227
	if ( dbgr && dbgr->IsRunning() ) {
2387 by eranif
"
2228
		switch ( cmd ) {
2229
		case DBG_PAUSE:
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2230
			dbgr->Interrupt();
2387 by eranif
"
2231
			break;
2232
		case DBG_NEXT:
2233
			dbgr->Next();
2234
			break;
2235
		case DBG_STEPIN:
2236
			dbgr->StepIn();
2237
			break;
2238
		case DBG_STEPOUT:
2239
			dbgr->StepOut();
2240
			break;
2241
		case DBG_SHOW_CURSOR:
2242
			dbgr->QueryFileLine();
2243
			break;
2244
		default:
2245
			break;
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2246
		}
2247
	}
2248
}
2249
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
2250
void Manager::DbgSetFrame ( int frame, int lineno )
2251
{
2252
	wxAuiPaneInfo &info = Frame::Get()->GetDockingManager().GetPane ( wxT ( "Debugger" ) );
2253
	if ( info.IsShown() ) {
2254
		IDebugger *dbgr = DebuggerMgr::Get().GetActiveDebugger();
2255
		if ( dbgr && dbgr->IsRunning() && DbgCanInteract() ) {
2256
			//set the frame
2257
			dbgr->SetFrame ( frame );
2258
			m_frameLineno = lineno;
2259
		}
2260
	}
2261
}
2262
2263
void Manager::DbgSetThread ( long threadId )
2264
{
2265
	IDebugger *dbgr = DebuggerMgr::Get().GetActiveDebugger();
2266
	if ( dbgr && dbgr->IsRunning() && DbgCanInteract() ) {
2267
		//set the frame
2268
		dbgr->SelectThread ( threadId );
2269
		dbgr->QueryFileLine();
2270
	}
2271
}
2272
2273
2274
// Event handlers from the debugger
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2275
2278 by eranif
- Added support for multi-selection in the 'File View' - user can now DragNDrop multiple items, delete multiple items and other functionalities (DavidGH)
2276
void Manager::UpdateAddLine ( const wxString &line, const bool OnlyIfLoggingOn /*=false*/ )
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2277
{
2278 by eranif
- Added support for multi-selection in the 'File View' - user can now DragNDrop multiple items, delete multiple items and other functionalities (DavidGH)
2278
	// There are a few messages that are only worth displaying if full logging is enabled
2279
	if (OnlyIfLoggingOn) {
2280
		IDebugger *dbgr = DebuggerMgr::Get().GetActiveDebugger();
2386 by eranif
- Changed the layout of the 'Debugger Settings' dialog
2281
		if ( dbgr && (dbgr->IsLoggingEnabled()==false) ) {
2278 by eranif
- Added support for multi-selection in the 'File View' - user can now DragNDrop multiple items, delete multiple items and other functionalities (DavidGH)
2282
			return;
2283
		}
2284
	}
2285
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2286
	DebugMessage ( line + wxT ( "\n" ) );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2287
}
2288
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2289
void Manager::UpdateFileLine ( const wxString &filename, int lineno )
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2290
{
2291
	wxString fileName = filename;
2292
	long lineNumber = lineno;
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2293
	if ( m_frameLineno != wxNOT_FOUND ) {
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2294
		lineNumber = m_frameLineno;
2295
		m_frameLineno = wxNOT_FOUND;
2296
	}
2297
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2298
	DbgMarkDebuggerLine ( fileName, lineNumber );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2299
	UpdateDebuggerPane();
2300
}
2301
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2302
void Manager::UpdateGotControl ( DebuggerReasons reason )
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2303
{
1195 by eranif
- spelling fixes
2304
	//put us on top of the z-order window
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2305
	Frame::Get()->Raise();
2306
	m_dbgCanInteract = true;
3017 by eranif
- When retagging, show a 'wait cursor' for better user hinting
2307
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2308
	switch ( reason ) {
2688 by eranif
- Debugger: when program is stopped while being debugged with signal SIGTRAP ( on Windows this means usually DebugBreak()) a proper notifcation dialog is presented to the user, and the active debug tab is set to the 'Call Stack' tab
2309
	case DBG_RECV_SIGNAL_SIGTRAP:         // DebugBreak()
2310
	case DBG_RECV_SIGNAL_EXC_BAD_ACCESS:  // SIGSEGV on Mac
2311
	case DBG_RECV_SIGNAL_SIGABRT:         // assert() ?
2312
	case DBG_RECV_SIGNAL_SIGSEGV: {       // program received signal sigsegv
3017 by eranif
- When retagging, show a 'wait cursor' for better user hinting
2313
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2314
		wxString signame = wxT ( "SIGSEGV" );
3017 by eranif
- When retagging, show a 'wait cursor' for better user hinting
2315
2725 by eranif
- Fixed: (Windows) codelite will no longer prompt the user with an error dialog when inserting a breakpoint while the debugger is running
2316
		// show the dialog only if the signal is not sigtrap
2317
		// since sigtap might be triggered by user inserting a breakpoint
2318
		// into an already running debug session
2834 by eranif
- codelite will now use wxAuiToolbar where possible to gain more clean look
2319
		bool     showDialog(true);
2725 by eranif
- Fixed: (Windows) codelite will no longer prompt the user with an error dialog when inserting a breakpoint while the debugger is running
2320
		if ( reason == DBG_RECV_SIGNAL_EXC_BAD_ACCESS ) {
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2321
			signame = wxT ( "EXC_BAD_ACCESS" );
2725 by eranif
- Fixed: (Windows) codelite will no longer prompt the user with an error dialog when inserting a breakpoint while the debugger is running
2322
			showDialog = true;
3017 by eranif
- When retagging, show a 'wait cursor' for better user hinting
2323
2725 by eranif
- Fixed: (Windows) codelite will no longer prompt the user with an error dialog when inserting a breakpoint while the debugger is running
2324
		} else if ( reason == DBG_RECV_SIGNAL_SIGABRT ) {
1997 by eranif
- codelite now handles assertions in a similar way of segmantation fault (user notification + call stack available)
2325
			signame = wxT ( "SIGABRT" );
2725 by eranif
- Fixed: (Windows) codelite will no longer prompt the user with an error dialog when inserting a breakpoint while the debugger is running
2326
			showDialog = true;
3017 by eranif
- When retagging, show a 'wait cursor' for better user hinting
2327
2725 by eranif
- Fixed: (Windows) codelite will no longer prompt the user with an error dialog when inserting a breakpoint while the debugger is running
2328
		} else if ( reason == DBG_RECV_SIGNAL_SIGTRAP ) {
2688 by eranif
- Debugger: when program is stopped while being debugged with signal SIGTRAP ( on Windows this means usually DebugBreak()) a proper notifcation dialog is presented to the user, and the active debug tab is set to the 'Call Stack' tab
2329
			signame = wxT ( "SIGTRAP" );
2834 by eranif
- codelite will now use wxAuiToolbar where possible to gain more clean look
2330
			showDialog = false;
2725 by eranif
- Fixed: (Windows) codelite will no longer prompt the user with an error dialog when inserting a breakpoint while the debugger is running
2331
		}
3017 by eranif
- When retagging, show a 'wait cursor' for better user hinting
2332
1932 by eranif
- Applied patch to make sure that the 'Segafult dialog' is always kept on top of the main frame
2333
		DebugMessage ( _("Program Received signal ") + signame + _("\n") );
2725 by eranif
- Fixed: (Windows) codelite will no longer prompt the user with an error dialog when inserting a breakpoint while the debugger is running
2334
		if(showDialog) {
2335
			wxMessageDialog dlg( Frame::Get(), _("Program Received signal ") + signame + wxT("\n") +
2336
								 _("Stack trace is available in the 'Call Stack' tab\n"),
2337
								 wxT("CodeLite"), wxICON_ERROR|wxOK );
2338
			dlg.ShowModal();
2339
		}
3017 by eranif
- When retagging, show a 'wait cursor' for better user hinting
2340
1997 by eranif
- codelite now handles assertions in a similar way of segmantation fault (user notification + call stack available)
2341
		//Print the stack trace
2342
		wxAuiPaneInfo &info = Frame::Get()->GetDockingManager().GetPane ( wxT("Debugger") );
2757 by eranif
- Code-Completion: Major changes to the parser. CodeLite now successfully parses (including iterators, nested typedefs) the STL libraries (tested: std::map, std::queue, std::list, std::vector, std::pair, std::shared_ptr, boost::shared_ptr and others ). In addition Qt's templates were tested (QMap, QHash etc) and confirmed to be working fine. Note that this is not a complete parser, and bugs may still occur
2343
		if ( info.IsShown() && showDialog ) {
1997 by eranif
- codelite now handles assertions in a similar way of segmantation fault (user notification + call stack available)
2344
			Frame::Get()->GetDebuggerPane()->SelectTab ( DebuggerPane::FRAMES );
2345
			UpdateDebuggerPane();
2346
		}
2347
	}
2348
	break;
2349
	case DBG_BP_ASSERTION_HIT: {
2350
2351
		wxMessageDialog dlg( Frame::Get(), _("Assertion failed!\nStack trace is available in the 'Call Stack' tab\n"),
2109 by eranif
- Fixed regression: 'New Class' from context virtual folder context menu now working again
2352
		                     wxT("CodeLite"), wxICON_ERROR|wxOK );
1932 by eranif
- Applied patch to make sure that the 'Segafult dialog' is always kept on top of the main frame
2353
		dlg.ShowModal();
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2354
2355
		//Print the stack trace
1932 by eranif
- Applied patch to make sure that the 'Segafult dialog' is always kept on top of the main frame
2356
		wxAuiPaneInfo &info = Frame::Get()->GetDockingManager().GetPane ( wxT("Debugger") );
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2357
		if ( info.IsShown() ) {
2358
			Frame::Get()->GetDebuggerPane()->SelectTab ( DebuggerPane::FRAMES );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2359
			UpdateDebuggerPane();
2360
		}
2361
	}
2362
	break;
1409 by eranif
- New: added 'Run to cursor' functionality to the gdb debugger (from within the editor's context menu)
2363
	case DBG_END_STEPPING:	// finished one of the following: next/step/nexti/stepi
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2364
	case DBG_FUNC_FINISHED:
1409 by eranif
- New: added 'Run to cursor' functionality to the gdb debugger (from within the editor's context menu)
2365
	case DBG_UNKNOWN:		// the most common reason: temporary breakpoint
2366
	case DBG_BP_HIT: { 		// breakpoint reached
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2367
		//query the current line and file
2368
		IDebugger *dbgr = DebuggerMgr::Get().GetActiveDebugger();
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2369
		if ( dbgr && dbgr->IsRunning() ) {
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2370
			dbgr->QueryFileLine();
2465 by eranif
- added 'what' column to the debugger breakpoint tab
2371
			dbgr->BreakList();
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2372
		}
2373
	}
2374
	break;
1699 by eranif
- Major change: switched debugger to use MI commands for breakpoints (-break*)
2375
	case DBG_DBGR_KILLED:
2376
		m_dbgCanInteract = false;
2377
		break;
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2378
	case DBG_EXITED_NORMALLY:
2379
		//debugging finished, stop the debugger process
2380
		DbgStop();
2381
		break;
2382
	default:
2383
		break;
2384
	}
2385
}
2386
2387
void Manager::UpdateLostControl()
2388
{
2389
	//debugger lost control
2390
	//hide the marker
2391
	DbgUnMarkDebuggerLine();
2392
	m_dbgCanInteract = false;
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2393
	DebugMessage ( _ ( "Continuing...\n" ) );
1927 by eranif
- Fixed: assertions on debugger call stack's icon
2394
2395
	// Reset the debugger call-stack pane
2109 by eranif
- Fixed regression: 'New Class' from context virtual folder context menu now working again
2396
	Frame::Get()->GetDebuggerPane()->GetFrameListView()->Clear();
2397
	Frame::Get()->GetDebuggerPane()->GetFrameListView()->SetCurrentLevel(0);
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2398
}
2399
2109 by eranif
- Fixed regression: 'New Class' from context virtual folder context menu now working again
2400
void Manager::UpdateTypeReolsved(const wxString& expr, const wxString& type_name)
2401
{
2402
	IDebugger *dbgr = DebuggerMgr::Get().GetActiveDebugger();
2403
	// Sanity
2346 by eranif
- Debugger: d-clicking an 'expandable' entry in the 'watches' table will now places the display variable dialog in the centre of the screen
2404
	if ( dbgr == NULL               ) {
2405
		return;
2406
	}
2407
	if ( dbgr->IsRunning() == false ) {
2408
		return;
2409
	}
2410
	if ( DbgCanInteract() == false  ) {
2411
		return;
2412
	}
2109 by eranif
- Fixed regression: 'New Class' from context virtual folder context menu now working again
2413
2414
	// gdb returns usually expression like:
2415
	// const string &, so in order to get the actual type
2416
	// we construct a valid expression by appending a valid identifier followed by a semi colon.
2417
	wxString expression;
2418
	wxString command(expr);
2419
	wxString dbg_command(wxT("print"));
2420
	wxString expression_type;
2421
2422
	//wxLogMessage(word + wxT(" resolved into: ") + type);
2423
	DebuggerSettingsData data;
2424
	DebuggerConfigTool::Get()->ReadObject(wxT("DebuggerCommands"), &data);
2425
	std::vector<DebuggerCmdData> cmds = data.GetCmds();
2426
2427
	expression << wxT("/^");
2428
	expression << type_name;
2429
	expression << wxT(" someValidName;");
2430
	expression << wxT("$/");
2431
2432
	Variable variable;
2433
	if (LanguageST::Get()->VariableFromPattern(expression, wxT("someValidName"), variable)) {
2434
		expression_type = _U(variable.m_type.c_str());
2435
		for (size_t i=0; i<cmds.size(); i++) {
2436
			DebuggerCmdData cmd = cmds.at(i);
2437
			if (cmd.GetName() == expression_type) {
2438
				// prepare the string to be evaluated
2439
				command = cmd.GetCommand();
2440
				command.Replace(wxT("$(Variable)"), expr);
2441
2442
				dbg_command = cmd.GetDbgCommand();
2443
2444
				//---------------------------------------------------
2445
				// Special handling for the templates
2446
				//---------------------------------------------------
2447
2448
				wxArrayString types = DoGetTemplateTypes(_U(variable.m_templateDecl.c_str()));
2449
				// Case 1: list
2450
				// The user defined scripts requires that we pass info like this:
2451
				// plist <list name> <T>
2452
				if ( expression_type == wxT("list") && types.GetCount() > 0 ) {
2453
					command << wxT(" ") << types.Item(0);
2454
				}
2455
				// Case 2: map & multimap
2456
				// The user defined script requires that we pass the TLeft & TRight
2457
				// pmap <list name> TLeft TRight
2458
				if ( (expression_type == wxT("map") || expression_type == wxT("multimap")) && types.GetCount() > 1 ) {
2459
					command << wxT(" ") << types.Item(0) << wxT(" ") << types.Item(1);
2460
				}
2461
2462
				break;
2463
			}
2464
		}
2465
	}
2466
2467
2468
	wxString output;
2469
	bool     get_tip (false);
2470
2471
	Notebook * book = Frame::Get()->GetDebuggerPane()->GetNotebook();
2472
	if ( book->GetPageText(book->GetSelection()) == DebuggerPane::ASCII_VIEWER || IsPaneVisible(DebuggerPane::ASCII_VIEWER) ) {
2473
		get_tip = true;
2474
	}
2475
2476
	if ( get_tip ) {
2351 by eranif
- Debugger: New 'locals' view now also displays the function arguments
2477
		dbgr->GetAsciiViewerContent(dbg_command, command); // Will trigger a call to UpdateTip()
2109 by eranif
- Fixed regression: 'New Class' from context virtual folder context menu now working again
2478
	}
2479
}
2480
2351 by eranif
- Debugger: New 'locals' view now also displays the function arguments
2481
void Manager::UpdateAsciiViewer(const wxString& expression, const wxString& tip)
2109 by eranif
- Fixed regression: 'New Class' from context virtual folder context menu now working again
2482
{
2163 by eranif
- Fixed: patch for commandlist serialisation (debugger) by DavidGH
2483
	Frame::Get()->GetDebuggerPane()->GetAsciiViewer()->UpdateView( expression, tip );
2109 by eranif
- Fixed regression: 'New Class' from context virtual folder context menu now working again
2484
}
2485
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
2486
void Manager::UpdateRemoteTargetConnected(const wxString& line)
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2487
{
2488
	IDebugger *dbgr = DebuggerMgr::Get().GetActiveDebugger();
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
2489
	if (dbgr && dbgr->IsRunning() && IsWorkspaceOpen()) {
2490
		// we currently do not support this feature when debugging using 'Quick debug'
2491
		wxString errMsg;
2492
		ProjectPtr proj = WorkspaceST::Get()->FindProjectByName ( GetActiveProjectName(), errMsg );
2493
		BuildConfigPtr bldConf = WorkspaceST::Get()->GetProjBuildConf ( proj->GetName(), wxEmptyString );
2494
		if ( bldConf ) {
2495
			wxArrayString dbg_cmds = wxStringTokenize ( bldConf->GetDebuggerPostRemoteConnectCmds(), wxT ( "\n" ), wxTOKEN_STRTOK );
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
2496
			for (size_t i=0; i<dbg_cmds.GetCount(); i++) {
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
2497
				dbgr->ExecuteCmd(dbg_cmds.Item(i));
2498
			}
2499
		}
2500
	}
2501
	// log the line
2502
	UpdateAddLine(line);
2503
}
2504
2505
2506
//--------------------------- Build Management -----------------------------
2507
2508
bool Manager::IsBuildInProgress() const
2509
{
2510
	return m_shellProcess && m_shellProcess->IsBusy();
2511
}
2512
2513
void Manager::StopBuild()
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2514
{
1334 by eranif
- some code refactoring
2515
	if ( m_shellProcess && m_shellProcess->IsBusy() ) {
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
2516
		m_shellProcess->Stop();
2517
	}
2518
	m_buildQueue.clear();
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2519
}
2520
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2521
void Manager::PushQueueCommand ( const QueueCommand& buildInfo )
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2522
{
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2523
	m_buildQueue.push_back ( buildInfo );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2524
}
2525
2526
void Manager::ProcessCommandQueue()
2527
{
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2528
	if ( m_buildQueue.empty() ) {
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2529
		return;
2530
	}
2531
2532
	// pop the next build build and process it
2533
	QueueCommand qcmd = m_buildQueue.front();
2534
	m_buildQueue.pop_front();
1139 by eranif
- Implemented [ codelite-Feature Requests-2092921 ] A new workspace should have a release configuration as well
2535
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2536
	if ( qcmd.GetCheckBuildSuccess() && !IsBuildEndedSuccessfully() ) {
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2537
		// build failed, remove command from the queue
2538
		return;
2539
	}
1139 by eranif
- Implemented [ codelite-Feature Requests-2092921 ] A new workspace should have a release configuration as well
2540
1258 by eranif
- Implemented multiple custom targets for the 'Custom Build' option. This allows users to define N targets other than the built-in (Build, Clean) for example: make clean all, make distclean etc.
2541
	switch ( qcmd.GetKind() ) {
2542
	case QueueCommand::CustomBuild:
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2543
		DoCustomBuild ( qcmd );
1258 by eranif
- Implemented multiple custom targets for the 'Custom Build' option. This allows users to define N targets other than the built-in (Build, Clean) for example: make clean all, make distclean etc.
2544
		break;
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2545
	case QueueCommand::Clean:
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2546
		DoCleanProject ( qcmd );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2547
		break;
2430 by eranif
- Added new 'Rebuild' option to 'Project Only -> Rebuild' this applies for custom build as well as for managed build
2548
	case QueueCommand::ReBuild:
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2549
	case QueueCommand::Build:
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2550
		DoBuildProject ( qcmd );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2551
		break;
2552
	case QueueCommand::Debug:
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2553
		DbgStart ( wxNOT_FOUND );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2554
		break;
2555
	}
2556
}
2557
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
2558
void Manager::BuildWorkspace()
2559
{
2560
	DoCmdWorkspace ( QueueCommand::Build );
2561
	ProcessCommandQueue();
2562
}
2563
2564
void Manager::CleanWorkspace()
2565
{
2566
	DoCmdWorkspace ( QueueCommand::Clean );
2567
	ProcessCommandQueue();
2568
}
2569
2570
void Manager::RebuildWorkspace()
2571
{
2572
	DoCmdWorkspace ( QueueCommand::Clean );
2573
	DoCmdWorkspace ( QueueCommand::Build );
2574
	ProcessCommandQueue();
2575
}
2576
2577
void Manager::RunCustomPreMakeCommand ( const wxString &project )
2578
{
2579
	if ( m_shellProcess && m_shellProcess->IsBusy() ) {
2580
		return;
2581
	}
2582
2583
	wxString conf;
2584
	// get the selected configuration to be built
2585
	BuildConfigPtr bldConf = WorkspaceST::Get()->GetProjBuildConf ( project, wxEmptyString );
2586
	if ( bldConf ) {
2587
		conf = bldConf->GetName();
2588
	}
2589
	QueueCommand info ( project, conf, false, QueueCommand::Build );
1735 by eranif
- Fixed: build compilation on Windows
2590
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
2591
	if ( m_shellProcess ) {
2592
		delete m_shellProcess;
2593
	}
2307 by eranif
- Changed the interface to the debugger so the 'IDebuggerObserver' will only exposes single debuggerUpdate() method which accepts DebuggerEvent
2594
	m_shellProcess = new CompileRequest ( Frame::Get(),  //owner window
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
2595
	                                      info,
2307 by eranif
- Changed the interface to the debugger so the 'IDebuggerObserver' will only exposes single debuggerUpdate() method which accepts DebuggerEvent
2596
	                                      wxEmptyString, //no file name (valid only for build file only)
2597
	                                      true );        //run premake step only
2479 by eranif
- Build System: Custom Build can now use the 'CurrentFilePath' in the working directory field
2598
	m_shellProcess->Process(PluginManager::Get());
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
2599
}
2600
2601
void Manager::CompileFile ( const wxString &projectName, const wxString &fileName, bool preprocessOnly )
2602
{
2603
	if ( m_shellProcess && m_shellProcess->IsBusy() ) {
2604
		return;
2605
	}
2606
2612 by eranif
- Continous build will ignore any save events that triggered due to build process startup
2607
	DoSaveAllFilesBeforeBuild();
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
2608
2609
	//If a debug session is running, stop it.
2610
	IDebugger *dbgr = DebuggerMgr::Get().GetActiveDebugger();
2611
	if ( dbgr && dbgr->IsRunning() ) {
1735 by eranif
- Fixed: build compilation on Windows
2612
		if ( wxMessageBox ( _ ( "This would terminate the current debug session, continue?" ),
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
2613
		                    wxT ( "Confirm" ), wxICON_QUESTION|wxYES_NO|wxCANCEL ) != wxYES )
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
2614
			return;
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
2615
		DbgStop();
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
2616
	}
2617
2618
	wxString conf;
2619
	BuildConfigPtr bldConf = WorkspaceST::Get()->GetProjBuildConf ( projectName, wxEmptyString );
2620
	if ( bldConf ) {
2621
		conf = bldConf->GetName();
2622
	}
2623
2624
	QueueCommand info ( projectName, conf, false, QueueCommand::Build );
2625
	if ( bldConf && bldConf->IsCustomBuild() ) {
2626
		info.SetCustomBuildTarget ( preprocessOnly ? wxT("Preprocess File") : wxT ( "Compile Single File" ) );
2627
		info.SetKind ( QueueCommand::CustomBuild );
2628
	}
2629
2630
	if ( m_shellProcess ) {
2631
		delete m_shellProcess;
2632
	}
2633
	switch ( info.GetKind() ) {
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
2634
	case QueueCommand::Build:
2635
		m_shellProcess = new CompileRequest ( Frame::Get(), info, fileName, false, preprocessOnly );
2636
		break;
2637
	case  QueueCommand::CustomBuild:
2638
		m_shellProcess = new CustomBuildRequest ( Frame::Get(), info, fileName );
2639
		break;
2640
	default:
2641
		m_shellProcess = NULL;
2642
		break;
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
2643
	}
2479 by eranif
- Build System: Custom Build can now use the 'CurrentFilePath' in the working directory field
2644
	m_shellProcess->Process(PluginManager::Get());
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
2645
}
1735 by eranif
- Fixed: build compilation on Windows
2646
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
2647
bool Manager::IsBuildEndedSuccessfully() const
2648
{
2490 by eranif
- Fixed BUG#2909844: Failed build doesn't prevent launch
2649
	// return the result of the last build
2650
	return Frame::Get()->GetOutputPane()->GetBuildTab()->GetBuildEndedSuccessfully();
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
2651
}
2652
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2653
void Manager::DoBuildProject ( const QueueCommand& buildInfo )
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2654
{
1735 by eranif
- Fixed: build compilation on Windows
2655
	if ( m_shellProcess && m_shellProcess->IsBusy() )
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2656
		return;
2657
2612 by eranif
- Continous build will ignore any save events that triggered due to build process startup
2658
	DoSaveAllFilesBeforeBuild();
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2659
2660
	//If a debug session is running, stop it.
2661
	IDebugger *dbgr = DebuggerMgr::Get().GetActiveDebugger();
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2662
	if ( dbgr && dbgr->IsRunning() ) {
1735 by eranif
- Fixed: build compilation on Windows
2663
		if ( wxMessageBox ( _ ( "This would terminate the current debug session, continue?" ),
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
2664
		                    wxT ( "Confirm" ), wxICON_QUESTION|wxYES_NO|wxCANCEL ) != wxYES )
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2665
			return;
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
2666
		DbgStop();
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
2667
	}
1735 by eranif
- Fixed: build compilation on Windows
2668
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
2669
	if ( m_shellProcess ) {
2670
		delete m_shellProcess;
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2671
	}
2222 by eranif
2672
1729 by sdolim
- Eliminated unneeded function Manager::GetMainFrame().
2673
	m_shellProcess = new CompileRequest ( Frame::Get(), buildInfo );
2479 by eranif
- Build System: Custom Build can now use the 'CurrentFilePath' in the working directory field
2674
	m_shellProcess->Process(PluginManager::Get());
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2675
}
2676
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2677
void Manager::DoCleanProject ( const QueueCommand& buildInfo )
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2678
{
1334 by eranif
- some code refactoring
2679
	if ( m_shellProcess && m_shellProcess->IsBusy() ) {
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2680
		return;
2681
	}
2682
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
2683
	if ( m_shellProcess ) {
2684
		delete m_shellProcess;
2685
	}
1729 by sdolim
- Eliminated unneeded function Manager::GetMainFrame().
2686
	m_shellProcess = new CleanRequest ( Frame::Get(), buildInfo );
2479 by eranif
- Build System: Custom Build can now use the 'CurrentFilePath' in the working directory field
2687
	m_shellProcess->Process(PluginManager::Get());
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2688
}
2689
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
2690
void Manager::DoCustomBuild ( const QueueCommand& buildInfo )
2691
{
2692
	if ( m_shellProcess && m_shellProcess->IsBusy() ) {
2693
		return;
2694
	}
2695
2612 by eranif
- Continous build will ignore any save events that triggered due to build process startup
2696
	DoSaveAllFilesBeforeBuild();
2697
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
2698
2699
	//If a debug session is running, stop it.
2700
	IDebugger *dbgr = DebuggerMgr::Get().GetActiveDebugger();
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
2701
	if ( dbgr && dbgr->IsRunning() ) {
1735 by eranif
- Fixed: build compilation on Windows
2702
		if ( wxMessageBox ( _ ( "This would terminate the current debug session, continue?" ),
1788 by eranif
- Reverted back code which handled menu accelerators in manager.cpp due to:
2703
		                    wxT ( "Confirm" ), wxICON_QUESTION|wxYES_NO|wxCANCEL ) != wxYES )
2704
			return;
2705
		DbgStop();
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
2706
	}
1735 by eranif
- Fixed: build compilation on Windows
2707
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
2708
	if ( m_shellProcess ) {
2709
		delete m_shellProcess;
2710
	}
2711
	m_shellProcess = new CustomBuildRequest ( Frame::Get(), buildInfo, wxEmptyString );
2479 by eranif
- Build System: Custom Build can now use the 'CurrentFilePath' in the working directory field
2712
	m_shellProcess->Process( PluginManager::Get() );
1734 by sdolim
- Cleaned up Manager class by grouping related methods and relocating single-use methods into caller classes
2713
}
1735 by eranif
- Fixed: build compilation on Windows
2714
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2715
void Manager::DoCmdWorkspace ( int cmd )
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2716
{
2717
	// get list of projects
2718
	wxArrayString projects;
2719
	wxArrayString optimizedList;
1139 by eranif
- Implemented [ codelite-Feature Requests-2092921 ] A new workspace should have a release configuration as well
2720
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2721
	ManagerST::Get()->GetProjectList ( projects );
1139 by eranif
- Implemented [ codelite-Feature Requests-2092921 ] A new workspace should have a release configuration as well
2722
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2723
	for ( size_t i=0; i<projects.GetCount(); i++ ) {
2724
		ProjectPtr p = GetProject ( projects.Item ( i ) );
2725
		BuildConfigPtr buildConf = WorkspaceST::Get()->GetProjBuildConf ( projects.Item ( i ), wxEmptyString );
2726
		if ( p && buildConf ) {
2727
			wxArrayString deps = p->GetDependencies ( buildConf->GetName() );
2728
			for ( size_t j=0; j<deps.GetCount(); j++ ) {
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2729
				// add a project only if it does not exist yet
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2730
				if ( optimizedList.Index ( deps.Item ( j ) ) == wxNOT_FOUND ) {
2731
					optimizedList.Add ( deps.Item ( j ) );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2732
				}
2733
			}
2734
			// add the project itself now, again only if it is not included yet
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2735
			if ( optimizedList.Index ( projects.Item ( i ) ) == wxNOT_FOUND ) {
2736
				optimizedList.Add ( projects.Item ( i ) );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2737
			}
2738
		}
2739
	}
1139 by eranif
- Implemented [ codelite-Feature Requests-2092921 ] A new workspace should have a release configuration as well
2740
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2741
	// add a build/clean project only command for every project in the optimized list
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2742
	for ( size_t i=0; i<optimizedList.GetCount(); i++ ) {
2743
		BuildConfigPtr buildConf = WorkspaceST::Get()->GetProjBuildConf ( optimizedList.Item ( i ), wxEmptyString );
2744
		if ( buildConf ) {
2745
			QueueCommand bi ( optimizedList.Item ( i ), buildConf->GetName(), true, cmd );
2746
			if ( buildConf->IsCustomBuild() ) {
2747
				bi.SetKind ( QueueCommand::CustomBuild );
2748
				switch ( cmd ) {
1335 by eranif
- continued code refactoring in the build system
2749
				case QueueCommand::Build:
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2750
					bi.SetCustomBuildTarget ( wxT ( "Build" ) );
1335 by eranif
- continued code refactoring in the build system
2751
					break;
2752
				case QueueCommand::Clean:
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2753
					bi.SetCustomBuildTarget ( wxT ( "Clean" ) );
1335 by eranif
- continued code refactoring in the build system
2754
					break;
2755
				}
2756
			}
1449 by eranif
- added 'In Shudown' flag to manager to avoid firing events to some plugins incase of codelite shutting down
2757
			bi.SetCleanLog ( i == 0 );
2758
			PushQueueCommand ( bi );
1127 by eranif
- Fixed a crtical regression bug in the build system (introduced in revision 2061)
2759
		}
2760
	}
2761
}
1839 by eranif
- Implemented FR#2623376: Remember watch expression. CodeLite now restores watches from the previous debug session
2762
1879 by eranif
- Applied patch by Mattia barbon so that codelite will send 2 events when file is renamed: 1 event for the removal of the file and one for adding new fie
2763
void Manager::DbgClearWatches()
1839 by eranif
- Implemented FR#2623376: Remember watch expression. CodeLite now restores watches from the previous debug session
2764
{
1879 by eranif
- Applied patch by Mattia barbon so that codelite will send 2 events when file is renamed: 1 event for the removal of the file and one for adding new fie
2765
	m_dbgWatchExpressions.Clear();
2766
}
2767
2346 by eranif
- Debugger: d-clicking an 'expandable' entry in the 'watches' table will now places the display variable dialog in the centre of the screen
2768
void Manager::DebuggerUpdate(const DebuggerEvent& event)
2307 by eranif
- Changed the interface to the debugger so the 'IDebuggerObserver' will only exposes single debuggerUpdate() method which accepts DebuggerEvent
2769
{
2346 by eranif
- Debugger: d-clicking an 'expandable' entry in the 'watches' table will now places the display variable dialog in the centre of the screen
2770
	IDebugger *dbgr = DebuggerMgr::Get().GetActiveDebugger();
2771
	DebuggerInformation dbgInfo = dbgr ? dbgr->GetDebuggerInformation() : DebuggerInformation();
2307 by eranif
- Changed the interface to the debugger so the 'IDebuggerObserver' will only exposes single debuggerUpdate() method which accepts DebuggerEvent
2772
	switch ( event.m_updateReason ) {
2773
2774
	case DBG_UR_GOT_CONTROL:
2775
		UpdateGotControl(event.m_controlReason);
2776
		break;
2777
2778
	case DBG_UR_LOST_CONTROL:
2779
		UpdateLostControl();
2780
		break;
2781
2782
	case DBG_UR_FILE_LINE:
2783
		UpdateFileLine(event.m_file, event.m_line);
2784
		break;
2785
2786
	case DBG_UR_ADD_LINE:
2787
		UpdateAddLine(event.m_text, event.m_onlyIfLogging);
2788
		break;
2789
2790
	case DBG_UR_BP_ADDED:
2791
		GetBreakpointsMgr()->SetBreakpointDebuggerID(event.m_bpInternalId, event.m_bpDebuggerId);
2792
		break;
2793
2794
	case DBG_UR_STOPPED:
2795
		// Nothing to do here
2796
		break;
2797
2798
	case DBG_UR_LOCALS:
2350 by eranif
- Debugger: 'Locals' now uses table instead of tree. This new method is much more stable and accurtate than the previous one used. d-clicking on an item, will automatically show the 'display variable' dialog with the item de-referenced
2799
		Frame::Get()->GetDebuggerPane()->GetLocalsTable()->UpdateLocals( event.m_locals );
2354 by eranif
- Debugger: grammar changed to match Mac syntax for locals output
2800
#ifdef __WXMAC__
2801
		{
2802
			for(size_t i=0; i<event.m_locals.size(); i++){
2803
				LocalVariable v = event.m_locals.at(i);
2804
				if(v.gdbId.IsEmpty() == false) {
2805
					dbgr->DeleteVariableObject(v.gdbId);
2806
				}
2807
			}
2808
		}
2809
#endif
2307 by eranif
- Changed the interface to the debugger so the 'IDebuggerObserver' will only exposes single debuggerUpdate() method which accepts DebuggerEvent
2810
		break;
2811
2351 by eranif
- Debugger: New 'locals' view now also displays the function arguments
2812
	case DBG_UR_FUNC_ARGS:
2813
		Frame::Get()->GetDebuggerPane()->GetLocalsTable()->UpdateFuncArgs( event.m_locals );
2354 by eranif
- Debugger: grammar changed to match Mac syntax for locals output
2814
#ifdef __WXMAC__
2815
		{
2816
			for(size_t i=0; i<event.m_locals.size(); i++){
2817
				LocalVariable v = event.m_locals.at(i);
2818
				if(v.gdbId.IsEmpty() == false) {
2819
					dbgr->DeleteVariableObject(v.gdbId);
2820
				}
2821
			}
2822
		}
2823
#endif
2351 by eranif
- Debugger: New 'locals' view now also displays the function arguments
2824
		break;
2825
2307 by eranif
- Changed the interface to the debugger so the 'IDebuggerObserver' will only exposes single debuggerUpdate() method which accepts DebuggerEvent
2826
	case DBG_UR_EXPRESSION:
2827
		Frame::Get()->GetDebuggerPane()->GetWatchesTable()->UpdateExpression ( event.m_expression, event.m_evaluated );
2828
		break;
2829
	case DBG_UR_UPDATE_STACK_LIST:
2830
		Frame::Get()->GetDebuggerPane()->GetFrameListView()->Update ( event.m_stack );
2831
		break;
2832
2833
	case DBG_UR_REMOTE_TARGET_CONNECTED:
2834
		UpdateRemoteTargetConnected( event.m_text );
2835
		break;
2836
2837
	case DBG_UR_RECONCILE_BPTS:
2838
		GetBreakpointsMgr()->ReconcileBreakpoints( event.m_bpInfoList );
2839
		break;
2840
2841
	case DBG_UR_BP_HIT:
2842
		GetBreakpointsMgr()->BreakpointHit( event.m_bpDebuggerId );
2843
		break;
2844
2845
	case DBG_UR_TYPE_RESOLVED:
2846
		UpdateTypeReolsved( event.m_expression, event.m_evaluated );
2847
		break;
2848
2351 by eranif
- Debugger: New 'locals' view now also displays the function arguments
2849
	case DBG_UR_ASCII_VIEWER:
2850
		UpdateAsciiViewer( event.m_expression, event.m_text );
2307 by eranif
- Changed the interface to the debugger so the 'IDebuggerObserver' will only exposes single debuggerUpdate() method which accepts DebuggerEvent
2851
		break;
2852
2309 by eranif
- GDB plugin no longer uses 'synchronous' commands, only ASYNC commands
2853
	case DBG_UR_LISTTHRAEDS:
2854
		Frame::Get()->GetDebuggerPane()->GetThreadsView()->PopulateList( event.m_threads );
2855
		break;
2856
2857
	case DBG_UR_WATCHMEMORY:
2858
		Frame::Get()->GetDebuggerPane()->GetMemoryView()->SetViewString( event.m_evaluated );
2859
		break;
2346 by eranif
- Debugger: d-clicking an 'expandable' entry in the 'watches' table will now places the display variable dialog in the centre of the screen
2860
	case DBG_UR_VARIABLEOBJ: {
2861
		if ( event.m_userReason == DBG_USERR_QUICKWACTH ) {
2862
2863
			if ( dbgInfo.showTooltips ) {
2864
2865
				/////////////////////////////////////////////
2866
				// Handle Tooltips
2867
				/////////////////////////////////////////////
2868
2869
				DoShowQuickWatchDialog( event );
2870
2871
			}
2872
2873
			// Handle ASCII Viewer
2874
			wxString expression ( event.m_expression );
2875
			if ( event.m_variableObject.isPtr && !event.m_expression.StartsWith(wxT("*")) ) {
2876
				if ( event.m_variableObject.typeName.Contains(wxT("char *"))    ||
2877
				        event.m_variableObject.typeName.Contains(wxT("wchar_t *")) ||
2878
				        event.m_variableObject.typeName.Contains(wxT("QChar *"))   ||
2879
				        event.m_variableObject.typeName.Contains(wxT("wxChar *"))) {
2880
					// dont de-reference
2881
				} else {
2882
					expression.Prepend(wxT("(*"));
2883
					expression.Append(wxT(")"));
2884
2330 by eranif
- Ascii Viewer is now working again
2885
				}
2324 by eranif
- added support for new quick watch dialog (not yet enabled)
2886
			}
2348 by eranif
- Fixed: regression in ascii-viewer
2887
			UpdateTypeReolsved( expression, event.m_variableObject.typeName );
2346 by eranif
- Debugger: d-clicking an 'expandable' entry in the 'watches' table will now places the display variable dialog in the centre of the screen
2888
		} else if ( event.m_userReason == DBG_USERR_WATCHTABLE ) {
2889
			// Double clicked on the 'Watches' table
2890
			DoShowQuickWatchDialog( event );
2350 by eranif
- Debugger: 'Locals' now uses table instead of tree. This new method is much more stable and accurtate than the previous one used. d-clicking on an item, will automatically show the 'display variable' dialog with the item de-referenced
2891
2892
		} else if ( event.m_userReason == DBG_USERR_LOCALS ) {
2893
			DoShowQuickWatchDialog( event );
2385 by eranif
- Debugger: Locals view will now auto-expand variables which are defined under the 'PreDefined' types
2894
2895
		} else if ( event.m_userReason == DBG_USERR_LOCALS_INLINE ) {
2896
			Frame::Get()->GetDebuggerPane()->GetLocalsTable()->UpdateInline( event );
2897
2324 by eranif
- added support for new quick watch dialog (not yet enabled)
2898
		}
2346 by eranif
- Debugger: d-clicking an 'expandable' entry in the 'watches' table will now places the display variable dialog in the centre of the screen
2899
	}
2900
	break;
2324 by eranif
- added support for new quick watch dialog (not yet enabled)
2901
	case DBG_UR_LISTCHILDREN: {
2346 by eranif
- Debugger: d-clicking an 'expandable' entry in the 'watches' table will now places the display variable dialog in the centre of the screen
2902
		IDebugger *dbgr = DebuggerMgr::Get().GetActiveDebugger();
2903
		if ( dbgr && dbgr->IsRunning() && DbgCanInteract() ) {
3049 by eranif
- Debugger: changed the debugger tip from wxDialog into wxPanel
2904
			if ( GetDebuggerTip() && !GetDebuggerTip()->IsShown() ) {
2905
				GetDebuggerTip()->BuildTree( event.m_varObjChildren, dbgr );
2906
				GetDebuggerTip()->m_mainVariableObject = event.m_expression;
2907
				GetDebuggerTip()->ShowDialog( (event.m_userReason == DBG_USERR_WATCHTABLE || event.m_userReason == DBG_USERR_LOCALS) );
2309 by eranif
- GDB plugin no longer uses 'synchronous' commands, only ASYNC commands
2908
3049 by eranif
- Debugger: changed the debugger tip from wxDialog into wxPanel
2909
			} else if(GetDebuggerTip()) {
2346 by eranif
- Debugger: d-clicking an 'expandable' entry in the 'watches' table will now places the display variable dialog in the centre of the screen
2910
				// The dialog is shown
3049 by eranif
- Debugger: changed the debugger tip from wxDialog into wxPanel
2911
				GetDebuggerTip()->AddItems(event.m_expression, event.m_varObjChildren);
2324 by eranif
- added support for new quick watch dialog (not yet enabled)
2912
			}
2913
		}
2346 by eranif
- Debugger: d-clicking an 'expandable' entry in the 'watches' table will now places the display variable dialog in the centre of the screen
2914
	}
2915
	break;
2324 by eranif
- added support for new quick watch dialog (not yet enabled)
2916
	case DBG_UR_EVALVARIABLEOBJ:
3049 by eranif
- Debugger: changed the debugger tip from wxDialog into wxPanel
2917
		if (GetDebuggerTip() && GetDebuggerTip()->IsShown()) {
2918
			GetDebuggerTip()->UpdateValue(event.m_expression, event.m_evaluated, event.m_displayFormat);
2324 by eranif
- added support for new quick watch dialog (not yet enabled)
2919
		}
2920
		break;
2307 by eranif
- Changed the interface to the debugger so the 'IDebuggerObserver' will only exposes single debuggerUpdate() method which accepts DebuggerEvent
2921
	case DBG_UR_INVALID:
2922
	default:
2923
		break;
2924
	}
2346 by eranif
- Debugger: d-clicking an 'expandable' entry in the 'watches' table will now places the display variable dialog in the centre of the screen
2925
}
2307 by eranif
- Changed the interface to the debugger so the 'IDebuggerObserver' will only exposes single debuggerUpdate() method which accepts DebuggerEvent
2926
1879 by eranif
- Applied patch by Mattia barbon so that codelite will send 2 events when file is renamed: 1 event for the removal of the file and one for adding new fie
2927
void Manager::DbgRestoreWatches()
1839 by eranif
- Implemented FR#2623376: Remember watch expression. CodeLite now restores watches from the previous debug session
2928
{
2929
	// restore any saved watch expressions from previous debug sessions
2109 by eranif
- Fixed regression: 'New Class' from context virtual folder context menu now working again
2930
	if ( m_dbgWatchExpressions.empty() == false ) {
2931
		for (size_t i=0; i<m_dbgWatchExpressions.GetCount(); i++) {
1839 by eranif
- Implemented FR#2623376: Remember watch expression. CodeLite now restores watches from the previous debug session
2932
			DebugMessage(wxT("Restoring watch: ") + m_dbgWatchExpressions.Item(i) + wxT("\n"));
2933
			wxCommandEvent e(wxEVT_COMMAND_MENU_SELECTED, XRCID("add_watch"));
2934
			e.SetString(m_dbgWatchExpressions.Item(i));
2852 by eranif
- Removed wxPropertyGrid completly from the SymbolView plugnin
2935
			Frame::Get()->GetDebuggerPane()->GetWatchesTable()->GetEventHandler()->AddPendingEvent( e );
1839 by eranif
- Implemented FR#2623376: Remember watch expression. CodeLite now restores watches from the previous debug session
2936
		}
1879 by eranif
- Applied patch by Mattia barbon so that codelite will send 2 events when file is renamed: 1 event for the removal of the file and one for adding new fie
2937
	}
2938
}
2030 by eranif
- Added "auto-restart" mechanism for windows & Linux
2939
2109 by eranif
- Fixed regression: 'New Class' from context virtual folder context menu now working again
2940
void Manager::DoRestartCodeLite()
2030 by eranif
- Added "auto-restart" mechanism for windows & Linux
2941
{
2942
	wxString command;
2943
#ifdef __WXMSW__
2944
	// the codelite_launcher application is located where the codelite executable is
2945
	// to properly shoutdown codelite. We first need to close the codelite_indexer process
2081 by eranif
- Fixed crash when codelite performs auto-restart
2946
	command << wxT("\"") << m_codeliteLauncher.GetFullPath() << wxT("\" ")
2109 by eranif
- Fixed regression: 'New Class' from context virtual folder context menu now working again
2947
	<< wxT(" --name=\"")
2948
	<< wxStandardPaths::Get().GetExecutablePath()
2949
	<< wxT("\"");
2090 by eranif
- Toggle all panes now restores the panes to the exact size and location
2950
2081 by eranif
- Fixed crash when codelite performs auto-restart
2951
	wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, XRCID("exit_app"));
2852 by eranif
- Removed wxPropertyGrid completly from the SymbolView plugnin
2952
	Frame::Get()->GetEventHandler()->ProcessEvent(event);
2090 by eranif
- Toggle all panes now restores the panes to the exact size and location
2953
2033 by eranif
"
2954
	wxExecute(command, wxEXEC_ASYNC|wxEXEC_NOHIDE);
2090 by eranif
- Toggle all panes now restores the panes to the exact size and location
2955
2030 by eranif
- Added "auto-restart" mechanism for windows & Linux
2956
#elif defined (__WXGTK__)
2957
	// The Shell is our friend
2082 by eranif
- Fixed: codelite restart now perform the standard shutdown before going down
2958
	command << wxStandardPaths::Get().GetExecutablePath();
2090 by eranif
- Toggle all panes now restores the panes to the exact size and location
2959
2081 by eranif
- Fixed crash when codelite performs auto-restart
2960
	wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, XRCID("exit_app"));
2852 by eranif
- Removed wxPropertyGrid completly from the SymbolView plugnin
2961
	Frame::Get()->GetEventHandler()->AddPendingEvent(event);
2090 by eranif
- Toggle all panes now restores the panes to the exact size and location
2962
2082 by eranif
- Fixed: codelite restart now perform the standard shutdown before going down
2963
	wxExecute(command, wxEXEC_ASYNC|wxEXEC_NOHIDE);
2033 by eranif
"
2964
#endif
2109 by eranif
- Fixed regression: 'New Class' from context virtual folder context menu now working again
2965
}
2030 by eranif
- Added "auto-restart" mechanism for windows & Linux
2966
2109 by eranif
- Fixed regression: 'New Class' from context virtual folder context menu now working again
2967
void Manager::SetCodeLiteLauncherPath(const wxString& path)
2030 by eranif
- Added "auto-restart" mechanism for windows & Linux
2968
{
2969
	m_codeliteLauncher = wxFileName(path, wxT("codelite_launcher"));
2109 by eranif
- Fixed regression: 'New Class' from context virtual folder context menu now working again
2970
}
2034 by eranif
2971
2109 by eranif
- Fixed regression: 'New Class' from context virtual folder context menu now working again
2972
void Manager::OnRestart(wxCommandEvent& event)
2034 by eranif
2973
{
2974
	wxUnusedVar(event);
2109 by eranif
- Fixed regression: 'New Class' from context virtual folder context menu now working again
2975
	DoRestartCodeLite();
2163 by eranif
- Fixed: patch for commandlist serialisation (debugger) by DavidGH
2976
}
2324 by eranif
- added support for new quick watch dialog (not yet enabled)
2977
2346 by eranif
- Debugger: d-clicking an 'expandable' entry in the 'watches' table will now places the display variable dialog in the centre of the screen
2978
void Manager::DoShowQuickWatchDialog( const DebuggerEvent &event )
2979
{
2980
	/////////////////////////////////////////////
2981
	// Handle Tooltips
2982
	/////////////////////////////////////////////
3053 by eranif
- Reverted back to use debugger tip based on wxDialog (to remove the constraint of the tip being confined to the editor area)
2983
2984
	bool                useDialog   = (event.m_userReason == DBG_USERR_WATCHTABLE || event.m_userReason == DBG_USERR_LOCALS);
2985
	IDebugger *         dbgr        = DebuggerMgr::Get().GetActiveDebugger();
2986
	bool                canInteract = (dbgr && dbgr->IsRunning() && DbgCanInteract());
2987
	DisplayVariableDlg* view        = NULL;
2988
2989
	if(canInteract) {
2990
2991
		// Editor Tooltip
2992
		view = GetDebuggerTip();
2993
		view->m_mainVariableObject = event.m_variableObject.gdbId;
2994
		view->m_variableName       = event.m_expression;
2995
		view->m_expression         = event.m_expression;
3051 by eranif
- Debugger: the tooltip is now dismissed automatically when a new item is hovered with the mouse
2996
2346 by eranif
- Debugger: d-clicking an 'expandable' entry in the 'watches' table will now places the display variable dialog in the centre of the screen
2997
		if ( event.m_evaluated.IsEmpty() == false ) {
3053 by eranif
- Reverted back to use debugger tip based on wxDialog (to remove the constraint of the tip being confined to the editor area)
2998
			view->m_variableName << wxT(" = ") << event.m_evaluated;
2346 by eranif
- Debugger: d-clicking an 'expandable' entry in the 'watches' table will now places the display variable dialog in the centre of the screen
2999
		}
2454 by eranif
- Debugger: user can now right click on a node in the tree and choose to add that node as a watch
3000
3001
		if ( event.m_variableObject.typeName.IsEmpty() == false ) {
3053 by eranif
- Reverted back to use debugger tip based on wxDialog (to remove the constraint of the tip being confined to the editor area)
3002
			view->m_variableName << wxT(" [") << event.m_variableObject.typeName << wxT("] ");
2454 by eranif
- Debugger: user can now right click on a node in the tree and choose to add that node as a watch
3003
		}
3004
2346 by eranif
- Debugger: d-clicking an 'expandable' entry in the 'watches' table will now places the display variable dialog in the centre of the screen
3005
		if ( event.m_variableObject.numChilds > 0 ) {
3006
			// Complex type
3007
			dbgr->ListChildren(event.m_variableObject.gdbId, event.m_userReason);
3008
3053 by eranif
- Reverted back to use debugger tip based on wxDialog (to remove the constraint of the tip being confined to the editor area)
3009
		} else  {
2346 by eranif
- Debugger: d-clicking an 'expandable' entry in the 'watches' table will now places the display variable dialog in the centre of the screen
3010
			// Simple type, no need for further calls, show the dialog
3053 by eranif
- Reverted back to use debugger tip based on wxDialog (to remove the constraint of the tip being confined to the editor area)
3011
			if ( !view->IsShown() ) {
3012
				view->BuildTree( event.m_varObjChildren, dbgr );
2346 by eranif
- Debugger: d-clicking an 'expandable' entry in the 'watches' table will now places the display variable dialog in the centre of the screen
3013
				// If the reason for showing the dialog was the 'Watches' table being d-clicked,
3014
				// center the dialog
3053 by eranif
- Reverted back to use debugger tip based on wxDialog (to remove the constraint of the tip being confined to the editor area)
3015
				view->ShowDialog( useDialog );
2346 by eranif
- Debugger: d-clicking an 'expandable' entry in the 'watches' table will now places the display variable dialog in the centre of the screen
3016
			}
3017
		}
3018
	}
3019
}
2453 by eranif
- Added new option to set include / exclude parser paths per workspace. This is done from:
3020
3098 by eranif
- Fixed: Tabsgroup: on Mac use the 'Alt' key for DnD instead of Ctrl (DavidGH)
3021
bool Manager::UpdateParserPaths()
2453 by eranif
- Added new option to set include / exclude parser paths per workspace. This is done from:
3022
{
3023
	wxArrayString localIncludePaths;
3024
	wxArrayString localExcludePaths;
3025
3026
	// If we have an opened workspace, get its search paths
3027
	if(IsWorkspaceOpen()) {
3028
		LocalWorkspaceST::Get()->GetParserPaths(localIncludePaths, localExcludePaths);
3029
	}
3030
3031
	// Update the parser thread with the new paths
2655 by eranif
- Subversion: the subversion tab now remembers its position after restart
3032
	wxArrayString globalIncludePath, uniExcludePath;
2453 by eranif
- Added new option to set include / exclude parser paths per workspace. This is done from:
3033
	TagsOptionsData tod = Frame::Get()->GetTagsOptions();
2655 by eranif
- Subversion: the subversion tab now remembers its position after restart
3034
	globalIncludePath   = tod.GetParserSearchPaths();
3035
	uniExcludePath      = tod.GetParserExcludePaths();
2453 by eranif
- Added new option to set include / exclude parser paths per workspace. This is done from:
3036
2655 by eranif
- Subversion: the subversion tab now remembers its position after restart
3037
	// Add the global search paths to the local workspace
3038
	// include paths (the order does matter)
3039
	for(size_t i=0; i<globalIncludePath.GetCount(); i++){
3040
		if(localIncludePaths.Index(globalIncludePath.Item(i)) == wxNOT_FOUND) {
3041
			localIncludePaths.Add( globalIncludePath.Item(i) );
2453 by eranif
- Added new option to set include / exclude parser paths per workspace. This is done from:
3042
		}
3043
	}
3044
3045
	for(size_t i=0; i<localExcludePaths.GetCount(); i++){
3046
		if(uniExcludePath.Index(localExcludePaths.Item(i)) == wxNOT_FOUND) {
3047
			uniExcludePath.Add( localExcludePaths.Item(i) );
3048
		}
3049
	}
3050
2655 by eranif
- Subversion: the subversion tab now remembers its position after restart
3051
	ParseThreadST::Get()->SetSearchPaths( localIncludePaths, uniExcludePath );
3098 by eranif
- Fixed: Tabsgroup: on Mac use the 'Alt' key for DnD instead of Ctrl (DavidGH)
3052
	return true;
3053
}
2592 by eranif
- code-completion: when retagging workspace, the 'scanning for includes files' is now done in a background thread
3054
3098 by eranif
- Fixed: Tabsgroup: on Mac use the 'Alt' key for DnD instead of Ctrl (DavidGH)
3055
void Manager::OnIncludeFilesScanDone(wxCommandEvent& event)
2592 by eranif
- code-completion: when retagging workspace, the 'scanning for includes files' is now done in a background thread
3056
{
3057
	Frame::Get()->SetStatusMessage(wxT("Retagging..."), 0);
3017 by eranif
- When retagging, show a 'wait cursor' for better user hinting
3058
3059
	wxBusyCursor busyCursor;
2646 by eranif
- Fixed: file spec for C++ files is now case insensitive
3060
	std::set<std::string> *fileSet = (std::set<std::string>*)event.GetClientData();
3061
//	fprintf(stderr, "fileSet size=%d\n", fileSet->size());
2650 by eranif
- Environment variables: Workspace can now uses its own set of environment variable. This is now avaiable from the workspace settings dialog
3062
2592 by eranif
- code-completion: when retagging workspace, the 'scanning for includes files' is now done in a background thread
3063
	wxArrayString projects;
3064
	GetProjectList ( projects );
3065
3066
	std::vector<wxFileName> projectFiles;
3067
	for ( size_t i=0; i<projects.GetCount(); i++ ) {
3068
		ProjectPtr proj = GetProject ( projects.Item ( i ) );
3069
		if ( proj ) {
3070
			proj->GetFiles( projectFiles, true );
3071
		}
3072
	}
3073
3074
	// add to this set the workspace files to create a unique list of
3075
	// files
3076
	for (size_t i=0; i<projectFiles.size(); i++) {
3077
		wxString fn( projectFiles.at(i).GetFullPath() );
2646 by eranif
- Fixed: file spec for C++ files is now case insensitive
3078
		fileSet->insert( fn.mb_str(wxConvUTF8).data() );
2592 by eranif
- code-completion: when retagging workspace, the 'scanning for includes files' is now done in a background thread
3079
	}
2650 by eranif
- Environment variables: Workspace can now uses its own set of environment variable. This is now avaiable from the workspace settings dialog
3080
2646 by eranif
- Fixed: file spec for C++ files is now case insensitive
3081
//	fprintf(stderr, "Parsing the following files\n");
2592 by eranif
- code-completion: when retagging workspace, the 'scanning for includes files' is now done in a background thread
3082
	// recreate the list in the form of vector (the API requirs vector)
3083
	projectFiles.clear();
2646 by eranif
- Fixed: file spec for C++ files is now case insensitive
3084
	std::set<std::string>::iterator iter = fileSet->begin();
3085
	for (; iter != fileSet->end(); iter++ ) {
2592 by eranif
- code-completion: when retagging workspace, the 'scanning for includes files' is now done in a background thread
3086
		wxFileName fn(wxString((*iter).c_str(), wxConvUTF8));
3087
		fn.MakeAbsolute();
2650 by eranif
- Environment variables: Workspace can now uses its own set of environment variable. This is now avaiable from the workspace settings dialog
3088
2646 by eranif
- Fixed: file spec for C++ files is now case insensitive
3089
//		const wxCharBuffer cfile = _C(fn.GetFullPath());
3090
//		fprintf(stderr, "%s\n", cfile.data());
2650 by eranif
- Environment variables: Workspace can now uses its own set of environment variable. This is now avaiable from the workspace settings dialog
3091
2592 by eranif
- code-completion: when retagging workspace, the 'scanning for includes files' is now done in a background thread
3092
		projectFiles.push_back( fn );
3093
	}
3094
3095
	wxStopWatch sw;
3096
	sw.Start();
3097
3098
	// -----------------------------------------------
3099
	// tag them
3100
	// -----------------------------------------------
3101
3102
	TagsManagerST::Get()->RetagFiles ( projectFiles, event.GetInt() );
3204 by eranif
- Added new expermintal code to perform retaggin in the background thread
3103
3104
#if !USE_PARSER_TREAD_FOR_RETAGGING_WORKSPACE
2592 by eranif
- code-completion: when retagging workspace, the 'scanning for includes files' is now done in a background thread
3105
	long end   = sw.Time();
3106
	Frame::Get()->SetStatusMessage(wxT("Done"), 0);
3107
	wxLogMessage(wxT("INFO: Retag workspace completed in %d seconds (%d files were scanned)"), (end)/1000, projectFiles.size());
2646 by eranif
- Fixed: file spec for C++ files is now case insensitive
3108
	SendCmdEvent ( wxEVT_FILE_RETAGGED, ( void* ) &projectFiles );
3204 by eranif
- Added new expermintal code to perform retaggin in the background thread
3109
#endif
2650 by eranif
- Environment variables: Workspace can now uses its own set of environment variable. This is now avaiable from the workspace settings dialog
3110
3098 by eranif
- Fixed: Tabsgroup: on Mac use the 'Alt' key for DnD instead of Ctrl (DavidGH)
3111
	delete fileSet;
3112
}
2612 by eranif
- Continous build will ignore any save events that triggered due to build process startup
3113
3098 by eranif
- Fixed: Tabsgroup: on Mac use the 'Alt' key for DnD instead of Ctrl (DavidGH)
3114
void Manager::DoSaveAllFilesBeforeBuild()
2612 by eranif
- Continous build will ignore any save events that triggered due to build process startup
3115
{
3116
	// Save all files before compiling, but dont saved new documents
3117
	SendCmdEvent(wxEVT_FILE_SAVE_BY_BUILD_START);
3118
	if (!Frame::Get()->GetMainBook()->SaveAll(false, false)) {
3119
		SendCmdEvent(wxEVT_FILE_SAVE_BY_BUILD_END);
3120
		return;
3121
	}
3122
	SendCmdEvent(wxEVT_FILE_SAVE_BY_BUILD_END);
3098 by eranif
- Fixed: Tabsgroup: on Mac use the 'Alt' key for DnD instead of Ctrl (DavidGH)
3123
}
3049 by eranif
- Debugger: changed the debugger tip from wxDialog into wxPanel
3124
3098 by eranif
- Fixed: Tabsgroup: on Mac use the 'Alt' key for DnD instead of Ctrl (DavidGH)
3125
DisplayVariableDlg* Manager::GetDebuggerTip()
3049 by eranif
- Debugger: changed the debugger tip from wxDialog into wxPanel
3126
{
3053 by eranif
- Reverted back to use debugger tip based on wxDialog (to remove the constraint of the tip being confined to the editor area)
3127
	if(!m_watchDlg) {
3128
		m_watchDlg = new DisplayVariableDlg(Frame::Get());
3049 by eranif
- Debugger: changed the debugger tip from wxDialog into wxPanel
3129
	}
3098 by eranif
- Fixed: Tabsgroup: on Mac use the 'Alt' key for DnD instead of Ctrl (DavidGH)
3130
	return m_watchDlg;
3131
}
3132