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 ProjectNode GetNodeFromWindow(Window document, Project project, bool isCObject)
573 if(document.fileName)
575 char winFileName[MAX_LOCATION];
576 char * documentFileName = GetSlashPathBuffer(winFileName, document.fileName);
581 char name[MAX_FILENAME];
582 GetLastDirectory(documentFileName, name);
583 ChangeExtension(name, "ec", name);
584 for(p : ide.workspace.projects)
586 prj = project ? project : p;
587 if((node = prj.topNode.Find(name, false)))
594 for(p : ide.workspace.projects)
596 prj = project ? project : p;
597 if((node = prj.topNode.FindByFullPath(documentFileName, false)))
606 // ((( UTILITY FUNCTIONS )))
608 // ************************************************************************
609 // *** These methods below are part of a sequence of events, and as ***
610 // *** such they must be passed the current compiler and project config ***
611 // ************************************************************************
612 bool DisplayCompiler(CompilerConfig compiler, bool cleanLog)
614 ide.outputView.buildBox.Logf($"%s Compiler\n", compiler ? compiler.name : $"{problem with compiler selection}");
618 bool ProjectPrepareForToolchain(Project project, PrepareMakefileMethod method, bool cleanLog, bool displayCompiler,
619 CompilerConfig compiler, ProjectConfig config)
622 char message[MAX_F_STRING];
623 LogBox logBox = ide.outputView.buildBox;
625 ShowOutputBuildLog(cleanLog);
628 DisplayCompiler(compiler, false);
630 ProjectPrepareCompiler(project, compiler, false);
631 ProjectPrepareMakefile(project, method, compiler, config);
635 bool ProjectPrepareCompiler(Project project, CompilerConfig compiler, bool silent)
637 if((!project.GenerateCrossPlatformMk(app.includeFile) || !project.GenerateCompilerCf(compiler)) && !silent)
638 ide.outputView.buildBox.Logf($"Error generating compiler configuration (Is the project/config directory writable?)\n");
642 // Note: Compiler is only passed in to for VisualStudio support
643 bool ProjectPrepareMakefile(Project project, PrepareMakefileMethod method, CompilerConfig compiler, ProjectConfig config)
645 if(compiler.type.isVC)
647 // I'm guessing we'll want to support generating VS files on Linux as well...
648 ide.statusBar.text = $"Generating Visual Studio Solution...";
650 //GenerateVSSolutionFile(project, compiler);
651 ide.statusBar.text = $"Generating Visual Studio Project...";
653 //GenerateVCProjectFile(project, compiler, bitDepth);
654 ide.statusBar.text = null;
660 char makefilePath[MAX_LOCATION];
661 char makefileName[MAX_LOCATION];
663 LogBox logBox = ide.outputView.buildBox;
665 strcpy(makefilePath, project.topNode.path);
666 project.CatMakeFileName(makefileName, config);
667 PathCatSlash(makefilePath, makefileName);
669 exists = FileExists(makefilePath);
670 if(method == force ||
671 (method == forceExists && exists) ||
672 (method == normal && (!exists || (config && config.makingModified))))
676 ide.statusBar.text = $"Generating Makefile & Dependencies..."; // Dependencies?
679 if((method == normal && !exists) || (method == force && !exists))
680 action = $"Generating ";
681 else if(method == force)
682 action = $"Regenerating ";
683 else if(method == normal || method == forceExists)
684 action = $"Updating ";
688 reason = $"Makefile doesn't exist. ";
689 else if(project.topNode.modified)
690 reason = $"Project has been modified. ";
694 //logBox.Logf("%s\n", makefileName);
695 logBox.Logf($"%s - %s%smakefile for %s config...\n", makefileName, reason, action, GetConfigName(config));
697 if(!project.GenerateMakefile(null, false, null, config))
698 ide.outputView.buildBox.Logf($"Error generating makefile (Is the project directory writable?)\n");
700 ide.statusBar.text = null;
708 bool BuildInterrim(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config, int bitDepth, bool justPrint)
710 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
712 ide.outputView.buildBox.Logf($"Building project %s using the %s configuration...\n", prj.name, GetConfigName(config));
713 return Build(prj, buildType, compiler, config, bitDepth, justPrint);
718 bool DebugStopForMake(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config)
721 // TOFIX: DebugStop is being abused and backfiring on us.
722 // It's supposed to be the 'Debug/Stop' item, not unloading executable or anything else
724 // configIsInDebugSession seems to be used for two OPPOSITE things:
725 // If we're debugging another config, we need to unload the executable!
726 // In building, we want to stop if we're debugging the 'same' executable
727 if(buildType != run) ///* && prj == project*/ && prj.configIsInDebugSession)
729 if(buildType == start || buildType == restart)
731 if(ide.debugger && ide.debugger.isPrepared)
732 result = DebugStop();
736 if(ide.project == prj && ide.debugger && ide.debugger.prjConfig == config && ide.debugger.isPrepared)
737 result = DebugStop();
743 bool Build(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config, int bitDepth, bool justPrint)
749 for(document = master.firstChild; document; document = document.next)
751 if(document.modifiedDocument)
753 ProjectNode node = GetNodeFromWindow(document, prj, false);
754 if(node && !document.MenuFileSave(null, 0))
763 DirExpression targetDir = prj.GetTargetDir(compiler, config, bitDepth);
765 DebugStopForMake(prj, buildType, compiler, config);
767 // TODO: Disabled until problems fixed... is it fixed?
768 if(buildType == rebuild || (config && config.compilingModified))
769 prj.Clean(compiler, config, bitDepth, clean, justPrint);
772 if(buildType == relink || (config && config.linkingModified))
773 prj.Clean(compiler, config, bitDepth, cleanTarget, false);
774 if(config && config.symbolGenModified)
776 DirExpression objDir = prj.GetObjDir(compiler, config, bitDepth);
777 char fileName[MAX_LOCATION];
778 char moduleName[MAX_FILENAME];
779 strcpy(fileName, prj.topNode.path);
780 PathCatSlash(fileName, objDir.dir);
781 ReplaceSpaces(moduleName, prj.moduleName);
782 strcat(moduleName, ".main.ec");
783 PathCatSlash(fileName, moduleName);
784 if(FileExists(fileName))
785 DeleteFile(fileName);
786 ChangeExtension(fileName, "c", fileName);
787 if(FileExists(fileName))
788 DeleteFile(fileName);
789 ChangeExtension(fileName, "o", fileName);
790 if(FileExists(fileName))
791 DeleteFile(fileName);
796 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
797 ide.AdjustBuildMenus();
798 ide.AdjustDebugMenus();
800 result = prj.Build(buildType == run, null, compiler, config, bitDepth, justPrint, normal);
804 config.compilingModified = false;
806 config.linkingModified = false;
808 config.symbolGenModified = false;
810 buildInProgress = none;
811 ide.AdjustBuildMenus();
812 ide.AdjustDebugMenus();
814 ide.workspace.modified = true;
821 // ((( USER ACTIONS )))
823 // ************************************************************************
824 // *** Methods below should atomically start a process, and as such ***
825 // *** they can query compiler and config directly from ide and project ***
826 // *** but ONLY ONCE!!! ***
827 // ************************************************************************
829 bool ProjectBuild(MenuItem selection, Modifiers mods)
831 if(buildInProgress == none)
833 Project prj = project;
834 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
835 int bitDepth = ide.workspace.bitDepth;
836 ProjectConfig config;
837 if(selection || !ide.activeClient)
839 DataRow row = fileList.currentRow;
840 ProjectNode node = row ? (ProjectNode)row.tag : null;
841 if(node) prj = node.project;
845 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
850 if(/*prj != project || */!prj.GetConfigIsInDebugSession(config) || !ide.DontTerminateDebugSession($"Project Build"))
852 BuildInterrim(prj, build, compiler, config, bitDepth, mods.ctrl && mods.shift);
861 bool ProjectLink(MenuItem selection, Modifiers mods)
863 Project prj = project;
864 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
865 int bitDepth = ide.workspace.bitDepth;
866 ProjectConfig config;
867 if(selection || !ide.activeClient)
869 DataRow row = fileList.currentRow;
870 ProjectNode node = row ? (ProjectNode)row.tag : null;
871 if(node) prj = node.project;
875 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
880 if(!prj.GetConfigIsInDebugSession(config) ||
881 (!ide.DontTerminateDebugSession($"Project Link") && DebugStopForMake(prj, relink, compiler, config)))
883 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
885 ide.outputView.buildBox.Logf($"Relinking project %s using the %s configuration...\n", prj.name, GetConfigName(config));
887 config.linkingModified = true;
888 Build(prj, relink, compiler, config, bitDepth, mods.ctrl && mods.shift);
895 bool ProjectRebuild(MenuItem selection, Modifiers mods)
897 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
898 int bitDepth = ide.workspace.bitDepth;
899 Project prj = project;
900 ProjectConfig config;
901 if(selection || !ide.activeClient)
903 DataRow row = fileList.currentRow;
904 ProjectNode node = row ? (ProjectNode)row.tag : null;
905 if(node) prj = node.project;
909 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
914 if(!prj.GetConfigIsInDebugSession(config) ||
915 (!ide.DontTerminateDebugSession($"Project Rebuild") && DebugStopForMake(prj, rebuild, compiler, config)))
917 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
919 ide.outputView.buildBox.Logf($"Rebuilding project %s using the %s configuration...\n", prj.name, GetConfigName(config));
922 config.compilingModified = true;
923 config.makingModified = true;
924 }*/ // -- should this still be used depite the new solution of BuildType?
925 Build(prj, rebuild, compiler, config, bitDepth, mods.ctrl && mods.shift);
932 bool ProjectCleanTarget(MenuItem selection, Modifiers mods)
934 CleanProject($"Project Clean Target", $"Cleaning project %s target using the %s configuration...\n", selection, cleanTarget, mods.ctrl && mods.shift);
938 bool ProjectClean(MenuItem selection, Modifiers mods)
940 CleanProject($"Project Clean", $"Cleaning project %s using the %s configuration...\n", selection, clean, mods.ctrl && mods.shift);
944 bool ProjectRealClean(MenuItem selection, Modifiers mods)
946 CleanProject($"Project Real Clean", $"Removing intermediate objects directory for project %s using the %s configuration...\n", selection, realClean, mods.ctrl && mods.shift);
950 void CleanProject(char * terminateDebugSessionMessage, char * cleaningMessageLogFormat, MenuItem selection, CleanType cleanType, bool justPrint)
952 Project prj = project;
953 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
954 ProjectConfig config;
955 int bitDepth = ide.workspace.bitDepth;
956 if(selection || !ide.activeClient)
958 DataRow row = fileList.currentRow;
959 ProjectNode node = row ? (ProjectNode)row.tag : null;
960 if(node) prj = node.project;
964 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
965 if(node) prj = node.project;
968 if(!prj.GetConfigIsInDebugSession(config) ||
969 (!ide.DontTerminateDebugSession(terminateDebugSessionMessage) && DebugStopForMake(prj, clean, compiler, config)))
971 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
973 ide.outputView.buildBox.Logf(cleaningMessageLogFormat, prj.name, GetConfigName(config));
975 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
976 ide.AdjustBuildMenus();
977 ide.AdjustDebugMenus();
979 prj.Clean(compiler, config, bitDepth, cleanType, justPrint);
980 buildInProgress = none;
981 ide.AdjustBuildMenus();
982 ide.AdjustDebugMenus();
988 bool ProjectRegenerate(MenuItem selection, Modifiers mods)
990 Project prj = project;
991 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
992 ShowOutputBuildLog(true);
993 if(selection || !ide.activeClient)
995 DataRow row = fileList.currentRow;
996 ProjectNode node = row ? (ProjectNode)row.tag : null;
1002 ProjectNode node = GetNodeFromWindow(ide.activeClient, null, false);
1007 DisplayCompiler(compiler, false);
1008 ProjectPrepareCompiler(project, compiler, false);
1009 ProjectPrepareMakefile(prj, force, compiler, prj.config);
1014 bool Compile(Project project, List<ProjectNode> nodes, bool justPrint, SingleFileCompileMode mode)
1017 char fileName[MAX_LOCATION];
1019 ProjectConfig config = project.config;
1023 for(document = ide.firstChild; document; document = document.next)
1025 if(document.modifiedDocument)
1027 ProjectNode n = GetNodeFromWindow(document, project, mode == cObject ? true : false);
1030 if(n && n.IsInNode(node) && !document.MenuFileSave(null, 0))
1032 ide.outputView.buildBox.Logf($"Unable to save %s file.\n", node.name);
1042 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1043 int bitDepth = ide.workspace.bitDepth;
1045 if(ProjectPrepareForToolchain(project, normal, true, true, compiler, config))
1048 ide.outputView.buildBox.Logf($"%s specific file(s) in project %s using the %s configuration...\n",
1049 (mode == normal || mode == cObject) ? $"Compiling" : $"Debug compiling", project.name, config.name);
1051 ide.outputView.buildBox.Logf($"%s specific file(s) in project %s...\n",
1052 (mode == normal || mode == cObject) ? $"Compiling" : $"Debug compiling", project.name);
1054 buildInProgress = compilingFile;
1055 ide.AdjustBuildMenus();
1056 result = project.Compile(nodes, compiler, config, bitDepth, justPrint, mode);
1057 buildInProgress = none;
1058 ide.AdjustBuildMenus();
1065 bool Clean(Project project, List<ProjectNode> nodes, bool justPrint)
1068 char fileName[MAX_LOCATION];
1070 ProjectConfig config = project.config;
1074 for(document = ide.firstChild; document; document = document.next)
1076 if(document.modifiedDocument)
1078 ProjectNode n = GetNodeFromWindow(document, project, false);
1081 if(n && n.IsInNode(node) && !document.MenuFileSave(null, 0))
1083 ide.outputView.buildBox.Logf($"Unable to save %s file.\n", node.name);
1093 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1094 int bitDepth = ide.workspace.bitDepth;
1096 if(ProjectPrepareForToolchain(project, normal, true, true, compiler, config))
1098 Map<String, NameCollisionInfo> namesInfo { };
1099 project.topNode.GenMakefileGetNameCollisionInfo(namesInfo, config);
1102 if(node.GetIsExcluded(config))
1103 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
1107 ide.outputView.buildBox.Logf($"Deleting intermediate objects for %s %s in project %s using the %s configuration...\n",
1108 node.type == file ? $"single file" : $"folder", node.name, project.name, config.name);
1110 ide.outputView.buildBox.Logf($"Deleting intermediate objects for %s %s in project %s...\n",
1111 node.type == file ? $"single file" : $"folder", node.name, project.name);
1113 node.DeleteIntermediateFiles(compiler, config, bitDepth, namesInfo, false);
1125 bool ProjectNewFile(MenuItem selection, Modifiers mods)
1127 DataRow row = fileList.currentRow;
1130 char fileName[1024];
1131 char filePath[MAX_LOCATION];
1132 ProjectNode parentNode = (ProjectNode)row.tag;
1133 ProjectNode n, fileNode;
1134 parentNode.GetFileSysMatchingPath(filePath);
1135 MakePathRelative(filePath, parentNode.project.topNode.path, filePath);
1136 for(n = parentNode; n && n != parentNode.project.resNode; n = n.parent);
1137 sprintf(fileName, $"Untitled %d", documentID);
1138 fileNode = AddFile(parentNode, fileName, (bool)n, true);
1139 fileNode.path = CopyUnixPath(filePath);
1142 NodeProperties nodeProperties
1145 position = { position.x + 100, position.y + 100 };
1149 nodeProperties.Create(); // not modal?
1155 bool ProjectNewFolder(MenuItem selection, Modifiers mods)
1157 DataRow row = fileList.currentRow;
1160 ProjectNode parentNode = (ProjectNode)row.tag;
1161 NewFolder(parentNode, null, true);
1166 bool ResourcesAddFiles(MenuItem selection, Modifiers mods)
1172 bool ProjectAddFiles(MenuItem selection, Modifiers mods)
1178 bool ProjectImportFolder(MenuItem selection, Modifiers mods)
1180 DataRow row = fileList.currentRow;
1183 ProjectNode toNode = (ProjectNode)row.tag;
1184 ImportFolder(toNode);
1189 bool ProjectAddNewForm(MenuItem selection, Modifiers mods)
1191 CodeEditor codeEditor = CreateNew("Form", "form", "Window", null);
1192 codeEditor.EnsureUpToDate();
1196 bool ProjectAddNewGraph(MenuItem selection, Modifiers mods)
1198 CodeEditor codeEditor = CreateNew("Graph", "graph", "Block", null);
1200 codeEditor.EnsureUpToDate();
1204 bool ProjectRemove(MenuItem selection, Modifiers mods)
1206 DataRow row = fileList.currentRow;
1209 ProjectNode node = (ProjectNode)row.tag;
1210 if(node.type == project)
1211 RemoveSelectedNodes();
1216 bool ProjectUpdateMakefileForAllConfigs(Project project)
1218 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1220 // This call really does not belong here:
1221 ide.UpdateToolBarActiveConfigs(false);
1222 for(config : project.configurations)
1223 ProjectPrepareMakefile(project, forceExists, compiler, config);
1230 bool MenuSettings(MenuItem selection, Modifiers mods)
1232 ProjectNode node = GetSelectedNode(true);
1233 Project prj = node ? node.project : project;
1234 projectSettingsDialog = ProjectSettings { master = parent, project = prj, projectNode = node };
1235 incref projectSettingsDialog;
1236 projectSettingsDialog.Modal();
1237 delete projectSettingsDialog;
1238 ide.UpdateToolBarActiveConfigs(false);
1244 bool FileProperties(MenuItem selection, Modifiers mods)
1246 DataRow row = fileList.currentRow;
1249 ProjectNode node = (ProjectNode)row.tag;
1250 NodeProperties { parent = parent, master = this, node = node,
1251 position = { position.x + 100, position.y + 100 } }.Create();
1256 bool FileOpenFile(MenuItem selection, Modifiers mods)
1258 OpenSelectedNodes(mods.ctrl && mods.shift);
1262 bool FileRemoveFile(MenuItem selection, Modifiers mods)
1264 RemoveSelectedNodes();
1268 bool FileCompile(MenuItem selection, Modifiers mods)
1271 OldList selectedRows;
1272 Project project = null;
1273 List<ProjectNode> nodes { };
1274 fileList.GetMultiSelection(selectedRows);
1275 for(item = selectedRows.first; item; item = item.next)
1278 DataRow row = item.data;
1279 ProjectNode node = (ProjectNode)row.tag;
1281 project = node.project;
1282 else if(node.project != project)
1289 selectedRows.Free(null);
1291 Compile(project, nodes, mods.ctrl && mods.shift, normal);
1293 ide.outputView.buildBox.Logf($"Please select files from a single project.\n");
1298 bool FileClean(MenuItem selection, Modifiers mods)
1301 OldList selectedRows;
1302 Project project = null;
1303 List<ProjectNode> nodes { };
1304 fileList.GetMultiSelection(selectedRows);
1305 for(item = selectedRows.first; item; item = item.next)
1308 DataRow row = item.data;
1309 ProjectNode node = (ProjectNode)row.tag;
1311 project = node.project;
1312 else if(node.project != project)
1319 selectedRows.Free(null);
1321 Clean(project, nodes, mods.ctrl && mods.shift);
1323 ide.outputView.buildBox.Logf($"Please select files from a single project.\n");
1328 bool FileDebugPrecompile(MenuItem selection, Modifiers mods)
1330 DataRow row = fileList.currentRow;
1331 ProjectNode node = row ? (ProjectNode)row.tag : null;
1334 List<ProjectNode> nodes { };
1336 if(node.type == project)
1337 ProjectBuild(selection, mods);
1340 Compile(node.project, nodes, mods.ctrl && mods.shift, debugPrecompile);
1346 bool FileDebugCompile(MenuItem selection, Modifiers mods)
1348 DataRow row = fileList.currentRow;
1349 ProjectNode node = row ? (ProjectNode)row.tag : null;
1352 List<ProjectNode> nodes { };
1354 if(node.type == project)
1355 ProjectBuild(selection, mods);
1357 Compile(node.project, nodes, mods.ctrl && mods.shift, normal);
1359 Compile(node.project, nodes, mods.ctrl && mods.shift, debugCompile);
1365 bool FileDebugGenerateSymbols(MenuItem selection, Modifiers mods)
1367 DataRow row = fileList.currentRow;
1368 ProjectNode node = row ? (ProjectNode)row.tag : null;
1371 List<ProjectNode> nodes { };
1373 if(node.type == project)
1374 ProjectBuild(selection, mods);
1376 Compile(node.project, nodes, mods.ctrl && mods.shift, normal);
1378 Compile(node.project, nodes, mods.ctrl && mods.shift, debugGenerateSymbols);
1384 Project GetSelectedProject(bool useSelection)
1386 Project prj = project;
1389 DataRow row = fileList.currentRow;
1390 ProjectNode node = row ? (ProjectNode)row.tag : null;
1397 void SelectNextProject(bool backwards)
1399 DataRow row = fileList.currentRow;
1400 DataRow currentRow = row;
1401 ProjectNode node = (ProjectNode)row.tag;
1402 if(node.type != project)
1403 row = node.project.topNode.row;
1405 row = row.previous ? row.previous : fileList.lastRow;
1407 row = row.next ? row.next : fileList.firstRow;
1408 if(row && row != currentRow)
1410 fileList.SelectRow(row);
1411 fileList.currentRow = row;
1415 ProjectNode GetSelectedNode(bool useSelection)
1417 ProjectNode node = null;
1420 DataRow row = fileList.currentRow;
1422 node = (ProjectNode)row.tag;
1427 bool MenuBrowseFolder(MenuItem selection, Modifiers mods)
1429 char folder[MAX_LOCATION];
1431 ProjectNode node = GetSelectedNode(true);
1433 node = project.topNode;
1436 strcpy(folder, prj.topNode.path);
1437 if(node != prj.topNode)
1438 PathCatSlash(folder, node.path);
1443 bool Run(MenuItem selection, Modifiers mods)
1445 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1446 ProjectConfig config = project.config;
1447 int bitDepth = ide.workspace.bitDepth;
1448 String args = new char[maxPathLen];
1450 if(ide.workspace.commandLineArgs)
1451 //ide.debugger.GetCommandLineArgs(args);
1452 strcpy(args, ide.workspace.commandLineArgs);
1453 if(ide.debugger.isActive)
1454 project.Run(args, compiler, config, bitDepth);
1455 /*else if(config.targetType == sharedLibrary || config.targetType == staticLibrary)
1456 MessageBox { master = ide, type = ok, text = "Run", contents = "Shared and static libraries cannot be run like executables." }.Modal();*/
1457 else if(BuildInterrim(project, run, compiler, config, bitDepth, false))
1458 project.Run(args, compiler, config, bitDepth);
1466 bool result = false;
1467 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1468 ProjectConfig config = project.config;
1469 int bitDepth = ide.workspace.bitDepth;
1470 TargetTypes targetType = project.GetTargetType(config);
1471 if(targetType == sharedLibrary || targetType == staticLibrary)
1472 MessageBox { master = ide, type = ok, text = $"Run", contents = $"Shared and static libraries cannot be run like executables." }.Modal();
1473 else if(project.GetCompress(config))
1474 MessageBox { master = ide, text = $"Starting Debug", contents = $"Debugging compressed applications is not supported\n" }.Modal();
1475 else if(project.GetDebug(config) ||
1476 MessageBox { master = ide, type = okCancel, text = $"Starting Debug", contents = $"Attempting to debug non-debug configuration\nProceed anyways?" }.Modal() == ok)
1478 if(/*!IsProjectModified() ||*/ BuildInterrim(project, start, compiler, config, bitDepth, false))
1480 if(compiler.type.isVC)
1482 //bool result = false;
1483 char oldwd[MAX_LOCATION];
1484 PathBackup pathBackup { };
1485 char command[MAX_LOCATION];
1487 ide.SetPath(false, compiler, config, bitDepth);
1489 GetWorkingDir(oldwd, sizeof(oldwd));
1490 ChangeWorkingDir(project.topNode.path);
1492 sprintf(command, "%s /useenv %s.sln /projectconfig \"%s|Win32\" /command \"%s\"" , "devenv", project.name, config.name, "Debug.Start");
1494 ChangeWorkingDir(oldwd);
1500 ide.debugger.Start(compiler, config, bitDepth);
1509 void GoToError(const char * line, const bool noParsing)
1513 while(isspace(*line)) line++;
1514 colon = strstr(line, ":");
1519 bool lookForLineNumber = true;
1521 // deal with linking error
1522 if(colon && colon[1] == ' ')
1524 colon = strstr(colon + 1, ":");
1525 if(colon && !colon[1])
1527 colon = strstr(line, ":");
1528 lookForLineNumber = false;
1530 else if(colon && !isdigit(colon[1]))
1533 colon = strstr(line, ":");
1536 // Don't be mistaken by the drive letter colon
1537 if(colon && (colon[1] == '/' || colon[1] == '\\'))
1538 colon = strstr(colon + 1, ":");
1539 if(colon && lookForLineNumber)
1542 #if 0 // MSVS Errors -- todo fix this later
1543 char * par = RSearchString(line, "(", colon - line, true, false);
1544 if(par && strstr(par, ")"))
1546 else if((colon+1)[0] == ' ')
1548 // NOTE: This is the same thing as saying 'colon = line'
1549 for( ; colon != line; colon--)
1554 lineNumber = atoi(colon + 1);
1556 comma = strchr(colon, ',');
1558 col = atoi(comma+1);
1560 comma = strchr(colon+1, ':');
1562 col = atoi(comma+1);
1566 char moduleName[MAX_LOCATION], filePath[MAX_LOCATION] = "";
1567 char ext[MAX_EXTENSION] = "";
1569 ProjectNode node = null;
1572 char * inFileIncludedFrom = strstr(line, stringInFileIncludedFrom);
1573 char * from = strstr(line, "from ");
1574 char * start = inFileIncludedFrom ? inFileIncludedFrom + strlen(stringInFileIncludedFrom) : from ? from + strlen("from ") : line;
1578 len = Min((int)(colon - start), MAX_LOCATION-1);
1580 strncpy(moduleName, start, len);
1581 moduleName[len] = '\0';
1584 strcpy(moduleName, line);
1589 if((msg = strstr(moduleName, " - ")))
1593 for(prj : ide.workspace.projects)
1595 strcpy(filePath, prj.topNode.path);
1596 PathCatSlash(filePath, moduleName);
1597 if(FileExists(filePath).isFile)
1609 else if((msg = strstr(moduleName, "...")) && (colon = strchr(moduleName, ' ')) && (++colon)[0])
1613 for(prj : ide.workspace.projects)
1615 if((node = prj.resNode.Find(colon, true)))
1617 strcpy(filePath, prj.topNode.path);
1618 PathCatSlash(filePath, node.path);
1619 PathCatSlash(filePath, node.name);
1633 // Remove stuff in brackets
1635 bracket = strstr(moduleName, "(");
1636 if(bracket) *bracket = '\0';
1638 MakeSlashPath(moduleName);
1639 GetExtension(moduleName, ext);
1641 if(!colon && !filePath[0])
1643 bool dotMain = false;
1644 // Check if it's one of our modules
1645 node = project.topNode.Find(moduleName, false);
1648 strcpy(filePath, node.path);
1649 PathCatSlash(filePath, node.name);
1653 IntermediateFileType type = none;
1654 ProjectConfig config;
1657 char ext2[MAX_EXTENSION];
1658 char stripExt[MAX_LOCATION];
1659 strcpy(stripExt, moduleName);
1660 StripExtension(stripExt);
1661 GetExtension(stripExt, ext2);
1662 if(ext2[0] && !strcmp(ext2, "main"))
1664 if(!strcmp(ext, "ec"))
1666 else if(!strcmp(ext, "c"))
1668 else if(!strcmp(ext, "sym"))
1670 else if(!strcmp(ext, "imp"))
1672 else if(!strcmp(ext, "bowl"))
1674 else if(!strcmp(ext, "o"))
1679 for(prj : ide.workspace.projects; prj.lastBuildConfigName)
1681 if((config = prj.GetConfig(prj.lastBuildConfigName)))
1682 node = prj.FindNodeByObjectFileName(moduleName, type, dotMain, config);
1690 char name[MAX_FILENAME];
1691 Project project = node.project;
1692 CompilerConfig compiler = ideSettings.GetCompilerConfig(project.lastBuildCompilerName);
1695 int bitDepth = ide.workspace.bitDepth;
1696 DirExpression objDir = project.GetObjDir(compiler, config, bitDepth);
1697 strcpy(filePath, project.topNode.path);
1698 PathCatSlash(filePath, objDir.dir);
1699 node.GetObjectFileName(name, project.lastBuildNamesInfo, type, dotMain);
1700 PathCatSlash(filePath, name);
1709 if(!strcmp(ext, "a") || !strcmp(ext, "o") || !strcmp(ext, "lib") ||
1710 !strcmp(ext, "dll") || !strcmp(ext, "exe") || !strcmp(ext, "mo"))
1711 moduleName[0] = 0; // Avoid opening binary files
1714 CodeEditor codeEditor;
1717 strcpy(filePath, project.topNode.path);
1718 PathCatSlash(filePath, moduleName);
1721 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal, noParsing);
1722 if(!codeEditor && !strcmp(ext, "c"))
1724 char ecName[MAX_LOCATION];
1725 ChangeExtension(filePath, "ec", ecName);
1726 codeEditor = (CodeEditor)ide.OpenFile(ecName, normal, true, null, no, normal, noParsing);
1730 char path[MAX_LOCATION];
1731 // TOFIX: Improve on this, don't use only filename, make a function
1732 if(ide && ide.workspace)
1734 for(prj : ide.workspace.projects)
1737 MakePathRelative(filePath, prj.topNode.path, path);
1739 if((node = prj.topNode.FindWithPath(path, false)))
1741 strcpy(filePath, prj.topNode.path);
1742 PathCatSlash(filePath, node.path);
1743 PathCatSlash(filePath, node.name);
1744 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal, noParsing);
1749 if(!codeEditor && !strchr(moduleName, '/') && !strchr(moduleName, '\\'))
1751 for(prj : ide.workspace.projects)
1754 if((node = prj.topNode.Find(moduleName, false)))
1756 strcpy(filePath, prj.topNode.path);
1757 PathCatSlash(filePath, node.path);
1758 PathCatSlash(filePath, node.name);
1759 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal, noParsing);
1767 if(codeEditor && lineNumber)
1769 EditBox editBox = codeEditor.editBox;
1770 editBox.GoToLineNum(lineNumber - 1);
1771 editBox.GoToPosition(editBox.line, lineNumber - 1, col ? (col - 1) : 0);
1778 bool OpenNode(ProjectNode node, bool noParsing)
1780 char filePath[MAX_LOCATION];
1781 node.GetFullFilePath(filePath);
1782 return ide.OpenFile(filePath, normal, true/*false Why was it opening hidden?*/, null, something, normal, noParsing) ? true : false;
1785 void AddNode(ProjectNode node, DataRow addTo)
1787 DataRow row = addTo ? addTo.AddRow() : fileList.AddRow();
1789 row.tag = (int64)node;
1792 if(node.type == resources)
1795 row.SetData(null, node);
1797 if(node.files && node.files.first && node.parent &&
1798 !(!node.parent.parent &&
1799 (!strcmpi(node.name, "notes") || !strcmpi(node.name, "sources") ||
1800 !strcmpi(node.name, "src") || !strcmpi(node.name, "tools"))))
1801 row.collapsed = true;
1802 else if(node.type == folder)
1803 node.icon = openFolder;
1807 for(child : node.files)
1808 AddNode(child, row);
1812 void DeleteNode(ProjectNode projectNode)
1814 if(projectNode.files)
1817 while(child = projectNode.files.first)
1820 fileList.DeleteRow(projectNode.row);
1821 projectNode.Delete();
1824 bool ProjectSave(MenuItem selection, Modifiers mods)
1826 DataRow row = fileList.currentRow;
1827 ProjectNode node = row ? (ProjectNode)row.tag : null;
1828 Project prj = node ? node.project : null;
1831 prj.StopMonitoring();
1832 if(prj.Save(prj.filePath))
1834 Project modPrj = null;
1835 prj.topNode.modified = false;
1836 for(p : ide.workspace.projects)
1838 if(p.topNode.modified)
1845 modifiedDocument = false;
1848 prj.StartMonitoring();
1853 bool ShowOutputBuildLog(bool cleanLog)
1855 OutputView output = ide.outputView;
1857 output.ShowClearSelectTab(build);
1860 output.SelectTab(build);
1868 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1869 ProjectConfig config = project.config;
1870 int bitDepth = ide.workspace.bitDepth;
1872 bool result = false;
1873 if(/*!IsProjectModified() ||*/ BuildInterrim(project, restart, compiler, config, bitDepth, false))
1875 // For Restart, compiler and config will only be used if for
1876 // whatever reason (if at all possible) the Debugger is in a
1877 // 'terminated' or 'none' state
1878 ide.debugger.Restart(compiler, config, bitDepth);
1888 ide.debugger.Resume();
1894 ide.debugger.Break();
1900 ide.debugger.Stop();
1904 bool DebugStepInto()
1906 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1907 ProjectConfig config = project.config;
1908 int bitDepth = ide.workspace.bitDepth;
1910 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config, bitDepth, false)))
1911 ide.debugger.StepInto(compiler, config, bitDepth);
1916 bool DebugStepOver(bool skip)
1918 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1919 ProjectConfig config = project.config;
1920 int bitDepth = ide.workspace.bitDepth;
1922 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config, bitDepth, false)))
1923 ide.debugger.StepOver(compiler, config, bitDepth, skip);
1929 bool DebugStepOut(bool skip)
1931 ide.debugger.StepOut(skip);
1935 void ImportFolder(ProjectNode toNode)
1939 //bool isFolder = toNode.type == folder;
1940 //bool isRes = toNode.isInResources;
1942 FileDialog fileDialog = importFileDialog;
1943 fileDialog.master = parent;
1944 if(fileDialog.Modal() == ok)
1946 ImportFolderFSI fsi { projectView = this };
1947 fsi.stack.Add(toNode);
1948 fsi.Iterate(fileDialog.filePath);
1954 ProjectNode NewFolder(ProjectNode parentNode, char * name, bool showProperties)
1958 ProjectNode folderNode;
1959 Project prj = parentNode.project;
1961 ProjectNode after = null;
1962 for(node : parentNode.files)
1964 if(node.type != folder)
1970 folderNode = parentNode.Add(prj, name, after, folder, folder, true);
1973 for(c = 0; c < 100; c++)
1976 sprintf(string, c ? "New Folder (%d)" : "New Folder", c);
1977 if((folderNode = parentNode.Add(prj, string, after, folder, folder, true)))
1984 NodeProperties nodeProperties;
1987 modifiedDocument = true;
1988 prj.topNode.modified = true;
1991 folderNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
1992 folderNode.row.tag = (int64)folderNode;
1994 folderNode.row.SetData(null, folderNode);
1995 fileList.currentRow = folderNode.row;
1999 nodeProperties = NodeProperties
2001 parent, this, mode = newFolder, node = folderNode;
2002 position = { position.x + 100, position.y + 100 };
2004 nodeProperties.Create(); // Modal?
2012 void AddFiles(bool resources)
2014 FileDialog fileDialog = (!resources) ? this.fileDialog : resourceFileDialog;
2015 fileDialog.type = multiOpen;
2016 fileDialog.text = !resources ? $"Add Files to Project" : $"Add Resources to Project";
2017 fileDialog.master = parent;
2019 if(fileDialog.Modal() == ok)
2022 DataRow row = fileList.currentRow;
2023 ProjectNode parentNode = (ProjectNode)row.tag;
2024 bool addFailed = false;
2025 int numSelections = fileDialog.numSelections;
2026 char ** multiFilePaths = fileDialog.multiFilePaths;
2028 Array<String> nameConflictFiles { };
2030 for(c = 0; c < numSelections; c++)
2032 char * filePath = multiFilePaths[c];
2033 FileAttribs exists = FileExists(filePath);
2034 bool addThisFile = true;
2036 if(exists.isDirectory)
2037 addThisFile = false;
2040 if(MessageBox { master = ide, type = yesNo, text = filePath,
2041 contents = $"File doesn't exist. Create?" }.Modal() == yes)
2043 File f = FileOpen(filePath, write);
2051 MessageBox { master = ide, type = ok, text = filePath,
2052 contents = $"Couldn't create file."}.Modal();
2053 addThisFile = false;
2060 /*addFailed = */if(!AddFile(parentNode, filePath, resources, false))//;
2062 nameConflictFiles.Add(CopyString(filePath));
2070 char * part1 = $"The following file";
2071 char * opt1 = $" was ";
2072 char * opt2 = $"s were ";
2073 char * part2 = $"not added because of identical file name conflict within the project.\n\n";
2075 len += strlen(part1);
2076 len += strlen(part2);
2077 len += nameConflictFiles.count > 1 ? strlen(opt2) : strlen(opt1);
2078 for(s : nameConflictFiles)
2079 len += strlen(s) + 1;
2080 message = new char[len + 1];
2081 strcpy(message, part1);
2082 strcat(message, nameConflictFiles.count > 1 ? opt2 : opt1);
2083 strcat(message, part2);
2084 for(s : nameConflictFiles)
2087 strcat(message, "\n");
2089 MessageBox { master = ide, type = ok, text = $"Name Conflict",
2090 contents = message }.Modal();
2093 nameConflictFiles.Free();
2094 delete nameConflictFiles;
2098 ProjectNode AddFile(ProjectNode parentNode, char * filePath, bool resources, bool isTemporary)
2100 ProjectNode result = null;
2101 ProjectNode after = null;
2102 for(node : parentNode.files)
2104 if(node.type != folder && node.type != file && node.type)
2109 result = parentNode.Add(parentNode.project, filePath, after, file, NodeIcons::SelectFileIcon(filePath), !resources);
2115 modifiedDocument = true;
2116 parentNode.project.topNode.modified = true;
2117 parentNode.project.ModifiedAllConfigs(true, false, true, true);
2120 result.row = parentNode.row.AddRowAfter(after ? after.row : null);
2121 result.row.tag = (int64)result;
2122 result.row.SetData(null, result);
2127 CodeEditor CreateNew(char * upper, char * lower, char * base, char * className)
2129 CodeEditor codeEditor = null;
2130 ProjectNode projectNode;
2131 ProjectNode after = null;
2132 DataRow row = fileList.currentRow;
2133 ProjectNode parentNode;
2136 if(!row) row = project.topNode.row;
2138 parentNode = (ProjectNode)row.tag;
2140 for(node : parentNode.files)
2142 if(node.type != folder && node.type != file && node.type)
2146 for(c = 1; c < 100; c++)
2149 sprintf(string, c ? "%s%d.ec" : "%s.ec", lower, c);
2150 if((projectNode = parentNode.Add(project, string, after, file, genFile, true)))
2156 char filePath[MAX_LOCATION];
2158 modifiedDocument = true;
2159 project.topNode.modified = true;
2161 project.ModifiedAllConfigs(true, false, false, true);
2162 projectNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
2163 projectNode.row.tag =(int64)projectNode;
2165 projectNode.row.SetData(null, projectNode);
2166 fileList.currentRow = projectNode.row;
2168 strcpy(filePath, project.topNode.path);
2169 PathCat(filePath, projectNode.path);
2170 PathCat(filePath, projectNode.name);
2172 codeEditor = (CodeEditor)ide.FindWindow(filePath);
2175 Class baseClass = eSystem_FindClass(__thisModule, base);
2176 subclass(ClassDesignerBase) designerClass = eClass_GetDesigner(baseClass);
2179 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal, false);
2180 strcpy(name, projectNode.name);
2181 sprintf(name, "%s%d", upper, c);
2183 strcpy(className, name);
2185 designerClass.CreateNew(codeEditor.editBox, codeEditor.clientSize, name, base);
2187 //codeEditor.modifiedDocument = false;
2188 //codeEditor.designer.modifiedDocument = false;
2190 //Code_EnsureUpToDate(codeEditor);
2193 else // TODO: fix no symbols generated when ommiting {} for following else
2195 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal, false);
2197 ide.sheet.visible = true;
2198 ide.sheet.Activate();
2201 codeEditor.ViewDesigner();
2202 codeEditor.codeModified = true;
2209 // Returns true if we opened something
2210 bool OpenSelectedNodes(bool noParsing)
2212 bool result = false;
2216 fileList.GetMultiSelection(selection);
2217 for(item = selection.first; item; item = item.next)
2219 DataRow row = item.data;
2220 ProjectNode node = (ProjectNode)row.tag;
2221 if(node.type == file)
2223 OpenNode(node, noParsing);
2227 selection.Free(null);
2228 ide.RepositionWindows(false);
2232 void RemoveSelectedNodes()
2237 fileList.GetMultiSelection(selection);
2239 // Remove children of parents we're deleting
2240 for(item = selection.first; item; item = next)
2243 DataRow row = item.data;
2244 ProjectNode n, node = (ProjectNode)row.tag;
2245 bool remove = false;
2248 for(i = selection.first; i && !remove; i = i.next)
2250 ProjectNode iNode = (ProjectNode)((DataRow)i.data).tag;
2251 for(n = node.parent; n; n = n.parent)
2261 selection.Delete(item);
2264 for(item = selection.first; item; item = item.next)
2266 DataRow row = item.data;
2267 ProjectNode node = (ProjectNode)row.tag;
2268 ProjectNode resNode;
2269 for(resNode = node.parent; resNode; resNode = resNode.parent)
2270 if(resNode.type == resources)
2272 if(node.type == file)
2274 Project prj = node.project;
2276 modifiedDocument = true;
2277 prj.topNode.modified = true;
2279 prj.ModifiedAllConfigs(true, false, true, true);
2281 else if(node.type == folder)
2284 sprintf(message, $"Are you sure you want to remove the folder \"%s\"\n"
2285 "and all of its contents from the project?", node.name);
2286 if(MessageBox { master = ide, type = yesNo, text = $"Delete Folder", contents = message }.Modal() == yes)
2288 Project prj = node.project;
2289 if(node.containsFile)
2290 prj.ModifiedAllConfigs(true, false, true, true);
2292 modifiedDocument = true;
2293 prj.topNode.modified = true;
2296 else if(node.type == project && node != project.topNode && !buildInProgress)
2300 for(p : workspace.projects)
2302 if(p.topNode == node)
2308 sprintf(message, $"Are you sure you want to remove the \"%s\" project\n" "from this workspace?", node.name);
2309 if(MessageBox { master = ide, type = yesNo, text = $"Remove Project", contents = message }.Modal() == yes)
2314 workspace.RemoveProject(prj);
2315 //modifiedDocument = true; // when project view is a workspace view
2319 selection.Free(null);