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 BuildType { build, rebuild, relink, run, start, restart, clean };
93 none, buildingMainProject, buildingSecondaryProject, compilingFile;
95 property bool { get { return this != none; } }
96 //property bool actualBuild { get { return this == buildingMainProject || this == buildingSecondaryProject; } }
99 class ProjectView : Window
102 //hasMinimize = true;
104 borderStyle = sizable;
105 hasHorzScroll = true;
106 hasVertScroll = true;
109 anchor = Anchor { left = 0, top = 0, bottom = 0 };
112 //hasMinimize = true;
113 saveDialog = projectFileDialog;
116 BuildState buildInProgress;
117 BitmapResource icons[NodeIcons];
120 property Workspace workspace
126 for(prj : workspace.projects)
128 DeleteNode(prj.topNode);
130 workspace.projects.Free();
131 ide.debugger.CleanUp();
136 fileDialog.currentDirectory = workspace.workspaceDir;
137 resourceFileDialog.currentDirectory = workspace.workspaceDir;
138 for(prj : workspace.projects)
139 AddNode(prj.topNode, null);
140 ide.statusBar.text = $"Generating Makefile & Dependencies...";
142 for(prj : workspace.projects)
143 prj.ModifiedAllConfigs(true, false, false, false);
144 ide.statusBar.text = $"Initializing Debugger"; app.UpdateDisplay();
145 ide.statusBar.text = null;
149 get { return workspace; }
152 bool drawingInProjectSettingsDialog;
153 bool drawingInProjectSettingsDialogHeader;
154 ProjectSettings projectSettingsDialog;
162 for(c = 0; c < NodeIcons::enumSize; c++)
164 icons[c] = BitmapResource { iconNames[c], alphaBlend = true };
165 AddResource(icons[c]);
167 fileList.AddField(DataField { dataType = class(ProjectNode), freeData = false, userData = this });
173 ide.DestroyTemporaryProjectDir();
183 multiSelect = true, fullRowSelect = false, hasVertScroll = true, hasHorzScroll = true;
184 borderStyle = deep, parent = this, collapseControl = true, treeBranches = true;
185 anchor = Anchor { left = 0, right = 0, top = 0 , bottom = 0 };
187 background = projectViewBackground;
188 foreground = projectViewText;
189 selectionColor = selectionColor, selectionText = selectionText;
190 stippleColor = skyBlue;
192 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
194 if(!active) Update(null);
195 return ListBox::OnActivate(active, previous, goOnWithActivation, direct);
198 bool NotifyDoubleClick(ListBox listBox, int x, int y, Modifiers mods)
200 // Prevent the double click from reactivating the project view (returns false if we opened something)
201 return !OpenSelectedNodes();
204 bool NotifyRightClick(ListBox listBox, int x, int y, Modifiers mods)
206 DataRow row = listBox.currentRow;
209 ProjectNode node = (ProjectNode)row.tag;
210 if(node.type == NodeTypes::project || node.type == resources || node.type == file || node.type == folder)
212 bool buildMenuUnavailable = buildInProgress;
213 Menu popupContent { };
215 if(node.type == NodeTypes::project)
217 //if(node == ((Project)workspace.projects.first).topNode)
219 MenuItem { popupContent, $"Build", b, NotifySelect = ProjectBuild }.disabled = buildMenuUnavailable;
220 MenuItem { popupContent, $"Relink", l, NotifySelect = ProjectLink }.disabled = buildMenuUnavailable;
221 MenuItem { popupContent, $"Rebuild", r, NotifySelect = ProjectRebuild }.disabled = buildMenuUnavailable;
222 MenuItem { popupContent, $"Clean", c, NotifySelect = ProjectClean }.disabled = buildMenuUnavailable;
223 MenuItem { popupContent, $"Real Clean", d, NotifySelect = ProjectRealClean }.disabled = buildMenuUnavailable;
224 MenuItem { popupContent, $"Regenerate Makefile", m, NotifySelect = ProjectRegenerate }.disabled = buildMenuUnavailable;
225 MenuDivider { popupContent };
227 MenuItem { popupContent, $"Debug Generate Symbols", l, NotifySelect = FileDebugGenerateSymbols }.disabled = buildMenuUnavailable;
228 MenuDivider { popupContent };
229 MenuItem { popupContent, $"New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
230 MenuItem { popupContent, $"New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
231 MenuItem { popupContent, $"Import Folder...", i, NotifySelect = ProjectImportFolder };
232 MenuItem { popupContent, $"Add Files to Project...", f, NotifySelect = ProjectAddFiles };
233 MenuDivider { popupContent };
234 MenuItem { popupContent, $"Add New Form...", o, NotifySelect = ProjectAddNewForm };
235 // MenuItem { popupContent, "Add New Behavior Graph...", g, NotifySelect = ProjectAddNewGraph };
236 MenuDivider { popupContent };
237 if(node != ((Project)workspace.projects.first).topNode)
239 MenuItem { popupContent, $"Remove project from workspace", r, NotifySelect = ProjectRemove }.disabled = buildMenuUnavailable;
240 MenuDivider { popupContent };
242 MenuItem { popupContent, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
243 MenuDivider { popupContent };
244 MenuItem { popupContent, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
245 MenuDivider { popupContent };
246 MenuItem { popupContent, $"Save", v, Key { s, ctrl = true }, NotifySelect = ProjectSave }.disabled = !node.modified;
247 MenuDivider { popupContent };
248 MenuItem { popupContent, $"Properties...", p, Key { enter, alt = true }, NotifySelect = FileProperties };
250 else if(node.type == resources)
252 MenuItem { popupContent, $"New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
253 MenuItem { popupContent, $"New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
254 MenuItem { popupContent, $"Import Folder...", i, NotifySelect = ProjectImportFolder };
255 MenuItem { popupContent, $"Add Resources to Project...", f, NotifySelect = ResourcesAddFiles };
256 MenuItem { popupContent, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
257 MenuDivider { popupContent };
258 MenuItem { popupContent, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
259 MenuItem { popupContent, $"Properties...", p, Key { enter, alt = true }, NotifySelect = FileProperties };
261 else if(node.type == file)
263 MenuItem { popupContent, $"Open", o, NotifySelect = FileOpenFile };
264 MenuDivider { popupContent };
265 MenuItem { popupContent, $"Clean", l, NotifySelect = FileClean }.disabled = buildMenuUnavailable;
266 MenuItem { popupContent, $"Compile", c, Key { f7, ctrl = true}, NotifySelect = FileCompile }.disabled = buildMenuUnavailable;
267 MenuDivider { popupContent };
268 MenuItem { popupContent, $"Debug Precompile", l, NotifySelect = FileDebugPrecompile }.disabled = buildMenuUnavailable;
269 MenuItem { popupContent, $"Debug Compile", l, NotifySelect = FileDebugCompile }.disabled = buildMenuUnavailable;
270 MenuDivider { popupContent };
271 MenuItem { popupContent, $"Remove", r, NotifySelect = FileRemoveFile };
272 MenuDivider { popupContent };
273 MenuItem { popupContent, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
274 MenuDivider { popupContent };
275 MenuItem { popupContent, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
276 MenuItem { popupContent, $"Properties..", p, Key { enter, alt = true }, NotifySelect = FileProperties };
278 else if(node.type == folder)
280 bool isInResources = node.isInResources;
282 MenuItem { popupContent, $"New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
283 MenuItem { popupContent, $"New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
284 MenuItem { popupContent, $"Import Folder...", i, NotifySelect = ProjectImportFolder };
287 MenuItem { popupContent, $"Add Resources to Folder...", f, NotifySelect = ResourcesAddFiles };
291 MenuItem { popupContent, $"Add Files to Folder...", f, NotifySelect = ProjectAddFiles };
295 MenuDivider { popupContent };
296 MenuItem { popupContent, $"Add New Form...", o, NotifySelect = ProjectAddNewForm };
297 MenuItem { popupContent, $"Add New Behavior Graph...", g, NotifySelect = ProjectAddNewGraph };
299 MenuDivider { popupContent };
300 MenuItem { popupContent, $"Clean", l, NotifySelect = FileClean }.disabled = buildMenuUnavailable;
301 MenuItem { popupContent, $"Compile", c, Key { f7, ctrl = true}, NotifySelect = FileCompile }.disabled = buildMenuUnavailable;
302 MenuDivider { popupContent };
303 MenuItem { popupContent, $"Remove", r, NotifySelect = FileRemoveFile };
304 MenuDivider { popupContent };
305 MenuItem { popupContent, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
306 MenuDivider { popupContent };
307 MenuItem { popupContent, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
308 MenuItem { popupContent, $"Properties...", p, Key { enter, alt = true }, NotifySelect = FileProperties };
313 master = this, menu = popupContent;
315 x + clientStart.x + absPosition.x - app.desktop.position.x,
316 y + clientStart.y + absPosition.y - app.desktop.position.y };
318 void NotifyDestroyed(Window window, DialogResult result)
329 bool NotifyKeyHit(ListBox listBox, DataRow row, Key key, unichar ch)
331 if(key == altUp || key == altDown)
333 SelectNextProject(key == altUp);
339 bool NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch)
343 ProjectNode node = (ProjectNode)row.tag;
346 case altEnter: case Key { keyPadEnter, alt = true }:
348 NodeProperties { parent = parent, master = this,
349 position = { position.x + 100, position.y + 100 }, node = node }.Create();
352 case enter: case keyPadEnter:
355 for(resNode = node.parent; resNode; resNode = resNode.parent)
356 if(resNode.type == resources)
358 if(node.type == project || (node.type == folder && !resNode))
363 else if(node.type == resources || node.type == folder)
372 if(node.type == project || node.type == folder || node.type == resources)
381 if(node.type == project || node.type == folder || node.type == resources)
383 NewFolder(node, null, true);
390 if(node.type == file)
392 FileCompile(null, (Modifiers)key);
397 case Key { space, shift = true }:
400 if(node.type == NodeTypes::project)
403 for(p : workspace.projects)
405 if(p.topNode == node)
411 prj.RotateActiveConfig(!key.shift);
422 case enter: case keyPadEnter: OpenSelectedNodes(); break;
423 case del: RemoveSelectedNodes(); break;
426 Window activeClient = ide.activeClient;
428 activeClient.Activate();
430 ide.RepositionWindows(true);
437 bool NotifyCollapse(ListBox listBox, DataRow row, bool collapsed)
439 ProjectNode node = (ProjectNode)row.tag;
440 if(node.type == folder)
441 node.icon = collapsed ? folder : openFolder;
446 FileDialog importFileDialog { autoCreate = false, type = selectDir, text = $"Import Folder" };
447 FileDialog projectFileDialog
449 autoCreate = false, filters = projectFilters.array, sizeFilters = projectFilters.count * sizeof(FileFilter);
450 types = projectTypes.array, sizeTypes = projectTypes.count * sizeof(FileType);
452 FileDialog fileDialog
454 autoCreate = false, mayNotExist = true, filters = fileFilters.array, sizeFilters = fileFilters.count * sizeof(FileFilter);
456 FileDialog resourceFileDialog
458 autoCreate = false, mayNotExist = true, filters = resourceFilters.array, sizeFilters = resourceFilters.count * sizeof(FileFilter);
461 Menu fileMenu { menu, $"File", f };
462 MenuItem { fileMenu, $"Save", s, Key { s, ctrl = true }, NotifySelect = MenuFileSave };
463 // MenuItem { fileMenu, "Save As...", a, NotifySelect = MenuFileSaveAs };
465 bool OnClose(bool parentClosing)
467 if(!parentClosing && visible)
477 DialogResult dialogRes;
480 strcpy(msg, $"You have modified projects.\nSave changes to ");
481 for(p : ide.workspace.projects)
483 if(p.topNode.modified)
485 if(!first) strcat(msg, ", ");
492 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = msg }.Modal();
496 // TOFIX: Precomp error if brackets are taken out
497 return (DialogResult)MenuFileSave(null, 0) != cancel;
499 else if(dialogRes == cancel)
501 modifiedDocument = false;
508 //if(ide.findInFilesDialog && ide.findInFilesDialog.created && ide.findInFilesDialog.mode != directory)
509 // ide.findInFilesDialog.SearchStop();
511 ide.outputView.buildBox.Clear();
512 ide.outputView.debugBox.Clear();
513 //ide.outputView.findBox.Clear();
514 ide.callStackView.Clear();
515 ide.watchesView.Clear();
516 ide.threadsView.Clear();
517 ide.breakpointsView.Clear();
518 ide.outputView.ShowClearSelectTab(find); // why this?
521 bool OnSaveFile(char * fileName)
523 for(prj : ide.workspace.projects)
525 if(prj.topNode.modified)
527 prj.StopMonitoring();
528 if(prj.Save(prj.filePath))
529 prj.topNode.modified = false;
530 prj.StartMonitoring();
533 modifiedDocument = false;
538 bool IsModuleInProject(char * filePath)
540 char moduleName[MAX_FILENAME]; //, modulePath[MAX_LOCATION];
541 GetLastDirectory(filePath, moduleName);
542 return project.topNode.Find(moduleName, false) != null;
545 bool GetRelativePath(char * filePath, char * relativePath)
547 return project.GetRelativePath(filePath, relativePath);
550 ProjectNode GetNodeFromWindow(Window document, Project project, bool isCObject)
552 if(document.fileName)
554 char winFileName[MAX_LOCATION];
555 char * documentFileName = GetSlashPathBuffer(winFileName, document.fileName);
560 char name[MAX_FILENAME];
561 GetLastDirectory(documentFileName, name);
562 ChangeExtension(name, "ec", name);
563 for(p : ide.workspace.projects)
565 prj = project ? project : p;
566 if((node = prj.topNode.Find(name, false)))
573 for(p : ide.workspace.projects)
575 prj = project ? project : p;
576 if((node = prj.topNode.FindByFullPath(documentFileName, false)))
585 // ((( UTILITY FUNCTIONS )))
587 // ************************************************************************
588 // *** These methods below are part of a sequence of events, and as ***
589 // *** such they must be passed the current compiler and project config ***
590 // ************************************************************************
591 bool DisplayCompiler(CompilerConfig compiler, bool cleanLog)
593 ide.outputView.buildBox.Logf($"%s Compiler\n", compiler ? compiler.name : $"{problem with compiler selection}");
597 bool ProjectPrepareForToolchain(Project project, PrepareMakefileMethod method, bool cleanLog, bool displayCompiler,
598 CompilerConfig compiler, ProjectConfig config)
601 char message[MAX_F_STRING];
602 LogBox logBox = ide.outputView.buildBox;
604 ShowOutputBuildLog(cleanLog);
607 DisplayCompiler(compiler, false);
609 ProjectPrepareCompiler(project, compiler);
610 ProjectPrepareMakefile(project, method, compiler, config);
614 bool ProjectPrepareCompiler(Project project, CompilerConfig compiler)
616 if(!project.GenerateCrossPlatformMk() || !project.GenerateCompilerCf(compiler))
617 ide.outputView.buildBox.Logf($"Error generating compiler configuration (Is the project/config directory writable?)\n");
621 // Note: Compiler is only passed in to for VisualStudio support
622 bool ProjectPrepareMakefile(Project project, PrepareMakefileMethod method, CompilerConfig compiler, ProjectConfig config)
624 if(compiler.type.isVC)
626 // I'm guessing we'll want to support generating VS files on Linux as well...
627 ide.statusBar.text = $"Generating Visual Studio Solution...";
629 //GenerateVSSolutionFile(project, compiler);
630 ide.statusBar.text = $"Generating Visual Studio Project...";
632 //GenerateVCProjectFile(project, compiler);
633 ide.statusBar.text = null;
639 char makefilePath[MAX_LOCATION];
640 char makefileName[MAX_LOCATION];
642 LogBox logBox = ide.outputView.buildBox;
644 strcpy(makefilePath, project.topNode.path);
645 project.CatMakeFileName(makefileName, config);
646 PathCatSlash(makefilePath, makefileName);
648 exists = FileExists(makefilePath);
649 if(method == force ||
650 (method == forceExists && exists) ||
651 (method == normal && (!exists || (config && config.makingModified))))
655 ide.statusBar.text = $"Generating Makefile & Dependencies..."; // Dependencies?
658 if((method == normal && !exists) || (method == force && !exists))
659 action = $"Generating ";
660 else if(method == force)
661 action = $"Regenerating ";
662 else if(method == normal || method == forceExists)
663 action = $"Updating ";
667 reason = $"Makefile doesn't exist. ";
668 else if(project.topNode.modified)
669 reason = $"Project has been modified. ";
673 //logBox.Logf("%s\n", makefileName);
674 logBox.Logf($"%s - %s%smakefile for %s config...\n", makefileName, reason, action, GetConfigName(config));
676 if(!project.GenerateMakefile(null, false, null, config))
677 ide.outputView.buildBox.Logf($"Error generating makefile (Is the project directory writable?)\n");
679 ide.statusBar.text = null;
687 bool BuildInterrim(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config, bool justPrint)
689 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
691 ide.outputView.buildBox.Logf($"Building project %s using the %s configuration...\n", prj.name, GetConfigName(config));
692 return Build(prj, buildType, compiler, config, justPrint);
697 bool DebugStopForMake(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config)
700 // TOFIX: DebugStop is being abused and backfiring on us.
701 // It's supposed to be the 'Debug/Stop' item, not unloading executable or anything else
703 // configIsInDebugSession seems to be used for two OPPOSITE things:
704 // If we're debugging another config, we need to unload the executable!
705 // In building, we want to stop if we're debugging the 'same' executable
706 if(buildType != run) ///* && prj == project*/ && prj.configIsInDebugSession)
708 if(buildType == start || buildType == restart)
710 if(ide.debugger && ide.debugger.isPrepared)
711 result = DebugStop();
715 if(ide.project == prj && ide.debugger && ide.debugger.prjConfig == config && ide.debugger.isPrepared)
716 result = DebugStop();
722 bool Build(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config, bool justPrint)
728 for(document = master.firstChild; document; document = document.next)
730 if(document.modifiedDocument)
732 ProjectNode node = GetNodeFromWindow(document, prj, false);
733 if(node && !document.MenuFileSave(null, 0))
742 DirExpression targetDir = prj.GetTargetDir(compiler, config);
744 DebugStopForMake(prj, buildType, compiler, config);
746 // TODO: Disabled until problems fixed... is it fixed?
747 if(buildType == rebuild || (config && config.compilingModified))
748 prj.Clean(compiler, config, false, justPrint);
751 if(buildType == relink || (config && config.linkingModified))
753 char target[MAX_LOCATION];
755 strcpy(target, prj.topNode.path);
756 PathCat(target, targetDir.dir);
757 prj.CatTargetFileName(target, compiler, config);
758 if(FileExists(target))
761 if(config && config.symbolGenModified)
763 DirExpression objDir = prj.GetObjDir(compiler, config);
764 char fileName[MAX_LOCATION];
765 char moduleName[MAX_FILENAME];
766 strcpy(fileName, prj.topNode.path);
767 PathCatSlash(fileName, objDir.dir);
768 strcpy(moduleName, prj.moduleName);
769 strcat(moduleName, ".main.ec");
770 PathCatSlash(fileName, moduleName);
771 if(FileExists(fileName))
772 DeleteFile(fileName);
773 ChangeExtension(fileName, "c", fileName);
774 if(FileExists(fileName))
775 DeleteFile(fileName);
776 ChangeExtension(fileName, "o", fileName);
777 if(FileExists(fileName))
778 DeleteFile(fileName);
783 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
784 ide.AdjustBuildMenus();
785 ide.AdjustDebugMenus();
787 result = prj.Build(buildType == run, null, compiler, config, justPrint, normal);
791 config.compilingModified = false;
792 if(!ide.ShouldStopBuild())
793 config.linkingModified = false;
795 config.symbolGenModified = false;
797 buildInProgress = none;
798 ide.AdjustBuildMenus();
799 ide.AdjustDebugMenus();
801 ide.workspace.modified = true;
808 // ((( USER ACTIONS )))
810 // ************************************************************************
811 // *** Methods below should atomically start a process, and as such ***
812 // *** they can query compiler and config directly from ide and project ***
813 // *** but ONLY ONCE!!! ***
814 // ************************************************************************
816 bool ProjectBuild(MenuItem selection, Modifiers mods)
818 Project prj = project;
819 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
820 ProjectConfig config;
821 if(selection || !ide.activeClient)
823 DataRow row = fileList.currentRow;
824 ProjectNode node = row ? (ProjectNode)row.tag : null;
825 if(node) prj = node.project;
829 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
834 if(/*prj != project || */!prj.GetConfigIsInDebugSession(config) || !ide.DontTerminateDebugSession($"Project Build"))
836 BuildInterrim(prj, build, compiler, config, mods.ctrl && mods.shift);
842 bool ProjectLink(MenuItem selection, Modifiers mods)
844 Project prj = project;
845 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
846 ProjectConfig config;
847 if(selection || !ide.activeClient)
849 DataRow row = fileList.currentRow;
850 ProjectNode node = row ? (ProjectNode)row.tag : null;
851 if(node) prj = node.project;
855 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
860 if(!prj.GetConfigIsInDebugSession(config) ||
861 (!ide.DontTerminateDebugSession($"Project Link") && DebugStopForMake(prj, relink, compiler, config)))
863 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
865 ide.outputView.buildBox.Logf($"Relinking project %s using the %s configuration...\n", prj.name, GetConfigName(config));
867 config.linkingModified = true;
868 Build(prj, relink, compiler, config, mods.ctrl && mods.shift);
875 bool ProjectRebuild(MenuItem selection, Modifiers mods)
877 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
878 Project prj = project;
879 ProjectConfig config;
880 if(selection || !ide.activeClient)
882 DataRow row = fileList.currentRow;
883 ProjectNode node = row ? (ProjectNode)row.tag : null;
884 if(node) prj = node.project;
888 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
893 if(!prj.GetConfigIsInDebugSession(config) ||
894 (!ide.DontTerminateDebugSession($"Project Rebuild") && DebugStopForMake(prj, rebuild, compiler, config)))
896 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
898 ide.outputView.buildBox.Logf($"Rebuilding project %s using the %s configuration...\n", prj.name, GetConfigName(config));
901 config.compilingModified = true;
902 config.makingModified = true;
903 }*/ // -- should this still be used depite the new solution of BuildType?
904 Build(prj, rebuild, compiler, config, mods.ctrl && mods.shift);
911 bool ProjectClean(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") && DebugStopForMake(prj, clean, compiler, config)))
932 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
934 ide.outputView.buildBox.Logf($"Cleaning 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, false, mods.ctrl && mods.shift);
941 buildInProgress = none;
942 ide.AdjustBuildMenus();
943 ide.AdjustDebugMenus();
950 bool ProjectRealClean(MenuItem selection, Modifiers mods)
952 Project prj = project;
953 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
954 ProjectConfig config;
955 if(selection || !ide.activeClient)
957 DataRow row = fileList.currentRow;
958 ProjectNode node = row ? (ProjectNode)row.tag : null;
959 if(node) prj = node.project;
963 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
968 if(!prj.GetConfigIsInDebugSession(config) ||
969 (!ide.DontTerminateDebugSession($"Project Real Clean") && DebugStopForMake(prj, clean, compiler, config)))
971 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
973 ide.outputView.buildBox.Logf($"Removing intermediate objects directory for project %s using the %s configuration...\n", prj.name, GetConfigName(config));
975 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
976 ide.AdjustBuildMenus();
977 ide.AdjustDebugMenus();
979 prj.Clean(compiler, config, true, mods.ctrl && mods.shift);
980 buildInProgress = none;
981 ide.AdjustBuildMenus();
982 ide.AdjustDebugMenus();
989 bool ProjectRegenerate(MenuItem selection, Modifiers mods)
991 Project prj = project;
992 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
993 ShowOutputBuildLog(true);
994 if(selection || !ide.activeClient)
996 DataRow row = fileList.currentRow;
997 ProjectNode node = row ? (ProjectNode)row.tag : null;
1003 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
1008 DisplayCompiler(compiler, false);
1009 ProjectPrepareCompiler(project, compiler);
1010 ProjectPrepareMakefile(prj, force, compiler, prj.config);
1015 bool Compile(Project project, List<ProjectNode> nodes, bool justPrint, SingleFileCompileMode mode)
1018 char fileName[MAX_LOCATION];
1020 ProjectConfig config = project.config;
1024 for(document = ide.firstChild; document; document = document.next)
1026 if(document.modifiedDocument)
1028 ProjectNode n = GetNodeFromWindow(document, project, mode == cObject ? true : false);
1031 if(n && n.IsInNode(node) && !document.MenuFileSave(null, 0))
1033 ide.outputView.buildBox.Logf($"Unable to save %s file.\n", node.name);
1043 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1045 if(ProjectPrepareForToolchain(project, normal, true, true, compiler, config))
1048 ide.outputView.buildBox.Logf($"%s specific file(s) in project %s using the %s configuration...\n",
1049 mode == normal ? $"Compiling" : $"Debug compiling", project.name, config.name);
1051 ide.outputView.buildBox.Logf($"%s specific file(s) in project %s...\n",
1052 mode == normal ? $"Compiling" : $"Debug compiling", project.name);
1054 buildInProgress = compilingFile;
1055 ide.AdjustBuildMenus();
1056 project.Compile(nodes, compiler, config, justPrint, mode);
1057 buildInProgress = none;
1058 ide.AdjustBuildMenus();
1067 bool Clean(Project project, List<ProjectNode> nodes, bool justPrint)
1070 char fileName[MAX_LOCATION];
1072 ProjectConfig config = project.config;
1076 for(document = ide.firstChild; document; document = document.next)
1078 if(document.modifiedDocument)
1080 ProjectNode n = GetNodeFromWindow(document, project, false);
1083 if(n && n.IsInNode(node) && !document.MenuFileSave(null, 0))
1085 ide.outputView.buildBox.Logf($"Unable to save %s file.\n", node.name);
1095 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1097 if(ProjectPrepareForToolchain(project, normal, true, true, compiler, config))
1099 Map<String, NameCollisionInfo> namesInfo { };
1100 project.topNode.GenMakefileGetNameCollisionInfo(namesInfo, config);
1103 if(node.GetIsExcluded(config))
1104 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
1108 ide.outputView.buildBox.Logf($"Deleteing intermediate objects for %s %s in project %s using the %s configuration...\n",
1109 node.type == file ? $"single file" : $"folder", node.name, project.name, config.name);
1111 ide.outputView.buildBox.Logf($"Deleteing intermediate objects for %s %s in project %s...\n",
1112 node.type == file ? $"single file" : $"folder", node.name, project.name);
1114 node.DeleteIntermediateFiles(compiler, config, namesInfo, false);
1126 bool ProjectNewFile(MenuItem selection, Modifiers mods)
1128 DataRow row = fileList.currentRow;
1131 char fileName[1024];
1132 char filePath[MAX_LOCATION];
1133 ProjectNode parentNode = (ProjectNode)row.tag;
1134 ProjectNode n, fileNode;
1135 parentNode.GetFileSysMatchingPath(filePath);
1136 MakePathRelative(filePath, parentNode.project.topNode.path, filePath);
1137 for(n = parentNode; n && n != parentNode.project.resNode; n = n.parent);
1138 sprintf(fileName, $"Untitled %d", documentID);
1139 fileNode = AddFile(parentNode, fileName, (bool)n, true);
1140 fileNode.path = CopyUnixPath(filePath);
1143 NodeProperties nodeProperties
1146 position = { position.x + 100, position.y + 100 };
1150 nodeProperties.Create(); // not modal?
1156 bool ProjectNewFolder(MenuItem selection, Modifiers mods)
1158 DataRow row = fileList.currentRow;
1161 ProjectNode parentNode = (ProjectNode)row.tag;
1162 NewFolder(parentNode, null, true);
1167 bool ResourcesAddFiles(MenuItem selection, Modifiers mods)
1173 bool ProjectAddFiles(MenuItem selection, Modifiers mods)
1179 bool ProjectImportFolder(MenuItem selection, Modifiers mods)
1181 DataRow row = fileList.currentRow;
1184 ProjectNode toNode = (ProjectNode)row.tag;
1185 ImportFolder(toNode);
1190 bool ProjectAddNewForm(MenuItem selection, Modifiers mods)
1192 CodeEditor codeEditor = CreateNew("Form", "form", "Window", null);
1193 codeEditor.EnsureUpToDate();
1197 bool ProjectAddNewGraph(MenuItem selection, Modifiers mods)
1199 CodeEditor codeEditor = CreateNew("Graph", "graph", "Block", null);
1201 codeEditor.EnsureUpToDate();
1205 bool ProjectRemove(MenuItem selection, Modifiers mods)
1207 DataRow row = fileList.currentRow;
1210 ProjectNode node = (ProjectNode)row.tag;
1211 if(node.type == project)
1212 RemoveSelectedNodes();
1217 bool ProjectUpdateMakefileForAllConfigs(Project project)
1219 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1221 // This call really does not belong here:
1222 ide.UpdateToolBarActiveConfigs(false);
1223 for(config : project.configurations)
1224 ProjectPrepareMakefile(project, forceExists, compiler, config);
1231 bool MenuSettings(MenuItem selection, Modifiers mods)
1233 ProjectNode node = GetSelectedNode(true);
1234 Project prj = node ? node.project : project;
1235 projectSettingsDialog = ProjectSettings { master = parent, project = prj, projectNode = node };
1236 projectSettingsDialog.Modal();
1243 bool FileProperties(MenuItem selection, Modifiers mods)
1245 DataRow row = fileList.currentRow;
1248 ProjectNode node = (ProjectNode)row.tag;
1249 NodeProperties { parent = parent, master = this, node = node,
1250 position = { position.x + 100, position.y + 100 } }.Create();
1255 bool FileOpenFile(MenuItem selection, Modifiers mods)
1257 OpenSelectedNodes();
1261 bool FileRemoveFile(MenuItem selection, Modifiers mods)
1263 RemoveSelectedNodes();
1267 bool FileCompile(MenuItem selection, Modifiers mods)
1270 OldList selectedRows;
1271 Project project = null;
1272 List<ProjectNode> nodes { };
1273 fileList.GetMultiSelection(selectedRows);
1274 for(item = selectedRows.first; item; item = item.next)
1277 DataRow row = item.data;
1278 ProjectNode node = (ProjectNode)row.tag;
1280 project = node.project;
1281 else if(node.project != project)
1288 selectedRows.Free(null);
1290 Compile(project, nodes, mods.ctrl && mods.shift, normal);
1292 ide.outputView.buildBox.Logf($"Please select files from a single project.\n");
1297 bool FileClean(MenuItem selection, Modifiers mods)
1300 OldList selectedRows;
1301 Project project = null;
1302 List<ProjectNode> nodes { };
1303 fileList.GetMultiSelection(selectedRows);
1304 for(item = selectedRows.first; item; item = item.next)
1307 DataRow row = item.data;
1308 ProjectNode node = (ProjectNode)row.tag;
1310 project = node.project;
1311 else if(node.project != project)
1318 selectedRows.Free(null);
1320 Clean(project, nodes, mods.ctrl && mods.shift);
1322 ide.outputView.buildBox.Logf($"Please select files from a single project.\n");
1327 bool FileDebugPrecompile(MenuItem selection, Modifiers mods)
1329 DataRow row = fileList.currentRow;
1330 ProjectNode node = row ? (ProjectNode)row.tag : null;
1333 List<ProjectNode> nodes { };
1335 Compile(node.project, nodes, mods.ctrl && mods.shift, debugPrecompile);
1340 bool FileDebugCompile(MenuItem selection, Modifiers mods)
1342 DataRow row = fileList.currentRow;
1343 ProjectNode node = row ? (ProjectNode)row.tag : null;
1346 List<ProjectNode> nodes { };
1348 Compile(node.project, nodes, mods.ctrl && mods.shift, debugCompile);
1353 bool FileDebugGenerateSymbols(MenuItem selection, Modifiers mods)
1355 DataRow row = fileList.currentRow;
1356 ProjectNode node = row ? (ProjectNode)row.tag : null;
1359 List<ProjectNode> nodes { };
1361 Compile(node.project, nodes, mods.ctrl && mods.shift, debugGenerateSymbols);
1366 Project GetSelectedProject(bool useSelection)
1368 Project prj = project;
1371 DataRow row = fileList.currentRow;
1372 ProjectNode node = row ? (ProjectNode)row.tag : null;
1379 void SelectNextProject(bool backwards)
1381 DataRow row = fileList.currentRow;
1382 DataRow currentRow = row;
1383 ProjectNode node = (ProjectNode)row.tag;
1384 if(node.type != project)
1385 row = node.project.topNode.row;
1387 row = row.previous ? row.previous : fileList.lastRow;
1389 row = row.next ? row.next : fileList.firstRow;
1390 if(row && row != currentRow)
1392 fileList.SelectRow(row);
1393 fileList.currentRow = row;
1397 ProjectNode GetSelectedNode(bool useSelection)
1399 ProjectNode node = null;
1402 DataRow row = fileList.currentRow;
1404 node = (ProjectNode)row.tag;
1409 bool MenuBrowseFolder(MenuItem selection, Modifiers mods)
1411 char folder[MAX_LOCATION];
1413 ProjectNode node = GetSelectedNode(true);
1415 node = project.topNode;
1418 strcpy(folder, prj.topNode.path);
1419 if(node != prj.topNode)
1420 PathCatSlash(folder, node.path);
1425 bool Run(MenuItem selection, Modifiers mods)
1427 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1428 ProjectConfig config = project.config;
1429 String args = new char[maxPathLen];
1431 if(ide.workspace.commandLineArgs)
1432 //ide.debugger.GetCommandLineArgs(args);
1433 strcpy(args, ide.workspace.commandLineArgs);
1434 if(ide.debugger.isActive)
1435 project.Run(args, compiler, config);
1436 /*else if(config.targetType == sharedLibrary || config.targetType == staticLibrary)
1437 MessageBox { master = ide, type = ok, text = "Run", contents = "Shared and static libraries cannot be run like executables." }.Modal();*/
1438 else if(BuildInterrim(project, run, compiler, config, false))
1439 project.Run(args, compiler, config);
1447 bool result = false;
1448 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1449 ProjectConfig config = project.config;
1450 TargetTypes targetType = project.GetTargetType(config);
1451 if(targetType == sharedLibrary || targetType == staticLibrary)
1452 MessageBox { master = ide, type = ok, text = $"Run", contents = $"Shared and static libraries cannot be run like executables." }.Modal();
1453 else if(project.GetCompress(config))
1454 MessageBox { master = ide, text = $"Starting Debug", contents = $"Debugging compressed applications is not supported\n" }.Modal();
1455 else if(project.GetDebug(config) ||
1456 MessageBox { master = ide, type = okCancel, text = $"Starting Debug", contents = $"Attempting to debug non-debug configuration\nProceed anyways?" }.Modal() == ok)
1458 if(/*!IsProjectModified() ||*/ BuildInterrim(project, start, compiler, config, false))
1460 if(compiler.type.isVC)
1462 //bool result = false;
1463 char oldwd[MAX_LOCATION];
1464 PathBackup pathBackup { };
1465 char command[MAX_LOCATION];
1467 ide.SetPath(false, compiler, config);
1469 GetWorkingDir(oldwd, sizeof(oldwd));
1470 ChangeWorkingDir(project.topNode.path);
1472 sprintf(command, "%s /useenv %s.sln /projectconfig \"%s|Win32\" /command \"%s\"" , "devenv", project.name, config.name, "Debug.Start");
1474 ChangeWorkingDir(oldwd);
1480 ide.debugger.Start(compiler, config);
1489 void GoToError(const char * line)
1493 while(isspace(*line)) line++;
1494 colon = strstr(line, ":");
1499 bool lookForLineNumber = true;
1501 // deal with linking error
1502 if(colon && colon[1] == ' ')
1504 colon = strstr(colon + 1, ":");
1505 if(colon && !colon[1])
1507 colon = strstr(line, ":");
1508 lookForLineNumber = false;
1510 else if(colon && !isdigit(colon[1]))
1513 colon = strstr(line, ":");
1516 // Don't be mistaken by the drive letter colon
1517 if(colon && (colon[1] == '/' || colon[1] == '\\'))
1518 colon = strstr(colon + 1, ":");
1519 if(colon && lookForLineNumber)
1523 char * par = RSearchString(line, "(", colon - line, true, false);
1524 if(par && strstr(par, ")"))
1526 else if((colon+1)[0] == ' ')
1528 // NOTE: This is the same thing as saying 'colon = line'
1529 for( ; colon != line; colon--)
1533 lineNumber = atoi(colon + 1);
1535 comma = strchr(colon, ',');
1537 col = atoi(comma+1);
1539 comma = strchr(colon+1, ':');
1541 col = atoi(comma+1);
1545 char moduleName[MAX_LOCATION], filePath[MAX_LOCATION];
1549 char * inFileIncludedFrom = strstr(line, stringInFileIncludedFrom);
1550 char * start = inFileIncludedFrom ? line + strlen(stringInFileIncludedFrom) : line;
1551 int len = (int)(colon - start);
1552 len = Min(len, MAX_LOCATION-1);
1554 strncpy(moduleName, start, len);
1555 moduleName[len] = '\0';
1558 strcpy(moduleName, line);
1560 // Remove stuff in brackets
1562 bracket = strstr(moduleName, "(");
1563 if(bracket) *bracket = '\0';
1565 MakeSlashPath(moduleName);
1569 // Check if it's one of our modules
1570 ProjectNode node = project.topNode.Find(moduleName, false);
1573 strcpy(moduleName, node.path);
1574 PathCatSlash(moduleName, node.name);
1577 moduleName[0] = '\0';
1581 CodeEditor codeEditor;
1582 strcpy(filePath, project.topNode.path);
1583 PathCatSlash(filePath, moduleName);
1585 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
1588 char name[MAX_LOCATION];
1589 // TOFIX: Improve on this, don't use only filename, make a function
1590 if(ide && ide.workspace)
1592 for(prj : ide.workspace.projects)
1594 if(prj.topNode.FindWithPath(moduleName, false))
1596 strcpy(filePath, prj.topNode.path);
1597 PathCatSlash(filePath, moduleName);
1598 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
1605 if(codeEditor && lineNumber)
1607 EditBox editBox = codeEditor.editBox;
1608 editBox.GoToLineNum(lineNumber - 1);
1609 editBox.GoToPosition(editBox.line, lineNumber - 1, col ? (col - 1) : 0);
1616 bool OpenNode(ProjectNode node)
1618 char filePath[MAX_LOCATION];
1619 node.GetFullFilePath(filePath);
1620 return ide.OpenFile(filePath, normal, true/*false Why was it opening hidden?*/, null, something, normal) ? true : false;
1623 void AddNode(ProjectNode node, DataRow addTo)
1625 DataRow row = addTo ? addTo.AddRow() : fileList.AddRow();
1627 row.tag = (int64)node;
1630 if(node.type == resources)
1633 row.SetData(null, node);
1635 if(node.files && node.files.first && node.parent &&
1636 !(!node.parent.parent &&
1637 (!strcmpi(node.name, "notes") || !strcmpi(node.name, "sources") ||
1638 !strcmpi(node.name, "src") || !strcmpi(node.name, "tools"))))
1639 row.collapsed = true;
1640 else if(node.type == folder)
1641 node.icon = openFolder;
1645 for(child : node.files)
1646 AddNode(child, row);
1650 void DeleteNode(ProjectNode projectNode)
1652 if(projectNode.files)
1655 while(child = projectNode.files.first)
1658 fileList.DeleteRow(projectNode.row);
1659 projectNode.Delete();
1662 bool ProjectSave(MenuItem selection, Modifiers mods)
1664 DataRow row = fileList.currentRow;
1665 ProjectNode node = row ? (ProjectNode)row.tag : null;
1666 Project prj = node ? node.project : null;
1669 prj.StopMonitoring();
1670 if(prj.Save(prj.filePath))
1672 Project modPrj = null;
1673 prj.topNode.modified = false;
1674 for(p : ide.workspace.projects)
1676 if(p.topNode.modified)
1683 modifiedDocument = false;
1686 prj.StartMonitoring();
1691 bool ShowOutputBuildLog(bool cleanLog)
1693 OutputView output = ide.outputView;
1695 output.ShowClearSelectTab(build);
1698 output.SelectTab(build);
1706 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1707 ProjectConfig config = project.config;
1709 bool result = false;
1710 if(/*!IsProjectModified() ||*/ BuildInterrim(project, restart, compiler, config, false))
1712 // For Restart, compiler and config will only be used if for
1713 // whatever reason (if at all possible) the Debugger is in a
1714 // 'terminated' or 'none' state
1715 ide.debugger.Restart(compiler, config);
1725 ide.debugger.Resume();
1731 ide.debugger.Break();
1737 ide.debugger.Stop();
1741 bool DebugStepInto()
1743 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1744 ProjectConfig config = project.config;
1746 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config, false)))
1747 ide.debugger.StepInto(compiler, config);
1752 bool DebugStepOver(bool skip)
1754 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1755 ProjectConfig config = project.config;
1757 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config, false)))
1758 ide.debugger.StepOver(compiler, config, skip);
1764 bool DebugStepOut(bool skip)
1766 ide.debugger.StepOut(skip);
1770 void ImportFolder(ProjectNode toNode)
1774 //bool isFolder = toNode.type == folder;
1775 //bool isRes = toNode.isInResources;
1777 FileDialog fileDialog = importFileDialog;
1778 fileDialog.master = parent;
1779 if(fileDialog.Modal() == ok)
1781 ImportFolderFSI fsi { projectView = this };
1782 fsi.stack.Add(toNode);
1783 fsi.Iterate(fileDialog.filePath);
1789 ProjectNode NewFolder(ProjectNode parentNode, char * name, bool showProperties)
1793 ProjectNode folderNode;
1794 Project prj = parentNode.project;
1796 ProjectNode after = null;
1797 for(node : parentNode.files)
1799 if(node.type != folder)
1805 folderNode = parentNode.Add(prj, name, after, folder, folder, true);
1808 for(c = 0; c < 100; c++)
1811 sprintf(string, c ? "New Folder (%d)" : "New Folder", c);
1812 if((folderNode = parentNode.Add(prj, string, after, folder, folder, true)))
1819 NodeProperties nodeProperties;
1822 modifiedDocument = true;
1823 prj.topNode.modified = true;
1826 folderNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
1827 folderNode.row.tag = (int64)folderNode;
1829 folderNode.row.SetData(null, folderNode);
1830 fileList.currentRow = folderNode.row;
1834 nodeProperties = NodeProperties
1836 parent, this, mode = newFolder, node = folderNode;
1837 position = { position.x + 100, position.y + 100 };
1839 nodeProperties.Create(); // Modal?
1847 void AddFiles(bool resources)
1849 FileDialog fileDialog = (!resources) ? this.fileDialog : resourceFileDialog;
1850 fileDialog.type = multiOpen;
1851 fileDialog.text = !resources ? $"Add Files to Project" : $"Add Resources to Project";
1852 fileDialog.master = parent;
1854 if(fileDialog.Modal() == ok)
1857 DataRow row = fileList.currentRow;
1858 ProjectNode parentNode = (ProjectNode)row.tag;
1859 bool addFailed = false;
1860 int numSelections = fileDialog.numSelections;
1861 char ** multiFilePaths = fileDialog.multiFilePaths;
1863 Array<String> nameConflictFiles { };
1865 for(c = 0; c < numSelections; c++)
1867 char * filePath = multiFilePaths[c];
1868 FileAttribs exists = FileExists(filePath);
1869 bool addThisFile = true;
1871 if(exists.isDirectory)
1872 addThisFile = false;
1875 if(MessageBox { master = ide, type = yesNo, text = filePath,
1876 contents = $"File doesn't exist. Create?" }.Modal() == yes)
1878 File f = FileOpen(filePath, write);
1886 MessageBox { master = ide, type = ok, text = filePath,
1887 contents = $"Couldn't create file."}.Modal();
1888 addThisFile = false;
1895 /*addFailed = */if(!AddFile(parentNode, filePath, resources, false))//;
1897 nameConflictFiles.Add(CopyString(filePath));
1905 char * part1 = $"The following file";
1906 char * opt1 = $" was ";
1907 char * opt2 = $"s were ";
1908 char * part2 = $"not added because of identical file name conflict within the project.\n\n";
1910 len += strlen(part1);
1911 len += strlen(part2);
1912 len += nameConflictFiles.count > 1 ? strlen(opt2) : strlen(opt1);
1913 for(s : nameConflictFiles)
1914 len += strlen(s) + 1;
1915 message = new char[len + 1];
1916 strcpy(message, part1);
1917 strcat(message, nameConflictFiles.count > 1 ? opt2 : opt1);
1918 strcat(message, part2);
1919 for(s : nameConflictFiles)
1922 strcat(message, "\n");
1924 MessageBox { master = ide, type = ok, text = $"Name Conflict",
1925 contents = message }.Modal();
1928 nameConflictFiles.Free();
1929 delete nameConflictFiles;
1933 ProjectNode AddFile(ProjectNode parentNode, char * filePath, bool resources, bool isTemporary)
1935 ProjectNode result = null;
1936 ProjectNode after = null;
1937 for(node : parentNode.files)
1939 if(node.type != folder && node.type != file && node.type)
1944 result = parentNode.Add(parentNode.project, filePath, after, file, NodeIcons::SelectFileIcon(filePath), !resources);
1950 modifiedDocument = true;
1951 parentNode.project.topNode.modified = true;
1952 parentNode.project.ModifiedAllConfigs(true, false, true, true);
1955 result.row = parentNode.row.AddRowAfter(after ? after.row : null);
1956 result.row.tag = (int64)result;
1957 result.row.SetData(null, result);
1962 CodeEditor CreateNew(char * upper, char * lower, char * base, char * className)
1964 CodeEditor codeEditor = null;
1965 ProjectNode projectNode;
1966 ProjectNode after = null;
1967 DataRow row = fileList.currentRow;
1968 ProjectNode parentNode;
1971 if(!row) row = project.topNode.row;
1973 parentNode = (ProjectNode)row.tag;
1975 for(node : parentNode.files)
1977 if(node.type != folder && node.type != file && node.type)
1981 for(c = 1; c < 100; c++)
1984 sprintf(string, c ? "%s%d.ec" : "%s.ec", lower, c);
1985 if((projectNode = parentNode.Add(project, string, after, file, genFile, true)))
1991 char filePath[MAX_LOCATION];
1993 modifiedDocument = true;
1994 project.topNode.modified = true;
1996 project.ModifiedAllConfigs(true, false, false, true);
1997 projectNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
1998 projectNode.row.tag =(int64)projectNode;
2000 projectNode.row.SetData(null, projectNode);
2001 fileList.currentRow = projectNode.row;
2003 strcpy(filePath, project.topNode.path);
2004 PathCat(filePath, projectNode.path);
2005 PathCat(filePath, projectNode.name);
2007 codeEditor = (CodeEditor)ide.FindWindow(filePath);
2010 Class baseClass = eSystem_FindClass(__thisModule, base);
2011 subclass(ClassDesignerBase) designerClass = eClass_GetDesigner(baseClass);
2014 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal);
2015 strcpy(name, projectNode.name);
2016 sprintf(name, "%s%d", upper, c);
2018 strcpy(className, name);
2020 designerClass.CreateNew(codeEditor.editBox, codeEditor.clientSize, name, base);
2022 //codeEditor.modifiedDocument = false;
2023 //codeEditor.designer.modifiedDocument = false;
2025 //Code_EnsureUpToDate(codeEditor);
2028 else // TODO: fix no symbols generated when ommiting {} for following else
2030 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal);
2034 codeEditor.ViewDesigner();
2035 codeEditor.codeModified = true;
2042 // Returns true if we opened something
2043 bool OpenSelectedNodes()
2045 bool result = false;
2049 fileList.GetMultiSelection(selection);
2050 for(item = selection.first; item; item = item.next)
2052 DataRow row = item.data;
2053 ProjectNode node = (ProjectNode)row.tag;
2054 if(node.type == file)
2061 selection.Free(null);
2065 void RemoveSelectedNodes()
2070 fileList.GetMultiSelection(selection);
2072 // Remove children of parents we're deleting
2073 for(item = selection.first; item; item = next)
2076 DataRow row = item.data;
2077 ProjectNode n, node = (ProjectNode)row.tag;
2078 bool remove = false;
2081 for(i = selection.first; i && !remove; i = i.next)
2083 ProjectNode iNode = (ProjectNode)((DataRow)i.data).tag;
2084 for(n = node.parent; n; n = n.parent)
2094 selection.Delete(item);
2097 for(item = selection.first; item; item = item.next)
2099 DataRow row = item.data;
2100 ProjectNode node = (ProjectNode)row.tag;
2101 ProjectNode resNode;
2102 for(resNode = node.parent; resNode; resNode = resNode.parent)
2103 if(resNode.type == resources)
2105 if(node.type == file)
2107 Project prj = node.project;
2109 modifiedDocument = true;
2110 prj.topNode.modified = true;
2112 prj.ModifiedAllConfigs(true, false, true, true);
2114 else if(node.type == folder)
2117 sprintf(message, $"Are you sure you want to remove the folder \"%s\"\n"
2118 "and all of its contents from the project?", node.name);
2119 if(MessageBox { master = ide, type = yesNo, text = $"Delete Folder", contents = message }.Modal() == yes)
2121 Project prj = node.project;
2122 if(node.containsFile)
2123 prj.ModifiedAllConfigs(true, false, true, true);
2125 modifiedDocument = true;
2126 prj.topNode.modified = true;
2129 else if(node.type == project && node != project.topNode && !buildInProgress)
2133 for(p : workspace.projects)
2135 if(p.topNode == node)
2141 sprintf(message, $"Are you sure you want to remove the \"%s\" project\n" "from this workspace?", node.name);
2142 if(MessageBox { master = ide, type = yesNo, text = $"Remove Project", contents = message }.Modal() == yes)
2147 workspace.RemoveProject(prj);
2148 //modifiedDocument = true; // when project view is a workspace view
2152 selection.Free(null);