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;
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 DebugStopForMake(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config)
617 // TOFIX: DebugStop is being abused and backfiring on us.
618 // It's supposed to be the 'Debug/Stop' item, not unloading executable or anything else
620 // configIsInDebugSession seems to be used for two OPPOSITE things:
621 // If we're debugging another config, we need to unload the executable!
622 // In building, we want to stop if we're debugging the 'same' executable
623 if(buildType != run) ///* && prj == project*/ && prj.configIsInDebugSession)
625 if(buildType == start || buildType == restart)
627 if(ide.debugger && ide.debugger.isPrepared)
628 result = DebugStop();
632 if(ide.project == prj && ide.debugger && ide.debugger.prjConfig == config && ide.debugger.isPrepared)
633 result = DebugStop();
639 bool Build(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config)
645 for(document = master.firstChild; document; document = document.next)
647 if(document.modifiedDocument)
649 ProjectNode node = GetNodeFromWindow(document, prj);
650 if(node && !document.MenuFileSave(null, 0))
659 DirExpression targetDir = prj.GetTargetDir(compiler, config);
661 DebugStopForMake(prj, buildType, compiler, config);
663 // TODO: Disabled until problems fixed... is it fixed?
664 if(buildType == rebuild || (config && config.compilingModified))
665 prj.Clean(compiler, config, false);
668 if(buildType == relink || (config && config.linkingModified))
670 char target[MAX_LOCATION];
672 strcpy(target, prj.topNode.path);
673 PathCat(target, targetDir.dir);
674 prj.CatTargetFileName(target, compiler, config);
675 if(FileExists(target))
678 if(config && config.symbolGenModified)
680 DirExpression objDir = prj.GetObjDir(compiler, config);
681 char fileName[MAX_LOCATION];
682 char moduleName[MAX_FILENAME];
683 strcpy(fileName, prj.topNode.path);
684 PathCatSlash(fileName, objDir.dir);
685 strcpy(moduleName, prj.moduleName);
686 strcat(moduleName, ".main.ec");
687 PathCatSlash(fileName, moduleName);
688 if(FileExists(fileName))
689 DeleteFile(fileName);
690 ChangeExtension(fileName, "c", fileName);
691 if(FileExists(fileName))
692 DeleteFile(fileName);
693 ChangeExtension(fileName, "o", fileName);
694 if(FileExists(fileName))
695 DeleteFile(fileName);
700 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
701 ide.AdjustBuildMenus();
702 ide.AdjustDebugMenus();
704 result = prj.Build(buildType == run, null, compiler, config);
708 config.compilingModified = false;
709 if(!ide.ShouldStopBuild())
710 config.linkingModified = false;
712 config.symbolGenModified = false;
714 buildInProgress = none;
715 ide.AdjustBuildMenus();
716 ide.AdjustDebugMenus();
718 ide.workspace.modified = true;
725 // ((( USER ACTIONS )))
727 // ************************************************************************
728 // *** Methods below should atomically start a process, and as such ***
729 // *** they can query compiler and config directly from ide and project ***
730 // *** but ONLY ONCE!!! ***
731 // ************************************************************************
733 bool ProjectBuild(MenuItem selection, Modifiers mods)
735 Project prj = project;
736 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
737 ProjectConfig config;
738 if(selection || !ide.activeClient)
740 DataRow row = fileList.currentRow;
741 ProjectNode node = row ? (ProjectNode)row.tag : null;
742 if(node) prj = node.project;
746 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
751 if(/*prj != project || */!prj.GetConfigIsInDebugSession(config) || !ide.DontTerminateDebugSession($"Project Build"))
753 BuildInterrim(prj, build, compiler, config);
759 bool ProjectLink(MenuItem selection, Modifiers mods)
761 Project prj = project;
762 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
763 ProjectConfig config;
764 if(selection || !ide.activeClient)
766 DataRow row = fileList.currentRow;
767 ProjectNode node = row ? (ProjectNode)row.tag : null;
768 if(node) prj = node.project;
772 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
777 if(!prj.GetConfigIsInDebugSession(config) ||
778 (!ide.DontTerminateDebugSession($"Project Link") && DebugStopForMake(prj, relink, compiler, config)))
780 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
782 ide.outputView.buildBox.Logf($"Relinking project %s using the %s configuration...\n", prj.name, GetConfigName(config));
784 config.linkingModified = true;
785 Build(prj, relink, compiler, config);
792 bool ProjectRebuild(MenuItem selection, Modifiers mods)
794 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
795 Project prj = project;
796 ProjectConfig config;
797 if(selection || !ide.activeClient)
799 DataRow row = fileList.currentRow;
800 ProjectNode node = row ? (ProjectNode)row.tag : null;
801 if(node) prj = node.project;
805 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
810 if(!prj.GetConfigIsInDebugSession(config) ||
811 (!ide.DontTerminateDebugSession($"Project Rebuild") && DebugStopForMake(prj, rebuild, compiler, config)))
813 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
815 ide.outputView.buildBox.Logf($"Rebuilding project %s using the %s configuration...\n", prj.name, GetConfigName(config));
818 config.compilingModified = true;
819 config.makingModified = true;
820 }*/ // -- should this still be used depite the new solution of BuildType?
821 Build(prj, rebuild, compiler, config);
828 bool ProjectClean(MenuItem selection, Modifiers mods)
830 Project prj = project;
831 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
832 ProjectConfig config;
833 if(selection || !ide.activeClient)
835 DataRow row = fileList.currentRow;
836 ProjectNode node = row ? (ProjectNode)row.tag : null;
837 if(node) prj = node.project;
841 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
846 if(!prj.GetConfigIsInDebugSession(config) ||
847 (!ide.DontTerminateDebugSession($"Project Clean") && DebugStopForMake(prj, clean, compiler, config)))
849 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
851 ide.outputView.buildBox.Logf($"Cleaning project %s using the %s configuration...\n", prj.name, GetConfigName(config));
853 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
854 ide.AdjustBuildMenus();
855 ide.AdjustDebugMenus();
857 prj.Clean(compiler, config, false);
858 buildInProgress = none;
859 ide.AdjustBuildMenus();
860 ide.AdjustDebugMenus();
867 bool ProjectRealClean(MenuItem selection, Modifiers mods)
869 Project prj = project;
870 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
871 ProjectConfig config;
872 if(selection || !ide.activeClient)
874 DataRow row = fileList.currentRow;
875 ProjectNode node = row ? (ProjectNode)row.tag : null;
876 if(node) prj = node.project;
880 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
885 if(!prj.GetConfigIsInDebugSession(config) ||
886 (!ide.DontTerminateDebugSession($"Project Real Clean") && DebugStopForMake(prj, clean, compiler, config)))
888 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
890 ide.outputView.buildBox.Logf($"Removing intermediate objects directory for project %s using the %s configuration...\n", prj.name, GetConfigName(config));
892 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
893 ide.AdjustBuildMenus();
894 ide.AdjustDebugMenus();
896 prj.Clean(compiler, config, true);
897 buildInProgress = none;
898 ide.AdjustBuildMenus();
899 ide.AdjustDebugMenus();
906 bool ProjectRegenerate(MenuItem selection, Modifiers mods)
908 Project prj = project;
909 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
910 if(selection || !ide.activeClient)
912 DataRow row = fileList.currentRow;
913 ProjectNode node = row ? (ProjectNode)row.tag : null;
919 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
924 ProjectPrepareMakefile(prj, force, true, true, compiler, prj.config);
929 void Compile(ProjectNode node)
931 char fileName[MAX_LOCATION];
932 char extension[MAX_EXTENSION];
934 Project prj = node.project;
935 ProjectConfig config = prj.config;
936 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
937 DirExpression objDir = prj.GetObjDir(compiler, config);
939 strcpy(fileName, prj.topNode.path);
940 PathCatSlash(fileName, objDir.dir);
941 PathCatSlash(fileName, node.name);
942 StripExtension(fileName);
943 strcat(fileName, ".o");
944 if(FileExists(fileName))
945 DeleteFile(fileName);
947 GetExtension(node.name, extension);
948 if(!strcmp(extension, "ec"))
950 // Delete generated C file
951 strcpy(fileName, prj.topNode.path);
952 PathCat(fileName, objDir.dir);
953 PathCat(fileName, node.name);
954 StripExtension(fileName);
955 strcat(fileName, ".c");
956 if(FileExists(fileName))
957 DeleteFile(fileName);
959 // Delete symbol file
960 strcpy(fileName, prj.topNode.path);
961 PathCat(fileName, node.path);
962 PathCat(fileName, node.name);
963 StripExtension(fileName);
964 strcat(fileName, ".sym");
965 if(FileExists(fileName))
966 DeleteFile(fileName);
971 // Check if we have to save
972 strcpy(fileName, prj.topNode.path);
973 PathCatSlash(fileName, node.path);
974 PathCatSlash(fileName, node.name);
975 for(document = ide.firstChild; document; document = document.next)
977 if(document.modifiedDocument)
979 char documentFileName[MAX_LOCATION];
980 if(!fstrcmp(GetSlashPathBuffer(documentFileName, document.fileName), fileName))
981 if(!document.MenuFileSave(null, 0))
986 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
988 if(!node.GetIsExcluded(config))
990 buildInProgress = compilingFile;
991 ide.AdjustBuildMenus();
993 //ide.outputView.ShowClearSelectTab(build);
994 // this stuff doesn't even appear
995 //ide.outputView.buildBox.Logf($"%s Compiler\n", compiler.name);
997 ide.outputView.buildBox.Logf($"Compiling single file %s in project %s using the %s configuration...\n", node.name, prj.name, config.name);
999 ide.outputView.buildBox.Logf($"Compiling single file %s in project %s...\n", node.name, prj.name);
1001 prj.Compile(node, compiler, config);
1002 buildInProgress = none;
1003 ide.AdjustBuildMenus();
1006 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
1012 bool ProjectNewFile(MenuItem selection, Modifiers mods)
1014 DataRow row = fileList.currentRow;
1017 char fileName[1024];
1018 char filePath[MAX_LOCATION];
1019 ProjectNode parentNode = (ProjectNode)row.tag;
1020 ProjectNode n, fileNode;
1021 parentNode.GetFileSysMatchingPath(filePath);
1022 MakePathRelative(filePath, parentNode.project.topNode.path, filePath);
1023 for(n = parentNode; n && n != parentNode.project.resNode; n = n.parent);
1024 sprintf(fileName, $"Untitled %d", documentID);
1025 fileNode = AddFile(parentNode, fileName, (bool)n, true);
1026 fileNode.path = CopyUnixPath(filePath);
1029 NodeProperties nodeProperties
1032 position = { position.x + 100, position.y + 100 };
1036 nodeProperties.Create(); // not modal?
1042 bool ProjectNewFolder(MenuItem selection, Modifiers mods)
1044 DataRow row = fileList.currentRow;
1047 ProjectNode parentNode = (ProjectNode)row.tag;
1048 NewFolder(parentNode, null, true);
1053 bool ResourcesAddFiles(MenuItem selection, Modifiers mods)
1059 bool ProjectAddFiles(MenuItem selection, Modifiers mods)
1065 bool ProjectImportFolder(MenuItem selection, Modifiers mods)
1067 DataRow row = fileList.currentRow;
1070 ProjectNode toNode = (ProjectNode)row.tag;
1071 ImportFolder(toNode);
1076 bool ProjectAddNewForm(MenuItem selection, Modifiers mods)
1078 CodeEditor codeEditor = CreateNew("Form", "form", "Window", null);
1079 codeEditor.EnsureUpToDate();
1083 bool ProjectAddNewGraph(MenuItem selection, Modifiers mods)
1085 CodeEditor codeEditor = CreateNew("Graph", "graph", "Block", null);
1087 codeEditor.EnsureUpToDate();
1091 bool ProjectRemove(MenuItem selection, Modifiers mods)
1093 DataRow row = fileList.currentRow;
1096 ProjectNode node = (ProjectNode)row.tag;
1097 if(node.type == project)
1098 RemoveSelectedNodes();
1103 bool ProjectUpdateMakefileForAllConfigs(Project project, bool cleanLog, bool displayCompiler)
1105 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1106 ShowOutputBuildLog(cleanLog);
1109 DisplayCompiler(compiler, false);
1111 for(config : project.configurations)
1113 ProjectPrepareMakefile(project, forceExists, false, false,
1121 bool MenuConfig(MenuItem selection, Modifiers mods)
1123 if(ProjectActiveConfig { master = parent, project = project }.Modal() == ok)
1128 bool MenuCompiler(MenuItem selection, Modifiers mods)
1130 ActiveCompilerDialog compilerDialog
1133 ideSettings = ideSettings, workspaceActiveCompiler = ide.workspace.compiler;
1135 incref compilerDialog;
1136 if(compilerDialog.Modal() == ok && strcmp(compilerDialog.workspaceActiveCompiler, ide.workspace.compiler))
1138 ide.workspace.compiler = compilerDialog.workspaceActiveCompiler;
1139 for(prj : ide.workspace.projects)
1140 ide.projectView.ProjectUpdateMakefileForAllConfigs(prj, true, true);
1142 delete compilerDialog;
1146 bool MenuSettings(MenuItem selection, Modifiers mods)
1148 ProjectNode node = GetSelectedNode(true);
1149 Project prj = node ? node.project : project;
1150 projectSettingsDialog = ProjectSettings { master = parent, project = prj, projectNode = node };
1151 projectSettingsDialog.Modal();
1158 bool FileProperties(MenuItem selection, Modifiers mods)
1160 DataRow row = fileList.currentRow;
1163 ProjectNode node = (ProjectNode)row.tag;
1164 NodeProperties { parent = parent, master = this, node = node,
1165 position = { position.x + 100, position.y + 100 } }.Create();
1170 bool FileOpenFile(MenuItem selection, Modifiers mods)
1172 OpenSelectedNodes();
1176 bool FileRemoveFile(MenuItem selection, Modifiers mods)
1178 RemoveSelectedNodes();
1182 bool FileCompile(MenuItem selection, Modifiers mods)
1184 DataRow row = fileList.currentRow;
1187 ProjectNode node = (ProjectNode)row.tag;
1193 Project GetSelectedProject(bool useSelection)
1195 Project prj = project;
1198 DataRow row = fileList.currentRow;
1199 ProjectNode node = row ? (ProjectNode)row.tag : null;
1206 ProjectNode GetSelectedNode(bool useSelection)
1208 ProjectNode node = null;
1211 DataRow row = fileList.currentRow;
1213 node = (ProjectNode)row.tag;
1218 bool MenuBrowseFolder(MenuItem selection, Modifiers mods)
1220 char folder[MAX_LOCATION];
1222 ProjectNode node = GetSelectedNode(true);
1224 node = project.topNode;
1227 strcpy(folder, prj.topNode.path);
1228 if(node != prj.topNode)
1229 PathCatSlash(folder, node.path);
1233 bool Run(MenuItem selection, Modifiers mods)
1235 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1236 ProjectConfig config = project.config;
1237 String args = new char[maxPathLen];
1239 if(ide.workspace.commandLineArgs)
1240 //ide.debugger.GetCommandLineArgs(args);
1241 strcpy(args, ide.workspace.commandLineArgs);
1242 if(ide.debugger.isActive)
1243 project.Run(args, compiler, config);
1244 /*else if(config.targetType == sharedLibrary || config.targetType == staticLibrary)
1245 MessageBox { master = ide, type = ok, text = "Run", contents = "Shared and static libraries cannot be run like executables." }.Modal();*/
1246 else if(BuildInterrim(project, run, compiler, config))
1247 project.Run(args, compiler, config);
1255 bool result = false;
1256 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1257 ProjectConfig config = project.config;
1258 TargetTypes targetType = project.GetTargetType(config);
1259 if(targetType == sharedLibrary || targetType == staticLibrary)
1260 MessageBox { master = ide, type = ok, text = $"Run", contents = $"Shared and static libraries cannot be run like executables." }.Modal();
1261 else if(project.GetCompress(config))
1262 MessageBox { master = ide, text = $"Starting Debug", contents = $"Debugging compressed applications is not supported\n" }.Modal();
1263 else if(project.GetDebug(config) ||
1264 MessageBox { master = ide, type = okCancel, text = $"Starting Debug", contents = $"Attempting to debug non-debug configuration\nProceed anyways?" }.Modal() == ok)
1266 if(/*!IsProjectModified() ||*/ BuildInterrim(project, start, compiler, config))
1268 if(compiler.type.isVC)
1270 //bool result = false;
1271 char oldwd[MAX_LOCATION];
1272 PathBackup pathBackup { };
1273 char command[MAX_LOCATION];
1275 ide.SetPath(false, compiler, config);
1277 GetWorkingDir(oldwd, sizeof(oldwd));
1278 ChangeWorkingDir(project.topNode.path);
1280 sprintf(command, "%s /useenv %s.sln /projectconfig \"%s|Win32\" /command \"%s\"" , "devenv", project.name, config.name, "Debug.Start");
1281 //ide.outputView.buildBox.Logf("command: %s\n", command);
1283 ChangeWorkingDir(oldwd);
1289 ide.debugger.Start(compiler, config);
1298 void GoToError(const char * line)
1302 while(isspace(*line)) line++;
1303 colon = strstr(line, ":");
1308 bool lookForLineNumber = true;
1310 // deal with linking error
1311 if(colon && colon[1] == ' ')
1313 colon = strstr(colon + 1, ":");
1314 if(colon && !colon[1])
1316 colon = strstr(line, ":");
1317 lookForLineNumber = false;
1319 else if(colon && !isdigit(colon[1]))
1322 colon = strstr(line, ":");
1325 // Don't be mistaken by the drive letter colon
1326 if(colon && (colon[1] == '/' || colon[1] == '\\'))
1327 colon = strstr(colon + 1, ":");
1328 if(colon && lookForLineNumber)
1332 char * par = RSearchString(line, "(", colon - line, true, false);
1333 if(par && strstr(par, ")"))
1335 else if((colon+1)[0] == ' ')
1337 // NOTE: This is the same thing as saying 'colon = line'
1338 for( ; colon != line; colon--)
1342 lineNumber = atoi(colon + 1);
1344 comma = strchr(colon, ',');
1346 col = atoi(comma+1);
1348 comma = strchr(colon+1, ':');
1350 col = atoi(comma+1);
1354 char moduleName[MAX_LOCATION], filePath[MAX_LOCATION];
1359 strncpy(moduleName, line, colon - line);
1360 moduleName[colon - line] = '\0';
1363 strcpy(moduleName, line);
1365 // Remove stuff in brackets
1367 bracket = strstr(moduleName, "(");
1368 if(bracket) *bracket = '\0';
1370 MakeSlashPath(moduleName);
1374 // Check if it's one of our modules
1375 ProjectNode node = project.topNode.Find(moduleName, false);
1378 strcpy(moduleName, node.path);
1379 PathCatSlash(moduleName, node.name);
1382 moduleName[0] = '\0';
1386 CodeEditor codeEditor;
1387 strcpy(filePath, project.topNode.path);
1388 PathCatSlash(filePath, moduleName);
1390 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
1393 char name[MAX_LOCATION];
1394 // TOFIX: Improve on this, don't use only filename, make a function
1395 if(ide && ide.workspace)
1397 for(prj : ide.workspace.projects)
1399 if(prj.topNode.FindWithPath(moduleName, false))
1401 strcpy(filePath, prj.topNode.path);
1402 PathCatSlash(filePath, moduleName);
1403 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
1410 if(codeEditor && lineNumber)
1412 EditBox editBox = codeEditor.editBox;
1413 editBox.GoToLineNum(lineNumber - 1);
1414 editBox.GoToPosition(editBox.line, lineNumber - 1, col ? (col - 1) : 0);
1421 bool OpenNode(ProjectNode node)
1423 char filePath[MAX_LOCATION];
1424 node.GetFullFilePath(filePath);
1425 return ide.OpenFile(filePath, normal, true/*false Why was it opening hidden?*/, null, something, normal) ? true : false;
1428 void AddNode(ProjectNode node, DataRow addTo)
1430 DataRow row = addTo ? addTo.AddRow() : fileList.AddRow();
1432 row.tag = (int)node;
1435 if(node.type == resources)
1438 row.SetData(null, node);
1440 if(node.files && node.files.first && node.parent &&
1441 !(!node.parent.parent &&
1442 (!strcmpi(node.name, "notes") || !strcmpi(node.name, "sources") ||
1443 !strcmpi(node.name, "src") || !strcmpi(node.name, "tools"))))
1444 row.collapsed = true;
1445 else if(node.type == folder)
1446 node.icon = openFolder;
1450 for(child : node.files)
1451 AddNode(child, row);
1455 void DeleteNode(ProjectNode projectNode)
1457 if(projectNode.files)
1460 while(child = projectNode.files.first)
1463 fileList.DeleteRow(projectNode.row);
1464 projectNode.Delete();
1467 bool ProjectSave(MenuItem selection, Modifiers mods)
1469 DataRow row = fileList.currentRow;
1470 ProjectNode node = row ? (ProjectNode)row.tag : null;
1471 Project prj = node ? node.project : null;
1474 if(prj.Save(prj.filePath))
1476 // ProjectUpdateMakefileForAllConfigs(prj, true, true);
1477 prj.topNode.modified = false;
1479 for(p : ide.workspace.projects)
1481 if(p.topNode.modified)
1488 modifiedDocument = false;
1495 bool ShowOutputBuildLog(bool cleanLog)
1497 OutputView output = ide.outputView;
1499 output.ShowClearSelectTab(build);
1502 output.SelectTab(build);
1509 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1510 ProjectConfig config = project.config;
1512 bool result = false;
1513 if(/*!IsProjectModified() ||*/ BuildInterrim(project, restart, compiler, config))
1515 // For Restart, compiler and config will only be used if for
1516 // whatever reason (if at all possible) the Debugger is in a
1517 // 'terminated' or 'none' state
1518 ide.debugger.Restart(compiler, config);
1528 ide.debugger.Resume();
1534 ide.debugger.Break();
1540 ide.debugger.Stop();
1544 bool DebugStepInto()
1546 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1547 ProjectConfig config = project.config;
1549 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config)))
1550 ide.debugger.StepInto(compiler, config);
1555 bool DebugStepOver(bool skip)
1557 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1558 ProjectConfig config = project.config;
1560 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config)))
1561 ide.debugger.StepOver(compiler, config, skip);
1567 bool DebugStepOut(bool skip)
1569 ide.debugger.StepOut(skip);
1573 void ImportFolder(ProjectNode toNode)
1577 //bool isFolder = toNode.type == folder;
1578 //bool isRes = toNode.isInResources;
1580 FileDialog fileDialog = importFileDialog;
1581 fileDialog.master = parent;
1582 if(fileDialog.Modal() == ok)
1584 ImportFolderFSI fsi { projectView = this };
1585 fsi.stack.Add(toNode);
1586 fsi.Iterate(fileDialog.filePath);
1592 ProjectNode NewFolder(ProjectNode parentNode, char * name, bool showProperties)
1596 ProjectNode folderNode;
1597 Project prj = parentNode.project;
1599 ProjectNode after = null;
1600 for(node : parentNode.files)
1602 if(node.type != folder)
1608 folderNode = parentNode.Add(prj, name, after, folder, folder, true);
1611 for(c = 0; c < 100; c++)
1614 sprintf(string, c ? "New Folder (%d)" : "New Folder", c);
1615 if((folderNode = parentNode.Add(prj, string, after, folder, folder, true)))
1622 NodeProperties nodeProperties;
1625 modifiedDocument = true;
1626 prj.topNode.modified = true;
1629 folderNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
1630 folderNode.row.tag = (int)folderNode;
1632 folderNode.row.SetData(null, folderNode);
1633 fileList.currentRow = folderNode.row;
1637 nodeProperties = NodeProperties
1639 parent, this, mode = newFolder, node = folderNode;
1640 position = { position.x + 100, position.y + 100 };
1642 nodeProperties.Create(); // Modal?
1650 void AddFiles(bool resources)
1652 FileDialog fileDialog = (!resources) ? this.fileDialog : resourceFileDialog;
1653 fileDialog.type = multiOpen;
1654 fileDialog.text = !resources ? $"Add Files to Project" : $"Add Resources to Project";
1655 fileDialog.master = parent;
1657 if(fileDialog.Modal() == ok)
1660 DataRow row = fileList.currentRow;
1661 ProjectNode parentNode = (ProjectNode)row.tag;
1662 bool addFailed = false;
1663 int numSelections = fileDialog.numSelections;
1664 char ** multiFilePaths = fileDialog.multiFilePaths;
1666 Array<String> nameConflictFiles { };
1668 for(c = 0; c < numSelections; c++)
1670 char * filePath = multiFilePaths[c];
1671 FileAttribs exists = FileExists(filePath);
1672 bool addThisFile = true;
1674 if(exists.isDirectory)
1675 addThisFile = false;
1678 if(MessageBox { master = ide, type = yesNo, text = filePath,
1679 contents = $"File doesn't exist. Create?" }.Modal() == yes)
1681 File f = FileOpen(filePath, write);
1689 MessageBox { master = ide, type = ok, text = filePath,
1690 contents = $"Couldn't create file."}.Modal();
1691 addThisFile = false;
1698 /*addFailed = */if(!AddFile(parentNode, filePath, resources, false))//;
1700 nameConflictFiles.Add(CopyString(filePath));
1708 char * part1 = $"The following file";
1709 char * opt1 = $" was ";
1710 char * opt2 = $"s were ";
1711 char * part2 = $"not added because of identical file name conflict within the project.\n\n";
1713 len += strlen(part1);
1714 len += strlen(part2);
1715 len += nameConflictFiles.count > 1 ? strlen(opt2) : strlen(opt1);
1716 for(s : nameConflictFiles)
1717 len += strlen(s) + 1;
1718 message = new char[len + 1];
1719 strcpy(message, part1);
1720 strcat(message, nameConflictFiles.count > 1 ? opt2 : opt1);
1721 strcat(message, part2);
1722 for(s : nameConflictFiles)
1725 strcat(message, "\n");
1727 MessageBox { master = ide, type = ok, text = $"Name Conflict",
1728 contents = message }.Modal();
1731 nameConflictFiles.Free();
1732 delete nameConflictFiles;
1736 ProjectNode AddFile(ProjectNode parentNode, char * filePath, bool resources, bool isTemporary)
1738 ProjectNode result = null;
1739 ProjectNode after = null;
1740 for(node : parentNode.files)
1742 if(node.type != folder && node.type != file && node.type)
1747 result = parentNode.Add(parentNode.project, filePath, after, file, NodeIcons::SelectFileIcon(filePath), !resources);
1753 modifiedDocument = true;
1754 parentNode.project.topNode.modified = true;
1755 parentNode.project.ModifiedAllConfigs(true, false, true, true);
1758 result.row = parentNode.row.AddRowAfter(after ? after.row : null);
1759 result.row.tag = (int)result;
1760 result.row.SetData(null, result);
1765 CodeEditor CreateNew(char * upper, char * lower, char * base, char * className)
1767 CodeEditor codeEditor = null;
1768 ProjectNode projectNode;
1769 ProjectNode after = null;
1770 DataRow row = fileList.currentRow;
1771 ProjectNode parentNode;
1774 if(!row) row = project.topNode.row;
1776 parentNode = (ProjectNode)row.tag;
1778 for(node : parentNode.files)
1780 if(node.type != folder && node.type != file && node.type)
1784 for(c = 1; c < 100; c++)
1787 sprintf(string, c ? "%s%d.ec" : "%s.ec", lower, c);
1788 if((projectNode = parentNode.Add(project, string, after, file, genFile, true)))
1794 char filePath[MAX_LOCATION];
1796 modifiedDocument = true;
1797 project.topNode.modified = true;
1799 project.ModifiedAllConfigs(true, false, false, true);
1800 projectNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
1801 projectNode.row.tag =(int)projectNode;
1803 projectNode.row.SetData(null, projectNode);
1804 fileList.currentRow = projectNode.row;
1806 strcpy(filePath, project.topNode.path);
1807 PathCat(filePath, projectNode.path);
1808 PathCat(filePath, projectNode.name);
1810 codeEditor = (CodeEditor)ide.FindWindow(filePath);
1813 Class baseClass = eSystem_FindClass(__thisModule, base);
1814 subclass(ClassDesignerBase) designerClass = eClass_GetDesigner(baseClass);
1817 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal);
1818 strcpy(name, projectNode.name);
1819 sprintf(name, "%s%d", upper, c);
1821 strcpy(className, name);
1823 designerClass.CreateNew(codeEditor.editBox, codeEditor.clientSize, name, base);
1825 //codeEditor.modifiedDocument = false;
1826 //codeEditor.designer.modifiedDocument = false;
1828 //Code_EnsureUpToDate(codeEditor);
1831 else // TODO: fix no symbols generated when ommiting {} for following else
1833 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal);
1837 codeEditor.ViewDesigner();
1838 codeEditor.codeModified = true;
1845 // Returns true if we opened something
1846 bool OpenSelectedNodes()
1848 bool result = false;
1852 fileList.GetMultiSelection(selection);
1853 for(item = selection.first; item; item = item.next)
1855 DataRow row = item.data;
1856 ProjectNode node = (ProjectNode)row.tag;
1857 if(node.type == file)
1864 selection.Free(null);
1868 void RemoveSelectedNodes()
1873 fileList.GetMultiSelection(selection);
1875 // Remove children of parents we're deleting
1876 for(item = selection.first; item; item = next)
1879 DataRow row = item.data;
1880 ProjectNode n, node = (ProjectNode)row.tag;
1881 bool remove = false;
1884 for(i = selection.first; i && !remove; i = i.next)
1886 ProjectNode iNode = (ProjectNode)((DataRow)i.data).tag;
1887 for(n = node.parent; n; n = n.parent)
1897 selection.Delete(item);
1900 for(item = selection.first; item; item = item.next)
1902 DataRow row = item.data;
1903 ProjectNode node = (ProjectNode)row.tag;
1904 ProjectNode resNode;
1905 for(resNode = node.parent; resNode; resNode = resNode.parent)
1906 if(resNode.type == resources)
1908 if(node.type == file)
1910 Project prj = node.project;
1912 modifiedDocument = true;
1913 prj.topNode.modified = true;
1915 prj.ModifiedAllConfigs(true, false, true, true);
1917 else if(node.type == folder)
1920 sprintf(message, $"Are you sure you want to remove the folder \"%s\"\n"
1921 "and all of its contents from the project?", node.name);
1922 if(MessageBox { master = ide, type = yesNo, text = $"Delete Folder", contents = message }.Modal() == yes)
1924 Project prj = node.project;
1925 if(node.containsFile)
1926 prj.ModifiedAllConfigs(true, false, true, true);
1928 modifiedDocument = true;
1929 prj.topNode.modified = true;
1932 else if(node.type == project && node != project.topNode && !buildInProgress)
1936 for(p : workspace.projects)
1938 if(p.topNode == node)
1944 sprintf(message, $"Are you sure you want to remove the \"%s\" project\n" "from this workspace?", node.name);
1945 if(MessageBox { master = ide, type = yesNo, text = $"Remove Project", contents = message }.Modal() == yes)
1950 workspace.RemoveProject(prj);
1951 //modifiedDocument = true; // when project view is a workspace view
1955 selection.Free(null);