3 import "FileSystemIterator"
5 class ImportFolderFSI : NormalFileSystemIterator
7 ProjectView projectView;
8 Array<ProjectNode> stack { };
10 bool OnFolder(char * folderPath)
12 char name[MAX_LOCATION];
13 ProjectNode parentNode = stack.lastIterator.data;
15 GetLastDirectory(folderPath, name);
16 folder = parentNode.FindSpecial(name, false, true, true);
18 folder = projectView.NewFolder(parentNode, name, false);
23 void OutFolder(char * folderPath, bool isRoot)
25 stack.lastIterator.Remove(); //stack.Remove();
28 bool OnFile(char * filePath)
30 ProjectNode parentNode = stack.lastIterator.data;
31 projectView.AddFile(parentNode, filePath, parentNode.isInResources, false);
36 static Array<FileFilter> fileFilters
38 { $"eC/C/C++ Files (*.ec, *.eh, *.c, *.cpp, *.cc, *.cxx, *.h, *.hpp, *.hh, *.hxx)", "ec, eh, c, cpp, cc, cxx, h, hpp, hh, hxx" },
39 { $"eC/C/C++ Source Files (*.ec, *.c, *.cpp, *.cc, *.cxx)", "ec, eh, c, cpp, cc, cxx" },
40 { $"Header Files for eC/C/C++ (*.eh, *.h, *.hpp, *.hh, *.hxx)", "eh, h, hpp, hh, hxx" },
41 { $"All files", null }
44 static Array<FileFilter> resourceFilters
46 { $"Image Files (*.jpg, *.jpeg, *.bmp, *.pcx, *.png,*.gif)", "jpg, jpeg, bmp, pcx, png, gif" },
47 { $"3D Studio Model Files (*.3ds)", "3ds" },
48 { $"Translations (*.mo)", "mo" },
49 { $"All files", null }
52 static Array<FileFilter> projectFilters
54 { $"Project Files (*.epj)", ProjectExtension },
55 { $"Workspace Files (*.ews)", WorkspaceExtension }
58 static Array<FileType> projectTypes
60 { $"Ecere IDE Project", ProjectExtension },
61 { $"Ecere IDE Workspace", WorkspaceExtension }
64 static char * iconNames[] =
66 "<:ecere>mimeTypes/file.png", /*genFile*/
67 "<:ecere>mimeTypes/textEcereWorkspace.png", /*ewsFile*/
68 "<:ecere>mimeTypes/textEcereProject.png", /*epjFile*/
69 "<:ecere>places/folder.png", /*folder*/
70 "<:ecere>status/folderOpen.png", /*openFolder*/
71 "<:ecere>mimeTypes/textEcereSource.png", /*ecFile*/
72 "<:ecere>mimeTypes/textEcereHeader.png", /*ehFile*/
73 "<:ecere>mimeTypes/textCSource.png", /*sFile*/ // TODO: change sFile icon to differentiate from cFile icon
74 "<:ecere>mimeTypes/textCSource.png", /*cFile*/
75 "<:ecere>mimeTypes/textCHeader.png", /*hFile*/
76 "<:ecere>mimeTypes/textC++Source.png", /*cppFile*/
77 "<:ecere>mimeTypes/textC++Header.png", /*hppFile*/
78 "<:ecere>mimeTypes/text.png", /*textFile*/
79 "<:ecere>mimeTypes/textHyperTextMarkup.png", /*webFile*/
80 "<:ecere>mimeTypes/image.png", /*pictureFile*/
81 "<:ecere>status/audioVolumeHigh.png", /*soundFile*/
82 "<:ecere>mimeTypes/package.png", /*archiveFile*/
83 "<:ecere>mimeTypes/packageSoftware.png", /*packageFile*/
84 "<:ecere>mimeTypes/packageOpticalDisc.png", /*opticalMediaImageFile*/
85 "<:ecere>mimeTypes/file.png" /*mFile*/ //TODO: create icon for mfile
88 enum PrepareMakefileMethod { normal, force, forceExists };
90 enum BuildType { build, rebuild, relink, run, start, restart, clean };
93 none, buildingMainProject, buildingSecondaryProject, compilingFile;
95 property bool { get { return this != none; } }
96 //property bool actualBuild { get { return this == buildingMainProject || this == buildingSecondaryProject; } }
99 class ProjectView : Window
102 //hasMinimize = true;
104 borderStyle = sizable;
105 hasHorzScroll = true;
106 hasVertScroll = true;
109 anchor = Anchor { left = 0, top = 0, bottom = 0 };
112 //hasMinimize = true;
113 saveDialog = projectFileDialog;
116 BuildState buildInProgress;
117 BitmapResource icons[NodeIcons];
120 property Workspace workspace
126 for(prj : workspace.projects)
128 DeleteNode(prj.topNode);
130 workspace.projects.Free();
131 ide.debugger.CleanUp();
136 fileDialog.currentDirectory = workspace.workspaceDir;
137 resourceFileDialog.currentDirectory = workspace.workspaceDir;
138 for(prj : workspace.projects)
139 AddNode(prj.topNode, null);
140 ide.statusBar.text = $"Generating Makefile & Dependencies...";
142 for(prj : workspace.projects)
143 prj.ModifiedAllConfigs(true, false, false, false);
144 ide.statusBar.text = $"Initializing Debugger"; app.UpdateDisplay();
145 ide.statusBar.text = null;
149 get { return workspace; }
152 bool drawingInProjectSettingsDialog;
153 bool drawingInProjectSettingsDialogHeader;
154 ProjectSettings projectSettingsDialog;
162 for(c = 0; c < NodeIcons::enumSize; c++)
164 icons[c] = BitmapResource { iconNames[c], alphaBlend = true };
165 AddResource(icons[c]);
167 fileList.AddField(DataField { dataType = class(ProjectNode), freeData = false, userData = this });
173 ide.DestroyTemporaryProjectDir();
183 multiSelect = true, fullRowSelect = false, hasVertScroll = true, hasHorzScroll = true;
184 borderStyle = deep, parent = this, collapseControl = true, treeBranches = true;
185 anchor = Anchor { left = 0, right = 0, top = 0 , bottom = 0 };
187 background = projectViewBackground;
188 foreground = projectViewText;
189 selectionColor = selectionColor, selectionText = selectionText;
190 stippleColor = skyBlue;
192 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
194 if(!active) Update(null);
195 return ListBox::OnActivate(active, previous, goOnWithActivation, direct);
198 bool NotifyDoubleClick(ListBox listBox, int x, int y, Modifiers mods)
200 // Prevent the double click from reactivating the project view (returns false if we opened something)
201 return !OpenSelectedNodes();
204 bool NotifyRightClick(ListBox listBox, int x, int y, Modifiers mods)
206 DataRow row = listBox.currentRow;
209 ProjectNode node = (ProjectNode)row.tag;
210 if(node.type == NodeTypes::project || node.type == resources || node.type == file || node.type == folder)
212 bool buildMenuUnavailable = buildInProgress;
213 Menu popupContent { };
215 if(node.type == NodeTypes::project)
217 //if(node == ((Project)workspace.projects.first).topNode)
219 MenuItem { popupContent, $"Build", b, NotifySelect = ProjectBuild }.disabled = buildMenuUnavailable;
220 MenuItem { popupContent, $"Relink", l, NotifySelect = ProjectLink }.disabled = buildMenuUnavailable;
221 MenuItem { popupContent, $"Rebuild", r, NotifySelect = ProjectRebuild }.disabled = buildMenuUnavailable;
222 MenuItem { popupContent, $"Clean", c, NotifySelect = ProjectClean }.disabled = buildMenuUnavailable;
223 MenuItem { popupContent, $"Real Clean", d, NotifySelect = ProjectRealClean }.disabled = buildMenuUnavailable;
224 MenuItem { popupContent, $"Regenerate Makefile", m, NotifySelect = ProjectRegenerate }.disabled = buildMenuUnavailable;
225 MenuDivider { popupContent };
227 MenuItem { popupContent, $"Debug Generate Symbols", l, NotifySelect = FileDebugGenerateSymbols }.disabled = buildMenuUnavailable;
228 MenuDivider { popupContent };
229 MenuItem { popupContent, $"New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
230 MenuItem { popupContent, $"New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
231 MenuItem { popupContent, $"Import Folder...", i, NotifySelect = ProjectImportFolder };
232 MenuItem { popupContent, $"Add Files to Project...", f, NotifySelect = ProjectAddFiles };
233 MenuDivider { popupContent };
234 MenuItem { popupContent, $"Add New Form...", o, NotifySelect = ProjectAddNewForm };
235 // MenuItem { popupContent, "Add New Behavior Graph...", g, NotifySelect = ProjectAddNewGraph };
236 MenuDivider { popupContent };
237 if(node != ((Project)workspace.projects.first).topNode)
239 MenuItem { popupContent, $"Remove project from workspace", r, NotifySelect = ProjectRemove }.disabled = buildMenuUnavailable;
240 MenuDivider { popupContent };
242 MenuItem { popupContent, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
243 MenuDivider { popupContent };
244 MenuItem { popupContent, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
245 MenuDivider { popupContent };
246 MenuItem { popupContent, $"Save", v, Key { s, ctrl = true }, NotifySelect = ProjectSave }.disabled = !node.modified;
247 MenuDivider { popupContent };
248 MenuItem { popupContent, $"Properties...", p, Key { enter, alt = true }, NotifySelect = FileProperties };
250 else if(node.type == resources)
252 MenuItem { popupContent, $"New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
253 MenuItem { popupContent, $"New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
254 MenuItem { popupContent, $"Import Folder...", i, NotifySelect = ProjectImportFolder };
255 MenuItem { popupContent, $"Add Resources to Project...", f, NotifySelect = ResourcesAddFiles };
256 MenuItem { popupContent, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
257 MenuDivider { popupContent };
258 MenuItem { popupContent, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
259 MenuItem { popupContent, $"Properties...", p, Key { enter, alt = true }, NotifySelect = FileProperties };
261 else if(node.type == file)
263 MenuItem { popupContent, $"Open", o, NotifySelect = FileOpenFile };
264 MenuDivider { popupContent };
265 MenuItem { popupContent, $"Clean", l, NotifySelect = FileClean }.disabled = buildMenuUnavailable;
266 MenuItem { popupContent, $"Compile", c, Key { f7, ctrl = true}, NotifySelect = FileCompile }.disabled = buildMenuUnavailable;
267 MenuDivider { popupContent };
268 MenuItem { popupContent, $"Debug Precompile", l, NotifySelect = FileDebugPrecompile }.disabled = buildMenuUnavailable;
269 MenuItem { popupContent, $"Debug Compile", l, NotifySelect = FileDebugCompile }.disabled = buildMenuUnavailable;
270 MenuDivider { popupContent };
271 MenuItem { popupContent, $"Remove", r, NotifySelect = FileRemoveFile };
272 MenuDivider { popupContent };
273 MenuItem { popupContent, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
274 MenuDivider { popupContent };
275 MenuItem { popupContent, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
276 MenuItem { popupContent, $"Properties..", p, Key { enter, alt = true }, NotifySelect = FileProperties };
278 else if(node.type == folder)
280 bool isInResources = node.isInResources;
282 MenuItem { popupContent, $"New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
283 MenuItem { popupContent, $"New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
284 MenuItem { popupContent, $"Import Folder...", i, NotifySelect = ProjectImportFolder };
287 MenuItem { popupContent, $"Add Resources to Folder...", f, NotifySelect = ResourcesAddFiles };
291 MenuItem { popupContent, $"Add Files to Folder...", f, NotifySelect = ProjectAddFiles };
295 MenuDivider { popupContent };
296 MenuItem { popupContent, $"Add New Form...", o, NotifySelect = ProjectAddNewForm };
297 MenuItem { popupContent, $"Add New Behavior Graph...", g, NotifySelect = ProjectAddNewGraph };
299 MenuDivider { popupContent };
300 MenuItem { popupContent, $"Clean", l, NotifySelect = FileClean }.disabled = buildMenuUnavailable;
301 MenuItem { popupContent, $"Compile", c, Key { f7, ctrl = true}, NotifySelect = FileCompile }.disabled = buildMenuUnavailable;
302 MenuDivider { popupContent };
303 MenuItem { popupContent, $"Remove", r, NotifySelect = FileRemoveFile };
304 MenuDivider { popupContent };
305 MenuItem { popupContent, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
306 MenuDivider { popupContent };
307 MenuItem { popupContent, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
308 MenuItem { popupContent, $"Properties...", p, Key { enter, alt = true }, NotifySelect = FileProperties };
313 master = this, menu = popupContent;
315 x + clientStart.x + absPosition.x - app.desktop.position.x,
316 y + clientStart.y + absPosition.y - app.desktop.position.y };
318 void NotifyDestroyed(Window window, DialogResult result)
329 bool NotifyKeyHit(ListBox listBox, DataRow row, Key key, unichar ch)
331 if(key == altUp || key == altDown)
333 SelectNextProject(key == altUp);
339 bool NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch)
343 ProjectNode node = (ProjectNode)row.tag;
346 case altEnter: case Key { keyPadEnter, alt = true }:
348 NodeProperties { parent = parent, master = this,
349 position = { position.x + 100, position.y + 100 }, node = node }.Create();
352 case enter: case keyPadEnter:
355 for(resNode = node.parent; resNode; resNode = resNode.parent)
356 if(resNode.type == resources)
358 if(node.type == project || (node.type == folder && !resNode))
363 else if(node.type == resources || node.type == folder)
372 if(node.type == project || node.type == folder || node.type == resources)
381 if(node.type == project || node.type == folder || node.type == resources)
383 NewFolder(node, null, true);
390 if(node.type == file)
392 FileCompile(null, (Modifiers)key);
397 case Key { space, shift = true }:
400 if(node.type == NodeTypes::project)
403 for(p : workspace.projects)
405 if(p.topNode == node)
411 prj.RotateActiveConfig(!key.shift);
422 case enter: case keyPadEnter: OpenSelectedNodes(); break;
423 case del: RemoveSelectedNodes(); break;
426 Window activeClient = ide.activeClient;
428 activeClient.Activate();
430 ide.RepositionWindows(true);
437 bool NotifyCollapse(ListBox listBox, DataRow row, bool collapsed)
439 ProjectNode node = (ProjectNode)row.tag;
440 if(node.type == folder)
441 node.icon = collapsed ? folder : openFolder;
446 FileDialog importFileDialog { autoCreate = false, type = selectDir, text = $"Import Folder" };
447 FileDialog projectFileDialog
449 autoCreate = false, filters = projectFilters.array, sizeFilters = projectFilters.count * sizeof(FileFilter);
450 types = projectTypes.array, sizeTypes = projectTypes.count * sizeof(FileType);
452 FileDialog fileDialog
454 autoCreate = false, mayNotExist = true, filters = fileFilters.array, sizeFilters = fileFilters.count * sizeof(FileFilter);
456 FileDialog resourceFileDialog
458 autoCreate = false, mayNotExist = true, filters = resourceFilters.array, sizeFilters = resourceFilters.count * sizeof(FileFilter);
461 Menu fileMenu { menu, $"File", f };
462 MenuItem { fileMenu, $"Save", s, Key { s, ctrl = true }, NotifySelect = MenuFileSave };
463 // MenuItem { fileMenu, "Save As...", a, NotifySelect = MenuFileSaveAs };
465 bool OnClose(bool parentClosing)
467 if(!parentClosing && visible)
477 DialogResult dialogRes;
480 strcpy(msg, $"You have modified projects.\nSave changes to ");
481 for(p : ide.workspace.projects)
483 if(p.topNode.modified)
485 if(!first) strcat(msg, ", ");
492 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = msg }.Modal();
496 // TOFIX: Precomp error if brackets are taken out
497 return (DialogResult)MenuFileSave(null, 0) != cancel;
499 else if(dialogRes == cancel)
501 modifiedDocument = false;
508 //if(ide.findInFilesDialog && ide.findInFilesDialog.created && ide.findInFilesDialog.mode != directory)
509 // ide.findInFilesDialog.SearchStop();
511 ide.outputView.buildBox.Clear();
512 ide.outputView.debugBox.Clear();
513 //ide.outputView.findBox.Clear();
514 ide.callStackView.Clear();
515 ide.watchesView.Clear();
516 ide.threadsView.Clear();
517 ide.breakpointsView.Clear();
518 ide.outputView.ShowClearSelectTab(find); // why this?
521 bool OnSaveFile(char * fileName)
523 for(prj : ide.workspace.projects)
525 if(prj.topNode.modified)
527 prj.StopMonitoring();
528 if(prj.Save(prj.filePath))
529 prj.topNode.modified = false;
530 prj.StartMonitoring();
533 modifiedDocument = false;
538 bool IsModuleInProject(char * filePath)
540 char moduleName[MAX_FILENAME]; //, modulePath[MAX_LOCATION];
541 GetLastDirectory(filePath, moduleName);
542 return project.topNode.Find(moduleName, false) != null;
545 bool GetRelativePath(char * filePath, char * relativePath)
547 return project.GetRelativePath(filePath, relativePath);
550 ProjectNode GetNodeFromWindow(Window document, Project project)
552 if(document.fileName)
554 char winFileName[MAX_LOCATION];
555 char * documentFileName = GetSlashPathBuffer(winFileName, document.fileName);
556 for(p : ide.workspace.projects)
558 Project prj = project ? project : p;
560 if((node = prj.topNode.FindByFullPath(documentFileName, false)))
568 // ((( UTILITY FUNCTIONS )))
570 // ************************************************************************
571 // *** These methods below are part of a sequence of events, and as ***
572 // *** such they must be passed the current compiler and project config ***
573 // ************************************************************************
574 bool DisplayCompiler(CompilerConfig compiler, bool cleanLog)
576 ide.outputView.buildBox.Logf($"%s Compiler\n", compiler ? compiler.name : $"{problem with compiler selection}");
580 bool ProjectPrepareForToolchain(Project project, PrepareMakefileMethod method, bool cleanLog, bool displayCompiler,
581 CompilerConfig compiler, ProjectConfig config)
584 char message[MAX_F_STRING];
585 LogBox logBox = ide.outputView.buildBox;
587 ShowOutputBuildLog(cleanLog);
590 DisplayCompiler(compiler, false);
592 ProjectPrepareCompiler(project, compiler);
593 ProjectPrepareMakefile(project, method, compiler, config);
597 bool ProjectPrepareCompiler(Project project, CompilerConfig compiler)
599 if(!project.GenerateCrossPlatformMk() || !project.GenerateCompilerCf(compiler))
600 ide.outputView.buildBox.Logf($"Error generating compiler configuration (Is the project/config directory writable?)\n");
604 // Note: Compiler is only passed in to for VisualStudio support
605 bool ProjectPrepareMakefile(Project project, PrepareMakefileMethod method, CompilerConfig compiler, ProjectConfig config)
607 if(compiler.type.isVC)
609 // I'm guessing we'll want to support generating VS files on Linux as well...
610 ide.statusBar.text = $"Generating Visual Studio Solution...";
612 //GenerateVSSolutionFile(project, compiler);
613 ide.statusBar.text = $"Generating Visual Studio Project...";
615 //GenerateVCProjectFile(project, compiler);
616 ide.statusBar.text = null;
622 char makefilePath[MAX_LOCATION];
623 char makefileName[MAX_LOCATION];
625 LogBox logBox = ide.outputView.buildBox;
627 strcpy(makefilePath, project.topNode.path);
628 project.CatMakeFileName(makefileName, config);
629 PathCatSlash(makefilePath, makefileName);
631 exists = FileExists(makefilePath);
632 if(method == force ||
633 (method == forceExists && exists) ||
634 (method == normal && (!exists || (config && config.makingModified))))
638 ide.statusBar.text = $"Generating Makefile & Dependencies..."; // Dependencies?
641 if((method == normal && !exists) || (method == force && !exists))
642 action = $"Generating ";
643 else if(method == force)
644 action = $"Regenerating ";
645 else if(method == normal || method == forceExists)
646 action = $"Updating ";
650 reason = $"Makefile doesn't exist. ";
651 else if(project.topNode.modified)
652 reason = $"Project has been modified. ";
656 //logBox.Logf("%s\n", makefileName);
657 logBox.Logf($"%s - %s%smakefile for %s config...\n", makefileName, reason, action, GetConfigName(config));
659 if(!project.GenerateMakefile(null, false, null, config))
660 ide.outputView.buildBox.Logf($"Error generating makefile (Is the project directory writable?)\n");
662 ide.statusBar.text = null;
670 bool BuildInterrim(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config, bool justPrint)
672 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
674 ide.outputView.buildBox.Logf($"Building project %s using the %s configuration...\n", prj.name, GetConfigName(config));
675 return Build(prj, buildType, compiler, config, justPrint);
680 bool DebugStopForMake(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config)
683 // TOFIX: DebugStop is being abused and backfiring on us.
684 // It's supposed to be the 'Debug/Stop' item, not unloading executable or anything else
686 // configIsInDebugSession seems to be used for two OPPOSITE things:
687 // If we're debugging another config, we need to unload the executable!
688 // In building, we want to stop if we're debugging the 'same' executable
689 if(buildType != run) ///* && prj == project*/ && prj.configIsInDebugSession)
691 if(buildType == start || buildType == restart)
693 if(ide.debugger && ide.debugger.isPrepared)
694 result = DebugStop();
698 if(ide.project == prj && ide.debugger && ide.debugger.prjConfig == config && ide.debugger.isPrepared)
699 result = DebugStop();
705 bool Build(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config, bool justPrint)
711 for(document = master.firstChild; document; document = document.next)
713 if(document.modifiedDocument)
715 ProjectNode node = GetNodeFromWindow(document, prj);
716 if(node && !document.MenuFileSave(null, 0))
725 DirExpression targetDir = prj.GetTargetDir(compiler, config);
727 DebugStopForMake(prj, buildType, compiler, config);
729 // TODO: Disabled until problems fixed... is it fixed?
730 if(buildType == rebuild || (config && config.compilingModified))
731 prj.Clean(compiler, config, false, justPrint);
734 if(buildType == relink || (config && config.linkingModified))
736 char target[MAX_LOCATION];
738 strcpy(target, prj.topNode.path);
739 PathCat(target, targetDir.dir);
740 prj.CatTargetFileName(target, compiler, config);
741 if(FileExists(target))
744 if(config && config.symbolGenModified)
746 DirExpression objDir = prj.GetObjDir(compiler, config);
747 char fileName[MAX_LOCATION];
748 char moduleName[MAX_FILENAME];
749 strcpy(fileName, prj.topNode.path);
750 PathCatSlash(fileName, objDir.dir);
751 strcpy(moduleName, prj.moduleName);
752 strcat(moduleName, ".main.ec");
753 PathCatSlash(fileName, moduleName);
754 if(FileExists(fileName))
755 DeleteFile(fileName);
756 ChangeExtension(fileName, "c", fileName);
757 if(FileExists(fileName))
758 DeleteFile(fileName);
759 ChangeExtension(fileName, "o", fileName);
760 if(FileExists(fileName))
761 DeleteFile(fileName);
766 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
767 ide.AdjustBuildMenus();
768 ide.AdjustDebugMenus();
770 result = prj.Build(buildType == run, null, compiler, config, justPrint, normal);
774 config.compilingModified = false;
775 if(!ide.ShouldStopBuild())
776 config.linkingModified = false;
778 config.symbolGenModified = false;
780 buildInProgress = none;
781 ide.AdjustBuildMenus();
782 ide.AdjustDebugMenus();
784 ide.workspace.modified = true;
791 // ((( USER ACTIONS )))
793 // ************************************************************************
794 // *** Methods below should atomically start a process, and as such ***
795 // *** they can query compiler and config directly from ide and project ***
796 // *** but ONLY ONCE!!! ***
797 // ************************************************************************
799 bool ProjectBuild(MenuItem selection, Modifiers mods)
801 Project prj = project;
802 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
803 ProjectConfig config;
804 if(selection || !ide.activeClient)
806 DataRow row = fileList.currentRow;
807 ProjectNode node = row ? (ProjectNode)row.tag : null;
808 if(node) prj = node.project;
812 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
817 if(/*prj != project || */!prj.GetConfigIsInDebugSession(config) || !ide.DontTerminateDebugSession($"Project Build"))
819 BuildInterrim(prj, build, compiler, config, mods.ctrl && mods.shift);
825 bool ProjectLink(MenuItem selection, Modifiers mods)
827 Project prj = project;
828 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
829 ProjectConfig config;
830 if(selection || !ide.activeClient)
832 DataRow row = fileList.currentRow;
833 ProjectNode node = row ? (ProjectNode)row.tag : null;
834 if(node) prj = node.project;
838 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
843 if(!prj.GetConfigIsInDebugSession(config) ||
844 (!ide.DontTerminateDebugSession($"Project Link") && DebugStopForMake(prj, relink, compiler, config)))
846 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
848 ide.outputView.buildBox.Logf($"Relinking project %s using the %s configuration...\n", prj.name, GetConfigName(config));
850 config.linkingModified = true;
851 Build(prj, relink, compiler, config, mods.ctrl && mods.shift);
858 bool ProjectRebuild(MenuItem selection, Modifiers mods)
860 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
861 Project prj = project;
862 ProjectConfig config;
863 if(selection || !ide.activeClient)
865 DataRow row = fileList.currentRow;
866 ProjectNode node = row ? (ProjectNode)row.tag : null;
867 if(node) prj = node.project;
871 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
876 if(!prj.GetConfigIsInDebugSession(config) ||
877 (!ide.DontTerminateDebugSession($"Project Rebuild") && DebugStopForMake(prj, rebuild, compiler, config)))
879 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
881 ide.outputView.buildBox.Logf($"Rebuilding project %s using the %s configuration...\n", prj.name, GetConfigName(config));
884 config.compilingModified = true;
885 config.makingModified = true;
886 }*/ // -- should this still be used depite the new solution of BuildType?
887 Build(prj, rebuild, compiler, config, mods.ctrl && mods.shift);
894 bool ProjectClean(MenuItem selection, Modifiers mods)
896 Project prj = project;
897 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
898 ProjectConfig config;
899 if(selection || !ide.activeClient)
901 DataRow row = fileList.currentRow;
902 ProjectNode node = row ? (ProjectNode)row.tag : null;
903 if(node) prj = node.project;
907 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
912 if(!prj.GetConfigIsInDebugSession(config) ||
913 (!ide.DontTerminateDebugSession($"Project Clean") && DebugStopForMake(prj, clean, compiler, config)))
915 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
917 ide.outputView.buildBox.Logf($"Cleaning project %s using the %s configuration...\n", prj.name, GetConfigName(config));
919 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
920 ide.AdjustBuildMenus();
921 ide.AdjustDebugMenus();
923 prj.Clean(compiler, config, false, mods.ctrl && mods.shift);
924 buildInProgress = none;
925 ide.AdjustBuildMenus();
926 ide.AdjustDebugMenus();
933 bool ProjectRealClean(MenuItem selection, Modifiers mods)
935 Project prj = project;
936 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
937 ProjectConfig config;
938 if(selection || !ide.activeClient)
940 DataRow row = fileList.currentRow;
941 ProjectNode node = row ? (ProjectNode)row.tag : null;
942 if(node) prj = node.project;
946 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
951 if(!prj.GetConfigIsInDebugSession(config) ||
952 (!ide.DontTerminateDebugSession($"Project Real Clean") && DebugStopForMake(prj, clean, compiler, config)))
954 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
956 ide.outputView.buildBox.Logf($"Removing intermediate objects directory for project %s using the %s configuration...\n", prj.name, GetConfigName(config));
958 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
959 ide.AdjustBuildMenus();
960 ide.AdjustDebugMenus();
962 prj.Clean(compiler, config, true, mods.ctrl && mods.shift);
963 buildInProgress = none;
964 ide.AdjustBuildMenus();
965 ide.AdjustDebugMenus();
972 bool ProjectRegenerate(MenuItem selection, Modifiers mods)
974 Project prj = project;
975 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
976 ShowOutputBuildLog(true);
977 if(selection || !ide.activeClient)
979 DataRow row = fileList.currentRow;
980 ProjectNode node = row ? (ProjectNode)row.tag : null;
986 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
991 DisplayCompiler(compiler, false);
992 ProjectPrepareCompiler(project, compiler);
993 ProjectPrepareMakefile(prj, force, compiler, prj.config);
998 bool Compile(Project project, List<ProjectNode> nodes, bool justPrint, SingleFileCompileMode mode)
1001 char fileName[MAX_LOCATION];
1003 ProjectConfig config = project.config;
1007 for(document = ide.firstChild; document; document = document.next)
1009 if(document.modifiedDocument)
1011 ProjectNode n = GetNodeFromWindow(document, project);
1014 if(n && n.IsInNode(node) && !document.MenuFileSave(null, 0))
1016 ide.outputView.buildBox.Logf($"Unable to save %s file.\n", node.name);
1026 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1028 if(ProjectPrepareForToolchain(project, normal, true, true, compiler, config))
1031 ide.outputView.buildBox.Logf($"%s specific file(s) in project %s using the %s configuration...\n",
1032 mode == normal ? $"Compiling" : $"Debug compiling", project.name, config.name);
1034 ide.outputView.buildBox.Logf($"%s specific file(s) in project %s...\n",
1035 mode == normal ? $"Compiling" : $"Debug compiling", project.name);
1037 buildInProgress = compilingFile;
1038 ide.AdjustBuildMenus();
1039 project.Compile(nodes, compiler, config, justPrint, mode);
1040 buildInProgress = none;
1041 ide.AdjustBuildMenus();
1050 bool Clean(Project project, List<ProjectNode> nodes, bool justPrint)
1053 char fileName[MAX_LOCATION];
1055 ProjectConfig config = project.config;
1059 for(document = ide.firstChild; document; document = document.next)
1061 if(document.modifiedDocument)
1063 ProjectNode n = GetNodeFromWindow(document, project);
1066 if(n && n.IsInNode(node) && !document.MenuFileSave(null, 0))
1068 ide.outputView.buildBox.Logf($"Unable to save %s file.\n", node.name);
1078 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1080 if(ProjectPrepareForToolchain(project, normal, true, true, compiler, config))
1082 Map<String, NameCollisionInfo> namesInfo { };
1083 project.topNode.GenMakefileGetNameCollisionInfo(namesInfo, config);
1086 if(node.GetIsExcluded(config))
1087 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
1091 ide.outputView.buildBox.Logf($"Deleteing intermediate objects for %s %s in project %s using the %s configuration...\n",
1092 node.type == file ? $"single file" : $"folder", node.name, project.name, config.name);
1094 ide.outputView.buildBox.Logf($"Deleteing intermediate objects for %s %s in project %s...\n",
1095 node.type == file ? $"single file" : $"folder", node.name, project.name);
1097 node.DeleteIntermediateFiles(compiler, config, namesInfo);
1109 bool ProjectNewFile(MenuItem selection, Modifiers mods)
1111 DataRow row = fileList.currentRow;
1114 char fileName[1024];
1115 char filePath[MAX_LOCATION];
1116 ProjectNode parentNode = (ProjectNode)row.tag;
1117 ProjectNode n, fileNode;
1118 parentNode.GetFileSysMatchingPath(filePath);
1119 MakePathRelative(filePath, parentNode.project.topNode.path, filePath);
1120 for(n = parentNode; n && n != parentNode.project.resNode; n = n.parent);
1121 sprintf(fileName, $"Untitled %d", documentID);
1122 fileNode = AddFile(parentNode, fileName, (bool)n, true);
1123 fileNode.path = CopyUnixPath(filePath);
1126 NodeProperties nodeProperties
1129 position = { position.x + 100, position.y + 100 };
1133 nodeProperties.Create(); // not modal?
1139 bool ProjectNewFolder(MenuItem selection, Modifiers mods)
1141 DataRow row = fileList.currentRow;
1144 ProjectNode parentNode = (ProjectNode)row.tag;
1145 NewFolder(parentNode, null, true);
1150 bool ResourcesAddFiles(MenuItem selection, Modifiers mods)
1156 bool ProjectAddFiles(MenuItem selection, Modifiers mods)
1162 bool ProjectImportFolder(MenuItem selection, Modifiers mods)
1164 DataRow row = fileList.currentRow;
1167 ProjectNode toNode = (ProjectNode)row.tag;
1168 ImportFolder(toNode);
1173 bool ProjectAddNewForm(MenuItem selection, Modifiers mods)
1175 CodeEditor codeEditor = CreateNew("Form", "form", "Window", null);
1176 codeEditor.EnsureUpToDate();
1180 bool ProjectAddNewGraph(MenuItem selection, Modifiers mods)
1182 CodeEditor codeEditor = CreateNew("Graph", "graph", "Block", null);
1184 codeEditor.EnsureUpToDate();
1188 bool ProjectRemove(MenuItem selection, Modifiers mods)
1190 DataRow row = fileList.currentRow;
1193 ProjectNode node = (ProjectNode)row.tag;
1194 if(node.type == project)
1195 RemoveSelectedNodes();
1200 bool ProjectUpdateMakefileForAllConfigs(Project project)
1202 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1204 // This call really does not belong here:
1205 ide.UpdateToolBarActiveConfigs(false);
1206 for(config : project.configurations)
1207 ProjectPrepareMakefile(project, forceExists, compiler, config);
1214 bool MenuSettings(MenuItem selection, Modifiers mods)
1216 ProjectNode node = GetSelectedNode(true);
1217 Project prj = node ? node.project : project;
1218 projectSettingsDialog = ProjectSettings { master = parent, project = prj, projectNode = node };
1219 projectSettingsDialog.Modal();
1226 bool FileProperties(MenuItem selection, Modifiers mods)
1228 DataRow row = fileList.currentRow;
1231 ProjectNode node = (ProjectNode)row.tag;
1232 NodeProperties { parent = parent, master = this, node = node,
1233 position = { position.x + 100, position.y + 100 } }.Create();
1238 bool FileOpenFile(MenuItem selection, Modifiers mods)
1240 OpenSelectedNodes();
1244 bool FileRemoveFile(MenuItem selection, Modifiers mods)
1246 RemoveSelectedNodes();
1250 bool FileCompile(MenuItem selection, Modifiers mods)
1253 OldList selectedRows;
1254 Project project = null;
1255 List<ProjectNode> nodes { };
1256 fileList.GetMultiSelection(selectedRows);
1257 for(item = selectedRows.first; item; item = item.next)
1260 DataRow row = item.data;
1261 ProjectNode node = (ProjectNode)row.tag;
1263 project = node.project;
1264 else if(node.project != project)
1271 selectedRows.Free(null);
1273 Compile(project, nodes, mods.ctrl && mods.shift, normal);
1275 ide.outputView.buildBox.Logf($"Please select files from a single project.\n");
1280 bool FileClean(MenuItem selection, Modifiers mods)
1283 OldList selectedRows;
1284 Project project = null;
1285 List<ProjectNode> nodes { };
1286 fileList.GetMultiSelection(selectedRows);
1287 for(item = selectedRows.first; item; item = item.next)
1290 DataRow row = item.data;
1291 ProjectNode node = (ProjectNode)row.tag;
1293 project = node.project;
1294 else if(node.project != project)
1301 selectedRows.Free(null);
1303 Clean(project, nodes, mods.ctrl && mods.shift);
1305 ide.outputView.buildBox.Logf($"Please select files from a single project.\n");
1310 bool FileDebugPrecompile(MenuItem selection, Modifiers mods)
1312 DataRow row = fileList.currentRow;
1313 ProjectNode node = row ? (ProjectNode)row.tag : null;
1316 List<ProjectNode> nodes { };
1318 Compile(node.project, nodes, mods.ctrl && mods.shift, debugPrecompile);
1323 bool FileDebugCompile(MenuItem selection, Modifiers mods)
1325 DataRow row = fileList.currentRow;
1326 ProjectNode node = row ? (ProjectNode)row.tag : null;
1329 List<ProjectNode> nodes { };
1331 Compile(node.project, nodes, mods.ctrl && mods.shift, debugCompile);
1336 bool FileDebugGenerateSymbols(MenuItem selection, Modifiers mods)
1338 DataRow row = fileList.currentRow;
1339 ProjectNode node = row ? (ProjectNode)row.tag : null;
1342 List<ProjectNode> nodes { };
1344 Compile(node.project, nodes, mods.ctrl && mods.shift, debugGenerateSymbols);
1349 Project GetSelectedProject(bool useSelection)
1351 Project prj = project;
1354 DataRow row = fileList.currentRow;
1355 ProjectNode node = row ? (ProjectNode)row.tag : null;
1362 void SelectNextProject(bool backwards)
1364 DataRow row = fileList.currentRow;
1365 DataRow currentRow = row;
1366 ProjectNode node = (ProjectNode)row.tag;
1367 if(node.type != project)
1368 row = node.project.topNode.row;
1370 row = row.previous ? row.previous : fileList.lastRow;
1372 row = row.next ? row.next : fileList.firstRow;
1373 if(row && row != currentRow)
1375 fileList.SelectRow(row);
1376 fileList.currentRow = row;
1380 ProjectNode GetSelectedNode(bool useSelection)
1382 ProjectNode node = null;
1385 DataRow row = fileList.currentRow;
1387 node = (ProjectNode)row.tag;
1392 bool MenuBrowseFolder(MenuItem selection, Modifiers mods)
1394 char folder[MAX_LOCATION];
1396 ProjectNode node = GetSelectedNode(true);
1398 node = project.topNode;
1401 strcpy(folder, prj.topNode.path);
1402 if(node != prj.topNode)
1403 PathCatSlash(folder, node.path);
1408 bool Run(MenuItem selection, Modifiers mods)
1410 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1411 ProjectConfig config = project.config;
1412 String args = new char[maxPathLen];
1414 if(ide.workspace.commandLineArgs)
1415 //ide.debugger.GetCommandLineArgs(args);
1416 strcpy(args, ide.workspace.commandLineArgs);
1417 if(ide.debugger.isActive)
1418 project.Run(args, compiler, config);
1419 /*else if(config.targetType == sharedLibrary || config.targetType == staticLibrary)
1420 MessageBox { master = ide, type = ok, text = "Run", contents = "Shared and static libraries cannot be run like executables." }.Modal();*/
1421 else if(BuildInterrim(project, run, compiler, config, false))
1422 project.Run(args, compiler, config);
1430 bool result = false;
1431 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1432 ProjectConfig config = project.config;
1433 TargetTypes targetType = project.GetTargetType(config);
1434 if(targetType == sharedLibrary || targetType == staticLibrary)
1435 MessageBox { master = ide, type = ok, text = $"Run", contents = $"Shared and static libraries cannot be run like executables." }.Modal();
1436 else if(project.GetCompress(config))
1437 MessageBox { master = ide, text = $"Starting Debug", contents = $"Debugging compressed applications is not supported\n" }.Modal();
1438 else if(project.GetDebug(config) ||
1439 MessageBox { master = ide, type = okCancel, text = $"Starting Debug", contents = $"Attempting to debug non-debug configuration\nProceed anyways?" }.Modal() == ok)
1441 if(/*!IsProjectModified() ||*/ BuildInterrim(project, start, compiler, config, false))
1443 if(compiler.type.isVC)
1445 //bool result = false;
1446 char oldwd[MAX_LOCATION];
1447 PathBackup pathBackup { };
1448 char command[MAX_LOCATION];
1450 ide.SetPath(false, compiler, config);
1452 GetWorkingDir(oldwd, sizeof(oldwd));
1453 ChangeWorkingDir(project.topNode.path);
1455 sprintf(command, "%s /useenv %s.sln /projectconfig \"%s|Win32\" /command \"%s\"" , "devenv", project.name, config.name, "Debug.Start");
1457 ChangeWorkingDir(oldwd);
1463 ide.debugger.Start(compiler, config);
1472 void GoToError(const char * line)
1476 while(isspace(*line)) line++;
1477 colon = strstr(line, ":");
1482 bool lookForLineNumber = true;
1484 // deal with linking error
1485 if(colon && colon[1] == ' ')
1487 colon = strstr(colon + 1, ":");
1488 if(colon && !colon[1])
1490 colon = strstr(line, ":");
1491 lookForLineNumber = false;
1493 else if(colon && !isdigit(colon[1]))
1496 colon = strstr(line, ":");
1499 // Don't be mistaken by the drive letter colon
1500 if(colon && (colon[1] == '/' || colon[1] == '\\'))
1501 colon = strstr(colon + 1, ":");
1502 if(colon && lookForLineNumber)
1506 char * par = RSearchString(line, "(", colon - line, true, false);
1507 if(par && strstr(par, ")"))
1509 else if((colon+1)[0] == ' ')
1511 // NOTE: This is the same thing as saying 'colon = line'
1512 for( ; colon != line; colon--)
1516 lineNumber = atoi(colon + 1);
1518 comma = strchr(colon, ',');
1520 col = atoi(comma+1);
1522 comma = strchr(colon+1, ':');
1524 col = atoi(comma+1);
1528 char moduleName[MAX_LOCATION], filePath[MAX_LOCATION];
1532 char * inFileIncludedFrom = strstr(line, stringInFileIncludedFrom);
1533 char * start = inFileIncludedFrom ? line + strlen(stringInFileIncludedFrom) : line;
1534 int len = (int)(colon - start);
1535 len = Min(len, MAX_LOCATION-1);
1537 strncpy(moduleName, start, len);
1538 moduleName[len] = '\0';
1541 strcpy(moduleName, line);
1543 // Remove stuff in brackets
1545 bracket = strstr(moduleName, "(");
1546 if(bracket) *bracket = '\0';
1548 MakeSlashPath(moduleName);
1552 // Check if it's one of our modules
1553 ProjectNode node = project.topNode.Find(moduleName, false);
1556 strcpy(moduleName, node.path);
1557 PathCatSlash(moduleName, node.name);
1560 moduleName[0] = '\0';
1564 CodeEditor codeEditor;
1565 strcpy(filePath, project.topNode.path);
1566 PathCatSlash(filePath, moduleName);
1568 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
1571 char name[MAX_LOCATION];
1572 // TOFIX: Improve on this, don't use only filename, make a function
1573 if(ide && ide.workspace)
1575 for(prj : ide.workspace.projects)
1577 if(prj.topNode.FindWithPath(moduleName, false))
1579 strcpy(filePath, prj.topNode.path);
1580 PathCatSlash(filePath, moduleName);
1581 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
1588 if(codeEditor && lineNumber)
1590 EditBox editBox = codeEditor.editBox;
1591 editBox.GoToLineNum(lineNumber - 1);
1592 editBox.GoToPosition(editBox.line, lineNumber - 1, col ? (col - 1) : 0);
1599 bool OpenNode(ProjectNode node)
1601 char filePath[MAX_LOCATION];
1602 node.GetFullFilePath(filePath);
1603 return ide.OpenFile(filePath, normal, true/*false Why was it opening hidden?*/, null, something, normal) ? true : false;
1606 void AddNode(ProjectNode node, DataRow addTo)
1608 DataRow row = addTo ? addTo.AddRow() : fileList.AddRow();
1610 row.tag = (int64)node;
1613 if(node.type == resources)
1616 row.SetData(null, node);
1618 if(node.files && node.files.first && node.parent &&
1619 !(!node.parent.parent &&
1620 (!strcmpi(node.name, "notes") || !strcmpi(node.name, "sources") ||
1621 !strcmpi(node.name, "src") || !strcmpi(node.name, "tools"))))
1622 row.collapsed = true;
1623 else if(node.type == folder)
1624 node.icon = openFolder;
1628 for(child : node.files)
1629 AddNode(child, row);
1633 void DeleteNode(ProjectNode projectNode)
1635 if(projectNode.files)
1638 while(child = projectNode.files.first)
1641 fileList.DeleteRow(projectNode.row);
1642 projectNode.Delete();
1645 bool ProjectSave(MenuItem selection, Modifiers mods)
1647 DataRow row = fileList.currentRow;
1648 ProjectNode node = row ? (ProjectNode)row.tag : null;
1649 Project prj = node ? node.project : null;
1652 prj.StopMonitoring();
1653 if(prj.Save(prj.filePath))
1655 Project modPrj = null;
1656 prj.topNode.modified = false;
1657 for(p : ide.workspace.projects)
1659 if(p.topNode.modified)
1666 modifiedDocument = false;
1669 prj.StartMonitoring();
1674 bool ShowOutputBuildLog(bool cleanLog)
1676 OutputView output = ide.outputView;
1678 output.ShowClearSelectTab(build);
1681 output.SelectTab(build);
1689 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1690 ProjectConfig config = project.config;
1692 bool result = false;
1693 if(/*!IsProjectModified() ||*/ BuildInterrim(project, restart, compiler, config, false))
1695 // For Restart, compiler and config will only be used if for
1696 // whatever reason (if at all possible) the Debugger is in a
1697 // 'terminated' or 'none' state
1698 ide.debugger.Restart(compiler, config);
1708 ide.debugger.Resume();
1714 ide.debugger.Break();
1720 ide.debugger.Stop();
1724 bool DebugStepInto()
1726 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1727 ProjectConfig config = project.config;
1729 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config, false)))
1730 ide.debugger.StepInto(compiler, config);
1735 bool DebugStepOver(bool skip)
1737 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1738 ProjectConfig config = project.config;
1740 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config, false)))
1741 ide.debugger.StepOver(compiler, config, skip);
1747 bool DebugStepOut(bool skip)
1749 ide.debugger.StepOut(skip);
1753 void ImportFolder(ProjectNode toNode)
1757 //bool isFolder = toNode.type == folder;
1758 //bool isRes = toNode.isInResources;
1760 FileDialog fileDialog = importFileDialog;
1761 fileDialog.master = parent;
1762 if(fileDialog.Modal() == ok)
1764 ImportFolderFSI fsi { projectView = this };
1765 fsi.stack.Add(toNode);
1766 fsi.Iterate(fileDialog.filePath);
1772 ProjectNode NewFolder(ProjectNode parentNode, char * name, bool showProperties)
1776 ProjectNode folderNode;
1777 Project prj = parentNode.project;
1779 ProjectNode after = null;
1780 for(node : parentNode.files)
1782 if(node.type != folder)
1788 folderNode = parentNode.Add(prj, name, after, folder, folder, true);
1791 for(c = 0; c < 100; c++)
1794 sprintf(string, c ? "New Folder (%d)" : "New Folder", c);
1795 if((folderNode = parentNode.Add(prj, string, after, folder, folder, true)))
1802 NodeProperties nodeProperties;
1805 modifiedDocument = true;
1806 prj.topNode.modified = true;
1809 folderNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
1810 folderNode.row.tag = (int64)folderNode;
1812 folderNode.row.SetData(null, folderNode);
1813 fileList.currentRow = folderNode.row;
1817 nodeProperties = NodeProperties
1819 parent, this, mode = newFolder, node = folderNode;
1820 position = { position.x + 100, position.y + 100 };
1822 nodeProperties.Create(); // Modal?
1830 void AddFiles(bool resources)
1832 FileDialog fileDialog = (!resources) ? this.fileDialog : resourceFileDialog;
1833 fileDialog.type = multiOpen;
1834 fileDialog.text = !resources ? $"Add Files to Project" : $"Add Resources to Project";
1835 fileDialog.master = parent;
1837 if(fileDialog.Modal() == ok)
1840 DataRow row = fileList.currentRow;
1841 ProjectNode parentNode = (ProjectNode)row.tag;
1842 bool addFailed = false;
1843 int numSelections = fileDialog.numSelections;
1844 char ** multiFilePaths = fileDialog.multiFilePaths;
1846 Array<String> nameConflictFiles { };
1848 for(c = 0; c < numSelections; c++)
1850 char * filePath = multiFilePaths[c];
1851 FileAttribs exists = FileExists(filePath);
1852 bool addThisFile = true;
1854 if(exists.isDirectory)
1855 addThisFile = false;
1858 if(MessageBox { master = ide, type = yesNo, text = filePath,
1859 contents = $"File doesn't exist. Create?" }.Modal() == yes)
1861 File f = FileOpen(filePath, write);
1869 MessageBox { master = ide, type = ok, text = filePath,
1870 contents = $"Couldn't create file."}.Modal();
1871 addThisFile = false;
1878 /*addFailed = */if(!AddFile(parentNode, filePath, resources, false))//;
1880 nameConflictFiles.Add(CopyString(filePath));
1888 char * part1 = $"The following file";
1889 char * opt1 = $" was ";
1890 char * opt2 = $"s were ";
1891 char * part2 = $"not added because of identical file name conflict within the project.\n\n";
1893 len += strlen(part1);
1894 len += strlen(part2);
1895 len += nameConflictFiles.count > 1 ? strlen(opt2) : strlen(opt1);
1896 for(s : nameConflictFiles)
1897 len += strlen(s) + 1;
1898 message = new char[len + 1];
1899 strcpy(message, part1);
1900 strcat(message, nameConflictFiles.count > 1 ? opt2 : opt1);
1901 strcat(message, part2);
1902 for(s : nameConflictFiles)
1905 strcat(message, "\n");
1907 MessageBox { master = ide, type = ok, text = $"Name Conflict",
1908 contents = message }.Modal();
1911 nameConflictFiles.Free();
1912 delete nameConflictFiles;
1916 ProjectNode AddFile(ProjectNode parentNode, char * filePath, bool resources, bool isTemporary)
1918 ProjectNode result = null;
1919 ProjectNode after = null;
1920 for(node : parentNode.files)
1922 if(node.type != folder && node.type != file && node.type)
1927 result = parentNode.Add(parentNode.project, filePath, after, file, NodeIcons::SelectFileIcon(filePath), !resources);
1933 modifiedDocument = true;
1934 parentNode.project.topNode.modified = true;
1935 parentNode.project.ModifiedAllConfigs(true, false, true, true);
1938 result.row = parentNode.row.AddRowAfter(after ? after.row : null);
1939 result.row.tag = (int64)result;
1940 result.row.SetData(null, result);
1945 CodeEditor CreateNew(char * upper, char * lower, char * base, char * className)
1947 CodeEditor codeEditor = null;
1948 ProjectNode projectNode;
1949 ProjectNode after = null;
1950 DataRow row = fileList.currentRow;
1951 ProjectNode parentNode;
1954 if(!row) row = project.topNode.row;
1956 parentNode = (ProjectNode)row.tag;
1958 for(node : parentNode.files)
1960 if(node.type != folder && node.type != file && node.type)
1964 for(c = 1; c < 100; c++)
1967 sprintf(string, c ? "%s%d.ec" : "%s.ec", lower, c);
1968 if((projectNode = parentNode.Add(project, string, after, file, genFile, true)))
1974 char filePath[MAX_LOCATION];
1976 modifiedDocument = true;
1977 project.topNode.modified = true;
1979 project.ModifiedAllConfigs(true, false, false, true);
1980 projectNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
1981 projectNode.row.tag =(int64)projectNode;
1983 projectNode.row.SetData(null, projectNode);
1984 fileList.currentRow = projectNode.row;
1986 strcpy(filePath, project.topNode.path);
1987 PathCat(filePath, projectNode.path);
1988 PathCat(filePath, projectNode.name);
1990 codeEditor = (CodeEditor)ide.FindWindow(filePath);
1993 Class baseClass = eSystem_FindClass(__thisModule, base);
1994 subclass(ClassDesignerBase) designerClass = eClass_GetDesigner(baseClass);
1997 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal);
1998 strcpy(name, projectNode.name);
1999 sprintf(name, "%s%d", upper, c);
2001 strcpy(className, name);
2003 designerClass.CreateNew(codeEditor.editBox, codeEditor.clientSize, name, base);
2005 //codeEditor.modifiedDocument = false;
2006 //codeEditor.designer.modifiedDocument = false;
2008 //Code_EnsureUpToDate(codeEditor);
2011 else // TODO: fix no symbols generated when ommiting {} for following else
2013 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal);
2017 codeEditor.ViewDesigner();
2018 codeEditor.codeModified = true;
2025 // Returns true if we opened something
2026 bool OpenSelectedNodes()
2028 bool result = false;
2032 fileList.GetMultiSelection(selection);
2033 for(item = selection.first; item; item = item.next)
2035 DataRow row = item.data;
2036 ProjectNode node = (ProjectNode)row.tag;
2037 if(node.type == file)
2044 selection.Free(null);
2048 void RemoveSelectedNodes()
2053 fileList.GetMultiSelection(selection);
2055 // Remove children of parents we're deleting
2056 for(item = selection.first; item; item = next)
2059 DataRow row = item.data;
2060 ProjectNode n, node = (ProjectNode)row.tag;
2061 bool remove = false;
2064 for(i = selection.first; i && !remove; i = i.next)
2066 ProjectNode iNode = (ProjectNode)((DataRow)i.data).tag;
2067 for(n = node.parent; n; n = n.parent)
2077 selection.Delete(item);
2080 for(item = selection.first; item; item = item.next)
2082 DataRow row = item.data;
2083 ProjectNode node = (ProjectNode)row.tag;
2084 ProjectNode resNode;
2085 for(resNode = node.parent; resNode; resNode = resNode.parent)
2086 if(resNode.type == resources)
2088 if(node.type == file)
2090 Project prj = node.project;
2092 modifiedDocument = true;
2093 prj.topNode.modified = true;
2095 prj.ModifiedAllConfigs(true, false, true, true);
2097 else if(node.type == folder)
2100 sprintf(message, $"Are you sure you want to remove the folder \"%s\"\n"
2101 "and all of its contents from the project?", node.name);
2102 if(MessageBox { master = ide, type = yesNo, text = $"Delete Folder", contents = message }.Modal() == yes)
2104 Project prj = node.project;
2105 if(node.containsFile)
2106 prj.ModifiedAllConfigs(true, false, true, true);
2108 modifiedDocument = true;
2109 prj.topNode.modified = true;
2112 else if(node.type == project && node != project.topNode && !buildInProgress)
2116 for(p : workspace.projects)
2118 if(p.topNode == node)
2124 sprintf(message, $"Are you sure you want to remove the \"%s\" project\n" "from this workspace?", node.name);
2125 if(MessageBox { master = ide, type = yesNo, text = $"Remove Project", contents = message }.Modal() == yes)
2130 workspace.RemoveProject(prj);
2131 //modifiedDocument = true; // when project view is a workspace view
2135 selection.Free(null);