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 { $"Translations (*.mo)", "mo" },
49 { $"All files", null }
52 static Array<FileFilter> projectFilters
54 { $"Project Files (*.epj)", ProjectExtension },
55 { $"Workspace Files (*.ews)", WorkspaceExtension }
58 static Array<FileType> projectTypes
60 { $"Ecere IDE Project", ProjectExtension },
61 { $"Ecere IDE Workspace", WorkspaceExtension }
64 static char * iconNames[] =
66 "<:ecere>mimeTypes/file.png", /*genFile*/
67 "<:ecere>mimeTypes/textEcereWorkspace.png", /*ewsFile*/
68 "<:ecere>mimeTypes/textEcereProject.png", /*epjFile*/
69 "<:ecere>places/folder.png", /*folder*/
70 "<:ecere>status/folderOpen.png", /*openFolder*/
71 "<:ecere>mimeTypes/textEcereSource.png", /*ecFile*/
72 "<:ecere>mimeTypes/textEcereHeader.png", /*ehFile*/
73 "<:ecere>mimeTypes/textCSource.png", /*cFile*/
74 "<:ecere>mimeTypes/textCHeader.png", /*hFile*/
75 "<:ecere>mimeTypes/textC++Source.png", /*cppFile*/
76 "<:ecere>mimeTypes/textC++Header.png", /*hppFile*/
77 "<:ecere>mimeTypes/text.png", /*textFile*/
78 "<:ecere>mimeTypes/textHyperTextMarkup.png", /*webFile*/
79 "<:ecere>mimeTypes/image.png", /*pictureFile*/
80 "<:ecere>status/audioVolumeHigh.png", /*soundFile*/
81 "<:ecere>mimeTypes/package.png", /*archiveFile*/
82 "<:ecere>mimeTypes/packageSoftware.png", /*packageFile*/
83 "<:ecere>mimeTypes/packageOpticalDisc.png", /*opticalMediaImageFile*/
84 "<:ecere>mimeTypes/file.png" /*mFile*/ //TODO: create icon for mfile
87 enum PrepareMakefileMethod { normal, force, forceExists };
89 enum BuildType { build, rebuild, relink, run, start, restart, clean };
92 none, buildingMainProject, buildingSecondaryProject, compilingFile;
94 property bool { get { return this != none; } }
95 //property bool actualBuild { get { return this == buildingMainProject || this == buildingSecondaryProject; } }
98 class ProjectView : Window
101 //hasMinimize = true;
103 borderStyle = sizable;
104 hasHorzScroll = true;
105 hasVertScroll = true;
108 anchor = Anchor { left = 0, top = 0, bottom = 0 };
111 //hasMinimize = true;
112 saveDialog = projectFileDialog;
115 BuildState buildInProgress;
116 BitmapResource icons[NodeIcons];
119 property Workspace workspace
125 for(prj : workspace.projects)
127 DeleteNode(prj.topNode);
129 workspace.projects.Free();
130 ide.debugger.CleanUp();
135 fileDialog.currentDirectory = workspace.workspaceDir;
136 resourceFileDialog.currentDirectory = workspace.workspaceDir;
137 for(prj : workspace.projects)
138 AddNode(prj.topNode, null);
139 ide.statusBar.text = $"Generating Makefile & Dependencies...";
141 for(prj : workspace.projects)
142 prj.ModifiedAllConfigs(true, false, false, false);
143 ide.statusBar.text = $"Initializing Debugger"; app.UpdateDisplay();
144 ide.statusBar.text = null;
148 get { return workspace; }
151 bool drawingInProjectSettingsDialog;
152 bool drawingInProjectSettingsDialogHeader;
153 ProjectSettings projectSettingsDialog;
161 for(c = 0; c < NodeIcons::enumSize; c++)
163 icons[c] = BitmapResource { iconNames[c], alphaBlend = true };
164 AddResource(icons[c]);
166 fileList.AddField(DataField { dataType = class(ProjectNode), freeData = false, userData = this });
172 ide.DestroyTemporaryProjectDir();
182 multiSelect = true, fullRowSelect = false, hasVertScroll = true, hasHorzScroll = true;
183 borderStyle = deep, parent = this, collapseControl = true, treeBranches = true;
184 anchor = Anchor { left = 0, right = 0, top = 0 , bottom = 0 };
186 background = projectViewBackground;
187 foreground = projectViewText;
188 selectionColor = selectionColor, selectionText = selectionText;
189 stippleColor = skyBlue;
191 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
193 if(!active) Update(null);
194 return ListBox::OnActivate(active, previous, goOnWithActivation, direct);
197 bool NotifyDoubleClick(ListBox listBox, int x, int y, Modifiers mods)
199 // Prevent the double click from reactivating the project view (returns false if we opened something)
200 return !OpenSelectedNodes();
203 bool NotifyRightClick(ListBox listBox, int x, int y, Modifiers mods)
205 DataRow row = listBox.currentRow;
208 ProjectNode node = (ProjectNode)row.tag;
209 if(node.type == NodeTypes::project || node.type == resources || node.type == file || node.type == folder)
211 bool buildMenuUnavailable = buildInProgress;
212 Menu popupContent { };
214 if(node.type == NodeTypes::project)
216 //if(node == ((Project)workspace.projects.first).topNode)
218 MenuItem { popupContent, $"Build", b, NotifySelect = ProjectBuild }.disabled = buildMenuUnavailable;
219 MenuItem { popupContent, $"Relink", l, NotifySelect = ProjectLink }.disabled = buildMenuUnavailable;
220 MenuItem { popupContent, $"Rebuild", r, NotifySelect = ProjectRebuild }.disabled = buildMenuUnavailable;
221 MenuItem { popupContent, $"Clean", c, NotifySelect = ProjectClean }.disabled = buildMenuUnavailable;
222 MenuItem { popupContent, $"Real Clean", d, NotifySelect = ProjectRealClean }.disabled = buildMenuUnavailable;
223 MenuItem { popupContent, $"Regenerate Makefile", m, NotifySelect = ProjectRegenerate }.disabled = buildMenuUnavailable;
224 MenuDivider { popupContent };
226 MenuItem { popupContent, $"New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
227 MenuItem { popupContent, $"New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
228 MenuItem { popupContent, $"Import Folder...", i, NotifySelect = ProjectImportFolder };
229 MenuItem { popupContent, $"Add Files to Project...", f, NotifySelect = ProjectAddFiles };
230 MenuDivider { popupContent };
231 MenuItem { popupContent, $"Add New Form...", o, NotifySelect = ProjectAddNewForm };
232 // MenuItem { popupContent, "Add New Behavior Graph...", g, NotifySelect = ProjectAddNewGraph };
233 MenuDivider { popupContent };
234 if(node != ((Project)workspace.projects.first).topNode)
236 MenuItem { popupContent, $"Remove project from workspace", r, NotifySelect = ProjectRemove }.disabled = buildMenuUnavailable;
237 MenuDivider { popupContent };
239 MenuItem { popupContent, $"Active Configuration...", s, Key { f5, alt = true } , NotifySelect = MenuConfig };
240 MenuItem { popupContent, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
241 MenuDivider { popupContent };
242 MenuItem { popupContent, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
243 MenuDivider { popupContent };
244 MenuItem { popupContent, $"Save", v, Key { s, ctrl = true }, NotifySelect = ProjectSave }.disabled = !node.modified;
245 MenuDivider { popupContent };
246 MenuItem { popupContent, $"Properties...", p, Key { enter, alt = true }, NotifySelect = FileProperties };
248 else if(node.type == resources)
250 MenuItem { popupContent, $"New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
251 MenuItem { popupContent, $"New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
252 MenuItem { popupContent, $"Import Folder...", i, NotifySelect = ProjectImportFolder };
253 MenuItem { popupContent, $"Add Resources to Project...", f, NotifySelect = ResourcesAddFiles };
254 MenuItem { popupContent, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
255 MenuDivider { popupContent };
256 MenuItem { popupContent, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
257 MenuItem { popupContent, $"Properties...", p, Key { enter, alt = true }, NotifySelect = FileProperties };
259 else if(node.type == file)
261 MenuItem { popupContent, $"Open", o, NotifySelect = FileOpenFile };
262 MenuItem { popupContent, $"Compile", c, Key { f7, ctrl = true}, NotifySelect = FileCompile }.disabled = buildMenuUnavailable;
263 MenuDivider { popupContent };
264 MenuItem { popupContent, $"Remove", r, NotifySelect = FileRemoveFile };
265 MenuDivider { popupContent };
266 MenuItem { popupContent, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
267 MenuDivider { popupContent };
268 MenuItem { popupContent, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
269 MenuItem { popupContent, $"Properties..", p, Key { enter, alt = true }, NotifySelect = FileProperties };
271 else if(node.type == folder)
273 bool isInResources = node.isInResources;
275 MenuItem { popupContent, $"New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
276 MenuItem { popupContent, $"New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
277 MenuItem { popupContent, $"Import Folder...", i, NotifySelect = ProjectImportFolder };
280 MenuItem { popupContent, $"Add Resources to Folder...", f, NotifySelect = ResourcesAddFiles };
284 MenuItem { popupContent, $"Add Files to Folder...", f, NotifySelect = ProjectAddFiles };
288 MenuDivider { popupContent };
289 MenuItem { popupContent, $"Add New Form...", o, NotifySelect = ProjectAddNewForm };
290 MenuItem { popupContent, $"Add New Behavior Graph...", g, NotifySelect = ProjectAddNewGraph };
292 MenuDivider { popupContent };
293 MenuItem { popupContent, $"Remove", r, NotifySelect = FileRemoveFile };
294 MenuDivider { popupContent };
295 MenuItem { popupContent, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
296 MenuDivider { popupContent };
297 MenuItem { popupContent, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
298 MenuItem { popupContent, $"Properties...", p, Key { enter, alt = true }, NotifySelect = FileProperties };
303 master = this, menu = popupContent;
305 x + clientStart.x + absPosition.x - app.desktop.position.x,
306 y + clientStart.y + absPosition.y - app.desktop.position.y };
308 void NotifyDestroyed(Window window, DialogResult result)
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);
436 FileDialog resourceFileDialog
438 autoCreate = false, mayNotExist = true, filters = resourceFilters.array, sizeFilters = resourceFilters.count * sizeof(FileFilter);
441 Menu fileMenu { menu, $"File", f };
442 MenuItem { fileMenu, $"Save", s, Key { s, ctrl = true }, NotifySelect = MenuFileSave };
443 // MenuItem { fileMenu, "Save As...", a, NotifySelect = MenuFileSaveAs };
445 bool OnClose(bool parentClosing)
447 if(!parentClosing && visible)
459 //if(ide.findInFilesDialog && ide.findInFilesDialog.created && ide.findInFilesDialog.mode != directory)
460 // ide.findInFilesDialog.SearchStop();
462 ide.outputView.buildBox.Clear();
463 ide.outputView.debugBox.Clear();
464 //ide.outputView.findBox.Clear();
465 ide.callStackView.Clear();
466 ide.watchesView.Clear();
467 ide.threadsView.Clear();
468 ide.breakpointsView.Clear();
469 ide.outputView.ShowClearSelectTab(find); // why this?
472 bool OnSaveFile(char * fileName)
474 for(prj : ide.workspace.projects)
476 if(prj.topNode.modified && prj.Save(prj.filePath))
478 // ShowOutputBuildLog(true);
479 // DisplayCompiler(compiler, false);
480 // ProjectUpdateMakefileForAllConfigs(prj);
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 if((node = prj.topNode.FindByFullPath(documentFileName, false)))
519 // ((( UTILITY FUNCTIONS )))
521 // ************************************************************************
522 // *** These methods below are part of a sequence of events, and as ***
523 // *** such they must be passed the current compiler and project config ***
524 // ************************************************************************
525 bool DisplayCompiler(CompilerConfig compiler, bool cleanLog)
527 ide.outputView.buildBox.Logf($"%s Compiler\n", compiler ? compiler.name : $"{problem with compiler selection}");
530 bool ProjectPrepareForToolchain(Project project, PrepareMakefileMethod method, bool cleanLog, bool displayCompiler,
531 CompilerConfig compiler, ProjectConfig config)
534 char message[MAX_F_STRING];
535 LogBox logBox = ide.outputView.buildBox;
537 ShowOutputBuildLog(cleanLog);
540 DisplayCompiler(compiler, false);
542 ProjectPrepareMakefile(project, method, false, false, compiler, config);
546 bool ProjectPrepareMakefile(Project project, PrepareMakefileMethod method, bool cleanLog, bool displayCompiler,
547 CompilerConfig compiler, ProjectConfig config)
549 char makefilePath[MAX_LOCATION];
550 char makefileName[MAX_LOCATION];
552 LogBox logBox = ide.outputView.buildBox;
555 DisplayCompiler(compiler, false);
557 strcpy(makefilePath, project.topNode.path);
558 project.CatMakeFileName(makefileName, config);
559 PathCatSlash(makefilePath, makefileName);
561 exists = FileExists(makefilePath);
562 if((method == normal && (!exists || config.makingModified/*|| project.topNode.modified*/)) ||
563 (method == forceExists && exists) ||
564 method == force) // || config.makingModified || makefileDirty
568 ide.statusBar.text = $"Generating Makefile & Dependencies..."; // Dependencies?
571 if((method == normal && !exists) || (method == force && !exists))
572 action = $"Generating ";
573 else if(method == force)
574 action = $"Regenerating ";
575 else if(method == normal || method == forceExists)
576 action = $"Updating ";
580 reason = $"Makefile doesn't exist. ";
581 else if(project.topNode.modified)
582 reason = $"Project has been modified. ";
586 //logBox.Logf("%s\n", makefileName);
587 logBox.Logf($"%s - %s%smakefile for %s config...\n", makefileName, reason, action, GetConfigName(config));
589 project.GenerateCrossPlatformCf();
590 project.GenerateDebugCf(compiler);
591 project.GenerateCompilerMk(compiler);
592 project.GenerateMakefile(null, false, null, compiler, config);
594 ide.statusBar.text = null;
601 bool BuildInterrim(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config)
603 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
605 ide.outputView.buildBox.Logf($"Building project %s using the %s configuration...\n", prj.name, GetConfigName(config));
606 return Build(prj, buildType, compiler, config);
611 bool DebugStopForMake(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config)
614 // TOFIX: DebugStop is being abused and backfiring on us.
615 // It's supposed to be the 'Debug/Stop' item, not unloading executable or anything else
617 // configIsInDebugSession seems to be used for two OPPOSITE things:
618 // If we're debugging another config, we need to unload the executable!
619 // In building, we want to stop if we're debugging the 'same' executable
620 if(buildType != run) ///* && prj == project*/ && prj.configIsInDebugSession)
622 if(buildType == start || buildType == restart)
624 if(ide.debugger && ide.debugger.isPrepared)
625 result = DebugStop();
629 if(ide.project == prj && ide.debugger && ide.debugger.prjConfig == config && ide.debugger.isPrepared)
630 result = DebugStop();
636 bool Build(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config)
642 for(document = master.firstChild; document; document = document.next)
644 if(document.modifiedDocument)
646 ProjectNode node = GetNodeFromWindow(document, prj);
647 if(node && !document.MenuFileSave(null, 0))
656 DirExpression targetDir = prj.GetTargetDir(compiler, config);
658 DebugStopForMake(prj, buildType, compiler, config);
660 // TODO: Disabled until problems fixed... is it fixed?
661 if(buildType == rebuild || (config && config.compilingModified))
662 prj.Clean(compiler, config, false);
665 if(buildType == relink || (config && config.linkingModified))
667 char target[MAX_LOCATION];
669 strcpy(target, prj.topNode.path);
670 PathCat(target, targetDir.dir);
671 prj.CatTargetFileName(target, compiler, config);
672 if(FileExists(target))
675 if(config && config.symbolGenModified)
677 DirExpression objDir = prj.GetObjDir(compiler, config);
678 char fileName[MAX_LOCATION];
679 char moduleName[MAX_FILENAME];
680 strcpy(fileName, prj.topNode.path);
681 PathCatSlash(fileName, objDir.dir);
682 strcpy(moduleName, prj.moduleName);
683 strcat(moduleName, ".main.ec");
684 PathCatSlash(fileName, moduleName);
685 if(FileExists(fileName))
686 DeleteFile(fileName);
687 ChangeExtension(fileName, "c", fileName);
688 if(FileExists(fileName))
689 DeleteFile(fileName);
690 ChangeExtension(fileName, "o", fileName);
691 if(FileExists(fileName))
692 DeleteFile(fileName);
697 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
698 ide.AdjustBuildMenus();
699 ide.AdjustDebugMenus();
701 result = prj.Build(buildType == run, null, compiler, config);
705 config.compilingModified = false;
706 if(!ide.ShouldStopBuild())
707 config.linkingModified = false;
709 config.symbolGenModified = false;
711 buildInProgress = none;
712 ide.AdjustBuildMenus();
713 ide.AdjustDebugMenus();
715 ide.workspace.modified = true;
722 // ((( USER ACTIONS )))
724 // ************************************************************************
725 // *** Methods below should atomically start a process, and as such ***
726 // *** they can query compiler and config directly from ide and project ***
727 // *** but ONLY ONCE!!! ***
728 // ************************************************************************
730 bool ProjectBuild(MenuItem selection, Modifiers mods)
732 Project prj = project;
733 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
734 ProjectConfig config;
735 if(selection || !ide.activeClient)
737 DataRow row = fileList.currentRow;
738 ProjectNode node = row ? (ProjectNode)row.tag : null;
739 if(node) prj = node.project;
743 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
748 if(/*prj != project || */!prj.GetConfigIsInDebugSession(config) || !ide.DontTerminateDebugSession($"Project Build"))
750 BuildInterrim(prj, build, compiler, config);
756 bool ProjectLink(MenuItem selection, Modifiers mods)
758 Project prj = project;
759 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
760 ProjectConfig config;
761 if(selection || !ide.activeClient)
763 DataRow row = fileList.currentRow;
764 ProjectNode node = row ? (ProjectNode)row.tag : null;
765 if(node) prj = node.project;
769 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
774 if(!prj.GetConfigIsInDebugSession(config) ||
775 (!ide.DontTerminateDebugSession($"Project Link") && DebugStopForMake(prj, relink, compiler, config)))
777 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
779 ide.outputView.buildBox.Logf($"Relinking project %s using the %s configuration...\n", prj.name, GetConfigName(config));
781 config.linkingModified = true;
782 Build(prj, relink, compiler, config);
789 bool ProjectRebuild(MenuItem selection, Modifiers mods)
791 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
792 Project prj = project;
793 ProjectConfig config;
794 if(selection || !ide.activeClient)
796 DataRow row = fileList.currentRow;
797 ProjectNode node = row ? (ProjectNode)row.tag : null;
798 if(node) prj = node.project;
802 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
807 if(!prj.GetConfigIsInDebugSession(config) ||
808 (!ide.DontTerminateDebugSession($"Project Rebuild") && DebugStopForMake(prj, rebuild, compiler, config)))
810 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
812 ide.outputView.buildBox.Logf($"Rebuilding project %s using the %s configuration...\n", prj.name, GetConfigName(config));
815 config.compilingModified = true;
816 config.makingModified = true;
817 }*/ // -- should this still be used depite the new solution of BuildType?
818 Build(prj, rebuild, compiler, config);
825 bool ProjectClean(MenuItem selection, Modifiers mods)
827 Project prj = project;
828 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
829 ProjectConfig config;
830 if(selection || !ide.activeClient)
832 DataRow row = fileList.currentRow;
833 ProjectNode node = row ? (ProjectNode)row.tag : null;
834 if(node) prj = node.project;
838 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
843 if(!prj.GetConfigIsInDebugSession(config) ||
844 (!ide.DontTerminateDebugSession($"Project Clean") && DebugStopForMake(prj, clean, compiler, config)))
846 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
848 ide.outputView.buildBox.Logf($"Cleaning project %s using the %s configuration...\n", prj.name, GetConfigName(config));
850 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
851 ide.AdjustBuildMenus();
852 ide.AdjustDebugMenus();
854 prj.Clean(compiler, config, false);
855 buildInProgress = none;
856 ide.AdjustBuildMenus();
857 ide.AdjustDebugMenus();
864 bool ProjectRealClean(MenuItem selection, Modifiers mods)
866 Project prj = project;
867 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
868 ProjectConfig config;
869 if(selection || !ide.activeClient)
871 DataRow row = fileList.currentRow;
872 ProjectNode node = row ? (ProjectNode)row.tag : null;
873 if(node) prj = node.project;
877 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
882 if(!prj.GetConfigIsInDebugSession(config) ||
883 (!ide.DontTerminateDebugSession($"Project Real Clean") && DebugStopForMake(prj, clean, compiler, config)))
885 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
887 ide.outputView.buildBox.Logf($"Removing intermediate objects directory for project %s using the %s configuration...\n", prj.name, GetConfigName(config));
889 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
890 ide.AdjustBuildMenus();
891 ide.AdjustDebugMenus();
893 prj.Clean(compiler, config, true);
894 buildInProgress = none;
895 ide.AdjustBuildMenus();
896 ide.AdjustDebugMenus();
903 bool ProjectRegenerate(MenuItem selection, Modifiers mods)
905 Project prj = project;
906 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
907 ShowOutputBuildLog(true);
908 if(selection || !ide.activeClient)
910 DataRow row = fileList.currentRow;
911 ProjectNode node = row ? (ProjectNode)row.tag : null;
917 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
922 ProjectPrepareMakefile(prj, force, true, true, compiler, prj.config);
927 bool Compile(ProjectNode node)
930 char fileName[MAX_LOCATION];
932 Project prj = node.project;
933 ProjectConfig config = prj.config;
934 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
938 // Check if we have to save
939 strcpy(fileName, prj.topNode.path);
940 PathCatSlash(fileName, node.path);
941 PathCatSlash(fileName, node.name);
942 for(document = ide.firstChild; document; document = document.next)
944 if(document.modifiedDocument)
946 char documentFileName[MAX_LOCATION];
947 if(!fstrcmp(GetSlashPathBuffer(documentFileName, document.fileName), fileName))
948 if(!document.MenuFileSave(null, 0))
953 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
955 if(!node.GetIsExcluded(config))
957 // Delete intermedaite files
959 char extension[MAX_EXTENSION];
960 DirExpression objDir = prj.GetObjDir(compiler, config);
962 strcpy(fileName, prj.topNode.path);
963 PathCatSlash(fileName, objDir.dir);
964 PathCatSlash(fileName, node.name);
965 StripExtension(fileName);
966 strcat(fileName, ".o");
967 if(FileExists(fileName))
968 DeleteFile(fileName);
970 GetExtension(node.name, extension);
971 if(!strcmp(extension, "ec"))
973 // Delete generated C file
974 strcpy(fileName, prj.topNode.path);
975 PathCat(fileName, objDir.dir);
976 PathCat(fileName, node.name);
977 StripExtension(fileName);
978 strcat(fileName, ".c");
979 if(FileExists(fileName))
980 DeleteFile(fileName);
982 // Delete symbol file
983 strcpy(fileName, prj.topNode.path);
984 PathCat(fileName, node.path);
985 PathCat(fileName, node.name);
986 StripExtension(fileName);
987 strcat(fileName, ".sym");
988 if(FileExists(fileName))
989 DeleteFile(fileName);
994 buildInProgress = compilingFile;
995 ide.AdjustBuildMenus();
997 //ide.outputView.ShowClearSelectTab(build);
998 // this stuff doesn't even appear
999 //ide.outputView.buildBox.Logf($"%s Compiler\n", compiler.name);
1001 ide.outputView.buildBox.Logf($"Compiling single file %s in project %s using the %s configuration...\n", node.name, prj.name, config.name);
1003 ide.outputView.buildBox.Logf($"Compiling single file %s in project %s...\n", node.name, prj.name);
1005 prj.Compile(node, compiler, config);
1006 buildInProgress = none;
1007 ide.AdjustBuildMenus();
1016 bool ProjectNewFile(MenuItem selection, Modifiers mods)
1018 DataRow row = fileList.currentRow;
1021 char fileName[1024];
1022 char filePath[MAX_LOCATION];
1023 ProjectNode parentNode = (ProjectNode)row.tag;
1024 ProjectNode n, fileNode;
1025 parentNode.GetFileSysMatchingPath(filePath);
1026 MakePathRelative(filePath, parentNode.project.topNode.path, filePath);
1027 for(n = parentNode; n && n != parentNode.project.resNode; n = n.parent);
1028 sprintf(fileName, $"Untitled %d", documentID);
1029 fileNode = AddFile(parentNode, fileName, (bool)n, true);
1030 fileNode.path = CopyUnixPath(filePath);
1033 NodeProperties nodeProperties
1036 position = { position.x + 100, position.y + 100 };
1040 nodeProperties.Create(); // not modal?
1046 bool ProjectNewFolder(MenuItem selection, Modifiers mods)
1048 DataRow row = fileList.currentRow;
1051 ProjectNode parentNode = (ProjectNode)row.tag;
1052 NewFolder(parentNode, null, true);
1057 bool ResourcesAddFiles(MenuItem selection, Modifiers mods)
1063 bool ProjectAddFiles(MenuItem selection, Modifiers mods)
1069 bool ProjectImportFolder(MenuItem selection, Modifiers mods)
1071 DataRow row = fileList.currentRow;
1074 ProjectNode toNode = (ProjectNode)row.tag;
1075 ImportFolder(toNode);
1080 bool ProjectAddNewForm(MenuItem selection, Modifiers mods)
1082 CodeEditor codeEditor = CreateNew("Form", "form", "Window", null);
1083 codeEditor.EnsureUpToDate();
1087 bool ProjectAddNewGraph(MenuItem selection, Modifiers mods)
1089 CodeEditor codeEditor = CreateNew("Graph", "graph", "Block", null);
1091 codeEditor.EnsureUpToDate();
1095 bool ProjectRemove(MenuItem selection, Modifiers mods)
1097 DataRow row = fileList.currentRow;
1100 ProjectNode node = (ProjectNode)row.tag;
1101 if(node.type == project)
1102 RemoveSelectedNodes();
1107 bool ProjectUpdateMakefileForAllConfigs(Project project)
1109 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1111 for(config : project.configurations)
1113 ProjectPrepareMakefile(project, forceExists, false, false,
1121 bool MenuConfig(MenuItem selection, Modifiers mods)
1123 if(ProjectActiveConfig { master = parent, project = project }.Modal() == ok)
1128 bool MenuCompiler(MenuItem selection, Modifiers mods)
1130 ActiveCompilerDialog compilerDialog
1133 ideSettings = ideSettings, workspaceActiveCompiler = ide.workspace.compiler;
1135 incref compilerDialog;
1136 if(compilerDialog.Modal() == ok && strcmp(compilerDialog.workspaceActiveCompiler, ide.workspace.compiler))
1138 CompilerConfig compiler = ideSettings.GetCompilerConfig(compilerDialog.workspaceActiveCompiler);
1139 ide.workspace.compiler = compilerDialog.workspaceActiveCompiler;
1140 ide.projectView.ShowOutputBuildLog(true);
1141 ide.projectView.DisplayCompiler(compiler, false);
1142 for(prj : ide.workspace.projects)
1143 ide.projectView.ProjectUpdateMakefileForAllConfigs(prj);
1146 delete compilerDialog;
1150 bool MenuSettings(MenuItem selection, Modifiers mods)
1152 ProjectNode node = GetSelectedNode(true);
1153 Project prj = node ? node.project : project;
1154 projectSettingsDialog = ProjectSettings { master = parent, project = prj, projectNode = node };
1155 projectSettingsDialog.Modal();
1162 bool FileProperties(MenuItem selection, Modifiers mods)
1164 DataRow row = fileList.currentRow;
1167 ProjectNode node = (ProjectNode)row.tag;
1168 NodeProperties { parent = parent, master = this, node = node,
1169 position = { position.x + 100, position.y + 100 } }.Create();
1174 bool FileOpenFile(MenuItem selection, Modifiers mods)
1176 OpenSelectedNodes();
1180 bool FileRemoveFile(MenuItem selection, Modifiers mods)
1182 RemoveSelectedNodes();
1186 bool FileCompile(MenuItem selection, Modifiers mods)
1188 DataRow row = fileList.currentRow;
1191 ProjectNode node = (ProjectNode)row.tag;
1193 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
1198 Project GetSelectedProject(bool useSelection)
1200 Project prj = project;
1203 DataRow row = fileList.currentRow;
1204 ProjectNode node = row ? (ProjectNode)row.tag : null;
1211 ProjectNode GetSelectedNode(bool useSelection)
1213 ProjectNode node = null;
1216 DataRow row = fileList.currentRow;
1218 node = (ProjectNode)row.tag;
1223 bool MenuBrowseFolder(MenuItem selection, Modifiers mods)
1225 char folder[MAX_LOCATION];
1227 ProjectNode node = GetSelectedNode(true);
1229 node = project.topNode;
1232 strcpy(folder, prj.topNode.path);
1233 if(node != prj.topNode)
1234 PathCatSlash(folder, node.path);
1238 bool Run(MenuItem selection, Modifiers mods)
1240 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1241 ProjectConfig config = project.config;
1242 String args = new char[maxPathLen];
1244 if(ide.workspace.commandLineArgs)
1245 //ide.debugger.GetCommandLineArgs(args);
1246 strcpy(args, ide.workspace.commandLineArgs);
1247 if(ide.debugger.isActive)
1248 project.Run(args, compiler, config);
1249 /*else if(config.targetType == sharedLibrary || config.targetType == staticLibrary)
1250 MessageBox { master = ide, type = ok, text = "Run", contents = "Shared and static libraries cannot be run like executables." }.Modal();*/
1251 else if(BuildInterrim(project, run, compiler, config))
1252 project.Run(args, compiler, config);
1260 bool result = false;
1261 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1262 ProjectConfig config = project.config;
1263 TargetTypes targetType = project.GetTargetType(config);
1264 if(targetType == sharedLibrary || targetType == staticLibrary)
1265 MessageBox { master = ide, type = ok, text = $"Run", contents = $"Shared and static libraries cannot be run like executables." }.Modal();
1266 else if(project.GetCompress(config))
1267 MessageBox { master = ide, text = $"Starting Debug", contents = $"Debugging compressed applications is not supported\n" }.Modal();
1268 else if(project.GetDebug(config) ||
1269 MessageBox { master = ide, type = okCancel, text = $"Starting Debug", contents = $"Attempting to debug non-debug configuration\nProceed anyways?" }.Modal() == ok)
1271 if(/*!IsProjectModified() ||*/ BuildInterrim(project, start, compiler, config))
1273 if(compiler.type.isVC)
1275 //bool result = false;
1276 char oldwd[MAX_LOCATION];
1277 PathBackup pathBackup { };
1278 char command[MAX_LOCATION];
1280 ide.SetPath(false, compiler, config);
1282 GetWorkingDir(oldwd, sizeof(oldwd));
1283 ChangeWorkingDir(project.topNode.path);
1285 sprintf(command, "%s /useenv %s.sln /projectconfig \"%s|Win32\" /command \"%s\"" , "devenv", project.name, config.name, "Debug.Start");
1286 //ide.outputView.buildBox.Logf("command: %s\n", command);
1288 ChangeWorkingDir(oldwd);
1294 ide.debugger.Start(compiler, config);
1303 void GoToError(const char * line)
1307 while(isspace(*line)) line++;
1308 colon = strstr(line, ":");
1313 bool lookForLineNumber = true;
1315 // deal with linking error
1316 if(colon && colon[1] == ' ')
1318 colon = strstr(colon + 1, ":");
1319 if(colon && !colon[1])
1321 colon = strstr(line, ":");
1322 lookForLineNumber = false;
1324 else if(colon && !isdigit(colon[1]))
1327 colon = strstr(line, ":");
1330 // Don't be mistaken by the drive letter colon
1331 if(colon && (colon[1] == '/' || colon[1] == '\\'))
1332 colon = strstr(colon + 1, ":");
1333 if(colon && lookForLineNumber)
1337 char * par = RSearchString(line, "(", colon - line, true, false);
1338 if(par && strstr(par, ")"))
1340 else if((colon+1)[0] == ' ')
1342 // NOTE: This is the same thing as saying 'colon = line'
1343 for( ; colon != line; colon--)
1347 lineNumber = atoi(colon + 1);
1349 comma = strchr(colon, ',');
1351 col = atoi(comma+1);
1353 comma = strchr(colon+1, ':');
1355 col = atoi(comma+1);
1359 char moduleName[MAX_LOCATION], filePath[MAX_LOCATION];
1363 char * inFileIncludedFrom = strstr(line, stringInFileIncludedFrom);
1364 char * start = inFileIncludedFrom ? line + strlen(stringInFileIncludedFrom) : line;
1365 int len = (int)(colon - start);
1366 len = Min(len, MAX_LOCATION-1);
1368 strncpy(moduleName, start, len);
1369 moduleName[len] = '\0';
1372 strcpy(moduleName, line);
1374 // Remove stuff in brackets
1376 bracket = strstr(moduleName, "(");
1377 if(bracket) *bracket = '\0';
1379 MakeSlashPath(moduleName);
1383 // Check if it's one of our modules
1384 ProjectNode node = project.topNode.Find(moduleName, false);
1387 strcpy(moduleName, node.path);
1388 PathCatSlash(moduleName, node.name);
1391 moduleName[0] = '\0';
1395 CodeEditor codeEditor;
1396 strcpy(filePath, project.topNode.path);
1397 PathCatSlash(filePath, moduleName);
1399 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
1402 char name[MAX_LOCATION];
1403 // TOFIX: Improve on this, don't use only filename, make a function
1404 if(ide && ide.workspace)
1406 for(prj : ide.workspace.projects)
1408 if(prj.topNode.FindWithPath(moduleName, false))
1410 strcpy(filePath, prj.topNode.path);
1411 PathCatSlash(filePath, moduleName);
1412 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
1419 if(codeEditor && lineNumber)
1421 EditBox editBox = codeEditor.editBox;
1422 editBox.GoToLineNum(lineNumber - 1);
1423 editBox.GoToPosition(editBox.line, lineNumber - 1, col ? (col - 1) : 0);
1430 bool OpenNode(ProjectNode node)
1432 char filePath[MAX_LOCATION];
1433 node.GetFullFilePath(filePath);
1434 return ide.OpenFile(filePath, normal, true/*false Why was it opening hidden?*/, null, something, normal) ? true : false;
1437 void AddNode(ProjectNode node, DataRow addTo)
1439 DataRow row = addTo ? addTo.AddRow() : fileList.AddRow();
1441 row.tag = (int)node;
1444 if(node.type == resources)
1447 row.SetData(null, node);
1449 if(node.files && node.files.first && node.parent &&
1450 !(!node.parent.parent &&
1451 (!strcmpi(node.name, "notes") || !strcmpi(node.name, "sources") ||
1452 !strcmpi(node.name, "src") || !strcmpi(node.name, "tools"))))
1453 row.collapsed = true;
1454 else if(node.type == folder)
1455 node.icon = openFolder;
1459 for(child : node.files)
1460 AddNode(child, row);
1464 void DeleteNode(ProjectNode projectNode)
1466 if(projectNode.files)
1469 while(child = projectNode.files.first)
1472 fileList.DeleteRow(projectNode.row);
1473 projectNode.Delete();
1476 bool ProjectSave(MenuItem selection, Modifiers mods)
1478 DataRow row = fileList.currentRow;
1479 ProjectNode node = row ? (ProjectNode)row.tag : null;
1480 Project prj = node ? node.project : null;
1483 if(prj.Save(prj.filePath))
1485 // ShowOutputBuildLog(true);
1486 // DisplayCompiler(compiler, false);
1487 // ProjectUpdateMakefileForAllConfigs(prj);
1488 prj.topNode.modified = false;
1490 for(p : ide.workspace.projects)
1492 if(p.topNode.modified)
1499 modifiedDocument = false;
1506 bool ShowOutputBuildLog(bool cleanLog)
1508 OutputView output = ide.outputView;
1510 output.ShowClearSelectTab(build);
1513 output.SelectTab(build);
1520 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1521 ProjectConfig config = project.config;
1523 bool result = false;
1524 if(/*!IsProjectModified() ||*/ BuildInterrim(project, restart, compiler, config))
1526 // For Restart, compiler and config will only be used if for
1527 // whatever reason (if at all possible) the Debugger is in a
1528 // 'terminated' or 'none' state
1529 ide.debugger.Restart(compiler, config);
1539 ide.debugger.Resume();
1545 ide.debugger.Break();
1551 ide.debugger.Stop();
1555 bool DebugStepInto()
1557 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1558 ProjectConfig config = project.config;
1560 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config)))
1561 ide.debugger.StepInto(compiler, config);
1566 bool DebugStepOver(bool skip)
1568 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1569 ProjectConfig config = project.config;
1571 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config)))
1572 ide.debugger.StepOver(compiler, config, skip);
1578 bool DebugStepOut(bool skip)
1580 ide.debugger.StepOut(skip);
1584 void ImportFolder(ProjectNode toNode)
1588 //bool isFolder = toNode.type == folder;
1589 //bool isRes = toNode.isInResources;
1591 FileDialog fileDialog = importFileDialog;
1592 fileDialog.master = parent;
1593 if(fileDialog.Modal() == ok)
1595 ImportFolderFSI fsi { projectView = this };
1596 fsi.stack.Add(toNode);
1597 fsi.Iterate(fileDialog.filePath);
1603 ProjectNode NewFolder(ProjectNode parentNode, char * name, bool showProperties)
1607 ProjectNode folderNode;
1608 Project prj = parentNode.project;
1610 ProjectNode after = null;
1611 for(node : parentNode.files)
1613 if(node.type != folder)
1619 folderNode = parentNode.Add(prj, name, after, folder, folder, true);
1622 for(c = 0; c < 100; c++)
1625 sprintf(string, c ? "New Folder (%d)" : "New Folder", c);
1626 if((folderNode = parentNode.Add(prj, string, after, folder, folder, true)))
1633 NodeProperties nodeProperties;
1636 modifiedDocument = true;
1637 prj.topNode.modified = true;
1640 folderNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
1641 folderNode.row.tag = (int)folderNode;
1643 folderNode.row.SetData(null, folderNode);
1644 fileList.currentRow = folderNode.row;
1648 nodeProperties = NodeProperties
1650 parent, this, mode = newFolder, node = folderNode;
1651 position = { position.x + 100, position.y + 100 };
1653 nodeProperties.Create(); // Modal?
1661 void AddFiles(bool resources)
1663 FileDialog fileDialog = (!resources) ? this.fileDialog : resourceFileDialog;
1664 fileDialog.type = multiOpen;
1665 fileDialog.text = !resources ? $"Add Files to Project" : $"Add Resources to Project";
1666 fileDialog.master = parent;
1668 if(fileDialog.Modal() == ok)
1671 DataRow row = fileList.currentRow;
1672 ProjectNode parentNode = (ProjectNode)row.tag;
1673 bool addFailed = false;
1674 int numSelections = fileDialog.numSelections;
1675 char ** multiFilePaths = fileDialog.multiFilePaths;
1677 Array<String> nameConflictFiles { };
1679 for(c = 0; c < numSelections; c++)
1681 char * filePath = multiFilePaths[c];
1682 FileAttribs exists = FileExists(filePath);
1683 bool addThisFile = true;
1685 if(exists.isDirectory)
1686 addThisFile = false;
1689 if(MessageBox { master = ide, type = yesNo, text = filePath,
1690 contents = $"File doesn't exist. Create?" }.Modal() == yes)
1692 File f = FileOpen(filePath, write);
1700 MessageBox { master = ide, type = ok, text = filePath,
1701 contents = $"Couldn't create file."}.Modal();
1702 addThisFile = false;
1709 /*addFailed = */if(!AddFile(parentNode, filePath, resources, false))//;
1711 nameConflictFiles.Add(CopyString(filePath));
1719 char * part1 = $"The following file";
1720 char * opt1 = $" was ";
1721 char * opt2 = $"s were ";
1722 char * part2 = $"not added because of identical file name conflict within the project.\n\n";
1724 len += strlen(part1);
1725 len += strlen(part2);
1726 len += nameConflictFiles.count > 1 ? strlen(opt2) : strlen(opt1);
1727 for(s : nameConflictFiles)
1728 len += strlen(s) + 1;
1729 message = new char[len + 1];
1730 strcpy(message, part1);
1731 strcat(message, nameConflictFiles.count > 1 ? opt2 : opt1);
1732 strcat(message, part2);
1733 for(s : nameConflictFiles)
1736 strcat(message, "\n");
1738 MessageBox { master = ide, type = ok, text = $"Name Conflict",
1739 contents = message }.Modal();
1742 nameConflictFiles.Free();
1743 delete nameConflictFiles;
1747 ProjectNode AddFile(ProjectNode parentNode, char * filePath, bool resources, bool isTemporary)
1749 ProjectNode result = null;
1750 ProjectNode after = null;
1751 for(node : parentNode.files)
1753 if(node.type != folder && node.type != file && node.type)
1758 result = parentNode.Add(parentNode.project, filePath, after, file, NodeIcons::SelectFileIcon(filePath), !resources);
1764 modifiedDocument = true;
1765 parentNode.project.topNode.modified = true;
1766 parentNode.project.ModifiedAllConfigs(true, false, true, true);
1769 result.row = parentNode.row.AddRowAfter(after ? after.row : null);
1770 result.row.tag = (int)result;
1771 result.row.SetData(null, result);
1776 CodeEditor CreateNew(char * upper, char * lower, char * base, char * className)
1778 CodeEditor codeEditor = null;
1779 ProjectNode projectNode;
1780 ProjectNode after = null;
1781 DataRow row = fileList.currentRow;
1782 ProjectNode parentNode;
1785 if(!row) row = project.topNode.row;
1787 parentNode = (ProjectNode)row.tag;
1789 for(node : parentNode.files)
1791 if(node.type != folder && node.type != file && node.type)
1795 for(c = 1; c < 100; c++)
1798 sprintf(string, c ? "%s%d.ec" : "%s.ec", lower, c);
1799 if((projectNode = parentNode.Add(project, string, after, file, genFile, true)))
1805 char filePath[MAX_LOCATION];
1807 modifiedDocument = true;
1808 project.topNode.modified = true;
1810 project.ModifiedAllConfigs(true, false, false, true);
1811 projectNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
1812 projectNode.row.tag =(int)projectNode;
1814 projectNode.row.SetData(null, projectNode);
1815 fileList.currentRow = projectNode.row;
1817 strcpy(filePath, project.topNode.path);
1818 PathCat(filePath, projectNode.path);
1819 PathCat(filePath, projectNode.name);
1821 codeEditor = (CodeEditor)ide.FindWindow(filePath);
1824 Class baseClass = eSystem_FindClass(__thisModule, base);
1825 subclass(ClassDesignerBase) designerClass = eClass_GetDesigner(baseClass);
1828 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal);
1829 strcpy(name, projectNode.name);
1830 sprintf(name, "%s%d", upper, c);
1832 strcpy(className, name);
1834 designerClass.CreateNew(codeEditor.editBox, codeEditor.clientSize, name, base);
1836 //codeEditor.modifiedDocument = false;
1837 //codeEditor.designer.modifiedDocument = false;
1839 //Code_EnsureUpToDate(codeEditor);
1842 else // TODO: fix no symbols generated when ommiting {} for following else
1844 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal);
1848 codeEditor.ViewDesigner();
1849 codeEditor.codeModified = true;
1856 // Returns true if we opened something
1857 bool OpenSelectedNodes()
1859 bool result = false;
1863 fileList.GetMultiSelection(selection);
1864 for(item = selection.first; item; item = item.next)
1866 DataRow row = item.data;
1867 ProjectNode node = (ProjectNode)row.tag;
1868 if(node.type == file)
1875 selection.Free(null);
1879 void RemoveSelectedNodes()
1884 fileList.GetMultiSelection(selection);
1886 // Remove children of parents we're deleting
1887 for(item = selection.first; item; item = next)
1890 DataRow row = item.data;
1891 ProjectNode n, node = (ProjectNode)row.tag;
1892 bool remove = false;
1895 for(i = selection.first; i && !remove; i = i.next)
1897 ProjectNode iNode = (ProjectNode)((DataRow)i.data).tag;
1898 for(n = node.parent; n; n = n.parent)
1908 selection.Delete(item);
1911 for(item = selection.first; item; item = item.next)
1913 DataRow row = item.data;
1914 ProjectNode node = (ProjectNode)row.tag;
1915 ProjectNode resNode;
1916 for(resNode = node.parent; resNode; resNode = resNode.parent)
1917 if(resNode.type == resources)
1919 if(node.type == file)
1921 Project prj = node.project;
1923 modifiedDocument = true;
1924 prj.topNode.modified = true;
1926 prj.ModifiedAllConfigs(true, false, true, true);
1928 else if(node.type == folder)
1931 sprintf(message, $"Are you sure you want to remove the folder \"%s\"\n"
1932 "and all of its contents from the project?", node.name);
1933 if(MessageBox { master = ide, type = yesNo, text = $"Delete Folder", contents = message }.Modal() == yes)
1935 Project prj = node.project;
1936 if(node.containsFile)
1937 prj.ModifiedAllConfigs(true, false, true, true);
1939 modifiedDocument = true;
1940 prj.topNode.modified = true;
1943 else if(node.type == project && node != project.topNode && !buildInProgress)
1947 for(p : workspace.projects)
1949 if(p.topNode == node)
1955 sprintf(message, $"Are you sure you want to remove the \"%s\" project\n" "from this workspace?", node.name);
1956 if(MessageBox { master = ide, type = yesNo, text = $"Remove Project", contents = message }.Modal() == yes)
1961 workspace.RemoveProject(prj);
1962 //modifiedDocument = true; // when project view is a workspace view
1966 selection.Free(null);