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, NotifySelect = ProjectBuild }.disabled = buildMenuUnavailable;
221 MenuItem { popupContent, $"Relink", l, NotifySelect = ProjectLink }.disabled = buildMenuUnavailable;
222 MenuItem { popupContent, $"Rebuild", r, 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)
330 bool NotifyKeyHit(ListBox listBox, DataRow row, Key key, unichar ch)
332 if(key == altUp || key == altDown)
334 SelectNextProject(key == altUp);
340 bool NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch)
344 ProjectNode node = (ProjectNode)row.tag;
347 case altEnter: case Key { keyPadEnter, alt = true }:
349 NodeProperties { parent = parent, master = this,
350 position = { position.x + 100, position.y + 100 }, node = node }.Create();
353 case enter: case keyPadEnter:
356 for(resNode = node.parent; resNode; resNode = resNode.parent)
357 if(resNode.type == resources)
359 if(node.type == project || (node.type == folder && !resNode))
364 else if(node.type == resources || node.type == folder)
373 if(node.type == project || node.type == folder || node.type == resources)
382 if(node.type == project || node.type == folder || node.type == resources)
384 NewFolder(node, null, true);
391 if(node.type == file)
393 FileCompile(null, (Modifiers)key);
398 case Key { space, shift = true }:
401 if(node.type == NodeTypes::project)
404 for(p : workspace.projects)
406 if(p.topNode == node)
412 prj.RotateActiveConfig(!key.shift);
423 case enter: case keyPadEnter: OpenSelectedNodes(); break;
424 case del: RemoveSelectedNodes(); break;
427 Window activeClient = ide.activeClient;
429 activeClient.Activate();
431 ide.RepositionWindows(true);
438 bool NotifyCollapse(ListBox listBox, DataRow row, bool collapsed)
440 ProjectNode node = (ProjectNode)row.tag;
441 if(node.type == folder)
442 node.icon = collapsed ? folder : openFolder;
447 FileDialog importFileDialog { autoCreate = false, type = selectDir, text = $"Import Folder" };
448 FileDialog projectFileDialog
450 autoCreate = false, filters = projectFilters.array, sizeFilters = projectFilters.count * sizeof(FileFilter);
451 types = projectTypes.array, sizeTypes = projectTypes.count * sizeof(FileType);
453 FileDialog fileDialog
455 autoCreate = false, mayNotExist = true, filters = fileFilters.array, sizeFilters = fileFilters.count * sizeof(FileFilter);
457 FileDialog resourceFileDialog
459 autoCreate = false, mayNotExist = true, filters = resourceFilters.array, sizeFilters = resourceFilters.count * sizeof(FileFilter);
462 Menu fileMenu { menu, $"File", f };
463 MenuItem { fileMenu, $"Save", s, Key { s, ctrl = true }, NotifySelect = MenuFileSave };
464 // MenuItem { fileMenu, "Save As...", a, NotifySelect = MenuFileSaveAs };
466 bool OnClose(bool parentClosing)
468 if(!parentClosing && visible)
478 DialogResult dialogRes;
481 strcpy(msg, $"You have modified projects.\nSave changes to ");
482 for(p : ide.workspace.projects)
484 if(p.topNode.modified)
486 if(!first) strcat(msg, ", ");
493 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = msg }.Modal();
497 // TOFIX: Precomp error if brackets are taken out
498 return (DialogResult)MenuFileSave(null, 0) != cancel;
500 else if(dialogRes == cancel)
502 modifiedDocument = false;
509 //if(ide.findInFilesDialog && ide.findInFilesDialog.created && ide.findInFilesDialog.mode != directory)
510 // ide.findInFilesDialog.SearchStop();
512 ide.outputView.buildBox.Clear();
513 ide.outputView.debugBox.Clear();
514 //ide.outputView.findBox.Clear();
515 ide.callStackView.Clear();
516 ide.watchesView.Clear();
517 ide.threadsView.Clear();
518 ide.breakpointsView.Clear();
519 ide.outputView.ShowClearSelectTab(find); // why this?
522 bool OnSaveFile(char * fileName)
524 for(prj : ide.workspace.projects)
526 if(prj.topNode.modified)
528 prj.StopMonitoring();
529 if(prj.Save(prj.filePath))
530 prj.topNode.modified = false;
531 prj.StartMonitoring();
534 modifiedDocument = false;
539 bool IsModuleInProject(char * filePath)
541 char moduleName[MAX_FILENAME]; //, modulePath[MAX_LOCATION];
542 GetLastDirectory(filePath, moduleName);
543 return project.topNode.Find(moduleName, false) != null;
546 bool GetRelativePath(char * filePath, char * relativePath)
548 return project.GetRelativePath(filePath, relativePath);
551 ProjectNode GetNodeFromWindow(Window document, Project project, bool isCObject)
553 if(document.fileName)
555 char winFileName[MAX_LOCATION];
556 char * documentFileName = GetSlashPathBuffer(winFileName, document.fileName);
561 char name[MAX_FILENAME];
562 GetLastDirectory(documentFileName, name);
563 ChangeExtension(name, "ec", name);
564 for(p : ide.workspace.projects)
566 prj = project ? project : p;
567 if((node = prj.topNode.Find(name, false)))
574 for(p : ide.workspace.projects)
576 prj = project ? project : p;
577 if((node = prj.topNode.FindByFullPath(documentFileName, false)))
586 // ((( UTILITY FUNCTIONS )))
588 // ************************************************************************
589 // *** These methods below are part of a sequence of events, and as ***
590 // *** such they must be passed the current compiler and project config ***
591 // ************************************************************************
592 bool DisplayCompiler(CompilerConfig compiler, bool cleanLog)
594 ide.outputView.buildBox.Logf($"%s Compiler\n", compiler ? compiler.name : $"{problem with compiler selection}");
598 bool ProjectPrepareForToolchain(Project project, PrepareMakefileMethod method, bool cleanLog, bool displayCompiler,
599 CompilerConfig compiler, ProjectConfig config)
602 char message[MAX_F_STRING];
603 LogBox logBox = ide.outputView.buildBox;
605 ShowOutputBuildLog(cleanLog);
608 DisplayCompiler(compiler, false);
610 ProjectPrepareCompiler(project, compiler);
611 ProjectPrepareMakefile(project, method, compiler, config);
615 bool ProjectPrepareCompiler(Project project, CompilerConfig compiler)
617 if(!project.GenerateCrossPlatformMk(app.includeFile) || !project.GenerateCompilerCf(compiler))
618 ide.outputView.buildBox.Logf($"Error generating compiler configuration (Is the project/config directory writable?)\n");
622 // Note: Compiler is only passed in to for VisualStudio support
623 bool ProjectPrepareMakefile(Project project, PrepareMakefileMethod method, CompilerConfig compiler, ProjectConfig config)
625 if(compiler.type.isVC)
627 // I'm guessing we'll want to support generating VS files on Linux as well...
628 ide.statusBar.text = $"Generating Visual Studio Solution...";
630 //GenerateVSSolutionFile(project, compiler);
631 ide.statusBar.text = $"Generating Visual Studio Project...";
633 //GenerateVCProjectFile(project, compiler);
634 ide.statusBar.text = null;
640 char makefilePath[MAX_LOCATION];
641 char makefileName[MAX_LOCATION];
643 LogBox logBox = ide.outputView.buildBox;
645 strcpy(makefilePath, project.topNode.path);
646 project.CatMakeFileName(makefileName, config);
647 PathCatSlash(makefilePath, makefileName);
649 exists = FileExists(makefilePath);
650 if(method == force ||
651 (method == forceExists && exists) ||
652 (method == normal && (!exists || (config && config.makingModified))))
656 ide.statusBar.text = $"Generating Makefile & Dependencies..."; // Dependencies?
659 if((method == normal && !exists) || (method == force && !exists))
660 action = $"Generating ";
661 else if(method == force)
662 action = $"Regenerating ";
663 else if(method == normal || method == forceExists)
664 action = $"Updating ";
668 reason = $"Makefile doesn't exist. ";
669 else if(project.topNode.modified)
670 reason = $"Project has been modified. ";
674 //logBox.Logf("%s\n", makefileName);
675 logBox.Logf($"%s - %s%smakefile for %s config...\n", makefileName, reason, action, GetConfigName(config));
677 if(!project.GenerateMakefile(null, false, null, config))
678 ide.outputView.buildBox.Logf($"Error generating makefile (Is the project directory writable?)\n");
680 ide.statusBar.text = null;
688 bool BuildInterrim(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config, bool justPrint)
690 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
692 ide.outputView.buildBox.Logf($"Building project %s using the %s configuration...\n", prj.name, GetConfigName(config));
693 return Build(prj, buildType, compiler, config, justPrint);
698 bool DebugStopForMake(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config)
701 // TOFIX: DebugStop is being abused and backfiring on us.
702 // It's supposed to be the 'Debug/Stop' item, not unloading executable or anything else
704 // configIsInDebugSession seems to be used for two OPPOSITE things:
705 // If we're debugging another config, we need to unload the executable!
706 // In building, we want to stop if we're debugging the 'same' executable
707 if(buildType != run) ///* && prj == project*/ && prj.configIsInDebugSession)
709 if(buildType == start || buildType == restart)
711 if(ide.debugger && ide.debugger.isPrepared)
712 result = DebugStop();
716 if(ide.project == prj && ide.debugger && ide.debugger.prjConfig == config && ide.debugger.isPrepared)
717 result = DebugStop();
723 bool Build(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config, bool justPrint)
729 for(document = master.firstChild; document; document = document.next)
731 if(document.modifiedDocument)
733 ProjectNode node = GetNodeFromWindow(document, prj, false);
734 if(node && !document.MenuFileSave(null, 0))
743 DirExpression targetDir = prj.GetTargetDir(compiler, config);
745 DebugStopForMake(prj, buildType, compiler, config);
747 // TODO: Disabled until problems fixed... is it fixed?
748 if(buildType == rebuild || (config && config.compilingModified))
749 prj.Clean(compiler, config, clean, justPrint);
752 if(buildType == relink || (config && config.linkingModified))
753 prj.Clean(compiler, config, cleanTarget, false);
754 if(config && config.symbolGenModified)
756 DirExpression objDir = prj.GetObjDir(compiler, config);
757 char fileName[MAX_LOCATION];
758 char moduleName[MAX_FILENAME];
759 strcpy(fileName, prj.topNode.path);
760 PathCatSlash(fileName, objDir.dir);
761 strcpy(moduleName, prj.moduleName);
762 strcat(moduleName, ".main.ec");
763 PathCatSlash(fileName, moduleName);
764 if(FileExists(fileName))
765 DeleteFile(fileName);
766 ChangeExtension(fileName, "c", fileName);
767 if(FileExists(fileName))
768 DeleteFile(fileName);
769 ChangeExtension(fileName, "o", fileName);
770 if(FileExists(fileName))
771 DeleteFile(fileName);
776 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
777 ide.AdjustBuildMenus();
778 ide.AdjustDebugMenus();
780 result = prj.Build(buildType == run, null, compiler, config, justPrint, normal);
784 config.compilingModified = false;
785 if(!ide.ShouldStopBuild())
786 config.linkingModified = false;
788 config.symbolGenModified = false;
790 buildInProgress = none;
791 ide.AdjustBuildMenus();
792 ide.AdjustDebugMenus();
794 ide.workspace.modified = true;
801 // ((( USER ACTIONS )))
803 // ************************************************************************
804 // *** Methods below should atomically start a process, and as such ***
805 // *** they can query compiler and config directly from ide and project ***
806 // *** but ONLY ONCE!!! ***
807 // ************************************************************************
809 bool ProjectBuild(MenuItem selection, Modifiers mods)
811 Project prj = project;
812 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
813 ProjectConfig config;
814 if(selection || !ide.activeClient)
816 DataRow row = fileList.currentRow;
817 ProjectNode node = row ? (ProjectNode)row.tag : null;
818 if(node) prj = node.project;
822 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
827 if(/*prj != project || */!prj.GetConfigIsInDebugSession(config) || !ide.DontTerminateDebugSession($"Project Build"))
829 BuildInterrim(prj, build, compiler, config, mods.ctrl && mods.shift);
835 bool ProjectLink(MenuItem selection, Modifiers mods)
837 Project prj = project;
838 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
839 ProjectConfig config;
840 if(selection || !ide.activeClient)
842 DataRow row = fileList.currentRow;
843 ProjectNode node = row ? (ProjectNode)row.tag : null;
844 if(node) prj = node.project;
848 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
853 if(!prj.GetConfigIsInDebugSession(config) ||
854 (!ide.DontTerminateDebugSession($"Project Link") && DebugStopForMake(prj, relink, compiler, config)))
856 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
858 ide.outputView.buildBox.Logf($"Relinking project %s using the %s configuration...\n", prj.name, GetConfigName(config));
860 config.linkingModified = true;
861 Build(prj, relink, compiler, config, mods.ctrl && mods.shift);
868 bool ProjectRebuild(MenuItem selection, Modifiers mods)
870 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
871 Project prj = project;
872 ProjectConfig config;
873 if(selection || !ide.activeClient)
875 DataRow row = fileList.currentRow;
876 ProjectNode node = row ? (ProjectNode)row.tag : null;
877 if(node) prj = node.project;
881 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
886 if(!prj.GetConfigIsInDebugSession(config) ||
887 (!ide.DontTerminateDebugSession($"Project Rebuild") && DebugStopForMake(prj, rebuild, compiler, config)))
889 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
891 ide.outputView.buildBox.Logf($"Rebuilding project %s using the %s configuration...\n", prj.name, GetConfigName(config));
894 config.compilingModified = true;
895 config.makingModified = true;
896 }*/ // -- should this still be used depite the new solution of BuildType?
897 Build(prj, rebuild, compiler, config, mods.ctrl && mods.shift);
905 bool ProjectCleanTarget(MenuItem selection, Modifiers mods)
907 Project prj = project;
908 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
909 ProjectConfig config;
910 if(selection || !ide.activeClient)
912 DataRow row = fileList.currentRow;
913 ProjectNode node = row ? (ProjectNode)row.tag : null;
914 if(node) prj = node.project;
918 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
923 if(!prj.GetConfigIsInDebugSession(config) ||
924 (!ide.DontTerminateDebugSession($"Project Clean Target") && DebugStopForMake(prj, clean, compiler, config)))
926 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
928 ide.outputView.buildBox.Logf($"Cleaning target for project %s using the %s configuration...\n", prj.name, GetConfigName(config));
930 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
931 ide.AdjustBuildMenus();
932 ide.AdjustDebugMenus();
934 prj.Clean(compiler, config, cleanTarget, mods.ctrl && mods.shift);
935 buildInProgress = none;
936 ide.AdjustBuildMenus();
937 ide.AdjustDebugMenus();
945 bool ProjectClean(MenuItem selection, Modifiers mods)
947 Project prj = project;
948 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
949 ProjectConfig config;
950 if(selection || !ide.activeClient)
952 DataRow row = fileList.currentRow;
953 ProjectNode node = row ? (ProjectNode)row.tag : null;
954 if(node) prj = node.project;
958 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
963 if(!prj.GetConfigIsInDebugSession(config) ||
964 (!ide.DontTerminateDebugSession($"Project Clean") && DebugStopForMake(prj, clean, compiler, config)))
966 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
968 ide.outputView.buildBox.Logf($"Cleaning project %s using the %s configuration...\n", prj.name, GetConfigName(config));
970 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
971 ide.AdjustBuildMenus();
972 ide.AdjustDebugMenus();
974 prj.Clean(compiler, config, clean, mods.ctrl && mods.shift);
975 buildInProgress = none;
976 ide.AdjustBuildMenus();
977 ide.AdjustDebugMenus();
984 bool ProjectRealClean(MenuItem selection, Modifiers mods)
986 Project prj = project;
987 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
988 ProjectConfig config;
989 if(selection || !ide.activeClient)
991 DataRow row = fileList.currentRow;
992 ProjectNode node = row ? (ProjectNode)row.tag : null;
993 if(node) prj = node.project;
997 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
1001 config = prj.config;
1002 if(!prj.GetConfigIsInDebugSession(config) ||
1003 (!ide.DontTerminateDebugSession($"Project Real Clean") && DebugStopForMake(prj, clean, compiler, config)))
1005 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
1007 ide.outputView.buildBox.Logf($"Removing intermediate objects directory for project %s using the %s configuration...\n", prj.name, GetConfigName(config));
1009 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
1010 ide.AdjustBuildMenus();
1011 ide.AdjustDebugMenus();
1013 prj.Clean(compiler, config, realClean, mods.ctrl && mods.shift);
1014 buildInProgress = none;
1015 ide.AdjustBuildMenus();
1016 ide.AdjustDebugMenus();
1023 bool ProjectRegenerate(MenuItem selection, Modifiers mods)
1025 Project prj = project;
1026 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1027 ShowOutputBuildLog(true);
1028 if(selection || !ide.activeClient)
1030 DataRow row = fileList.currentRow;
1031 ProjectNode node = row ? (ProjectNode)row.tag : null;
1037 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
1042 DisplayCompiler(compiler, false);
1043 ProjectPrepareCompiler(project, compiler);
1044 ProjectPrepareMakefile(prj, force, compiler, prj.config);
1049 bool Compile(Project project, List<ProjectNode> nodes, bool justPrint, SingleFileCompileMode mode)
1052 char fileName[MAX_LOCATION];
1054 ProjectConfig config = project.config;
1058 for(document = ide.firstChild; document; document = document.next)
1060 if(document.modifiedDocument)
1062 ProjectNode n = GetNodeFromWindow(document, project, mode == cObject ? true : false);
1065 if(n && n.IsInNode(node) && !document.MenuFileSave(null, 0))
1067 ide.outputView.buildBox.Logf($"Unable to save %s file.\n", node.name);
1077 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1079 if(ProjectPrepareForToolchain(project, normal, true, true, compiler, config))
1082 ide.outputView.buildBox.Logf($"%s specific file(s) in project %s using the %s configuration...\n",
1083 mode == normal ? $"Compiling" : $"Debug compiling", project.name, config.name);
1085 ide.outputView.buildBox.Logf($"%s specific file(s) in project %s...\n",
1086 mode == normal ? $"Compiling" : $"Debug compiling", project.name);
1088 buildInProgress = compilingFile;
1089 ide.AdjustBuildMenus();
1090 project.Compile(nodes, compiler, config, justPrint, mode);
1091 buildInProgress = none;
1092 ide.AdjustBuildMenus();
1101 bool Clean(Project project, List<ProjectNode> nodes, bool justPrint)
1104 char fileName[MAX_LOCATION];
1106 ProjectConfig config = project.config;
1110 for(document = ide.firstChild; document; document = document.next)
1112 if(document.modifiedDocument)
1114 ProjectNode n = GetNodeFromWindow(document, project, false);
1117 if(n && n.IsInNode(node) && !document.MenuFileSave(null, 0))
1119 ide.outputView.buildBox.Logf($"Unable to save %s file.\n", node.name);
1129 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1131 if(ProjectPrepareForToolchain(project, normal, true, true, compiler, config))
1133 Map<String, NameCollisionInfo> namesInfo { };
1134 project.topNode.GenMakefileGetNameCollisionInfo(namesInfo, config);
1137 if(node.GetIsExcluded(config))
1138 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
1142 ide.outputView.buildBox.Logf($"Deleteing intermediate objects for %s %s in project %s using the %s configuration...\n",
1143 node.type == file ? $"single file" : $"folder", node.name, project.name, config.name);
1145 ide.outputView.buildBox.Logf($"Deleteing intermediate objects for %s %s in project %s...\n",
1146 node.type == file ? $"single file" : $"folder", node.name, project.name);
1148 node.DeleteIntermediateFiles(compiler, config, namesInfo, false);
1160 bool ProjectNewFile(MenuItem selection, Modifiers mods)
1162 DataRow row = fileList.currentRow;
1165 char fileName[1024];
1166 char filePath[MAX_LOCATION];
1167 ProjectNode parentNode = (ProjectNode)row.tag;
1168 ProjectNode n, fileNode;
1169 parentNode.GetFileSysMatchingPath(filePath);
1170 MakePathRelative(filePath, parentNode.project.topNode.path, filePath);
1171 for(n = parentNode; n && n != parentNode.project.resNode; n = n.parent);
1172 sprintf(fileName, $"Untitled %d", documentID);
1173 fileNode = AddFile(parentNode, fileName, (bool)n, true);
1174 fileNode.path = CopyUnixPath(filePath);
1177 NodeProperties nodeProperties
1180 position = { position.x + 100, position.y + 100 };
1184 nodeProperties.Create(); // not modal?
1190 bool ProjectNewFolder(MenuItem selection, Modifiers mods)
1192 DataRow row = fileList.currentRow;
1195 ProjectNode parentNode = (ProjectNode)row.tag;
1196 NewFolder(parentNode, null, true);
1201 bool ResourcesAddFiles(MenuItem selection, Modifiers mods)
1207 bool ProjectAddFiles(MenuItem selection, Modifiers mods)
1213 bool ProjectImportFolder(MenuItem selection, Modifiers mods)
1215 DataRow row = fileList.currentRow;
1218 ProjectNode toNode = (ProjectNode)row.tag;
1219 ImportFolder(toNode);
1224 bool ProjectAddNewForm(MenuItem selection, Modifiers mods)
1226 CodeEditor codeEditor = CreateNew("Form", "form", "Window", null);
1227 codeEditor.EnsureUpToDate();
1231 bool ProjectAddNewGraph(MenuItem selection, Modifiers mods)
1233 CodeEditor codeEditor = CreateNew("Graph", "graph", "Block", null);
1235 codeEditor.EnsureUpToDate();
1239 bool ProjectRemove(MenuItem selection, Modifiers mods)
1241 DataRow row = fileList.currentRow;
1244 ProjectNode node = (ProjectNode)row.tag;
1245 if(node.type == project)
1246 RemoveSelectedNodes();
1251 bool ProjectUpdateMakefileForAllConfigs(Project project)
1253 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1255 // This call really does not belong here:
1256 ide.UpdateToolBarActiveConfigs(false);
1257 for(config : project.configurations)
1258 ProjectPrepareMakefile(project, forceExists, compiler, config);
1265 bool MenuSettings(MenuItem selection, Modifiers mods)
1267 ProjectNode node = GetSelectedNode(true);
1268 Project prj = node ? node.project : project;
1269 projectSettingsDialog = ProjectSettings { master = parent, project = prj, projectNode = node };
1270 projectSettingsDialog.Modal();
1277 bool FileProperties(MenuItem selection, Modifiers mods)
1279 DataRow row = fileList.currentRow;
1282 ProjectNode node = (ProjectNode)row.tag;
1283 NodeProperties { parent = parent, master = this, node = node,
1284 position = { position.x + 100, position.y + 100 } }.Create();
1289 bool FileOpenFile(MenuItem selection, Modifiers mods)
1291 OpenSelectedNodes();
1295 bool FileRemoveFile(MenuItem selection, Modifiers mods)
1297 RemoveSelectedNodes();
1301 bool FileCompile(MenuItem selection, Modifiers mods)
1304 OldList selectedRows;
1305 Project project = null;
1306 List<ProjectNode> nodes { };
1307 fileList.GetMultiSelection(selectedRows);
1308 for(item = selectedRows.first; item; item = item.next)
1311 DataRow row = item.data;
1312 ProjectNode node = (ProjectNode)row.tag;
1314 project = node.project;
1315 else if(node.project != project)
1322 selectedRows.Free(null);
1324 Compile(project, nodes, mods.ctrl && mods.shift, normal);
1326 ide.outputView.buildBox.Logf($"Please select files from a single project.\n");
1331 bool FileClean(MenuItem selection, Modifiers mods)
1334 OldList selectedRows;
1335 Project project = null;
1336 List<ProjectNode> nodes { };
1337 fileList.GetMultiSelection(selectedRows);
1338 for(item = selectedRows.first; item; item = item.next)
1341 DataRow row = item.data;
1342 ProjectNode node = (ProjectNode)row.tag;
1344 project = node.project;
1345 else if(node.project != project)
1352 selectedRows.Free(null);
1354 Clean(project, nodes, mods.ctrl && mods.shift);
1356 ide.outputView.buildBox.Logf($"Please select files from a single project.\n");
1361 bool FileDebugPrecompile(MenuItem selection, Modifiers mods)
1363 DataRow row = fileList.currentRow;
1364 ProjectNode node = row ? (ProjectNode)row.tag : null;
1367 List<ProjectNode> nodes { };
1369 Compile(node.project, nodes, mods.ctrl && mods.shift, debugPrecompile);
1374 bool FileDebugCompile(MenuItem selection, Modifiers mods)
1376 DataRow row = fileList.currentRow;
1377 ProjectNode node = row ? (ProjectNode)row.tag : null;
1380 List<ProjectNode> nodes { };
1382 Compile(node.project, nodes, mods.ctrl && mods.shift, debugCompile);
1387 bool FileDebugGenerateSymbols(MenuItem selection, Modifiers mods)
1389 DataRow row = fileList.currentRow;
1390 ProjectNode node = row ? (ProjectNode)row.tag : null;
1393 List<ProjectNode> nodes { };
1395 Compile(node.project, nodes, mods.ctrl && mods.shift, debugGenerateSymbols);
1400 Project GetSelectedProject(bool useSelection)
1402 Project prj = project;
1405 DataRow row = fileList.currentRow;
1406 ProjectNode node = row ? (ProjectNode)row.tag : null;
1413 void SelectNextProject(bool backwards)
1415 DataRow row = fileList.currentRow;
1416 DataRow currentRow = row;
1417 ProjectNode node = (ProjectNode)row.tag;
1418 if(node.type != project)
1419 row = node.project.topNode.row;
1421 row = row.previous ? row.previous : fileList.lastRow;
1423 row = row.next ? row.next : fileList.firstRow;
1424 if(row && row != currentRow)
1426 fileList.SelectRow(row);
1427 fileList.currentRow = row;
1431 ProjectNode GetSelectedNode(bool useSelection)
1433 ProjectNode node = null;
1436 DataRow row = fileList.currentRow;
1438 node = (ProjectNode)row.tag;
1443 bool MenuBrowseFolder(MenuItem selection, Modifiers mods)
1445 char folder[MAX_LOCATION];
1447 ProjectNode node = GetSelectedNode(true);
1449 node = project.topNode;
1452 strcpy(folder, prj.topNode.path);
1453 if(node != prj.topNode)
1454 PathCatSlash(folder, node.path);
1459 bool Run(MenuItem selection, Modifiers mods)
1461 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1462 ProjectConfig config = project.config;
1463 String args = new char[maxPathLen];
1465 if(ide.workspace.commandLineArgs)
1466 //ide.debugger.GetCommandLineArgs(args);
1467 strcpy(args, ide.workspace.commandLineArgs);
1468 if(ide.debugger.isActive)
1469 project.Run(args, compiler, config);
1470 /*else if(config.targetType == sharedLibrary || config.targetType == staticLibrary)
1471 MessageBox { master = ide, type = ok, text = "Run", contents = "Shared and static libraries cannot be run like executables." }.Modal();*/
1472 else if(BuildInterrim(project, run, compiler, config, false))
1473 project.Run(args, compiler, config);
1481 bool result = false;
1482 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1483 ProjectConfig config = project.config;
1484 TargetTypes targetType = project.GetTargetType(config);
1485 if(targetType == sharedLibrary || targetType == staticLibrary)
1486 MessageBox { master = ide, type = ok, text = $"Run", contents = $"Shared and static libraries cannot be run like executables." }.Modal();
1487 else if(project.GetCompress(config))
1488 MessageBox { master = ide, text = $"Starting Debug", contents = $"Debugging compressed applications is not supported\n" }.Modal();
1489 else if(project.GetDebug(config) ||
1490 MessageBox { master = ide, type = okCancel, text = $"Starting Debug", contents = $"Attempting to debug non-debug configuration\nProceed anyways?" }.Modal() == ok)
1492 if(/*!IsProjectModified() ||*/ BuildInterrim(project, start, compiler, config, false))
1494 if(compiler.type.isVC)
1496 //bool result = false;
1497 char oldwd[MAX_LOCATION];
1498 PathBackup pathBackup { };
1499 char command[MAX_LOCATION];
1501 ide.SetPath(false, compiler, config);
1503 GetWorkingDir(oldwd, sizeof(oldwd));
1504 ChangeWorkingDir(project.topNode.path);
1506 sprintf(command, "%s /useenv %s.sln /projectconfig \"%s|Win32\" /command \"%s\"" , "devenv", project.name, config.name, "Debug.Start");
1508 ChangeWorkingDir(oldwd);
1514 ide.debugger.Start(compiler, config);
1523 void GoToError(const char * line)
1527 while(isspace(*line)) line++;
1528 colon = strstr(line, ":");
1533 bool lookForLineNumber = true;
1535 // deal with linking error
1536 if(colon && colon[1] == ' ')
1538 colon = strstr(colon + 1, ":");
1539 if(colon && !colon[1])
1541 colon = strstr(line, ":");
1542 lookForLineNumber = false;
1544 else if(colon && !isdigit(colon[1]))
1547 colon = strstr(line, ":");
1550 // Don't be mistaken by the drive letter colon
1551 if(colon && (colon[1] == '/' || colon[1] == '\\'))
1552 colon = strstr(colon + 1, ":");
1553 if(colon && lookForLineNumber)
1557 char * par = RSearchString(line, "(", colon - line, true, false);
1558 if(par && strstr(par, ")"))
1560 else if((colon+1)[0] == ' ')
1562 // NOTE: This is the same thing as saying 'colon = line'
1563 for( ; colon != line; colon--)
1567 lineNumber = atoi(colon + 1);
1569 comma = strchr(colon, ',');
1571 col = atoi(comma+1);
1573 comma = strchr(colon+1, ':');
1575 col = atoi(comma+1);
1579 char moduleName[MAX_LOCATION], filePath[MAX_LOCATION];
1583 char * inFileIncludedFrom = strstr(line, stringInFileIncludedFrom);
1584 char * start = inFileIncludedFrom ? line + strlen(stringInFileIncludedFrom) : line;
1585 int len = (int)(colon - start);
1586 len = Min(len, MAX_LOCATION-1);
1588 strncpy(moduleName, start, len);
1589 moduleName[len] = '\0';
1592 strcpy(moduleName, line);
1594 // Remove stuff in brackets
1596 bracket = strstr(moduleName, "(");
1597 if(bracket) *bracket = '\0';
1599 MakeSlashPath(moduleName);
1603 // Check if it's one of our modules
1604 ProjectNode node = project.topNode.Find(moduleName, false);
1607 strcpy(moduleName, node.path);
1608 PathCatSlash(moduleName, node.name);
1611 moduleName[0] = '\0';
1615 CodeEditor codeEditor;
1616 strcpy(filePath, project.topNode.path);
1617 PathCatSlash(filePath, moduleName);
1619 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
1622 char name[MAX_LOCATION];
1623 // TOFIX: Improve on this, don't use only filename, make a function
1624 if(ide && ide.workspace)
1626 for(prj : ide.workspace.projects)
1628 if(prj.topNode.FindWithPath(moduleName, false))
1630 strcpy(filePath, prj.topNode.path);
1631 PathCatSlash(filePath, moduleName);
1632 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
1639 if(codeEditor && lineNumber)
1641 EditBox editBox = codeEditor.editBox;
1642 editBox.GoToLineNum(lineNumber - 1);
1643 editBox.GoToPosition(editBox.line, lineNumber - 1, col ? (col - 1) : 0);
1650 bool OpenNode(ProjectNode node)
1652 char filePath[MAX_LOCATION];
1653 node.GetFullFilePath(filePath);
1654 return ide.OpenFile(filePath, normal, true/*false Why was it opening hidden?*/, null, something, normal) ? true : false;
1657 void AddNode(ProjectNode node, DataRow addTo)
1659 DataRow row = addTo ? addTo.AddRow() : fileList.AddRow();
1661 row.tag = (int64)node;
1664 if(node.type == resources)
1667 row.SetData(null, node);
1669 if(node.files && node.files.first && node.parent &&
1670 !(!node.parent.parent &&
1671 (!strcmpi(node.name, "notes") || !strcmpi(node.name, "sources") ||
1672 !strcmpi(node.name, "src") || !strcmpi(node.name, "tools"))))
1673 row.collapsed = true;
1674 else if(node.type == folder)
1675 node.icon = openFolder;
1679 for(child : node.files)
1680 AddNode(child, row);
1684 void DeleteNode(ProjectNode projectNode)
1686 if(projectNode.files)
1689 while(child = projectNode.files.first)
1692 fileList.DeleteRow(projectNode.row);
1693 projectNode.Delete();
1696 bool ProjectSave(MenuItem selection, Modifiers mods)
1698 DataRow row = fileList.currentRow;
1699 ProjectNode node = row ? (ProjectNode)row.tag : null;
1700 Project prj = node ? node.project : null;
1703 prj.StopMonitoring();
1704 if(prj.Save(prj.filePath))
1706 Project modPrj = null;
1707 prj.topNode.modified = false;
1708 for(p : ide.workspace.projects)
1710 if(p.topNode.modified)
1717 modifiedDocument = false;
1720 prj.StartMonitoring();
1725 bool ShowOutputBuildLog(bool cleanLog)
1727 OutputView output = ide.outputView;
1729 output.ShowClearSelectTab(build);
1732 output.SelectTab(build);
1740 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1741 ProjectConfig config = project.config;
1743 bool result = false;
1744 if(/*!IsProjectModified() ||*/ BuildInterrim(project, restart, compiler, config, false))
1746 // For Restart, compiler and config will only be used if for
1747 // whatever reason (if at all possible) the Debugger is in a
1748 // 'terminated' or 'none' state
1749 ide.debugger.Restart(compiler, config);
1759 ide.debugger.Resume();
1765 ide.debugger.Break();
1771 ide.debugger.Stop();
1775 bool DebugStepInto()
1777 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1778 ProjectConfig config = project.config;
1780 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config, false)))
1781 ide.debugger.StepInto(compiler, config);
1786 bool DebugStepOver(bool skip)
1788 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1789 ProjectConfig config = project.config;
1791 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config, false)))
1792 ide.debugger.StepOver(compiler, config, skip);
1798 bool DebugStepOut(bool skip)
1800 ide.debugger.StepOut(skip);
1804 void ImportFolder(ProjectNode toNode)
1808 //bool isFolder = toNode.type == folder;
1809 //bool isRes = toNode.isInResources;
1811 FileDialog fileDialog = importFileDialog;
1812 fileDialog.master = parent;
1813 if(fileDialog.Modal() == ok)
1815 ImportFolderFSI fsi { projectView = this };
1816 fsi.stack.Add(toNode);
1817 fsi.Iterate(fileDialog.filePath);
1823 ProjectNode NewFolder(ProjectNode parentNode, char * name, bool showProperties)
1827 ProjectNode folderNode;
1828 Project prj = parentNode.project;
1830 ProjectNode after = null;
1831 for(node : parentNode.files)
1833 if(node.type != folder)
1839 folderNode = parentNode.Add(prj, name, after, folder, folder, true);
1842 for(c = 0; c < 100; c++)
1845 sprintf(string, c ? "New Folder (%d)" : "New Folder", c);
1846 if((folderNode = parentNode.Add(prj, string, after, folder, folder, true)))
1853 NodeProperties nodeProperties;
1856 modifiedDocument = true;
1857 prj.topNode.modified = true;
1860 folderNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
1861 folderNode.row.tag = (int64)folderNode;
1863 folderNode.row.SetData(null, folderNode);
1864 fileList.currentRow = folderNode.row;
1868 nodeProperties = NodeProperties
1870 parent, this, mode = newFolder, node = folderNode;
1871 position = { position.x + 100, position.y + 100 };
1873 nodeProperties.Create(); // Modal?
1881 void AddFiles(bool resources)
1883 FileDialog fileDialog = (!resources) ? this.fileDialog : resourceFileDialog;
1884 fileDialog.type = multiOpen;
1885 fileDialog.text = !resources ? $"Add Files to Project" : $"Add Resources to Project";
1886 fileDialog.master = parent;
1888 if(fileDialog.Modal() == ok)
1891 DataRow row = fileList.currentRow;
1892 ProjectNode parentNode = (ProjectNode)row.tag;
1893 bool addFailed = false;
1894 int numSelections = fileDialog.numSelections;
1895 char ** multiFilePaths = fileDialog.multiFilePaths;
1897 Array<String> nameConflictFiles { };
1899 for(c = 0; c < numSelections; c++)
1901 char * filePath = multiFilePaths[c];
1902 FileAttribs exists = FileExists(filePath);
1903 bool addThisFile = true;
1905 if(exists.isDirectory)
1906 addThisFile = false;
1909 if(MessageBox { master = ide, type = yesNo, text = filePath,
1910 contents = $"File doesn't exist. Create?" }.Modal() == yes)
1912 File f = FileOpen(filePath, write);
1920 MessageBox { master = ide, type = ok, text = filePath,
1921 contents = $"Couldn't create file."}.Modal();
1922 addThisFile = false;
1929 /*addFailed = */if(!AddFile(parentNode, filePath, resources, false))//;
1931 nameConflictFiles.Add(CopyString(filePath));
1939 char * part1 = $"The following file";
1940 char * opt1 = $" was ";
1941 char * opt2 = $"s were ";
1942 char * part2 = $"not added because of identical file name conflict within the project.\n\n";
1944 len += strlen(part1);
1945 len += strlen(part2);
1946 len += nameConflictFiles.count > 1 ? strlen(opt2) : strlen(opt1);
1947 for(s : nameConflictFiles)
1948 len += strlen(s) + 1;
1949 message = new char[len + 1];
1950 strcpy(message, part1);
1951 strcat(message, nameConflictFiles.count > 1 ? opt2 : opt1);
1952 strcat(message, part2);
1953 for(s : nameConflictFiles)
1956 strcat(message, "\n");
1958 MessageBox { master = ide, type = ok, text = $"Name Conflict",
1959 contents = message }.Modal();
1962 nameConflictFiles.Free();
1963 delete nameConflictFiles;
1967 ProjectNode AddFile(ProjectNode parentNode, char * filePath, bool resources, bool isTemporary)
1969 ProjectNode result = null;
1970 ProjectNode after = null;
1971 for(node : parentNode.files)
1973 if(node.type != folder && node.type != file && node.type)
1978 result = parentNode.Add(parentNode.project, filePath, after, file, NodeIcons::SelectFileIcon(filePath), !resources);
1984 modifiedDocument = true;
1985 parentNode.project.topNode.modified = true;
1986 parentNode.project.ModifiedAllConfigs(true, false, true, true);
1989 result.row = parentNode.row.AddRowAfter(after ? after.row : null);
1990 result.row.tag = (int64)result;
1991 result.row.SetData(null, result);
1996 CodeEditor CreateNew(char * upper, char * lower, char * base, char * className)
1998 CodeEditor codeEditor = null;
1999 ProjectNode projectNode;
2000 ProjectNode after = null;
2001 DataRow row = fileList.currentRow;
2002 ProjectNode parentNode;
2005 if(!row) row = project.topNode.row;
2007 parentNode = (ProjectNode)row.tag;
2009 for(node : parentNode.files)
2011 if(node.type != folder && node.type != file && node.type)
2015 for(c = 1; c < 100; c++)
2018 sprintf(string, c ? "%s%d.ec" : "%s.ec", lower, c);
2019 if((projectNode = parentNode.Add(project, string, after, file, genFile, true)))
2025 char filePath[MAX_LOCATION];
2027 modifiedDocument = true;
2028 project.topNode.modified = true;
2030 project.ModifiedAllConfigs(true, false, false, true);
2031 projectNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
2032 projectNode.row.tag =(int64)projectNode;
2034 projectNode.row.SetData(null, projectNode);
2035 fileList.currentRow = projectNode.row;
2037 strcpy(filePath, project.topNode.path);
2038 PathCat(filePath, projectNode.path);
2039 PathCat(filePath, projectNode.name);
2041 codeEditor = (CodeEditor)ide.FindWindow(filePath);
2044 Class baseClass = eSystem_FindClass(__thisModule, base);
2045 subclass(ClassDesignerBase) designerClass = eClass_GetDesigner(baseClass);
2048 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal);
2049 strcpy(name, projectNode.name);
2050 sprintf(name, "%s%d", upper, c);
2052 strcpy(className, name);
2054 designerClass.CreateNew(codeEditor.editBox, codeEditor.clientSize, name, base);
2056 //codeEditor.modifiedDocument = false;
2057 //codeEditor.designer.modifiedDocument = false;
2059 //Code_EnsureUpToDate(codeEditor);
2062 else // TODO: fix no symbols generated when ommiting {} for following else
2064 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal);
2068 codeEditor.ViewDesigner();
2069 codeEditor.codeModified = true;
2076 // Returns true if we opened something
2077 bool OpenSelectedNodes()
2079 bool result = false;
2083 fileList.GetMultiSelection(selection);
2084 for(item = selection.first; item; item = item.next)
2086 DataRow row = item.data;
2087 ProjectNode node = (ProjectNode)row.tag;
2088 if(node.type == file)
2095 selection.Free(null);
2099 void RemoveSelectedNodes()
2104 fileList.GetMultiSelection(selection);
2106 // Remove children of parents we're deleting
2107 for(item = selection.first; item; item = next)
2110 DataRow row = item.data;
2111 ProjectNode n, node = (ProjectNode)row.tag;
2112 bool remove = false;
2115 for(i = selection.first; i && !remove; i = i.next)
2117 ProjectNode iNode = (ProjectNode)((DataRow)i.data).tag;
2118 for(n = node.parent; n; n = n.parent)
2128 selection.Delete(item);
2131 for(item = selection.first; item; item = item.next)
2133 DataRow row = item.data;
2134 ProjectNode node = (ProjectNode)row.tag;
2135 ProjectNode resNode;
2136 for(resNode = node.parent; resNode; resNode = resNode.parent)
2137 if(resNode.type == resources)
2139 if(node.type == file)
2141 Project prj = node.project;
2143 modifiedDocument = true;
2144 prj.topNode.modified = true;
2146 prj.ModifiedAllConfigs(true, false, true, true);
2148 else if(node.type == folder)
2151 sprintf(message, $"Are you sure you want to remove the folder \"%s\"\n"
2152 "and all of its contents from the project?", node.name);
2153 if(MessageBox { master = ide, type = yesNo, text = $"Delete Folder", contents = message }.Modal() == yes)
2155 Project prj = node.project;
2156 if(node.containsFile)
2157 prj.ModifiedAllConfigs(true, false, true, true);
2159 modifiedDocument = true;
2160 prj.topNode.modified = true;
2163 else if(node.type == project && node != project.topNode && !buildInProgress)
2167 for(p : workspace.projects)
2169 if(p.topNode == node)
2175 sprintf(message, $"Are you sure you want to remove the \"%s\" project\n" "from this workspace?", node.name);
2176 if(MessageBox { master = ide, type = yesNo, text = $"Remove Project", contents = message }.Modal() == yes)
2181 workspace.RemoveProject(prj);
2182 //modifiedDocument = true; // when project view is a workspace view
2186 selection.Free(null);