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)
478 prj.StopMonitoring();
479 if(prj.Save(prj.filePath))
481 // ShowOutputBuildLog(true);
482 // DisplayCompiler(compiler, false);
483 // ProjectUpdateMakefileForAllConfigs(prj);
484 prj.topNode.modified = false;
486 prj.StartMonitoring();
489 modifiedDocument = false;
494 bool IsModuleInProject(char * filePath)
496 char moduleName[MAX_FILENAME]; //, modulePath[MAX_LOCATION];
497 GetLastDirectory(filePath, moduleName);
498 return project.topNode.Find(moduleName, false) != null;
501 bool GetRelativePath(char * filePath, char * relativePath)
503 return project.GetRelativePath(filePath, relativePath);
506 ProjectNode GetNodeFromWindow(Window document, Project project)
508 if(document.fileName)
510 char winFileName[MAX_LOCATION];
511 char * documentFileName = GetSlashPathBuffer(winFileName, document.fileName);
512 for(p : ide.workspace.projects)
514 Project prj = project ? project : p;
516 if((node = prj.topNode.FindByFullPath(documentFileName, false)))
524 // ((( UTILITY FUNCTIONS )))
526 // ************************************************************************
527 // *** These methods below are part of a sequence of events, and as ***
528 // *** such they must be passed the current compiler and project config ***
529 // ************************************************************************
530 bool DisplayCompiler(CompilerConfig compiler, bool cleanLog)
532 ide.outputView.buildBox.Logf($"%s Compiler\n", compiler ? compiler.name : $"{problem with compiler selection}");
535 bool ProjectPrepareForToolchain(Project project, PrepareMakefileMethod method, bool cleanLog, bool displayCompiler,
536 CompilerConfig compiler, ProjectConfig config)
539 char message[MAX_F_STRING];
540 LogBox logBox = ide.outputView.buildBox;
542 ShowOutputBuildLog(cleanLog);
545 DisplayCompiler(compiler, false);
547 ProjectPrepareMakefile(project, method, false, false, compiler, config);
551 bool ProjectPrepareMakefile(Project project, PrepareMakefileMethod method, bool cleanLog, bool displayCompiler,
552 CompilerConfig compiler, ProjectConfig config)
554 char makefilePath[MAX_LOCATION];
555 char makefileName[MAX_LOCATION];
557 LogBox logBox = ide.outputView.buildBox;
560 DisplayCompiler(compiler, false);
562 strcpy(makefilePath, project.topNode.path);
563 project.CatMakeFileName(makefileName, config);
564 PathCatSlash(makefilePath, makefileName);
566 exists = FileExists(makefilePath);
567 if((method == normal && (!exists || config.makingModified/*|| project.topNode.modified*/)) ||
568 (method == forceExists && exists) ||
569 method == force) // || config.makingModified || makefileDirty
573 ide.statusBar.text = $"Generating Makefile & Dependencies..."; // Dependencies?
576 if((method == normal && !exists) || (method == force && !exists))
577 action = $"Generating ";
578 else if(method == force)
579 action = $"Regenerating ";
580 else if(method == normal || method == forceExists)
581 action = $"Updating ";
585 reason = $"Makefile doesn't exist. ";
586 else if(project.topNode.modified)
587 reason = $"Project has been modified. ";
591 //logBox.Logf("%s\n", makefileName);
592 logBox.Logf($"%s - %s%smakefile for %s config...\n", makefileName, reason, action, GetConfigName(config));
594 project.GenerateCrossPlatformCf();
595 project.GenerateCompilerMk(compiler);
596 project.GenerateMakefile(null, false, null, compiler, config);
598 ide.statusBar.text = null;
605 bool BuildInterrim(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config)
607 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
609 ide.outputView.buildBox.Logf($"Building project %s using the %s configuration...\n", prj.name, GetConfigName(config));
610 return Build(prj, buildType, compiler, config);
615 bool DebugStopForMake(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config)
618 // TOFIX: DebugStop is being abused and backfiring on us.
619 // It's supposed to be the 'Debug/Stop' item, not unloading executable or anything else
621 // configIsInDebugSession seems to be used for two OPPOSITE things:
622 // If we're debugging another config, we need to unload the executable!
623 // In building, we want to stop if we're debugging the 'same' executable
624 if(buildType != run) ///* && prj == project*/ && prj.configIsInDebugSession)
626 if(buildType == start || buildType == restart)
628 if(ide.debugger && ide.debugger.isPrepared)
629 result = DebugStop();
633 if(ide.project == prj && ide.debugger && ide.debugger.prjConfig == config && ide.debugger.isPrepared)
634 result = DebugStop();
640 bool Build(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config)
646 for(document = master.firstChild; document; document = document.next)
648 if(document.modifiedDocument)
650 ProjectNode node = GetNodeFromWindow(document, prj);
651 if(node && !document.MenuFileSave(null, 0))
660 DirExpression targetDir = prj.GetTargetDir(compiler, config);
662 DebugStopForMake(prj, buildType, compiler, config);
664 // TODO: Disabled until problems fixed... is it fixed?
665 if(buildType == rebuild || (config && config.compilingModified))
666 prj.Clean(compiler, config, false);
669 if(buildType == relink || (config && config.linkingModified))
671 char target[MAX_LOCATION];
673 strcpy(target, prj.topNode.path);
674 PathCat(target, targetDir.dir);
675 prj.CatTargetFileName(target, compiler, config);
676 if(FileExists(target))
679 if(config && config.symbolGenModified)
681 DirExpression objDir = prj.GetObjDir(compiler, config);
682 char fileName[MAX_LOCATION];
683 char moduleName[MAX_FILENAME];
684 strcpy(fileName, prj.topNode.path);
685 PathCatSlash(fileName, objDir.dir);
686 strcpy(moduleName, prj.moduleName);
687 strcat(moduleName, ".main.ec");
688 PathCatSlash(fileName, moduleName);
689 if(FileExists(fileName))
690 DeleteFile(fileName);
691 ChangeExtension(fileName, "c", fileName);
692 if(FileExists(fileName))
693 DeleteFile(fileName);
694 ChangeExtension(fileName, "o", fileName);
695 if(FileExists(fileName))
696 DeleteFile(fileName);
701 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
702 ide.AdjustBuildMenus();
703 ide.AdjustDebugMenus();
705 result = prj.Build(buildType == run, null, compiler, config);
709 config.compilingModified = false;
710 if(!ide.ShouldStopBuild())
711 config.linkingModified = false;
713 config.symbolGenModified = false;
715 buildInProgress = none;
716 ide.AdjustBuildMenus();
717 ide.AdjustDebugMenus();
719 ide.workspace.modified = true;
726 // ((( USER ACTIONS )))
728 // ************************************************************************
729 // *** Methods below should atomically start a process, and as such ***
730 // *** they can query compiler and config directly from ide and project ***
731 // *** but ONLY ONCE!!! ***
732 // ************************************************************************
734 bool ProjectBuild(MenuItem selection, Modifiers mods)
736 Project prj = project;
737 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
738 ProjectConfig config;
739 if(selection || !ide.activeClient)
741 DataRow row = fileList.currentRow;
742 ProjectNode node = row ? (ProjectNode)row.tag : null;
743 if(node) prj = node.project;
747 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
752 if(/*prj != project || */!prj.GetConfigIsInDebugSession(config) || !ide.DontTerminateDebugSession($"Project Build"))
754 BuildInterrim(prj, build, compiler, config);
760 bool ProjectLink(MenuItem selection, Modifiers mods)
762 Project prj = project;
763 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
764 ProjectConfig config;
765 if(selection || !ide.activeClient)
767 DataRow row = fileList.currentRow;
768 ProjectNode node = row ? (ProjectNode)row.tag : null;
769 if(node) prj = node.project;
773 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
778 if(!prj.GetConfigIsInDebugSession(config) ||
779 (!ide.DontTerminateDebugSession($"Project Link") && DebugStopForMake(prj, relink, compiler, config)))
781 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
783 ide.outputView.buildBox.Logf($"Relinking project %s using the %s configuration...\n", prj.name, GetConfigName(config));
785 config.linkingModified = true;
786 Build(prj, relink, compiler, config);
793 bool ProjectRebuild(MenuItem selection, Modifiers mods)
795 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
796 Project prj = project;
797 ProjectConfig config;
798 if(selection || !ide.activeClient)
800 DataRow row = fileList.currentRow;
801 ProjectNode node = row ? (ProjectNode)row.tag : null;
802 if(node) prj = node.project;
806 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
811 if(!prj.GetConfigIsInDebugSession(config) ||
812 (!ide.DontTerminateDebugSession($"Project Rebuild") && DebugStopForMake(prj, rebuild, compiler, config)))
814 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
816 ide.outputView.buildBox.Logf($"Rebuilding project %s using the %s configuration...\n", prj.name, GetConfigName(config));
819 config.compilingModified = true;
820 config.makingModified = true;
821 }*/ // -- should this still be used depite the new solution of BuildType?
822 Build(prj, rebuild, compiler, config);
829 bool ProjectClean(MenuItem selection, Modifiers mods)
831 Project prj = project;
832 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
833 ProjectConfig config;
834 if(selection || !ide.activeClient)
836 DataRow row = fileList.currentRow;
837 ProjectNode node = row ? (ProjectNode)row.tag : null;
838 if(node) prj = node.project;
842 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
847 if(!prj.GetConfigIsInDebugSession(config) ||
848 (!ide.DontTerminateDebugSession($"Project Clean") && DebugStopForMake(prj, clean, compiler, config)))
850 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
852 ide.outputView.buildBox.Logf($"Cleaning project %s using the %s configuration...\n", prj.name, GetConfigName(config));
854 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
855 ide.AdjustBuildMenus();
856 ide.AdjustDebugMenus();
858 prj.Clean(compiler, config, false);
859 buildInProgress = none;
860 ide.AdjustBuildMenus();
861 ide.AdjustDebugMenus();
868 bool ProjectRealClean(MenuItem selection, Modifiers mods)
870 Project prj = project;
871 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
872 ProjectConfig config;
873 if(selection || !ide.activeClient)
875 DataRow row = fileList.currentRow;
876 ProjectNode node = row ? (ProjectNode)row.tag : null;
877 if(node) prj = node.project;
881 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
886 if(!prj.GetConfigIsInDebugSession(config) ||
887 (!ide.DontTerminateDebugSession($"Project Real Clean") && DebugStopForMake(prj, clean, compiler, config)))
889 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
891 ide.outputView.buildBox.Logf($"Removing intermediate objects directory for project %s using the %s configuration...\n", prj.name, GetConfigName(config));
893 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
894 ide.AdjustBuildMenus();
895 ide.AdjustDebugMenus();
897 prj.Clean(compiler, config, true);
898 buildInProgress = none;
899 ide.AdjustBuildMenus();
900 ide.AdjustDebugMenus();
907 bool ProjectRegenerate(MenuItem selection, Modifiers mods)
909 Project prj = project;
910 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
911 ShowOutputBuildLog(true);
912 if(selection || !ide.activeClient)
914 DataRow row = fileList.currentRow;
915 ProjectNode node = row ? (ProjectNode)row.tag : null;
921 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
926 ProjectPrepareMakefile(prj, force, true, true, compiler, prj.config);
931 bool Compile(ProjectNode node)
934 char fileName[MAX_LOCATION];
936 Project prj = node.project;
937 ProjectConfig config = prj.config;
938 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
942 // Check if we have to save
943 strcpy(fileName, prj.topNode.path);
944 PathCatSlash(fileName, node.path);
945 PathCatSlash(fileName, node.name);
946 for(document = ide.firstChild; document; document = document.next)
948 if(document.modifiedDocument)
950 char documentFileName[MAX_LOCATION];
951 if(!fstrcmp(GetSlashPathBuffer(documentFileName, document.fileName), fileName))
952 if(!document.MenuFileSave(null, 0))
957 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
959 if(!node.GetIsExcluded(config))
961 // Delete intermedaite files
963 char extension[MAX_EXTENSION];
964 DirExpression objDir = prj.GetObjDir(compiler, config);
966 strcpy(fileName, prj.topNode.path);
967 PathCatSlash(fileName, objDir.dir);
968 PathCatSlash(fileName, node.name);
969 StripExtension(fileName);
970 strcat(fileName, ".o");
971 if(FileExists(fileName))
972 DeleteFile(fileName);
974 GetExtension(node.name, extension);
975 if(!strcmp(extension, "ec"))
977 // Delete generated C file
978 strcpy(fileName, prj.topNode.path);
979 PathCat(fileName, objDir.dir);
980 PathCat(fileName, node.name);
981 StripExtension(fileName);
982 strcat(fileName, ".c");
983 if(FileExists(fileName))
984 DeleteFile(fileName);
986 // Delete symbol file
987 strcpy(fileName, prj.topNode.path);
988 PathCat(fileName, node.path);
989 PathCat(fileName, node.name);
990 StripExtension(fileName);
991 strcat(fileName, ".sym");
992 if(FileExists(fileName))
993 DeleteFile(fileName);
998 buildInProgress = compilingFile;
999 ide.AdjustBuildMenus();
1001 //ide.outputView.ShowClearSelectTab(build);
1002 // this stuff doesn't even appear
1003 //ide.outputView.buildBox.Logf($"%s Compiler\n", compiler.name);
1005 ide.outputView.buildBox.Logf($"Compiling single file %s in project %s using the %s configuration...\n", node.name, prj.name, config.name);
1007 ide.outputView.buildBox.Logf($"Compiling single file %s in project %s...\n", node.name, prj.name);
1009 prj.Compile(node, compiler, config);
1010 buildInProgress = none;
1011 ide.AdjustBuildMenus();
1020 bool ProjectNewFile(MenuItem selection, Modifiers mods)
1022 DataRow row = fileList.currentRow;
1025 char fileName[1024];
1026 char filePath[MAX_LOCATION];
1027 ProjectNode parentNode = (ProjectNode)row.tag;
1028 ProjectNode n, fileNode;
1029 parentNode.GetFileSysMatchingPath(filePath);
1030 MakePathRelative(filePath, parentNode.project.topNode.path, filePath);
1031 for(n = parentNode; n && n != parentNode.project.resNode; n = n.parent);
1032 sprintf(fileName, $"Untitled %d", documentID);
1033 fileNode = AddFile(parentNode, fileName, (bool)n, true);
1034 fileNode.path = CopyUnixPath(filePath);
1037 NodeProperties nodeProperties
1040 position = { position.x + 100, position.y + 100 };
1044 nodeProperties.Create(); // not modal?
1050 bool ProjectNewFolder(MenuItem selection, Modifiers mods)
1052 DataRow row = fileList.currentRow;
1055 ProjectNode parentNode = (ProjectNode)row.tag;
1056 NewFolder(parentNode, null, true);
1061 bool ResourcesAddFiles(MenuItem selection, Modifiers mods)
1067 bool ProjectAddFiles(MenuItem selection, Modifiers mods)
1073 bool ProjectImportFolder(MenuItem selection, Modifiers mods)
1075 DataRow row = fileList.currentRow;
1078 ProjectNode toNode = (ProjectNode)row.tag;
1079 ImportFolder(toNode);
1084 bool ProjectAddNewForm(MenuItem selection, Modifiers mods)
1086 CodeEditor codeEditor = CreateNew("Form", "form", "Window", null);
1087 codeEditor.EnsureUpToDate();
1091 bool ProjectAddNewGraph(MenuItem selection, Modifiers mods)
1093 CodeEditor codeEditor = CreateNew("Graph", "graph", "Block", null);
1095 codeEditor.EnsureUpToDate();
1099 bool ProjectRemove(MenuItem selection, Modifiers mods)
1101 DataRow row = fileList.currentRow;
1104 ProjectNode node = (ProjectNode)row.tag;
1105 if(node.type == project)
1106 RemoveSelectedNodes();
1111 bool ProjectUpdateMakefileForAllConfigs(Project project)
1113 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1115 for(config : project.configurations)
1117 ProjectPrepareMakefile(project, forceExists, false, false,
1125 bool MenuConfig(MenuItem selection, Modifiers mods)
1127 if(ProjectActiveConfig { master = parent, project = project }.Modal() == ok)
1132 bool MenuCompiler(MenuItem selection, Modifiers mods)
1134 ActiveCompilerDialog compilerDialog
1137 ideSettings = ideSettings, workspaceActiveCompiler = ide.workspace.compiler;
1139 incref compilerDialog;
1140 if(compilerDialog.Modal() == ok && strcmp(compilerDialog.workspaceActiveCompiler, ide.workspace.compiler))
1142 CompilerConfig compiler = ideSettings.GetCompilerConfig(compilerDialog.workspaceActiveCompiler);
1143 ide.workspace.compiler = compilerDialog.workspaceActiveCompiler;
1144 ide.projectView.ShowOutputBuildLog(true);
1145 ide.projectView.DisplayCompiler(compiler, false);
1146 for(prj : ide.workspace.projects)
1147 ide.projectView.ProjectUpdateMakefileForAllConfigs(prj);
1150 delete compilerDialog;
1154 bool MenuSettings(MenuItem selection, Modifiers mods)
1156 ProjectNode node = GetSelectedNode(true);
1157 Project prj = node ? node.project : project;
1158 projectSettingsDialog = ProjectSettings { master = parent, project = prj, projectNode = node };
1159 projectSettingsDialog.Modal();
1166 bool FileProperties(MenuItem selection, Modifiers mods)
1168 DataRow row = fileList.currentRow;
1171 ProjectNode node = (ProjectNode)row.tag;
1172 NodeProperties { parent = parent, master = this, node = node,
1173 position = { position.x + 100, position.y + 100 } }.Create();
1178 bool FileOpenFile(MenuItem selection, Modifiers mods)
1180 OpenSelectedNodes();
1184 bool FileRemoveFile(MenuItem selection, Modifiers mods)
1186 RemoveSelectedNodes();
1190 bool FileCompile(MenuItem selection, Modifiers mods)
1192 DataRow row = fileList.currentRow;
1195 ProjectNode node = (ProjectNode)row.tag;
1197 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
1202 Project GetSelectedProject(bool useSelection)
1204 Project prj = project;
1207 DataRow row = fileList.currentRow;
1208 ProjectNode node = row ? (ProjectNode)row.tag : null;
1215 ProjectNode GetSelectedNode(bool useSelection)
1217 ProjectNode node = null;
1220 DataRow row = fileList.currentRow;
1222 node = (ProjectNode)row.tag;
1227 bool MenuBrowseFolder(MenuItem selection, Modifiers mods)
1229 char folder[MAX_LOCATION];
1231 ProjectNode node = GetSelectedNode(true);
1233 node = project.topNode;
1236 strcpy(folder, prj.topNode.path);
1237 if(node != prj.topNode)
1238 PathCatSlash(folder, node.path);
1242 bool Run(MenuItem selection, Modifiers mods)
1244 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1245 ProjectConfig config = project.config;
1246 String args = new char[maxPathLen];
1248 if(ide.workspace.commandLineArgs)
1249 //ide.debugger.GetCommandLineArgs(args);
1250 strcpy(args, ide.workspace.commandLineArgs);
1251 if(ide.debugger.isActive)
1252 project.Run(args, compiler, config);
1253 /*else if(config.targetType == sharedLibrary || config.targetType == staticLibrary)
1254 MessageBox { master = ide, type = ok, text = "Run", contents = "Shared and static libraries cannot be run like executables." }.Modal();*/
1255 else if(BuildInterrim(project, run, compiler, config))
1256 project.Run(args, compiler, config);
1264 bool result = false;
1265 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1266 ProjectConfig config = project.config;
1267 TargetTypes targetType = project.GetTargetType(config);
1268 if(targetType == sharedLibrary || targetType == staticLibrary)
1269 MessageBox { master = ide, type = ok, text = $"Run", contents = $"Shared and static libraries cannot be run like executables." }.Modal();
1270 else if(project.GetCompress(config))
1271 MessageBox { master = ide, text = $"Starting Debug", contents = $"Debugging compressed applications is not supported\n" }.Modal();
1272 else if(project.GetDebug(config) ||
1273 MessageBox { master = ide, type = okCancel, text = $"Starting Debug", contents = $"Attempting to debug non-debug configuration\nProceed anyways?" }.Modal() == ok)
1275 if(/*!IsProjectModified() ||*/ BuildInterrim(project, start, compiler, config))
1277 if(compiler.type.isVC)
1279 //bool result = false;
1280 char oldwd[MAX_LOCATION];
1281 PathBackup pathBackup { };
1282 char command[MAX_LOCATION];
1284 ide.SetPath(false, compiler, config);
1286 GetWorkingDir(oldwd, sizeof(oldwd));
1287 ChangeWorkingDir(project.topNode.path);
1289 sprintf(command, "%s /useenv %s.sln /projectconfig \"%s|Win32\" /command \"%s\"" , "devenv", project.name, config.name, "Debug.Start");
1290 //ide.outputView.buildBox.Logf("command: %s\n", command);
1292 ChangeWorkingDir(oldwd);
1298 ide.debugger.Start(compiler, config);
1307 void GoToError(const char * line)
1311 while(isspace(*line)) line++;
1312 colon = strstr(line, ":");
1317 bool lookForLineNumber = true;
1319 // deal with linking error
1320 if(colon && colon[1] == ' ')
1322 colon = strstr(colon + 1, ":");
1323 if(colon && !colon[1])
1325 colon = strstr(line, ":");
1326 lookForLineNumber = false;
1328 else if(colon && !isdigit(colon[1]))
1331 colon = strstr(line, ":");
1334 // Don't be mistaken by the drive letter colon
1335 if(colon && (colon[1] == '/' || colon[1] == '\\'))
1336 colon = strstr(colon + 1, ":");
1337 if(colon && lookForLineNumber)
1341 char * par = RSearchString(line, "(", colon - line, true, false);
1342 if(par && strstr(par, ")"))
1344 else if((colon+1)[0] == ' ')
1346 // NOTE: This is the same thing as saying 'colon = line'
1347 for( ; colon != line; colon--)
1351 lineNumber = atoi(colon + 1);
1353 comma = strchr(colon, ',');
1355 col = atoi(comma+1);
1357 comma = strchr(colon+1, ':');
1359 col = atoi(comma+1);
1363 char moduleName[MAX_LOCATION], filePath[MAX_LOCATION];
1367 char * inFileIncludedFrom = strstr(line, stringInFileIncludedFrom);
1368 char * start = inFileIncludedFrom ? line + strlen(stringInFileIncludedFrom) : line;
1369 int len = (int)(colon - start);
1370 len = Min(len, MAX_LOCATION-1);
1372 strncpy(moduleName, start, len);
1373 moduleName[len] = '\0';
1376 strcpy(moduleName, line);
1378 // Remove stuff in brackets
1380 bracket = strstr(moduleName, "(");
1381 if(bracket) *bracket = '\0';
1383 MakeSlashPath(moduleName);
1387 // Check if it's one of our modules
1388 ProjectNode node = project.topNode.Find(moduleName, false);
1391 strcpy(moduleName, node.path);
1392 PathCatSlash(moduleName, node.name);
1395 moduleName[0] = '\0';
1399 CodeEditor codeEditor;
1400 strcpy(filePath, project.topNode.path);
1401 PathCatSlash(filePath, moduleName);
1403 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
1406 char name[MAX_LOCATION];
1407 // TOFIX: Improve on this, don't use only filename, make a function
1408 if(ide && ide.workspace)
1410 for(prj : ide.workspace.projects)
1412 if(prj.topNode.FindWithPath(moduleName, false))
1414 strcpy(filePath, prj.topNode.path);
1415 PathCatSlash(filePath, moduleName);
1416 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
1423 if(codeEditor && lineNumber)
1425 EditBox editBox = codeEditor.editBox;
1426 editBox.GoToLineNum(lineNumber - 1);
1427 editBox.GoToPosition(editBox.line, lineNumber - 1, col ? (col - 1) : 0);
1434 bool OpenNode(ProjectNode node)
1436 char filePath[MAX_LOCATION];
1437 node.GetFullFilePath(filePath);
1438 return ide.OpenFile(filePath, normal, true/*false Why was it opening hidden?*/, null, something, normal) ? true : false;
1441 void AddNode(ProjectNode node, DataRow addTo)
1443 DataRow row = addTo ? addTo.AddRow() : fileList.AddRow();
1445 row.tag = (int)node;
1448 if(node.type == resources)
1451 row.SetData(null, node);
1453 if(node.files && node.files.first && node.parent &&
1454 !(!node.parent.parent &&
1455 (!strcmpi(node.name, "notes") || !strcmpi(node.name, "sources") ||
1456 !strcmpi(node.name, "src") || !strcmpi(node.name, "tools"))))
1457 row.collapsed = true;
1458 else if(node.type == folder)
1459 node.icon = openFolder;
1463 for(child : node.files)
1464 AddNode(child, row);
1468 void DeleteNode(ProjectNode projectNode)
1470 if(projectNode.files)
1473 while(child = projectNode.files.first)
1476 fileList.DeleteRow(projectNode.row);
1477 projectNode.Delete();
1480 bool ProjectSave(MenuItem selection, Modifiers mods)
1482 DataRow row = fileList.currentRow;
1483 ProjectNode node = row ? (ProjectNode)row.tag : null;
1484 Project prj = node ? node.project : null;
1487 prj.StopMonitoring();
1488 if(prj.Save(prj.filePath))
1490 Project modPrj = null;
1491 // ShowOutputBuildLog(true);
1492 // DisplayCompiler(compiler, false);
1493 // ProjectUpdateMakefileForAllConfigs(prj);
1494 prj.topNode.modified = false;
1495 for(p : ide.workspace.projects)
1497 if(p.topNode.modified)
1504 modifiedDocument = false;
1507 prj.StartMonitoring();
1512 bool ShowOutputBuildLog(bool cleanLog)
1514 OutputView output = ide.outputView;
1516 output.ShowClearSelectTab(build);
1519 output.SelectTab(build);
1526 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1527 ProjectConfig config = project.config;
1529 bool result = false;
1530 if(/*!IsProjectModified() ||*/ BuildInterrim(project, restart, compiler, config))
1532 // For Restart, compiler and config will only be used if for
1533 // whatever reason (if at all possible) the Debugger is in a
1534 // 'terminated' or 'none' state
1535 ide.debugger.Restart(compiler, config);
1545 ide.debugger.Resume();
1551 ide.debugger.Break();
1557 ide.debugger.Stop();
1561 bool DebugStepInto()
1563 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1564 ProjectConfig config = project.config;
1566 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config)))
1567 ide.debugger.StepInto(compiler, config);
1572 bool DebugStepOver(bool skip)
1574 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1575 ProjectConfig config = project.config;
1577 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config)))
1578 ide.debugger.StepOver(compiler, config, skip);
1584 bool DebugStepOut(bool skip)
1586 ide.debugger.StepOut(skip);
1590 void ImportFolder(ProjectNode toNode)
1594 //bool isFolder = toNode.type == folder;
1595 //bool isRes = toNode.isInResources;
1597 FileDialog fileDialog = importFileDialog;
1598 fileDialog.master = parent;
1599 if(fileDialog.Modal() == ok)
1601 ImportFolderFSI fsi { projectView = this };
1602 fsi.stack.Add(toNode);
1603 fsi.Iterate(fileDialog.filePath);
1609 ProjectNode NewFolder(ProjectNode parentNode, char * name, bool showProperties)
1613 ProjectNode folderNode;
1614 Project prj = parentNode.project;
1616 ProjectNode after = null;
1617 for(node : parentNode.files)
1619 if(node.type != folder)
1625 folderNode = parentNode.Add(prj, name, after, folder, folder, true);
1628 for(c = 0; c < 100; c++)
1631 sprintf(string, c ? "New Folder (%d)" : "New Folder", c);
1632 if((folderNode = parentNode.Add(prj, string, after, folder, folder, true)))
1639 NodeProperties nodeProperties;
1642 modifiedDocument = true;
1643 prj.topNode.modified = true;
1646 folderNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
1647 folderNode.row.tag = (int)folderNode;
1649 folderNode.row.SetData(null, folderNode);
1650 fileList.currentRow = folderNode.row;
1654 nodeProperties = NodeProperties
1656 parent, this, mode = newFolder, node = folderNode;
1657 position = { position.x + 100, position.y + 100 };
1659 nodeProperties.Create(); // Modal?
1667 void AddFiles(bool resources)
1669 FileDialog fileDialog = (!resources) ? this.fileDialog : resourceFileDialog;
1670 fileDialog.type = multiOpen;
1671 fileDialog.text = !resources ? $"Add Files to Project" : $"Add Resources to Project";
1672 fileDialog.master = parent;
1674 if(fileDialog.Modal() == ok)
1677 DataRow row = fileList.currentRow;
1678 ProjectNode parentNode = (ProjectNode)row.tag;
1679 bool addFailed = false;
1680 int numSelections = fileDialog.numSelections;
1681 char ** multiFilePaths = fileDialog.multiFilePaths;
1683 Array<String> nameConflictFiles { };
1685 for(c = 0; c < numSelections; c++)
1687 char * filePath = multiFilePaths[c];
1688 FileAttribs exists = FileExists(filePath);
1689 bool addThisFile = true;
1691 if(exists.isDirectory)
1692 addThisFile = false;
1695 if(MessageBox { master = ide, type = yesNo, text = filePath,
1696 contents = $"File doesn't exist. Create?" }.Modal() == yes)
1698 File f = FileOpen(filePath, write);
1706 MessageBox { master = ide, type = ok, text = filePath,
1707 contents = $"Couldn't create file."}.Modal();
1708 addThisFile = false;
1715 /*addFailed = */if(!AddFile(parentNode, filePath, resources, false))//;
1717 nameConflictFiles.Add(CopyString(filePath));
1725 char * part1 = $"The following file";
1726 char * opt1 = $" was ";
1727 char * opt2 = $"s were ";
1728 char * part2 = $"not added because of identical file name conflict within the project.\n\n";
1730 len += strlen(part1);
1731 len += strlen(part2);
1732 len += nameConflictFiles.count > 1 ? strlen(opt2) : strlen(opt1);
1733 for(s : nameConflictFiles)
1734 len += strlen(s) + 1;
1735 message = new char[len + 1];
1736 strcpy(message, part1);
1737 strcat(message, nameConflictFiles.count > 1 ? opt2 : opt1);
1738 strcat(message, part2);
1739 for(s : nameConflictFiles)
1742 strcat(message, "\n");
1744 MessageBox { master = ide, type = ok, text = $"Name Conflict",
1745 contents = message }.Modal();
1748 nameConflictFiles.Free();
1749 delete nameConflictFiles;
1753 ProjectNode AddFile(ProjectNode parentNode, char * filePath, bool resources, bool isTemporary)
1755 ProjectNode result = null;
1756 ProjectNode after = null;
1757 for(node : parentNode.files)
1759 if(node.type != folder && node.type != file && node.type)
1764 result = parentNode.Add(parentNode.project, filePath, after, file, NodeIcons::SelectFileIcon(filePath), !resources);
1770 modifiedDocument = true;
1771 parentNode.project.topNode.modified = true;
1772 parentNode.project.ModifiedAllConfigs(true, false, true, true);
1775 result.row = parentNode.row.AddRowAfter(after ? after.row : null);
1776 result.row.tag = (int)result;
1777 result.row.SetData(null, result);
1782 CodeEditor CreateNew(char * upper, char * lower, char * base, char * className)
1784 CodeEditor codeEditor = null;
1785 ProjectNode projectNode;
1786 ProjectNode after = null;
1787 DataRow row = fileList.currentRow;
1788 ProjectNode parentNode;
1791 if(!row) row = project.topNode.row;
1793 parentNode = (ProjectNode)row.tag;
1795 for(node : parentNode.files)
1797 if(node.type != folder && node.type != file && node.type)
1801 for(c = 1; c < 100; c++)
1804 sprintf(string, c ? "%s%d.ec" : "%s.ec", lower, c);
1805 if((projectNode = parentNode.Add(project, string, after, file, genFile, true)))
1811 char filePath[MAX_LOCATION];
1813 modifiedDocument = true;
1814 project.topNode.modified = true;
1816 project.ModifiedAllConfigs(true, false, false, true);
1817 projectNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
1818 projectNode.row.tag =(int)projectNode;
1820 projectNode.row.SetData(null, projectNode);
1821 fileList.currentRow = projectNode.row;
1823 strcpy(filePath, project.topNode.path);
1824 PathCat(filePath, projectNode.path);
1825 PathCat(filePath, projectNode.name);
1827 codeEditor = (CodeEditor)ide.FindWindow(filePath);
1830 Class baseClass = eSystem_FindClass(__thisModule, base);
1831 subclass(ClassDesignerBase) designerClass = eClass_GetDesigner(baseClass);
1834 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal);
1835 strcpy(name, projectNode.name);
1836 sprintf(name, "%s%d", upper, c);
1838 strcpy(className, name);
1840 designerClass.CreateNew(codeEditor.editBox, codeEditor.clientSize, name, base);
1842 //codeEditor.modifiedDocument = false;
1843 //codeEditor.designer.modifiedDocument = false;
1845 //Code_EnsureUpToDate(codeEditor);
1848 else // TODO: fix no symbols generated when ommiting {} for following else
1850 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal);
1854 codeEditor.ViewDesigner();
1855 codeEditor.codeModified = true;
1862 // Returns true if we opened something
1863 bool OpenSelectedNodes()
1865 bool result = false;
1869 fileList.GetMultiSelection(selection);
1870 for(item = selection.first; item; item = item.next)
1872 DataRow row = item.data;
1873 ProjectNode node = (ProjectNode)row.tag;
1874 if(node.type == file)
1881 selection.Free(null);
1885 void RemoveSelectedNodes()
1890 fileList.GetMultiSelection(selection);
1892 // Remove children of parents we're deleting
1893 for(item = selection.first; item; item = next)
1896 DataRow row = item.data;
1897 ProjectNode n, node = (ProjectNode)row.tag;
1898 bool remove = false;
1901 for(i = selection.first; i && !remove; i = i.next)
1903 ProjectNode iNode = (ProjectNode)((DataRow)i.data).tag;
1904 for(n = node.parent; n; n = n.parent)
1914 selection.Delete(item);
1917 for(item = selection.first; item; item = item.next)
1919 DataRow row = item.data;
1920 ProjectNode node = (ProjectNode)row.tag;
1921 ProjectNode resNode;
1922 for(resNode = node.parent; resNode; resNode = resNode.parent)
1923 if(resNode.type == resources)
1925 if(node.type == file)
1927 Project prj = node.project;
1929 modifiedDocument = true;
1930 prj.topNode.modified = true;
1932 prj.ModifiedAllConfigs(true, false, true, true);
1934 else if(node.type == folder)
1937 sprintf(message, $"Are you sure you want to remove the folder \"%s\"\n"
1938 "and all of its contents from the project?", node.name);
1939 if(MessageBox { master = ide, type = yesNo, text = $"Delete Folder", contents = message }.Modal() == yes)
1941 Project prj = node.project;
1942 if(node.containsFile)
1943 prj.ModifiedAllConfigs(true, false, true, true);
1945 modifiedDocument = true;
1946 prj.topNode.modified = true;
1949 else if(node.type == project && node != project.topNode && !buildInProgress)
1953 for(p : workspace.projects)
1955 if(p.topNode == node)
1961 sprintf(message, $"Are you sure you want to remove the \"%s\" project\n" "from this workspace?", node.name);
1962 if(MessageBox { master = ide, type = yesNo, text = $"Remove Project", contents = message }.Modal() == yes)
1967 workspace.RemoveProject(prj);
1968 //modifiedDocument = true; // when project view is a workspace view
1972 selection.Free(null);