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 NotifyKeyHit(ListBox listBox, DataRow row, Key key, unichar ch)
321 if(key == altUp || key == altDown)
323 SelectNextProject(key == altUp);
329 bool NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch)
333 ProjectNode node = (ProjectNode)row.tag;
336 case altEnter: case Key { keyPadEnter, alt = true }:
338 NodeProperties { parent = parent, master = this,
339 position = { position.x + 100, position.y + 100 }, node = node }.Create();
342 case enter: case keyPadEnter:
345 for(resNode = node.parent; resNode; resNode = resNode.parent)
346 if(resNode.type == resources)
348 if(node.type == project || (node.type == folder && !resNode))
353 else if(node.type == resources || node.type == folder)
362 if(node.type == project || node.type == folder || node.type == resources)
371 if(node.type == project || node.type == folder || node.type == resources)
373 NewFolder(node, null, true);
380 if(node.type == file)
382 FileCompile(null, (Modifiers)key);
387 case Key { space, shift = true }:
390 if(node.type == NodeTypes::project)
393 for(p : workspace.projects)
395 if(p.topNode == node)
401 prj.RotateActiveConfig(!key.shift);
412 case enter: case keyPadEnter: OpenSelectedNodes(); break;
413 case del: RemoveSelectedNodes(); break;
416 Window activeClient = ide.activeClient;
418 activeClient.Activate();
420 ide.RepositionWindows(true);
427 bool NotifyCollapse(ListBox listBox, DataRow row, bool collapsed)
429 ProjectNode node = (ProjectNode)row.tag;
430 if(node.type == folder)
431 node.icon = collapsed ? folder : openFolder;
436 FileDialog importFileDialog { autoCreate = false, type = selectDir, text = $"Import Folder" };
437 FileDialog projectFileDialog
439 autoCreate = false, filters = projectFilters.array, sizeFilters = projectFilters.count * sizeof(FileFilter);
440 types = projectTypes.array, sizeTypes = projectTypes.count * sizeof(FileType);
442 FileDialog fileDialog
444 autoCreate = false, mayNotExist = true, filters = fileFilters.array, sizeFilters = fileFilters.count * sizeof(FileFilter);
446 FileDialog resourceFileDialog
448 autoCreate = false, mayNotExist = true, filters = resourceFilters.array, sizeFilters = resourceFilters.count * sizeof(FileFilter);
451 Menu fileMenu { menu, $"File", f };
452 MenuItem { fileMenu, $"Save", s, Key { s, ctrl = true }, NotifySelect = MenuFileSave };
453 // MenuItem { fileMenu, "Save As...", a, NotifySelect = MenuFileSaveAs };
455 bool OnClose(bool parentClosing)
457 if(!parentClosing && visible)
467 DialogResult dialogRes;
470 strcpy(msg, $"You have modified projects.\nSave changes to ");
471 for(p : ide.workspace.projects)
473 if(p.topNode.modified)
475 if(!first) strcat(msg, ", ");
482 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = msg }.Modal();
486 // TOFIX: Precomp error if brackets are taken out
487 return (DialogResult)MenuFileSave(null, 0) != cancel;
489 else if(dialogRes == cancel)
491 modifiedDocument = false;
498 //if(ide.findInFilesDialog && ide.findInFilesDialog.created && ide.findInFilesDialog.mode != directory)
499 // ide.findInFilesDialog.SearchStop();
501 ide.outputView.buildBox.Clear();
502 ide.outputView.debugBox.Clear();
503 //ide.outputView.findBox.Clear();
504 ide.callStackView.Clear();
505 ide.watchesView.Clear();
506 ide.threadsView.Clear();
507 ide.breakpointsView.Clear();
508 ide.outputView.ShowClearSelectTab(find); // why this?
511 bool OnSaveFile(char * fileName)
513 for(prj : ide.workspace.projects)
515 if(prj.topNode.modified)
517 prj.StopMonitoring();
518 if(prj.Save(prj.filePath))
519 prj.topNode.modified = false;
520 prj.StartMonitoring();
523 modifiedDocument = false;
528 bool IsModuleInProject(char * filePath)
530 char moduleName[MAX_FILENAME]; //, modulePath[MAX_LOCATION];
531 GetLastDirectory(filePath, moduleName);
532 return project.topNode.Find(moduleName, false) != null;
535 bool GetRelativePath(char * filePath, char * relativePath)
537 return project.GetRelativePath(filePath, relativePath);
540 ProjectNode GetNodeFromWindow(Window document, Project project)
542 if(document.fileName)
544 char winFileName[MAX_LOCATION];
545 char * documentFileName = GetSlashPathBuffer(winFileName, document.fileName);
546 for(p : ide.workspace.projects)
548 Project prj = project ? project : p;
550 if((node = prj.topNode.FindByFullPath(documentFileName, false)))
558 // ((( UTILITY FUNCTIONS )))
560 // ************************************************************************
561 // *** These methods below are part of a sequence of events, and as ***
562 // *** such they must be passed the current compiler and project config ***
563 // ************************************************************************
564 bool DisplayCompiler(CompilerConfig compiler, bool cleanLog)
566 ide.outputView.buildBox.Logf($"%s Compiler\n", compiler ? compiler.name : $"{problem with compiler selection}");
570 bool ProjectPrepareForToolchain(Project project, PrepareMakefileMethod method, bool cleanLog, bool displayCompiler,
571 CompilerConfig compiler, ProjectConfig config)
574 char message[MAX_F_STRING];
575 LogBox logBox = ide.outputView.buildBox;
577 ShowOutputBuildLog(cleanLog);
580 DisplayCompiler(compiler, false);
582 ProjectPrepareCompiler(project, compiler);
583 ProjectPrepareMakefile(project, method, compiler, config);
587 bool ProjectPrepareCompiler(Project project, CompilerConfig compiler)
589 project.GenerateCrossPlatformMk();
590 project.GenerateCompilerCf(compiler);
594 // Note: Compiler is only passed in to for VisualStudio support
595 bool ProjectPrepareMakefile(Project project, PrepareMakefileMethod method, CompilerConfig compiler, ProjectConfig config)
597 if(compiler.type.isVC)
599 // I'm guessing we'll want to support generating VS files on Linux as well...
600 ide.statusBar.text = $"Generating Visual Studio Solution...";
602 //GenerateVSSolutionFile(project, compiler);
603 ide.statusBar.text = $"Generating Visual Studio Project...";
605 //GenerateVCProjectFile(project, compiler);
606 ide.statusBar.text = null;
612 char makefilePath[MAX_LOCATION];
613 char makefileName[MAX_LOCATION];
615 LogBox logBox = ide.outputView.buildBox;
617 strcpy(makefilePath, project.topNode.path);
618 project.CatMakeFileName(makefileName, config);
619 PathCatSlash(makefilePath, makefileName);
621 exists = FileExists(makefilePath);
622 if(method == force ||
623 (method == forceExists && exists) ||
624 (method == normal && (!exists || (config && config.makingModified))))
628 ide.statusBar.text = $"Generating Makefile & Dependencies..."; // Dependencies?
631 if((method == normal && !exists) || (method == force && !exists))
632 action = $"Generating ";
633 else if(method == force)
634 action = $"Regenerating ";
635 else if(method == normal || method == forceExists)
636 action = $"Updating ";
640 reason = $"Makefile doesn't exist. ";
641 else if(project.topNode.modified)
642 reason = $"Project has been modified. ";
646 //logBox.Logf("%s\n", makefileName);
647 logBox.Logf($"%s - %s%smakefile for %s config...\n", makefileName, reason, action, GetConfigName(config));
649 project.GenerateMakefile(null, false, null, config);
651 ide.statusBar.text = null;
659 bool BuildInterrim(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config)
661 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
663 ide.outputView.buildBox.Logf($"Building project %s using the %s configuration...\n", prj.name, GetConfigName(config));
664 return Build(prj, buildType, compiler, config);
669 bool DebugStopForMake(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config)
672 // TOFIX: DebugStop is being abused and backfiring on us.
673 // It's supposed to be the 'Debug/Stop' item, not unloading executable or anything else
675 // configIsInDebugSession seems to be used for two OPPOSITE things:
676 // If we're debugging another config, we need to unload the executable!
677 // In building, we want to stop if we're debugging the 'same' executable
678 if(buildType != run) ///* && prj == project*/ && prj.configIsInDebugSession)
680 if(buildType == start || buildType == restart)
682 if(ide.debugger && ide.debugger.isPrepared)
683 result = DebugStop();
687 if(ide.project == prj && ide.debugger && ide.debugger.prjConfig == config && ide.debugger.isPrepared)
688 result = DebugStop();
694 bool Build(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config)
700 for(document = master.firstChild; document; document = document.next)
702 if(document.modifiedDocument)
704 ProjectNode node = GetNodeFromWindow(document, prj);
705 if(node && !document.MenuFileSave(null, 0))
714 DirExpression targetDir = prj.GetTargetDir(compiler, config);
716 DebugStopForMake(prj, buildType, compiler, config);
718 // TODO: Disabled until problems fixed... is it fixed?
719 if(buildType == rebuild || (config && config.compilingModified))
720 prj.Clean(compiler, config, false);
723 if(buildType == relink || (config && config.linkingModified))
725 char target[MAX_LOCATION];
727 strcpy(target, prj.topNode.path);
728 PathCat(target, targetDir.dir);
729 prj.CatTargetFileName(target, compiler, config);
730 if(FileExists(target))
733 if(config && config.symbolGenModified)
735 DirExpression objDir = prj.GetObjDir(compiler, config);
736 char fileName[MAX_LOCATION];
737 char moduleName[MAX_FILENAME];
738 strcpy(fileName, prj.topNode.path);
739 PathCatSlash(fileName, objDir.dir);
740 strcpy(moduleName, prj.moduleName);
741 strcat(moduleName, ".main.ec");
742 PathCatSlash(fileName, moduleName);
743 if(FileExists(fileName))
744 DeleteFile(fileName);
745 ChangeExtension(fileName, "c", fileName);
746 if(FileExists(fileName))
747 DeleteFile(fileName);
748 ChangeExtension(fileName, "o", fileName);
749 if(FileExists(fileName))
750 DeleteFile(fileName);
755 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
756 ide.AdjustBuildMenus();
757 ide.AdjustDebugMenus();
759 result = prj.Build(buildType == run, null, compiler, config);
763 config.compilingModified = false;
764 if(!ide.ShouldStopBuild())
765 config.linkingModified = false;
767 config.symbolGenModified = false;
769 buildInProgress = none;
770 ide.AdjustBuildMenus();
771 ide.AdjustDebugMenus();
773 ide.workspace.modified = true;
780 // ((( USER ACTIONS )))
782 // ************************************************************************
783 // *** Methods below should atomically start a process, and as such ***
784 // *** they can query compiler and config directly from ide and project ***
785 // *** but ONLY ONCE!!! ***
786 // ************************************************************************
788 bool ProjectBuild(MenuItem selection, Modifiers mods)
790 Project prj = project;
791 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
792 ProjectConfig config;
793 if(selection || !ide.activeClient)
795 DataRow row = fileList.currentRow;
796 ProjectNode node = row ? (ProjectNode)row.tag : null;
797 if(node) prj = node.project;
801 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
806 if(/*prj != project || */!prj.GetConfigIsInDebugSession(config) || !ide.DontTerminateDebugSession($"Project Build"))
808 BuildInterrim(prj, build, compiler, config);
814 bool ProjectLink(MenuItem selection, Modifiers mods)
816 Project prj = project;
817 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
818 ProjectConfig config;
819 if(selection || !ide.activeClient)
821 DataRow row = fileList.currentRow;
822 ProjectNode node = row ? (ProjectNode)row.tag : null;
823 if(node) prj = node.project;
827 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
832 if(!prj.GetConfigIsInDebugSession(config) ||
833 (!ide.DontTerminateDebugSession($"Project Link") && DebugStopForMake(prj, relink, compiler, config)))
835 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
837 ide.outputView.buildBox.Logf($"Relinking project %s using the %s configuration...\n", prj.name, GetConfigName(config));
839 config.linkingModified = true;
840 Build(prj, relink, compiler, config);
847 bool ProjectRebuild(MenuItem selection, Modifiers mods)
849 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
850 Project prj = project;
851 ProjectConfig config;
852 if(selection || !ide.activeClient)
854 DataRow row = fileList.currentRow;
855 ProjectNode node = row ? (ProjectNode)row.tag : null;
856 if(node) prj = node.project;
860 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
865 if(!prj.GetConfigIsInDebugSession(config) ||
866 (!ide.DontTerminateDebugSession($"Project Rebuild") && DebugStopForMake(prj, rebuild, compiler, config)))
868 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
870 ide.outputView.buildBox.Logf($"Rebuilding project %s using the %s configuration...\n", prj.name, GetConfigName(config));
873 config.compilingModified = true;
874 config.makingModified = true;
875 }*/ // -- should this still be used depite the new solution of BuildType?
876 Build(prj, rebuild, compiler, config);
883 bool ProjectClean(MenuItem selection, Modifiers mods)
885 Project prj = project;
886 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
887 ProjectConfig config;
888 if(selection || !ide.activeClient)
890 DataRow row = fileList.currentRow;
891 ProjectNode node = row ? (ProjectNode)row.tag : null;
892 if(node) prj = node.project;
896 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
901 if(!prj.GetConfigIsInDebugSession(config) ||
902 (!ide.DontTerminateDebugSession($"Project Clean") && DebugStopForMake(prj, clean, compiler, config)))
904 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
906 ide.outputView.buildBox.Logf($"Cleaning project %s using the %s configuration...\n", prj.name, GetConfigName(config));
908 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
909 ide.AdjustBuildMenus();
910 ide.AdjustDebugMenus();
912 prj.Clean(compiler, config, false);
913 buildInProgress = none;
914 ide.AdjustBuildMenus();
915 ide.AdjustDebugMenus();
922 bool ProjectRealClean(MenuItem selection, Modifiers mods)
924 Project prj = project;
925 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
926 ProjectConfig config;
927 if(selection || !ide.activeClient)
929 DataRow row = fileList.currentRow;
930 ProjectNode node = row ? (ProjectNode)row.tag : null;
931 if(node) prj = node.project;
935 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
940 if(!prj.GetConfigIsInDebugSession(config) ||
941 (!ide.DontTerminateDebugSession($"Project Real Clean") && DebugStopForMake(prj, clean, compiler, config)))
943 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
945 ide.outputView.buildBox.Logf($"Removing intermediate objects directory for project %s using the %s configuration...\n", prj.name, GetConfigName(config));
947 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
948 ide.AdjustBuildMenus();
949 ide.AdjustDebugMenus();
951 prj.Clean(compiler, config, true);
952 buildInProgress = none;
953 ide.AdjustBuildMenus();
954 ide.AdjustDebugMenus();
961 bool ProjectRegenerate(MenuItem selection, Modifiers mods)
963 Project prj = project;
964 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
965 ShowOutputBuildLog(true);
966 if(selection || !ide.activeClient)
968 DataRow row = fileList.currentRow;
969 ProjectNode node = row ? (ProjectNode)row.tag : null;
975 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
980 DisplayCompiler(compiler, false);
981 ProjectPrepareCompiler(project, compiler);
982 ProjectPrepareMakefile(prj, force, compiler, prj.config);
987 bool Compile(ProjectNode node)
990 char fileName[MAX_LOCATION];
992 Project prj = node.project;
993 ProjectConfig config = prj.config;
994 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
998 // Check if we have to save
999 strcpy(fileName, prj.topNode.path);
1000 PathCatSlash(fileName, node.path);
1001 PathCatSlash(fileName, node.name);
1002 for(document = ide.firstChild; document; document = document.next)
1004 if(document.modifiedDocument)
1006 char documentFileName[MAX_LOCATION];
1007 if(!fstrcmp(GetSlashPathBuffer(documentFileName, document.fileName), fileName))
1008 if(!document.MenuFileSave(null, 0))
1013 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
1015 if(!node.GetIsExcluded(config))
1017 // Delete intermedaite files
1019 char extension[MAX_EXTENSION];
1020 DirExpression objDir = prj.GetObjDir(compiler, config);
1022 strcpy(fileName, prj.topNode.path);
1023 PathCatSlash(fileName, objDir.dir);
1024 PathCatSlash(fileName, node.name);
1025 StripExtension(fileName);
1026 strcat(fileName, ".o");
1027 if(FileExists(fileName))
1028 DeleteFile(fileName);
1030 GetExtension(node.name, extension);
1031 if(!strcmp(extension, "ec"))
1033 // Delete generated C file
1034 strcpy(fileName, prj.topNode.path);
1035 PathCat(fileName, objDir.dir);
1036 PathCat(fileName, node.name);
1037 StripExtension(fileName);
1038 strcat(fileName, ".c");
1039 if(FileExists(fileName))
1040 DeleteFile(fileName);
1042 // Delete symbol file
1043 strcpy(fileName, prj.topNode.path);
1044 PathCat(fileName, node.path);
1045 PathCat(fileName, node.name);
1046 StripExtension(fileName);
1047 strcat(fileName, ".sym");
1048 if(FileExists(fileName))
1049 DeleteFile(fileName);
1054 buildInProgress = compilingFile;
1055 ide.AdjustBuildMenus();
1057 //ide.outputView.ShowClearSelectTab(build);
1058 // this stuff doesn't even appear
1059 //ide.outputView.buildBox.Logf($"%s Compiler\n", compiler.name);
1061 ide.outputView.buildBox.Logf($"Compiling single file %s in project %s using the %s configuration...\n", node.name, prj.name, config.name);
1063 ide.outputView.buildBox.Logf($"Compiling single file %s in project %s...\n", node.name, prj.name);
1065 prj.Compile(node, compiler, config);
1066 buildInProgress = none;
1067 ide.AdjustBuildMenus();
1076 bool ProjectNewFile(MenuItem selection, Modifiers mods)
1078 DataRow row = fileList.currentRow;
1081 char fileName[1024];
1082 char filePath[MAX_LOCATION];
1083 ProjectNode parentNode = (ProjectNode)row.tag;
1084 ProjectNode n, fileNode;
1085 parentNode.GetFileSysMatchingPath(filePath);
1086 MakePathRelative(filePath, parentNode.project.topNode.path, filePath);
1087 for(n = parentNode; n && n != parentNode.project.resNode; n = n.parent);
1088 sprintf(fileName, $"Untitled %d", documentID);
1089 fileNode = AddFile(parentNode, fileName, (bool)n, true);
1090 fileNode.path = CopyUnixPath(filePath);
1093 NodeProperties nodeProperties
1096 position = { position.x + 100, position.y + 100 };
1100 nodeProperties.Create(); // not modal?
1106 bool ProjectNewFolder(MenuItem selection, Modifiers mods)
1108 DataRow row = fileList.currentRow;
1111 ProjectNode parentNode = (ProjectNode)row.tag;
1112 NewFolder(parentNode, null, true);
1117 bool ResourcesAddFiles(MenuItem selection, Modifiers mods)
1123 bool ProjectAddFiles(MenuItem selection, Modifiers mods)
1129 bool ProjectImportFolder(MenuItem selection, Modifiers mods)
1131 DataRow row = fileList.currentRow;
1134 ProjectNode toNode = (ProjectNode)row.tag;
1135 ImportFolder(toNode);
1140 bool ProjectAddNewForm(MenuItem selection, Modifiers mods)
1142 CodeEditor codeEditor = CreateNew("Form", "form", "Window", null);
1143 codeEditor.EnsureUpToDate();
1147 bool ProjectAddNewGraph(MenuItem selection, Modifiers mods)
1149 CodeEditor codeEditor = CreateNew("Graph", "graph", "Block", null);
1151 codeEditor.EnsureUpToDate();
1155 bool ProjectRemove(MenuItem selection, Modifiers mods)
1157 DataRow row = fileList.currentRow;
1160 ProjectNode node = (ProjectNode)row.tag;
1161 if(node.type == project)
1162 RemoveSelectedNodes();
1167 bool ProjectUpdateMakefileForAllConfigs(Project project)
1169 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1171 for(config : project.configurations)
1172 ProjectPrepareMakefile(project, forceExists, compiler, config);
1179 bool MenuConfig(MenuItem selection, Modifiers mods)
1181 if(ProjectActiveConfig { master = parent, project = project }.Modal() == ok)
1186 bool MenuCompiler(MenuItem selection, Modifiers mods)
1188 ActiveCompilerDialog compilerDialog
1191 ideSettings = ideSettings, workspaceActiveCompiler = ide.workspace.compiler;
1193 incref compilerDialog;
1194 if(compilerDialog.Modal() == ok && strcmp(compilerDialog.workspaceActiveCompiler, ide.workspace.compiler))
1196 CompilerConfig compiler = ideSettings.GetCompilerConfig(compilerDialog.workspaceActiveCompiler);
1197 ide.workspace.compiler = compilerDialog.workspaceActiveCompiler;
1198 ide.projectView.ShowOutputBuildLog(true);
1199 ide.projectView.DisplayCompiler(compiler, false);
1201 for(prj : ide.workspace.projects)
1202 ide.projectView.ProjectPrepareCompiler(prj, compiler);
1205 delete compilerDialog;
1209 bool MenuSettings(MenuItem selection, Modifiers mods)
1211 ProjectNode node = GetSelectedNode(true);
1212 Project prj = node ? node.project : project;
1213 projectSettingsDialog = ProjectSettings { master = parent, project = prj, projectNode = node };
1214 projectSettingsDialog.Modal();
1221 bool FileProperties(MenuItem selection, Modifiers mods)
1223 DataRow row = fileList.currentRow;
1226 ProjectNode node = (ProjectNode)row.tag;
1227 NodeProperties { parent = parent, master = this, node = node,
1228 position = { position.x + 100, position.y + 100 } }.Create();
1233 bool FileOpenFile(MenuItem selection, Modifiers mods)
1235 OpenSelectedNodes();
1239 bool FileRemoveFile(MenuItem selection, Modifiers mods)
1241 RemoveSelectedNodes();
1245 bool FileCompile(MenuItem selection, Modifiers mods)
1247 DataRow row = fileList.currentRow;
1250 ProjectNode node = (ProjectNode)row.tag;
1252 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
1257 Project GetSelectedProject(bool useSelection)
1259 Project prj = project;
1262 DataRow row = fileList.currentRow;
1263 ProjectNode node = row ? (ProjectNode)row.tag : null;
1270 void SelectNextProject(bool backwards)
1272 DataRow row = fileList.currentRow;
1273 DataRow currentRow = row;
1274 ProjectNode node = (ProjectNode)row.tag;
1275 if(node.type != project)
1276 row = node.project.topNode.row;
1278 row = row.previous ? row.previous : fileList.lastRow;
1280 row = row.next ? row.next : fileList.firstRow;
1281 if(row && row != currentRow)
1283 fileList.SelectRow(row);
1284 fileList.currentRow = row;
1288 ProjectNode GetSelectedNode(bool useSelection)
1290 ProjectNode node = null;
1293 DataRow row = fileList.currentRow;
1295 node = (ProjectNode)row.tag;
1300 bool MenuBrowseFolder(MenuItem selection, Modifiers mods)
1302 char folder[MAX_LOCATION];
1304 ProjectNode node = GetSelectedNode(true);
1306 node = project.topNode;
1309 strcpy(folder, prj.topNode.path);
1310 if(node != prj.topNode)
1311 PathCatSlash(folder, node.path);
1316 bool Run(MenuItem selection, Modifiers mods)
1318 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1319 ProjectConfig config = project.config;
1320 String args = new char[maxPathLen];
1322 if(ide.workspace.commandLineArgs)
1323 //ide.debugger.GetCommandLineArgs(args);
1324 strcpy(args, ide.workspace.commandLineArgs);
1325 if(ide.debugger.isActive)
1326 project.Run(args, compiler, config);
1327 /*else if(config.targetType == sharedLibrary || config.targetType == staticLibrary)
1328 MessageBox { master = ide, type = ok, text = "Run", contents = "Shared and static libraries cannot be run like executables." }.Modal();*/
1329 else if(BuildInterrim(project, run, compiler, config))
1330 project.Run(args, compiler, config);
1338 bool result = false;
1339 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1340 ProjectConfig config = project.config;
1341 TargetTypes targetType = project.GetTargetType(config);
1342 if(targetType == sharedLibrary || targetType == staticLibrary)
1343 MessageBox { master = ide, type = ok, text = $"Run", contents = $"Shared and static libraries cannot be run like executables." }.Modal();
1344 else if(project.GetCompress(config))
1345 MessageBox { master = ide, text = $"Starting Debug", contents = $"Debugging compressed applications is not supported\n" }.Modal();
1346 else if(project.GetDebug(config) ||
1347 MessageBox { master = ide, type = okCancel, text = $"Starting Debug", contents = $"Attempting to debug non-debug configuration\nProceed anyways?" }.Modal() == ok)
1349 if(/*!IsProjectModified() ||*/ BuildInterrim(project, start, compiler, config))
1351 if(compiler.type.isVC)
1353 //bool result = false;
1354 char oldwd[MAX_LOCATION];
1355 PathBackup pathBackup { };
1356 char command[MAX_LOCATION];
1358 ide.SetPath(false, compiler, config);
1360 GetWorkingDir(oldwd, sizeof(oldwd));
1361 ChangeWorkingDir(project.topNode.path);
1363 sprintf(command, "%s /useenv %s.sln /projectconfig \"%s|Win32\" /command \"%s\"" , "devenv", project.name, config.name, "Debug.Start");
1364 //ide.outputView.buildBox.Logf("command: %s\n", command);
1366 ChangeWorkingDir(oldwd);
1372 ide.debugger.Start(compiler, config);
1381 void GoToError(const char * line)
1385 while(isspace(*line)) line++;
1386 colon = strstr(line, ":");
1391 bool lookForLineNumber = true;
1393 // deal with linking error
1394 if(colon && colon[1] == ' ')
1396 colon = strstr(colon + 1, ":");
1397 if(colon && !colon[1])
1399 colon = strstr(line, ":");
1400 lookForLineNumber = false;
1402 else if(colon && !isdigit(colon[1]))
1405 colon = strstr(line, ":");
1408 // Don't be mistaken by the drive letter colon
1409 if(colon && (colon[1] == '/' || colon[1] == '\\'))
1410 colon = strstr(colon + 1, ":");
1411 if(colon && lookForLineNumber)
1415 char * par = RSearchString(line, "(", colon - line, true, false);
1416 if(par && strstr(par, ")"))
1418 else if((colon+1)[0] == ' ')
1420 // NOTE: This is the same thing as saying 'colon = line'
1421 for( ; colon != line; colon--)
1425 lineNumber = atoi(colon + 1);
1427 comma = strchr(colon, ',');
1429 col = atoi(comma+1);
1431 comma = strchr(colon+1, ':');
1433 col = atoi(comma+1);
1437 char moduleName[MAX_LOCATION], filePath[MAX_LOCATION];
1441 char * inFileIncludedFrom = strstr(line, stringInFileIncludedFrom);
1442 char * start = inFileIncludedFrom ? line + strlen(stringInFileIncludedFrom) : line;
1443 int len = (int)(colon - start);
1444 len = Min(len, MAX_LOCATION-1);
1446 strncpy(moduleName, start, len);
1447 moduleName[len] = '\0';
1450 strcpy(moduleName, line);
1452 // Remove stuff in brackets
1454 bracket = strstr(moduleName, "(");
1455 if(bracket) *bracket = '\0';
1457 MakeSlashPath(moduleName);
1461 // Check if it's one of our modules
1462 ProjectNode node = project.topNode.Find(moduleName, false);
1465 strcpy(moduleName, node.path);
1466 PathCatSlash(moduleName, node.name);
1469 moduleName[0] = '\0';
1473 CodeEditor codeEditor;
1474 strcpy(filePath, project.topNode.path);
1475 PathCatSlash(filePath, moduleName);
1477 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
1480 char name[MAX_LOCATION];
1481 // TOFIX: Improve on this, don't use only filename, make a function
1482 if(ide && ide.workspace)
1484 for(prj : ide.workspace.projects)
1486 if(prj.topNode.FindWithPath(moduleName, false))
1488 strcpy(filePath, prj.topNode.path);
1489 PathCatSlash(filePath, moduleName);
1490 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
1497 if(codeEditor && lineNumber)
1499 EditBox editBox = codeEditor.editBox;
1500 editBox.GoToLineNum(lineNumber - 1);
1501 editBox.GoToPosition(editBox.line, lineNumber - 1, col ? (col - 1) : 0);
1508 bool OpenNode(ProjectNode node)
1510 char filePath[MAX_LOCATION];
1511 node.GetFullFilePath(filePath);
1512 return ide.OpenFile(filePath, normal, true/*false Why was it opening hidden?*/, null, something, normal) ? true : false;
1515 void AddNode(ProjectNode node, DataRow addTo)
1517 DataRow row = addTo ? addTo.AddRow() : fileList.AddRow();
1519 row.tag = (int)node;
1522 if(node.type == resources)
1525 row.SetData(null, node);
1527 if(node.files && node.files.first && node.parent &&
1528 !(!node.parent.parent &&
1529 (!strcmpi(node.name, "notes") || !strcmpi(node.name, "sources") ||
1530 !strcmpi(node.name, "src") || !strcmpi(node.name, "tools"))))
1531 row.collapsed = true;
1532 else if(node.type == folder)
1533 node.icon = openFolder;
1537 for(child : node.files)
1538 AddNode(child, row);
1542 void DeleteNode(ProjectNode projectNode)
1544 if(projectNode.files)
1547 while(child = projectNode.files.first)
1550 fileList.DeleteRow(projectNode.row);
1551 projectNode.Delete();
1554 bool ProjectSave(MenuItem selection, Modifiers mods)
1556 DataRow row = fileList.currentRow;
1557 ProjectNode node = row ? (ProjectNode)row.tag : null;
1558 Project prj = node ? node.project : null;
1561 prj.StopMonitoring();
1562 if(prj.Save(prj.filePath))
1564 Project modPrj = null;
1565 prj.topNode.modified = false;
1566 for(p : ide.workspace.projects)
1568 if(p.topNode.modified)
1575 modifiedDocument = false;
1578 prj.StartMonitoring();
1583 bool ShowOutputBuildLog(bool cleanLog)
1585 OutputView output = ide.outputView;
1587 output.ShowClearSelectTab(build);
1590 output.SelectTab(build);
1598 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1599 ProjectConfig config = project.config;
1601 bool result = false;
1602 if(/*!IsProjectModified() ||*/ BuildInterrim(project, restart, compiler, config))
1604 // For Restart, compiler and config will only be used if for
1605 // whatever reason (if at all possible) the Debugger is in a
1606 // 'terminated' or 'none' state
1607 ide.debugger.Restart(compiler, config);
1617 ide.debugger.Resume();
1623 ide.debugger.Break();
1629 ide.debugger.Stop();
1633 bool DebugStepInto()
1635 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1636 ProjectConfig config = project.config;
1638 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config)))
1639 ide.debugger.StepInto(compiler, config);
1644 bool DebugStepOver(bool skip)
1646 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1647 ProjectConfig config = project.config;
1649 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config)))
1650 ide.debugger.StepOver(compiler, config, skip);
1656 bool DebugStepOut(bool skip)
1658 ide.debugger.StepOut(skip);
1662 void ImportFolder(ProjectNode toNode)
1666 //bool isFolder = toNode.type == folder;
1667 //bool isRes = toNode.isInResources;
1669 FileDialog fileDialog = importFileDialog;
1670 fileDialog.master = parent;
1671 if(fileDialog.Modal() == ok)
1673 ImportFolderFSI fsi { projectView = this };
1674 fsi.stack.Add(toNode);
1675 fsi.Iterate(fileDialog.filePath);
1681 ProjectNode NewFolder(ProjectNode parentNode, char * name, bool showProperties)
1685 ProjectNode folderNode;
1686 Project prj = parentNode.project;
1688 ProjectNode after = null;
1689 for(node : parentNode.files)
1691 if(node.type != folder)
1697 folderNode = parentNode.Add(prj, name, after, folder, folder, true);
1700 for(c = 0; c < 100; c++)
1703 sprintf(string, c ? "New Folder (%d)" : "New Folder", c);
1704 if((folderNode = parentNode.Add(prj, string, after, folder, folder, true)))
1711 NodeProperties nodeProperties;
1714 modifiedDocument = true;
1715 prj.topNode.modified = true;
1718 folderNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
1719 folderNode.row.tag = (int)folderNode;
1721 folderNode.row.SetData(null, folderNode);
1722 fileList.currentRow = folderNode.row;
1726 nodeProperties = NodeProperties
1728 parent, this, mode = newFolder, node = folderNode;
1729 position = { position.x + 100, position.y + 100 };
1731 nodeProperties.Create(); // Modal?
1739 void AddFiles(bool resources)
1741 FileDialog fileDialog = (!resources) ? this.fileDialog : resourceFileDialog;
1742 fileDialog.type = multiOpen;
1743 fileDialog.text = !resources ? $"Add Files to Project" : $"Add Resources to Project";
1744 fileDialog.master = parent;
1746 if(fileDialog.Modal() == ok)
1749 DataRow row = fileList.currentRow;
1750 ProjectNode parentNode = (ProjectNode)row.tag;
1751 bool addFailed = false;
1752 int numSelections = fileDialog.numSelections;
1753 char ** multiFilePaths = fileDialog.multiFilePaths;
1755 Array<String> nameConflictFiles { };
1757 for(c = 0; c < numSelections; c++)
1759 char * filePath = multiFilePaths[c];
1760 FileAttribs exists = FileExists(filePath);
1761 bool addThisFile = true;
1763 if(exists.isDirectory)
1764 addThisFile = false;
1767 if(MessageBox { master = ide, type = yesNo, text = filePath,
1768 contents = $"File doesn't exist. Create?" }.Modal() == yes)
1770 File f = FileOpen(filePath, write);
1778 MessageBox { master = ide, type = ok, text = filePath,
1779 contents = $"Couldn't create file."}.Modal();
1780 addThisFile = false;
1787 /*addFailed = */if(!AddFile(parentNode, filePath, resources, false))//;
1789 nameConflictFiles.Add(CopyString(filePath));
1797 char * part1 = $"The following file";
1798 char * opt1 = $" was ";
1799 char * opt2 = $"s were ";
1800 char * part2 = $"not added because of identical file name conflict within the project.\n\n";
1802 len += strlen(part1);
1803 len += strlen(part2);
1804 len += nameConflictFiles.count > 1 ? strlen(opt2) : strlen(opt1);
1805 for(s : nameConflictFiles)
1806 len += strlen(s) + 1;
1807 message = new char[len + 1];
1808 strcpy(message, part1);
1809 strcat(message, nameConflictFiles.count > 1 ? opt2 : opt1);
1810 strcat(message, part2);
1811 for(s : nameConflictFiles)
1814 strcat(message, "\n");
1816 MessageBox { master = ide, type = ok, text = $"Name Conflict",
1817 contents = message }.Modal();
1820 nameConflictFiles.Free();
1821 delete nameConflictFiles;
1825 ProjectNode AddFile(ProjectNode parentNode, char * filePath, bool resources, bool isTemporary)
1827 ProjectNode result = null;
1828 ProjectNode after = null;
1829 for(node : parentNode.files)
1831 if(node.type != folder && node.type != file && node.type)
1836 result = parentNode.Add(parentNode.project, filePath, after, file, NodeIcons::SelectFileIcon(filePath), !resources);
1842 modifiedDocument = true;
1843 parentNode.project.topNode.modified = true;
1844 parentNode.project.ModifiedAllConfigs(true, false, true, true);
1847 result.row = parentNode.row.AddRowAfter(after ? after.row : null);
1848 result.row.tag = (int)result;
1849 result.row.SetData(null, result);
1854 CodeEditor CreateNew(char * upper, char * lower, char * base, char * className)
1856 CodeEditor codeEditor = null;
1857 ProjectNode projectNode;
1858 ProjectNode after = null;
1859 DataRow row = fileList.currentRow;
1860 ProjectNode parentNode;
1863 if(!row) row = project.topNode.row;
1865 parentNode = (ProjectNode)row.tag;
1867 for(node : parentNode.files)
1869 if(node.type != folder && node.type != file && node.type)
1873 for(c = 1; c < 100; c++)
1876 sprintf(string, c ? "%s%d.ec" : "%s.ec", lower, c);
1877 if((projectNode = parentNode.Add(project, string, after, file, genFile, true)))
1883 char filePath[MAX_LOCATION];
1885 modifiedDocument = true;
1886 project.topNode.modified = true;
1888 project.ModifiedAllConfigs(true, false, false, true);
1889 projectNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
1890 projectNode.row.tag =(int)projectNode;
1892 projectNode.row.SetData(null, projectNode);
1893 fileList.currentRow = projectNode.row;
1895 strcpy(filePath, project.topNode.path);
1896 PathCat(filePath, projectNode.path);
1897 PathCat(filePath, projectNode.name);
1899 codeEditor = (CodeEditor)ide.FindWindow(filePath);
1902 Class baseClass = eSystem_FindClass(__thisModule, base);
1903 subclass(ClassDesignerBase) designerClass = eClass_GetDesigner(baseClass);
1906 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal);
1907 strcpy(name, projectNode.name);
1908 sprintf(name, "%s%d", upper, c);
1910 strcpy(className, name);
1912 designerClass.CreateNew(codeEditor.editBox, codeEditor.clientSize, name, base);
1914 //codeEditor.modifiedDocument = false;
1915 //codeEditor.designer.modifiedDocument = false;
1917 //Code_EnsureUpToDate(codeEditor);
1920 else // TODO: fix no symbols generated when ommiting {} for following else
1922 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal);
1926 codeEditor.ViewDesigner();
1927 codeEditor.codeModified = true;
1934 // Returns true if we opened something
1935 bool OpenSelectedNodes()
1937 bool result = false;
1941 fileList.GetMultiSelection(selection);
1942 for(item = selection.first; item; item = item.next)
1944 DataRow row = item.data;
1945 ProjectNode node = (ProjectNode)row.tag;
1946 if(node.type == file)
1953 selection.Free(null);
1957 void RemoveSelectedNodes()
1962 fileList.GetMultiSelection(selection);
1964 // Remove children of parents we're deleting
1965 for(item = selection.first; item; item = next)
1968 DataRow row = item.data;
1969 ProjectNode n, node = (ProjectNode)row.tag;
1970 bool remove = false;
1973 for(i = selection.first; i && !remove; i = i.next)
1975 ProjectNode iNode = (ProjectNode)((DataRow)i.data).tag;
1976 for(n = node.parent; n; n = n.parent)
1986 selection.Delete(item);
1989 for(item = selection.first; item; item = item.next)
1991 DataRow row = item.data;
1992 ProjectNode node = (ProjectNode)row.tag;
1993 ProjectNode resNode;
1994 for(resNode = node.parent; resNode; resNode = resNode.parent)
1995 if(resNode.type == resources)
1997 if(node.type == file)
1999 Project prj = node.project;
2001 modifiedDocument = true;
2002 prj.topNode.modified = true;
2004 prj.ModifiedAllConfigs(true, false, true, true);
2006 else if(node.type == folder)
2009 sprintf(message, $"Are you sure you want to remove the folder \"%s\"\n"
2010 "and all of its contents from the project?", node.name);
2011 if(MessageBox { master = ide, type = yesNo, text = $"Delete Folder", contents = message }.Modal() == yes)
2013 Project prj = node.project;
2014 if(node.containsFile)
2015 prj.ModifiedAllConfigs(true, false, true, true);
2017 modifiedDocument = true;
2018 prj.topNode.modified = true;
2021 else if(node.type == project && node != project.topNode && !buildInProgress)
2025 for(p : workspace.projects)
2027 if(p.topNode == node)
2033 sprintf(message, $"Are you sure you want to remove the \"%s\" project\n" "from this workspace?", node.name);
2034 if(MessageBox { master = ide, type = yesNo, text = $"Remove Project", contents = message }.Modal() == yes)
2039 workspace.RemoveProject(prj);
2040 //modifiedDocument = true; // when project view is a workspace view
2044 selection.Free(null);