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 };
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;
160 for(c = 0; c < NodeIcons::enumSize; c++)
162 icons[c] = BitmapResource { iconNames[c], alphaBlend = true };
163 AddResource(icons[c]);
165 fileList.AddField(DataField { dataType = class(ProjectNode), freeData = false, userData = this });
171 ide.DestroyTemporaryProjectDir();
181 multiSelect = true, fullRowSelect = false, hasVertScroll = true, hasHorzScroll = true;
182 borderStyle = deep, parent = this, collapseControl = true, treeBranches = true;
183 anchor = Anchor { left = 0, right = 0, top = 0 , bottom = 0 };
185 background = projectViewBackground;
186 foreground = projectViewText;
187 selectionColor = selectionColor, selectionText = selectionText;
188 stippleColor = skyBlue;
190 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
192 if(!active) Update(null);
193 return ListBox::OnActivate(active, previous, goOnWithActivation, direct);
196 bool NotifyDoubleClick(ListBox listBox, int x, int y, Modifiers mods)
198 // Prevent the double click from reactivating the project view (returns false if we opened something)
199 return !OpenSelectedNodes();
202 bool NotifyRightClick(ListBox listBox, int x, int y, Modifiers mods)
204 DataRow row = listBox.currentRow;
207 ProjectNode node = (ProjectNode)row.tag;
208 if(node.type == NodeTypes::project || node.type == resources || node.type == file || node.type == folder)
210 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 };
314 bool NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch)
318 ProjectNode node = (ProjectNode)row.tag;
321 case altEnter: case Key { keyPadEnter, alt = true }:
323 NodeProperties { parent = parent, master = this,
324 position = { position.x + 100, position.y + 100 }, node = node }.Create();
327 case enter: case keyPadEnter:
330 for(resNode = node.parent; resNode; resNode = resNode.parent)
331 if(resNode.type == resources)
333 if(node.type == project || (node.type == folder && !resNode))
338 else if(node.type == resources || node.type == folder)
347 if(node.type == project || node.type == folder || node.type == resources)
356 if(node.type == project || node.type == folder || node.type == resources)
358 NewFolder(node, null, true);
365 if(node.type == file)
367 FileCompile(null, (Modifiers)key);
372 case Key { space, shift = true }:
375 if(node.type == NodeTypes::project)
378 for(p : workspace.projects)
380 if(p.topNode == node)
386 prj.RotateActiveConfig(!key.shift);
397 case enter: case keyPadEnter: OpenSelectedNodes(); break;
398 case del: RemoveSelectedNodes(); break;
401 Window activeClient = ide.activeClient;
403 activeClient.Activate();
405 ide.RepositionWindows(true);
412 bool NotifyCollapse(ListBox listBox, DataRow row, bool collapsed)
414 ProjectNode node = (ProjectNode)row.tag;
415 if(node.type == folder)
416 node.icon = collapsed ? folder : openFolder;
421 FileDialog importFileDialog { autoCreate = false, type = selectDir, text = $"Import Folder" };
422 FileDialog projectFileDialog
424 autoCreate = false, filters = projectFilters.array, sizeFilters = projectFilters.count * sizeof(FileFilter);
425 types = projectTypes.array, sizeTypes = projectTypes.count * sizeof(FileType);
427 FileDialog fileDialog
429 autoCreate = false, mayNotExist = true, filters = fileFilters.array, sizeFilters = fileFilters.count * sizeof(FileFilter);
431 FileDialog resourceFileDialog
433 autoCreate = false, mayNotExist = true, filters = resourceFilters.array, sizeFilters = resourceFilters.count * sizeof(FileFilter);
436 Menu fileMenu { menu, $"File", f };
437 MenuItem { fileMenu, $"Save", s, Key { s, ctrl = true }, NotifySelect = MenuFileSave };
438 // MenuItem { fileMenu, "Save As...", a, NotifySelect = MenuFileSaveAs };
440 bool OnClose(bool parentClosing)
442 if(!parentClosing && visible)
454 //if(ide.findInFilesDialog && ide.findInFilesDialog.created && ide.findInFilesDialog.mode != directory)
455 // ide.findInFilesDialog.SearchStop();
457 ide.outputView.buildBox.Clear();
458 ide.outputView.debugBox.Clear();
459 //ide.outputView.findBox.Clear();
460 ide.callStackView.Clear();
461 ide.watchesView.Clear();
462 ide.threadsView.Clear();
463 ide.breakpointsView.Clear();
464 ide.outputView.ShowClearSelectTab(find); // why this?
467 bool OnSaveFile(char * fileName)
469 for(prj : ide.workspace.projects)
471 if(prj.topNode.modified && prj.Save(prj.filePath))
473 // ProjectUpdateMakefileForAllConfigs(prj, true, true);
474 prj.topNode.modified = false;
477 modifiedDocument = false;
482 bool IsModuleInProject(char * filePath)
484 char moduleName[MAX_FILENAME]; //, modulePath[MAX_LOCATION];
485 GetLastDirectory(filePath, moduleName);
486 return project.topNode.Find(moduleName, false) != null;
489 bool GetRelativePath(char * filePath, char * relativePath)
491 return project.GetRelativePath(filePath, relativePath);
494 ProjectNode GetNodeFromWindow(Window document, Project project)
496 if(document.fileName)
498 char winFileName[MAX_LOCATION];
499 char * documentFileName = GetSlashPathBuffer(winFileName, document.fileName);
500 for(p : ide.workspace.projects)
502 Project prj = project ? project : p;
504 char moduleName[MAX_FILENAME], modulePath[MAX_LOCATION];
505 GetLastDirectory(document.fileName, moduleName);
507 if((node = prj.topNode.Find(moduleName, false)))
509 strcpy(modulePath, prj.topNode.path);
510 PathCatSlash(modulePath, node.path);
511 PathCatSlash(modulePath, node.name);
512 if(!fstrcmp(documentFileName, modulePath))
523 // ((( UTILITY FUNCTIONS )))
525 // ************************************************************************
526 // *** These methods below are part of a sequence of events, and as ***
527 // *** such they must be passed the current compiler and project config ***
528 // ************************************************************************
529 bool DisplayCompiler(CompilerConfig compiler, bool cleanLog)
531 ShowOutputBuildLog(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;
559 ShowOutputBuildLog(cleanLog);
562 DisplayCompiler(compiler, false);
564 strcpy(makefilePath, project.topNode.path);
565 project.CatMakeFileName(makefileName, compiler, config);
566 PathCatSlash(makefilePath, makefileName);
568 exists = FileExists(makefilePath);
569 if((method == normal && (!exists || config.makingModified/*|| project.topNode.modified*/)) ||
570 (method == forceExists && exists) ||
571 method == force) // || config.makingModified || makefileDirty
575 ide.statusBar.text = $"Generating Makefile & Dependencies..."; // Dependencies?
578 if((method == normal && !exists) || (method == force && !exists))
579 action = $"Generating ";
580 else if(method == force)
581 action = $"Regenerating ";
582 else if(method == normal || method == forceExists)
583 action = $"Updating ";
587 reason = $"Makefile doesn't exist. ";
588 else if(project.topNode.modified)
589 reason = $"Project has been modified. ";
593 //logBox.Logf("%s\n", makefileName);
594 logBox.Logf($"%s - %s%smakefile for %s config...\n", makefileName, reason, action, GetConfigName(config));
595 project.GenerateMakefile(null, false, null, compiler, config);
597 ide.statusBar.text = null;
604 bool BuildInterrim(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config)
606 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
608 ide.outputView.buildBox.Logf($"Building project %s using the %s configuration...\n", prj.name, GetConfigName(config));
609 return Build(prj, buildType, compiler, config);
614 bool Build(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config)
620 for(document = master.firstChild; document; document = document.next)
622 if(document.modifiedDocument)
624 ProjectNode node = GetNodeFromWindow(document, prj);
625 if(node && !document.MenuFileSave(null, 0))
634 DirExpression targetDir = prj.GetTargetDir(compiler, config);
636 // TOFIX: DebugStop is being abused and backfiring on us.
637 // It's supposed to be the 'Debug/Stop' item, not unloading executable or anything else
639 // configIsInDebugSession seems to be used for two OPPOSITE things:
640 // If we're debugging another config, we need to unload the executable!
641 // In building, we want to stop if we're debugging the 'same' executable
642 if(buildType != run) ///* && prj == project*/ && prj.configIsInDebugSession)
644 if(buildType == start || buildType == restart)
646 if(ide.debugger && ide.debugger.isPrepared)
653 if(ide.project == prj && ide.debugger && ide.debugger.prjConfig == config && ide.debugger.isPrepared)
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(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
776 ide.outputView.buildBox.Logf($"Relinking project %s using the %s configuration...\n", prj.name, GetConfigName(config));
778 config.linkingModified = true;
779 Build(prj, relink, compiler, config);
785 bool ProjectRebuild(MenuItem selection, Modifiers mods)
787 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
788 Project prj = project;
789 ProjectConfig config;
790 if(selection || !ide.activeClient)
792 DataRow row = fileList.currentRow;
793 ProjectNode node = row ? (ProjectNode)row.tag : null;
794 if(node) prj = node.project;
798 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
803 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
805 ide.outputView.buildBox.Logf($"Rebuilding project %s using the %s configuration...\n", prj.name, GetConfigName(config));
808 config.compilingModified = true;
809 config.makingModified = true;
810 }*/ // -- should this still be used depite the new solution of BuildType?
811 Build(prj, rebuild, compiler, config);
817 bool ProjectClean(MenuItem selection, Modifiers mods)
819 Project prj = project;
820 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
821 ProjectConfig config;
822 if(selection || !ide.activeClient)
824 DataRow row = fileList.currentRow;
825 ProjectNode node = row ? (ProjectNode)row.tag : null;
826 if(node) prj = node.project;
830 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
835 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
837 ide.outputView.buildBox.Logf($"Cleaning project %s using the %s configuration...\n", prj.name, GetConfigName(config));
839 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
840 ide.AdjustBuildMenus();
842 prj.Clean(compiler, config, false);
843 buildInProgress = none;
844 ide.AdjustBuildMenus();
850 bool ProjectRealClean(MenuItem selection, Modifiers mods)
852 Project prj = project;
853 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
854 ProjectConfig config;
855 if(selection || !ide.activeClient)
857 DataRow row = fileList.currentRow;
858 ProjectNode node = row ? (ProjectNode)row.tag : null;
859 if(node) prj = node.project;
863 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
868 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
870 ide.outputView.buildBox.Logf($"Removing intermediate objects directory for project %s using the %s configuration...\n", prj.name, GetConfigName(config));
872 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
873 ide.AdjustBuildMenus();
875 prj.Clean(compiler, config, true);
876 buildInProgress = none;
877 ide.AdjustBuildMenus();
883 bool ProjectRegenerate(MenuItem selection, Modifiers mods)
885 Project prj = project;
886 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
887 if(selection || !ide.activeClient)
889 DataRow row = fileList.currentRow;
890 ProjectNode node = row ? (ProjectNode)row.tag : null;
896 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
901 ProjectPrepareMakefile(prj, force, true, true, compiler, prj.config);
906 void Compile(ProjectNode node)
908 char fileName[MAX_LOCATION];
909 char extension[MAX_EXTENSION];
911 Project prj = node.project;
912 ProjectConfig config = prj.config;
913 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
914 DirExpression objDir = prj.GetObjDir(compiler, config);
916 strcpy(fileName, prj.topNode.path);
917 PathCatSlash(fileName, objDir.dir);
918 PathCatSlash(fileName, node.name);
919 StripExtension(fileName);
920 strcat(fileName, ".o");
921 if(FileExists(fileName))
922 DeleteFile(fileName);
924 GetExtension(node.name, extension);
925 if(!strcmp(extension, "ec"))
927 // Delete generated C file
928 strcpy(fileName, prj.topNode.path);
929 PathCat(fileName, objDir.dir);
930 PathCat(fileName, node.name);
931 StripExtension(fileName);
932 strcat(fileName, ".c");
933 if(FileExists(fileName))
934 DeleteFile(fileName);
936 // Delete symbol file
937 strcpy(fileName, prj.topNode.path);
938 PathCat(fileName, node.path);
939 PathCat(fileName, node.name);
940 StripExtension(fileName);
941 strcat(fileName, ".sym");
942 if(FileExists(fileName))
943 DeleteFile(fileName);
948 // Check if we have to save
949 strcpy(fileName, prj.topNode.path);
950 PathCatSlash(fileName, node.path);
951 PathCatSlash(fileName, node.name);
952 for(document = ide.firstChild; document; document = document.next)
954 if(document.modifiedDocument)
956 char documentFileName[MAX_LOCATION];
957 if(!fstrcmp(GetSlashPathBuffer(documentFileName, document.fileName), fileName))
958 if(!document.MenuFileSave(null, 0))
963 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
965 if(!node.GetIsExcluded(config))
967 buildInProgress = compilingFile;
968 ide.AdjustBuildMenus();
970 //ide.outputView.ShowClearSelectTab(build);
971 // this stuff doesn't even appear
972 //ide.outputView.buildBox.Logf($"%s Compiler\n", compiler.name);
974 ide.outputView.buildBox.Logf($"Compiling single file %s in project %s using the %s configuration...\n", node.name, prj.name, config.name);
976 ide.outputView.buildBox.Logf($"Compiling single file %s in project %s...\n", node.name, prj.name);
978 prj.Compile(node, compiler, config);
979 buildInProgress = none;
980 ide.AdjustBuildMenus();
983 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
989 bool ProjectNewFile(MenuItem selection, Modifiers mods)
991 DataRow row = fileList.currentRow;
995 char filePath[MAX_LOCATION];
996 ProjectNode parentNode = (ProjectNode)row.tag;
997 ProjectNode n, fileNode;
998 parentNode.GetFileSysMatchingPath(filePath);
999 MakePathRelative(filePath, parentNode.project.topNode.path, filePath);
1000 for(n = parentNode; n && n != parentNode.project.resNode; n = n.parent);
1001 sprintf(fileName, $"Untitled %d", documentID);
1002 fileNode = AddFile(parentNode, fileName, (bool)n, true);
1003 fileNode.path = CopyUnixPath(filePath);
1006 NodeProperties nodeProperties
1009 position = { position.x + 100, position.y + 100 };
1013 nodeProperties.Create(); // not modal?
1019 bool ProjectNewFolder(MenuItem selection, Modifiers mods)
1021 DataRow row = fileList.currentRow;
1024 ProjectNode parentNode = (ProjectNode)row.tag;
1025 NewFolder(parentNode, null, true);
1030 bool ResourcesAddFiles(MenuItem selection, Modifiers mods)
1036 bool ProjectAddFiles(MenuItem selection, Modifiers mods)
1042 bool ProjectImportFolder(MenuItem selection, Modifiers mods)
1044 DataRow row = fileList.currentRow;
1047 ProjectNode toNode = (ProjectNode)row.tag;
1048 ImportFolder(toNode);
1053 bool ProjectAddNewForm(MenuItem selection, Modifiers mods)
1055 CodeEditor codeEditor = CreateNew("Form", "form", "Window", null);
1056 codeEditor.EnsureUpToDate();
1060 bool ProjectAddNewGraph(MenuItem selection, Modifiers mods)
1062 CodeEditor codeEditor = CreateNew("Graph", "graph", "Block", null);
1064 codeEditor.EnsureUpToDate();
1068 bool ProjectRemove(MenuItem selection, Modifiers mods)
1070 DataRow row = fileList.currentRow;
1073 ProjectNode node = (ProjectNode)row.tag;
1074 if(node.type == project)
1075 RemoveSelectedNodes();
1080 bool ProjectUpdateMakefileForAllConfigs(Project project, bool cleanLog, bool displayCompiler)
1082 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1083 ShowOutputBuildLog(cleanLog);
1086 DisplayCompiler(compiler, false);
1088 for(config : project.configurations)
1090 ProjectPrepareMakefile(project, forceExists, false, false,
1098 bool MenuConfig(MenuItem selection, Modifiers mods)
1100 if(ProjectActiveConfig { master = parent, project = project }.Modal() == ok)
1105 bool MenuCompiler(MenuItem selection, Modifiers mods)
1107 ActiveCompilerDialog compilerDialog
1110 ideSettings = ideSettings, workspaceActiveCompiler = ide.workspace.compiler;
1112 incref compilerDialog;
1113 if(compilerDialog.Modal() == ok && strcmp(compilerDialog.workspaceActiveCompiler, ide.workspace.compiler))
1115 ide.workspace.compiler = compilerDialog.workspaceActiveCompiler;
1116 for(prj : ide.workspace.projects)
1117 ide.projectView.ProjectUpdateMakefileForAllConfigs(prj, true, true);
1119 delete compilerDialog;
1123 bool MenuSettings(MenuItem selection, Modifiers mods)
1125 ProjectNode node = GetSelectedNode(true);
1126 Project prj = node ? node.project : project;
1127 projectSettingsDialog = ProjectSettings { master = parent, project = prj, projectNode = node };
1128 projectSettingsDialog.Modal();
1135 bool FileProperties(MenuItem selection, Modifiers mods)
1137 DataRow row = fileList.currentRow;
1140 ProjectNode node = (ProjectNode)row.tag;
1141 NodeProperties { parent = parent, master = this, node = node,
1142 position = { position.x + 100, position.y + 100 } }.Create();
1147 bool FileOpenFile(MenuItem selection, Modifiers mods)
1149 OpenSelectedNodes();
1153 bool FileRemoveFile(MenuItem selection, Modifiers mods)
1155 RemoveSelectedNodes();
1159 bool FileCompile(MenuItem selection, Modifiers mods)
1161 DataRow row = fileList.currentRow;
1164 ProjectNode node = (ProjectNode)row.tag;
1170 Project GetSelectedProject(bool useSelection)
1172 Project prj = project;
1175 DataRow row = fileList.currentRow;
1176 ProjectNode node = row ? (ProjectNode)row.tag : null;
1183 ProjectNode GetSelectedNode(bool useSelection)
1185 ProjectNode node = null;
1188 DataRow row = fileList.currentRow;
1190 node = (ProjectNode)row.tag;
1195 bool MenuBrowseFolder(MenuItem selection, Modifiers mods)
1197 char folder[MAX_LOCATION];
1199 ProjectNode node = GetSelectedNode(true);
1201 node = project.topNode;
1204 strcpy(folder, prj.topNode.path);
1205 if(node != prj.topNode)
1206 PathCatSlash(folder, node.path);
1210 bool Run(MenuItem selection, Modifiers mods)
1212 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1213 ProjectConfig config = project.config;
1214 String args = new char[maxPathLen];
1216 if(ide.workspace.commandLineArgs)
1217 //ide.debugger.GetCommandLineArgs(args);
1218 strcpy(args, ide.workspace.commandLineArgs);
1219 if(ide.debugger.isActive)
1220 project.Run(args, compiler, config);
1221 /*else if(config.targetType == sharedLibrary || config.targetType == staticLibrary)
1222 MessageBox { master = ide, type = ok, text = "Run", contents = "Shared and static libraries cannot be run like executables." }.Modal();*/
1223 else if(BuildInterrim(project, run, compiler, config))
1224 project.Run(args, compiler, config);
1232 bool result = false;
1233 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1234 ProjectConfig config = project.config;
1235 TargetTypes targetType = project.GetTargetType(config);
1236 if(targetType == sharedLibrary || targetType == staticLibrary)
1237 MessageBox { master = ide, type = ok, text = $"Run", contents = $"Shared and static libraries cannot be run like executables." }.Modal();
1238 else if(project.GetCompress(config))
1239 MessageBox { master = ide, text = $"Starting Debug", contents = $"Debugging compressed applications is not supported\n" }.Modal();
1240 else if(project.GetDebug(config) ||
1241 MessageBox { master = ide, type = okCancel, text = $"Starting Debug", contents = $"Attempting to debug non-debug configuration\nProceed anyways?" }.Modal() == ok)
1243 if(/*!IsProjectModified() ||*/ BuildInterrim(project, start, compiler, config))
1245 if(compiler.type.isVC)
1247 //bool result = false;
1248 char oldwd[MAX_LOCATION];
1249 PathBackup pathBackup { };
1250 char command[MAX_LOCATION];
1252 ide.SetPath(false, compiler, config);
1254 GetWorkingDir(oldwd, sizeof(oldwd));
1255 ChangeWorkingDir(project.topNode.path);
1257 sprintf(command, "%s /useenv %s.sln /projectconfig \"%s|Win32\" /command \"%s\"" , "devenv", project.name, config.name, "Debug.Start");
1258 //ide.outputView.buildBox.Logf("command: %s\n", command);
1260 ChangeWorkingDir(oldwd);
1266 ide.debugger.Start(compiler, config);
1275 void GoToError(const char * line)
1279 while(isspace(*line)) line++;
1280 colon = strstr(line, ":");
1285 bool lookForLineNumber = true;
1287 // deal with linking error
1288 if(colon && colon[1] == ' ')
1290 colon = strstr(colon + 1, ":");
1291 if(colon && !colon[1])
1293 colon = strstr(line, ":");
1294 lookForLineNumber = false;
1296 else if(colon && !isdigit(colon[1]))
1299 colon = strstr(line, ":");
1302 // Don't be mistaken by the drive letter colon
1303 if(colon && (colon[1] == '/' || colon[1] == '\\'))
1304 colon = strstr(colon + 1, ":");
1305 if(colon && lookForLineNumber)
1309 char * par = RSearchString(line, "(", colon - line, true, false);
1310 if(par && strstr(par, ")"))
1312 else if((colon+1)[0] == ' ')
1314 // NOTE: This is the same thing as saying 'colon = line'
1315 for( ; colon != line; colon--)
1319 lineNumber = atoi(colon + 1);
1321 comma = strchr(colon, ',');
1323 col = atoi(comma+1);
1325 comma = strchr(colon+1, ':');
1327 col = atoi(comma+1);
1331 char moduleName[MAX_LOCATION], filePath[MAX_LOCATION];
1336 strncpy(moduleName, line, colon - line);
1337 moduleName[colon - line] = '\0';
1340 strcpy(moduleName, line);
1342 // Remove stuff in brackets
1344 bracket = strstr(moduleName, "(");
1345 if(bracket) *bracket = '\0';
1347 MakeSlashPath(moduleName);
1351 // Check if it's one of our modules
1352 ProjectNode node = project.topNode.Find(moduleName, false);
1355 strcpy(moduleName, node.path);
1356 PathCatSlash(moduleName, node.name);
1359 moduleName[0] = '\0';
1363 CodeEditor codeEditor;
1364 strcpy(filePath, project.topNode.path);
1365 PathCatSlash(filePath, moduleName);
1367 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
1370 char name[MAX_LOCATION];
1371 // TOFIX: Improve on this, don't use only filename, make a function
1372 if(ide && ide.workspace)
1374 for(prj : ide.workspace.projects)
1376 if(prj.topNode.FindWithPath(moduleName, false))
1378 strcpy(filePath, prj.topNode.path);
1379 PathCatSlash(filePath, moduleName);
1380 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
1387 if(codeEditor && lineNumber)
1389 EditBox editBox = codeEditor.editBox;
1390 editBox.GoToLineNum(lineNumber - 1);
1391 editBox.GoToPosition(editBox.line, lineNumber - 1, col ? (col - 1) : 0);
1398 bool OpenNode(ProjectNode node)
1400 char filePath[MAX_LOCATION];
1401 node.GetFullFilePath(filePath);
1402 return ide.OpenFile(filePath, normal, true/*false Why was it opening hidden?*/, null, something, normal) ? true : false;
1405 void AddNode(ProjectNode node, DataRow addTo)
1407 DataRow row = addTo ? addTo.AddRow() : fileList.AddRow();
1409 row.tag = (int)node;
1412 if(node.type == resources)
1415 row.SetData(null, node);
1417 if(node.files && node.files.first && node.parent &&
1418 !(!node.parent.parent &&
1419 (!strcmpi(node.name, "notes") || !strcmpi(node.name, "sources") ||
1420 !strcmpi(node.name, "src") || !strcmpi(node.name, "tools"))))
1421 row.collapsed = true;
1422 else if(node.type == folder)
1423 node.icon = openFolder;
1427 for(child : node.files)
1428 AddNode(child, row);
1432 void DeleteNode(ProjectNode projectNode)
1434 if(projectNode.files)
1437 while(child = projectNode.files.first)
1440 fileList.DeleteRow(projectNode.row);
1441 projectNode.Delete();
1444 bool ProjectSave(MenuItem selection, Modifiers mods)
1446 DataRow row = fileList.currentRow;
1447 ProjectNode node = row ? (ProjectNode)row.tag : null;
1448 Project prj = node ? node.project : null;
1451 if(prj.Save(prj.filePath))
1453 // ProjectUpdateMakefileForAllConfigs(prj, true, true);
1454 prj.topNode.modified = false;
1456 for(p : ide.workspace.projects)
1458 if(p.topNode.modified)
1465 modifiedDocument = false;
1472 bool ShowOutputBuildLog(bool cleanLog)
1474 OutputView output = ide.outputView;
1476 output.ShowClearSelectTab(build);
1479 output.SelectTab(build);
1486 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1487 ProjectConfig config = project.config;
1489 bool result = false;
1490 if(/*!IsProjectModified() ||*/ BuildInterrim(project, restart, compiler, config))
1492 // For Restart, compiler and config will only be used if for
1493 // whatever reason (if at all possible) the Debugger is in a
1494 // 'terminated' or 'none' state
1495 ide.debugger.Restart(compiler, config);
1505 ide.debugger.Resume();
1511 ide.debugger.Break();
1517 ide.debugger.Stop();
1521 bool DebugStepInto()
1523 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1524 ProjectConfig config = project.config;
1526 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config)))
1527 ide.debugger.StepInto(compiler, config);
1532 bool DebugStepOver(bool skip)
1534 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1535 ProjectConfig config = project.config;
1537 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config)))
1538 ide.debugger.StepOver(compiler, config, skip);
1544 bool DebugStepOut(bool skip)
1546 ide.debugger.StepOut(skip);
1550 void ImportFolder(ProjectNode toNode)
1554 //bool isFolder = toNode.type == folder;
1555 //bool isRes = toNode.isInResources;
1557 FileDialog fileDialog = importFileDialog;
1558 fileDialog.master = parent;
1559 if(fileDialog.Modal() == ok)
1561 ImportFolderFSI fsi { projectView = this };
1562 fsi.stack.Add(toNode);
1563 fsi.Iterate(fileDialog.filePath);
1569 ProjectNode NewFolder(ProjectNode parentNode, char * name, bool showProperties)
1573 ProjectNode folderNode;
1574 Project prj = parentNode.project;
1576 ProjectNode after = null;
1577 for(node : parentNode.files)
1579 if(node.type != folder)
1585 folderNode = parentNode.Add(prj, name, after, folder, folder, true);
1588 for(c = 0; c < 100; c++)
1591 sprintf(string, c ? "New Folder (%d)" : "New Folder", c);
1592 if((folderNode = parentNode.Add(prj, string, after, folder, folder, true)))
1599 NodeProperties nodeProperties;
1602 modifiedDocument = true;
1603 prj.topNode.modified = true;
1606 folderNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
1607 folderNode.row.tag = (int)folderNode;
1609 folderNode.row.SetData(null, folderNode);
1610 fileList.currentRow = folderNode.row;
1614 nodeProperties = NodeProperties
1616 parent, this, mode = newFolder, node = folderNode;
1617 position = { position.x + 100, position.y + 100 };
1619 nodeProperties.Create(); // Modal?
1627 void AddFiles(bool resources)
1629 FileDialog fileDialog = (!resources) ? this.fileDialog : resourceFileDialog;
1630 fileDialog.type = multiOpen;
1631 fileDialog.text = !resources ? $"Add Files to Project" : $"Add Resources to Project";
1632 fileDialog.master = parent;
1634 if(fileDialog.Modal() == ok)
1637 DataRow row = fileList.currentRow;
1638 ProjectNode parentNode = (ProjectNode)row.tag;
1639 bool addFailed = false;
1640 int numSelections = fileDialog.numSelections;
1641 char ** multiFilePaths = fileDialog.multiFilePaths;
1643 Array<String> nameConflictFiles { };
1645 for(c = 0; c < numSelections; c++)
1647 char * filePath = multiFilePaths[c];
1648 FileAttribs exists = FileExists(filePath);
1649 bool addThisFile = true;
1651 if(exists.isDirectory)
1652 addThisFile = false;
1655 if(MessageBox { master = ide, type = yesNo, text = filePath,
1656 contents = $"File doesn't exist. Create?" }.Modal() == yes)
1658 File f = FileOpen(filePath, write);
1666 MessageBox { master = ide, type = ok, text = filePath,
1667 contents = $"Couldn't create file."}.Modal();
1668 addThisFile = false;
1675 /*addFailed = */if(!AddFile(parentNode, filePath, resources, false))//;
1677 nameConflictFiles.Add(CopyString(filePath));
1685 char * part1 = $"The following file";
1686 char * opt1 = $" was ";
1687 char * opt2 = $"s were ";
1688 char * part2 = $"not added because of identical file name conflict within the project.\n\n";
1690 len += strlen(part1);
1691 len += strlen(part2);
1692 len += nameConflictFiles.count > 1 ? strlen(opt2) : strlen(opt1);
1693 for(s : nameConflictFiles)
1694 len += strlen(s) + 1;
1695 message = new char[len + 1];
1696 strcpy(message, part1);
1697 strcat(message, nameConflictFiles.count > 1 ? opt2 : opt1);
1698 strcat(message, part2);
1699 for(s : nameConflictFiles)
1702 strcat(message, "\n");
1704 MessageBox { master = ide, type = ok, text = $"Name Conflict",
1705 contents = message }.Modal();
1708 nameConflictFiles.Free();
1709 delete nameConflictFiles;
1713 ProjectNode AddFile(ProjectNode parentNode, char * filePath, bool resources, bool isTemporary)
1715 ProjectNode result = null;
1716 ProjectNode after = null;
1717 for(node : parentNode.files)
1719 if(node.type != folder && node.type != file && node.type)
1724 result = parentNode.Add(parentNode.project, filePath, after, file, NodeIcons::SelectFileIcon(filePath), !resources);
1730 modifiedDocument = true;
1731 parentNode.project.topNode.modified = true;
1732 parentNode.project.ModifiedAllConfigs(true, false, true, true);
1735 result.row = parentNode.row.AddRowAfter(after ? after.row : null);
1736 result.row.tag = (int)result;
1737 result.row.SetData(null, result);
1742 CodeEditor CreateNew(char * upper, char * lower, char * base, char * className)
1744 CodeEditor codeEditor = null;
1745 ProjectNode projectNode;
1746 ProjectNode after = null;
1747 DataRow row = fileList.currentRow;
1748 ProjectNode parentNode;
1751 if(!row) row = project.topNode.row;
1753 parentNode = (ProjectNode)row.tag;
1755 for(node : parentNode.files)
1757 if(node.type != folder && node.type != file && node.type)
1761 for(c = 1; c < 100; c++)
1764 sprintf(string, c ? "%s%d.ec" : "%s.ec", lower, c);
1765 if((projectNode = parentNode.Add(project, string, after, file, genFile, true)))
1771 char filePath[MAX_LOCATION];
1773 modifiedDocument = true;
1774 project.topNode.modified = true;
1776 project.ModifiedAllConfigs(true, false, false, true);
1777 projectNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
1778 projectNode.row.tag =(int)projectNode;
1780 projectNode.row.SetData(null, projectNode);
1781 fileList.currentRow = projectNode.row;
1783 strcpy(filePath, project.topNode.path);
1784 PathCat(filePath, projectNode.path);
1785 PathCat(filePath, projectNode.name);
1787 codeEditor = (CodeEditor)ide.FindWindow(filePath);
1790 Class baseClass = eSystem_FindClass(__thisModule, base);
1791 subclass(ClassDesignerBase) designerClass = eClass_GetDesigner(baseClass);
1794 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal);
1795 strcpy(name, projectNode.name);
1796 sprintf(name, "%s%d", upper, c);
1798 strcpy(className, name);
1800 designerClass.CreateNew(codeEditor.editBox, codeEditor.clientSize, name, base);
1802 //codeEditor.modifiedDocument = false;
1803 //codeEditor.designer.modifiedDocument = false;
1805 //Code_EnsureUpToDate(codeEditor);
1808 else // TODO: fix no symbols generated when ommiting {} for following else
1810 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal);
1814 codeEditor.ViewDesigner();
1815 codeEditor.codeModified = true;
1822 // Returns true if we opened something
1823 bool OpenSelectedNodes()
1825 bool result = false;
1829 fileList.GetMultiSelection(selection);
1830 for(item = selection.first; item; item = item.next)
1832 DataRow row = item.data;
1833 ProjectNode node = (ProjectNode)row.tag;
1834 if(node.type == file)
1841 selection.Free(null);
1845 void RemoveSelectedNodes()
1850 fileList.GetMultiSelection(selection);
1852 // Remove children of parents we're deleting
1853 for(item = selection.first; item; item = next)
1856 DataRow row = item.data;
1857 ProjectNode n, node = (ProjectNode)row.tag;
1858 bool remove = false;
1861 for(i = selection.first; i && !remove; i = i.next)
1863 ProjectNode iNode = (ProjectNode)((DataRow)i.data).tag;
1864 for(n = node.parent; n; n = n.parent)
1874 selection.Delete(item);
1877 for(item = selection.first; item; item = item.next)
1879 DataRow row = item.data;
1880 ProjectNode node = (ProjectNode)row.tag;
1881 ProjectNode resNode;
1882 for(resNode = node.parent; resNode; resNode = resNode.parent)
1883 if(resNode.type == resources)
1885 if(node.type == file)
1887 Project prj = node.project;
1889 modifiedDocument = true;
1890 prj.topNode.modified = true;
1892 prj.ModifiedAllConfigs(true, false, true, true);
1894 else if(node.type == folder)
1897 sprintf(message, $"Are you sure you want to remove the folder \"%s\"\n"
1898 "and all of its contents from the project?", node.name);
1899 if(MessageBox { master = ide, type = yesNo, text = $"Delete Folder", contents = message }.Modal() == yes)
1901 Project prj = node.project;
1902 if(node.containsFile)
1903 prj.ModifiedAllConfigs(true, false, true, true);
1905 modifiedDocument = true;
1906 prj.topNode.modified = true;
1909 else if(node.type == project && node != project.topNode && !buildInProgress)
1913 for(p : workspace.projects)
1915 if(p.topNode == node)
1921 sprintf(message, $"Are you sure you want to remove the \"%s\" project\n" "from this workspace?", node.name);
1922 if(MessageBox { master = ide, type = yesNo, text = $"Remove Project", contents = message }.Modal() == yes)
1927 workspace.RemoveProject(prj);
1928 //modifiedDocument = true; // when project view is a workspace view
1932 selection.Free(null);