3 import "FileSystemIterator"
5 class ImportFolderFSI : NormalFileSystemIterator
7 ProjectView projectView;
8 Array<ProjectNode> stack { };
10 bool OnFolder(char * folderPath)
12 char name[MAX_LOCATION];
13 ProjectNode parentNode = stack.lastIterator.data;
15 GetLastDirectory(folderPath, name);
16 folder = parentNode.FindSpecial(name, false, true, true);
18 folder = projectView.NewFolder(parentNode, name, false);
23 void OutFolder(char * folderPath, bool isRoot)
25 stack.lastIterator.Remove(); //stack.Remove();
28 bool OnFile(char * filePath)
30 ProjectNode parentNode = stack.lastIterator.data;
31 projectView.AddFile(parentNode, filePath, parentNode.isInResources, false);
36 static Array<FileFilter> fileFilters
38 { $"eC/C/C++ Files (*.ec, *.eh, *.c, *.cpp, *.cc, *.cxx, *.h, *.hpp, *.hh, *.hxx)", "ec, eh, c, cpp, cc, cxx, h, hpp, hh, hxx" },
39 { $"eC/C/C++ Source Files (*.ec, *.c, *.cpp, *.cc, *.cxx)", "ec, eh, c, cpp, cc, cxx" },
40 { $"Header Files for eC/C/C++ (*.eh, *.h, *.hpp, *.hh, *.hxx)", "eh, h, hpp, hh, hxx" },
41 { $"All files", null }
44 static Array<FileFilter> resourceFilters
46 { $"Image Files (*.jpg, *.jpeg, *.bmp, *.pcx, *.png,*.gif)", "jpg, jpeg, bmp, pcx, png, gif" },
47 { $"3D Studio Model Files (*.3ds)", "3ds" },
48 { $"All files", null }
51 static Array<FileType> fileTypes
53 { $"Based on extension", null },
56 { $"3D Studio Model", "3ds" }
59 static Array<FileFilter> projectFilters
61 { $"Project Files (*.epj)", ProjectExtension },
62 { $"Workspace Files (*.ews)", WorkspaceExtension }
65 static Array<FileType> projectTypes
67 { $"Ecere IDE Project", ProjectExtension },
68 { $"Ecere IDE Workspace", WorkspaceExtension }
71 static char * iconNames[] =
73 "<:ecere>mimeTypes/file.png", /*genFile*/
74 "<:ecere>mimeTypes/textEcereWorkspace.png", /*ewsFile*/
75 "<:ecere>mimeTypes/textEcereProject.png", /*epjFile*/
76 "<:ecere>places/folder.png", /*folder*/
77 "<:ecere>status/folderOpen.png", /*openFolder*/
78 "<:ecere>mimeTypes/textEcereSource.png", /*ecFile*/
79 "<:ecere>mimeTypes/textEcereHeader.png", /*ehFile*/
80 "<:ecere>mimeTypes/textCSource.png", /*cFile*/
81 "<:ecere>mimeTypes/textCHeader.png", /*hFile*/
82 "<:ecere>mimeTypes/textC++Source.png", /*cppFile*/
83 "<:ecere>mimeTypes/textC++Header.png", /*hppFile*/
84 "<:ecere>mimeTypes/text.png", /*textFile*/
85 "<:ecere>mimeTypes/textHyperTextMarkup.png", /*webFile*/
86 "<:ecere>mimeTypes/image.png", /*pictureFile*/
87 "<:ecere>status/audioVolumeHigh.png", /*soundFile*/
88 "<:ecere>mimeTypes/package.png", /*archiveFile*/
89 "<:ecere>mimeTypes/packageSoftware.png", /*packageFile*/
90 "<:ecere>mimeTypes/packageOpticalDisc.png", /*opticalMediaImageFile*/
91 "<:ecere>mimeTypes/file.png" /*mFile*/ //TODO: create icon for mfile
94 enum PrepareMakefileMethod { normal, force, forceExists };
96 enum BuildType { build, rebuild, relink, run, start, restart };
99 none, buildingMainProject, buildingSecondaryProject, compilingFile;
101 property bool { get { return this != none; } }
102 //property bool actualBuild { get { return this == buildingMainProject || this == buildingSecondaryProject; } }
105 class ProjectView : Window
108 //hasMinimize = true;
110 borderStyle = sizable;
111 hasHorzScroll = true;
112 hasVertScroll = true;
115 anchor = Anchor { left = 0, top = 0, bottom = 0 };
118 //hasMinimize = true;
119 saveDialog = projectFileDialog;
122 BuildState buildInProgress;
123 BitmapResource icons[NodeIcons];
126 property Workspace workspace
132 for(prj : workspace.projects)
134 DeleteNode(prj.topNode);
136 workspace.projects.Free();
137 ide.debugger.CleanUp();
142 fileDialog.currentDirectory = workspace.workspaceDir;
143 resourceFileDialog.currentDirectory = workspace.workspaceDir;
144 for(prj : workspace.projects)
145 AddNode(prj.topNode, null);
146 ide.statusBar.text = $"Generating Makefile & Dependencies...";
148 for(prj : workspace.projects)
149 prj.ModifiedAllConfigs(true, false, false, false);
150 ide.statusBar.text = $"Initializing Debugger"; app.UpdateDisplay();
151 ide.statusBar.text = null;
155 get { return workspace; }
158 bool drawingInProjectSettingsDialog;
159 bool drawingInProjectSettingsDialogHeader;
160 ProjectSettings projectSettingsDialog;
167 for(c = 0; c < NodeIcons::enumSize; c++)
169 icons[c] = BitmapResource { iconNames[c], alphaBlend = true };
170 AddResource(icons[c]);
172 fileList.AddField(DataField { dataType = class(ProjectNode), freeData = false, userData = this });
178 ide.DestroyTemporaryProjectDir();
188 multiSelect = true, fullRowSelect = false, hasVertScroll = true, hasHorzScroll = true;
189 borderStyle = deep, parent = this, collapseControl = true, treeBranches = true;
190 anchor = Anchor { left = 0, right = 0, top = 0 , bottom = 0 };
192 background = projectViewBackground;
193 foreground = projectViewText;
194 selectionColor = selectionColor, selectionText = selectionText;
195 stippleColor = skyBlue;
197 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
199 if(!active) Update(null);
200 return ListBox::OnActivate(active, previous, goOnWithActivation, direct);
203 bool NotifyDoubleClick(ListBox listBox, int x, int y, Modifiers mods)
205 // Prevent the double click from reactivating the project view (returns false if we opened something)
206 return !OpenSelectedNodes();
209 bool NotifyRightClick(ListBox listBox, int x, int y, Modifiers mods)
211 DataRow row = listBox.currentRow;
214 ProjectNode node = (ProjectNode)row.tag;
215 if(node.type == NodeTypes::project || node.type == resources || node.type == file || node.type == folder)
217 bool buildMenuUnavailable = buildInProgress;
219 Menu popupContent { };
221 if(node.type == NodeTypes::project)
223 //if(node == ((Project)workspace.projects.first).topNode)
225 MenuItem { popupContent, $"Build", b, NotifySelect = ProjectBuild }.disabled = buildMenuUnavailable;
226 MenuItem { popupContent, $"Relink", l, NotifySelect = ProjectLink }.disabled = buildMenuUnavailable;
227 MenuItem { popupContent, $"Rebuild", r, NotifySelect = ProjectRebuild }.disabled = buildMenuUnavailable;
228 MenuItem { popupContent, $"Clean", c, NotifySelect = ProjectClean }.disabled = buildMenuUnavailable;
229 MenuItem { popupContent, $"Regenerate Makefile", m, NotifySelect = ProjectRegenerate }.disabled = buildMenuUnavailable;
230 MenuDivider { popupContent };
232 MenuItem { popupContent, $"New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
233 MenuItem { popupContent, $"New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
234 MenuItem { popupContent, $"Import Folder...", i, NotifySelect = ProjectImportFolder };
235 MenuItem { popupContent, $"Add Files to Project...", f, NotifySelect = ProjectAddFiles };
236 MenuDivider { popupContent };
237 MenuItem { popupContent, $"Add New Form...", o, NotifySelect = ProjectAddNewForm };
238 // MenuItem { popupContent, "Add New Behavior Graph...", g, NotifySelect = ProjectAddNewGraph };
239 MenuDivider { popupContent };
240 if(node != ((Project)workspace.projects.first).topNode)
242 MenuItem { popupContent, $"Remove project from workspace", r, NotifySelect = ProjectRemove }.disabled = buildMenuUnavailable;
243 MenuDivider { popupContent };
245 MenuItem { popupContent, $"Active Configuration...", s, Key { f5, alt = true } , NotifySelect = MenuConfig };
246 MenuItem { popupContent, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
247 MenuDivider { popupContent };
248 MenuItem { popupContent, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
249 MenuDivider { popupContent };
250 MenuItem { popupContent, $"Save", v, Key { s, ctrl = true }, NotifySelect = ProjectSave }.disabled = !node.modified;
251 MenuDivider { popupContent };
252 MenuItem { popupContent, $"Properties...", p, Key { enter, alt = true }, NotifySelect = FileProperties };
254 else if(node.type == resources)
256 MenuItem { popupContent, $"New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
257 MenuItem { popupContent, $"New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
258 MenuItem { popupContent, $"Add Resources to Project...", f, NotifySelect = ResourcesAddFiles };
259 MenuItem { popupContent, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
260 MenuDivider { popupContent };
261 MenuItem { popupContent, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
262 MenuItem { popupContent, $"Properties...", p, Key { enter, alt = true }, NotifySelect = FileProperties };
264 else if(node.type == file)
266 MenuItem { popupContent, $"Open", o, NotifySelect = FileOpenFile };
267 MenuItem { popupContent, $"Compile", c, Key { f7, ctrl = true}, NotifySelect = FileCompile }.disabled = buildMenuUnavailable;
268 MenuDivider { popupContent };
269 MenuItem { popupContent, $"Remove", r, NotifySelect = FileRemoveFile };
270 MenuDivider { popupContent };
271 MenuItem { popupContent, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
272 MenuDivider { popupContent };
273 MenuItem { popupContent, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
274 MenuItem { popupContent, $"Properties..", p, Key { enter, alt = true }, NotifySelect = FileProperties };
276 else if(node.type == folder)
278 bool isInResources = node.isInResources;
280 MenuItem { popupContent, $"New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
281 MenuItem { popupContent, $"New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
282 MenuItem { popupContent, $"Import Folder...", i, NotifySelect = ProjectImportFolder };
285 MenuItem { popupContent, $"Add Resources to Folder...", f, NotifySelect = ResourcesAddFiles };
289 MenuItem { popupContent, $"Add Files to Folder...", f, NotifySelect = ProjectAddFiles };
293 MenuDivider { popupContent };
294 MenuItem { popupContent, $"Add New Form...", o, NotifySelect = ProjectAddNewForm };
295 MenuItem { popupContent, $"Add New Behavior Graph...", g, NotifySelect = ProjectAddNewGraph };
297 MenuDivider { popupContent };
298 MenuItem { popupContent, $"Remove", r, NotifySelect = FileRemoveFile };
299 MenuDivider { popupContent };
300 MenuItem { popupContent, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
301 MenuDivider { popupContent };
302 MenuItem { popupContent, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
303 MenuItem { popupContent, $"Properties...", p, Key { enter, alt = true }, NotifySelect = FileProperties };
308 master = this, menu = popupContent;
310 x + clientStart.x + absPosition.x - app.desktop.position.x,
311 y + clientStart.y + absPosition.y - app.desktop.position.y };
319 bool NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch)
323 ProjectNode node = (ProjectNode)row.tag;
326 case altEnter: case Key { keyPadEnter, alt = true }:
328 NodeProperties { parent = parent, master = this,
329 position = { position.x + 100, position.y + 100 }, node = node }.Create();
332 case enter: case keyPadEnter:
335 for(resNode = node.parent; resNode; resNode = resNode.parent)
336 if(resNode.type == resources)
338 if(node.type == project || (node.type == folder && !resNode))
343 else if(node.type == resources || node.type == folder)
352 if(node.type == project || node.type == folder || node.type == resources)
361 if(node.type == project || node.type == folder || node.type == resources)
363 NewFolder(node, null, true);
370 if(node.type == file)
372 FileCompile(null, (Modifiers)key);
377 case Key { space, shift = true }:
380 if(node.type == NodeTypes::project)
383 for(p : workspace.projects)
385 if(p.topNode == node)
391 prj.RotateActiveConfig(!key.shift);
402 case enter: case keyPadEnter: OpenSelectedNodes(); break;
403 case del: RemoveSelectedNodes(); break;
406 Window activeClient = ide.activeClient;
408 activeClient.Activate();
410 ide.RepositionWindows(true);
417 bool NotifyCollapse(ListBox listBox, DataRow row, bool collapsed)
419 ProjectNode node = (ProjectNode)row.tag;
420 if(node.type == folder)
421 node.icon = collapsed ? folder : openFolder;
426 FileDialog importFileDialog { autoCreate = false, type = selectDir, text = $"Import Folder" };
427 FileDialog projectFileDialog
429 autoCreate = false, filters = projectFilters.array, sizeFilters = projectFilters.count * sizeof(FileFilter);
430 types = projectTypes.array, sizeTypes = projectTypes.count * sizeof(FileType);
432 FileDialog fileDialog
434 autoCreate = false, mayNotExist = true, filters = fileFilters.array, sizeFilters = fileFilters.count * sizeof(FileFilter);
435 types = fileTypes.array, sizeTypes = fileTypes.count * sizeof(FileType);
437 FileDialog resourceFileDialog
439 autoCreate = false, mayNotExist = true, filters = resourceFilters.array, sizeFilters = resourceFilters.count * sizeof(FileFilter);
440 types = fileTypes.array, sizeTypes = fileTypes.count * sizeof(FileType);
443 Menu fileMenu { menu, $"File", f };
444 MenuItem { fileMenu, $"Save", s, Key { s, ctrl = true }, NotifySelect = MenuFileSave };
445 // MenuItem { fileMenu, "Save As...", a, NotifySelect = MenuFileSaveAs };
447 bool OnClose(bool parentClosing)
449 if(!parentClosing && visible)
461 //if(ide.findInFilesDialog && ide.findInFilesDialog.created && ide.findInFilesDialog.mode != directory)
462 // ide.findInFilesDialog.SearchStop();
464 ide.outputView.buildBox.Clear();
465 ide.outputView.debugBox.Clear();
466 //ide.outputView.findBox.Clear();
467 ide.callStackView.Clear();
468 ide.watchesView.Clear();
469 ide.threadsView.Clear();
470 ide.breakpointsView.Clear();
471 ide.outputView.ShowClearSelectTab(find); // why this?
474 bool OnSaveFile(char * fileName)
476 for(prj : ide.workspace.projects)
478 if(prj.topNode.modified && prj.Save(prj.filePath))
480 // ProjectUpdateMakefileForAllConfigs(prj, true, true);
481 prj.topNode.modified = false;
484 modifiedDocument = false;
489 bool IsModuleInProject(char * filePath)
491 char moduleName[MAX_FILENAME]; //, modulePath[MAX_LOCATION];
492 GetLastDirectory(filePath, moduleName);
493 return project.topNode.Find(moduleName, false) != null;
496 bool GetRelativePath(char * filePath, char * relativePath)
498 return project.GetRelativePath(filePath, relativePath);
501 ProjectNode GetNodeFromWindow(Window document, Project project)
503 if(document.fileName)
505 char winFileName[MAX_LOCATION];
506 char * documentFileName = GetSlashPathBuffer(winFileName, document.fileName);
507 for(p : ide.workspace.projects)
509 Project prj = project ? project : p;
511 char moduleName[MAX_FILENAME], modulePath[MAX_LOCATION];
512 GetLastDirectory(document.fileName, moduleName);
514 if((node = prj.topNode.Find(moduleName, false)))
516 strcpy(modulePath, prj.topNode.path);
517 PathCatSlash(modulePath, node.path);
518 PathCatSlash(modulePath, node.name);
519 if(!fstrcmp(documentFileName, modulePath))
530 // ((( UTILITY FUNCTIONS )))
532 // ************************************************************************
533 // *** These methods below are part of a sequence of events, and as ***
534 // *** such they must be passed the current compiler and project config ***
535 // ************************************************************************
536 bool DisplayCompiler(CompilerConfig compiler, bool cleanLog)
538 ShowOutputBuildLog(cleanLog);
539 ide.outputView.buildBox.Logf($"%s Compiler\n", compiler ? compiler.name : $"{problem with compiler selection}");
542 bool ProjectPrepareForToolchain(Project project, PrepareMakefileMethod method, bool cleanLog, bool displayCompiler,
543 CompilerConfig compiler, ProjectConfig config)
546 char message[MAX_F_STRING];
547 LogBox logBox = ide.outputView.buildBox;
549 ShowOutputBuildLog(cleanLog);
552 DisplayCompiler(compiler, false);
554 ProjectPrepareMakefile(project, method, false, false, compiler, config);
558 bool ProjectPrepareMakefile(Project project, PrepareMakefileMethod method, bool cleanLog, bool displayCompiler,
559 CompilerConfig compiler, ProjectConfig config)
561 char makefilePath[MAX_LOCATION];
562 char makefileName[MAX_LOCATION];
564 LogBox logBox = ide.outputView.buildBox;
566 ShowOutputBuildLog(cleanLog);
569 DisplayCompiler(compiler, false);
571 strcpy(makefilePath, project.topNode.path);
572 project.CatMakeFileName(makefileName, compiler, config);
573 PathCatSlash(makefilePath, makefileName);
575 exists = FileExists(makefilePath);
576 if((method == normal && (!exists || config.makingModified/*|| project.topNode.modified*/)) ||
577 (method == forceExists && exists) ||
578 method == force) // || config.makingModified || makefileDirty
582 ide.statusBar.text = $"Generating Makefile & Dependencies..."; // Dependencies?
585 if((method == normal && !exists) || (method == force && !exists))
586 action = $"Generating ";
587 else if(method == force)
588 action = $"Regenerating ";
589 else if(method == normal || method == forceExists)
590 action = $"Updating ";
594 reason = $"Makefile doesn't exist. ";
595 else if(project.topNode.modified)
596 reason = $"Project has been modified. ";
600 //logBox.Logf("%s\n", makefileName);
601 logBox.Logf($"%s - %s%smakefile for %s config...\n", makefileName, reason, action, GetConfigName(config));
602 project.GenerateMakefile(null, false, null, compiler, config);
604 ide.statusBar.text = null;
611 bool BuildInterrim(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config)
613 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
615 ide.outputView.buildBox.Logf($"Building project %s using the %s configuration...\n", prj.name, GetConfigName(config));
616 return Build(prj, buildType, compiler, config);
621 bool Build(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config)
627 for(document = master.firstChild; document; document = document.next)
629 if(document.modifiedDocument)
631 ProjectNode node = GetNodeFromWindow(document, prj);
632 if(node && !document.MenuFileSave(null, 0))
641 DirExpression targetDir = prj.GetTargetDir(compiler, config);
643 // TOFIX: DebugStop is being abused and backfiring on us.
644 // It's supposed to be the 'Debug/Stop' item, not unloading executable or anything else
646 // configIsInDebugSession seems to be used for two OPPOSITE things:
647 // If we're debugging another config, we need to unload the executable!
648 // In building, we want to stop if we're debugging the 'same' executable
649 if(buildType != run) ///* && prj == project*/ && prj.configIsInDebugSession)
651 if(buildType == start || buildType == restart)
653 if(ide.debugger && ide.debugger.isPrepared)
660 if(ide.project == prj && ide.debugger && ide.debugger.prjConfig == config && ide.debugger.isPrepared)
667 // TODO: Disabled until problems fixed... is it fixed?
668 if(buildType == rebuild || (config && config.compilingModified))
669 prj.Clean(compiler, config);
672 if(buildType == relink || (config && config.linkingModified))
674 char target[MAX_LOCATION];
676 strcpy(target, prj.topNode.path);
677 PathCat(target, targetDir.dir);
678 prj.CatTargetFileName(target, compiler, config);
679 if(FileExists(target))
682 if(config && config.symbolGenModified)
684 DirExpression objDir = prj.GetObjDir(compiler, config);
685 char fileName[MAX_LOCATION];
686 char moduleName[MAX_FILENAME];
687 strcpy(fileName, prj.topNode.path);
688 PathCatSlash(fileName, objDir.dir);
689 strcpy(moduleName, prj.moduleName);
690 strcat(moduleName, ".main.ec");
691 PathCatSlash(fileName, moduleName);
692 if(FileExists(fileName))
693 DeleteFile(fileName);
694 ChangeExtension(fileName, "c", fileName);
695 if(FileExists(fileName))
696 DeleteFile(fileName);
697 ChangeExtension(fileName, "o", fileName);
698 if(FileExists(fileName))
699 DeleteFile(fileName);
704 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
705 ide.AdjustBuildMenus();
706 ide.AdjustDebugMenus();
708 result = prj.Build(buildType == run, null, compiler, config);
712 config.compilingModified = false;
713 if(!ide.ShouldStopBuild())
714 config.linkingModified = false;
716 config.symbolGenModified = false;
718 buildInProgress = none;
719 ide.AdjustBuildMenus();
720 ide.AdjustDebugMenus();
722 ide.workspace.modified = true;
729 // ((( USER ACTIONS )))
731 // ************************************************************************
732 // *** Methods below should atomically start a process, and as such ***
733 // *** they can query compiler and config directly from ide and project ***
734 // *** but ONLY ONCE!!! ***
735 // ************************************************************************
737 bool ProjectBuild(MenuItem selection, Modifiers mods)
739 Project prj = project;
740 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
741 ProjectConfig config = prj.config;
742 if(selection || !ide.activeClient || activeClient == this)
744 DataRow row = fileList.currentRow;
745 ProjectNode node = row ? (ProjectNode)row.tag : null;
746 if(node) prj = node.project;
748 // Added this code here until dependencies work:
749 else //if(ide.activeClient)
751 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
755 if(/*prj != project || */!prj.GetConfigIsInDebugSession(config) || !ide.DontTerminateDebugSession($"Project Build"))
757 BuildInterrim(prj, build, compiler, config);
763 bool ProjectLink(MenuItem selection, Modifiers mods)
765 Project prj = project;
766 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
767 ProjectConfig config;
768 if(selection || !ide.activeClient || activeClient == this)
770 DataRow row = fileList.currentRow;
771 ProjectNode node = row ? (ProjectNode)row.tag : null;
772 if(node) prj = node.project;
774 // Added this code here until dependencies work:
775 else //if(ide.activeClient)
777 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
782 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
784 ide.outputView.buildBox.Logf("Relinking project %s using the %s configuration...\n", prj.name, GetConfigName(config));
786 config.linkingModified = true;
787 Build(prj, relink, compiler, config);
793 bool ProjectRebuild(MenuItem selection, Modifiers mods)
795 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
796 Project prj = GetSelectedProject((bool)selection);
797 ProjectConfig config = prj.config;
798 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
800 ide.outputView.buildBox.Logf($"Rebuilding project %s using the %s configuration...\n", prj.name, GetConfigName(config));
803 config.compilingModified = true;
804 config.makingModified = true;
805 }*/ // -- should this still be used depite the new solution of BuildType?
806 Build(prj, rebuild, compiler, config);
812 bool ProjectClean(MenuItem selection, Modifiers mods)
814 Project prj = GetSelectedProject((bool)selection);
815 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
816 ProjectConfig config = prj.config;
817 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
819 ide.outputView.buildBox.Logf($"Cleaning project %s using the %s configuration...\n", prj.name, GetConfigName(config));
821 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
822 ide.AdjustBuildMenus();
824 prj.Clean(compiler, config);
825 buildInProgress = none;
826 ide.AdjustBuildMenus();
832 bool ProjectRegenerate(MenuItem selection, Modifiers mods)
834 Project prj = project;
835 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
836 if(selection || !ide.activeClient || activeClient == this)
838 DataRow row = fileList.currentRow;
839 ProjectNode node = row ? (ProjectNode)row.tag : null;
843 // Added this code here until dependencies work:
844 else //if(ide.activeClient)
846 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
851 ProjectPrepareMakefile(prj, force, true, true, compiler, prj.config);
856 void Compile(ProjectNode node)
858 char fileName[MAX_LOCATION];
859 char extension[MAX_EXTENSION];
861 Project prj = node.project;
862 ProjectConfig config = prj.config;
863 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
864 DirExpression objDir = prj.GetObjDir(compiler, config);
866 strcpy(fileName, prj.topNode.path);
867 PathCatSlash(fileName, objDir.dir);
868 PathCatSlash(fileName, node.name);
869 StripExtension(fileName);
870 strcat(fileName, ".o");
871 if(FileExists(fileName))
872 DeleteFile(fileName);
874 GetExtension(node.name, extension);
875 if(!strcmp(extension, "ec"))
877 // Delete generated C file
878 strcpy(fileName, prj.topNode.path);
879 PathCat(fileName, objDir.dir);
880 PathCat(fileName, node.name);
881 StripExtension(fileName);
882 strcat(fileName, ".c");
883 if(FileExists(fileName))
884 DeleteFile(fileName);
886 // Delete symbol file
887 strcpy(fileName, prj.topNode.path);
888 PathCat(fileName, node.path);
889 PathCat(fileName, node.name);
890 StripExtension(fileName);
891 strcat(fileName, ".sym");
892 if(FileExists(fileName))
893 DeleteFile(fileName);
898 // Check if we have to save
899 strcpy(fileName, prj.topNode.path);
900 PathCatSlash(fileName, node.path);
901 PathCatSlash(fileName, node.name);
902 for(document = ide.firstChild; document; document = document.next)
904 if(document.modifiedDocument)
906 char documentFileName[MAX_LOCATION];
907 if(!fstrcmp(GetSlashPathBuffer(documentFileName, document.fileName), fileName))
908 if(!document.MenuFileSave(null, 0))
913 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
915 if(!node.GetIsExcluded(config))
917 buildInProgress = compilingFile;
918 ide.AdjustBuildMenus();
920 //ide.outputView.ShowClearSelectTab(build);
921 // this stuff doesn't even appear
922 //ide.outputView.buildBox.Logf("%s Compiler\n", compiler.name);
924 ide.outputView.buildBox.Logf($"Compiling single file %s in project %s using the %s configuration...\n", node.name, prj.name, config.name);
926 ide.outputView.buildBox.Logf($"Compiling single file %s in project %s...\n", node.name, prj.name);
928 prj.Compile(node, compiler, config);
929 buildInProgress = none;
930 ide.AdjustBuildMenus();
933 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
939 bool ProjectNewFile(MenuItem selection, Modifiers mods)
941 DataRow row = fileList.currentRow;
945 char filePath[MAX_LOCATION];
946 ProjectNode parentNode = (ProjectNode)row.tag;
947 ProjectNode n, fileNode;
948 parentNode.GetFileSysMatchingPath(filePath);
949 MakePathRelative(filePath, parentNode.project.topNode.path, filePath);
950 for(n = parentNode; n && n != parentNode.project.resNode; n = n.parent);
951 sprintf(fileName, $"Untitled %d", documentID);
952 fileNode = AddFile(parentNode, fileName, (bool)n, true);
953 fileNode.path = CopyUnixPath(filePath);
956 NodeProperties nodeProperties
959 position = { position.x + 100, position.y + 100 };
963 nodeProperties.Create(); // not modal?
969 bool ProjectNewFolder(MenuItem selection, Modifiers mods)
971 DataRow row = fileList.currentRow;
974 ProjectNode parentNode = (ProjectNode)row.tag;
975 NewFolder(parentNode, null, true);
980 bool ResourcesAddFiles(MenuItem selection, Modifiers mods)
986 bool ProjectAddFiles(MenuItem selection, Modifiers mods)
992 bool ProjectImportFolder(MenuItem selection, Modifiers mods)
994 DataRow row = fileList.currentRow;
997 ProjectNode toNode = (ProjectNode)row.tag;
998 ImportFolder(toNode);
1003 bool ProjectAddNewForm(MenuItem selection, Modifiers mods)
1005 CodeEditor codeEditor = CreateNew("Form", "form", "Window", null);
1006 codeEditor.EnsureUpToDate();
1010 bool ProjectAddNewGraph(MenuItem selection, Modifiers mods)
1012 CodeEditor codeEditor = CreateNew("Graph", "graph", "Block", null);
1014 codeEditor.EnsureUpToDate();
1018 bool ProjectRemove(MenuItem selection, Modifiers mods)
1020 DataRow row = fileList.currentRow;
1023 ProjectNode node = (ProjectNode)row.tag;
1024 if(node.type == project)
1025 RemoveSelectedNodes();
1030 bool ProjectUpdateMakefileForAllConfigs(Project project, bool cleanLog, bool displayCompiler)
1032 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1033 ShowOutputBuildLog(cleanLog);
1036 DisplayCompiler(compiler, false);
1038 for(config : project.configurations)
1040 ProjectPrepareMakefile(project, forceExists, false, false,
1048 bool MenuConfig(MenuItem selection, Modifiers mods)
1050 if(ProjectActiveConfig { parent = parent.parent, master = parent, project = project }.Modal() == ok)
1055 bool MenuCompiler(MenuItem selection, Modifiers mods)
1057 ActiveCompilerDialog compilerDialog
1059 parent = parent.parent, master = parent;
1060 ideSettings = ideSettings, workspaceActiveCompiler = ide.workspace.compiler;
1062 incref compilerDialog;
1063 if(compilerDialog.Modal() == ok && strcmp(compilerDialog.workspaceActiveCompiler, ide.workspace.compiler))
1065 ide.workspace.compiler = compilerDialog.workspaceActiveCompiler;
1066 for(prj : ide.workspace.projects)
1067 ide.projectView.ProjectUpdateMakefileForAllConfigs(prj, true, true);
1069 delete compilerDialog;
1073 bool MenuSettings(MenuItem selection, Modifiers mods)
1075 ProjectNode node = GetSelectedNode(true);
1076 Project prj = node ? node.project : project;
1077 projectSettingsDialog = ProjectSettings { parent = parent.parent, master = parent, project = prj, projectNode = node };
1078 projectSettingsDialog.Modal();
1085 bool FileProperties(MenuItem selection, Modifiers mods)
1087 DataRow row = fileList.currentRow;
1090 ProjectNode node = (ProjectNode)row.tag;
1091 NodeProperties { parent = parent, master = this, node = node,
1092 position = { position.x + 100, position.y + 100 } }.Create();
1097 bool FileOpenFile(MenuItem selection, Modifiers mods)
1099 OpenSelectedNodes();
1103 bool FileRemoveFile(MenuItem selection, Modifiers mods)
1105 RemoveSelectedNodes();
1109 bool FileCompile(MenuItem selection, Modifiers mods)
1111 DataRow row = fileList.currentRow;
1114 ProjectNode node = (ProjectNode)row.tag;
1120 Project GetSelectedProject(bool useSelection)
1122 Project prj = project;
1125 DataRow row = fileList.currentRow;
1126 ProjectNode node = row ? (ProjectNode)row.tag : null;
1133 ProjectNode GetSelectedNode(bool useSelection)
1135 ProjectNode node = null;
1138 DataRow row = fileList.currentRow;
1140 node = (ProjectNode)row.tag;
1145 bool MenuBrowseFolder(MenuItem selection, Modifiers mods)
1147 char folder[MAX_LOCATION];
1149 ProjectNode node = GetSelectedNode(true);
1151 node = project.topNode;
1154 strcpy(folder, prj.topNode.path);
1155 if(node != prj.topNode)
1156 PathCatSlash(folder, node.path);
1160 bool Run(MenuItem selection, Modifiers mods)
1162 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1163 ProjectConfig config = project.config;
1164 String args = new char[maxPathLen];
1166 if(ide.workspace.commandLineArgs)
1167 //ide.debugger.GetCommandLineArgs(args);
1168 strcpy(args, ide.workspace.commandLineArgs);
1169 if(ide.debugger.isActive)
1170 project.Run(args, compiler, config);
1171 /*else if(config.targetType == sharedLibrary || config.targetType == staticLibrary)
1172 MessageBox { master = ide, type = ok, text = "Run", contents = "Shared and static libraries cannot be run like executables." }.Modal();*/
1173 else if(BuildInterrim(project, run, compiler, config))
1174 project.Run(args, compiler, config);
1182 bool result = false;
1183 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1184 ProjectConfig config = project.config;
1185 TargetTypes targetType = project.GetTargetType(config);
1186 if(targetType == sharedLibrary || targetType == staticLibrary)
1187 MessageBox { master = ide, type = ok, text = $"Run", contents = $"Shared and static libraries cannot be run like executables." }.Modal();
1188 else if(project.GetCompress(config))
1189 MessageBox { master = ide, text = $"Starting Debug", contents = $"Debugging compressed applications is not supported\n" }.Modal();
1190 else if(project.GetDebug(config) ||
1191 MessageBox { master = ide, type = okCancel, text = $"Starting Debug", contents = $"Attempting to debug non-debug configuration\nProceed anyways?" }.Modal() == ok)
1193 if(/*!IsProjectModified() ||*/ BuildInterrim(project, start, compiler, config))
1195 if(compiler.type.isVC)
1197 //bool result = false;
1198 char oldwd[MAX_LOCATION];
1199 PathBackup pathBackup { };
1200 char command[MAX_LOCATION];
1202 ide.SetPath(false, compiler, config);
1204 GetWorkingDir(oldwd, sizeof(oldwd));
1205 ChangeWorkingDir(project.topNode.path);
1207 sprintf(command, "%s /useenv %s.sln /projectconfig \"%s|Win32\" /command \"%s\"" , "devenv", project.name, config.name, "Debug.Start");
1208 //ide.outputView.buildBox.Logf("command: %s\n", command);
1210 ChangeWorkingDir(oldwd);
1216 ide.debugger.Start(compiler, config);
1225 void GoToError(const char * line)
1229 while(isspace(*line)) line++;
1230 colon = strstr(line, ":");
1235 bool lookForLineNumber = true;
1237 // deal with linking error
1238 if(colon && colon[1] == ' ')
1240 colon = strstr(colon + 1, ":");
1241 if(colon && !colon[1])
1243 colon = strstr(line, ":");
1244 lookForLineNumber = false;
1246 else if(colon && !isdigit(colon[1]))
1249 colon = strstr(line, ":");
1252 // Don't be mistaken by the drive letter colon
1253 if(colon && (colon[1] == '/' || colon[1] == '\\'))
1254 colon = strstr(colon + 1, ":");
1255 if(colon && lookForLineNumber)
1259 char * par = RSearchString(line, "(", colon - line, true, false);
1260 if(par && strstr(par, ")"))
1262 else if((colon+1)[0] == ' ')
1264 // NOTE: This is the same thing as saying 'colon = line'
1265 for( ; colon != line; colon--)
1269 lineNumber = atoi(colon + 1);
1271 comma = strchr(colon, ',');
1273 col = atoi(comma+1);
1275 comma = strchr(colon+1, ':');
1277 col = atoi(comma+1);
1281 char moduleName[MAX_LOCATION], filePath[MAX_LOCATION];
1286 strncpy(moduleName, line, colon - line);
1287 moduleName[colon - line] = '\0';
1290 strcpy(moduleName, line);
1292 // Remove stuff in brackets
1294 bracket = strstr(moduleName, "(");
1295 if(bracket) *bracket = '\0';
1297 MakeSlashPath(moduleName);
1301 // Check if it's one of our modules
1302 ProjectNode node = project.topNode.Find(moduleName, false);
1305 strcpy(moduleName, node.path);
1306 PathCatSlash(moduleName, node.name);
1309 moduleName[0] = '\0';
1313 CodeEditor codeEditor;
1314 strcpy(filePath, project.topNode.path);
1315 PathCatSlash(filePath, moduleName);
1317 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
1320 char name[MAX_LOCATION];
1321 // TOFIX: Improve on this, don't use only filename, make a function
1322 if(ide && ide.workspace)
1324 for(prj : ide.workspace.projects)
1326 if(prj.topNode.FindWithPath(moduleName, false))
1328 strcpy(filePath, prj.topNode.path);
1329 PathCatSlash(filePath, moduleName);
1330 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
1337 if(codeEditor && lineNumber)
1339 EditBox editBox = codeEditor.editBox;
1340 editBox.GoToLineNum(lineNumber - 1);
1341 editBox.GoToPosition(editBox.line, lineNumber - 1, col ? (col - 1) : 0);
1348 bool OpenNode(ProjectNode node)
1350 char filePath[MAX_LOCATION];
1351 node.GetFullFilePath(filePath);
1352 return ide.OpenFile(filePath, normal, true/*false Why was it opening hidden?*/, null, something, normal) ? true : false;
1355 void AddNode(ProjectNode node, DataRow addTo)
1357 DataRow row = addTo ? addTo.AddRow() : fileList.AddRow();
1359 row.tag = (int)node;
1362 if(node.type == resources)
1365 row.SetData(null, node);
1367 if(node.files && node.files.first && node.parent &&
1368 !(!node.parent.parent &&
1369 (!strcmpi(node.name, "notes") || !strcmpi(node.name, "sources") ||
1370 !strcmpi(node.name, "src") || !strcmpi(node.name, "tools"))))
1371 row.collapsed = true;
1372 else if(node.type == folder)
1373 node.icon = openFolder;
1377 for(child : node.files)
1378 AddNode(child, row);
1382 void DeleteNode(ProjectNode projectNode)
1384 if(projectNode.files)
1387 while(child = projectNode.files.first)
1390 fileList.DeleteRow(projectNode.row);
1391 projectNode.Delete();
1394 bool ProjectSave(MenuItem selection, Modifiers mods)
1396 DataRow row = fileList.currentRow;
1397 ProjectNode node = row ? (ProjectNode)row.tag : null;
1398 Project prj = node ? node.project : null;
1401 if(prj.Save(prj.filePath))
1403 // ProjectUpdateMakefileForAllConfigs(prj, true, true);
1404 prj.topNode.modified = false;
1406 for(p : ide.workspace.projects)
1408 if(p.topNode.modified)
1415 modifiedDocument = false;
1422 bool ShowOutputBuildLog(bool cleanLog)
1424 OutputView output = ide.outputView;
1426 output.ShowClearSelectTab(build);
1429 output.SelectTab(build);
1436 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1437 ProjectConfig config = project.config;
1439 bool result = false;
1440 if(/*!IsProjectModified() ||*/ BuildInterrim(project, restart, compiler, config))
1442 // For Restart, compiler and config will only be used if for
1443 // whatever reason (if at all possible) the Debugger is in a
1444 // 'terminated' or 'none' state
1445 ide.debugger.Restart(compiler, config);
1455 ide.debugger.Resume();
1461 ide.debugger.Break();
1467 ide.debugger.Stop();
1471 bool DebugStepInto()
1473 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1474 ProjectConfig config = project.config;
1476 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config)))
1477 ide.debugger.StepInto(compiler, config);
1482 bool DebugStepOver(bool skip)
1484 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1485 ProjectConfig config = project.config;
1487 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config)))
1488 ide.debugger.StepOver(compiler, config, skip);
1494 bool DebugStepOut(bool skip)
1496 ide.debugger.StepOut(skip);
1500 void ImportFolder(ProjectNode toNode)
1504 //bool isFolder = toNode.type == folder;
1505 //bool isRes = toNode.isInResources;
1507 FileDialog fileDialog = importFileDialog;
1508 fileDialog.master = parent;
1509 if(fileDialog.Modal() == ok)
1511 ImportFolderFSI fsi { projectView = this };
1512 fsi.stack.Add(toNode);
1513 fsi.Iterate(fileDialog.filePath);
1519 ProjectNode NewFolder(ProjectNode parentNode, char * name, bool showProperties)
1523 ProjectNode folderNode;
1524 Project prj = parentNode.project;
1526 ProjectNode after = null;
1527 for(node : parentNode.files)
1529 if(node.type != folder)
1535 folderNode = parentNode.Add(prj, name, after, folder, folder, true);
1538 for(c = 0; c < 100; c++)
1541 sprintf(string, c ? "New Folder (%d)" : "New Folder", c);
1542 if((folderNode = parentNode.Add(prj, string, after, folder, folder, true)))
1549 NodeProperties nodeProperties;
1552 modifiedDocument = true;
1553 prj.topNode.modified = true;
1556 folderNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
1557 folderNode.row.tag = (int)folderNode;
1559 folderNode.row.SetData(null, folderNode);
1560 fileList.currentRow = folderNode.row;
1564 nodeProperties = NodeProperties
1566 parent, this, mode = newFolder, node = folderNode;
1567 position = { position.x + 100, position.y + 100 };
1569 nodeProperties.Create(); // Modal?
1577 void AddFiles(bool resources)
1579 FileDialog fileDialog = (!resources) ? this.fileDialog : resourceFileDialog;
1580 fileDialog.type = multiOpen;
1581 fileDialog.text = !resources ? $"Add Files to Project" : $"Add Resources to Project";
1582 fileDialog.master = parent;
1584 if(fileDialog.Modal() == ok)
1587 DataRow row = fileList.currentRow;
1588 ProjectNode parentNode = (ProjectNode)row.tag;
1589 bool addFailed = false;
1590 int numSelections = fileDialog.numSelections;
1591 char ** multiFilePaths = fileDialog.multiFilePaths;
1593 Array<String> nameConflictFiles { };
1595 for(c = 0; c < numSelections; c++)
1597 char * filePath = multiFilePaths[c];
1598 FileAttribs exists = FileExists(filePath);
1599 bool addThisFile = true;
1601 if(exists.isDirectory)
1602 addThisFile = false;
1605 if(MessageBox { master = ide, type = yesNo, text = filePath,
1606 contents = $"File doesn't exist. Create?" }.Modal() == yes)
1608 File f = FileOpen(filePath, write);
1616 MessageBox { master = ide, type = ok, text = filePath,
1617 contents = $"Couldn't create file."}.Modal();
1618 addThisFile = false;
1625 /*addFailed = */if(!AddFile(parentNode, filePath, resources, false))//;
1627 nameConflictFiles.Add(CopyString(filePath));
1635 char * part1 = $"The following file";
1636 char * opt1 = $" was ";
1637 char * opt2 = $"s were ";
1638 char * part2 = $"not added because of identical file name conflict within the project.\n\n";
1640 len += strlen(part1);
1641 len += strlen(part2);
1642 len += nameConflictFiles.count > 1 ? strlen(opt2) : strlen(opt1);
1643 for(s : nameConflictFiles)
1644 len += strlen(s) + 1;
1645 message = new char[len + 1];
1646 strcpy(message, part1);
1647 strcat(message, nameConflictFiles.count > 1 ? opt2 : opt1);
1648 strcat(message, part2);
1649 for(s : nameConflictFiles)
1652 strcat(message, "\n");
1654 MessageBox { master = ide, type = ok, text = $"Name Conflict",
1655 contents = message }.Modal();
1658 nameConflictFiles.Free();
1659 delete nameConflictFiles;
1663 ProjectNode AddFile(ProjectNode parentNode, char * filePath, bool resources, bool isTemporary)
1665 ProjectNode result = null;
1666 ProjectNode after = null;
1667 for(node : parentNode.files)
1669 if(node.type != folder && node.type != file && node.type)
1674 result = parentNode.Add(parentNode.project, filePath, after, file, NodeIcons::SelectFileIcon(filePath), !resources);
1680 modifiedDocument = true;
1681 parentNode.project.topNode.modified = true;
1682 parentNode.project.ModifiedAllConfigs(true, false, true, true);
1685 result.row = parentNode.row.AddRowAfter(after ? after.row : null);
1686 result.row.tag = (int)result;
1687 result.row.SetData(null, result);
1692 CodeEditor CreateNew(char * upper, char * lower, char * base, char * className)
1694 CodeEditor codeEditor = null;
1695 ProjectNode projectNode;
1696 ProjectNode after = null;
1697 DataRow row = fileList.currentRow;
1698 ProjectNode parentNode;
1701 if(!row) row = project.topNode.row;
1703 parentNode = (ProjectNode)row.tag;
1705 for(node : parentNode.files)
1707 if(node.type != folder && node.type != file && node.type)
1711 for(c = 1; c < 100; c++)
1714 sprintf(string, c ? "%s%d.ec" : "%s.ec", lower, c);
1715 if((projectNode = parentNode.Add(project, string, after, file, genFile, true)))
1721 char filePath[MAX_LOCATION];
1723 modifiedDocument = true;
1724 project.topNode.modified = true;
1726 project.ModifiedAllConfigs(true, false, false, true);
1727 projectNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
1728 projectNode.row.tag =(int)projectNode;
1730 projectNode.row.SetData(null, projectNode);
1731 fileList.currentRow = projectNode.row;
1733 strcpy(filePath, project.topNode.path);
1734 PathCat(filePath, projectNode.path);
1735 PathCat(filePath, projectNode.name);
1737 codeEditor = (CodeEditor)ide.FindWindow(filePath);
1740 Class baseClass = eSystem_FindClass(__thisModule, base);
1741 subclass(ClassDesignerBase) designerClass = eClass_GetDesigner(baseClass);
1744 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal);
1745 strcpy(name, projectNode.name);
1746 sprintf(name, "%s%d", upper, c);
1748 strcpy(className, name);
1750 designerClass.CreateNew(codeEditor.editBox, codeEditor.clientSize, name, base);
1752 //codeEditor.modifiedDocument = false;
1753 //codeEditor.designer.modifiedDocument = false;
1755 //Code_EnsureUpToDate(codeEditor);
1758 else // TODO: fix no symbols generated when ommiting {} for following else
1760 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal);
1764 codeEditor.ViewDesigner();
1765 codeEditor.codeModified = true;
1772 // Returns true if we opened something
1773 bool OpenSelectedNodes()
1775 bool result = false;
1779 fileList.GetMultiSelection(selection);
1780 for(item = selection.first; item; item = item.next)
1782 DataRow row = item.data;
1783 ProjectNode node = (ProjectNode)row.tag;
1784 if(node.type == file)
1791 selection.Free(null);
1795 void RemoveSelectedNodes()
1800 fileList.GetMultiSelection(selection);
1802 // Remove children of parents we're deleting
1803 for(item = selection.first; item; item = next)
1806 DataRow row = item.data;
1807 ProjectNode n, node = (ProjectNode)row.tag;
1808 bool remove = false;
1811 for(i = selection.first; i && !remove; i = i.next)
1813 ProjectNode iNode = (ProjectNode)((DataRow)i.data).tag;
1814 for(n = node.parent; n; n = n.parent)
1824 selection.Delete(item);
1827 for(item = selection.first; item; item = item.next)
1829 DataRow row = item.data;
1830 ProjectNode node = (ProjectNode)row.tag;
1831 ProjectNode resNode;
1832 for(resNode = node.parent; resNode; resNode = resNode.parent)
1833 if(resNode.type == resources)
1835 if(node.type == file)
1837 Project prj = node.project;
1839 modifiedDocument = true;
1840 prj.topNode.modified = true;
1842 prj.ModifiedAllConfigs(true, false, true, true);
1844 else if(node.type == folder)
1847 sprintf(message, $"Are you sure you want to remove the folder \"%s\"\n"
1848 "and all of its contents from the project?", node.name);
1849 if(MessageBox { master = ide, type = yesNo, text = $"Delete Folder", contents = message }.Modal() == yes)
1851 Project prj = node.project;
1852 if(node.containsFile)
1853 prj.ModifiedAllConfigs(true, false, true, true);
1855 modifiedDocument = true;
1856 prj.topNode.modified = true;
1859 else if(node.type == project && node != project.topNode && !buildInProgress)
1863 for(p : workspace.projects)
1865 if(p.topNode == node)
1871 sprintf(message, $"Are you sure you want to remove the \"%s\" project\n" "from this workspace?", node.name);
1872 if(MessageBox { master = ide, type = yesNo, text = $"Remove Project", contents = message }.Modal() == yes)
1877 workspace.RemoveProject(prj);
1878 //modifiedDocument = true; // when project view is a workspace view
1882 selection.Free(null);