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 if(!projectView.AddFile(parentNode, filePath, parentNode.isInResources, false))
33 char * msg = PrintString($"This file can't be imported due to a conflict.\n\n", filePath,
34 "\n\nThis occurs with identical file paths and with conflicting file names.\n");
35 MessageBox { master = ide, type = ok, text = "Import File Conflict", contents = msg }.Modal();
42 static Array<FileFilter> fileFilters
44 { $"eC/C/C++ Files (*.ec, *.eh, *.c, *.cpp, *.cc, *.cxx, *.h, *.hpp, *.hh, *.hxx)", "ec, eh, c, cpp, cc, cxx, h, hpp, hh, hxx" },
45 { $"eC/C/C++ Source Files (*.ec, *.c, *.cpp, *.cc, *.cxx)", "ec, eh, c, cpp, cc, cxx" },
46 { $"Header Files for eC/C/C++ (*.eh, *.h, *.hpp, *.hh, *.hxx)", "eh, h, hpp, hh, hxx" },
47 { $"All files", null }
50 static Array<FileFilter> resourceFilters
52 { $"Image Files (*.jpg, *.jpeg, *.bmp, *.pcx, *.png,*.gif)", "jpg, jpeg, bmp, pcx, png, gif" },
53 { $"3D Studio Model Files (*.3ds)", "3ds" },
54 { $"Translations (*.mo)", "mo" },
55 { $"All files", null }
58 static Array<FileFilter> projectFilters
60 { $"Project Files (*.epj)", ProjectExtension },
61 { $"Workspace Files (*.ews)", WorkspaceExtension }
64 static Array<FileType> projectTypes
66 { $"Ecere IDE Project", ProjectExtension },
67 { $"Ecere IDE Workspace", WorkspaceExtension }
70 static char * iconNames[] =
72 "<:ecere>mimeTypes/file.png", /*genFile*/
73 "<:ecere>mimeTypes/textEcereWorkspace.png", /*ewsFile*/
74 "<:ecere>mimeTypes/textEcereProject.png", /*epjFile*/
75 "<:ecere>places/folder.png", /*folder*/
76 "<:ecere>status/folderOpen.png", /*openFolder*/
77 "<:ecere>mimeTypes/textEcereSource.png", /*ecFile*/
78 "<:ecere>mimeTypes/textEcereHeader.png", /*ehFile*/
79 "<:ecere>mimeTypes/textCSource.png", /*sFile*/ // TODO: change sFile icon to differentiate from cFile icon
80 "<:ecere>mimeTypes/textCSource.png", /*cFile*/
81 "<:ecere>mimeTypes/textCHeader.png", /*hFile*/
82 "<:ecere>mimeTypes/textC++Source.png", /*cppFile*/
83 "<:ecere>mimeTypes/textC++Header.png", /*hppFile*/
84 "<:ecere>mimeTypes/text.png", /*textFile*/
85 "<:ecere>mimeTypes/textHyperTextMarkup.png", /*webFile*/
86 "<:ecere>mimeTypes/image.png", /*pictureFile*/
87 "<:ecere>status/audioVolumeHigh.png", /*soundFile*/
88 "<:ecere>mimeTypes/package.png", /*archiveFile*/
89 "<:ecere>mimeTypes/packageSoftware.png", /*packageFile*/
90 "<:ecere>mimeTypes/packageOpticalDisc.png", /*opticalMediaImageFile*/
91 "<:ecere>mimeTypes/file.png", /*mFile*/ //TODO: create icon for .m file
92 "<:ecere>mimeTypes/file.png" /*mmFile*/ //TODO: create icon for .mm file
95 enum PrepareMakefileMethod { normal, force, forceExists };
97 enum CleanType { clean, realClean, cleanTarget };
98 enum BuildType { build, rebuild, relink, run, start, restart, clean };
101 none, buildingMainProject, buildingSecondaryProject, compilingFile;
103 property bool { get { return this != none; } }
104 //property bool actualBuild { get { return this == buildingMainProject || this == buildingSecondaryProject; } }
107 class ProjectView : Window
110 //hasMinimize = true;
112 borderStyle = sizable;
113 hasHorzScroll = true;
114 hasVertScroll = true;
117 anchor = Anchor { left = 0, top = 0, bottom = 0 };
120 //hasMinimize = true;
121 saveDialog = projectFileDialog;
124 BuildState buildInProgress;
125 BitmapResource icons[NodeIcons];
128 property Workspace workspace
134 for(prj : workspace.projects)
136 DeleteNode(prj.topNode);
138 workspace.projects.Free();
139 ide.debugger.CleanUp();
144 fileDialog.currentDirectory = workspace.workspaceDir;
145 resourceFileDialog.currentDirectory = workspace.workspaceDir;
146 for(prj : workspace.projects)
147 AddNode(prj.topNode, null);
148 ide.statusBar.text = $"Generating Makefile & Dependencies...";
150 for(prj : workspace.projects)
151 prj.ModifiedAllConfigs(true, false, false, false);
152 ide.statusBar.text = $"Initializing Debugger"; app.UpdateDisplay();
153 ide.statusBar.text = null;
157 get { return workspace; }
160 bool drawingInProjectSettingsDialog;
161 bool drawingInProjectSettingsDialogHeader;
162 ProjectSettings projectSettingsDialog;
170 for(c = 0; c < NodeIcons::enumSize; c++)
172 icons[c] = BitmapResource { iconNames[c], alphaBlend = true };
173 AddResource(icons[c]);
175 fileList.AddField(DataField { dataType = class(ProjectNode), freeData = false, userData = this });
181 ide.DestroyTemporaryProjectDir();
191 multiSelect = true, fullRowSelect = false, hasVertScroll = true, hasHorzScroll = true;
192 borderStyle = deep, parent = this, collapseControl = true, treeBranches = true;
193 anchor = Anchor { left = 0, right = 0, top = 0 , bottom = 0 };
195 background = projectViewBackground;
196 foreground = projectViewText;
197 selectionColor = selectionColor, selectionText = selectionText;
198 stippleColor = skyBlue;
200 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
202 if(!active) Update(null);
203 return ListBox::OnActivate(active, previous, goOnWithActivation, direct);
206 bool NotifyDoubleClick(ListBox listBox, int x, int y, Modifiers mods)
208 // Prevent the double click from reactivating the project view (returns false if we opened something)
209 return !OpenSelectedNodes(mods.ctrl && mods.shift);
212 bool NotifyRightClick(ListBox listBox, int x, int y, Modifiers mods)
214 DataRow row = listBox.currentRow;
217 bool showDebuggingMenuItems = mods.ctrl && mods.shift;
218 ProjectNode node = (ProjectNode)row.tag;
219 if(node.type == NodeTypes::project || node.type == resources || node.type == file || node.type == folder)
221 bool na = buildInProgress; // N/A - buildMenuUnavailable
224 if(node.type == NodeTypes::project)
227 mi = ide.projectBuildItem;
228 MenuItem { pop, $"Build" , b, f7 , NotifySelect = ProjectBuild , bitmap = mi.bitmap }.disabled = na; mi = ide.projectLinkItem;
229 MenuItem { pop, $"Relink" , l , NotifySelect = ProjectLink , bitmap = mi.bitmap }.disabled = na; mi = ide.projectRebuildItem;
230 MenuItem { pop, $"Rebuild" , r, shiftF7, NotifySelect = ProjectRebuild , bitmap = mi.bitmap }.disabled = na; mi = ide.projectCleanTargetItem;
231 MenuItem { pop, $"Clean Target" , g , NotifySelect = ProjectCleanTarget, bitmap = mi.bitmap }.disabled = na; mi = ide.projectCleanItem;
232 MenuItem { pop, $"Clean" , c , NotifySelect = ProjectClean , bitmap = mi.bitmap }.disabled = na; mi = ide.projectRealCleanItem;
233 MenuItem { pop, $"Real Clean" , NotifySelect = ProjectRealClean , bitmap = mi.bitmap }.disabled = na; mi = ide.projectRegenerateItem;
234 MenuItem { pop, $"Regenerate Makefile", m , NotifySelect = ProjectRegenerate , bitmap = mi.bitmap }.disabled = na;
236 if(showDebuggingMenuItems && node.ContainsFilesWithExtension("ec"))
239 MenuItem { pop, $"Debug Generate Symbols", l, NotifySelect = FileDebugGenerateSymbols }.disabled = na;
240 MenuItem { pop, $"Debug Precompile", l, NotifySelect = FileDebugPrecompile }.disabled = na;
241 MenuItem { pop, $"Debug Compile", l, NotifySelect = FileDebugCompile }.disabled = na;
244 MenuItem { pop, $"New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
245 MenuItem { pop, $"New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
246 MenuItem { pop, $"Import Folder...", i, NotifySelect = ProjectImportFolder };
247 MenuItem { pop, $"Add Files to Project...", f, NotifySelect = ProjectAddFiles };
249 MenuItem { pop, $"Add New Form...", o, NotifySelect = ProjectAddNewForm };
250 // MenuItem { pop, "Add New Behavior Graph...", g, NotifySelect = ProjectAddNewGraph };
252 if(node != ((Project)workspace.projects.first).topNode)
254 MenuItem { pop, $"Remove project from workspace", r, NotifySelect = ProjectRemove }.disabled = na;
257 MenuItem { pop, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
259 MenuItem { pop, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
261 MenuItem { pop, $"Save", v, Key { s, ctrl = true }, NotifySelect = ProjectSave }.disabled = !node.modified;
263 MenuItem { pop, $"Properties...", p, Key { enter, alt = true }, NotifySelect = FileProperties };
265 else if(node.type == resources)
267 MenuItem { pop, $"New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
268 MenuItem { pop, $"New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
269 MenuItem { pop, $"Import Folder...", i, NotifySelect = ProjectImportFolder };
270 MenuItem { pop, $"Add Resources to Project...", f, NotifySelect = ResourcesAddFiles };
271 MenuItem { pop, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
273 MenuItem { pop, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
274 MenuItem { pop, $"Properties...", p, Key { enter, alt = true }, NotifySelect = FileProperties };
276 else if(node.type == file)
278 MenuItem { pop, $"Open", o, NotifySelect = FileOpenFile };
280 MenuItem { pop, $"Clean", l, NotifySelect = FileClean, bitmap = ide.projectCleanItem.bitmap }.disabled = na;
281 MenuItem { pop, $"Compile", c, Key { f7, ctrl = true}, NotifySelect = FileCompile, bitmap = ide.projectBuildItem.bitmap }.disabled = na;
282 if(showDebuggingMenuItems)
284 char extension[MAX_EXTENSION];
285 GetExtension(node.name, extension);
286 if(!strcmpi(extension, "ec"))
289 MenuItem { pop, $"Debug Precompile", l, NotifySelect = FileDebugPrecompile }.disabled = na;
290 MenuItem { pop, $"Debug Compile", l, NotifySelect = FileDebugCompile }.disabled = na;
294 MenuItem { pop, $"Remove", r, NotifySelect = FileRemoveFile };
296 MenuItem { pop, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
298 MenuItem { pop, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
299 MenuItem { pop, $"Properties..", p, Key { enter, alt = true }, NotifySelect = FileProperties };
301 else if(node.type == folder)
303 bool isInResources = node.isInResources;
305 MenuItem { pop, $"New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
306 MenuItem { pop, $"New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
307 MenuItem { pop, $"Import Folder...", i, NotifySelect = ProjectImportFolder };
310 MenuItem { pop, $"Add Resources to Folder...", f, NotifySelect = ResourcesAddFiles };
314 MenuItem { pop, $"Add Files to Folder...", f, NotifySelect = ProjectAddFiles };
319 MenuItem { pop, $"Add New Form...", o, NotifySelect = ProjectAddNewForm };
320 // MenuItem { pop, $"Add New Behavior Graph...", g, NotifySelect = ProjectAddNewGraph };
323 MenuItem { pop, $"Clean", l, NotifySelect = FileClean, bitmap = ide.projectCleanItem.bitmap }.disabled = na;
324 MenuItem { pop, $"Compile", c, Key { f7, ctrl = true}, NotifySelect = FileCompile, bitmap = ide.projectBuildItem.bitmap }.disabled = na;
326 MenuItem { pop, $"Remove", r, NotifySelect = FileRemoveFile };
328 MenuItem { pop, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
330 MenuItem { pop, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
331 MenuItem { pop, $"Properties...", p, Key { enter, alt = true }, NotifySelect = FileProperties };
336 master = this, menu = pop;
338 x + clientStart.x + absPosition.x - app.desktop.position.x,
339 y + clientStart.y + absPosition.y - app.desktop.position.y };
341 void NotifyDestroyed(Window window, DialogResult result)
347 ide.AdjustPopupBuildMenus();
353 bool NotifyKeyHit(ListBox listBox, DataRow row, Key key, unichar ch)
355 if(key == altUp || key == altDown)
357 SelectNextProject(key == altUp);
363 bool NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch)
367 ProjectNode node = (ProjectNode)row.tag;
370 case altEnter: case Key { keyPadEnter, alt = true }:
372 NodeProperties { parent = parent, master = this,
373 position = { position.x + 100, position.y + 100 }, node = node }.Create();
376 case enter: case keyPadEnter:
379 for(resNode = node.parent; resNode; resNode = resNode.parent)
380 if(resNode.type == resources)
382 if(node.type == project || (node.type == folder && !resNode))
387 else if(node.type == resources || node.type == folder)
396 if(node.type == project || node.type == folder || node.type == resources)
405 if(node.type == project || node.type == folder || node.type == resources)
407 NewFolder(node, null, true);
414 if(node.type == file)
416 FileCompile(null, (Modifiers)key);
421 case Key { space, shift = true }:
424 if(node.type == NodeTypes::project)
427 for(p : workspace.projects)
429 if(p.topNode == node)
435 prj.RotateActiveConfig(!key.shift);
446 case Key { enter, true, true }: OpenSelectedNodes(true); break;
447 case Key { keyPadEnter, true, true }: OpenSelectedNodes(true); break;
448 case enter: case keyPadEnter: OpenSelectedNodes(false); break;
449 case del: RemoveSelectedNodes(); break;
452 Window activeClient = ide.activeClient;
454 activeClient.Activate();
456 ide.RepositionWindows(true);
463 bool NotifyCollapse(ListBox listBox, DataRow row, bool collapsed)
465 ProjectNode node = (ProjectNode)row.tag;
466 if(node.type == folder)
467 node.icon = collapsed ? folder : openFolder;
472 FileDialog importFileDialog { autoCreate = false, type = selectDir, text = $"Import Folder" };
473 FileDialog projectFileDialog
475 autoCreate = false, filters = projectFilters.array, sizeFilters = projectFilters.count * sizeof(FileFilter);
476 types = projectTypes.array, sizeTypes = projectTypes.count * sizeof(FileType);
478 FileDialog fileDialog
480 autoCreate = false, mayNotExist = true, filters = fileFilters.array, sizeFilters = fileFilters.count * sizeof(FileFilter);
482 FileDialog resourceFileDialog
484 autoCreate = false, mayNotExist = true, filters = resourceFilters.array, sizeFilters = resourceFilters.count * sizeof(FileFilter);
487 Menu fileMenu { menu, $"File", f };
488 MenuItem { fileMenu, $"Save", s, Key { s, ctrl = true }, NotifySelect = MenuFileSave };
489 // MenuItem { fileMenu, "Save As...", a, NotifySelect = MenuFileSaveAs };
491 bool OnClose(bool parentClosing)
493 if(!parentClosing && visible)
503 DialogResult dialogRes;
506 strcpy(msg, $"You have modified projects.\nSave changes to ");
507 for(p : ide.workspace.projects)
509 if(p.topNode.modified)
511 if(!first) strcat(msg, ", ");
518 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = msg }.Modal();
522 // TOFIX: Precomp error if brackets are taken out
523 return (DialogResult)MenuFileSave(null, 0) != cancel;
525 else if(dialogRes == cancel)
527 modifiedDocument = false;
534 //if(ide.findInFilesDialog && ide.findInFilesDialog.created && ide.findInFilesDialog.mode != directory)
535 // ide.findInFilesDialog.SearchStop();
537 ide.outputView.buildBox.Clear();
538 ide.outputView.debugBox.Clear();
539 //ide.outputView.findBox.Clear();
540 ide.callStackView.Clear();
541 ide.watchesView.Clear();
542 ide.threadsView.Clear();
543 ide.breakpointsView.Clear();
544 ide.outputView.ShowClearSelectTab(find); // why this?
547 bool OnSaveFile(char * fileName)
549 for(prj : ide.workspace.projects)
551 if(prj.topNode.modified)
553 prj.StopMonitoring();
554 if(prj.Save(prj.filePath))
555 prj.topNode.modified = false;
556 prj.StartMonitoring();
559 modifiedDocument = false;
564 bool IsModuleInProject(char * filePath)
566 char moduleName[MAX_FILENAME]; //, modulePath[MAX_LOCATION];
567 GetLastDirectory(filePath, moduleName);
568 return project.topNode.Find(moduleName, false) != null;
571 bool GetRelativePath(char * filePath, char * relativePath)
573 return project.GetRelativePath(filePath, relativePath);
576 ProjectNode GetNodeFromWindow(Window document, Project project, bool isCObject)
578 if(document.fileName)
580 char winFileName[MAX_LOCATION];
581 char * documentFileName = GetSlashPathBuffer(winFileName, document.fileName);
586 char name[MAX_FILENAME];
587 GetLastDirectory(documentFileName, name);
588 ChangeExtension(name, "ec", name);
589 for(p : ide.workspace.projects)
591 prj = project ? project : p;
592 if((node = prj.topNode.Find(name, false)))
599 for(p : ide.workspace.projects)
601 prj = project ? project : p;
602 if((node = prj.topNode.FindByFullPath(documentFileName, false)))
611 // ((( UTILITY FUNCTIONS )))
613 // ************************************************************************
614 // *** These methods below are part of a sequence of events, and as ***
615 // *** such they must be passed the current compiler and project config ***
616 // ************************************************************************
617 bool DisplayCompiler(CompilerConfig compiler, bool cleanLog)
619 ide.outputView.buildBox.Logf($"%s Compiler\n", compiler ? compiler.name : $"{problem with compiler selection}");
623 bool ProjectPrepareForToolchain(Project project, PrepareMakefileMethod method, bool cleanLog, bool displayCompiler,
624 CompilerConfig compiler, ProjectConfig config)
627 char message[MAX_F_STRING];
628 LogBox logBox = ide.outputView.buildBox;
630 ShowOutputBuildLog(cleanLog);
633 DisplayCompiler(compiler, false);
635 ProjectPrepareCompiler(project, compiler, false);
636 ProjectPrepareMakefile(project, method, compiler, config);
640 bool ProjectPrepareCompiler(Project project, CompilerConfig compiler, bool silent)
642 if((!project.GenerateCrossPlatformMk(app.includeFile) || !project.GenerateCompilerCf(compiler)) && !silent)
643 ide.outputView.buildBox.Logf($"Error generating compiler configuration (Is the project/config directory writable?)\n");
647 // Note: Compiler is only passed in to for VisualStudio support
648 bool ProjectPrepareMakefile(Project project, PrepareMakefileMethod method, CompilerConfig compiler, ProjectConfig config)
650 if(compiler.type.isVC)
652 // I'm guessing we'll want to support generating VS files on Linux as well...
653 ide.statusBar.text = $"Generating Visual Studio Solution...";
655 //GenerateVSSolutionFile(project, compiler);
656 ide.statusBar.text = $"Generating Visual Studio Project...";
658 //GenerateVCProjectFile(project, compiler, bitDepth);
659 ide.statusBar.text = null;
665 char makefilePath[MAX_LOCATION];
666 char makefileName[MAX_LOCATION];
668 LogBox logBox = ide.outputView.buildBox;
670 strcpy(makefilePath, project.topNode.path);
671 project.CatMakeFileName(makefileName, config);
672 PathCatSlash(makefilePath, makefileName);
674 exists = FileExists(makefilePath);
675 if(method == force ||
676 (method == forceExists && exists) ||
677 (method == normal && (!exists || (config && config.makingModified))))
681 ide.statusBar.text = $"Generating Makefile & Dependencies..."; // Dependencies?
684 if((method == normal && !exists) || (method == force && !exists))
685 action = $"Generating ";
686 else if(method == force)
687 action = $"Regenerating ";
688 else if(method == normal || method == forceExists)
689 action = $"Updating ";
693 reason = $"Makefile doesn't exist. ";
694 else if(project.topNode.modified)
695 reason = $"Project has been modified. ";
699 //logBox.Logf("%s\n", makefileName);
700 logBox.Logf($"%s - %s%smakefile for %s config...\n", makefileName, reason, action, GetConfigName(config));
702 if(!project.GenerateMakefile(null, false, null, config))
703 ide.outputView.buildBox.Logf($"Error generating makefile (Is the project directory writable?)\n");
705 ide.statusBar.text = null;
713 bool BuildInterrim(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config, int bitDepth, bool justPrint)
715 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
717 ide.outputView.buildBox.Logf($"Building project %s using the %s configuration...\n", prj.name, GetConfigName(config));
718 return Build(prj, buildType, compiler, config, bitDepth, justPrint);
723 bool DebugStopForMake(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config)
726 // TOFIX: DebugStop is being abused and backfiring on us.
727 // It's supposed to be the 'Debug/Stop' item, not unloading executable or anything else
729 // configIsInDebugSession seems to be used for two OPPOSITE things:
730 // If we're debugging another config, we need to unload the executable!
731 // In building, we want to stop if we're debugging the 'same' executable
732 if(buildType != run) ///* && prj == project*/ && prj.configIsInDebugSession)
734 if(buildType == start || buildType == restart)
736 if(ide.debugger && ide.debugger.isPrepared)
737 result = DebugStop();
741 if(ide.project == prj && ide.debugger && ide.debugger.prjConfig == config && ide.debugger.isPrepared)
742 result = DebugStop();
748 bool Build(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config, int bitDepth, bool justPrint)
754 for(document = master.firstChild; document; document = document.next)
756 if(document.modifiedDocument)
758 ProjectNode node = GetNodeFromWindow(document, prj, false);
759 if(node && !document.MenuFileSave(null, 0))
768 DirExpression targetDir = prj.GetTargetDir(compiler, config, bitDepth);
770 DebugStopForMake(prj, buildType, compiler, config);
772 // TODO: Disabled until problems fixed... is it fixed?
773 if(buildType == rebuild || (config && config.compilingModified))
774 prj.Clean(compiler, config, bitDepth, clean, justPrint);
777 if(buildType == relink || (config && config.linkingModified))
778 prj.Clean(compiler, config, bitDepth, cleanTarget, false);
779 if(config && config.symbolGenModified)
781 DirExpression objDir = prj.GetObjDir(compiler, config, bitDepth);
782 char fileName[MAX_LOCATION];
783 char moduleName[MAX_FILENAME];
784 strcpy(fileName, prj.topNode.path);
785 PathCatSlash(fileName, objDir.dir);
786 strcpy(moduleName, prj.moduleName);
787 strcat(moduleName, ".main.ec");
788 PathCatSlash(fileName, moduleName);
789 if(FileExists(fileName))
790 DeleteFile(fileName);
791 ChangeExtension(fileName, "c", fileName);
792 if(FileExists(fileName))
793 DeleteFile(fileName);
794 ChangeExtension(fileName, "o", fileName);
795 if(FileExists(fileName))
796 DeleteFile(fileName);
801 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
802 ide.AdjustBuildMenus();
803 ide.AdjustDebugMenus();
805 result = prj.Build(buildType == run, null, compiler, config, bitDepth, justPrint, normal);
809 config.compilingModified = false;
811 config.linkingModified = false;
813 config.symbolGenModified = false;
815 buildInProgress = none;
816 ide.AdjustBuildMenus();
817 ide.AdjustDebugMenus();
819 ide.workspace.modified = true;
826 // ((( USER ACTIONS )))
828 // ************************************************************************
829 // *** Methods below should atomically start a process, and as such ***
830 // *** they can query compiler and config directly from ide and project ***
831 // *** but ONLY ONCE!!! ***
832 // ************************************************************************
834 bool ProjectBuild(MenuItem selection, Modifiers mods)
836 if(buildInProgress == none)
838 Project prj = project;
839 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
840 int bitDepth = ide.workspace.bitDepth;
841 ProjectConfig config;
842 if(selection || !ide.activeClient)
844 DataRow row = fileList.currentRow;
845 ProjectNode node = row ? (ProjectNode)row.tag : null;
846 if(node) prj = node.project;
850 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
855 if(/*prj != project || */!prj.GetConfigIsInDebugSession(config) || !ide.DontTerminateDebugSession($"Project Build"))
857 BuildInterrim(prj, build, compiler, config, bitDepth, mods.ctrl && mods.shift);
866 bool ProjectLink(MenuItem selection, Modifiers mods)
868 Project prj = project;
869 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
870 int bitDepth = ide.workspace.bitDepth;
871 ProjectConfig config;
872 if(selection || !ide.activeClient)
874 DataRow row = fileList.currentRow;
875 ProjectNode node = row ? (ProjectNode)row.tag : null;
876 if(node) prj = node.project;
880 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
885 if(!prj.GetConfigIsInDebugSession(config) ||
886 (!ide.DontTerminateDebugSession($"Project Link") && DebugStopForMake(prj, relink, compiler, config)))
888 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
890 ide.outputView.buildBox.Logf($"Relinking project %s using the %s configuration...\n", prj.name, GetConfigName(config));
892 config.linkingModified = true;
893 Build(prj, relink, compiler, config, bitDepth, mods.ctrl && mods.shift);
900 bool ProjectRebuild(MenuItem selection, Modifiers mods)
902 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
903 int bitDepth = ide.workspace.bitDepth;
904 Project prj = project;
905 ProjectConfig config;
906 if(selection || !ide.activeClient)
908 DataRow row = fileList.currentRow;
909 ProjectNode node = row ? (ProjectNode)row.tag : null;
910 if(node) prj = node.project;
914 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
919 if(!prj.GetConfigIsInDebugSession(config) ||
920 (!ide.DontTerminateDebugSession($"Project Rebuild") && DebugStopForMake(prj, rebuild, compiler, config)))
922 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
924 ide.outputView.buildBox.Logf($"Rebuilding project %s using the %s configuration...\n", prj.name, GetConfigName(config));
927 config.compilingModified = true;
928 config.makingModified = true;
929 }*/ // -- should this still be used depite the new solution of BuildType?
930 Build(prj, rebuild, compiler, config, bitDepth, mods.ctrl && mods.shift);
937 bool ProjectCleanTarget(MenuItem selection, Modifiers mods)
939 CleanProject($"Project Clean Target", $"Cleaning project %s target using the %s configuration...\n", selection, cleanTarget, mods.ctrl && mods.shift);
943 bool ProjectClean(MenuItem selection, Modifiers mods)
945 CleanProject($"Project Clean", $"Cleaning project %s using the %s configuration...\n", selection, clean, mods.ctrl && mods.shift);
949 bool ProjectRealClean(MenuItem selection, Modifiers mods)
951 CleanProject($"Project Real Clean", $"Removing intermediate objects directory for project %s using the %s configuration...\n", selection, realClean, mods.ctrl && mods.shift);
955 void CleanProject(char * terminateDebugSessionMessage, char * cleaningMessageLogFormat, MenuItem selection, CleanType cleanType, bool justPrint)
957 Project prj = project;
958 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
959 ProjectConfig config;
960 int bitDepth = ide.workspace.bitDepth;
961 if(selection || !ide.activeClient)
963 DataRow row = fileList.currentRow;
964 ProjectNode node = row ? (ProjectNode)row.tag : null;
965 if(node) prj = node.project;
969 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
970 if(node) prj = node.project;
973 if(!prj.GetConfigIsInDebugSession(config) ||
974 (!ide.DontTerminateDebugSession(terminateDebugSessionMessage) && DebugStopForMake(prj, clean, compiler, config)))
976 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
978 ide.outputView.buildBox.Logf(cleaningMessageLogFormat, prj.name, GetConfigName(config));
980 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
981 ide.AdjustBuildMenus();
982 ide.AdjustDebugMenus();
984 prj.Clean(compiler, config, bitDepth, cleanType, justPrint);
985 buildInProgress = none;
986 ide.AdjustBuildMenus();
987 ide.AdjustDebugMenus();
993 bool ProjectRegenerate(MenuItem selection, Modifiers mods)
995 Project prj = project;
996 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
997 ShowOutputBuildLog(true);
998 if(selection || !ide.activeClient)
1000 DataRow row = fileList.currentRow;
1001 ProjectNode node = row ? (ProjectNode)row.tag : null;
1007 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
1012 DisplayCompiler(compiler, false);
1013 ProjectPrepareCompiler(project, compiler, false);
1014 ProjectPrepareMakefile(prj, force, compiler, prj.config);
1019 bool Compile(Project project, List<ProjectNode> nodes, bool justPrint, SingleFileCompileMode mode)
1022 char fileName[MAX_LOCATION];
1024 ProjectConfig config = project.config;
1028 for(document = ide.firstChild; document; document = document.next)
1030 if(document.modifiedDocument)
1032 ProjectNode n = GetNodeFromWindow(document, project, mode == cObject ? true : false);
1035 if(n && n.IsInNode(node) && !document.MenuFileSave(null, 0))
1037 ide.outputView.buildBox.Logf($"Unable to save %s file.\n", node.name);
1047 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1048 int bitDepth = ide.workspace.bitDepth;
1050 if(ProjectPrepareForToolchain(project, normal, true, true, compiler, config))
1053 ide.outputView.buildBox.Logf($"%s specific file(s) in project %s using the %s configuration...\n",
1054 (mode == normal || mode == cObject) ? $"Compiling" : $"Debug compiling", project.name, config.name);
1056 ide.outputView.buildBox.Logf($"%s specific file(s) in project %s...\n",
1057 (mode == normal || mode == cObject) ? $"Compiling" : $"Debug compiling", project.name);
1059 buildInProgress = compilingFile;
1060 ide.AdjustBuildMenus();
1061 result = project.Compile(nodes, compiler, config, bitDepth, justPrint, mode);
1062 buildInProgress = none;
1063 ide.AdjustBuildMenus();
1070 bool Clean(Project project, List<ProjectNode> nodes, bool justPrint)
1073 char fileName[MAX_LOCATION];
1075 ProjectConfig config = project.config;
1079 for(document = ide.firstChild; document; document = document.next)
1081 if(document.modifiedDocument)
1083 ProjectNode n = GetNodeFromWindow(document, project, false);
1086 if(n && n.IsInNode(node) && !document.MenuFileSave(null, 0))
1088 ide.outputView.buildBox.Logf($"Unable to save %s file.\n", node.name);
1098 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1099 int bitDepth = ide.workspace.bitDepth;
1101 if(ProjectPrepareForToolchain(project, normal, true, true, compiler, config))
1103 Map<String, NameCollisionInfo> namesInfo { };
1104 project.topNode.GenMakefileGetNameCollisionInfo(namesInfo, config);
1107 if(node.GetIsExcluded(config))
1108 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
1112 ide.outputView.buildBox.Logf($"Deleteing intermediate objects for %s %s in project %s using the %s configuration...\n",
1113 node.type == file ? $"single file" : $"folder", node.name, project.name, config.name);
1115 ide.outputView.buildBox.Logf($"Deleteing intermediate objects for %s %s in project %s...\n",
1116 node.type == file ? $"single file" : $"folder", node.name, project.name);
1118 node.DeleteIntermediateFiles(compiler, config, bitDepth, namesInfo, false);
1130 bool ProjectNewFile(MenuItem selection, Modifiers mods)
1132 DataRow row = fileList.currentRow;
1135 char fileName[1024];
1136 char filePath[MAX_LOCATION];
1137 ProjectNode parentNode = (ProjectNode)row.tag;
1138 ProjectNode n, fileNode;
1139 parentNode.GetFileSysMatchingPath(filePath);
1140 MakePathRelative(filePath, parentNode.project.topNode.path, filePath);
1141 for(n = parentNode; n && n != parentNode.project.resNode; n = n.parent);
1142 sprintf(fileName, $"Untitled %d", documentID);
1143 fileNode = AddFile(parentNode, fileName, (bool)n, true);
1144 fileNode.path = CopyUnixPath(filePath);
1147 NodeProperties nodeProperties
1150 position = { position.x + 100, position.y + 100 };
1154 nodeProperties.Create(); // not modal?
1160 bool ProjectNewFolder(MenuItem selection, Modifiers mods)
1162 DataRow row = fileList.currentRow;
1165 ProjectNode parentNode = (ProjectNode)row.tag;
1166 NewFolder(parentNode, null, true);
1171 bool ResourcesAddFiles(MenuItem selection, Modifiers mods)
1177 bool ProjectAddFiles(MenuItem selection, Modifiers mods)
1183 bool ProjectImportFolder(MenuItem selection, Modifiers mods)
1185 DataRow row = fileList.currentRow;
1188 ProjectNode toNode = (ProjectNode)row.tag;
1189 ImportFolder(toNode);
1194 bool ProjectAddNewForm(MenuItem selection, Modifiers mods)
1196 CodeEditor codeEditor = CreateNew("Form", "form", "Window", null);
1197 codeEditor.EnsureUpToDate();
1201 bool ProjectAddNewGraph(MenuItem selection, Modifiers mods)
1203 CodeEditor codeEditor = CreateNew("Graph", "graph", "Block", null);
1205 codeEditor.EnsureUpToDate();
1209 bool ProjectRemove(MenuItem selection, Modifiers mods)
1211 DataRow row = fileList.currentRow;
1214 ProjectNode node = (ProjectNode)row.tag;
1215 if(node.type == project)
1216 RemoveSelectedNodes();
1221 bool ProjectUpdateMakefileForAllConfigs(Project project)
1223 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1225 // This call really does not belong here:
1226 ide.UpdateToolBarActiveConfigs(false);
1227 for(config : project.configurations)
1228 ProjectPrepareMakefile(project, forceExists, compiler, config);
1235 bool MenuSettings(MenuItem selection, Modifiers mods)
1237 ProjectNode node = GetSelectedNode(true);
1238 Project prj = node ? node.project : project;
1239 projectSettingsDialog = ProjectSettings { master = parent, project = prj, projectNode = node };
1240 incref projectSettingsDialog;
1241 projectSettingsDialog.Modal();
1242 delete projectSettingsDialog;
1243 ide.UpdateToolBarActiveConfigs(false);
1249 bool FileProperties(MenuItem selection, Modifiers mods)
1251 DataRow row = fileList.currentRow;
1254 ProjectNode node = (ProjectNode)row.tag;
1255 NodeProperties { parent = parent, master = this, node = node,
1256 position = { position.x + 100, position.y + 100 } }.Create();
1261 bool FileOpenFile(MenuItem selection, Modifiers mods)
1263 OpenSelectedNodes(mods.ctrl && mods.shift);
1267 bool FileRemoveFile(MenuItem selection, Modifiers mods)
1269 RemoveSelectedNodes();
1273 bool FileCompile(MenuItem selection, Modifiers mods)
1276 OldList selectedRows;
1277 Project project = null;
1278 List<ProjectNode> nodes { };
1279 fileList.GetMultiSelection(selectedRows);
1280 for(item = selectedRows.first; item; item = item.next)
1283 DataRow row = item.data;
1284 ProjectNode node = (ProjectNode)row.tag;
1286 project = node.project;
1287 else if(node.project != project)
1294 selectedRows.Free(null);
1296 Compile(project, nodes, mods.ctrl && mods.shift, normal);
1298 ide.outputView.buildBox.Logf($"Please select files from a single project.\n");
1303 bool FileClean(MenuItem selection, Modifiers mods)
1306 OldList selectedRows;
1307 Project project = null;
1308 List<ProjectNode> nodes { };
1309 fileList.GetMultiSelection(selectedRows);
1310 for(item = selectedRows.first; item; item = item.next)
1313 DataRow row = item.data;
1314 ProjectNode node = (ProjectNode)row.tag;
1316 project = node.project;
1317 else if(node.project != project)
1324 selectedRows.Free(null);
1326 Clean(project, nodes, mods.ctrl && mods.shift);
1328 ide.outputView.buildBox.Logf($"Please select files from a single project.\n");
1333 bool FileDebugPrecompile(MenuItem selection, Modifiers mods)
1335 DataRow row = fileList.currentRow;
1336 ProjectNode node = row ? (ProjectNode)row.tag : null;
1339 List<ProjectNode> nodes { };
1341 if(node.type == project)
1342 ProjectBuild(selection, mods);
1345 Compile(node.project, nodes, mods.ctrl && mods.shift, debugPrecompile);
1351 bool FileDebugCompile(MenuItem selection, Modifiers mods)
1353 DataRow row = fileList.currentRow;
1354 ProjectNode node = row ? (ProjectNode)row.tag : null;
1357 List<ProjectNode> nodes { };
1359 if(node.type == project)
1360 ProjectBuild(selection, mods);
1362 Compile(node.project, nodes, mods.ctrl && mods.shift, normal);
1364 Compile(node.project, nodes, mods.ctrl && mods.shift, debugCompile);
1370 bool FileDebugGenerateSymbols(MenuItem selection, Modifiers mods)
1372 DataRow row = fileList.currentRow;
1373 ProjectNode node = row ? (ProjectNode)row.tag : null;
1376 List<ProjectNode> nodes { };
1378 if(node.type == project)
1379 ProjectBuild(selection, mods);
1381 Compile(node.project, nodes, mods.ctrl && mods.shift, normal);
1383 Compile(node.project, nodes, mods.ctrl && mods.shift, debugGenerateSymbols);
1389 Project GetSelectedProject(bool useSelection)
1391 Project prj = project;
1394 DataRow row = fileList.currentRow;
1395 ProjectNode node = row ? (ProjectNode)row.tag : null;
1402 void SelectNextProject(bool backwards)
1404 DataRow row = fileList.currentRow;
1405 DataRow currentRow = row;
1406 ProjectNode node = (ProjectNode)row.tag;
1407 if(node.type != project)
1408 row = node.project.topNode.row;
1410 row = row.previous ? row.previous : fileList.lastRow;
1412 row = row.next ? row.next : fileList.firstRow;
1413 if(row && row != currentRow)
1415 fileList.SelectRow(row);
1416 fileList.currentRow = row;
1420 ProjectNode GetSelectedNode(bool useSelection)
1422 ProjectNode node = null;
1425 DataRow row = fileList.currentRow;
1427 node = (ProjectNode)row.tag;
1432 bool MenuBrowseFolder(MenuItem selection, Modifiers mods)
1434 char folder[MAX_LOCATION];
1436 ProjectNode node = GetSelectedNode(true);
1438 node = project.topNode;
1441 strcpy(folder, prj.topNode.path);
1442 if(node != prj.topNode)
1443 PathCatSlash(folder, node.path);
1448 bool Run(MenuItem selection, Modifiers mods)
1450 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1451 ProjectConfig config = project.config;
1452 int bitDepth = ide.workspace.bitDepth;
1453 String args = new char[maxPathLen];
1455 if(ide.workspace.commandLineArgs)
1456 //ide.debugger.GetCommandLineArgs(args);
1457 strcpy(args, ide.workspace.commandLineArgs);
1458 if(ide.debugger.isActive)
1459 project.Run(args, compiler, config, bitDepth);
1460 /*else if(config.targetType == sharedLibrary || config.targetType == staticLibrary)
1461 MessageBox { master = ide, type = ok, text = "Run", contents = "Shared and static libraries cannot be run like executables." }.Modal();*/
1462 else if(BuildInterrim(project, run, compiler, config, bitDepth, false))
1463 project.Run(args, compiler, config, bitDepth);
1471 bool result = false;
1472 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1473 ProjectConfig config = project.config;
1474 int bitDepth = ide.workspace.bitDepth;
1475 TargetTypes targetType = project.GetTargetType(config);
1476 if(targetType == sharedLibrary || targetType == staticLibrary)
1477 MessageBox { master = ide, type = ok, text = $"Run", contents = $"Shared and static libraries cannot be run like executables." }.Modal();
1478 else if(project.GetCompress(config))
1479 MessageBox { master = ide, text = $"Starting Debug", contents = $"Debugging compressed applications is not supported\n" }.Modal();
1480 else if(project.GetDebug(config) ||
1481 MessageBox { master = ide, type = okCancel, text = $"Starting Debug", contents = $"Attempting to debug non-debug configuration\nProceed anyways?" }.Modal() == ok)
1483 if(/*!IsProjectModified() ||*/ BuildInterrim(project, start, compiler, config, bitDepth, false))
1485 if(compiler.type.isVC)
1487 //bool result = false;
1488 char oldwd[MAX_LOCATION];
1489 PathBackup pathBackup { };
1490 char command[MAX_LOCATION];
1492 ide.SetPath(false, compiler, config, bitDepth);
1494 GetWorkingDir(oldwd, sizeof(oldwd));
1495 ChangeWorkingDir(project.topNode.path);
1497 sprintf(command, "%s /useenv %s.sln /projectconfig \"%s|Win32\" /command \"%s\"" , "devenv", project.name, config.name, "Debug.Start");
1499 ChangeWorkingDir(oldwd);
1505 ide.debugger.Start(compiler, config, bitDepth);
1514 void GoToError(const char * line, const bool noParsing)
1518 while(isspace(*line)) line++;
1519 colon = strstr(line, ":");
1524 bool lookForLineNumber = true;
1526 // deal with linking error
1527 if(colon && colon[1] == ' ')
1529 colon = strstr(colon + 1, ":");
1530 if(colon && !colon[1])
1532 colon = strstr(line, ":");
1533 lookForLineNumber = false;
1535 else if(colon && !isdigit(colon[1]))
1538 colon = strstr(line, ":");
1541 // Don't be mistaken by the drive letter colon
1542 if(colon && (colon[1] == '/' || colon[1] == '\\'))
1543 colon = strstr(colon + 1, ":");
1544 if(colon && lookForLineNumber)
1548 char * par = RSearchString(line, "(", colon - line, true, false);
1549 if(par && strstr(par, ")"))
1551 else if((colon+1)[0] == ' ')
1553 // NOTE: This is the same thing as saying 'colon = line'
1554 for( ; colon != line; colon--)
1558 lineNumber = atoi(colon + 1);
1560 comma = strchr(colon, ',');
1562 col = atoi(comma+1);
1564 comma = strchr(colon+1, ':');
1566 col = atoi(comma+1);
1570 char moduleName[MAX_LOCATION], filePath[MAX_LOCATION];
1571 char ext[MAX_EXTENSION];
1575 char * inFileIncludedFrom = strstr(line, stringInFileIncludedFrom);
1576 char * from = strstr(line, "from ");
1577 char * start = inFileIncludedFrom ? inFileIncludedFrom + strlen(stringInFileIncludedFrom) : from ? from + strlen("from ") : line;
1581 len = Min((int)(colon - start), MAX_LOCATION-1);
1583 strncpy(moduleName, start, len);
1584 moduleName[len] = '\0';
1587 strcpy(moduleName, line);
1589 // Remove stuff in brackets
1591 bracket = strstr(moduleName, "(");
1592 if(bracket) *bracket = '\0';
1594 MakeSlashPath(moduleName);
1598 // Check if it's one of our modules
1599 ProjectNode node = project.topNode.Find(moduleName, false);
1602 strcpy(moduleName, node.path);
1603 PathCatSlash(moduleName, node.name);
1606 moduleName[0] = '\0';
1608 GetExtension(moduleName, ext);
1609 if(!strcmp(ext, "a") || !strcmp(ext, "o") || !strcmp(ext, "lib") || !strcmp(ext, "dll"))
1610 moduleName[0] = 0; // Avoid opening binary files
1613 CodeEditor codeEditor;
1614 strcpy(filePath, project.topNode.path);
1615 PathCatSlash(filePath, moduleName);
1617 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal, noParsing);
1618 if(!codeEditor && !strcmp(ext, "c"))
1620 char ecName[MAX_LOCATION];
1621 ChangeExtension(filePath, "ec", ecName);
1622 codeEditor = (CodeEditor)ide.OpenFile(ecName, normal, true, null, no, normal, noParsing);
1626 char path[MAX_LOCATION];
1627 // TOFIX: Improve on this, don't use only filename, make a function
1628 if(ide && ide.workspace)
1630 for(prj : ide.workspace.projects)
1633 MakePathRelative(filePath, prj.topNode.path, path);
1635 if((node = prj.topNode.FindWithPath(path, false)))
1637 strcpy(filePath, prj.topNode.path);
1638 PathCatSlash(filePath, node.path);
1639 PathCatSlash(filePath, node.name);
1640 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal, noParsing);
1645 if(!codeEditor && !strchr(moduleName, '/') && !strchr(moduleName, '\\'))
1647 for(prj : ide.workspace.projects)
1650 if((node = prj.topNode.Find(moduleName, false)))
1652 strcpy(filePath, prj.topNode.path);
1653 PathCatSlash(filePath, node.path);
1654 PathCatSlash(filePath, node.name);
1655 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal, noParsing);
1663 if(codeEditor && lineNumber)
1665 EditBox editBox = codeEditor.editBox;
1666 editBox.GoToLineNum(lineNumber - 1);
1667 editBox.GoToPosition(editBox.line, lineNumber - 1, col ? (col - 1) : 0);
1674 bool OpenNode(ProjectNode node, bool noParsing)
1676 char filePath[MAX_LOCATION];
1677 node.GetFullFilePath(filePath);
1678 return ide.OpenFile(filePath, normal, true/*false Why was it opening hidden?*/, null, something, normal, noParsing) ? true : false;
1681 void AddNode(ProjectNode node, DataRow addTo)
1683 DataRow row = addTo ? addTo.AddRow() : fileList.AddRow();
1685 row.tag = (int64)node;
1688 if(node.type == resources)
1691 row.SetData(null, node);
1693 if(node.files && node.files.first && node.parent &&
1694 !(!node.parent.parent &&
1695 (!strcmpi(node.name, "notes") || !strcmpi(node.name, "sources") ||
1696 !strcmpi(node.name, "src") || !strcmpi(node.name, "tools"))))
1697 row.collapsed = true;
1698 else if(node.type == folder)
1699 node.icon = openFolder;
1703 for(child : node.files)
1704 AddNode(child, row);
1708 void DeleteNode(ProjectNode projectNode)
1710 if(projectNode.files)
1713 while(child = projectNode.files.first)
1716 fileList.DeleteRow(projectNode.row);
1717 projectNode.Delete();
1720 bool ProjectSave(MenuItem selection, Modifiers mods)
1722 DataRow row = fileList.currentRow;
1723 ProjectNode node = row ? (ProjectNode)row.tag : null;
1724 Project prj = node ? node.project : null;
1727 prj.StopMonitoring();
1728 if(prj.Save(prj.filePath))
1730 Project modPrj = null;
1731 prj.topNode.modified = false;
1732 for(p : ide.workspace.projects)
1734 if(p.topNode.modified)
1741 modifiedDocument = false;
1744 prj.StartMonitoring();
1749 bool ShowOutputBuildLog(bool cleanLog)
1751 OutputView output = ide.outputView;
1753 output.ShowClearSelectTab(build);
1756 output.SelectTab(build);
1764 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1765 ProjectConfig config = project.config;
1766 int bitDepth = ide.workspace.bitDepth;
1768 bool result = false;
1769 if(/*!IsProjectModified() ||*/ BuildInterrim(project, restart, compiler, config, bitDepth, false))
1771 // For Restart, compiler and config will only be used if for
1772 // whatever reason (if at all possible) the Debugger is in a
1773 // 'terminated' or 'none' state
1774 ide.debugger.Restart(compiler, config, bitDepth);
1784 ide.debugger.Resume();
1790 ide.debugger.Break();
1796 ide.debugger.Stop();
1800 bool DebugStepInto()
1802 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1803 ProjectConfig config = project.config;
1804 int bitDepth = ide.workspace.bitDepth;
1806 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config, bitDepth, false)))
1807 ide.debugger.StepInto(compiler, config, bitDepth);
1812 bool DebugStepOver(bool skip)
1814 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1815 ProjectConfig config = project.config;
1816 int bitDepth = ide.workspace.bitDepth;
1818 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config, bitDepth, false)))
1819 ide.debugger.StepOver(compiler, config, bitDepth, skip);
1825 bool DebugStepOut(bool skip)
1827 ide.debugger.StepOut(skip);
1831 void ImportFolder(ProjectNode toNode)
1835 //bool isFolder = toNode.type == folder;
1836 //bool isRes = toNode.isInResources;
1838 FileDialog fileDialog = importFileDialog;
1839 fileDialog.master = parent;
1840 if(fileDialog.Modal() == ok)
1842 ImportFolderFSI fsi { projectView = this };
1843 fsi.stack.Add(toNode);
1844 fsi.Iterate(fileDialog.filePath);
1850 ProjectNode NewFolder(ProjectNode parentNode, char * name, bool showProperties)
1854 ProjectNode folderNode;
1855 Project prj = parentNode.project;
1857 ProjectNode after = null;
1858 for(node : parentNode.files)
1860 if(node.type != folder)
1866 folderNode = parentNode.Add(prj, name, after, folder, folder, true);
1869 for(c = 0; c < 100; c++)
1872 sprintf(string, c ? "New Folder (%d)" : "New Folder", c);
1873 if((folderNode = parentNode.Add(prj, string, after, folder, folder, true)))
1880 NodeProperties nodeProperties;
1883 modifiedDocument = true;
1884 prj.topNode.modified = true;
1887 folderNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
1888 folderNode.row.tag = (int64)folderNode;
1890 folderNode.row.SetData(null, folderNode);
1891 fileList.currentRow = folderNode.row;
1895 nodeProperties = NodeProperties
1897 parent, this, mode = newFolder, node = folderNode;
1898 position = { position.x + 100, position.y + 100 };
1900 nodeProperties.Create(); // Modal?
1908 void AddFiles(bool resources)
1910 FileDialog fileDialog = (!resources) ? this.fileDialog : resourceFileDialog;
1911 fileDialog.type = multiOpen;
1912 fileDialog.text = !resources ? $"Add Files to Project" : $"Add Resources to Project";
1913 fileDialog.master = parent;
1915 if(fileDialog.Modal() == ok)
1918 DataRow row = fileList.currentRow;
1919 ProjectNode parentNode = (ProjectNode)row.tag;
1920 bool addFailed = false;
1921 int numSelections = fileDialog.numSelections;
1922 char ** multiFilePaths = fileDialog.multiFilePaths;
1924 Array<String> nameConflictFiles { };
1926 for(c = 0; c < numSelections; c++)
1928 char * filePath = multiFilePaths[c];
1929 FileAttribs exists = FileExists(filePath);
1930 bool addThisFile = true;
1932 if(exists.isDirectory)
1933 addThisFile = false;
1936 if(MessageBox { master = ide, type = yesNo, text = filePath,
1937 contents = $"File doesn't exist. Create?" }.Modal() == yes)
1939 File f = FileOpen(filePath, write);
1947 MessageBox { master = ide, type = ok, text = filePath,
1948 contents = $"Couldn't create file."}.Modal();
1949 addThisFile = false;
1956 /*addFailed = */if(!AddFile(parentNode, filePath, resources, false))//;
1958 nameConflictFiles.Add(CopyString(filePath));
1966 char * part1 = $"The following file";
1967 char * opt1 = $" was ";
1968 char * opt2 = $"s were ";
1969 char * part2 = $"not added because of identical file name conflict within the project.\n\n";
1971 len += strlen(part1);
1972 len += strlen(part2);
1973 len += nameConflictFiles.count > 1 ? strlen(opt2) : strlen(opt1);
1974 for(s : nameConflictFiles)
1975 len += strlen(s) + 1;
1976 message = new char[len + 1];
1977 strcpy(message, part1);
1978 strcat(message, nameConflictFiles.count > 1 ? opt2 : opt1);
1979 strcat(message, part2);
1980 for(s : nameConflictFiles)
1983 strcat(message, "\n");
1985 MessageBox { master = ide, type = ok, text = $"Name Conflict",
1986 contents = message }.Modal();
1989 nameConflictFiles.Free();
1990 delete nameConflictFiles;
1994 ProjectNode AddFile(ProjectNode parentNode, char * filePath, bool resources, bool isTemporary)
1996 ProjectNode result = null;
1997 ProjectNode after = null;
1998 for(node : parentNode.files)
2000 if(node.type != folder && node.type != file && node.type)
2005 result = parentNode.Add(parentNode.project, filePath, after, file, NodeIcons::SelectFileIcon(filePath), !resources);
2011 modifiedDocument = true;
2012 parentNode.project.topNode.modified = true;
2013 parentNode.project.ModifiedAllConfigs(true, false, true, true);
2016 result.row = parentNode.row.AddRowAfter(after ? after.row : null);
2017 result.row.tag = (int64)result;
2018 result.row.SetData(null, result);
2023 CodeEditor CreateNew(char * upper, char * lower, char * base, char * className)
2025 CodeEditor codeEditor = null;
2026 ProjectNode projectNode;
2027 ProjectNode after = null;
2028 DataRow row = fileList.currentRow;
2029 ProjectNode parentNode;
2032 if(!row) row = project.topNode.row;
2034 parentNode = (ProjectNode)row.tag;
2036 for(node : parentNode.files)
2038 if(node.type != folder && node.type != file && node.type)
2042 for(c = 1; c < 100; c++)
2045 sprintf(string, c ? "%s%d.ec" : "%s.ec", lower, c);
2046 if((projectNode = parentNode.Add(project, string, after, file, genFile, true)))
2052 char filePath[MAX_LOCATION];
2054 modifiedDocument = true;
2055 project.topNode.modified = true;
2057 project.ModifiedAllConfigs(true, false, false, true);
2058 projectNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
2059 projectNode.row.tag =(int64)projectNode;
2061 projectNode.row.SetData(null, projectNode);
2062 fileList.currentRow = projectNode.row;
2064 strcpy(filePath, project.topNode.path);
2065 PathCat(filePath, projectNode.path);
2066 PathCat(filePath, projectNode.name);
2068 codeEditor = (CodeEditor)ide.FindWindow(filePath);
2071 Class baseClass = eSystem_FindClass(__thisModule, base);
2072 subclass(ClassDesignerBase) designerClass = eClass_GetDesigner(baseClass);
2075 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal, false);
2076 strcpy(name, projectNode.name);
2077 sprintf(name, "%s%d", upper, c);
2079 strcpy(className, name);
2081 designerClass.CreateNew(codeEditor.editBox, codeEditor.clientSize, name, base);
2083 //codeEditor.modifiedDocument = false;
2084 //codeEditor.designer.modifiedDocument = false;
2086 //Code_EnsureUpToDate(codeEditor);
2089 else // TODO: fix no symbols generated when ommiting {} for following else
2091 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal, false);
2093 ide.sheet.visible = true;
2094 ide.sheet.Activate();
2097 codeEditor.ViewDesigner();
2098 codeEditor.codeModified = true;
2105 // Returns true if we opened something
2106 bool OpenSelectedNodes(bool noParsing)
2108 bool result = false;
2112 fileList.GetMultiSelection(selection);
2113 for(item = selection.first; item; item = item.next)
2115 DataRow row = item.data;
2116 ProjectNode node = (ProjectNode)row.tag;
2117 if(node.type == file)
2119 OpenNode(node, noParsing);
2124 selection.Free(null);
2128 void RemoveSelectedNodes()
2133 fileList.GetMultiSelection(selection);
2135 // Remove children of parents we're deleting
2136 for(item = selection.first; item; item = next)
2139 DataRow row = item.data;
2140 ProjectNode n, node = (ProjectNode)row.tag;
2141 bool remove = false;
2144 for(i = selection.first; i && !remove; i = i.next)
2146 ProjectNode iNode = (ProjectNode)((DataRow)i.data).tag;
2147 for(n = node.parent; n; n = n.parent)
2157 selection.Delete(item);
2160 for(item = selection.first; item; item = item.next)
2162 DataRow row = item.data;
2163 ProjectNode node = (ProjectNode)row.tag;
2164 ProjectNode resNode;
2165 for(resNode = node.parent; resNode; resNode = resNode.parent)
2166 if(resNode.type == resources)
2168 if(node.type == file)
2170 Project prj = node.project;
2172 modifiedDocument = true;
2173 prj.topNode.modified = true;
2175 prj.ModifiedAllConfigs(true, false, true, true);
2177 else if(node.type == folder)
2180 sprintf(message, $"Are you sure you want to remove the folder \"%s\"\n"
2181 "and all of its contents from the project?", node.name);
2182 if(MessageBox { master = ide, type = yesNo, text = $"Delete Folder", contents = message }.Modal() == yes)
2184 Project prj = node.project;
2185 if(node.containsFile)
2186 prj.ModifiedAllConfigs(true, false, true, true);
2188 modifiedDocument = true;
2189 prj.topNode.modified = true;
2192 else if(node.type == project && node != project.topNode && !buildInProgress)
2196 for(p : workspace.projects)
2198 if(p.topNode == node)
2204 sprintf(message, $"Are you sure you want to remove the \"%s\" project\n" "from this workspace?", node.name);
2205 if(MessageBox { master = ide, type = yesNo, text = $"Remove Project", contents = message }.Modal() == yes)
2210 workspace.RemoveProject(prj);
2211 //modifiedDocument = true; // when project view is a workspace view
2215 selection.Free(null);