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 bool showDebuggingMenuItems = mods.ctrl && mods.shift;
211 ProjectNode node = (ProjectNode)row.tag;
212 if(node.type == NodeTypes::project || node.type == resources || node.type == file || node.type == folder)
214 bool na = buildInProgress; // N/A - buildMenuUnavailable
217 if(node.type == NodeTypes::project)
220 mi = ide.projectBuildItem;
221 MenuItem { pop, $"Build" , b, f7 , NotifySelect = ProjectBuild , bitmap = mi.bitmap }.disabled = na; mi = ide.projectLinkItem;
222 MenuItem { pop, $"Relink" , l , NotifySelect = ProjectLink , bitmap = mi.bitmap }.disabled = na; mi = ide.projectRebuildItem;
223 MenuItem { pop, $"Rebuild" , r, shiftF7, NotifySelect = ProjectRebuild , bitmap = mi.bitmap }.disabled = na; mi = ide.projectCleanItem;
224 MenuItem { pop, $"Clean" , c , NotifySelect = ProjectClean , bitmap = mi.bitmap }.disabled = na; mi = ide.projectRealCleanItem;
225 MenuItem { pop, $"Real Clean" , d , NotifySelect = ProjectRealClean , bitmap = mi.bitmap }.disabled = na; mi = ide.projectRegenerateItem;
226 MenuItem { pop, $"Regenerate Makefile", m , NotifySelect = ProjectRegenerate, bitmap = mi.bitmap }.disabled = na;
228 if(showDebuggingMenuItems && node.ContainsFilesWithExtension("ec"))
231 MenuItem { pop, $"Debug Generate Symbols", l, NotifySelect = FileDebugGenerateSymbols }.disabled = na;
234 MenuItem { pop, $"New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
235 MenuItem { pop, $"New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
236 MenuItem { pop, $"Import Folder...", i, NotifySelect = ProjectImportFolder };
237 MenuItem { pop, $"Add Files to Project...", f, NotifySelect = ProjectAddFiles };
239 MenuItem { pop, $"Add New Form...", o, NotifySelect = ProjectAddNewForm };
240 // MenuItem { pop, "Add New Behavior Graph...", g, NotifySelect = ProjectAddNewGraph };
242 if(node != ((Project)workspace.projects.first).topNode)
244 MenuItem { pop, $"Remove project from workspace", r, NotifySelect = ProjectRemove }.disabled = na;
247 MenuItem { pop, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
249 MenuItem { pop, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
251 MenuItem { pop, $"Save", v, Key { s, ctrl = true }, NotifySelect = ProjectSave }.disabled = !node.modified;
253 MenuItem { pop, $"Properties...", p, Key { enter, alt = true }, NotifySelect = FileProperties };
255 else if(node.type == resources)
257 MenuItem { pop, $"New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
258 MenuItem { pop, $"New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
259 MenuItem { pop, $"Import Folder...", i, NotifySelect = ProjectImportFolder };
260 MenuItem { pop, $"Add Resources to Project...", f, NotifySelect = ResourcesAddFiles };
261 MenuItem { pop, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
263 MenuItem { pop, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
264 MenuItem { pop, $"Properties...", p, Key { enter, alt = true }, NotifySelect = FileProperties };
266 else if(node.type == file)
268 MenuItem { pop, $"Open", o, NotifySelect = FileOpenFile };
270 MenuItem { pop, $"Clean", l, NotifySelect = FileClean, bitmap = ide.projectCleanItem.bitmap }.disabled = na;
271 MenuItem { pop, $"Compile", c, Key { f7, ctrl = true}, NotifySelect = FileCompile, bitmap = ide.projectBuildItem.bitmap }.disabled = na;
272 if(showDebuggingMenuItems)
274 char extension[MAX_EXTENSION];
275 GetExtension(node.name, extension);
276 if(!strcmpi(extension, "ec"))
279 MenuItem { pop, $"Debug Precompile", l, NotifySelect = FileDebugPrecompile }.disabled = na;
280 MenuItem { pop, $"Debug Compile", l, NotifySelect = FileDebugCompile }.disabled = na;
284 MenuItem { pop, $"Remove", r, NotifySelect = FileRemoveFile };
286 MenuItem { pop, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
288 MenuItem { pop, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
289 MenuItem { pop, $"Properties..", p, Key { enter, alt = true }, NotifySelect = FileProperties };
291 else if(node.type == folder)
293 bool isInResources = node.isInResources;
295 MenuItem { pop, $"New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
296 MenuItem { pop, $"New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
297 MenuItem { pop, $"Import Folder...", i, NotifySelect = ProjectImportFolder };
300 MenuItem { pop, $"Add Resources to Folder...", f, NotifySelect = ResourcesAddFiles };
304 MenuItem { pop, $"Add Files to Folder...", f, NotifySelect = ProjectAddFiles };
309 MenuItem { pop, $"Add New Form...", o, NotifySelect = ProjectAddNewForm };
310 // MenuItem { pop, $"Add New Behavior Graph...", g, NotifySelect = ProjectAddNewGraph };
313 MenuItem { pop, $"Clean", l, NotifySelect = FileClean, bitmap = ide.projectCleanItem.bitmap }.disabled = na;
314 MenuItem { pop, $"Compile", c, Key { f7, ctrl = true}, NotifySelect = FileCompile, bitmap = ide.projectBuildItem.bitmap }.disabled = na;
316 MenuItem { pop, $"Remove", r, NotifySelect = FileRemoveFile };
318 MenuItem { pop, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
320 MenuItem { pop, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
321 MenuItem { pop, $"Properties...", p, Key { enter, alt = true }, NotifySelect = FileProperties };
326 master = this, menu = pop;
328 x + clientStart.x + absPosition.x - app.desktop.position.x,
329 y + clientStart.y + absPosition.y - app.desktop.position.y };
331 void NotifyDestroyed(Window window, DialogResult result)
337 ide.AdjustPopupBuildMenus();
343 bool NotifyKeyHit(ListBox listBox, DataRow row, Key key, unichar ch)
345 if(key == altUp || key == altDown)
347 SelectNextProject(key == altUp);
353 bool NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch)
357 ProjectNode node = (ProjectNode)row.tag;
360 case altEnter: case Key { keyPadEnter, alt = true }:
362 NodeProperties { parent = parent, master = this,
363 position = { position.x + 100, position.y + 100 }, node = node }.Create();
366 case enter: case keyPadEnter:
369 for(resNode = node.parent; resNode; resNode = resNode.parent)
370 if(resNode.type == resources)
372 if(node.type == project || (node.type == folder && !resNode))
377 else if(node.type == resources || node.type == folder)
386 if(node.type == project || node.type == folder || node.type == resources)
395 if(node.type == project || node.type == folder || node.type == resources)
397 NewFolder(node, null, true);
404 if(node.type == file)
406 FileCompile(null, (Modifiers)key);
411 case Key { space, shift = true }:
414 if(node.type == NodeTypes::project)
417 for(p : workspace.projects)
419 if(p.topNode == node)
425 prj.RotateActiveConfig(!key.shift);
436 case enter: case keyPadEnter: OpenSelectedNodes(); break;
437 case del: RemoveSelectedNodes(); break;
440 Window activeClient = ide.activeClient;
442 activeClient.Activate();
444 ide.RepositionWindows(true);
451 bool NotifyCollapse(ListBox listBox, DataRow row, bool collapsed)
453 ProjectNode node = (ProjectNode)row.tag;
454 if(node.type == folder)
455 node.icon = collapsed ? folder : openFolder;
460 FileDialog importFileDialog { autoCreate = false, type = selectDir, text = $"Import Folder" };
461 FileDialog projectFileDialog
463 autoCreate = false, filters = projectFilters.array, sizeFilters = projectFilters.count * sizeof(FileFilter);
464 types = projectTypes.array, sizeTypes = projectTypes.count * sizeof(FileType);
466 FileDialog fileDialog
468 autoCreate = false, mayNotExist = true, filters = fileFilters.array, sizeFilters = fileFilters.count * sizeof(FileFilter);
470 FileDialog resourceFileDialog
472 autoCreate = false, mayNotExist = true, filters = resourceFilters.array, sizeFilters = resourceFilters.count * sizeof(FileFilter);
475 Menu fileMenu { menu, $"File", f };
476 MenuItem { fileMenu, $"Save", s, Key { s, ctrl = true }, NotifySelect = MenuFileSave };
477 // MenuItem { fileMenu, "Save As...", a, NotifySelect = MenuFileSaveAs };
479 bool OnClose(bool parentClosing)
481 if(!parentClosing && visible)
491 DialogResult dialogRes;
494 strcpy(msg, $"You have modified projects.\nSave changes to ");
495 for(p : ide.workspace.projects)
497 if(p.topNode.modified)
499 if(!first) strcat(msg, ", ");
506 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = msg }.Modal();
510 // TOFIX: Precomp error if brackets are taken out
511 return (DialogResult)MenuFileSave(null, 0) != cancel;
513 else if(dialogRes == cancel)
515 modifiedDocument = false;
522 //if(ide.findInFilesDialog && ide.findInFilesDialog.created && ide.findInFilesDialog.mode != directory)
523 // ide.findInFilesDialog.SearchStop();
525 ide.outputView.buildBox.Clear();
526 ide.outputView.debugBox.Clear();
527 //ide.outputView.findBox.Clear();
528 ide.callStackView.Clear();
529 ide.watchesView.Clear();
530 ide.threadsView.Clear();
531 ide.breakpointsView.Clear();
532 ide.outputView.ShowClearSelectTab(find); // why this?
535 bool OnSaveFile(char * fileName)
537 for(prj : ide.workspace.projects)
539 if(prj.topNode.modified)
541 prj.StopMonitoring();
542 if(prj.Save(prj.filePath))
543 prj.topNode.modified = false;
544 prj.StartMonitoring();
547 modifiedDocument = false;
552 bool IsModuleInProject(char * filePath)
554 char moduleName[MAX_FILENAME]; //, modulePath[MAX_LOCATION];
555 GetLastDirectory(filePath, moduleName);
556 return project.topNode.Find(moduleName, false) != null;
559 bool GetRelativePath(char * filePath, char * relativePath)
561 return project.GetRelativePath(filePath, relativePath);
564 ProjectNode GetNodeFromWindow(Window document, Project project, bool isCObject)
566 if(document.fileName)
568 char winFileName[MAX_LOCATION];
569 char * documentFileName = GetSlashPathBuffer(winFileName, document.fileName);
574 char name[MAX_FILENAME];
575 GetLastDirectory(documentFileName, name);
576 ChangeExtension(name, "ec", name);
577 for(p : ide.workspace.projects)
579 prj = project ? project : p;
580 if((node = prj.topNode.Find(name, false)))
587 for(p : ide.workspace.projects)
589 prj = project ? project : p;
590 if((node = prj.topNode.FindByFullPath(documentFileName, false)))
599 // ((( UTILITY FUNCTIONS )))
601 // ************************************************************************
602 // *** These methods below are part of a sequence of events, and as ***
603 // *** such they must be passed the current compiler and project config ***
604 // ************************************************************************
605 bool DisplayCompiler(CompilerConfig compiler, bool cleanLog)
607 ide.outputView.buildBox.Logf($"%s Compiler\n", compiler ? compiler.name : $"{problem with compiler selection}");
611 bool ProjectPrepareForToolchain(Project project, PrepareMakefileMethod method, bool cleanLog, bool displayCompiler,
612 CompilerConfig compiler, ProjectConfig config)
615 char message[MAX_F_STRING];
616 LogBox logBox = ide.outputView.buildBox;
618 ShowOutputBuildLog(cleanLog);
621 DisplayCompiler(compiler, false);
623 ProjectPrepareCompiler(project, compiler, false);
624 ProjectPrepareMakefile(project, method, compiler, config);
628 bool ProjectPrepareCompiler(Project project, CompilerConfig compiler, bool silent)
630 if((!project.GenerateCrossPlatformMk(app.includeFile) || !project.GenerateCompilerCf(compiler)) && !silent)
631 ide.outputView.buildBox.Logf($"Error generating compiler configuration (Is the project/config directory writable?)\n");
635 // Note: Compiler is only passed in to for VisualStudio support
636 bool ProjectPrepareMakefile(Project project, PrepareMakefileMethod method, CompilerConfig compiler, ProjectConfig config)
638 if(compiler.type.isVC)
640 // I'm guessing we'll want to support generating VS files on Linux as well...
641 ide.statusBar.text = $"Generating Visual Studio Solution...";
643 //GenerateVSSolutionFile(project, compiler);
644 ide.statusBar.text = $"Generating Visual Studio Project...";
646 //GenerateVCProjectFile(project, compiler, bitDepth);
647 ide.statusBar.text = null;
653 char makefilePath[MAX_LOCATION];
654 char makefileName[MAX_LOCATION];
656 LogBox logBox = ide.outputView.buildBox;
658 strcpy(makefilePath, project.topNode.path);
659 project.CatMakeFileName(makefileName, config);
660 PathCatSlash(makefilePath, makefileName);
662 exists = FileExists(makefilePath);
663 if(method == force ||
664 (method == forceExists && exists) ||
665 (method == normal && (!exists || (config && config.makingModified))))
669 ide.statusBar.text = $"Generating Makefile & Dependencies..."; // Dependencies?
672 if((method == normal && !exists) || (method == force && !exists))
673 action = $"Generating ";
674 else if(method == force)
675 action = $"Regenerating ";
676 else if(method == normal || method == forceExists)
677 action = $"Updating ";
681 reason = $"Makefile doesn't exist. ";
682 else if(project.topNode.modified)
683 reason = $"Project has been modified. ";
687 //logBox.Logf("%s\n", makefileName);
688 logBox.Logf($"%s - %s%smakefile for %s config...\n", makefileName, reason, action, GetConfigName(config));
690 if(!project.GenerateMakefile(null, false, null, config))
691 ide.outputView.buildBox.Logf($"Error generating makefile (Is the project directory writable?)\n");
693 ide.statusBar.text = null;
701 bool BuildInterrim(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config, int bitDepth, bool justPrint)
703 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
705 ide.outputView.buildBox.Logf($"Building project %s using the %s configuration...\n", prj.name, GetConfigName(config));
706 return Build(prj, buildType, compiler, config, bitDepth, justPrint);
711 bool DebugStopForMake(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config)
714 // TOFIX: DebugStop is being abused and backfiring on us.
715 // It's supposed to be the 'Debug/Stop' item, not unloading executable or anything else
717 // configIsInDebugSession seems to be used for two OPPOSITE things:
718 // If we're debugging another config, we need to unload the executable!
719 // In building, we want to stop if we're debugging the 'same' executable
720 if(buildType != run) ///* && prj == project*/ && prj.configIsInDebugSession)
722 if(buildType == start || buildType == restart)
724 if(ide.debugger && ide.debugger.isPrepared)
725 result = DebugStop();
729 if(ide.project == prj && ide.debugger && ide.debugger.prjConfig == config && ide.debugger.isPrepared)
730 result = DebugStop();
736 bool Build(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config, int bitDepth, bool justPrint)
742 for(document = master.firstChild; document; document = document.next)
744 if(document.modifiedDocument)
746 ProjectNode node = GetNodeFromWindow(document, prj, false);
747 if(node && !document.MenuFileSave(null, 0))
756 DirExpression targetDir = prj.GetTargetDir(compiler, config, bitDepth);
758 DebugStopForMake(prj, buildType, compiler, config);
760 // TODO: Disabled until problems fixed... is it fixed?
761 if(buildType == rebuild || (config && config.compilingModified))
762 prj.Clean(compiler, config, bitDepth, clean, justPrint);
765 if(buildType == relink || (config && config.linkingModified))
766 prj.Clean(compiler, config, bitDepth, cleanTarget, false);
767 if(config && config.symbolGenModified)
769 DirExpression objDir = prj.GetObjDir(compiler, config, bitDepth);
770 char fileName[MAX_LOCATION];
771 char moduleName[MAX_FILENAME];
772 strcpy(fileName, prj.topNode.path);
773 PathCatSlash(fileName, objDir.dir);
774 strcpy(moduleName, prj.moduleName);
775 strcat(moduleName, ".main.ec");
776 PathCatSlash(fileName, moduleName);
777 if(FileExists(fileName))
778 DeleteFile(fileName);
779 ChangeExtension(fileName, "c", fileName);
780 if(FileExists(fileName))
781 DeleteFile(fileName);
782 ChangeExtension(fileName, "o", fileName);
783 if(FileExists(fileName))
784 DeleteFile(fileName);
789 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
790 ide.AdjustBuildMenus();
791 ide.AdjustDebugMenus();
793 result = prj.Build(buildType == run, null, compiler, config, bitDepth, justPrint, normal);
797 config.compilingModified = false;
798 if(!ide.ShouldStopBuild())
799 config.linkingModified = false;
801 config.symbolGenModified = false;
803 buildInProgress = none;
804 ide.AdjustBuildMenus();
805 ide.AdjustDebugMenus();
807 ide.workspace.modified = true;
814 // ((( USER ACTIONS )))
816 // ************************************************************************
817 // *** Methods below should atomically start a process, and as such ***
818 // *** they can query compiler and config directly from ide and project ***
819 // *** but ONLY ONCE!!! ***
820 // ************************************************************************
822 bool ProjectBuild(MenuItem selection, Modifiers mods)
824 if(buildInProgress == none)
826 Project prj = project;
827 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
828 int bitDepth = ide.workspace.bitDepth;
829 ProjectConfig config;
830 if(selection || !ide.activeClient)
832 DataRow row = fileList.currentRow;
833 ProjectNode node = row ? (ProjectNode)row.tag : null;
834 if(node) prj = node.project;
838 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
843 if(/*prj != project || */!prj.GetConfigIsInDebugSession(config) || !ide.DontTerminateDebugSession($"Project Build"))
845 BuildInterrim(prj, build, compiler, config, bitDepth, mods.ctrl && mods.shift);
854 bool ProjectLink(MenuItem selection, Modifiers mods)
856 Project prj = project;
857 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
858 int bitDepth = ide.workspace.bitDepth;
859 ProjectConfig config;
860 if(selection || !ide.activeClient)
862 DataRow row = fileList.currentRow;
863 ProjectNode node = row ? (ProjectNode)row.tag : null;
864 if(node) prj = node.project;
868 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
873 if(!prj.GetConfigIsInDebugSession(config) ||
874 (!ide.DontTerminateDebugSession($"Project Link") && DebugStopForMake(prj, relink, compiler, config)))
876 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
878 ide.outputView.buildBox.Logf($"Relinking project %s using the %s configuration...\n", prj.name, GetConfigName(config));
880 config.linkingModified = true;
881 Build(prj, relink, compiler, config, bitDepth, mods.ctrl && mods.shift);
888 bool ProjectRebuild(MenuItem selection, Modifiers mods)
890 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
891 int bitDepth = ide.workspace.bitDepth;
892 Project prj = project;
893 ProjectConfig config;
894 if(selection || !ide.activeClient)
896 DataRow row = fileList.currentRow;
897 ProjectNode node = row ? (ProjectNode)row.tag : null;
898 if(node) prj = node.project;
902 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
907 if(!prj.GetConfigIsInDebugSession(config) ||
908 (!ide.DontTerminateDebugSession($"Project Rebuild") && DebugStopForMake(prj, rebuild, compiler, config)))
910 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
912 ide.outputView.buildBox.Logf($"Rebuilding project %s using the %s configuration...\n", prj.name, GetConfigName(config));
915 config.compilingModified = true;
916 config.makingModified = true;
917 }*/ // -- should this still be used depite the new solution of BuildType?
918 Build(prj, rebuild, compiler, config, bitDepth, mods.ctrl && mods.shift);
926 bool ProjectCleanTarget(MenuItem selection, Modifiers mods)
928 Project prj = project;
929 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
930 ProjectConfig config;
931 if(selection || !ide.activeClient)
933 DataRow row = fileList.currentRow;
934 ProjectNode node = row ? (ProjectNode)row.tag : null;
935 if(node) prj = node.project;
939 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
944 if(!prj.GetConfigIsInDebugSession(config) ||
945 (!ide.DontTerminateDebugSession($"Project Clean Target") && DebugStopForMake(prj, clean, compiler, config)))
947 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
949 ide.outputView.buildBox.Logf($"Cleaning target for project %s using the %s configuration...\n", prj.name, GetConfigName(config));
951 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
952 ide.AdjustBuildMenus();
953 ide.AdjustDebugMenus();
955 prj.Clean(compiler, config, cleanTarget, mods.ctrl && mods.shift);
956 buildInProgress = none;
957 ide.AdjustBuildMenus();
958 ide.AdjustDebugMenus();
966 bool ProjectClean(MenuItem selection, Modifiers mods)
968 Project prj = project;
969 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
970 ProjectConfig config;
971 int bitDepth = ide.workspace.bitDepth;
972 if(selection || !ide.activeClient)
974 DataRow row = fileList.currentRow;
975 ProjectNode node = row ? (ProjectNode)row.tag : null;
976 if(node) prj = node.project;
980 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
985 if(!prj.GetConfigIsInDebugSession(config) ||
986 (!ide.DontTerminateDebugSession($"Project Clean") && DebugStopForMake(prj, clean, compiler, config)))
988 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
990 ide.outputView.buildBox.Logf($"Cleaning project %s using the %s configuration...\n", prj.name, GetConfigName(config));
992 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
993 ide.AdjustBuildMenus();
994 ide.AdjustDebugMenus();
996 prj.Clean(compiler, config, bitDepth, clean, mods.ctrl && mods.shift);
997 buildInProgress = none;
998 ide.AdjustBuildMenus();
999 ide.AdjustDebugMenus();
1006 bool ProjectRealClean(MenuItem selection, Modifiers mods)
1008 Project prj = project;
1009 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1010 ProjectConfig config;
1011 int bitDepth = ide.workspace.bitDepth;
1012 if(selection || !ide.activeClient)
1014 DataRow row = fileList.currentRow;
1015 ProjectNode node = row ? (ProjectNode)row.tag : null;
1016 if(node) prj = node.project;
1020 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
1024 config = prj.config;
1025 if(!prj.GetConfigIsInDebugSession(config) ||
1026 (!ide.DontTerminateDebugSession($"Project Real Clean") && DebugStopForMake(prj, clean, compiler, config)))
1028 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
1030 ide.outputView.buildBox.Logf($"Removing intermediate objects directory for project %s using the %s configuration...\n", prj.name, GetConfigName(config));
1032 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
1033 ide.AdjustBuildMenus();
1034 ide.AdjustDebugMenus();
1036 prj.Clean(compiler, config, bitDepth, realClean, mods.ctrl && mods.shift);
1037 buildInProgress = none;
1038 ide.AdjustBuildMenus();
1039 ide.AdjustDebugMenus();
1046 bool ProjectRegenerate(MenuItem selection, Modifiers mods)
1048 Project prj = project;
1049 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1050 ShowOutputBuildLog(true);
1051 if(selection || !ide.activeClient)
1053 DataRow row = fileList.currentRow;
1054 ProjectNode node = row ? (ProjectNode)row.tag : null;
1060 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
1065 DisplayCompiler(compiler, false);
1066 ProjectPrepareCompiler(project, compiler, false);
1067 ProjectPrepareMakefile(prj, force, compiler, prj.config);
1072 bool Compile(Project project, List<ProjectNode> nodes, bool justPrint, SingleFileCompileMode mode)
1075 char fileName[MAX_LOCATION];
1077 ProjectConfig config = project.config;
1081 for(document = ide.firstChild; document; document = document.next)
1083 if(document.modifiedDocument)
1085 ProjectNode n = GetNodeFromWindow(document, project, mode == cObject ? true : false);
1088 if(n && n.IsInNode(node) && !document.MenuFileSave(null, 0))
1090 ide.outputView.buildBox.Logf($"Unable to save %s file.\n", node.name);
1100 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1101 int bitDepth = ide.workspace.bitDepth;
1103 if(ProjectPrepareForToolchain(project, normal, true, true, compiler, config))
1106 ide.outputView.buildBox.Logf($"%s specific file(s) in project %s using the %s configuration...\n",
1107 (mode == normal || mode == cObject) ? $"Compiling" : $"Debug compiling", project.name, config.name);
1109 ide.outputView.buildBox.Logf($"%s specific file(s) in project %s...\n",
1110 (mode == normal || mode == cObject) ? $"Compiling" : $"Debug compiling", project.name);
1112 buildInProgress = compilingFile;
1113 ide.AdjustBuildMenus();
1114 project.Compile(nodes, compiler, config, bitDepth, justPrint, mode);
1115 buildInProgress = none;
1116 ide.AdjustBuildMenus();
1125 bool Clean(Project project, List<ProjectNode> nodes, bool justPrint)
1128 char fileName[MAX_LOCATION];
1130 ProjectConfig config = project.config;
1134 for(document = ide.firstChild; document; document = document.next)
1136 if(document.modifiedDocument)
1138 ProjectNode n = GetNodeFromWindow(document, project, false);
1141 if(n && n.IsInNode(node) && !document.MenuFileSave(null, 0))
1143 ide.outputView.buildBox.Logf($"Unable to save %s file.\n", node.name);
1153 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1154 int bitDepth = ide.workspace.bitDepth;
1156 if(ProjectPrepareForToolchain(project, normal, true, true, compiler, config))
1158 Map<String, NameCollisionInfo> namesInfo { };
1159 project.topNode.GenMakefileGetNameCollisionInfo(namesInfo, config);
1162 if(node.GetIsExcluded(config))
1163 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
1167 ide.outputView.buildBox.Logf($"Deleteing intermediate objects for %s %s in project %s using the %s configuration...\n",
1168 node.type == file ? $"single file" : $"folder", node.name, project.name, config.name);
1170 ide.outputView.buildBox.Logf($"Deleteing intermediate objects for %s %s in project %s...\n",
1171 node.type == file ? $"single file" : $"folder", node.name, project.name);
1173 node.DeleteIntermediateFiles(compiler, config, bitDepth, namesInfo, false);
1185 bool ProjectNewFile(MenuItem selection, Modifiers mods)
1187 DataRow row = fileList.currentRow;
1190 char fileName[1024];
1191 char filePath[MAX_LOCATION];
1192 ProjectNode parentNode = (ProjectNode)row.tag;
1193 ProjectNode n, fileNode;
1194 parentNode.GetFileSysMatchingPath(filePath);
1195 MakePathRelative(filePath, parentNode.project.topNode.path, filePath);
1196 for(n = parentNode; n && n != parentNode.project.resNode; n = n.parent);
1197 sprintf(fileName, $"Untitled %d", documentID);
1198 fileNode = AddFile(parentNode, fileName, (bool)n, true);
1199 fileNode.path = CopyUnixPath(filePath);
1202 NodeProperties nodeProperties
1205 position = { position.x + 100, position.y + 100 };
1209 nodeProperties.Create(); // not modal?
1215 bool ProjectNewFolder(MenuItem selection, Modifiers mods)
1217 DataRow row = fileList.currentRow;
1220 ProjectNode parentNode = (ProjectNode)row.tag;
1221 NewFolder(parentNode, null, true);
1226 bool ResourcesAddFiles(MenuItem selection, Modifiers mods)
1232 bool ProjectAddFiles(MenuItem selection, Modifiers mods)
1238 bool ProjectImportFolder(MenuItem selection, Modifiers mods)
1240 DataRow row = fileList.currentRow;
1243 ProjectNode toNode = (ProjectNode)row.tag;
1244 ImportFolder(toNode);
1249 bool ProjectAddNewForm(MenuItem selection, Modifiers mods)
1251 CodeEditor codeEditor = CreateNew("Form", "form", "Window", null);
1252 codeEditor.EnsureUpToDate();
1256 bool ProjectAddNewGraph(MenuItem selection, Modifiers mods)
1258 CodeEditor codeEditor = CreateNew("Graph", "graph", "Block", null);
1260 codeEditor.EnsureUpToDate();
1264 bool ProjectRemove(MenuItem selection, Modifiers mods)
1266 DataRow row = fileList.currentRow;
1269 ProjectNode node = (ProjectNode)row.tag;
1270 if(node.type == project)
1271 RemoveSelectedNodes();
1276 bool ProjectUpdateMakefileForAllConfigs(Project project)
1278 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1280 // This call really does not belong here:
1281 ide.UpdateToolBarActiveConfigs(false);
1282 for(config : project.configurations)
1283 ProjectPrepareMakefile(project, forceExists, compiler, config);
1290 bool MenuSettings(MenuItem selection, Modifiers mods)
1292 ProjectNode node = GetSelectedNode(true);
1293 Project prj = node ? node.project : project;
1294 projectSettingsDialog = ProjectSettings { master = parent, project = prj, projectNode = node };
1295 incref projectSettingsDialog;
1296 projectSettingsDialog.Modal();
1297 delete projectSettingsDialog;
1298 ide.UpdateToolBarActiveConfigs(false);
1304 bool FileProperties(MenuItem selection, Modifiers mods)
1306 DataRow row = fileList.currentRow;
1309 ProjectNode node = (ProjectNode)row.tag;
1310 NodeProperties { parent = parent, master = this, node = node,
1311 position = { position.x + 100, position.y + 100 } }.Create();
1316 bool FileOpenFile(MenuItem selection, Modifiers mods)
1318 OpenSelectedNodes();
1322 bool FileRemoveFile(MenuItem selection, Modifiers mods)
1324 RemoveSelectedNodes();
1328 bool FileCompile(MenuItem selection, Modifiers mods)
1331 OldList selectedRows;
1332 Project project = null;
1333 List<ProjectNode> nodes { };
1334 fileList.GetMultiSelection(selectedRows);
1335 for(item = selectedRows.first; item; item = item.next)
1338 DataRow row = item.data;
1339 ProjectNode node = (ProjectNode)row.tag;
1341 project = node.project;
1342 else if(node.project != project)
1349 selectedRows.Free(null);
1351 Compile(project, nodes, mods.ctrl && mods.shift, normal);
1353 ide.outputView.buildBox.Logf($"Please select files from a single project.\n");
1358 bool FileClean(MenuItem selection, Modifiers mods)
1361 OldList selectedRows;
1362 Project project = null;
1363 List<ProjectNode> nodes { };
1364 fileList.GetMultiSelection(selectedRows);
1365 for(item = selectedRows.first; item; item = item.next)
1368 DataRow row = item.data;
1369 ProjectNode node = (ProjectNode)row.tag;
1371 project = node.project;
1372 else if(node.project != project)
1379 selectedRows.Free(null);
1381 Clean(project, nodes, mods.ctrl && mods.shift);
1383 ide.outputView.buildBox.Logf($"Please select files from a single project.\n");
1388 bool FileDebugPrecompile(MenuItem selection, Modifiers mods)
1390 DataRow row = fileList.currentRow;
1391 ProjectNode node = row ? (ProjectNode)row.tag : null;
1394 List<ProjectNode> nodes { };
1396 Compile(node.project, nodes, mods.ctrl && mods.shift, debugPrecompile);
1401 bool FileDebugCompile(MenuItem selection, Modifiers mods)
1403 DataRow row = fileList.currentRow;
1404 ProjectNode node = row ? (ProjectNode)row.tag : null;
1407 List<ProjectNode> nodes { };
1409 Compile(node.project, nodes, mods.ctrl && mods.shift, debugCompile);
1414 bool FileDebugGenerateSymbols(MenuItem selection, Modifiers mods)
1416 DataRow row = fileList.currentRow;
1417 ProjectNode node = row ? (ProjectNode)row.tag : null;
1420 List<ProjectNode> nodes { };
1422 Compile(node.project, nodes, mods.ctrl && mods.shift, debugGenerateSymbols);
1427 Project GetSelectedProject(bool useSelection)
1429 Project prj = project;
1432 DataRow row = fileList.currentRow;
1433 ProjectNode node = row ? (ProjectNode)row.tag : null;
1440 void SelectNextProject(bool backwards)
1442 DataRow row = fileList.currentRow;
1443 DataRow currentRow = row;
1444 ProjectNode node = (ProjectNode)row.tag;
1445 if(node.type != project)
1446 row = node.project.topNode.row;
1448 row = row.previous ? row.previous : fileList.lastRow;
1450 row = row.next ? row.next : fileList.firstRow;
1451 if(row && row != currentRow)
1453 fileList.SelectRow(row);
1454 fileList.currentRow = row;
1458 ProjectNode GetSelectedNode(bool useSelection)
1460 ProjectNode node = null;
1463 DataRow row = fileList.currentRow;
1465 node = (ProjectNode)row.tag;
1470 bool MenuBrowseFolder(MenuItem selection, Modifiers mods)
1472 char folder[MAX_LOCATION];
1474 ProjectNode node = GetSelectedNode(true);
1476 node = project.topNode;
1479 strcpy(folder, prj.topNode.path);
1480 if(node != prj.topNode)
1481 PathCatSlash(folder, node.path);
1486 bool Run(MenuItem selection, Modifiers mods)
1488 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1489 ProjectConfig config = project.config;
1490 int bitDepth = ide.workspace.bitDepth;
1491 String args = new char[maxPathLen];
1493 if(ide.workspace.commandLineArgs)
1494 //ide.debugger.GetCommandLineArgs(args);
1495 strcpy(args, ide.workspace.commandLineArgs);
1496 if(ide.debugger.isActive)
1497 project.Run(args, compiler, config, bitDepth);
1498 /*else if(config.targetType == sharedLibrary || config.targetType == staticLibrary)
1499 MessageBox { master = ide, type = ok, text = "Run", contents = "Shared and static libraries cannot be run like executables." }.Modal();*/
1500 else if(BuildInterrim(project, run, compiler, config, bitDepth, false))
1501 project.Run(args, compiler, config, bitDepth);
1509 bool result = false;
1510 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1511 ProjectConfig config = project.config;
1512 int bitDepth = ide.workspace.bitDepth;
1513 TargetTypes targetType = project.GetTargetType(config);
1514 if(targetType == sharedLibrary || targetType == staticLibrary)
1515 MessageBox { master = ide, type = ok, text = $"Run", contents = $"Shared and static libraries cannot be run like executables." }.Modal();
1516 else if(project.GetCompress(config))
1517 MessageBox { master = ide, text = $"Starting Debug", contents = $"Debugging compressed applications is not supported\n" }.Modal();
1518 else if(project.GetDebug(config) ||
1519 MessageBox { master = ide, type = okCancel, text = $"Starting Debug", contents = $"Attempting to debug non-debug configuration\nProceed anyways?" }.Modal() == ok)
1521 if(/*!IsProjectModified() ||*/ BuildInterrim(project, start, compiler, config, bitDepth, false))
1523 if(compiler.type.isVC)
1525 //bool result = false;
1526 char oldwd[MAX_LOCATION];
1527 PathBackup pathBackup { };
1528 char command[MAX_LOCATION];
1530 ide.SetPath(false, compiler, config, bitDepth);
1532 GetWorkingDir(oldwd, sizeof(oldwd));
1533 ChangeWorkingDir(project.topNode.path);
1535 sprintf(command, "%s /useenv %s.sln /projectconfig \"%s|Win32\" /command \"%s\"" , "devenv", project.name, config.name, "Debug.Start");
1537 ChangeWorkingDir(oldwd);
1543 ide.debugger.Start(compiler, config, bitDepth);
1552 void GoToError(const char * line)
1556 while(isspace(*line)) line++;
1557 colon = strstr(line, ":");
1562 bool lookForLineNumber = true;
1564 // deal with linking error
1565 if(colon && colon[1] == ' ')
1567 colon = strstr(colon + 1, ":");
1568 if(colon && !colon[1])
1570 colon = strstr(line, ":");
1571 lookForLineNumber = false;
1573 else if(colon && !isdigit(colon[1]))
1576 colon = strstr(line, ":");
1579 // Don't be mistaken by the drive letter colon
1580 if(colon && (colon[1] == '/' || colon[1] == '\\'))
1581 colon = strstr(colon + 1, ":");
1582 if(colon && lookForLineNumber)
1586 char * par = RSearchString(line, "(", colon - line, true, false);
1587 if(par && strstr(par, ")"))
1589 else if((colon+1)[0] == ' ')
1591 // NOTE: This is the same thing as saying 'colon = line'
1592 for( ; colon != line; colon--)
1596 lineNumber = atoi(colon + 1);
1598 comma = strchr(colon, ',');
1600 col = atoi(comma+1);
1602 comma = strchr(colon+1, ':');
1604 col = atoi(comma+1);
1608 char moduleName[MAX_LOCATION], filePath[MAX_LOCATION];
1612 char * inFileIncludedFrom = strstr(line, stringInFileIncludedFrom);
1613 char * start = inFileIncludedFrom ? line + strlen(stringInFileIncludedFrom) : line;
1614 int len = (int)(colon - start);
1615 len = Min(len, MAX_LOCATION-1);
1617 strncpy(moduleName, start, len);
1618 moduleName[len] = '\0';
1621 strcpy(moduleName, line);
1623 // Remove stuff in brackets
1625 bracket = strstr(moduleName, "(");
1626 if(bracket) *bracket = '\0';
1628 MakeSlashPath(moduleName);
1632 // Check if it's one of our modules
1633 ProjectNode node = project.topNode.Find(moduleName, false);
1636 strcpy(moduleName, node.path);
1637 PathCatSlash(moduleName, node.name);
1640 moduleName[0] = '\0';
1644 CodeEditor codeEditor;
1645 strcpy(filePath, project.topNode.path);
1646 PathCatSlash(filePath, moduleName);
1648 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
1651 char name[MAX_LOCATION];
1652 // TOFIX: Improve on this, don't use only filename, make a function
1653 if(ide && ide.workspace)
1655 for(prj : ide.workspace.projects)
1657 if(prj.topNode.FindWithPath(moduleName, false))
1659 strcpy(filePath, prj.topNode.path);
1660 PathCatSlash(filePath, moduleName);
1661 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
1668 if(codeEditor && lineNumber)
1670 EditBox editBox = codeEditor.editBox;
1671 editBox.GoToLineNum(lineNumber - 1);
1672 editBox.GoToPosition(editBox.line, lineNumber - 1, col ? (col - 1) : 0);
1679 bool OpenNode(ProjectNode node)
1681 char filePath[MAX_LOCATION];
1682 node.GetFullFilePath(filePath);
1683 return ide.OpenFile(filePath, normal, true/*false Why was it opening hidden?*/, null, something, normal) ? true : false;
1686 void AddNode(ProjectNode node, DataRow addTo)
1688 DataRow row = addTo ? addTo.AddRow() : fileList.AddRow();
1690 row.tag = (int64)node;
1693 if(node.type == resources)
1696 row.SetData(null, node);
1698 if(node.files && node.files.first && node.parent &&
1699 !(!node.parent.parent &&
1700 (!strcmpi(node.name, "notes") || !strcmpi(node.name, "sources") ||
1701 !strcmpi(node.name, "src") || !strcmpi(node.name, "tools"))))
1702 row.collapsed = true;
1703 else if(node.type == folder)
1704 node.icon = openFolder;
1708 for(child : node.files)
1709 AddNode(child, row);
1713 void DeleteNode(ProjectNode projectNode)
1715 if(projectNode.files)
1718 while(child = projectNode.files.first)
1721 fileList.DeleteRow(projectNode.row);
1722 projectNode.Delete();
1725 bool ProjectSave(MenuItem selection, Modifiers mods)
1727 DataRow row = fileList.currentRow;
1728 ProjectNode node = row ? (ProjectNode)row.tag : null;
1729 Project prj = node ? node.project : null;
1732 prj.StopMonitoring();
1733 if(prj.Save(prj.filePath))
1735 Project modPrj = null;
1736 prj.topNode.modified = false;
1737 for(p : ide.workspace.projects)
1739 if(p.topNode.modified)
1746 modifiedDocument = false;
1749 prj.StartMonitoring();
1754 bool ShowOutputBuildLog(bool cleanLog)
1756 OutputView output = ide.outputView;
1758 output.ShowClearSelectTab(build);
1761 output.SelectTab(build);
1769 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1770 ProjectConfig config = project.config;
1771 int bitDepth = ide.workspace.bitDepth;
1773 bool result = false;
1774 if(/*!IsProjectModified() ||*/ BuildInterrim(project, restart, compiler, config, bitDepth, false))
1776 // For Restart, compiler and config will only be used if for
1777 // whatever reason (if at all possible) the Debugger is in a
1778 // 'terminated' or 'none' state
1779 ide.debugger.Restart(compiler, config, bitDepth);
1789 ide.debugger.Resume();
1795 ide.debugger.Break();
1801 ide.debugger.Stop();
1805 bool DebugStepInto()
1807 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1808 ProjectConfig config = project.config;
1809 int bitDepth = ide.workspace.bitDepth;
1811 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config, bitDepth, false)))
1812 ide.debugger.StepInto(compiler, config, bitDepth);
1817 bool DebugStepOver(bool skip)
1819 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1820 ProjectConfig config = project.config;
1821 int bitDepth = ide.workspace.bitDepth;
1823 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config, bitDepth, false)))
1824 ide.debugger.StepOver(compiler, config, bitDepth, skip);
1830 bool DebugStepOut(bool skip)
1832 ide.debugger.StepOut(skip);
1836 void ImportFolder(ProjectNode toNode)
1840 //bool isFolder = toNode.type == folder;
1841 //bool isRes = toNode.isInResources;
1843 FileDialog fileDialog = importFileDialog;
1844 fileDialog.master = parent;
1845 if(fileDialog.Modal() == ok)
1847 ImportFolderFSI fsi { projectView = this };
1848 fsi.stack.Add(toNode);
1849 fsi.Iterate(fileDialog.filePath);
1855 ProjectNode NewFolder(ProjectNode parentNode, char * name, bool showProperties)
1859 ProjectNode folderNode;
1860 Project prj = parentNode.project;
1862 ProjectNode after = null;
1863 for(node : parentNode.files)
1865 if(node.type != folder)
1871 folderNode = parentNode.Add(prj, name, after, folder, folder, true);
1874 for(c = 0; c < 100; c++)
1877 sprintf(string, c ? "New Folder (%d)" : "New Folder", c);
1878 if((folderNode = parentNode.Add(prj, string, after, folder, folder, true)))
1885 NodeProperties nodeProperties;
1888 modifiedDocument = true;
1889 prj.topNode.modified = true;
1892 folderNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
1893 folderNode.row.tag = (int64)folderNode;
1895 folderNode.row.SetData(null, folderNode);
1896 fileList.currentRow = folderNode.row;
1900 nodeProperties = NodeProperties
1902 parent, this, mode = newFolder, node = folderNode;
1903 position = { position.x + 100, position.y + 100 };
1905 nodeProperties.Create(); // Modal?
1913 void AddFiles(bool resources)
1915 FileDialog fileDialog = (!resources) ? this.fileDialog : resourceFileDialog;
1916 fileDialog.type = multiOpen;
1917 fileDialog.text = !resources ? $"Add Files to Project" : $"Add Resources to Project";
1918 fileDialog.master = parent;
1920 if(fileDialog.Modal() == ok)
1923 DataRow row = fileList.currentRow;
1924 ProjectNode parentNode = (ProjectNode)row.tag;
1925 bool addFailed = false;
1926 int numSelections = fileDialog.numSelections;
1927 char ** multiFilePaths = fileDialog.multiFilePaths;
1929 Array<String> nameConflictFiles { };
1931 for(c = 0; c < numSelections; c++)
1933 char * filePath = multiFilePaths[c];
1934 FileAttribs exists = FileExists(filePath);
1935 bool addThisFile = true;
1937 if(exists.isDirectory)
1938 addThisFile = false;
1941 if(MessageBox { master = ide, type = yesNo, text = filePath,
1942 contents = $"File doesn't exist. Create?" }.Modal() == yes)
1944 File f = FileOpen(filePath, write);
1952 MessageBox { master = ide, type = ok, text = filePath,
1953 contents = $"Couldn't create file."}.Modal();
1954 addThisFile = false;
1961 /*addFailed = */if(!AddFile(parentNode, filePath, resources, false))//;
1963 nameConflictFiles.Add(CopyString(filePath));
1971 char * part1 = $"The following file";
1972 char * opt1 = $" was ";
1973 char * opt2 = $"s were ";
1974 char * part2 = $"not added because of identical file name conflict within the project.\n\n";
1976 len += strlen(part1);
1977 len += strlen(part2);
1978 len += nameConflictFiles.count > 1 ? strlen(opt2) : strlen(opt1);
1979 for(s : nameConflictFiles)
1980 len += strlen(s) + 1;
1981 message = new char[len + 1];
1982 strcpy(message, part1);
1983 strcat(message, nameConflictFiles.count > 1 ? opt2 : opt1);
1984 strcat(message, part2);
1985 for(s : nameConflictFiles)
1988 strcat(message, "\n");
1990 MessageBox { master = ide, type = ok, text = $"Name Conflict",
1991 contents = message }.Modal();
1994 nameConflictFiles.Free();
1995 delete nameConflictFiles;
1999 ProjectNode AddFile(ProjectNode parentNode, char * filePath, bool resources, bool isTemporary)
2001 ProjectNode result = null;
2002 ProjectNode after = null;
2003 for(node : parentNode.files)
2005 if(node.type != folder && node.type != file && node.type)
2010 result = parentNode.Add(parentNode.project, filePath, after, file, NodeIcons::SelectFileIcon(filePath), !resources);
2016 modifiedDocument = true;
2017 parentNode.project.topNode.modified = true;
2018 parentNode.project.ModifiedAllConfigs(true, false, true, true);
2021 result.row = parentNode.row.AddRowAfter(after ? after.row : null);
2022 result.row.tag = (int64)result;
2023 result.row.SetData(null, result);
2028 CodeEditor CreateNew(char * upper, char * lower, char * base, char * className)
2030 CodeEditor codeEditor = null;
2031 ProjectNode projectNode;
2032 ProjectNode after = null;
2033 DataRow row = fileList.currentRow;
2034 ProjectNode parentNode;
2037 if(!row) row = project.topNode.row;
2039 parentNode = (ProjectNode)row.tag;
2041 for(node : parentNode.files)
2043 if(node.type != folder && node.type != file && node.type)
2047 for(c = 1; c < 100; c++)
2050 sprintf(string, c ? "%s%d.ec" : "%s.ec", lower, c);
2051 if((projectNode = parentNode.Add(project, string, after, file, genFile, true)))
2057 char filePath[MAX_LOCATION];
2059 modifiedDocument = true;
2060 project.topNode.modified = true;
2062 project.ModifiedAllConfigs(true, false, false, true);
2063 projectNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
2064 projectNode.row.tag =(int64)projectNode;
2066 projectNode.row.SetData(null, projectNode);
2067 fileList.currentRow = projectNode.row;
2069 strcpy(filePath, project.topNode.path);
2070 PathCat(filePath, projectNode.path);
2071 PathCat(filePath, projectNode.name);
2073 codeEditor = (CodeEditor)ide.FindWindow(filePath);
2076 Class baseClass = eSystem_FindClass(__thisModule, base);
2077 subclass(ClassDesignerBase) designerClass = eClass_GetDesigner(baseClass);
2080 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal);
2081 strcpy(name, projectNode.name);
2082 sprintf(name, "%s%d", upper, c);
2084 strcpy(className, name);
2086 designerClass.CreateNew(codeEditor.editBox, codeEditor.clientSize, name, base);
2088 //codeEditor.modifiedDocument = false;
2089 //codeEditor.designer.modifiedDocument = false;
2091 //Code_EnsureUpToDate(codeEditor);
2094 else // TODO: fix no symbols generated when ommiting {} for following else
2096 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal);
2100 codeEditor.ViewDesigner();
2101 codeEditor.codeModified = true;
2108 // Returns true if we opened something
2109 bool OpenSelectedNodes()
2111 bool result = false;
2115 fileList.GetMultiSelection(selection);
2116 for(item = selection.first; item; item = item.next)
2118 DataRow row = item.data;
2119 ProjectNode node = (ProjectNode)row.tag;
2120 if(node.type == file)
2127 selection.Free(null);
2131 void RemoveSelectedNodes()
2136 fileList.GetMultiSelection(selection);
2138 // Remove children of parents we're deleting
2139 for(item = selection.first; item; item = next)
2142 DataRow row = item.data;
2143 ProjectNode n, node = (ProjectNode)row.tag;
2144 bool remove = false;
2147 for(i = selection.first; i && !remove; i = i.next)
2149 ProjectNode iNode = (ProjectNode)((DataRow)i.data).tag;
2150 for(n = node.parent; n; n = n.parent)
2160 selection.Delete(item);
2163 for(item = selection.first; item; item = item.next)
2165 DataRow row = item.data;
2166 ProjectNode node = (ProjectNode)row.tag;
2167 ProjectNode resNode;
2168 for(resNode = node.parent; resNode; resNode = resNode.parent)
2169 if(resNode.type == resources)
2171 if(node.type == file)
2173 Project prj = node.project;
2175 modifiedDocument = true;
2176 prj.topNode.modified = true;
2178 prj.ModifiedAllConfigs(true, false, true, true);
2180 else if(node.type == folder)
2183 sprintf(message, $"Are you sure you want to remove the folder \"%s\"\n"
2184 "and all of its contents from the project?", node.name);
2185 if(MessageBox { master = ide, type = yesNo, text = $"Delete Folder", contents = message }.Modal() == yes)
2187 Project prj = node.project;
2188 if(node.containsFile)
2189 prj.ModifiedAllConfigs(true, false, true, true);
2191 modifiedDocument = true;
2192 prj.topNode.modified = true;
2195 else if(node.type == project && node != project.topNode && !buildInProgress)
2199 for(p : workspace.projects)
2201 if(p.topNode == node)
2207 sprintf(message, $"Are you sure you want to remove the \"%s\" project\n" "from this workspace?", node.name);
2208 if(MessageBox { master = ide, type = yesNo, text = $"Remove Project", contents = message }.Modal() == yes)
2213 workspace.RemoveProject(prj);
2214 //modifiedDocument = true; // when project view is a workspace view
2218 selection.Free(null);