forked from eranif/codelite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimanager.h
630 lines (539 loc) · 20.5 KB
/
imanager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// copyright : (C) 2008 by Eran Ifrah
// file name : imanager.h
//
// -------------------------------------------------------------------------
// A
// _____ _ _ _ _
// / __ \ | | | | (_) |
// | / \/ ___ __| | ___| | _| |_ ___
// | | / _ \ / _ |/ _ \ | | | __/ _ )
// | \__/\ (_) | (_| | __/ |___| | || __/
// \____/\___/ \__,_|\___\_____/_|\__\___|
//
// F i l e
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
#ifndef IMANAGER_H
#define IMANAGER_H
#include "ieditor.h"
#include "iconfigtool.h"
#include "wx/treectrl.h"
#include "project.h"
#include "Notebook.h"
#include "optionsconfig.h"
#include "queuecommand.h"
#include <wx/aui/framemanager.h>
#include "bitmap_loader.h"
#include <vector>
#include "debugger.h"
#include "clStatusBar.h"
class clWorkspaceView;
class TagsManager;
class clCxxWorkspace;
class EnvironmentConfig;
class JobQueue;
class wxApp;
class IPlugin;
class BuildManager;
class BuildSettingsConfig;
class NavMgr;
class IMacroManager;
class wxAuiManager;
//--------------------------
// Auxulary class
//--------------------------
class TreeItemInfo
{
public:
wxTreeItemId m_item;
wxFileName m_fileName; //< FileName where available (FileView & File Explorer trees)
wxString m_text; //< Tree item text (all)
int m_itemType; //< For FileView items (FileView only)
wxArrayString m_paths; //< For file explorer which supports multiple selection (File Explorer tree only)
};
//---------------------------
// List of available trees
//---------------------------
enum TreeType { TreeFileView = 0, TreeFileExplorer };
enum eOutputPaneTab { kOutputTab_Build, kOutputTab_Output };
// A struct representing a tab in the notebook control
struct clTab {
typedef std::vector<clTab> Vec_t;
wxString text;
wxWindow* window;
wxBitmap bitmap;
bool isFile;
wxFileName filename;
clTab()
: window(NULL)
, isFile(false)
{
}
};
//------------------------------------------------------------------
// Defines the interface of the manager
//------------------------------------------------------------------
/**
* @class IManager
* @author Eran
* @date 05/07/08
* @file imanager.h
* @brief every plugin holds an instance of this class.
* You should use this class to interact with CodeLite
*/
class IManager
{
wxArrayString m_workspaceTabs;
wxArrayString m_outputTabs;
public:
IManager() {}
virtual ~IManager() {}
/**
* @brief return a list of all possible output tabs registered by the user
*/
const wxArrayString& GetOutputTabs() const { return m_outputTabs; }
/**
* @brief return a list of all possible workspace tabs
*/
const wxArrayString& GetWorkspaceTabs() const { return m_workspaceTabs; }
/**
* @brief register a workspace tab
*/
void AddWorkspaceTab(const wxString& tabLabel) {
if(m_workspaceTabs.Index(tabLabel) == wxNOT_FOUND) {
m_workspaceTabs.Add(tabLabel);
}
}
/**
* @brief register output pane tab
*/
void AddOutputTab(const wxString& tabLabel) {
if(m_outputTabs.Index(tabLabel) == wxNOT_FOUND) {
m_outputTabs.Add(tabLabel);
}
}
/**
* @brief show the output pane and if provided, select 'selectedWindow'
* @param selectWindow tab within the 'Output Pane' to select, if empty don't change
* the selection
*/
virtual void ShowOutputPane(const wxString& selectWindow = "") = 0;
/**
* @brief show the toolbar. This only works when using the native toolbar
*/
virtual void ShowToolBar(bool show = true) = 0;
/**
* @brief is the native toolbar visible?
*/
virtual bool IsToolBarShown() const = 0;
/**
* @brief toggle the output pane
* @param selectWindow tab within the 'Output Pane' to select, if empty don't change
* the selection
*/
virtual void ToggleOutputPane(const wxString& selectedWindow = "") = 0;
// return the current editor
/**
* @brief return the active editor
* @return pointer to the current editor, or NULL incase the active editor is not of type LEditor or no active
* editor open
*/
virtual IEditor* GetActiveEditor() = 0;
/**
* @brief return the main frame's status bar
*/
virtual clStatusBar* GetStatusBar() = 0;
/**
* @brief open file and make it the active editor
* @param fileName the file to open - use absolute path
* @param projectName project to associate this file - can be wxEmptyString
* @param lineno if lineno is not wxNOT_FOUD, the caret will placed on this line number
* @return true if file opened
*/
virtual IEditor*
OpenFile(const wxString& fileName, const wxString& projectName = wxEmptyString, int lineno = wxNOT_FOUND) = 0;
/**
* @brief Open file using browsing record
* @param rec browsing record
* @return true on success false otherwise
*/
virtual IEditor* OpenFile(const BrowseRecord& rec) = 0;
/**
* @brief return a pointer to the configuration tool
* @sa IConfigTool
*/
virtual IConfigTool* GetConfigTool() = 0;
/**
* @brief return TreeItemInfo for the selected tree item
* @param type the tree we are interested in
* @sa TreeItemInfo
* @sa TreeType
*/
virtual TreeItemInfo GetSelectedTreeItemInfo(TreeType type) = 0;
/**
* @brief returns a pointer to wxTreeCtrl by type
* @param type the type of tree
* @sa TreeType
*/
virtual wxTreeCtrl* GetTree(TreeType type) = 0;
/**
* @brief return a pointer to the workspace pane notebook (the one with the 'workspace' title)
* @return pointer to Notebook
* @sa Notebook
*/
virtual Notebook* GetWorkspacePaneNotebook() = 0;
/**
* @brief return a pointer to the output pane notebook (the one with the 'output' title)
* @return pointer to Notebook
* @sa Notebook
*/
virtual Notebook* GetOutputPaneNotebook() = 0;
/**
* @brief append text line to the tab in the "Output View"
*/
virtual void AppendOutputTabText(eOutputPaneTab tab, const wxString& text) = 0;
/**
* @brief clear the content of the selected output tab
*/
virtual void ClearOutputTab(eOutputPaneTab tab) = 0;
virtual wxPanel* GetEditorPaneNotebook() = 0;
virtual void AddEditorPage(wxWindow* page, const wxString& name, const wxString& tooltip = wxEmptyString) = 0;
virtual wxWindow* GetActivePage() = 0;
virtual wxWindow* GetPage(size_t page) = 0;
/**
* @brief return the startup directory of CodeLite which is also the base directory for searching installation files
* @return a full path to the startup directory
*/
virtual wxString GetStartupDirectory() const = 0;
/**
* @brief return the installation directory of codelite
* @return a full path to codelite installation
*/
virtual wxString GetInstallDirectory() const = 0;
/**
* @brief add project to the workspace
* @param path full path to the project to add
*/
virtual void AddProject(const wxString& path) = 0;
/**
* @brief return true of a workspace is already open
*/
virtual bool IsWorkspaceOpen() const = 0;
/**
* @brief return an instance to the tags manager - which allows access to CodeLite CodeCompletion API
* @return a pointer to the tags manager
* @sa TagsManager
*/
virtual TagsManager* GetTagsManager() = 0;
/**
* @brief return a pointer to the ** C++ ** workspace manager
*/
virtual clCxxWorkspace* GetWorkspace() = 0;
/**
* @brief return the workspace view tab
* @return
*/
virtual clWorkspaceView* GetWorkspaceView() = 0;
/**
* @brief add files to a virtual folder in the project
* @param item a tree item which represents the tree item of the virtual folder
* @param paths an array of files to add
* @return true on sucesss, false otherwise
*/
virtual bool AddFilesToVirtualFolder(wxTreeItemId& item, wxArrayString& paths) = 0;
/**
* @brief add files to a virtual folder in the project
* @param vdFullPath virtual directory full path in the form of <project>:vd1:vd2:...:vdN
* @param paths an array of files to add
* @return true on sucesss, false otherwise
*/
virtual bool AddFilesToVirtualFolder(const wxString& vdFullPath, wxArrayString& paths) = 0;
/**
* @brief Add a pair of cpp/h files to the :src/include folders, if these exist
* @param vdFullPath virtual directory full path in the form of <project>:vd1:vd2:...:vdN
* @param paths an array of files to add
* @return true on sucesss, false otherwise
*/
virtual bool AddFilesToVirtualFolderIntelligently(const wxString& vdFullPath, wxArrayString& paths) = 0;
/**
* @brief Redefine the files / folders that make up a project
* @param proj Ref to the project to modify
* @param path The root directory of the files to add
* @param files The list of file paths w/o separate folder entries
*/
virtual void RedefineProjFiles(ProjectPtr proj, const wxString& path, std::vector<wxString>& files) = 0;
/**
* @brief create virtual folder to parentPath
* @param parentPath parent virtual directory full path in the form of <project>:vd1:vd2:...:vdN which must exist
* @param vdName child VD name
* @return true on success, false otherwise
*/
virtual bool CreateVirtualDirectory(const wxString& parentPath, const wxString& vdName) = 0;
/**
* @brief return the size of the icons used by CodeLite
* @return 16 or 24
*/
virtual int GetToolbarIconSize() = 0;
/**
* @brief return true if toobars are allowed for plugins. This is useful for the Mac port of
* codelite. On Mac, only single toolbar is allowed in the application (otherwise, the application
* does not feet into the environment)
* @return true if plugin can create a toolbar, false otherwise
*/
virtual bool AllowToolbar() = 0;
/**
* @brief return a pointer to the docking manager (wxAUI)
*/
virtual wxAuiManager* GetDockingManager() = 0;
/**
* @brief return a pointer to the environment manager
* @sa EnvironmentConfig
*/
virtual EnvironmentConfig* GetEnv() = 0;
/**
* @brief return a pointer to the job queue manager
* @return job queue manager
*/
virtual JobQueue* GetJobQueue() = 0;
/**
* @brief return the project execution command as set in the project's settings
* @param projectName the project
* @param wd starting dirctory
* @return the execution command or wxEmptyString if the project does not exist
*/
virtual wxString GetProjectExecutionCommand(const wxString& projectName, wxString& wd) = 0;
/**
* @brief return the application
*/
virtual wxApp* GetTheApp() = 0;
/**
* @brief reload the current workspace, this function does not do anything if a workspace is not opened
*/
virtual void ReloadWorkspace() = 0;
/**
* @brief search for loaded plugin by its name, if the plugin is loaded returns its pointer
* @param pluginName plugin to search
* @return pointer to the plugin or NULL if it is not loaded
*/
virtual IPlugin* GetPlugin(const wxString& pluginName) = 0;
/**
* @brief output window for receiving async cmd events
*/
virtual wxEvtHandler* GetOutputWindow() = 0;
/**
* @brief save all modified files
*/
virtual bool SaveAll() = 0;
/**
* @brief return the editor's settings object
*/
virtual OptionsConfigPtr GetEditorSettings() = 0;
/**
* @brief search for pattern in active editor and select name if found
*/
virtual void FindAndSelect(const wxString& pattern, const wxString& name, int pos = 0) = 0;
/**
* @brief return tag at caret in active editor (if ambiguous, user will get a selection dialog)
* @param scoped whether to do scope-aware lookup
* @param impl whether to return declaration (false) or definition (true)
* @return the found tag or NULL
*/
virtual TagEntryPtr GetTagAtCaret(bool scoped, bool impl) = 0;
/**
* @brief show a (short) message in the status bar
* @param msg the string to display
* @param col the statusbar pane to use
* @param seconds_to_live how many seconds to display it for; 0 == forever; -1 == use the default
*/
virtual void SetStatusMessage(const wxString& msg, int col, int seconds_to_live = wxID_ANY) = 0;
/**
* @brief start processing commands from the queue
*/
virtual void ProcessCommandQueue() = 0;
/**
* @brief place a command on the internal queue of codelite to be processed. Each command is executed on
* a separated process. The queue will not start processing, until a call to ProcessCommandQueue() is issued
* @param cmd command to process
*/
virtual void PushQueueCommand(const QueueCommand& cmd) = 0;
/**
* @brief stop the current process execution and clear all commands from the queue
*/
virtual void StopAndClearQueue() = 0;
/**
* return true if a compilation is in process (either clean or build)
*/
virtual bool IsBuildInProgress() const = 0;
/**
* @brief return true if a shutdown is currently in progress
* @return
*/
virtual bool IsShutdownInProgress() const = 0;
/**
* return true if the last buid ended successfully
*/
virtual bool IsBuildEndedSuccessfully() const = 0;
/**
* @brief return the project name of a file
* @param fullPathFileName file to search
* @return project name or wxEmptyString if the search failed
*/
virtual wxString GetProjectNameByFile(const wxString& fullPathFileName) = 0;
/**
* @brief accessor to singleton object in the application
*/
virtual BuildManager* GetBuildManager() = 0;
/**
* @brief accessor to singleton object in the application
*/
virtual BuildSettingsConfig* GetBuildSettingsConfigManager() = 0;
/**
* @brief return the singleton object of the navigation manager
*/
virtual NavMgr* GetNavigationMgr() = 0;
void SetStatusMessage(const wxString& msg) { SetStatusMessage(msg, 0); }
/**
* @brief close the named page in the mainbook
* @param the tab title.
* @note if there are multiple items with this title, all of them will be closed
*/
virtual bool ClosePage(const wxString& title) = 0;
/**
* @brief close an editor with a given file name (full path)
*/
virtual bool ClosePage(const wxFileName& filename) = 0;
/**
* @brief return named window in mainbook
*/
virtual wxWindow* FindPage(const wxString& text) = 0;
/**
* @brief add a page to the mainbook
*/
virtual bool AddPage(wxWindow* win,
const wxString& text,
const wxString& tooltip = wxEmptyString,
const wxBitmap& bmp = wxNullBitmap,
bool selected = false) = 0;
/**
* @brief select a window in mainbook
*/
virtual bool SelectPage(wxWindow* win) = 0;
/**
* @brief set the page's title
*/
virtual void SetPageTitle(wxWindow* win, const wxString& title) = 0;
/**
* @brief set the page's title
*/
virtual wxString GetPageTitle(wxWindow* win) const = 0;
/**
* @brief open new editor "untitiled"
* @return pointer to the editor
*/
virtual IEditor* NewEditor() = 0;
/**
* @brief return the default icons loader class
*/
virtual BitmapLoader* GetStdIcons() = 0;
/**
* @brief return the compilation flags for a file in a given project
*/
virtual wxArrayString GetProjectCompileFlags(const wxString& projectName, bool isCppFile) = 0;
/**
* @brief return the selected project item. Note that this is different than
* returning the *active* project. A selected project, is the project that it is
* selected in the tree "blue highlight" or the parent of the selected item
*/
virtual ProjectPtr GetSelectedProject() const = 0;
/**
* @brief search the mainbook for an editor representing a given filename
* return IEditor* or NULL if no match was found
*/
virtual IEditor* FindEditor(const wxString& filename) const = 0;
/**
* @brief enable/disable clang code completion
*/
virtual void EnableClangCodeCompletion(bool b) = 0;
/**
* @brief return the number of pages in the main editor
*/
virtual size_t GetPageCount() const = 0;
/**
* @brief return list of all open editors in the main notebook.
* This function returns only instances of IEditor (i.e. a file text editor)
*/
virtual size_t GetAllEditors(IEditor::List_t& editors, bool inOrder = false) = 0;
/**
* @brief return list of open tabs in the main notebook. If you need only editors, use GetAllEditors
* @param tabs [output]
* @param inOrder retain the editors order
*/
virtual size_t GetAllTabs(clTab::Vec_t& tabs) = 0;
// ---------------------------------------------
// Breakpoint management
// ---------------------------------------------
/**
* @brief return a vector of all the current breakpoints set by the user
*/
virtual size_t GetAllBreakpoints(BreakpointInfo::Vec_t& breakpoints) = 0;
/**
* @brief delete all breakpoints assigned by the user
*/
virtual void DeleteAllBreakpoints() = 0;
/**
* @brief set breakpoints (override any existing breakpoints)
* this function also refreshes the editors markers
*/
virtual void SetBreakpoints(const BreakpointInfo::Vec_t& breakpoints) = 0;
/**
* @brief process a standard edit event ( wxID_COPY, wxID_PASTE etc)
* @param e the event to process
* @param editor the editor
*/
virtual void ProcessEditEvent(wxCommandEvent& e, IEditor* editor) = 0;
/**
* @brief add 'fileName' to the list of recently used workspaces
* @param fileName
*/
virtual void AddWorkspaceToRecentlyUsedList(const wxFileName& fileName) = 0;
/**
* @brief store a new session for the workspace file associated with the file 'workspaceFile'
*/
virtual void StoreWorkspaceSession(const wxFileName& workspaceFile) = 0;
/**
* @brief load the session associated with 'workspaceFile'
*/
virtual void LoadWorkspaceSession(const wxFileName& workspaceFile) = 0;
// ----------------------------------------------
// Perspective management
// ----------------------------------------------
/**
* @brief load perspective by name. If no such perspective exists
* this function does nothing
*/
virtual void LoadPerspective(const wxString& perspectiveName) = 0;
/**
* @brief Save the current perspective by name
* this function also makes sure that the 'Perspective' menu is updated
*/
virtual void SavePerspective(const wxString& perspectiveName) = 0;
// Search
/**
* @brief open the find in files dialog and select 'path' to search in
*/
virtual void OpenFindInFileForPath(const wxString& path) = 0;
/**
* @brief open the find in files dialog with multiple search paths
*/
virtual void OpenFindInFileForPaths(const wxArrayString& paths) = 0;
};
#endif // IMANAGER_H