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, install };
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 bool showInstallMenuItem = mods.ctrl && mods.shift;
219 ProjectNode node = (ProjectNode)row.tag;
220 #ifdef IDE_SHOW_INSTALL_MENU_BUTTON
221 showInstallMenuItem = true;
223 if(node.type == NodeTypes::project || node.type == resources || node.type == file || node.type == folder)
225 bool na = buildInProgress; // N/A - buildMenuUnavailable
228 if(node.type == NodeTypes::project)
231 mi = ide.projectBuildItem;
232 MenuItem { pop, $"Build" , b, f7 , NotifySelect = ProjectBuild , bitmap = mi.bitmap }.disabled = na; mi = ide.projectLinkItem;
233 MenuItem { pop, $"Relink" , l , NotifySelect = ProjectLink , bitmap = mi.bitmap }.disabled = na; mi = ide.projectRebuildItem;
234 MenuItem { pop, $"Rebuild" , r, shiftF7, NotifySelect = ProjectRebuild , bitmap = mi.bitmap }.disabled = na; mi = ide.projectCleanTargetItem;
235 MenuItem { pop, $"Clean Target" , g , NotifySelect = ProjectCleanTarget, bitmap = mi.bitmap }.disabled = na; mi = ide.projectCleanItem;
236 MenuItem { pop, $"Clean" , c , NotifySelect = ProjectClean , bitmap = mi.bitmap }.disabled = na; mi = ide.projectRealCleanItem;
237 MenuItem { pop, $"Real Clean" , NotifySelect = ProjectRealClean , bitmap = mi.bitmap }.disabled = na; mi = ide.projectRegenerateItem;
238 MenuItem { pop, $"Regenerate Makefile", m , NotifySelect = ProjectRegenerate , bitmap = mi.bitmap }.disabled = na;
239 if(showInstallMenuItem)
241 mi = ide.projectInstallItem;
242 MenuItem { pop, $"Install" , t , NotifySelect = ProjectInstall , bitmap = mi.bitmap }.disabled = na;
244 if(showDebuggingMenuItems && node.ContainsFilesWithExtension("ec"))
247 MenuItem { pop, $"Debug Generate Symbols", l, NotifySelect = FileDebugGenerateSymbols }.disabled = na;
248 MenuItem { pop, $"Debug Precompile", l, NotifySelect = FileDebugPrecompile }.disabled = na;
249 MenuItem { pop, $"Debug Compile", l, NotifySelect = FileDebugCompile }.disabled = na;
252 MenuItem { pop, $"New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
253 MenuItem { pop, $"New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
254 MenuItem { pop, $"Import Folder...", i, NotifySelect = ProjectImportFolder };
255 MenuItem { pop, $"Add Files to Project...", f, NotifySelect = ProjectAddFiles };
257 MenuItem { pop, $"Add New Form...", o, NotifySelect = ProjectAddNewForm };
258 // MenuItem { pop, "Add New Behavior Graph...", g, NotifySelect = ProjectAddNewGraph };
260 if(node != ((Project)workspace.projects.first).topNode)
262 MenuItem { pop, $"Remove project from workspace", r, NotifySelect = ProjectRemove }.disabled = na;
265 MenuItem { pop, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
267 MenuItem { pop, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
269 MenuItem { pop, $"Save", v, Key { s, ctrl = true }, NotifySelect = ProjectSave }.disabled = !node.modified;
271 MenuItem { pop, $"Properties...", p, Key { enter, alt = true }, NotifySelect = FileProperties };
273 else if(node.type == resources)
275 MenuItem { pop, $"New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
276 MenuItem { pop, $"New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
277 MenuItem { pop, $"Import Folder...", i, NotifySelect = ProjectImportFolder };
278 MenuItem { pop, $"Add Resources to Project...", f, NotifySelect = ResourcesAddFiles };
279 MenuItem { pop, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
281 MenuItem { pop, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
282 MenuItem { pop, $"Properties...", p, Key { enter, alt = true }, NotifySelect = FileProperties };
284 else if(node.type == file)
286 MenuItem { pop, $"Open", o, NotifySelect = FileOpenFile };
288 MenuItem { pop, $"Clean", l, NotifySelect = FileClean, bitmap = ide.projectCleanItem.bitmap }.disabled = na;
289 MenuItem { pop, $"Compile", c, Key { f7, ctrl = true}, NotifySelect = FileCompile, bitmap = ide.projectBuildItem.bitmap }.disabled = na;
290 if(showDebuggingMenuItems)
292 char extension[MAX_EXTENSION];
293 GetExtension(node.name, extension);
294 if(!strcmpi(extension, "ec"))
297 MenuItem { pop, $"Debug Precompile", l, NotifySelect = FileDebugPrecompile }.disabled = na;
298 MenuItem { pop, $"Debug Compile", l, NotifySelect = FileDebugCompile }.disabled = na;
302 MenuItem { pop, $"Remove", r, NotifySelect = FileRemoveFile };
304 MenuItem { pop, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
306 MenuItem { pop, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
307 MenuItem { pop, $"Properties..", p, Key { enter, alt = true }, NotifySelect = FileProperties };
309 else if(node.type == folder)
311 bool isInResources = node.isInResources;
313 MenuItem { pop, $"New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
314 MenuItem { pop, $"New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
315 MenuItem { pop, $"Import Folder...", i, NotifySelect = ProjectImportFolder };
318 MenuItem { pop, $"Add Resources to Folder...", f, NotifySelect = ResourcesAddFiles };
322 MenuItem { pop, $"Add Files to Folder...", f, NotifySelect = ProjectAddFiles };
327 MenuItem { pop, $"Add New Form...", o, NotifySelect = ProjectAddNewForm };
328 // MenuItem { pop, $"Add New Behavior Graph...", g, NotifySelect = ProjectAddNewGraph };
331 MenuItem { pop, $"Clean", l, NotifySelect = FileClean, bitmap = ide.projectCleanItem.bitmap }.disabled = na;
332 MenuItem { pop, $"Compile", c, Key { f7, ctrl = true}, NotifySelect = FileCompile, bitmap = ide.projectBuildItem.bitmap }.disabled = na;
334 MenuItem { pop, $"Remove", r, NotifySelect = FileRemoveFile };
336 MenuItem { pop, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
338 MenuItem { pop, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
339 MenuItem { pop, $"Properties...", p, Key { enter, alt = true }, NotifySelect = FileProperties };
344 master = this, menu = pop;
346 x + clientStart.x + absPosition.x - app.desktop.position.x,
347 y + clientStart.y + absPosition.y - app.desktop.position.y };
349 void NotifyDestroyed(Window window, DialogResult result)
355 ide.AdjustPopupBuildMenus();
361 bool NotifyKeyHit(ListBox listBox, DataRow row, Key key, unichar ch)
363 if(key == altUp || key == altDown)
365 SelectNextProject(key == altUp);
371 bool NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch)
375 ProjectNode node = (ProjectNode)row.tag;
378 case altEnter: case Key { keyPadEnter, alt = true }:
380 NodeProperties { parent = parent, master = this,
381 position = { position.x + 100, position.y + 100 }, node = node }.Create();
384 case enter: case keyPadEnter:
387 for(resNode = node.parent; resNode; resNode = resNode.parent)
388 if(resNode.type == resources)
390 if(node.type == project || (node.type == folder && !resNode))
395 else if(node.type == resources || node.type == folder)
404 if(node.type == project || node.type == folder || node.type == resources)
413 if(node.type == project || node.type == folder || node.type == resources)
415 NewFolder(node, null, true);
422 if(node.type == file)
424 FileCompile(null, (Modifiers)key);
429 case Key { space, shift = true }:
432 if(node.type == NodeTypes::project)
435 for(p : workspace.projects)
437 if(p.topNode == node)
443 prj.RotateActiveConfig(!key.shift);
454 case Key { enter, true, true }: OpenSelectedNodes(true); break;
455 case Key { keyPadEnter, true, true }: OpenSelectedNodes(true); break;
456 case enter: case keyPadEnter: OpenSelectedNodes(false); break;
457 case del: RemoveSelectedNodes(); break;
460 Window activeClient = ide.activeClient;
462 activeClient.Activate();
464 ide.RepositionWindows(true);
471 bool NotifyCollapse(ListBox listBox, DataRow row, bool collapsed)
473 ProjectNode node = (ProjectNode)row.tag;
474 if(node.type == folder)
475 node.icon = collapsed ? folder : openFolder;
480 FileDialog importFileDialog { autoCreate = false, type = selectDir, text = $"Import Folder" };
481 FileDialog projectFileDialog
483 autoCreate = false, filters = projectFilters.array, sizeFilters = projectFilters.count * sizeof(FileFilter);
484 types = projectTypes.array, sizeTypes = projectTypes.count * sizeof(FileType);
486 FileDialog fileDialog
488 autoCreate = false, mayNotExist = true, filters = fileFilters.array, sizeFilters = fileFilters.count * sizeof(FileFilter);
490 FileDialog resourceFileDialog
492 autoCreate = false, mayNotExist = true, filters = resourceFilters.array, sizeFilters = resourceFilters.count * sizeof(FileFilter);
495 Menu fileMenu { menu, $"File", f };
496 MenuItem { fileMenu, $"Save", s, Key { s, ctrl = true }, NotifySelect = MenuFileSave };
497 // MenuItem { fileMenu, "Save As...", a, NotifySelect = MenuFileSaveAs };
499 bool OnClose(bool parentClosing)
501 if(!parentClosing && visible)
511 DialogResult dialogRes;
514 strcpy(msg, $"You have modified projects.\nSave changes to ");
515 for(p : ide.workspace.projects)
517 if(p.topNode.modified)
519 if(!first) strcat(msg, ", ");
526 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = msg }.Modal();
530 // TOFIX: Precomp error if brackets are taken out
531 return (DialogResult)MenuFileSave(null, 0) != cancel;
533 else if(dialogRes == cancel)
535 modifiedDocument = false;
542 //if(ide.findInFilesDialog && ide.findInFilesDialog.created && ide.findInFilesDialog.mode != directory)
543 // ide.findInFilesDialog.SearchStop();
545 ide.outputView.buildBox.Clear();
546 ide.outputView.debugBox.Clear();
547 //ide.outputView.findBox.Clear();
548 ide.callStackView.Clear();
549 ide.watchesView.Clear();
550 ide.threadsView.Clear();
551 ide.breakpointsView.Clear();
552 ide.outputView.ShowClearSelectTab(find); // why this?
555 bool OnSaveFile(char * fileName)
557 for(prj : ide.workspace.projects)
559 if(prj.topNode.modified)
561 prj.StopMonitoring();
562 if(prj.Save(prj.filePath))
563 prj.topNode.modified = false;
564 prj.StartMonitoring();
567 modifiedDocument = false;
572 bool IsModuleInProject(char * filePath)
574 char moduleName[MAX_FILENAME]; //, modulePath[MAX_LOCATION];
575 GetLastDirectory(filePath, moduleName);
576 return project.topNode.Find(moduleName, false) != null;
579 ProjectNode GetNodeFromWindow(Window document, Project project, bool isCObject)
581 if(document.fileName)
583 char winFileName[MAX_LOCATION];
584 char * documentFileName = GetSlashPathBuffer(winFileName, document.fileName);
589 char name[MAX_FILENAME];
590 GetLastDirectory(documentFileName, name);
591 ChangeExtension(name, "ec", name);
592 for(p : ide.workspace.projects)
594 prj = project ? project : p;
595 if((node = prj.topNode.Find(name, false)))
602 for(p : ide.workspace.projects)
604 prj = project ? project : p;
605 if((node = prj.topNode.FindByFullPath(documentFileName, false)))
614 // ((( UTILITY FUNCTIONS )))
616 // ************************************************************************
617 // *** These methods below are part of a sequence of events, and as ***
618 // *** such they must be passed the current compiler and project config ***
619 // ************************************************************************
620 bool DisplayCompiler(CompilerConfig compiler, bool cleanLog)
622 ide.outputView.buildBox.Logf($"%s Compiler\n", compiler ? compiler.name : $"{problem with compiler selection}");
626 bool ProjectPrepareForToolchain(Project project, PrepareMakefileMethod method, bool cleanLog, bool displayCompiler,
627 CompilerConfig compiler, ProjectConfig config)
630 char message[MAX_F_STRING];
631 LogBox logBox = ide.outputView.buildBox;
633 ShowOutputBuildLog(cleanLog);
636 DisplayCompiler(compiler, false);
638 ProjectPrepareCompiler(project, compiler, false);
639 ProjectPrepareMakefile(project, method, compiler, config);
643 bool ProjectPrepareCompiler(Project project, CompilerConfig compiler, bool silent)
645 if((!project.GenerateCrossPlatformMk(app.includeFile) || !project.GenerateCompilerCf(compiler)) && !silent)
646 ide.outputView.buildBox.Logf($"Error generating compiler configuration (Is the project/config directory writable?)\n");
650 // Note: Compiler is only passed in to for VisualStudio support
651 bool ProjectPrepareMakefile(Project project, PrepareMakefileMethod method, CompilerConfig compiler, ProjectConfig config)
653 if(compiler.type.isVC)
655 // I'm guessing we'll want to support generating VS files on Linux as well...
656 ide.statusBar.text = $"Generating Visual Studio Solution...";
658 //GenerateVSSolutionFile(project, compiler);
659 ide.statusBar.text = $"Generating Visual Studio Project...";
661 //GenerateVCProjectFile(project, compiler, bitDepth);
662 ide.statusBar.text = null;
668 char makefilePath[MAX_LOCATION];
669 char makefileName[MAX_LOCATION];
671 LogBox logBox = ide.outputView.buildBox;
673 strcpy(makefilePath, project.topNode.path);
674 project.CatMakeFileName(makefileName, config);
675 PathCatSlash(makefilePath, makefileName);
677 exists = FileExists(makefilePath);
678 if(method == force ||
679 (method == forceExists && exists) ||
680 (method == normal && (!exists || (config && config.makingModified))))
684 ide.statusBar.text = $"Generating Makefile & Dependencies..."; // Dependencies?
687 if((method == normal && !exists) || (method == force && !exists))
688 action = $"Generating ";
689 else if(method == force)
690 action = $"Regenerating ";
691 else if(method == normal || method == forceExists)
692 action = $"Updating ";
696 reason = $"Makefile doesn't exist. ";
697 else if(project.topNode.modified)
698 reason = $"Project has been modified. ";
702 //logBox.Logf("%s\n", makefileName);
703 logBox.Logf($"%s - %s%smakefile for %s config...\n", makefileName, reason, action, GetConfigName(config));
705 if(!project.GenerateMakefile(null, false, null, config))
706 ide.outputView.buildBox.Logf($"Error generating makefile (Is the project directory writable?)\n");
708 ide.statusBar.text = null;
716 bool BuildInterrim(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config, int bitDepth, bool justPrint)
718 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
720 ide.outputView.buildBox.Logf($"Building project %s using the %s configuration...\n", prj.name, GetConfigName(config));
721 return Build(prj, buildType, compiler, config, bitDepth, justPrint);
726 bool DebugStopForMake(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config)
729 // TOFIX: DebugStop is being abused and backfiring on us.
730 // It's supposed to be the 'Debug/Stop' item, not unloading executable or anything else
732 // configIsInDebugSession seems to be used for two OPPOSITE things:
733 // If we're debugging another config, we need to unload the executable!
734 // In building, we want to stop if we're debugging the 'same' executable
735 if(buildType != run) ///* && prj == project*/ && prj.configIsInDebugSession)
737 if(buildType == start || buildType == restart)
739 if(ide.debugger && ide.debugger.isPrepared)
740 result = DebugStop();
744 if(ide.project == prj && ide.debugger && ide.debugger.prjConfig == config && ide.debugger.isPrepared)
745 result = DebugStop();
751 bool Build(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config, int bitDepth, bool justPrint)
757 for(document = master.firstChild; document; document = document.next)
759 if(document.modifiedDocument)
761 ProjectNode node = GetNodeFromWindow(document, prj, false);
762 if(node && !document.MenuFileSave(null, 0))
771 DirExpression targetDir = prj.GetTargetDir(compiler, config, bitDepth);
773 DebugStopForMake(prj, buildType, compiler, config);
775 // TODO: Disabled until problems fixed... is it fixed?
776 if(buildType == rebuild || (config && config.compilingModified))
777 prj.Clean(compiler, config, bitDepth, clean, justPrint);
780 if(buildType == relink || (config && config.linkingModified))
781 prj.Clean(compiler, config, bitDepth, cleanTarget, false);
782 if(config && config.symbolGenModified)
784 DirExpression objDir = prj.GetObjDir(compiler, config, bitDepth);
785 char fileName[MAX_LOCATION];
786 char moduleName[MAX_FILENAME];
787 strcpy(fileName, prj.topNode.path);
788 PathCatSlash(fileName, objDir.dir);
789 ReplaceSpaces(moduleName, prj.moduleName);
790 strcat(moduleName, ".main.ec");
791 PathCatSlash(fileName, moduleName);
792 if(FileExists(fileName))
793 DeleteFile(fileName);
794 ChangeExtension(fileName, "c", fileName);
795 if(FileExists(fileName))
796 DeleteFile(fileName);
797 ChangeExtension(fileName, "o", fileName);
798 if(FileExists(fileName))
799 DeleteFile(fileName);
804 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
805 ide.AdjustBuildMenus();
806 ide.AdjustDebugMenus();
808 result = prj.Build(buildType, null, compiler, config, bitDepth, justPrint, normal);
812 config.compilingModified = false;
814 config.linkingModified = false;
816 config.symbolGenModified = false;
818 buildInProgress = none;
819 ide.AdjustBuildMenus();
820 ide.AdjustDebugMenus();
822 ide.workspace.modified = true;
829 // ((( USER ACTIONS )))
831 // ************************************************************************
832 // *** Methods below should atomically start a process, and as such ***
833 // *** they can query compiler and config directly from ide and project ***
834 // *** but ONLY ONCE!!! ***
835 // ************************************************************************
837 bool ProjectBuild(MenuItem selection, Modifiers mods)
839 if(buildInProgress == none)
841 Project prj = project;
842 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
843 int bitDepth = ide.workspace.bitDepth;
844 ProjectConfig config;
845 if(selection || !ide.activeClient)
847 DataRow row = fileList.currentRow;
848 ProjectNode node = row ? (ProjectNode)row.tag : null;
849 if(node) prj = node.project;
853 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
858 if(/*prj != project || */!prj.GetConfigIsInDebugSession(config) || !ide.DontTerminateDebugSession($"Project Build"))
860 BuildInterrim(prj, build, compiler, config, bitDepth, mods.ctrl && mods.shift);
869 bool ProjectInstall(MenuItem selection, Modifiers mods)
871 Project prj = project;
872 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
873 int bitDepth = ide.workspace.bitDepth;
874 ProjectConfig config;
875 if(selection || !ide.activeClient)
877 DataRow row = fileList.currentRow;
878 ProjectNode node = row ? (ProjectNode)row.tag : null;
879 if(node) prj = node.project;
883 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
888 if(!prj.GetConfigIsInDebugSession(config) ||
889 (!ide.DontTerminateDebugSession($"Project Install") && DebugStopForMake(prj, relink, compiler, config)))
891 BuildInterrim(prj, build, compiler, config, bitDepth, mods.ctrl && mods.shift);
892 if(ProjectPrepareForToolchain(prj, normal, false, false, compiler, config))
894 ide.outputView.buildBox.Logf($"\nInstalling project %s using the %s configuration...\n", prj.name, GetConfigName(config));
895 Build(prj, install, compiler, config, bitDepth, mods.ctrl && mods.shift);
902 bool ProjectLink(MenuItem selection, Modifiers mods)
904 Project prj = project;
905 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
906 int bitDepth = ide.workspace.bitDepth;
907 ProjectConfig config;
908 if(selection || !ide.activeClient)
910 DataRow row = fileList.currentRow;
911 ProjectNode node = row ? (ProjectNode)row.tag : null;
912 if(node) prj = node.project;
916 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
921 if(!prj.GetConfigIsInDebugSession(config) ||
922 (!ide.DontTerminateDebugSession($"Project Link") && DebugStopForMake(prj, relink, compiler, config)))
924 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
926 ide.outputView.buildBox.Logf($"Relinking project %s using the %s configuration...\n", prj.name, GetConfigName(config));
928 config.linkingModified = true;
929 Build(prj, relink, compiler, config, bitDepth, mods.ctrl && mods.shift);
936 bool ProjectRebuild(MenuItem selection, Modifiers mods)
938 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
939 int bitDepth = ide.workspace.bitDepth;
940 Project prj = project;
941 ProjectConfig config;
942 if(selection || !ide.activeClient)
944 DataRow row = fileList.currentRow;
945 ProjectNode node = row ? (ProjectNode)row.tag : null;
946 if(node) prj = node.project;
950 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
955 if(!prj.GetConfigIsInDebugSession(config) ||
956 (!ide.DontTerminateDebugSession($"Project Rebuild") && DebugStopForMake(prj, rebuild, compiler, config)))
958 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
960 ide.outputView.buildBox.Logf($"Rebuilding project %s using the %s configuration...\n", prj.name, GetConfigName(config));
963 config.compilingModified = true;
964 config.makingModified = true;
965 }*/ // -- should this still be used depite the new solution of BuildType?
966 Build(prj, rebuild, compiler, config, bitDepth, mods.ctrl && mods.shift);
973 bool ProjectCleanTarget(MenuItem selection, Modifiers mods)
975 CleanProject($"Project Clean Target", $"Cleaning project %s target using the %s configuration...\n", selection, cleanTarget, mods.ctrl && mods.shift);
979 bool ProjectClean(MenuItem selection, Modifiers mods)
981 CleanProject($"Project Clean", $"Cleaning project %s using the %s configuration...\n", selection, clean, mods.ctrl && mods.shift);
985 bool ProjectRealClean(MenuItem selection, Modifiers mods)
987 CleanProject($"Project Real Clean", $"Removing intermediate objects directory for project %s using the %s configuration...\n", selection, realClean, mods.ctrl && mods.shift);
991 void CleanProject(char * terminateDebugSessionMessage, char * cleaningMessageLogFormat, MenuItem selection, CleanType cleanType, bool justPrint)
993 Project prj = project;
994 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
995 ProjectConfig config;
996 int bitDepth = ide.workspace.bitDepth;
997 if(selection || !ide.activeClient)
999 DataRow row = fileList.currentRow;
1000 ProjectNode node = row ? (ProjectNode)row.tag : null;
1001 if(node) prj = node.project;
1005 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
1006 if(node) prj = node.project;
1008 config = prj.config;
1009 if(!prj.GetConfigIsInDebugSession(config) ||
1010 (!ide.DontTerminateDebugSession(terminateDebugSessionMessage) && DebugStopForMake(prj, clean, compiler, config)))
1012 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
1014 ide.outputView.buildBox.Logf(cleaningMessageLogFormat, prj.name, GetConfigName(config));
1016 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
1017 ide.AdjustBuildMenus();
1018 ide.AdjustDebugMenus();
1020 prj.Clean(compiler, config, bitDepth, cleanType, justPrint);
1021 buildInProgress = none;
1022 ide.AdjustBuildMenus();
1023 ide.AdjustDebugMenus();
1029 bool ProjectRegenerate(MenuItem selection, Modifiers mods)
1031 Project prj = project;
1032 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1033 ShowOutputBuildLog(true);
1034 if(selection || !ide.activeClient)
1036 DataRow row = fileList.currentRow;
1037 ProjectNode node = row ? (ProjectNode)row.tag : null;
1043 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
1048 DisplayCompiler(compiler, false);
1049 ProjectPrepareCompiler(project, compiler, false);
1050 ProjectPrepareMakefile(prj, force, compiler, prj.config);
1055 bool Compile(Project project, List<ProjectNode> nodes, bool justPrint, SingleFileCompileMode mode)
1058 char fileName[MAX_LOCATION];
1060 ProjectConfig config = project.config;
1064 for(document = ide.firstChild; document; document = document.next)
1066 if(document.modifiedDocument)
1068 ProjectNode n = GetNodeFromWindow(document, project, mode == cObject ? true : false);
1071 if(n && n.IsInNode(node) && !document.MenuFileSave(null, 0))
1073 ide.outputView.buildBox.Logf($"Unable to save %s file.\n", node.name);
1083 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1084 int bitDepth = ide.workspace.bitDepth;
1086 if(ProjectPrepareForToolchain(project, normal, true, true, compiler, config))
1089 ide.outputView.buildBox.Logf($"%s specific file(s) in project %s using the %s configuration...\n",
1090 (mode == normal || mode == cObject) ? $"Compiling" : $"Debug compiling", project.name, config.name);
1092 ide.outputView.buildBox.Logf($"%s specific file(s) in project %s...\n",
1093 (mode == normal || mode == cObject) ? $"Compiling" : $"Debug compiling", project.name);
1095 buildInProgress = compilingFile;
1096 ide.AdjustBuildMenus();
1097 result = project.Compile(nodes, compiler, config, bitDepth, justPrint, mode);
1098 buildInProgress = none;
1099 ide.AdjustBuildMenus();
1106 bool Clean(Project project, List<ProjectNode> nodes, bool justPrint)
1109 char fileName[MAX_LOCATION];
1111 ProjectConfig config = project.config;
1115 for(document = ide.firstChild; document; document = document.next)
1117 if(document.modifiedDocument)
1119 ProjectNode n = GetNodeFromWindow(document, project, false);
1122 if(n && n.IsInNode(node) && !document.MenuFileSave(null, 0))
1124 ide.outputView.buildBox.Logf($"Unable to save %s file.\n", node.name);
1134 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1135 int bitDepth = ide.workspace.bitDepth;
1137 if(ProjectPrepareForToolchain(project, normal, true, true, compiler, config))
1139 Map<String, NameCollisionInfo> namesInfo { };
1140 project.topNode.GenMakefileGetNameCollisionInfo(namesInfo, config);
1143 if(node.GetIsExcluded(config))
1144 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
1148 ide.outputView.buildBox.Logf($"Deleting intermediate objects for %s %s in project %s using the %s configuration...\n",
1149 node.type == file ? $"single file" : $"folder", node.name, project.name, config.name);
1151 ide.outputView.buildBox.Logf($"Deleting intermediate objects for %s %s in project %s...\n",
1152 node.type == file ? $"single file" : $"folder", node.name, project.name);
1154 node.DeleteIntermediateFiles(compiler, config, bitDepth, namesInfo, false);
1166 bool ProjectNewFile(MenuItem selection, Modifiers mods)
1168 DataRow row = fileList.currentRow;
1171 char fileName[1024];
1172 char filePath[MAX_LOCATION];
1173 ProjectNode parentNode = (ProjectNode)row.tag;
1174 ProjectNode n, fileNode;
1175 parentNode.GetFileSysMatchingPath(filePath);
1176 MakePathRelative(filePath, parentNode.project.topNode.path, filePath);
1177 for(n = parentNode; n && n != parentNode.project.resNode; n = n.parent);
1178 sprintf(fileName, $"Untitled %d", documentID);
1179 fileNode = AddFile(parentNode, fileName, (bool)n, true);
1180 fileNode.path = CopyUnixPath(filePath);
1183 NodeProperties nodeProperties
1186 position = { position.x + 100, position.y + 100 };
1190 nodeProperties.Create(); // not modal?
1196 bool ProjectNewFolder(MenuItem selection, Modifiers mods)
1198 DataRow row = fileList.currentRow;
1201 ProjectNode parentNode = (ProjectNode)row.tag;
1202 NewFolder(parentNode, null, true);
1207 bool ResourcesAddFiles(MenuItem selection, Modifiers mods)
1213 bool ProjectAddFiles(MenuItem selection, Modifiers mods)
1219 bool ProjectImportFolder(MenuItem selection, Modifiers mods)
1221 DataRow row = fileList.currentRow;
1224 ProjectNode toNode = (ProjectNode)row.tag;
1225 ImportFolder(toNode);
1230 bool ProjectAddNewForm(MenuItem selection, Modifiers mods)
1232 CodeEditor codeEditor = CreateNew("Form", "form", "Window", null);
1233 codeEditor.EnsureUpToDate();
1237 bool ProjectAddNewGraph(MenuItem selection, Modifiers mods)
1239 CodeEditor codeEditor = CreateNew("Graph", "graph", "Block", null);
1241 codeEditor.EnsureUpToDate();
1245 bool ProjectRemove(MenuItem selection, Modifiers mods)
1247 DataRow row = fileList.currentRow;
1250 ProjectNode node = (ProjectNode)row.tag;
1251 if(node.type == project)
1252 RemoveSelectedNodes();
1257 bool ProjectUpdateMakefileForAllConfigs(Project project)
1259 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1261 // This call really does not belong here:
1262 ide.UpdateToolBarActiveConfigs(false);
1263 for(config : project.configurations)
1264 ProjectPrepareMakefile(project, forceExists, compiler, config);
1271 bool MenuSettings(MenuItem selection, Modifiers mods)
1273 ProjectNode node = GetSelectedNode(true);
1274 Project prj = node ? node.project : project;
1275 projectSettingsDialog = ProjectSettings { master = parent, project = prj, projectNode = node };
1276 incref projectSettingsDialog;
1277 projectSettingsDialog.Modal();
1278 delete projectSettingsDialog;
1279 ide.UpdateToolBarActiveConfigs(false);
1285 bool FileProperties(MenuItem selection, Modifiers mods)
1287 DataRow row = fileList.currentRow;
1290 ProjectNode node = (ProjectNode)row.tag;
1291 NodeProperties { parent = parent, master = this, node = node,
1292 position = { position.x + 100, position.y + 100 } }.Create();
1297 bool FileOpenFile(MenuItem selection, Modifiers mods)
1299 OpenSelectedNodes(mods.ctrl && mods.shift);
1303 bool FileRemoveFile(MenuItem selection, Modifiers mods)
1305 RemoveSelectedNodes();
1309 bool FileCompile(MenuItem selection, Modifiers mods)
1312 OldList selectedRows;
1313 Project project = null;
1314 List<ProjectNode> nodes { };
1315 fileList.GetMultiSelection(selectedRows);
1316 for(item = selectedRows.first; item; item = item.next)
1319 DataRow row = item.data;
1320 ProjectNode node = (ProjectNode)row.tag;
1322 project = node.project;
1323 else if(node.project != project)
1330 selectedRows.Free(null);
1332 Compile(project, nodes, mods.ctrl && mods.shift, normal);
1334 ide.outputView.buildBox.Logf($"Please select files from a single project.\n");
1339 bool FileClean(MenuItem selection, Modifiers mods)
1342 OldList selectedRows;
1343 Project project = null;
1344 List<ProjectNode> nodes { };
1345 fileList.GetMultiSelection(selectedRows);
1346 for(item = selectedRows.first; item; item = item.next)
1349 DataRow row = item.data;
1350 ProjectNode node = (ProjectNode)row.tag;
1352 project = node.project;
1353 else if(node.project != project)
1360 selectedRows.Free(null);
1362 Clean(project, nodes, mods.ctrl && mods.shift);
1364 ide.outputView.buildBox.Logf($"Please select files from a single project.\n");
1369 bool FileDebugPrecompile(MenuItem selection, Modifiers mods)
1371 DataRow row = fileList.currentRow;
1372 ProjectNode node = row ? (ProjectNode)row.tag : null;
1375 List<ProjectNode> nodes { };
1377 if(node.type == project)
1378 ProjectBuild(selection, mods);
1381 Compile(node.project, nodes, mods.ctrl && mods.shift, debugPrecompile);
1387 bool FileDebugCompile(MenuItem selection, Modifiers mods)
1389 DataRow row = fileList.currentRow;
1390 ProjectNode node = row ? (ProjectNode)row.tag : null;
1393 List<ProjectNode> nodes { };
1395 if(node.type == project)
1396 ProjectBuild(selection, mods);
1398 Compile(node.project, nodes, mods.ctrl && mods.shift, normal);
1400 Compile(node.project, nodes, mods.ctrl && mods.shift, debugCompile);
1406 bool FileDebugGenerateSymbols(MenuItem selection, Modifiers mods)
1408 DataRow row = fileList.currentRow;
1409 ProjectNode node = row ? (ProjectNode)row.tag : null;
1412 List<ProjectNode> nodes { };
1414 if(node.type == project)
1415 ProjectBuild(selection, mods);
1417 Compile(node.project, nodes, mods.ctrl && mods.shift, normal);
1419 Compile(node.project, nodes, mods.ctrl && mods.shift, debugGenerateSymbols);
1425 Project GetSelectedProject(bool useSelection)
1427 Project prj = project;
1430 DataRow row = fileList.currentRow;
1431 ProjectNode node = row ? (ProjectNode)row.tag : null;
1438 void SelectNextProject(bool backwards)
1440 DataRow row = fileList.currentRow;
1441 DataRow currentRow = row;
1442 ProjectNode node = (ProjectNode)row.tag;
1443 if(node.type != project)
1444 row = node.project.topNode.row;
1446 row = row.previous ? row.previous : fileList.lastRow;
1448 row = row.next ? row.next : fileList.firstRow;
1449 if(row && row != currentRow)
1451 fileList.SelectRow(row);
1452 fileList.currentRow = row;
1456 ProjectNode GetSelectedNode(bool useSelection)
1458 ProjectNode node = null;
1461 DataRow row = fileList.currentRow;
1463 node = (ProjectNode)row.tag;
1468 bool MenuBrowseFolder(MenuItem selection, Modifiers mods)
1470 char folder[MAX_LOCATION];
1472 ProjectNode node = GetSelectedNode(true);
1474 node = project.topNode;
1477 strcpy(folder, prj.topNode.path);
1478 if(node != prj.topNode)
1479 PathCatSlash(folder, node.path);
1484 bool Run(MenuItem selection, Modifiers mods)
1486 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1487 ProjectConfig config = project.config;
1488 int bitDepth = ide.workspace.bitDepth;
1489 String args = new char[maxPathLen];
1491 if(ide.workspace.commandLineArgs)
1492 //ide.debugger.GetCommandLineArgs(args);
1493 strcpy(args, ide.workspace.commandLineArgs);
1494 if(ide.debugger.isActive)
1495 project.Run(args, compiler, config, bitDepth);
1496 /*else if(config.targetType == sharedLibrary || config.targetType == staticLibrary)
1497 MessageBox { master = ide, type = ok, text = "Run", contents = "Shared and static libraries cannot be run like executables." }.Modal();*/
1498 else if(BuildInterrim(project, run, compiler, config, bitDepth, false))
1499 project.Run(args, compiler, config, bitDepth);
1507 bool result = false;
1508 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1509 ProjectConfig config = project.config;
1510 int bitDepth = ide.workspace.bitDepth;
1511 TargetTypes targetType = project.GetTargetType(config);
1512 if(targetType == sharedLibrary || targetType == staticLibrary)
1513 MessageBox { master = ide, type = ok, text = $"Run", contents = $"Shared and static libraries cannot be run like executables." }.Modal();
1514 else if(project.GetCompress(config))
1515 MessageBox { master = ide, text = $"Starting Debug", contents = $"Debugging compressed applications is not supported\n" }.Modal();
1516 else if(project.GetDebug(config) ||
1517 MessageBox { master = ide, type = okCancel, text = $"Starting Debug", contents = $"Attempting to debug non-debug configuration\nProceed anyways?" }.Modal() == ok)
1519 if(/*!IsProjectModified() ||*/ BuildInterrim(project, start, compiler, config, bitDepth, false))
1521 if(compiler.type.isVC)
1523 //bool result = false;
1524 char oldwd[MAX_LOCATION];
1525 PathBackup pathBackup { };
1526 char command[MAX_LOCATION];
1528 ide.SetPath(false, compiler, config, bitDepth);
1530 GetWorkingDir(oldwd, sizeof(oldwd));
1531 ChangeWorkingDir(project.topNode.path);
1533 sprintf(command, "%s /useenv %s.sln /projectconfig \"%s|Win32\" /command \"%s\"" , "devenv", project.name, config.name, "Debug.Start");
1535 ChangeWorkingDir(oldwd);
1541 ide.debugger.Start(compiler, config, bitDepth);
1550 void GoToError(const char * line, const bool noParsing)
1554 while(isspace(*line)) line++;
1555 colon = strstr(line, ":");
1560 bool lookForLineNumber = true;
1562 // deal with linking error
1563 if(colon && colon[1] == ' ')
1565 colon = strstr(colon + 1, ":");
1566 if(colon && !colon[1])
1568 colon = strstr(line, ":");
1569 lookForLineNumber = false;
1571 else if(colon && !isdigit(colon[1]))
1574 colon = strstr(line, ":");
1577 // Don't be mistaken by the drive letter colon
1578 if(colon && (colon[1] == '/' || colon[1] == '\\'))
1579 colon = strstr(colon + 1, ":");
1580 if(colon && lookForLineNumber)
1583 #if 0 // MSVS Errors -- todo fix this later
1584 char * par = RSearchString(line, "(", colon - line, true, false);
1585 if(par && strstr(par, ")"))
1587 else if((colon+1)[0] == ' ')
1589 // NOTE: This is the same thing as saying 'colon = line'
1590 for( ; colon != line; colon--)
1595 lineNumber = atoi(colon + 1);
1597 comma = strchr(colon, ',');
1599 col = atoi(comma+1);
1601 comma = strchr(colon+1, ':');
1603 col = atoi(comma+1);
1607 char moduleName[MAX_LOCATION], filePath[MAX_LOCATION] = "";
1608 char ext[MAX_EXTENSION] = "";
1610 ProjectNode node = null;
1613 char * inFileIncludedFrom = strstr(line, stringInFileIncludedFrom);
1614 char * from = strstr(line, "from ");
1615 char * start = inFileIncludedFrom ? inFileIncludedFrom + strlen(stringInFileIncludedFrom) : from ? from + strlen("from ") : line;
1619 len = Min((int)(colon - start), MAX_LOCATION-1);
1621 strncpy(moduleName, start, len);
1622 moduleName[len] = '\0';
1625 strcpy(moduleName, line);
1630 if((msg = strstr(moduleName, " - ")))
1634 for(prj : ide.workspace.projects)
1636 strcpy(filePath, prj.topNode.path);
1637 PathCatSlash(filePath, moduleName);
1638 if(FileExists(filePath).isFile)
1650 else if((msg = strstr(moduleName, "...")) && (colon = strchr(moduleName, ' ')) && (++colon)[0])
1654 for(prj : ide.workspace.projects)
1656 if((node = prj.resNode.Find(colon, true)))
1658 strcpy(filePath, prj.topNode.path);
1659 PathCatSlash(filePath, node.path);
1660 PathCatSlash(filePath, node.name);
1674 // Remove stuff in brackets
1676 bracket = strstr(moduleName, "(");
1677 if(bracket) *bracket = '\0';
1679 MakeSlashPath(moduleName);
1680 GetExtension(moduleName, ext);
1682 if(!colon && !filePath[0])
1684 bool dotMain = false;
1685 // Check if it's one of our modules
1686 node = project.topNode.Find(moduleName, false);
1689 strcpy(filePath, node.path);
1690 PathCatSlash(filePath, node.name);
1694 IntermediateFileType type = none;
1695 ProjectConfig config;
1698 char ext2[MAX_EXTENSION];
1699 char stripExt[MAX_LOCATION];
1700 strcpy(stripExt, moduleName);
1701 StripExtension(stripExt);
1702 GetExtension(stripExt, ext2);
1703 if(ext2[0] && !strcmp(ext2, "main"))
1705 if(!strcmp(ext, "ec"))
1707 else if(!strcmp(ext, "c"))
1709 else if(!strcmp(ext, "sym"))
1711 else if(!strcmp(ext, "imp"))
1713 else if(!strcmp(ext, "bowl"))
1715 else if(!strcmp(ext, "o"))
1720 for(prj : ide.workspace.projects; prj.lastBuildConfigName)
1722 if((config = prj.GetConfig(prj.lastBuildConfigName)))
1723 node = prj.FindNodeByObjectFileName(moduleName, type, dotMain, config);
1731 char name[MAX_FILENAME];
1732 Project project = node.project;
1733 CompilerConfig compiler = ideSettings.GetCompilerConfig(project.lastBuildCompilerName);
1736 int bitDepth = ide.workspace.bitDepth;
1737 DirExpression objDir = project.GetObjDir(compiler, config, bitDepth);
1738 strcpy(filePath, project.topNode.path);
1739 PathCatSlash(filePath, objDir.dir);
1740 node.GetObjectFileName(name, project.lastBuildNamesInfo, type, dotMain);
1741 PathCatSlash(filePath, name);
1750 if(!strcmp(ext, "a") || !strcmp(ext, "o") || !strcmp(ext, "lib") ||
1751 !strcmp(ext, "dll") || !strcmp(ext, "exe") || !strcmp(ext, "mo"))
1752 moduleName[0] = 0; // Avoid opening binary files
1755 CodeEditor codeEditor;
1758 strcpy(filePath, project.topNode.path);
1759 PathCatSlash(filePath, moduleName);
1762 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal, noParsing);
1763 if(!codeEditor && !strcmp(ext, "c"))
1765 char ecName[MAX_LOCATION];
1766 ChangeExtension(filePath, "ec", ecName);
1767 codeEditor = (CodeEditor)ide.OpenFile(ecName, normal, true, null, no, normal, noParsing);
1771 char path[MAX_LOCATION];
1772 // TOFIX: Improve on this, don't use only filename, make a function
1773 if(ide && ide.workspace)
1775 for(prj : ide.workspace.projects)
1778 MakePathRelative(filePath, prj.topNode.path, path);
1780 if((node = prj.topNode.FindWithPath(path, false)))
1782 strcpy(filePath, prj.topNode.path);
1783 PathCatSlash(filePath, node.path);
1784 PathCatSlash(filePath, node.name);
1785 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal, noParsing);
1790 if(!codeEditor && !strchr(moduleName, '/') && !strchr(moduleName, '\\'))
1792 for(prj : ide.workspace.projects)
1795 if((node = prj.topNode.Find(moduleName, false)))
1797 strcpy(filePath, prj.topNode.path);
1798 PathCatSlash(filePath, node.path);
1799 PathCatSlash(filePath, node.name);
1800 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal, noParsing);
1808 if(codeEditor && lineNumber)
1810 EditBox editBox = codeEditor.editBox;
1811 editBox.GoToLineNum(lineNumber - 1);
1812 editBox.GoToPosition(editBox.line, lineNumber - 1, col ? (col - 1) : 0);
1819 bool OpenNode(ProjectNode node, bool noParsing)
1821 char filePath[MAX_LOCATION];
1822 node.GetFullFilePath(filePath);
1823 return ide.OpenFile(filePath, normal, true/*false Why was it opening hidden?*/, null, something, normal, noParsing) ? true : false;
1826 void AddNode(ProjectNode node, DataRow addTo)
1828 DataRow row = addTo ? addTo.AddRow() : fileList.AddRow();
1830 row.tag = (int64)node;
1833 if(node.type == resources)
1836 row.SetData(null, node);
1838 if(node.files && node.files.first && node.parent &&
1839 !(!node.parent.parent &&
1840 (!strcmpi(node.name, "notes") || !strcmpi(node.name, "sources") ||
1841 !strcmpi(node.name, "src") || !strcmpi(node.name, "tools"))))
1842 row.collapsed = true;
1843 else if(node.type == folder)
1844 node.icon = openFolder;
1848 for(child : node.files)
1849 AddNode(child, row);
1853 void DeleteNode(ProjectNode projectNode)
1855 if(projectNode.files)
1858 while(child = projectNode.files.first)
1861 fileList.DeleteRow(projectNode.row);
1862 projectNode.Delete();
1865 bool ProjectSave(MenuItem selection, Modifiers mods)
1867 DataRow row = fileList.currentRow;
1868 ProjectNode node = row ? (ProjectNode)row.tag : null;
1869 Project prj = node ? node.project : null;
1872 prj.StopMonitoring();
1873 if(prj.Save(prj.filePath))
1875 Project modPrj = null;
1876 prj.topNode.modified = false;
1877 for(p : ide.workspace.projects)
1879 if(p.topNode.modified)
1886 modifiedDocument = false;
1889 prj.StartMonitoring();
1894 bool ShowOutputBuildLog(bool cleanLog)
1896 OutputView output = ide.outputView;
1898 output.ShowClearSelectTab(build);
1901 output.SelectTab(build);
1909 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1910 ProjectConfig config = project.config;
1911 int bitDepth = ide.workspace.bitDepth;
1913 bool result = false;
1914 if(/*!IsProjectModified() ||*/ BuildInterrim(project, restart, compiler, config, bitDepth, false))
1916 // For Restart, compiler and config will only be used if for
1917 // whatever reason (if at all possible) the Debugger is in a
1918 // 'terminated' or 'none' state
1919 ide.debugger.Restart(compiler, config, bitDepth);
1929 ide.debugger.Resume();
1935 ide.debugger.Break();
1941 ide.debugger.Stop();
1945 bool DebugStepInto()
1947 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1948 ProjectConfig config = project.config;
1949 int bitDepth = ide.workspace.bitDepth;
1951 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config, bitDepth, false)))
1952 ide.debugger.StepInto(compiler, config, bitDepth);
1957 bool DebugStepOver(bool skip)
1959 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1960 ProjectConfig config = project.config;
1961 int bitDepth = ide.workspace.bitDepth;
1963 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config, bitDepth, false)))
1964 ide.debugger.StepOver(compiler, config, bitDepth, skip);
1970 bool DebugStepOut(bool skip)
1972 ide.debugger.StepOut(skip);
1976 void ImportFolder(ProjectNode toNode)
1980 //bool isFolder = toNode.type == folder;
1981 //bool isRes = toNode.isInResources;
1983 FileDialog fileDialog = importFileDialog;
1984 fileDialog.master = parent;
1985 if(fileDialog.Modal() == ok)
1987 ImportFolderFSI fsi { projectView = this };
1988 fsi.stack.Add(toNode);
1989 fsi.Iterate(fileDialog.filePath);
1995 ProjectNode NewFolder(ProjectNode parentNode, char * name, bool showProperties)
1999 ProjectNode folderNode;
2000 Project prj = parentNode.project;
2002 ProjectNode after = null;
2003 for(node : parentNode.files)
2005 if(node.type != folder)
2011 folderNode = parentNode.Add(prj, name, after, folder, folder, true);
2014 for(c = 0; c < 100; c++)
2017 sprintf(string, c ? "New Folder (%d)" : "New Folder", c);
2018 if((folderNode = parentNode.Add(prj, string, after, folder, folder, true)))
2025 NodeProperties nodeProperties;
2028 modifiedDocument = true;
2029 prj.topNode.modified = true;
2032 folderNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
2033 folderNode.row.tag = (int64)folderNode;
2035 folderNode.row.SetData(null, folderNode);
2036 fileList.currentRow = folderNode.row;
2040 nodeProperties = NodeProperties
2042 parent, this, mode = newFolder, node = folderNode;
2043 position = { position.x + 100, position.y + 100 };
2045 nodeProperties.Create(); // Modal?
2053 void AddFiles(bool resources)
2055 FileDialog fileDialog = (!resources) ? this.fileDialog : resourceFileDialog;
2056 fileDialog.type = multiOpen;
2057 fileDialog.text = !resources ? $"Add Files to Project" : $"Add Resources to Project";
2058 fileDialog.master = parent;
2060 if(fileDialog.Modal() == ok)
2063 DataRow row = fileList.currentRow;
2064 ProjectNode parentNode = (ProjectNode)row.tag;
2065 bool addFailed = false;
2066 int numSelections = fileDialog.numSelections;
2067 char ** multiFilePaths = fileDialog.multiFilePaths;
2069 Array<String> nameConflictFiles { };
2071 for(c = 0; c < numSelections; c++)
2073 char * filePath = multiFilePaths[c];
2074 FileAttribs exists = FileExists(filePath);
2075 bool addThisFile = true;
2077 if(exists.isDirectory)
2078 addThisFile = false;
2081 if(MessageBox { master = ide, type = yesNo, text = filePath,
2082 contents = $"File doesn't exist. Create?" }.Modal() == yes)
2084 File f = FileOpen(filePath, write);
2092 MessageBox { master = ide, type = ok, text = filePath,
2093 contents = $"Couldn't create file."}.Modal();
2094 addThisFile = false;
2101 /*addFailed = */if(!AddFile(parentNode, filePath, resources, false))//;
2103 nameConflictFiles.Add(CopyString(filePath));
2111 char * part1 = $"The following file";
2112 char * opt1 = $" was ";
2113 char * opt2 = $"s were ";
2114 char * part2 = $"not added because of identical file name conflict within the project.\n\n";
2116 len += strlen(part1);
2117 len += strlen(part2);
2118 len += nameConflictFiles.count > 1 ? strlen(opt2) : strlen(opt1);
2119 for(s : nameConflictFiles)
2120 len += strlen(s) + 1;
2121 message = new char[len + 1];
2122 strcpy(message, part1);
2123 strcat(message, nameConflictFiles.count > 1 ? opt2 : opt1);
2124 strcat(message, part2);
2125 for(s : nameConflictFiles)
2128 strcat(message, "\n");
2130 MessageBox { master = ide, type = ok, text = $"Name Conflict",
2131 contents = message }.Modal();
2134 nameConflictFiles.Free();
2135 delete nameConflictFiles;
2139 ProjectNode AddFile(ProjectNode parentNode, char * filePath, bool resources, bool isTemporary)
2141 ProjectNode result = null;
2142 ProjectNode after = null;
2143 for(node : parentNode.files)
2145 if(node.type != folder && node.type != file && node.type)
2150 result = parentNode.Add(parentNode.project, filePath, after, file, NodeIcons::SelectFileIcon(filePath), !resources);
2156 modifiedDocument = true;
2157 parentNode.project.topNode.modified = true;
2158 parentNode.project.ModifiedAllConfigs(true, false, true, true);
2161 result.row = parentNode.row.AddRowAfter(after ? after.row : null);
2162 result.row.tag = (int64)result;
2163 result.row.SetData(null, result);
2168 CodeEditor CreateNew(char * upper, char * lower, char * base, char * className)
2170 CodeEditor codeEditor = null;
2171 ProjectNode projectNode;
2172 ProjectNode after = null;
2173 DataRow row = fileList.currentRow;
2174 ProjectNode parentNode;
2177 if(!row) row = project.topNode.row;
2179 parentNode = (ProjectNode)row.tag;
2181 for(node : parentNode.files)
2183 if(node.type != folder && node.type != file && node.type)
2187 for(c = 1; c < 100; c++)
2190 sprintf(string, c ? "%s%d.ec" : "%s.ec", lower, c);
2191 if((projectNode = parentNode.Add(project, string, after, file, genFile, true)))
2197 char filePath[MAX_LOCATION];
2199 modifiedDocument = true;
2200 project.topNode.modified = true;
2202 project.ModifiedAllConfigs(true, false, false, true);
2203 projectNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
2204 projectNode.row.tag =(int64)projectNode;
2206 projectNode.row.SetData(null, projectNode);
2207 fileList.currentRow = projectNode.row;
2209 strcpy(filePath, project.topNode.path);
2210 PathCat(filePath, projectNode.path);
2211 PathCat(filePath, projectNode.name);
2213 codeEditor = (CodeEditor)ide.FindWindow(filePath);
2216 Class baseClass = eSystem_FindClass(__thisModule, base);
2217 subclass(ClassDesignerBase) designerClass = eClass_GetDesigner(baseClass);
2220 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal, false);
2221 strcpy(name, projectNode.name);
2222 sprintf(name, "%s%d", upper, c);
2224 strcpy(className, name);
2226 designerClass.CreateNew(codeEditor.editBox, codeEditor.clientSize, name, base);
2228 //codeEditor.modifiedDocument = false;
2229 //codeEditor.designer.modifiedDocument = false;
2231 //Code_EnsureUpToDate(codeEditor);
2234 else // TODO: fix no symbols generated when ommiting {} for following else
2236 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal, false);
2238 ide.sheet.visible = true;
2239 ide.sheet.Activate();
2242 codeEditor.ViewDesigner();
2243 codeEditor.codeModified = true;
2250 // Returns true if we opened something
2251 bool OpenSelectedNodes(bool noParsing)
2253 bool result = false;
2257 fileList.GetMultiSelection(selection);
2258 for(item = selection.first; item; item = item.next)
2260 DataRow row = item.data;
2261 ProjectNode node = (ProjectNode)row.tag;
2262 if(node.type == file)
2264 OpenNode(node, noParsing);
2268 selection.Free(null);
2269 ide.RepositionWindows(false);
2273 void RemoveSelectedNodes()
2278 fileList.GetMultiSelection(selection);
2280 // Remove children of parents we're deleting
2281 for(item = selection.first; item; item = next)
2284 DataRow row = item.data;
2285 ProjectNode n, node = (ProjectNode)row.tag;
2286 bool remove = false;
2289 for(i = selection.first; i && !remove; i = i.next)
2291 ProjectNode iNode = (ProjectNode)((DataRow)i.data).tag;
2292 for(n = node.parent; n; n = n.parent)
2302 selection.Delete(item);
2305 for(item = selection.first; item; item = item.next)
2307 DataRow row = item.data;
2308 ProjectNode node = (ProjectNode)row.tag;
2309 ProjectNode resNode;
2310 for(resNode = node.parent; resNode; resNode = resNode.parent)
2311 if(resNode.type == resources)
2313 if(node.type == file)
2315 Project prj = node.project;
2317 modifiedDocument = true;
2318 prj.topNode.modified = true;
2320 prj.ModifiedAllConfigs(true, false, true, true);
2322 else if(node.type == folder)
2325 sprintf(message, $"Are you sure you want to remove the folder \"%s\"\n"
2326 "and all of its contents from the project?", node.name);
2327 if(MessageBox { master = ide, type = yesNo, text = $"Delete Folder", contents = message }.Modal() == yes)
2329 Project prj = node.project;
2330 if(node.containsFile)
2331 prj.ModifiedAllConfigs(true, false, true, true);
2333 modifiedDocument = true;
2334 prj.topNode.modified = true;
2337 else if(node.type == project && node != project.topNode && !buildInProgress)
2341 for(p : workspace.projects)
2343 if(p.topNode == node)
2349 sprintf(message, $"Are you sure you want to remove the \"%s\" project\n" "from this workspace?", node.name);
2350 if(MessageBox { master = ide, type = yesNo, text = $"Remove Project", contents = message }.Modal() == yes)
2355 workspace.RemoveProject(prj);
2356 //modifiedDocument = true; // when project view is a workspace view
2360 selection.Free(null);