3 import "FileSystemIterator"
5 class ImportFolderFSI : NormalFileSystemIterator
7 ProjectView projectView;
8 Array<ProjectNode> stack { };
10 bool OnFolder(char * folderPath)
12 char name[MAX_LOCATION];
13 ProjectNode parentNode = stack.lastIterator.data;
15 GetLastDirectory(folderPath, name);
16 folder = parentNode.FindSpecial(name, false, true, true);
18 folder = projectView.NewFolder(parentNode, name, false);
23 void OutFolder(char * folderPath, bool isRoot)
25 stack.lastIterator.Remove(); //stack.Remove();
28 bool OnFile(char * filePath)
30 ProjectNode parentNode = stack.lastIterator.data;
31 projectView.AddFile(parentNode, filePath, parentNode.isInResources, false);
36 static Array<FileFilter> fileFilters
38 { $"eC/C/C++ Files (*.ec, *.eh, *.c, *.cpp, *.cc, *.cxx, *.h, *.hpp, *.hh, *.hxx)", "ec, eh, c, cpp, cc, cxx, h, hpp, hh, hxx" },
39 { $"eC/C/C++ Source Files (*.ec, *.c, *.cpp, *.cc, *.cxx)", "ec, eh, c, cpp, cc, cxx" },
40 { $"Header Files for eC/C/C++ (*.eh, *.h, *.hpp, *.hh, *.hxx)", "eh, h, hpp, hh, hxx" },
41 { $"All files", null }
44 static Array<FileFilter> resourceFilters
46 { $"Image Files (*.jpg, *.jpeg, *.bmp, *.pcx, *.png,*.gif)", "jpg, jpeg, bmp, pcx, png, gif" },
47 { $"3D Studio Model Files (*.3ds)", "3ds" },
48 { $"Translations (*.mo)", "mo" },
49 { $"All files", null }
52 static Array<FileFilter> projectFilters
54 { $"Project Files (*.epj)", ProjectExtension },
55 { $"Workspace Files (*.ews)", WorkspaceExtension }
58 static Array<FileType> projectTypes
60 { $"Ecere IDE Project", ProjectExtension },
61 { $"Ecere IDE Workspace", WorkspaceExtension }
64 static char * iconNames[] =
66 "<:ecere>mimeTypes/file.png", /*genFile*/
67 "<:ecere>mimeTypes/textEcereWorkspace.png", /*ewsFile*/
68 "<:ecere>mimeTypes/textEcereProject.png", /*epjFile*/
69 "<:ecere>places/folder.png", /*folder*/
70 "<:ecere>status/folderOpen.png", /*openFolder*/
71 "<:ecere>mimeTypes/textEcereSource.png", /*ecFile*/
72 "<:ecere>mimeTypes/textEcereHeader.png", /*ehFile*/
73 "<:ecere>mimeTypes/textCSource.png", /*cFile*/
74 "<:ecere>mimeTypes/textCHeader.png", /*hFile*/
75 "<:ecere>mimeTypes/textC++Source.png", /*cppFile*/
76 "<:ecere>mimeTypes/textC++Header.png", /*hppFile*/
77 "<:ecere>mimeTypes/text.png", /*textFile*/
78 "<:ecere>mimeTypes/textHyperTextMarkup.png", /*webFile*/
79 "<:ecere>mimeTypes/image.png", /*pictureFile*/
80 "<:ecere>status/audioVolumeHigh.png", /*soundFile*/
81 "<:ecere>mimeTypes/package.png", /*archiveFile*/
82 "<:ecere>mimeTypes/packageSoftware.png", /*packageFile*/
83 "<:ecere>mimeTypes/packageOpticalDisc.png", /*opticalMediaImageFile*/
84 "<:ecere>mimeTypes/file.png" /*mFile*/ //TODO: create icon for mfile
87 enum PrepareMakefileMethod { normal, force, forceExists };
89 enum BuildType { build, rebuild, relink, run, start, restart, clean };
92 none, buildingMainProject, buildingSecondaryProject, compilingFile;
94 property bool { get { return this != none; } }
95 //property bool actualBuild { get { return this == buildingMainProject || this == buildingSecondaryProject; } }
98 class ProjectView : Window
101 //hasMinimize = true;
103 borderStyle = sizable;
104 hasHorzScroll = true;
105 hasVertScroll = true;
108 anchor = Anchor { left = 0, top = 0, bottom = 0 };
111 //hasMinimize = true;
112 saveDialog = projectFileDialog;
115 BuildState buildInProgress;
116 BitmapResource icons[NodeIcons];
119 property Workspace workspace
125 for(prj : workspace.projects)
127 DeleteNode(prj.topNode);
129 workspace.projects.Free();
130 ide.debugger.CleanUp();
135 fileDialog.currentDirectory = workspace.workspaceDir;
136 resourceFileDialog.currentDirectory = workspace.workspaceDir;
137 for(prj : workspace.projects)
138 AddNode(prj.topNode, null);
139 ide.statusBar.text = $"Generating Makefile & Dependencies...";
141 for(prj : workspace.projects)
142 prj.ModifiedAllConfigs(true, false, false, false);
143 ide.statusBar.text = $"Initializing Debugger"; app.UpdateDisplay();
144 ide.statusBar.text = null;
148 get { return workspace; }
151 bool drawingInProjectSettingsDialog;
152 bool drawingInProjectSettingsDialogHeader;
153 ProjectSettings projectSettingsDialog;
161 for(c = 0; c < NodeIcons::enumSize; c++)
163 icons[c] = BitmapResource { iconNames[c], alphaBlend = true };
164 AddResource(icons[c]);
166 fileList.AddField(DataField { dataType = class(ProjectNode), freeData = false, userData = this });
172 ide.DestroyTemporaryProjectDir();
182 multiSelect = true, fullRowSelect = false, hasVertScroll = true, hasHorzScroll = true;
183 borderStyle = deep, parent = this, collapseControl = true, treeBranches = true;
184 anchor = Anchor { left = 0, right = 0, top = 0 , bottom = 0 };
186 background = projectViewBackground;
187 foreground = projectViewText;
188 selectionColor = selectionColor, selectionText = selectionText;
189 stippleColor = skyBlue;
191 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
193 if(!active) Update(null);
194 return ListBox::OnActivate(active, previous, goOnWithActivation, direct);
197 bool NotifyDoubleClick(ListBox listBox, int x, int y, Modifiers mods)
199 // Prevent the double click from reactivating the project view (returns false if we opened something)
200 return !OpenSelectedNodes();
203 bool NotifyRightClick(ListBox listBox, int x, int y, Modifiers mods)
205 DataRow row = listBox.currentRow;
208 ProjectNode node = (ProjectNode)row.tag;
209 if(node.type == NodeTypes::project || node.type == resources || node.type == file || node.type == folder)
211 bool buildMenuUnavailable = buildInProgress;
212 Menu popupContent { };
214 if(node.type == NodeTypes::project)
216 //if(node == ((Project)workspace.projects.first).topNode)
218 MenuItem { popupContent, $"Build", b, NotifySelect = ProjectBuild }.disabled = buildMenuUnavailable;
219 MenuItem { popupContent, $"Relink", l, NotifySelect = ProjectLink }.disabled = buildMenuUnavailable;
220 MenuItem { popupContent, $"Rebuild", r, NotifySelect = ProjectRebuild }.disabled = buildMenuUnavailable;
221 MenuItem { popupContent, $"Clean", c, NotifySelect = ProjectClean }.disabled = buildMenuUnavailable;
222 MenuItem { popupContent, $"Real Clean", d, NotifySelect = ProjectRealClean }.disabled = buildMenuUnavailable;
223 MenuItem { popupContent, $"Regenerate Makefile", m, NotifySelect = ProjectRegenerate }.disabled = buildMenuUnavailable;
224 MenuDivider { popupContent };
226 MenuItem { popupContent, $"New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
227 MenuItem { popupContent, $"New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
228 MenuItem { popupContent, $"Import Folder...", i, NotifySelect = ProjectImportFolder };
229 MenuItem { popupContent, $"Add Files to Project...", f, NotifySelect = ProjectAddFiles };
230 MenuDivider { popupContent };
231 MenuItem { popupContent, $"Add New Form...", o, NotifySelect = ProjectAddNewForm };
232 // MenuItem { popupContent, "Add New Behavior Graph...", g, NotifySelect = ProjectAddNewGraph };
233 MenuDivider { popupContent };
234 if(node != ((Project)workspace.projects.first).topNode)
236 MenuItem { popupContent, $"Remove project from workspace", r, NotifySelect = ProjectRemove }.disabled = buildMenuUnavailable;
237 MenuDivider { popupContent };
239 MenuItem { popupContent, $"Active Configuration...", s, Key { f5, alt = true } , NotifySelect = MenuConfig };
240 MenuItem { popupContent, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
241 MenuDivider { popupContent };
242 MenuItem { popupContent, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
243 MenuDivider { popupContent };
244 MenuItem { popupContent, $"Save", v, Key { s, ctrl = true }, NotifySelect = ProjectSave }.disabled = !node.modified;
245 MenuDivider { popupContent };
246 MenuItem { popupContent, $"Properties...", p, Key { enter, alt = true }, NotifySelect = FileProperties };
248 else if(node.type == resources)
250 MenuItem { popupContent, $"New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
251 MenuItem { popupContent, $"New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
252 MenuItem { popupContent, $"Import Folder...", i, NotifySelect = ProjectImportFolder };
253 MenuItem { popupContent, $"Add Resources to Project...", f, NotifySelect = ResourcesAddFiles };
254 MenuItem { popupContent, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
255 MenuDivider { popupContent };
256 MenuItem { popupContent, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
257 MenuItem { popupContent, $"Properties...", p, Key { enter, alt = true }, NotifySelect = FileProperties };
259 else if(node.type == file)
261 MenuItem { popupContent, $"Open", o, NotifySelect = FileOpenFile };
262 MenuItem { popupContent, $"Compile", c, Key { f7, ctrl = true}, NotifySelect = FileCompile }.disabled = buildMenuUnavailable;
263 MenuDivider { popupContent };
264 MenuItem { popupContent, $"Remove", r, NotifySelect = FileRemoveFile };
265 MenuDivider { popupContent };
266 MenuItem { popupContent, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
267 MenuDivider { popupContent };
268 MenuItem { popupContent, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
269 MenuItem { popupContent, $"Properties..", p, Key { enter, alt = true }, NotifySelect = FileProperties };
271 else if(node.type == folder)
273 bool isInResources = node.isInResources;
275 MenuItem { popupContent, $"New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
276 MenuItem { popupContent, $"New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
277 MenuItem { popupContent, $"Import Folder...", i, NotifySelect = ProjectImportFolder };
280 MenuItem { popupContent, $"Add Resources to Folder...", f, NotifySelect = ResourcesAddFiles };
284 MenuItem { popupContent, $"Add Files to Folder...", f, NotifySelect = ProjectAddFiles };
288 MenuDivider { popupContent };
289 MenuItem { popupContent, $"Add New Form...", o, NotifySelect = ProjectAddNewForm };
290 MenuItem { popupContent, $"Add New Behavior Graph...", g, NotifySelect = ProjectAddNewGraph };
292 MenuDivider { popupContent };
293 MenuItem { popupContent, $"Remove", r, NotifySelect = FileRemoveFile };
294 MenuDivider { popupContent };
295 MenuItem { popupContent, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
296 MenuDivider { popupContent };
297 MenuItem { popupContent, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
298 MenuItem { popupContent, $"Properties...", p, Key { enter, alt = true }, NotifySelect = FileProperties };
303 master = this, menu = popupContent;
305 x + clientStart.x + absPosition.x - app.desktop.position.x,
306 y + clientStart.y + absPosition.y - app.desktop.position.y };
308 void NotifyDestroyed(Window window, DialogResult result)
319 bool NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch)
323 ProjectNode node = (ProjectNode)row.tag;
326 case altEnter: case Key { keyPadEnter, alt = true }:
328 NodeProperties { parent = parent, master = this,
329 position = { position.x + 100, position.y + 100 }, node = node }.Create();
332 case enter: case keyPadEnter:
335 for(resNode = node.parent; resNode; resNode = resNode.parent)
336 if(resNode.type == resources)
338 if(node.type == project || (node.type == folder && !resNode))
343 else if(node.type == resources || node.type == folder)
352 if(node.type == project || node.type == folder || node.type == resources)
361 if(node.type == project || node.type == folder || node.type == resources)
363 NewFolder(node, null, true);
370 if(node.type == file)
372 FileCompile(null, (Modifiers)key);
377 case Key { space, shift = true }:
380 if(node.type == NodeTypes::project)
383 for(p : workspace.projects)
385 if(p.topNode == node)
391 prj.RotateActiveConfig(!key.shift);
402 case enter: case keyPadEnter: OpenSelectedNodes(); break;
403 case del: RemoveSelectedNodes(); break;
406 Window activeClient = ide.activeClient;
408 activeClient.Activate();
410 ide.RepositionWindows(true);
417 bool NotifyCollapse(ListBox listBox, DataRow row, bool collapsed)
419 ProjectNode node = (ProjectNode)row.tag;
420 if(node.type == folder)
421 node.icon = collapsed ? folder : openFolder;
426 FileDialog importFileDialog { autoCreate = false, type = selectDir, text = $"Import Folder" };
427 FileDialog projectFileDialog
429 autoCreate = false, filters = projectFilters.array, sizeFilters = projectFilters.count * sizeof(FileFilter);
430 types = projectTypes.array, sizeTypes = projectTypes.count * sizeof(FileType);
432 FileDialog fileDialog
434 autoCreate = false, mayNotExist = true, filters = fileFilters.array, sizeFilters = fileFilters.count * sizeof(FileFilter);
436 FileDialog resourceFileDialog
438 autoCreate = false, mayNotExist = true, filters = resourceFilters.array, sizeFilters = resourceFilters.count * sizeof(FileFilter);
441 Menu fileMenu { menu, $"File", f };
442 MenuItem { fileMenu, $"Save", s, Key { s, ctrl = true }, NotifySelect = MenuFileSave };
443 // MenuItem { fileMenu, "Save As...", a, NotifySelect = MenuFileSaveAs };
445 bool OnClose(bool parentClosing)
447 if(!parentClosing && visible)
459 //if(ide.findInFilesDialog && ide.findInFilesDialog.created && ide.findInFilesDialog.mode != directory)
460 // ide.findInFilesDialog.SearchStop();
462 ide.outputView.buildBox.Clear();
463 ide.outputView.debugBox.Clear();
464 //ide.outputView.findBox.Clear();
465 ide.callStackView.Clear();
466 ide.watchesView.Clear();
467 ide.threadsView.Clear();
468 ide.breakpointsView.Clear();
469 ide.outputView.ShowClearSelectTab(find); // why this?
472 bool OnSaveFile(char * fileName)
474 for(prj : ide.workspace.projects)
476 if(prj.topNode.modified && prj.Save(prj.filePath))
478 // ShowOutputBuildLog(true);
479 // DisplayCompiler(compiler, false);
480 // ProjectUpdateMakefileForAllConfigs(prj);
481 prj.topNode.modified = false;
484 modifiedDocument = false;
489 bool IsModuleInProject(char * filePath)
491 char moduleName[MAX_FILENAME]; //, modulePath[MAX_LOCATION];
492 GetLastDirectory(filePath, moduleName);
493 return project.topNode.Find(moduleName, false) != null;
496 bool GetRelativePath(char * filePath, char * relativePath)
498 return project.GetRelativePath(filePath, relativePath);
501 ProjectNode GetNodeFromWindow(Window document, Project project)
503 if(document.fileName)
505 char winFileName[MAX_LOCATION];
506 char * documentFileName = GetSlashPathBuffer(winFileName, document.fileName);
507 for(p : ide.workspace.projects)
509 Project prj = project ? project : p;
511 if((node = prj.topNode.FindByFullPath(documentFileName, false)))
519 // ((( UTILITY FUNCTIONS )))
521 // ************************************************************************
522 // *** These methods below are part of a sequence of events, and as ***
523 // *** such they must be passed the current compiler and project config ***
524 // ************************************************************************
525 bool DisplayCompiler(CompilerConfig compiler, bool cleanLog)
527 ide.outputView.buildBox.Logf($"%s Compiler\n", compiler ? compiler.name : $"{problem with compiler selection}");
530 bool ProjectPrepareForToolchain(Project project, PrepareMakefileMethod method, bool cleanLog, bool displayCompiler,
531 CompilerConfig compiler, ProjectConfig config)
534 char message[MAX_F_STRING];
535 LogBox logBox = ide.outputView.buildBox;
537 ShowOutputBuildLog(cleanLog);
540 DisplayCompiler(compiler, false);
542 ProjectPrepareMakefile(project, method, false, false, compiler, config);
546 bool ProjectPrepareMakefile(Project project, PrepareMakefileMethod method, bool cleanLog, bool displayCompiler,
547 CompilerConfig compiler, ProjectConfig config)
549 char makefilePath[MAX_LOCATION];
550 char makefileName[MAX_LOCATION];
552 LogBox logBox = ide.outputView.buildBox;
555 DisplayCompiler(compiler, false);
557 strcpy(makefilePath, project.topNode.path);
558 project.CatMakeFileName(makefileName, compiler, config);
559 PathCatSlash(makefilePath, makefileName);
561 exists = FileExists(makefilePath);
562 if((method == normal && (!exists || config.makingModified/*|| project.topNode.modified*/)) ||
563 (method == forceExists && exists) ||
564 method == force) // || config.makingModified || makefileDirty
568 ide.statusBar.text = $"Generating Makefile & Dependencies..."; // Dependencies?
571 if((method == normal && !exists) || (method == force && !exists))
572 action = $"Generating ";
573 else if(method == force)
574 action = $"Regenerating ";
575 else if(method == normal || method == forceExists)
576 action = $"Updating ";
580 reason = $"Makefile doesn't exist. ";
581 else if(project.topNode.modified)
582 reason = $"Project has been modified. ";
586 //logBox.Logf("%s\n", makefileName);
587 logBox.Logf($"%s - %s%smakefile for %s config...\n", makefileName, reason, action, GetConfigName(config));
588 project.GenerateMakefile(null, false, null, compiler, config);
590 ide.statusBar.text = null;
597 bool BuildInterrim(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config)
599 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
601 ide.outputView.buildBox.Logf($"Building project %s using the %s configuration...\n", prj.name, GetConfigName(config));
602 return Build(prj, buildType, compiler, config);
607 bool DebugStopForMake(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config)
610 // TOFIX: DebugStop is being abused and backfiring on us.
611 // It's supposed to be the 'Debug/Stop' item, not unloading executable or anything else
613 // configIsInDebugSession seems to be used for two OPPOSITE things:
614 // If we're debugging another config, we need to unload the executable!
615 // In building, we want to stop if we're debugging the 'same' executable
616 if(buildType != run) ///* && prj == project*/ && prj.configIsInDebugSession)
618 if(buildType == start || buildType == restart)
620 if(ide.debugger && ide.debugger.isPrepared)
621 result = DebugStop();
625 if(ide.project == prj && ide.debugger && ide.debugger.prjConfig == config && ide.debugger.isPrepared)
626 result = DebugStop();
632 bool Build(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config)
638 for(document = master.firstChild; document; document = document.next)
640 if(document.modifiedDocument)
642 ProjectNode node = GetNodeFromWindow(document, prj);
643 if(node && !document.MenuFileSave(null, 0))
652 DirExpression targetDir = prj.GetTargetDir(compiler, config);
654 DebugStopForMake(prj, buildType, compiler, config);
656 // TODO: Disabled until problems fixed... is it fixed?
657 if(buildType == rebuild || (config && config.compilingModified))
658 prj.Clean(compiler, config, false);
661 if(buildType == relink || (config && config.linkingModified))
663 char target[MAX_LOCATION];
665 strcpy(target, prj.topNode.path);
666 PathCat(target, targetDir.dir);
667 prj.CatTargetFileName(target, compiler, config);
668 if(FileExists(target))
671 if(config && config.symbolGenModified)
673 DirExpression objDir = prj.GetObjDir(compiler, config);
674 char fileName[MAX_LOCATION];
675 char moduleName[MAX_FILENAME];
676 strcpy(fileName, prj.topNode.path);
677 PathCatSlash(fileName, objDir.dir);
678 strcpy(moduleName, prj.moduleName);
679 strcat(moduleName, ".main.ec");
680 PathCatSlash(fileName, moduleName);
681 if(FileExists(fileName))
682 DeleteFile(fileName);
683 ChangeExtension(fileName, "c", fileName);
684 if(FileExists(fileName))
685 DeleteFile(fileName);
686 ChangeExtension(fileName, "o", fileName);
687 if(FileExists(fileName))
688 DeleteFile(fileName);
693 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
694 ide.AdjustBuildMenus();
695 ide.AdjustDebugMenus();
697 result = prj.Build(buildType == run, null, compiler, config);
701 config.compilingModified = false;
702 if(!ide.ShouldStopBuild())
703 config.linkingModified = false;
705 config.symbolGenModified = false;
707 buildInProgress = none;
708 ide.AdjustBuildMenus();
709 ide.AdjustDebugMenus();
711 ide.workspace.modified = true;
718 // ((( USER ACTIONS )))
720 // ************************************************************************
721 // *** Methods below should atomically start a process, and as such ***
722 // *** they can query compiler and config directly from ide and project ***
723 // *** but ONLY ONCE!!! ***
724 // ************************************************************************
726 bool ProjectBuild(MenuItem selection, Modifiers mods)
728 Project prj = project;
729 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
730 ProjectConfig config;
731 if(selection || !ide.activeClient)
733 DataRow row = fileList.currentRow;
734 ProjectNode node = row ? (ProjectNode)row.tag : null;
735 if(node) prj = node.project;
739 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
744 if(/*prj != project || */!prj.GetConfigIsInDebugSession(config) || !ide.DontTerminateDebugSession($"Project Build"))
746 BuildInterrim(prj, build, compiler, config);
752 bool ProjectLink(MenuItem selection, Modifiers mods)
754 Project prj = project;
755 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
756 ProjectConfig config;
757 if(selection || !ide.activeClient)
759 DataRow row = fileList.currentRow;
760 ProjectNode node = row ? (ProjectNode)row.tag : null;
761 if(node) prj = node.project;
765 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
770 if(!prj.GetConfigIsInDebugSession(config) ||
771 (!ide.DontTerminateDebugSession($"Project Link") && DebugStopForMake(prj, relink, compiler, config)))
773 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
775 ide.outputView.buildBox.Logf($"Relinking project %s using the %s configuration...\n", prj.name, GetConfigName(config));
777 config.linkingModified = true;
778 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(!prj.GetConfigIsInDebugSession(config) ||
804 (!ide.DontTerminateDebugSession($"Project Rebuild") && DebugStopForMake(prj, rebuild, compiler, config)))
806 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
808 ide.outputView.buildBox.Logf($"Rebuilding project %s using the %s configuration...\n", prj.name, GetConfigName(config));
811 config.compilingModified = true;
812 config.makingModified = true;
813 }*/ // -- should this still be used depite the new solution of BuildType?
814 Build(prj, rebuild, compiler, config);
821 bool ProjectClean(MenuItem selection, Modifiers mods)
823 Project prj = project;
824 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
825 ProjectConfig config;
826 if(selection || !ide.activeClient)
828 DataRow row = fileList.currentRow;
829 ProjectNode node = row ? (ProjectNode)row.tag : null;
830 if(node) prj = node.project;
834 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
839 if(!prj.GetConfigIsInDebugSession(config) ||
840 (!ide.DontTerminateDebugSession($"Project Clean") && DebugStopForMake(prj, clean, compiler, config)))
842 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
844 ide.outputView.buildBox.Logf($"Cleaning project %s using the %s configuration...\n", prj.name, GetConfigName(config));
846 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
847 ide.AdjustBuildMenus();
848 ide.AdjustDebugMenus();
850 prj.Clean(compiler, config, false);
851 buildInProgress = none;
852 ide.AdjustBuildMenus();
853 ide.AdjustDebugMenus();
860 bool ProjectRealClean(MenuItem selection, Modifiers mods)
862 Project prj = project;
863 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
864 ProjectConfig config;
865 if(selection || !ide.activeClient)
867 DataRow row = fileList.currentRow;
868 ProjectNode node = row ? (ProjectNode)row.tag : null;
869 if(node) prj = node.project;
873 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
878 if(!prj.GetConfigIsInDebugSession(config) ||
879 (!ide.DontTerminateDebugSession($"Project Real Clean") && DebugStopForMake(prj, clean, compiler, config)))
881 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
883 ide.outputView.buildBox.Logf($"Removing intermediate objects directory for project %s using the %s configuration...\n", prj.name, GetConfigName(config));
885 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
886 ide.AdjustBuildMenus();
887 ide.AdjustDebugMenus();
889 prj.Clean(compiler, config, true);
890 buildInProgress = none;
891 ide.AdjustBuildMenus();
892 ide.AdjustDebugMenus();
899 bool ProjectRegenerate(MenuItem selection, Modifiers mods)
901 Project prj = project;
902 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
903 ShowOutputBuildLog(true);
904 if(selection || !ide.activeClient)
906 DataRow row = fileList.currentRow;
907 ProjectNode node = row ? (ProjectNode)row.tag : null;
913 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
918 ProjectPrepareMakefile(prj, force, true, true, compiler, prj.config);
923 bool Compile(ProjectNode node)
926 char fileName[MAX_LOCATION];
928 Project prj = node.project;
929 ProjectConfig config = prj.config;
930 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
934 // Check if we have to save
935 strcpy(fileName, prj.topNode.path);
936 PathCatSlash(fileName, node.path);
937 PathCatSlash(fileName, node.name);
938 for(document = ide.firstChild; document; document = document.next)
940 if(document.modifiedDocument)
942 char documentFileName[MAX_LOCATION];
943 if(!fstrcmp(GetSlashPathBuffer(documentFileName, document.fileName), fileName))
944 if(!document.MenuFileSave(null, 0))
949 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
951 if(!node.GetIsExcluded(config))
953 // Delete intermedaite files
955 char extension[MAX_EXTENSION];
956 DirExpression objDir = prj.GetObjDir(compiler, config);
958 strcpy(fileName, prj.topNode.path);
959 PathCatSlash(fileName, objDir.dir);
960 PathCatSlash(fileName, node.name);
961 StripExtension(fileName);
962 strcat(fileName, ".o");
963 if(FileExists(fileName))
964 DeleteFile(fileName);
966 GetExtension(node.name, extension);
967 if(!strcmp(extension, "ec"))
969 // Delete generated C file
970 strcpy(fileName, prj.topNode.path);
971 PathCat(fileName, objDir.dir);
972 PathCat(fileName, node.name);
973 StripExtension(fileName);
974 strcat(fileName, ".c");
975 if(FileExists(fileName))
976 DeleteFile(fileName);
978 // Delete symbol file
979 strcpy(fileName, prj.topNode.path);
980 PathCat(fileName, node.path);
981 PathCat(fileName, node.name);
982 StripExtension(fileName);
983 strcat(fileName, ".sym");
984 if(FileExists(fileName))
985 DeleteFile(fileName);
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();
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)
1105 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1107 for(config : project.configurations)
1109 ProjectPrepareMakefile(project, forceExists, false, false,
1117 bool MenuConfig(MenuItem selection, Modifiers mods)
1119 if(ProjectActiveConfig { master = parent, project = project }.Modal() == ok)
1124 bool MenuCompiler(MenuItem selection, Modifiers mods)
1126 ActiveCompilerDialog compilerDialog
1129 ideSettings = ideSettings, workspaceActiveCompiler = ide.workspace.compiler;
1131 incref compilerDialog;
1132 if(compilerDialog.Modal() == ok && strcmp(compilerDialog.workspaceActiveCompiler, ide.workspace.compiler))
1134 CompilerConfig compiler = ideSettings.GetCompilerConfig(compilerDialog.workspaceActiveCompiler);
1135 ide.workspace.compiler = compilerDialog.workspaceActiveCompiler;
1136 ide.projectView.ShowOutputBuildLog(true);
1137 ide.projectView.DisplayCompiler(compiler, false);
1138 for(prj : ide.workspace.projects)
1139 ide.projectView.ProjectUpdateMakefileForAllConfigs(prj);
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;
1189 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
1194 Project GetSelectedProject(bool useSelection)
1196 Project prj = project;
1199 DataRow row = fileList.currentRow;
1200 ProjectNode node = row ? (ProjectNode)row.tag : null;
1207 ProjectNode GetSelectedNode(bool useSelection)
1209 ProjectNode node = null;
1212 DataRow row = fileList.currentRow;
1214 node = (ProjectNode)row.tag;
1219 bool MenuBrowseFolder(MenuItem selection, Modifiers mods)
1221 char folder[MAX_LOCATION];
1223 ProjectNode node = GetSelectedNode(true);
1225 node = project.topNode;
1228 strcpy(folder, prj.topNode.path);
1229 if(node != prj.topNode)
1230 PathCatSlash(folder, node.path);
1234 bool Run(MenuItem selection, Modifiers mods)
1236 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1237 ProjectConfig config = project.config;
1238 String args = new char[maxPathLen];
1240 if(ide.workspace.commandLineArgs)
1241 //ide.debugger.GetCommandLineArgs(args);
1242 strcpy(args, ide.workspace.commandLineArgs);
1243 if(ide.debugger.isActive)
1244 project.Run(args, compiler, config);
1245 /*else if(config.targetType == sharedLibrary || config.targetType == staticLibrary)
1246 MessageBox { master = ide, type = ok, text = "Run", contents = "Shared and static libraries cannot be run like executables." }.Modal();*/
1247 else if(BuildInterrim(project, run, compiler, config))
1248 project.Run(args, compiler, config);
1256 bool result = false;
1257 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1258 ProjectConfig config = project.config;
1259 TargetTypes targetType = project.GetTargetType(config);
1260 if(targetType == sharedLibrary || targetType == staticLibrary)
1261 MessageBox { master = ide, type = ok, text = $"Run", contents = $"Shared and static libraries cannot be run like executables." }.Modal();
1262 else if(project.GetCompress(config))
1263 MessageBox { master = ide, text = $"Starting Debug", contents = $"Debugging compressed applications is not supported\n" }.Modal();
1264 else if(project.GetDebug(config) ||
1265 MessageBox { master = ide, type = okCancel, text = $"Starting Debug", contents = $"Attempting to debug non-debug configuration\nProceed anyways?" }.Modal() == ok)
1267 if(/*!IsProjectModified() ||*/ BuildInterrim(project, start, compiler, config))
1269 if(compiler.type.isVC)
1271 //bool result = false;
1272 char oldwd[MAX_LOCATION];
1273 PathBackup pathBackup { };
1274 char command[MAX_LOCATION];
1276 ide.SetPath(false, compiler, config);
1278 GetWorkingDir(oldwd, sizeof(oldwd));
1279 ChangeWorkingDir(project.topNode.path);
1281 sprintf(command, "%s /useenv %s.sln /projectconfig \"%s|Win32\" /command \"%s\"" , "devenv", project.name, config.name, "Debug.Start");
1282 //ide.outputView.buildBox.Logf("command: %s\n", command);
1284 ChangeWorkingDir(oldwd);
1290 ide.debugger.Start(compiler, config);
1299 void GoToError(const char * line)
1303 while(isspace(*line)) line++;
1304 colon = strstr(line, ":");
1309 bool lookForLineNumber = true;
1311 // deal with linking error
1312 if(colon && colon[1] == ' ')
1314 colon = strstr(colon + 1, ":");
1315 if(colon && !colon[1])
1317 colon = strstr(line, ":");
1318 lookForLineNumber = false;
1320 else if(colon && !isdigit(colon[1]))
1323 colon = strstr(line, ":");
1326 // Don't be mistaken by the drive letter colon
1327 if(colon && (colon[1] == '/' || colon[1] == '\\'))
1328 colon = strstr(colon + 1, ":");
1329 if(colon && lookForLineNumber)
1333 char * par = RSearchString(line, "(", colon - line, true, false);
1334 if(par && strstr(par, ")"))
1336 else if((colon+1)[0] == ' ')
1338 // NOTE: This is the same thing as saying 'colon = line'
1339 for( ; colon != line; colon--)
1343 lineNumber = atoi(colon + 1);
1345 comma = strchr(colon, ',');
1347 col = atoi(comma+1);
1349 comma = strchr(colon+1, ':');
1351 col = atoi(comma+1);
1355 char moduleName[MAX_LOCATION], filePath[MAX_LOCATION];
1359 char * inFileIncludedFrom = strstr(line, stringInFileIncludedFrom);
1360 char * start = inFileIncludedFrom ? line + strlen(stringInFileIncludedFrom) : line;
1361 int len = (int)(colon - start);
1362 len = Min(len, MAX_LOCATION-1);
1364 strncpy(moduleName, start, len);
1365 moduleName[len] = '\0';
1368 strcpy(moduleName, line);
1370 // Remove stuff in brackets
1372 bracket = strstr(moduleName, "(");
1373 if(bracket) *bracket = '\0';
1375 MakeSlashPath(moduleName);
1379 // Check if it's one of our modules
1380 ProjectNode node = project.topNode.Find(moduleName, false);
1383 strcpy(moduleName, node.path);
1384 PathCatSlash(moduleName, node.name);
1387 moduleName[0] = '\0';
1391 CodeEditor codeEditor;
1392 strcpy(filePath, project.topNode.path);
1393 PathCatSlash(filePath, moduleName);
1395 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
1398 char name[MAX_LOCATION];
1399 // TOFIX: Improve on this, don't use only filename, make a function
1400 if(ide && ide.workspace)
1402 for(prj : ide.workspace.projects)
1404 if(prj.topNode.FindWithPath(moduleName, false))
1406 strcpy(filePath, prj.topNode.path);
1407 PathCatSlash(filePath, moduleName);
1408 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
1415 if(codeEditor && lineNumber)
1417 EditBox editBox = codeEditor.editBox;
1418 editBox.GoToLineNum(lineNumber - 1);
1419 editBox.GoToPosition(editBox.line, lineNumber - 1, col ? (col - 1) : 0);
1426 bool OpenNode(ProjectNode node)
1428 char filePath[MAX_LOCATION];
1429 node.GetFullFilePath(filePath);
1430 return ide.OpenFile(filePath, normal, true/*false Why was it opening hidden?*/, null, something, normal) ? true : false;
1433 void AddNode(ProjectNode node, DataRow addTo)
1435 DataRow row = addTo ? addTo.AddRow() : fileList.AddRow();
1437 row.tag = (int)node;
1440 if(node.type == resources)
1443 row.SetData(null, node);
1445 if(node.files && node.files.first && node.parent &&
1446 !(!node.parent.parent &&
1447 (!strcmpi(node.name, "notes") || !strcmpi(node.name, "sources") ||
1448 !strcmpi(node.name, "src") || !strcmpi(node.name, "tools"))))
1449 row.collapsed = true;
1450 else if(node.type == folder)
1451 node.icon = openFolder;
1455 for(child : node.files)
1456 AddNode(child, row);
1460 void DeleteNode(ProjectNode projectNode)
1462 if(projectNode.files)
1465 while(child = projectNode.files.first)
1468 fileList.DeleteRow(projectNode.row);
1469 projectNode.Delete();
1472 bool ProjectSave(MenuItem selection, Modifiers mods)
1474 DataRow row = fileList.currentRow;
1475 ProjectNode node = row ? (ProjectNode)row.tag : null;
1476 Project prj = node ? node.project : null;
1479 if(prj.Save(prj.filePath))
1481 // ShowOutputBuildLog(true);
1482 // DisplayCompiler(compiler, false);
1483 // ProjectUpdateMakefileForAllConfigs(prj);
1484 prj.topNode.modified = false;
1486 for(p : ide.workspace.projects)
1488 if(p.topNode.modified)
1495 modifiedDocument = false;
1502 bool ShowOutputBuildLog(bool cleanLog)
1504 OutputView output = ide.outputView;
1506 output.ShowClearSelectTab(build);
1509 output.SelectTab(build);
1516 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1517 ProjectConfig config = project.config;
1519 bool result = false;
1520 if(/*!IsProjectModified() ||*/ BuildInterrim(project, restart, compiler, config))
1522 // For Restart, compiler and config will only be used if for
1523 // whatever reason (if at all possible) the Debugger is in a
1524 // 'terminated' or 'none' state
1525 ide.debugger.Restart(compiler, config);
1535 ide.debugger.Resume();
1541 ide.debugger.Break();
1547 ide.debugger.Stop();
1551 bool DebugStepInto()
1553 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1554 ProjectConfig config = project.config;
1556 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config)))
1557 ide.debugger.StepInto(compiler, config);
1562 bool DebugStepOver(bool skip)
1564 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1565 ProjectConfig config = project.config;
1567 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config)))
1568 ide.debugger.StepOver(compiler, config, skip);
1574 bool DebugStepOut(bool skip)
1576 ide.debugger.StepOut(skip);
1580 void ImportFolder(ProjectNode toNode)
1584 //bool isFolder = toNode.type == folder;
1585 //bool isRes = toNode.isInResources;
1587 FileDialog fileDialog = importFileDialog;
1588 fileDialog.master = parent;
1589 if(fileDialog.Modal() == ok)
1591 ImportFolderFSI fsi { projectView = this };
1592 fsi.stack.Add(toNode);
1593 fsi.Iterate(fileDialog.filePath);
1599 ProjectNode NewFolder(ProjectNode parentNode, char * name, bool showProperties)
1603 ProjectNode folderNode;
1604 Project prj = parentNode.project;
1606 ProjectNode after = null;
1607 for(node : parentNode.files)
1609 if(node.type != folder)
1615 folderNode = parentNode.Add(prj, name, after, folder, folder, true);
1618 for(c = 0; c < 100; c++)
1621 sprintf(string, c ? "New Folder (%d)" : "New Folder", c);
1622 if((folderNode = parentNode.Add(prj, string, after, folder, folder, true)))
1629 NodeProperties nodeProperties;
1632 modifiedDocument = true;
1633 prj.topNode.modified = true;
1636 folderNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
1637 folderNode.row.tag = (int)folderNode;
1639 folderNode.row.SetData(null, folderNode);
1640 fileList.currentRow = folderNode.row;
1644 nodeProperties = NodeProperties
1646 parent, this, mode = newFolder, node = folderNode;
1647 position = { position.x + 100, position.y + 100 };
1649 nodeProperties.Create(); // Modal?
1657 void AddFiles(bool resources)
1659 FileDialog fileDialog = (!resources) ? this.fileDialog : resourceFileDialog;
1660 fileDialog.type = multiOpen;
1661 fileDialog.text = !resources ? $"Add Files to Project" : $"Add Resources to Project";
1662 fileDialog.master = parent;
1664 if(fileDialog.Modal() == ok)
1667 DataRow row = fileList.currentRow;
1668 ProjectNode parentNode = (ProjectNode)row.tag;
1669 bool addFailed = false;
1670 int numSelections = fileDialog.numSelections;
1671 char ** multiFilePaths = fileDialog.multiFilePaths;
1673 Array<String> nameConflictFiles { };
1675 for(c = 0; c < numSelections; c++)
1677 char * filePath = multiFilePaths[c];
1678 FileAttribs exists = FileExists(filePath);
1679 bool addThisFile = true;
1681 if(exists.isDirectory)
1682 addThisFile = false;
1685 if(MessageBox { master = ide, type = yesNo, text = filePath,
1686 contents = $"File doesn't exist. Create?" }.Modal() == yes)
1688 File f = FileOpen(filePath, write);
1696 MessageBox { master = ide, type = ok, text = filePath,
1697 contents = $"Couldn't create file."}.Modal();
1698 addThisFile = false;
1705 /*addFailed = */if(!AddFile(parentNode, filePath, resources, false))//;
1707 nameConflictFiles.Add(CopyString(filePath));
1715 char * part1 = $"The following file";
1716 char * opt1 = $" was ";
1717 char * opt2 = $"s were ";
1718 char * part2 = $"not added because of identical file name conflict within the project.\n\n";
1720 len += strlen(part1);
1721 len += strlen(part2);
1722 len += nameConflictFiles.count > 1 ? strlen(opt2) : strlen(opt1);
1723 for(s : nameConflictFiles)
1724 len += strlen(s) + 1;
1725 message = new char[len + 1];
1726 strcpy(message, part1);
1727 strcat(message, nameConflictFiles.count > 1 ? opt2 : opt1);
1728 strcat(message, part2);
1729 for(s : nameConflictFiles)
1732 strcat(message, "\n");
1734 MessageBox { master = ide, type = ok, text = $"Name Conflict",
1735 contents = message }.Modal();
1738 nameConflictFiles.Free();
1739 delete nameConflictFiles;
1743 ProjectNode AddFile(ProjectNode parentNode, char * filePath, bool resources, bool isTemporary)
1745 ProjectNode result = null;
1746 ProjectNode after = null;
1747 for(node : parentNode.files)
1749 if(node.type != folder && node.type != file && node.type)
1754 result = parentNode.Add(parentNode.project, filePath, after, file, NodeIcons::SelectFileIcon(filePath), !resources);
1760 modifiedDocument = true;
1761 parentNode.project.topNode.modified = true;
1762 parentNode.project.ModifiedAllConfigs(true, false, true, true);
1765 result.row = parentNode.row.AddRowAfter(after ? after.row : null);
1766 result.row.tag = (int)result;
1767 result.row.SetData(null, result);
1772 CodeEditor CreateNew(char * upper, char * lower, char * base, char * className)
1774 CodeEditor codeEditor = null;
1775 ProjectNode projectNode;
1776 ProjectNode after = null;
1777 DataRow row = fileList.currentRow;
1778 ProjectNode parentNode;
1781 if(!row) row = project.topNode.row;
1783 parentNode = (ProjectNode)row.tag;
1785 for(node : parentNode.files)
1787 if(node.type != folder && node.type != file && node.type)
1791 for(c = 1; c < 100; c++)
1794 sprintf(string, c ? "%s%d.ec" : "%s.ec", lower, c);
1795 if((projectNode = parentNode.Add(project, string, after, file, genFile, true)))
1801 char filePath[MAX_LOCATION];
1803 modifiedDocument = true;
1804 project.topNode.modified = true;
1806 project.ModifiedAllConfigs(true, false, false, true);
1807 projectNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
1808 projectNode.row.tag =(int)projectNode;
1810 projectNode.row.SetData(null, projectNode);
1811 fileList.currentRow = projectNode.row;
1813 strcpy(filePath, project.topNode.path);
1814 PathCat(filePath, projectNode.path);
1815 PathCat(filePath, projectNode.name);
1817 codeEditor = (CodeEditor)ide.FindWindow(filePath);
1820 Class baseClass = eSystem_FindClass(__thisModule, base);
1821 subclass(ClassDesignerBase) designerClass = eClass_GetDesigner(baseClass);
1824 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal);
1825 strcpy(name, projectNode.name);
1826 sprintf(name, "%s%d", upper, c);
1828 strcpy(className, name);
1830 designerClass.CreateNew(codeEditor.editBox, codeEditor.clientSize, name, base);
1832 //codeEditor.modifiedDocument = false;
1833 //codeEditor.designer.modifiedDocument = false;
1835 //Code_EnsureUpToDate(codeEditor);
1838 else // TODO: fix no symbols generated when ommiting {} for following else
1840 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal);
1844 codeEditor.ViewDesigner();
1845 codeEditor.codeModified = true;
1852 // Returns true if we opened something
1853 bool OpenSelectedNodes()
1855 bool result = false;
1859 fileList.GetMultiSelection(selection);
1860 for(item = selection.first; item; item = item.next)
1862 DataRow row = item.data;
1863 ProjectNode node = (ProjectNode)row.tag;
1864 if(node.type == file)
1871 selection.Free(null);
1875 void RemoveSelectedNodes()
1880 fileList.GetMultiSelection(selection);
1882 // Remove children of parents we're deleting
1883 for(item = selection.first; item; item = next)
1886 DataRow row = item.data;
1887 ProjectNode n, node = (ProjectNode)row.tag;
1888 bool remove = false;
1891 for(i = selection.first; i && !remove; i = i.next)
1893 ProjectNode iNode = (ProjectNode)((DataRow)i.data).tag;
1894 for(n = node.parent; n; n = n.parent)
1904 selection.Delete(item);
1907 for(item = selection.first; item; item = item.next)
1909 DataRow row = item.data;
1910 ProjectNode node = (ProjectNode)row.tag;
1911 ProjectNode resNode;
1912 for(resNode = node.parent; resNode; resNode = resNode.parent)
1913 if(resNode.type == resources)
1915 if(node.type == file)
1917 Project prj = node.project;
1919 modifiedDocument = true;
1920 prj.topNode.modified = true;
1922 prj.ModifiedAllConfigs(true, false, true, true);
1924 else if(node.type == folder)
1927 sprintf(message, $"Are you sure you want to remove the folder \"%s\"\n"
1928 "and all of its contents from the project?", node.name);
1929 if(MessageBox { master = ide, type = yesNo, text = $"Delete Folder", contents = message }.Modal() == yes)
1931 Project prj = node.project;
1932 if(node.containsFile)
1933 prj.ModifiedAllConfigs(true, false, true, true);
1935 modifiedDocument = true;
1936 prj.topNode.modified = true;
1939 else if(node.type == project && node != project.topNode && !buildInProgress)
1943 for(p : workspace.projects)
1945 if(p.topNode == node)
1951 sprintf(message, $"Are you sure you want to remove the \"%s\" project\n" "from this workspace?", node.name);
1952 if(MessageBox { master = ide, type = yesNo, text = $"Remove Project", contents = message }.Modal() == yes)
1957 workspace.RemoveProject(prj);
1958 //modifiedDocument = true; // when project view is a workspace view
1962 selection.Free(null);