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", /*sFile*/ // TODO: change sFile icon to differentiate from cFile icon
74 "<:ecere>mimeTypes/textCSource.png", /*cFile*/
75 "<:ecere>mimeTypes/textCHeader.png", /*hFile*/
76 "<:ecere>mimeTypes/textC++Source.png", /*cppFile*/
77 "<:ecere>mimeTypes/textC++Header.png", /*hppFile*/
78 "<:ecere>mimeTypes/text.png", /*textFile*/
79 "<:ecere>mimeTypes/textHyperTextMarkup.png", /*webFile*/
80 "<:ecere>mimeTypes/image.png", /*pictureFile*/
81 "<:ecere>status/audioVolumeHigh.png", /*soundFile*/
82 "<:ecere>mimeTypes/package.png", /*archiveFile*/
83 "<:ecere>mimeTypes/packageSoftware.png", /*packageFile*/
84 "<:ecere>mimeTypes/packageOpticalDisc.png", /*opticalMediaImageFile*/
85 "<:ecere>mimeTypes/file.png" /*mFile*/ //TODO: create icon for mfile
88 enum PrepareMakefileMethod { normal, force, forceExists };
90 enum CleanType { clean, realClean, cleanTarget };
91 enum BuildType { build, rebuild, relink, run, start, restart, clean };
94 none, buildingMainProject, buildingSecondaryProject, compilingFile;
96 property bool { get { return this != none; } }
97 //property bool actualBuild { get { return this == buildingMainProject || this == buildingSecondaryProject; } }
100 class ProjectView : Window
103 //hasMinimize = true;
105 borderStyle = sizable;
106 hasHorzScroll = true;
107 hasVertScroll = true;
110 anchor = Anchor { left = 0, top = 0, bottom = 0 };
113 //hasMinimize = true;
114 saveDialog = projectFileDialog;
117 BuildState buildInProgress;
118 BitmapResource icons[NodeIcons];
121 property Workspace workspace
127 for(prj : workspace.projects)
129 DeleteNode(prj.topNode);
131 workspace.projects.Free();
132 ide.debugger.CleanUp();
137 fileDialog.currentDirectory = workspace.workspaceDir;
138 resourceFileDialog.currentDirectory = workspace.workspaceDir;
139 for(prj : workspace.projects)
140 AddNode(prj.topNode, null);
141 ide.statusBar.text = $"Generating Makefile & Dependencies...";
143 for(prj : workspace.projects)
144 prj.ModifiedAllConfigs(true, false, false, false);
145 ide.statusBar.text = $"Initializing Debugger"; app.UpdateDisplay();
146 ide.statusBar.text = null;
150 get { return workspace; }
153 bool drawingInProjectSettingsDialog;
154 bool drawingInProjectSettingsDialogHeader;
155 ProjectSettings projectSettingsDialog;
163 for(c = 0; c < NodeIcons::enumSize; c++)
165 icons[c] = BitmapResource { iconNames[c], alphaBlend = true };
166 AddResource(icons[c]);
168 fileList.AddField(DataField { dataType = class(ProjectNode), freeData = false, userData = this });
174 ide.DestroyTemporaryProjectDir();
184 multiSelect = true, fullRowSelect = false, hasVertScroll = true, hasHorzScroll = true;
185 borderStyle = deep, parent = this, collapseControl = true, treeBranches = true;
186 anchor = Anchor { left = 0, right = 0, top = 0 , bottom = 0 };
188 background = projectViewBackground;
189 foreground = projectViewText;
190 selectionColor = selectionColor, selectionText = selectionText;
191 stippleColor = skyBlue;
193 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
195 if(!active) Update(null);
196 return ListBox::OnActivate(active, previous, goOnWithActivation, direct);
199 bool NotifyDoubleClick(ListBox listBox, int x, int y, Modifiers mods)
201 // Prevent the double click from reactivating the project view (returns false if we opened something)
202 return !OpenSelectedNodes();
205 bool NotifyRightClick(ListBox listBox, int x, int y, Modifiers mods)
207 DataRow row = listBox.currentRow;
210 ProjectNode node = (ProjectNode)row.tag;
211 if(node.type == NodeTypes::project || node.type == resources || node.type == file || node.type == folder)
213 bool buildMenuUnavailable = buildInProgress;
214 Menu popupContent { };
216 if(node.type == NodeTypes::project)
218 //if(node == ((Project)workspace.projects.first).topNode)
220 MenuItem { popupContent, $"Build", b, f7, NotifySelect = ProjectBuild }.disabled = buildMenuUnavailable;
221 MenuItem { popupContent, $"Relink", l, NotifySelect = ProjectLink }.disabled = buildMenuUnavailable;
222 MenuItem { popupContent, $"Rebuild", r, shiftF7, NotifySelect = ProjectRebuild }.disabled = buildMenuUnavailable;
223 MenuItem { popupContent, $"Clean", c, NotifySelect = ProjectClean }.disabled = buildMenuUnavailable;
224 MenuItem { popupContent, $"Real Clean", d, NotifySelect = ProjectRealClean }.disabled = buildMenuUnavailable;
225 MenuItem { popupContent, $"Regenerate Makefile", m, NotifySelect = ProjectRegenerate }.disabled = buildMenuUnavailable;
226 MenuDivider { popupContent };
228 MenuItem { popupContent, $"Debug Generate Symbols", l, NotifySelect = FileDebugGenerateSymbols }.disabled = buildMenuUnavailable;
229 MenuDivider { popupContent };
230 MenuItem { popupContent, $"New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
231 MenuItem { popupContent, $"New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
232 MenuItem { popupContent, $"Import Folder...", i, NotifySelect = ProjectImportFolder };
233 MenuItem { popupContent, $"Add Files to Project...", f, NotifySelect = ProjectAddFiles };
234 MenuDivider { popupContent };
235 MenuItem { popupContent, $"Add New Form...", o, NotifySelect = ProjectAddNewForm };
236 // MenuItem { popupContent, "Add New Behavior Graph...", g, NotifySelect = ProjectAddNewGraph };
237 MenuDivider { popupContent };
238 if(node != ((Project)workspace.projects.first).topNode)
240 MenuItem { popupContent, $"Remove project from workspace", r, NotifySelect = ProjectRemove }.disabled = buildMenuUnavailable;
241 MenuDivider { popupContent };
243 MenuItem { popupContent, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
244 MenuDivider { popupContent };
245 MenuItem { popupContent, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
246 MenuDivider { popupContent };
247 MenuItem { popupContent, $"Save", v, Key { s, ctrl = true }, NotifySelect = ProjectSave }.disabled = !node.modified;
248 MenuDivider { popupContent };
249 MenuItem { popupContent, $"Properties...", p, Key { enter, alt = true }, NotifySelect = FileProperties };
251 else if(node.type == resources)
253 MenuItem { popupContent, $"New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
254 MenuItem { popupContent, $"New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
255 MenuItem { popupContent, $"Import Folder...", i, NotifySelect = ProjectImportFolder };
256 MenuItem { popupContent, $"Add Resources to Project...", f, NotifySelect = ResourcesAddFiles };
257 MenuItem { popupContent, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
258 MenuDivider { popupContent };
259 MenuItem { popupContent, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
260 MenuItem { popupContent, $"Properties...", p, Key { enter, alt = true }, NotifySelect = FileProperties };
262 else if(node.type == file)
264 MenuItem { popupContent, $"Open", o, NotifySelect = FileOpenFile };
265 MenuDivider { popupContent };
266 MenuItem { popupContent, $"Clean", l, NotifySelect = FileClean }.disabled = buildMenuUnavailable;
267 MenuItem { popupContent, $"Compile", c, Key { f7, ctrl = true}, NotifySelect = FileCompile }.disabled = buildMenuUnavailable;
268 MenuDivider { popupContent };
269 MenuItem { popupContent, $"Debug Precompile", l, NotifySelect = FileDebugPrecompile }.disabled = buildMenuUnavailable;
270 MenuItem { popupContent, $"Debug Compile", l, NotifySelect = FileDebugCompile }.disabled = buildMenuUnavailable;
271 MenuDivider { popupContent };
272 MenuItem { popupContent, $"Remove", r, NotifySelect = FileRemoveFile };
273 MenuDivider { popupContent };
274 MenuItem { popupContent, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
275 MenuDivider { popupContent };
276 MenuItem { popupContent, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
277 MenuItem { popupContent, $"Properties..", p, Key { enter, alt = true }, NotifySelect = FileProperties };
279 else if(node.type == folder)
281 bool isInResources = node.isInResources;
283 MenuItem { popupContent, $"New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
284 MenuItem { popupContent, $"New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
285 MenuItem { popupContent, $"Import Folder...", i, NotifySelect = ProjectImportFolder };
288 MenuItem { popupContent, $"Add Resources to Folder...", f, NotifySelect = ResourcesAddFiles };
292 MenuItem { popupContent, $"Add Files to Folder...", f, NotifySelect = ProjectAddFiles };
296 MenuDivider { popupContent };
297 MenuItem { popupContent, $"Add New Form...", o, NotifySelect = ProjectAddNewForm };
298 MenuItem { popupContent, $"Add New Behavior Graph...", g, NotifySelect = ProjectAddNewGraph };
300 MenuDivider { popupContent };
301 MenuItem { popupContent, $"Clean", l, NotifySelect = FileClean }.disabled = buildMenuUnavailable;
302 MenuItem { popupContent, $"Compile", c, Key { f7, ctrl = true}, NotifySelect = FileCompile }.disabled = buildMenuUnavailable;
303 MenuDivider { popupContent };
304 MenuItem { popupContent, $"Remove", r, NotifySelect = FileRemoveFile };
305 MenuDivider { popupContent };
306 MenuItem { popupContent, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
307 MenuDivider { popupContent };
308 MenuItem { popupContent, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
309 MenuItem { popupContent, $"Properties...", p, Key { enter, alt = true }, NotifySelect = FileProperties };
314 master = this, menu = popupContent;
316 x + clientStart.x + absPosition.x - app.desktop.position.x,
317 y + clientStart.y + absPosition.y - app.desktop.position.y };
319 void NotifyDestroyed(Window window, DialogResult result)
325 ide.AdjustPopupBuildMenus();
331 bool NotifyKeyHit(ListBox listBox, DataRow row, Key key, unichar ch)
333 if(key == altUp || key == altDown)
335 SelectNextProject(key == altUp);
341 bool NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch)
345 ProjectNode node = (ProjectNode)row.tag;
348 case altEnter: case Key { keyPadEnter, alt = true }:
350 NodeProperties { parent = parent, master = this,
351 position = { position.x + 100, position.y + 100 }, node = node }.Create();
354 case enter: case keyPadEnter:
357 for(resNode = node.parent; resNode; resNode = resNode.parent)
358 if(resNode.type == resources)
360 if(node.type == project || (node.type == folder && !resNode))
365 else if(node.type == resources || node.type == folder)
374 if(node.type == project || node.type == folder || node.type == resources)
383 if(node.type == project || node.type == folder || node.type == resources)
385 NewFolder(node, null, true);
392 if(node.type == file)
394 FileCompile(null, (Modifiers)key);
399 case Key { space, shift = true }:
402 if(node.type == NodeTypes::project)
405 for(p : workspace.projects)
407 if(p.topNode == node)
413 prj.RotateActiveConfig(!key.shift);
424 case enter: case keyPadEnter: OpenSelectedNodes(); break;
425 case del: RemoveSelectedNodes(); break;
428 Window activeClient = ide.activeClient;
430 activeClient.Activate();
432 ide.RepositionWindows(true);
439 bool NotifyCollapse(ListBox listBox, DataRow row, bool collapsed)
441 ProjectNode node = (ProjectNode)row.tag;
442 if(node.type == folder)
443 node.icon = collapsed ? folder : openFolder;
448 FileDialog importFileDialog { autoCreate = false, type = selectDir, text = $"Import Folder" };
449 FileDialog projectFileDialog
451 autoCreate = false, filters = projectFilters.array, sizeFilters = projectFilters.count * sizeof(FileFilter);
452 types = projectTypes.array, sizeTypes = projectTypes.count * sizeof(FileType);
454 FileDialog fileDialog
456 autoCreate = false, mayNotExist = true, filters = fileFilters.array, sizeFilters = fileFilters.count * sizeof(FileFilter);
458 FileDialog resourceFileDialog
460 autoCreate = false, mayNotExist = true, filters = resourceFilters.array, sizeFilters = resourceFilters.count * sizeof(FileFilter);
463 Menu fileMenu { menu, $"File", f };
464 MenuItem { fileMenu, $"Save", s, Key { s, ctrl = true }, NotifySelect = MenuFileSave };
465 // MenuItem { fileMenu, "Save As...", a, NotifySelect = MenuFileSaveAs };
467 bool OnClose(bool parentClosing)
469 if(!parentClosing && visible)
479 DialogResult dialogRes;
482 strcpy(msg, $"You have modified projects.\nSave changes to ");
483 for(p : ide.workspace.projects)
485 if(p.topNode.modified)
487 if(!first) strcat(msg, ", ");
494 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = msg }.Modal();
498 // TOFIX: Precomp error if brackets are taken out
499 return (DialogResult)MenuFileSave(null, 0) != cancel;
501 else if(dialogRes == cancel)
503 modifiedDocument = false;
510 //if(ide.findInFilesDialog && ide.findInFilesDialog.created && ide.findInFilesDialog.mode != directory)
511 // ide.findInFilesDialog.SearchStop();
513 ide.outputView.buildBox.Clear();
514 ide.outputView.debugBox.Clear();
515 //ide.outputView.findBox.Clear();
516 ide.callStackView.Clear();
517 ide.watchesView.Clear();
518 ide.threadsView.Clear();
519 ide.breakpointsView.Clear();
520 ide.outputView.ShowClearSelectTab(find); // why this?
523 bool OnSaveFile(char * fileName)
525 for(prj : ide.workspace.projects)
527 if(prj.topNode.modified)
529 prj.StopMonitoring();
530 if(prj.Save(prj.filePath))
531 prj.topNode.modified = false;
532 prj.StartMonitoring();
535 modifiedDocument = false;
540 bool IsModuleInProject(char * filePath)
542 char moduleName[MAX_FILENAME]; //, modulePath[MAX_LOCATION];
543 GetLastDirectory(filePath, moduleName);
544 return project.topNode.Find(moduleName, false) != null;
547 bool GetRelativePath(char * filePath, char * relativePath)
549 return project.GetRelativePath(filePath, relativePath);
552 ProjectNode GetNodeFromWindow(Window document, Project project, bool isCObject)
554 if(document.fileName)
556 char winFileName[MAX_LOCATION];
557 char * documentFileName = GetSlashPathBuffer(winFileName, document.fileName);
562 char name[MAX_FILENAME];
563 GetLastDirectory(documentFileName, name);
564 ChangeExtension(name, "ec", name);
565 for(p : ide.workspace.projects)
567 prj = project ? project : p;
568 if((node = prj.topNode.Find(name, false)))
575 for(p : ide.workspace.projects)
577 prj = project ? project : p;
578 if((node = prj.topNode.FindByFullPath(documentFileName, false)))
587 // ((( UTILITY FUNCTIONS )))
589 // ************************************************************************
590 // *** These methods below are part of a sequence of events, and as ***
591 // *** such they must be passed the current compiler and project config ***
592 // ************************************************************************
593 bool DisplayCompiler(CompilerConfig compiler, bool cleanLog)
595 ide.outputView.buildBox.Logf($"%s Compiler\n", compiler ? compiler.name : $"{problem with compiler selection}");
599 bool ProjectPrepareForToolchain(Project project, PrepareMakefileMethod method, bool cleanLog, bool displayCompiler,
600 CompilerConfig compiler, ProjectConfig config)
603 char message[MAX_F_STRING];
604 LogBox logBox = ide.outputView.buildBox;
606 ShowOutputBuildLog(cleanLog);
609 DisplayCompiler(compiler, false);
611 ProjectPrepareCompiler(project, compiler, false);
612 ProjectPrepareMakefile(project, method, compiler, config);
616 bool ProjectPrepareCompiler(Project project, CompilerConfig compiler, bool silent)
618 if((!project.GenerateCrossPlatformMk(app.includeFile) || !project.GenerateCompilerCf(compiler)) && !silent)
619 ide.outputView.buildBox.Logf($"Error generating compiler configuration (Is the project/config directory writable?)\n");
623 // Note: Compiler is only passed in to for VisualStudio support
624 bool ProjectPrepareMakefile(Project project, PrepareMakefileMethod method, CompilerConfig compiler, ProjectConfig config)
626 if(compiler.type.isVC)
628 // I'm guessing we'll want to support generating VS files on Linux as well...
629 ide.statusBar.text = $"Generating Visual Studio Solution...";
631 //GenerateVSSolutionFile(project, compiler);
632 ide.statusBar.text = $"Generating Visual Studio Project...";
634 //GenerateVCProjectFile(project, compiler);
635 ide.statusBar.text = null;
641 char makefilePath[MAX_LOCATION];
642 char makefileName[MAX_LOCATION];
644 LogBox logBox = ide.outputView.buildBox;
646 strcpy(makefilePath, project.topNode.path);
647 project.CatMakeFileName(makefileName, config);
648 PathCatSlash(makefilePath, makefileName);
650 exists = FileExists(makefilePath);
651 if(method == force ||
652 (method == forceExists && exists) ||
653 (method == normal && (!exists || (config && config.makingModified))))
657 ide.statusBar.text = $"Generating Makefile & Dependencies..."; // Dependencies?
660 if((method == normal && !exists) || (method == force && !exists))
661 action = $"Generating ";
662 else if(method == force)
663 action = $"Regenerating ";
664 else if(method == normal || method == forceExists)
665 action = $"Updating ";
669 reason = $"Makefile doesn't exist. ";
670 else if(project.topNode.modified)
671 reason = $"Project has been modified. ";
675 //logBox.Logf("%s\n", makefileName);
676 logBox.Logf($"%s - %s%smakefile for %s config...\n", makefileName, reason, action, GetConfigName(config));
678 if(!project.GenerateMakefile(null, false, null, config))
679 ide.outputView.buildBox.Logf($"Error generating makefile (Is the project directory writable?)\n");
681 ide.statusBar.text = null;
689 bool BuildInterrim(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config, bool justPrint)
691 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
693 ide.outputView.buildBox.Logf($"Building project %s using the %s configuration...\n", prj.name, GetConfigName(config));
694 return Build(prj, buildType, compiler, config, justPrint);
699 bool DebugStopForMake(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config)
702 // TOFIX: DebugStop is being abused and backfiring on us.
703 // It's supposed to be the 'Debug/Stop' item, not unloading executable or anything else
705 // configIsInDebugSession seems to be used for two OPPOSITE things:
706 // If we're debugging another config, we need to unload the executable!
707 // In building, we want to stop if we're debugging the 'same' executable
708 if(buildType != run) ///* && prj == project*/ && prj.configIsInDebugSession)
710 if(buildType == start || buildType == restart)
712 if(ide.debugger && ide.debugger.isPrepared)
713 result = DebugStop();
717 if(ide.project == prj && ide.debugger && ide.debugger.prjConfig == config && ide.debugger.isPrepared)
718 result = DebugStop();
724 bool Build(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config, bool justPrint)
730 for(document = master.firstChild; document; document = document.next)
732 if(document.modifiedDocument)
734 ProjectNode node = GetNodeFromWindow(document, prj, false);
735 if(node && !document.MenuFileSave(null, 0))
744 DirExpression targetDir = prj.GetTargetDir(compiler, config);
746 DebugStopForMake(prj, buildType, compiler, config);
748 // TODO: Disabled until problems fixed... is it fixed?
749 if(buildType == rebuild || (config && config.compilingModified))
750 prj.Clean(compiler, config, clean, justPrint);
753 if(buildType == relink || (config && config.linkingModified))
754 prj.Clean(compiler, config, cleanTarget, false);
755 if(config && config.symbolGenModified)
757 DirExpression objDir = prj.GetObjDir(compiler, config);
758 char fileName[MAX_LOCATION];
759 char moduleName[MAX_FILENAME];
760 strcpy(fileName, prj.topNode.path);
761 PathCatSlash(fileName, objDir.dir);
762 strcpy(moduleName, prj.moduleName);
763 strcat(moduleName, ".main.ec");
764 PathCatSlash(fileName, moduleName);
765 if(FileExists(fileName))
766 DeleteFile(fileName);
767 ChangeExtension(fileName, "c", fileName);
768 if(FileExists(fileName))
769 DeleteFile(fileName);
770 ChangeExtension(fileName, "o", fileName);
771 if(FileExists(fileName))
772 DeleteFile(fileName);
777 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
778 ide.AdjustBuildMenus();
779 ide.AdjustDebugMenus();
781 result = prj.Build(buildType == run, null, compiler, config, justPrint, normal);
785 config.compilingModified = false;
786 if(!ide.ShouldStopBuild())
787 config.linkingModified = false;
789 config.symbolGenModified = false;
791 buildInProgress = none;
792 ide.AdjustBuildMenus();
793 ide.AdjustDebugMenus();
795 ide.workspace.modified = true;
802 // ((( USER ACTIONS )))
804 // ************************************************************************
805 // *** Methods below should atomically start a process, and as such ***
806 // *** they can query compiler and config directly from ide and project ***
807 // *** but ONLY ONCE!!! ***
808 // ************************************************************************
810 bool ProjectBuild(MenuItem selection, Modifiers mods)
812 if(buildInProgress == none)
814 Project prj = project;
815 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
816 ProjectConfig config;
817 if(selection || !ide.activeClient)
819 DataRow row = fileList.currentRow;
820 ProjectNode node = row ? (ProjectNode)row.tag : null;
821 if(node) prj = node.project;
825 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
830 if(/*prj != project || */!prj.GetConfigIsInDebugSession(config) || !ide.DontTerminateDebugSession($"Project Build"))
832 BuildInterrim(prj, build, compiler, config, mods.ctrl && mods.shift);
841 bool ProjectLink(MenuItem selection, Modifiers mods)
843 Project prj = project;
844 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
845 ProjectConfig config;
846 if(selection || !ide.activeClient)
848 DataRow row = fileList.currentRow;
849 ProjectNode node = row ? (ProjectNode)row.tag : null;
850 if(node) prj = node.project;
854 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
859 if(!prj.GetConfigIsInDebugSession(config) ||
860 (!ide.DontTerminateDebugSession($"Project Link") && DebugStopForMake(prj, relink, compiler, config)))
862 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
864 ide.outputView.buildBox.Logf($"Relinking project %s using the %s configuration...\n", prj.name, GetConfigName(config));
866 config.linkingModified = true;
867 Build(prj, relink, compiler, config, mods.ctrl && mods.shift);
874 bool ProjectRebuild(MenuItem selection, Modifiers mods)
876 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
877 Project prj = project;
878 ProjectConfig config;
879 if(selection || !ide.activeClient)
881 DataRow row = fileList.currentRow;
882 ProjectNode node = row ? (ProjectNode)row.tag : null;
883 if(node) prj = node.project;
887 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
892 if(!prj.GetConfigIsInDebugSession(config) ||
893 (!ide.DontTerminateDebugSession($"Project Rebuild") && DebugStopForMake(prj, rebuild, compiler, config)))
895 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
897 ide.outputView.buildBox.Logf($"Rebuilding project %s using the %s configuration...\n", prj.name, GetConfigName(config));
900 config.compilingModified = true;
901 config.makingModified = true;
902 }*/ // -- should this still be used depite the new solution of BuildType?
903 Build(prj, rebuild, compiler, config, mods.ctrl && mods.shift);
911 bool ProjectCleanTarget(MenuItem selection, Modifiers mods)
913 Project prj = project;
914 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
915 ProjectConfig config;
916 if(selection || !ide.activeClient)
918 DataRow row = fileList.currentRow;
919 ProjectNode node = row ? (ProjectNode)row.tag : null;
920 if(node) prj = node.project;
924 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
929 if(!prj.GetConfigIsInDebugSession(config) ||
930 (!ide.DontTerminateDebugSession($"Project Clean Target") && DebugStopForMake(prj, clean, compiler, config)))
932 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
934 ide.outputView.buildBox.Logf($"Cleaning target for project %s using the %s configuration...\n", prj.name, GetConfigName(config));
936 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
937 ide.AdjustBuildMenus();
938 ide.AdjustDebugMenus();
940 prj.Clean(compiler, config, cleanTarget, mods.ctrl && mods.shift);
941 buildInProgress = none;
942 ide.AdjustBuildMenus();
943 ide.AdjustDebugMenus();
951 bool ProjectClean(MenuItem selection, Modifiers mods)
953 Project prj = project;
954 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
955 ProjectConfig config;
956 if(selection || !ide.activeClient)
958 DataRow row = fileList.currentRow;
959 ProjectNode node = row ? (ProjectNode)row.tag : null;
960 if(node) prj = node.project;
964 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
969 if(!prj.GetConfigIsInDebugSession(config) ||
970 (!ide.DontTerminateDebugSession($"Project Clean") && DebugStopForMake(prj, clean, compiler, config)))
972 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
974 ide.outputView.buildBox.Logf($"Cleaning project %s using the %s configuration...\n", prj.name, GetConfigName(config));
976 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
977 ide.AdjustBuildMenus();
978 ide.AdjustDebugMenus();
980 prj.Clean(compiler, config, clean, mods.ctrl && mods.shift);
981 buildInProgress = none;
982 ide.AdjustBuildMenus();
983 ide.AdjustDebugMenus();
990 bool ProjectRealClean(MenuItem selection, Modifiers mods)
992 Project prj = project;
993 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
994 ProjectConfig config;
995 if(selection || !ide.activeClient)
997 DataRow row = fileList.currentRow;
998 ProjectNode node = row ? (ProjectNode)row.tag : null;
999 if(node) prj = node.project;
1003 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
1007 config = prj.config;
1008 if(!prj.GetConfigIsInDebugSession(config) ||
1009 (!ide.DontTerminateDebugSession($"Project Real Clean") && DebugStopForMake(prj, clean, compiler, config)))
1011 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
1013 ide.outputView.buildBox.Logf($"Removing intermediate objects directory for project %s using the %s configuration...\n", prj.name, GetConfigName(config));
1015 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
1016 ide.AdjustBuildMenus();
1017 ide.AdjustDebugMenus();
1019 prj.Clean(compiler, config, realClean, mods.ctrl && mods.shift);
1020 buildInProgress = none;
1021 ide.AdjustBuildMenus();
1022 ide.AdjustDebugMenus();
1029 bool ProjectRegenerate(MenuItem selection, Modifiers mods)
1031 Project prj = project;
1032 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1033 ShowOutputBuildLog(true);
1034 if(selection || !ide.activeClient)
1036 DataRow row = fileList.currentRow;
1037 ProjectNode node = row ? (ProjectNode)row.tag : null;
1043 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
1048 DisplayCompiler(compiler, false);
1049 ProjectPrepareCompiler(project, compiler, false);
1050 ProjectPrepareMakefile(prj, force, compiler, prj.config);
1055 bool Compile(Project project, List<ProjectNode> nodes, bool justPrint, SingleFileCompileMode mode)
1058 char fileName[MAX_LOCATION];
1060 ProjectConfig config = project.config;
1064 for(document = ide.firstChild; document; document = document.next)
1066 if(document.modifiedDocument)
1068 ProjectNode n = GetNodeFromWindow(document, project, mode == cObject ? true : false);
1071 if(n && n.IsInNode(node) && !document.MenuFileSave(null, 0))
1073 ide.outputView.buildBox.Logf($"Unable to save %s file.\n", node.name);
1083 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1085 if(ProjectPrepareForToolchain(project, normal, true, true, compiler, config))
1088 ide.outputView.buildBox.Logf($"%s specific file(s) in project %s using the %s configuration...\n",
1089 mode == normal ? $"Compiling" : $"Debug compiling", project.name, config.name);
1091 ide.outputView.buildBox.Logf($"%s specific file(s) in project %s...\n",
1092 mode == normal ? $"Compiling" : $"Debug compiling", project.name);
1094 buildInProgress = compilingFile;
1095 ide.AdjustBuildMenus();
1096 project.Compile(nodes, compiler, config, justPrint, mode);
1097 buildInProgress = none;
1098 ide.AdjustBuildMenus();
1107 bool Clean(Project project, List<ProjectNode> nodes, bool justPrint)
1110 char fileName[MAX_LOCATION];
1112 ProjectConfig config = project.config;
1116 for(document = ide.firstChild; document; document = document.next)
1118 if(document.modifiedDocument)
1120 ProjectNode n = GetNodeFromWindow(document, project, false);
1123 if(n && n.IsInNode(node) && !document.MenuFileSave(null, 0))
1125 ide.outputView.buildBox.Logf($"Unable to save %s file.\n", node.name);
1135 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1137 if(ProjectPrepareForToolchain(project, normal, true, true, compiler, config))
1139 Map<String, NameCollisionInfo> namesInfo { };
1140 project.topNode.GenMakefileGetNameCollisionInfo(namesInfo, config);
1143 if(node.GetIsExcluded(config))
1144 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
1148 ide.outputView.buildBox.Logf($"Deleteing intermediate objects for %s %s in project %s using the %s configuration...\n",
1149 node.type == file ? $"single file" : $"folder", node.name, project.name, config.name);
1151 ide.outputView.buildBox.Logf($"Deleteing intermediate objects for %s %s in project %s...\n",
1152 node.type == file ? $"single file" : $"folder", node.name, project.name);
1154 node.DeleteIntermediateFiles(compiler, config, namesInfo, false);
1166 bool ProjectNewFile(MenuItem selection, Modifiers mods)
1168 DataRow row = fileList.currentRow;
1171 char fileName[1024];
1172 char filePath[MAX_LOCATION];
1173 ProjectNode parentNode = (ProjectNode)row.tag;
1174 ProjectNode n, fileNode;
1175 parentNode.GetFileSysMatchingPath(filePath);
1176 MakePathRelative(filePath, parentNode.project.topNode.path, filePath);
1177 for(n = parentNode; n && n != parentNode.project.resNode; n = n.parent);
1178 sprintf(fileName, $"Untitled %d", documentID);
1179 fileNode = AddFile(parentNode, fileName, (bool)n, true);
1180 fileNode.path = CopyUnixPath(filePath);
1183 NodeProperties nodeProperties
1186 position = { position.x + 100, position.y + 100 };
1190 nodeProperties.Create(); // not modal?
1196 bool ProjectNewFolder(MenuItem selection, Modifiers mods)
1198 DataRow row = fileList.currentRow;
1201 ProjectNode parentNode = (ProjectNode)row.tag;
1202 NewFolder(parentNode, null, true);
1207 bool ResourcesAddFiles(MenuItem selection, Modifiers mods)
1213 bool ProjectAddFiles(MenuItem selection, Modifiers mods)
1219 bool ProjectImportFolder(MenuItem selection, Modifiers mods)
1221 DataRow row = fileList.currentRow;
1224 ProjectNode toNode = (ProjectNode)row.tag;
1225 ImportFolder(toNode);
1230 bool ProjectAddNewForm(MenuItem selection, Modifiers mods)
1232 CodeEditor codeEditor = CreateNew("Form", "form", "Window", null);
1233 codeEditor.EnsureUpToDate();
1237 bool ProjectAddNewGraph(MenuItem selection, Modifiers mods)
1239 CodeEditor codeEditor = CreateNew("Graph", "graph", "Block", null);
1241 codeEditor.EnsureUpToDate();
1245 bool ProjectRemove(MenuItem selection, Modifiers mods)
1247 DataRow row = fileList.currentRow;
1250 ProjectNode node = (ProjectNode)row.tag;
1251 if(node.type == project)
1252 RemoveSelectedNodes();
1257 bool ProjectUpdateMakefileForAllConfigs(Project project)
1259 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1261 // This call really does not belong here:
1262 ide.UpdateToolBarActiveConfigs(false);
1263 for(config : project.configurations)
1264 ProjectPrepareMakefile(project, forceExists, compiler, config);
1271 bool MenuSettings(MenuItem selection, Modifiers mods)
1273 ProjectNode node = GetSelectedNode(true);
1274 Project prj = node ? node.project : project;
1275 projectSettingsDialog = ProjectSettings { master = parent, project = prj, projectNode = node };
1276 projectSettingsDialog.Modal();
1283 bool FileProperties(MenuItem selection, Modifiers mods)
1285 DataRow row = fileList.currentRow;
1288 ProjectNode node = (ProjectNode)row.tag;
1289 NodeProperties { parent = parent, master = this, node = node,
1290 position = { position.x + 100, position.y + 100 } }.Create();
1295 bool FileOpenFile(MenuItem selection, Modifiers mods)
1297 OpenSelectedNodes();
1301 bool FileRemoveFile(MenuItem selection, Modifiers mods)
1303 RemoveSelectedNodes();
1307 bool FileCompile(MenuItem selection, Modifiers mods)
1310 OldList selectedRows;
1311 Project project = null;
1312 List<ProjectNode> nodes { };
1313 fileList.GetMultiSelection(selectedRows);
1314 for(item = selectedRows.first; item; item = item.next)
1317 DataRow row = item.data;
1318 ProjectNode node = (ProjectNode)row.tag;
1320 project = node.project;
1321 else if(node.project != project)
1328 selectedRows.Free(null);
1330 Compile(project, nodes, mods.ctrl && mods.shift, normal);
1332 ide.outputView.buildBox.Logf($"Please select files from a single project.\n");
1337 bool FileClean(MenuItem selection, Modifiers mods)
1340 OldList selectedRows;
1341 Project project = null;
1342 List<ProjectNode> nodes { };
1343 fileList.GetMultiSelection(selectedRows);
1344 for(item = selectedRows.first; item; item = item.next)
1347 DataRow row = item.data;
1348 ProjectNode node = (ProjectNode)row.tag;
1350 project = node.project;
1351 else if(node.project != project)
1358 selectedRows.Free(null);
1360 Clean(project, nodes, mods.ctrl && mods.shift);
1362 ide.outputView.buildBox.Logf($"Please select files from a single project.\n");
1367 bool FileDebugPrecompile(MenuItem selection, Modifiers mods)
1369 DataRow row = fileList.currentRow;
1370 ProjectNode node = row ? (ProjectNode)row.tag : null;
1373 List<ProjectNode> nodes { };
1375 Compile(node.project, nodes, mods.ctrl && mods.shift, debugPrecompile);
1380 bool FileDebugCompile(MenuItem selection, Modifiers mods)
1382 DataRow row = fileList.currentRow;
1383 ProjectNode node = row ? (ProjectNode)row.tag : null;
1386 List<ProjectNode> nodes { };
1388 Compile(node.project, nodes, mods.ctrl && mods.shift, debugCompile);
1393 bool FileDebugGenerateSymbols(MenuItem selection, Modifiers mods)
1395 DataRow row = fileList.currentRow;
1396 ProjectNode node = row ? (ProjectNode)row.tag : null;
1399 List<ProjectNode> nodes { };
1401 Compile(node.project, nodes, mods.ctrl && mods.shift, debugGenerateSymbols);
1406 Project GetSelectedProject(bool useSelection)
1408 Project prj = project;
1411 DataRow row = fileList.currentRow;
1412 ProjectNode node = row ? (ProjectNode)row.tag : null;
1419 void SelectNextProject(bool backwards)
1421 DataRow row = fileList.currentRow;
1422 DataRow currentRow = row;
1423 ProjectNode node = (ProjectNode)row.tag;
1424 if(node.type != project)
1425 row = node.project.topNode.row;
1427 row = row.previous ? row.previous : fileList.lastRow;
1429 row = row.next ? row.next : fileList.firstRow;
1430 if(row && row != currentRow)
1432 fileList.SelectRow(row);
1433 fileList.currentRow = row;
1437 ProjectNode GetSelectedNode(bool useSelection)
1439 ProjectNode node = null;
1442 DataRow row = fileList.currentRow;
1444 node = (ProjectNode)row.tag;
1449 bool MenuBrowseFolder(MenuItem selection, Modifiers mods)
1451 char folder[MAX_LOCATION];
1453 ProjectNode node = GetSelectedNode(true);
1455 node = project.topNode;
1458 strcpy(folder, prj.topNode.path);
1459 if(node != prj.topNode)
1460 PathCatSlash(folder, node.path);
1465 bool Run(MenuItem selection, Modifiers mods)
1467 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1468 ProjectConfig config = project.config;
1469 String args = new char[maxPathLen];
1471 if(ide.workspace.commandLineArgs)
1472 //ide.debugger.GetCommandLineArgs(args);
1473 strcpy(args, ide.workspace.commandLineArgs);
1474 if(ide.debugger.isActive)
1475 project.Run(args, compiler, config);
1476 /*else if(config.targetType == sharedLibrary || config.targetType == staticLibrary)
1477 MessageBox { master = ide, type = ok, text = "Run", contents = "Shared and static libraries cannot be run like executables." }.Modal();*/
1478 else if(BuildInterrim(project, run, compiler, config, false))
1479 project.Run(args, compiler, config);
1487 bool result = false;
1488 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1489 ProjectConfig config = project.config;
1490 TargetTypes targetType = project.GetTargetType(config);
1491 if(targetType == sharedLibrary || targetType == staticLibrary)
1492 MessageBox { master = ide, type = ok, text = $"Run", contents = $"Shared and static libraries cannot be run like executables." }.Modal();
1493 else if(project.GetCompress(config))
1494 MessageBox { master = ide, text = $"Starting Debug", contents = $"Debugging compressed applications is not supported\n" }.Modal();
1495 else if(project.GetDebug(config) ||
1496 MessageBox { master = ide, type = okCancel, text = $"Starting Debug", contents = $"Attempting to debug non-debug configuration\nProceed anyways?" }.Modal() == ok)
1498 if(/*!IsProjectModified() ||*/ BuildInterrim(project, start, compiler, config, false))
1500 if(compiler.type.isVC)
1502 //bool result = false;
1503 char oldwd[MAX_LOCATION];
1504 PathBackup pathBackup { };
1505 char command[MAX_LOCATION];
1507 ide.SetPath(false, compiler, config);
1509 GetWorkingDir(oldwd, sizeof(oldwd));
1510 ChangeWorkingDir(project.topNode.path);
1512 sprintf(command, "%s /useenv %s.sln /projectconfig \"%s|Win32\" /command \"%s\"" , "devenv", project.name, config.name, "Debug.Start");
1514 ChangeWorkingDir(oldwd);
1520 ide.debugger.Start(compiler, config);
1529 void GoToError(const char * line)
1533 while(isspace(*line)) line++;
1534 colon = strstr(line, ":");
1539 bool lookForLineNumber = true;
1541 // deal with linking error
1542 if(colon && colon[1] == ' ')
1544 colon = strstr(colon + 1, ":");
1545 if(colon && !colon[1])
1547 colon = strstr(line, ":");
1548 lookForLineNumber = false;
1550 else if(colon && !isdigit(colon[1]))
1553 colon = strstr(line, ":");
1556 // Don't be mistaken by the drive letter colon
1557 if(colon && (colon[1] == '/' || colon[1] == '\\'))
1558 colon = strstr(colon + 1, ":");
1559 if(colon && lookForLineNumber)
1563 char * par = RSearchString(line, "(", colon - line, true, false);
1564 if(par && strstr(par, ")"))
1566 else if((colon+1)[0] == ' ')
1568 // NOTE: This is the same thing as saying 'colon = line'
1569 for( ; colon != line; colon--)
1573 lineNumber = atoi(colon + 1);
1575 comma = strchr(colon, ',');
1577 col = atoi(comma+1);
1579 comma = strchr(colon+1, ':');
1581 col = atoi(comma+1);
1585 char moduleName[MAX_LOCATION], filePath[MAX_LOCATION];
1589 char * inFileIncludedFrom = strstr(line, stringInFileIncludedFrom);
1590 char * start = inFileIncludedFrom ? line + strlen(stringInFileIncludedFrom) : line;
1591 int len = (int)(colon - start);
1592 len = Min(len, MAX_LOCATION-1);
1594 strncpy(moduleName, start, len);
1595 moduleName[len] = '\0';
1598 strcpy(moduleName, line);
1600 // Remove stuff in brackets
1602 bracket = strstr(moduleName, "(");
1603 if(bracket) *bracket = '\0';
1605 MakeSlashPath(moduleName);
1609 // Check if it's one of our modules
1610 ProjectNode node = project.topNode.Find(moduleName, false);
1613 strcpy(moduleName, node.path);
1614 PathCatSlash(moduleName, node.name);
1617 moduleName[0] = '\0';
1621 CodeEditor codeEditor;
1622 strcpy(filePath, project.topNode.path);
1623 PathCatSlash(filePath, moduleName);
1625 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
1628 char name[MAX_LOCATION];
1629 // TOFIX: Improve on this, don't use only filename, make a function
1630 if(ide && ide.workspace)
1632 for(prj : ide.workspace.projects)
1634 if(prj.topNode.FindWithPath(moduleName, false))
1636 strcpy(filePath, prj.topNode.path);
1637 PathCatSlash(filePath, moduleName);
1638 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
1645 if(codeEditor && lineNumber)
1647 EditBox editBox = codeEditor.editBox;
1648 editBox.GoToLineNum(lineNumber - 1);
1649 editBox.GoToPosition(editBox.line, lineNumber - 1, col ? (col - 1) : 0);
1656 bool OpenNode(ProjectNode node)
1658 char filePath[MAX_LOCATION];
1659 node.GetFullFilePath(filePath);
1660 return ide.OpenFile(filePath, normal, true/*false Why was it opening hidden?*/, null, something, normal) ? true : false;
1663 void AddNode(ProjectNode node, DataRow addTo)
1665 DataRow row = addTo ? addTo.AddRow() : fileList.AddRow();
1667 row.tag = (int64)node;
1670 if(node.type == resources)
1673 row.SetData(null, node);
1675 if(node.files && node.files.first && node.parent &&
1676 !(!node.parent.parent &&
1677 (!strcmpi(node.name, "notes") || !strcmpi(node.name, "sources") ||
1678 !strcmpi(node.name, "src") || !strcmpi(node.name, "tools"))))
1679 row.collapsed = true;
1680 else if(node.type == folder)
1681 node.icon = openFolder;
1685 for(child : node.files)
1686 AddNode(child, row);
1690 void DeleteNode(ProjectNode projectNode)
1692 if(projectNode.files)
1695 while(child = projectNode.files.first)
1698 fileList.DeleteRow(projectNode.row);
1699 projectNode.Delete();
1702 bool ProjectSave(MenuItem selection, Modifiers mods)
1704 DataRow row = fileList.currentRow;
1705 ProjectNode node = row ? (ProjectNode)row.tag : null;
1706 Project prj = node ? node.project : null;
1709 prj.StopMonitoring();
1710 if(prj.Save(prj.filePath))
1712 Project modPrj = null;
1713 prj.topNode.modified = false;
1714 for(p : ide.workspace.projects)
1716 if(p.topNode.modified)
1723 modifiedDocument = false;
1726 prj.StartMonitoring();
1731 bool ShowOutputBuildLog(bool cleanLog)
1733 OutputView output = ide.outputView;
1735 output.ShowClearSelectTab(build);
1738 output.SelectTab(build);
1746 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1747 ProjectConfig config = project.config;
1749 bool result = false;
1750 if(/*!IsProjectModified() ||*/ BuildInterrim(project, restart, compiler, config, false))
1752 // For Restart, compiler and config will only be used if for
1753 // whatever reason (if at all possible) the Debugger is in a
1754 // 'terminated' or 'none' state
1755 ide.debugger.Restart(compiler, config);
1765 ide.debugger.Resume();
1771 ide.debugger.Break();
1777 ide.debugger.Stop();
1781 bool DebugStepInto()
1783 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1784 ProjectConfig config = project.config;
1786 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config, false)))
1787 ide.debugger.StepInto(compiler, config);
1792 bool DebugStepOver(bool skip)
1794 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1795 ProjectConfig config = project.config;
1797 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config, false)))
1798 ide.debugger.StepOver(compiler, config, skip);
1804 bool DebugStepOut(bool skip)
1806 ide.debugger.StepOut(skip);
1810 void ImportFolder(ProjectNode toNode)
1814 //bool isFolder = toNode.type == folder;
1815 //bool isRes = toNode.isInResources;
1817 FileDialog fileDialog = importFileDialog;
1818 fileDialog.master = parent;
1819 if(fileDialog.Modal() == ok)
1821 ImportFolderFSI fsi { projectView = this };
1822 fsi.stack.Add(toNode);
1823 fsi.Iterate(fileDialog.filePath);
1829 ProjectNode NewFolder(ProjectNode parentNode, char * name, bool showProperties)
1833 ProjectNode folderNode;
1834 Project prj = parentNode.project;
1836 ProjectNode after = null;
1837 for(node : parentNode.files)
1839 if(node.type != folder)
1845 folderNode = parentNode.Add(prj, name, after, folder, folder, true);
1848 for(c = 0; c < 100; c++)
1851 sprintf(string, c ? "New Folder (%d)" : "New Folder", c);
1852 if((folderNode = parentNode.Add(prj, string, after, folder, folder, true)))
1859 NodeProperties nodeProperties;
1862 modifiedDocument = true;
1863 prj.topNode.modified = true;
1866 folderNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
1867 folderNode.row.tag = (int64)folderNode;
1869 folderNode.row.SetData(null, folderNode);
1870 fileList.currentRow = folderNode.row;
1874 nodeProperties = NodeProperties
1876 parent, this, mode = newFolder, node = folderNode;
1877 position = { position.x + 100, position.y + 100 };
1879 nodeProperties.Create(); // Modal?
1887 void AddFiles(bool resources)
1889 FileDialog fileDialog = (!resources) ? this.fileDialog : resourceFileDialog;
1890 fileDialog.type = multiOpen;
1891 fileDialog.text = !resources ? $"Add Files to Project" : $"Add Resources to Project";
1892 fileDialog.master = parent;
1894 if(fileDialog.Modal() == ok)
1897 DataRow row = fileList.currentRow;
1898 ProjectNode parentNode = (ProjectNode)row.tag;
1899 bool addFailed = false;
1900 int numSelections = fileDialog.numSelections;
1901 char ** multiFilePaths = fileDialog.multiFilePaths;
1903 Array<String> nameConflictFiles { };
1905 for(c = 0; c < numSelections; c++)
1907 char * filePath = multiFilePaths[c];
1908 FileAttribs exists = FileExists(filePath);
1909 bool addThisFile = true;
1911 if(exists.isDirectory)
1912 addThisFile = false;
1915 if(MessageBox { master = ide, type = yesNo, text = filePath,
1916 contents = $"File doesn't exist. Create?" }.Modal() == yes)
1918 File f = FileOpen(filePath, write);
1926 MessageBox { master = ide, type = ok, text = filePath,
1927 contents = $"Couldn't create file."}.Modal();
1928 addThisFile = false;
1935 /*addFailed = */if(!AddFile(parentNode, filePath, resources, false))//;
1937 nameConflictFiles.Add(CopyString(filePath));
1945 char * part1 = $"The following file";
1946 char * opt1 = $" was ";
1947 char * opt2 = $"s were ";
1948 char * part2 = $"not added because of identical file name conflict within the project.\n\n";
1950 len += strlen(part1);
1951 len += strlen(part2);
1952 len += nameConflictFiles.count > 1 ? strlen(opt2) : strlen(opt1);
1953 for(s : nameConflictFiles)
1954 len += strlen(s) + 1;
1955 message = new char[len + 1];
1956 strcpy(message, part1);
1957 strcat(message, nameConflictFiles.count > 1 ? opt2 : opt1);
1958 strcat(message, part2);
1959 for(s : nameConflictFiles)
1962 strcat(message, "\n");
1964 MessageBox { master = ide, type = ok, text = $"Name Conflict",
1965 contents = message }.Modal();
1968 nameConflictFiles.Free();
1969 delete nameConflictFiles;
1973 ProjectNode AddFile(ProjectNode parentNode, char * filePath, bool resources, bool isTemporary)
1975 ProjectNode result = null;
1976 ProjectNode after = null;
1977 for(node : parentNode.files)
1979 if(node.type != folder && node.type != file && node.type)
1984 result = parentNode.Add(parentNode.project, filePath, after, file, NodeIcons::SelectFileIcon(filePath), !resources);
1990 modifiedDocument = true;
1991 parentNode.project.topNode.modified = true;
1992 parentNode.project.ModifiedAllConfigs(true, false, true, true);
1995 result.row = parentNode.row.AddRowAfter(after ? after.row : null);
1996 result.row.tag = (int64)result;
1997 result.row.SetData(null, result);
2002 CodeEditor CreateNew(char * upper, char * lower, char * base, char * className)
2004 CodeEditor codeEditor = null;
2005 ProjectNode projectNode;
2006 ProjectNode after = null;
2007 DataRow row = fileList.currentRow;
2008 ProjectNode parentNode;
2011 if(!row) row = project.topNode.row;
2013 parentNode = (ProjectNode)row.tag;
2015 for(node : parentNode.files)
2017 if(node.type != folder && node.type != file && node.type)
2021 for(c = 1; c < 100; c++)
2024 sprintf(string, c ? "%s%d.ec" : "%s.ec", lower, c);
2025 if((projectNode = parentNode.Add(project, string, after, file, genFile, true)))
2031 char filePath[MAX_LOCATION];
2033 modifiedDocument = true;
2034 project.topNode.modified = true;
2036 project.ModifiedAllConfigs(true, false, false, true);
2037 projectNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
2038 projectNode.row.tag =(int64)projectNode;
2040 projectNode.row.SetData(null, projectNode);
2041 fileList.currentRow = projectNode.row;
2043 strcpy(filePath, project.topNode.path);
2044 PathCat(filePath, projectNode.path);
2045 PathCat(filePath, projectNode.name);
2047 codeEditor = (CodeEditor)ide.FindWindow(filePath);
2050 Class baseClass = eSystem_FindClass(__thisModule, base);
2051 subclass(ClassDesignerBase) designerClass = eClass_GetDesigner(baseClass);
2054 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal);
2055 strcpy(name, projectNode.name);
2056 sprintf(name, "%s%d", upper, c);
2058 strcpy(className, name);
2060 designerClass.CreateNew(codeEditor.editBox, codeEditor.clientSize, name, base);
2062 //codeEditor.modifiedDocument = false;
2063 //codeEditor.designer.modifiedDocument = false;
2065 //Code_EnsureUpToDate(codeEditor);
2068 else // TODO: fix no symbols generated when ommiting {} for following else
2070 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal);
2074 codeEditor.ViewDesigner();
2075 codeEditor.codeModified = true;
2082 // Returns true if we opened something
2083 bool OpenSelectedNodes()
2085 bool result = false;
2089 fileList.GetMultiSelection(selection);
2090 for(item = selection.first; item; item = item.next)
2092 DataRow row = item.data;
2093 ProjectNode node = (ProjectNode)row.tag;
2094 if(node.type == file)
2101 selection.Free(null);
2105 void RemoveSelectedNodes()
2110 fileList.GetMultiSelection(selection);
2112 // Remove children of parents we're deleting
2113 for(item = selection.first; item; item = next)
2116 DataRow row = item.data;
2117 ProjectNode n, node = (ProjectNode)row.tag;
2118 bool remove = false;
2121 for(i = selection.first; i && !remove; i = i.next)
2123 ProjectNode iNode = (ProjectNode)((DataRow)i.data).tag;
2124 for(n = node.parent; n; n = n.parent)
2134 selection.Delete(item);
2137 for(item = selection.first; item; item = item.next)
2139 DataRow row = item.data;
2140 ProjectNode node = (ProjectNode)row.tag;
2141 ProjectNode resNode;
2142 for(resNode = node.parent; resNode; resNode = resNode.parent)
2143 if(resNode.type == resources)
2145 if(node.type == file)
2147 Project prj = node.project;
2149 modifiedDocument = true;
2150 prj.topNode.modified = true;
2152 prj.ModifiedAllConfigs(true, false, true, true);
2154 else if(node.type == folder)
2157 sprintf(message, $"Are you sure you want to remove the folder \"%s\"\n"
2158 "and all of its contents from the project?", node.name);
2159 if(MessageBox { master = ide, type = yesNo, text = $"Delete Folder", contents = message }.Modal() == yes)
2161 Project prj = node.project;
2162 if(node.containsFile)
2163 prj.ModifiedAllConfigs(true, false, true, true);
2165 modifiedDocument = true;
2166 prj.topNode.modified = true;
2169 else if(node.type == project && node != project.topNode && !buildInProgress)
2173 for(p : workspace.projects)
2175 if(p.topNode == node)
2181 sprintf(message, $"Are you sure you want to remove the \"%s\" project\n" "from this workspace?", node.name);
2182 if(MessageBox { master = ide, type = yesNo, text = $"Remove Project", contents = message }.Modal() == yes)
2187 workspace.RemoveProject(prj);
2188 //modifiedDocument = true; // when project view is a workspace view
2192 selection.Free(null);