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", /*cFile*/
74 "<:ecere>mimeTypes/textCHeader.png", /*hFile*/
75 "<:ecere>mimeTypes/textC++Source.png", /*cppFile*/
76 "<:ecere>mimeTypes/textC++Header.png", /*hppFile*/
77 "<:ecere>mimeTypes/text.png", /*textFile*/
78 "<:ecere>mimeTypes/textHyperTextMarkup.png", /*webFile*/
79 "<:ecere>mimeTypes/image.png", /*pictureFile*/
80 "<:ecere>status/audioVolumeHigh.png", /*soundFile*/
81 "<:ecere>mimeTypes/package.png", /*archiveFile*/
82 "<:ecere>mimeTypes/packageSoftware.png", /*packageFile*/
83 "<:ecere>mimeTypes/packageOpticalDisc.png", /*opticalMediaImageFile*/
84 "<:ecere>mimeTypes/file.png" /*mFile*/ //TODO: create icon for mfile
87 enum PrepareMakefileMethod { normal, force, forceExists };
89 enum BuildType { build, rebuild, relink, run, start, restart, clean };
92 none, buildingMainProject, buildingSecondaryProject, compilingFile;
94 property bool { get { return this != none; } }
95 //property bool actualBuild { get { return this == buildingMainProject || this == buildingSecondaryProject; } }
98 class ProjectView : Window
101 //hasMinimize = true;
103 borderStyle = sizable;
104 hasHorzScroll = true;
105 hasVertScroll = true;
108 anchor = Anchor { left = 0, top = 0, bottom = 0 };
111 //hasMinimize = true;
112 saveDialog = projectFileDialog;
115 BuildState buildInProgress;
116 BitmapResource icons[NodeIcons];
119 property Workspace workspace
125 for(prj : workspace.projects)
127 DeleteNode(prj.topNode);
129 workspace.projects.Free();
130 ide.debugger.CleanUp();
135 fileDialog.currentDirectory = workspace.workspaceDir;
136 resourceFileDialog.currentDirectory = workspace.workspaceDir;
137 for(prj : workspace.projects)
138 AddNode(prj.topNode, null);
139 ide.statusBar.text = $"Generating Makefile & Dependencies...";
141 for(prj : workspace.projects)
142 prj.ModifiedAllConfigs(true, false, false, false);
143 ide.statusBar.text = $"Initializing Debugger"; app.UpdateDisplay();
144 ide.statusBar.text = null;
148 get { return workspace; }
151 bool drawingInProjectSettingsDialog;
152 bool drawingInProjectSettingsDialogHeader;
153 ProjectSettings projectSettingsDialog;
161 for(c = 0; c < NodeIcons::enumSize; c++)
163 icons[c] = BitmapResource { iconNames[c], alphaBlend = true };
164 AddResource(icons[c]);
166 fileList.AddField(DataField { dataType = class(ProjectNode), freeData = false, userData = this });
172 ide.DestroyTemporaryProjectDir();
182 multiSelect = true, fullRowSelect = false, hasVertScroll = true, hasHorzScroll = true;
183 borderStyle = deep, parent = this, collapseControl = true, treeBranches = true;
184 anchor = Anchor { left = 0, right = 0, top = 0 , bottom = 0 };
186 background = projectViewBackground;
187 foreground = projectViewText;
188 selectionColor = selectionColor, selectionText = selectionText;
189 stippleColor = skyBlue;
191 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
193 if(!active) Update(null);
194 return ListBox::OnActivate(active, previous, goOnWithActivation, direct);
197 bool NotifyDoubleClick(ListBox listBox, int x, int y, Modifiers mods)
199 // Prevent the double click from reactivating the project view (returns false if we opened something)
200 return !OpenSelectedNodes();
203 bool NotifyRightClick(ListBox listBox, int x, int y, Modifiers mods)
205 DataRow row = listBox.currentRow;
208 ProjectNode node = (ProjectNode)row.tag;
209 if(node.type == NodeTypes::project || node.type == resources || node.type == file || node.type == folder)
211 bool buildMenuUnavailable = buildInProgress;
212 Menu popupContent { };
214 if(node.type == NodeTypes::project)
216 //if(node == ((Project)workspace.projects.first).topNode)
218 MenuItem { popupContent, $"Build", b, NotifySelect = ProjectBuild }.disabled = buildMenuUnavailable;
219 MenuItem { popupContent, $"Relink", l, NotifySelect = ProjectLink }.disabled = buildMenuUnavailable;
220 MenuItem { popupContent, $"Rebuild", r, NotifySelect = ProjectRebuild }.disabled = buildMenuUnavailable;
221 MenuItem { popupContent, $"Clean", c, NotifySelect = ProjectClean }.disabled = buildMenuUnavailable;
222 MenuItem { popupContent, $"Real Clean", d, NotifySelect = ProjectRealClean }.disabled = buildMenuUnavailable;
223 MenuItem { popupContent, $"Regenerate Makefile", m, NotifySelect = ProjectRegenerate }.disabled = buildMenuUnavailable;
224 MenuDivider { popupContent };
226 MenuItem { popupContent, $"New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
227 MenuItem { popupContent, $"New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
228 MenuItem { popupContent, $"Import Folder...", i, NotifySelect = ProjectImportFolder };
229 MenuItem { popupContent, $"Add Files to Project...", f, NotifySelect = ProjectAddFiles };
230 MenuDivider { popupContent };
231 MenuItem { popupContent, $"Add New Form...", o, NotifySelect = ProjectAddNewForm };
232 // MenuItem { popupContent, "Add New Behavior Graph...", g, NotifySelect = ProjectAddNewGraph };
233 MenuDivider { popupContent };
234 if(node != ((Project)workspace.projects.first).topNode)
236 MenuItem { popupContent, $"Remove project from workspace", r, NotifySelect = ProjectRemove }.disabled = buildMenuUnavailable;
237 MenuDivider { popupContent };
239 MenuItem { popupContent, $"Active Configuration...", s, Key { f5, alt = true } , NotifySelect = MenuConfig };
240 MenuItem { popupContent, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
241 MenuDivider { popupContent };
242 MenuItem { popupContent, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
243 MenuDivider { popupContent };
244 MenuItem { popupContent, $"Save", v, Key { s, ctrl = true }, NotifySelect = ProjectSave }.disabled = !node.modified;
245 MenuDivider { popupContent };
246 MenuItem { popupContent, $"Properties...", p, Key { enter, alt = true }, NotifySelect = FileProperties };
248 else if(node.type == resources)
250 MenuItem { popupContent, $"New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
251 MenuItem { popupContent, $"New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
252 MenuItem { popupContent, $"Import Folder...", i, NotifySelect = ProjectImportFolder };
253 MenuItem { popupContent, $"Add Resources to Project...", f, NotifySelect = ResourcesAddFiles };
254 MenuItem { popupContent, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
255 MenuDivider { popupContent };
256 MenuItem { popupContent, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
257 MenuItem { popupContent, $"Properties...", p, Key { enter, alt = true }, NotifySelect = FileProperties };
259 else if(node.type == file)
261 MenuItem { popupContent, $"Open", o, NotifySelect = FileOpenFile };
262 MenuItem { popupContent, $"Compile", c, Key { f7, ctrl = true}, NotifySelect = FileCompile }.disabled = buildMenuUnavailable;
263 MenuDivider { popupContent };
264 MenuItem { popupContent, $"Remove", r, NotifySelect = FileRemoveFile };
265 MenuDivider { popupContent };
266 MenuItem { popupContent, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
267 MenuDivider { popupContent };
268 MenuItem { popupContent, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
269 MenuItem { popupContent, $"Properties..", p, Key { enter, alt = true }, NotifySelect = FileProperties };
271 else if(node.type == folder)
273 bool isInResources = node.isInResources;
275 MenuItem { popupContent, $"New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
276 MenuItem { popupContent, $"New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
277 MenuItem { popupContent, $"Import Folder...", i, NotifySelect = ProjectImportFolder };
280 MenuItem { popupContent, $"Add Resources to Folder...", f, NotifySelect = ResourcesAddFiles };
284 MenuItem { popupContent, $"Add Files to Folder...", f, NotifySelect = ProjectAddFiles };
288 MenuDivider { popupContent };
289 MenuItem { popupContent, $"Add New Form...", o, NotifySelect = ProjectAddNewForm };
290 MenuItem { popupContent, $"Add New Behavior Graph...", g, NotifySelect = ProjectAddNewGraph };
292 MenuDivider { popupContent };
293 MenuItem { popupContent, $"Remove", r, NotifySelect = FileRemoveFile };
294 MenuDivider { popupContent };
295 MenuItem { popupContent, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
296 MenuDivider { popupContent };
297 MenuItem { popupContent, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
298 MenuItem { popupContent, $"Properties...", p, Key { enter, alt = true }, NotifySelect = FileProperties };
303 master = this, menu = popupContent;
305 x + clientStart.x + absPosition.x - app.desktop.position.x,
306 y + clientStart.y + absPosition.y - app.desktop.position.y };
308 void NotifyDestroyed(Window window, DialogResult result)
319 bool NotifyKeyHit(ListBox listBox, DataRow row, Key key, unichar ch)
321 if(key == altUp || key == altDown)
323 SelectNextProject(key == altUp);
329 bool NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch)
333 ProjectNode node = (ProjectNode)row.tag;
336 case altEnter: case Key { keyPadEnter, alt = true }:
338 NodeProperties { parent = parent, master = this,
339 position = { position.x + 100, position.y + 100 }, node = node }.Create();
342 case enter: case keyPadEnter:
345 for(resNode = node.parent; resNode; resNode = resNode.parent)
346 if(resNode.type == resources)
348 if(node.type == project || (node.type == folder && !resNode))
353 else if(node.type == resources || node.type == folder)
362 if(node.type == project || node.type == folder || node.type == resources)
371 if(node.type == project || node.type == folder || node.type == resources)
373 NewFolder(node, null, true);
380 if(node.type == file)
382 FileCompile(null, (Modifiers)key);
387 case Key { space, shift = true }:
390 if(node.type == NodeTypes::project)
393 for(p : workspace.projects)
395 if(p.topNode == node)
401 prj.RotateActiveConfig(!key.shift);
412 case enter: case keyPadEnter: OpenSelectedNodes(); break;
413 case del: RemoveSelectedNodes(); break;
416 Window activeClient = ide.activeClient;
418 activeClient.Activate();
420 ide.RepositionWindows(true);
427 bool NotifyCollapse(ListBox listBox, DataRow row, bool collapsed)
429 ProjectNode node = (ProjectNode)row.tag;
430 if(node.type == folder)
431 node.icon = collapsed ? folder : openFolder;
436 FileDialog importFileDialog { autoCreate = false, type = selectDir, text = $"Import Folder" };
437 FileDialog projectFileDialog
439 autoCreate = false, filters = projectFilters.array, sizeFilters = projectFilters.count * sizeof(FileFilter);
440 types = projectTypes.array, sizeTypes = projectTypes.count * sizeof(FileType);
442 FileDialog fileDialog
444 autoCreate = false, mayNotExist = true, filters = fileFilters.array, sizeFilters = fileFilters.count * sizeof(FileFilter);
446 FileDialog resourceFileDialog
448 autoCreate = false, mayNotExist = true, filters = resourceFilters.array, sizeFilters = resourceFilters.count * sizeof(FileFilter);
451 Menu fileMenu { menu, $"File", f };
452 MenuItem { fileMenu, $"Save", s, Key { s, ctrl = true }, NotifySelect = MenuFileSave };
453 // MenuItem { fileMenu, "Save As...", a, NotifySelect = MenuFileSaveAs };
455 bool OnClose(bool parentClosing)
457 if(!parentClosing && visible)
467 DialogResult dialogRes;
470 strcpy(msg, $"You have modified projects.\nSave changes to ");
471 for(p : ide.workspace.projects)
473 if(p.topNode.modified)
475 if(!first) strcat(msg, ", ");
482 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = msg }.Modal();
486 // TOFIX: Precomp error if brackets are taken out
487 return (DialogResult)MenuFileSave(null, 0) != cancel;
489 else if(dialogRes == cancel)
491 modifiedDocument = false;
498 //if(ide.findInFilesDialog && ide.findInFilesDialog.created && ide.findInFilesDialog.mode != directory)
499 // ide.findInFilesDialog.SearchStop();
501 ide.outputView.buildBox.Clear();
502 ide.outputView.debugBox.Clear();
503 //ide.outputView.findBox.Clear();
504 ide.callStackView.Clear();
505 ide.watchesView.Clear();
506 ide.threadsView.Clear();
507 ide.breakpointsView.Clear();
508 ide.outputView.ShowClearSelectTab(find); // why this?
511 bool OnSaveFile(char * fileName)
513 for(prj : ide.workspace.projects)
515 if(prj.topNode.modified)
517 prj.StopMonitoring();
518 if(prj.Save(prj.filePath))
519 prj.topNode.modified = false;
520 prj.StartMonitoring();
523 modifiedDocument = false;
528 bool IsModuleInProject(char * filePath)
530 char moduleName[MAX_FILENAME]; //, modulePath[MAX_LOCATION];
531 GetLastDirectory(filePath, moduleName);
532 return project.topNode.Find(moduleName, false) != null;
535 bool GetRelativePath(char * filePath, char * relativePath)
537 return project.GetRelativePath(filePath, relativePath);
540 ProjectNode GetNodeFromWindow(Window document, Project project)
542 if(document.fileName)
544 char winFileName[MAX_LOCATION];
545 char * documentFileName = GetSlashPathBuffer(winFileName, document.fileName);
546 for(p : ide.workspace.projects)
548 Project prj = project ? project : p;
550 if((node = prj.topNode.FindByFullPath(documentFileName, false)))
558 // ((( UTILITY FUNCTIONS )))
560 // ************************************************************************
561 // *** These methods below are part of a sequence of events, and as ***
562 // *** such they must be passed the current compiler and project config ***
563 // ************************************************************************
564 bool DisplayCompiler(CompilerConfig compiler, bool cleanLog)
566 ide.outputView.buildBox.Logf($"%s Compiler\n", compiler ? compiler.name : $"{problem with compiler selection}");
570 bool ProjectPrepareForToolchain(Project project, PrepareMakefileMethod method, bool cleanLog, bool displayCompiler,
571 CompilerConfig compiler, ProjectConfig config)
574 char message[MAX_F_STRING];
575 LogBox logBox = ide.outputView.buildBox;
577 ShowOutputBuildLog(cleanLog);
580 DisplayCompiler(compiler, false);
582 ProjectPrepareCompiler(project, compiler);
583 ProjectPrepareMakefile(project, method, compiler, config);
587 bool ProjectPrepareCompiler(Project project, CompilerConfig compiler)
589 if(!project.GenerateCrossPlatformMk() || !project.GenerateCompilerCf(compiler))
590 ide.outputView.buildBox.Logf($"Error generating compiler configuration (Is the project/config directory writable?)\n");
594 // Note: Compiler is only passed in to for VisualStudio support
595 bool ProjectPrepareMakefile(Project project, PrepareMakefileMethod method, CompilerConfig compiler, ProjectConfig config)
597 if(compiler.type.isVC)
599 // I'm guessing we'll want to support generating VS files on Linux as well...
600 ide.statusBar.text = $"Generating Visual Studio Solution...";
602 //GenerateVSSolutionFile(project, compiler);
603 ide.statusBar.text = $"Generating Visual Studio Project...";
605 //GenerateVCProjectFile(project, compiler);
606 ide.statusBar.text = null;
612 char makefilePath[MAX_LOCATION];
613 char makefileName[MAX_LOCATION];
615 LogBox logBox = ide.outputView.buildBox;
617 strcpy(makefilePath, project.topNode.path);
618 project.CatMakeFileName(makefileName, config);
619 PathCatSlash(makefilePath, makefileName);
621 exists = FileExists(makefilePath);
622 if(method == force ||
623 (method == forceExists && exists) ||
624 (method == normal && (!exists || (config && config.makingModified))))
628 ide.statusBar.text = $"Generating Makefile & Dependencies..."; // Dependencies?
631 if((method == normal && !exists) || (method == force && !exists))
632 action = $"Generating ";
633 else if(method == force)
634 action = $"Regenerating ";
635 else if(method == normal || method == forceExists)
636 action = $"Updating ";
640 reason = $"Makefile doesn't exist. ";
641 else if(project.topNode.modified)
642 reason = $"Project has been modified. ";
646 //logBox.Logf("%s\n", makefileName);
647 logBox.Logf($"%s - %s%smakefile for %s config...\n", makefileName, reason, action, GetConfigName(config));
649 if(!project.GenerateMakefile(null, false, null, config))
650 ide.outputView.buildBox.Logf($"Error generating makefile (Is the project directory writable?)\n");
652 ide.statusBar.text = null;
660 bool BuildInterrim(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config, bool justPrint)
662 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
664 ide.outputView.buildBox.Logf($"Building project %s using the %s configuration...\n", prj.name, GetConfigName(config));
665 return Build(prj, buildType, compiler, config, justPrint);
670 bool DebugStopForMake(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config)
673 // TOFIX: DebugStop is being abused and backfiring on us.
674 // It's supposed to be the 'Debug/Stop' item, not unloading executable or anything else
676 // configIsInDebugSession seems to be used for two OPPOSITE things:
677 // If we're debugging another config, we need to unload the executable!
678 // In building, we want to stop if we're debugging the 'same' executable
679 if(buildType != run) ///* && prj == project*/ && prj.configIsInDebugSession)
681 if(buildType == start || buildType == restart)
683 if(ide.debugger && ide.debugger.isPrepared)
684 result = DebugStop();
688 if(ide.project == prj && ide.debugger && ide.debugger.prjConfig == config && ide.debugger.isPrepared)
689 result = DebugStop();
695 bool Build(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config, bool justPrint)
701 for(document = master.firstChild; document; document = document.next)
703 if(document.modifiedDocument)
705 ProjectNode node = GetNodeFromWindow(document, prj);
706 if(node && !document.MenuFileSave(null, 0))
715 DirExpression targetDir = prj.GetTargetDir(compiler, config);
717 DebugStopForMake(prj, buildType, compiler, config);
719 // TODO: Disabled until problems fixed... is it fixed?
720 if(buildType == rebuild || (config && config.compilingModified))
721 prj.Clean(compiler, config, false, justPrint);
724 if(buildType == relink || (config && config.linkingModified))
726 char target[MAX_LOCATION];
728 strcpy(target, prj.topNode.path);
729 PathCat(target, targetDir.dir);
730 prj.CatTargetFileName(target, compiler, config);
731 if(FileExists(target))
734 if(config && config.symbolGenModified)
736 DirExpression objDir = prj.GetObjDir(compiler, config);
737 char fileName[MAX_LOCATION];
738 char moduleName[MAX_FILENAME];
739 strcpy(fileName, prj.topNode.path);
740 PathCatSlash(fileName, objDir.dir);
741 strcpy(moduleName, prj.moduleName);
742 strcat(moduleName, ".main.ec");
743 PathCatSlash(fileName, moduleName);
744 if(FileExists(fileName))
745 DeleteFile(fileName);
746 ChangeExtension(fileName, "c", fileName);
747 if(FileExists(fileName))
748 DeleteFile(fileName);
749 ChangeExtension(fileName, "o", fileName);
750 if(FileExists(fileName))
751 DeleteFile(fileName);
756 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
757 ide.AdjustBuildMenus();
758 ide.AdjustDebugMenus();
760 result = prj.Build(buildType == run, null, compiler, config, justPrint);
764 config.compilingModified = false;
765 if(!ide.ShouldStopBuild())
766 config.linkingModified = false;
768 config.symbolGenModified = false;
770 buildInProgress = none;
771 ide.AdjustBuildMenus();
772 ide.AdjustDebugMenus();
774 ide.workspace.modified = true;
781 // ((( USER ACTIONS )))
783 // ************************************************************************
784 // *** Methods below should atomically start a process, and as such ***
785 // *** they can query compiler and config directly from ide and project ***
786 // *** but ONLY ONCE!!! ***
787 // ************************************************************************
789 bool ProjectBuild(MenuItem selection, Modifiers mods)
791 Project prj = project;
792 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
793 ProjectConfig config;
794 if(selection || !ide.activeClient)
796 DataRow row = fileList.currentRow;
797 ProjectNode node = row ? (ProjectNode)row.tag : null;
798 if(node) prj = node.project;
802 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
807 if(/*prj != project || */!prj.GetConfigIsInDebugSession(config) || !ide.DontTerminateDebugSession($"Project Build"))
809 BuildInterrim(prj, build, compiler, config, mods.ctrl && mods.shift);
815 bool ProjectLink(MenuItem selection, Modifiers mods)
817 Project prj = project;
818 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
819 ProjectConfig config;
820 if(selection || !ide.activeClient)
822 DataRow row = fileList.currentRow;
823 ProjectNode node = row ? (ProjectNode)row.tag : null;
824 if(node) prj = node.project;
828 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
833 if(!prj.GetConfigIsInDebugSession(config) ||
834 (!ide.DontTerminateDebugSession($"Project Link") && DebugStopForMake(prj, relink, compiler, config)))
836 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
838 ide.outputView.buildBox.Logf($"Relinking project %s using the %s configuration...\n", prj.name, GetConfigName(config));
840 config.linkingModified = true;
841 Build(prj, relink, compiler, config, mods.ctrl && mods.shift);
848 bool ProjectRebuild(MenuItem selection, Modifiers mods)
850 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
851 Project prj = project;
852 ProjectConfig config;
853 if(selection || !ide.activeClient)
855 DataRow row = fileList.currentRow;
856 ProjectNode node = row ? (ProjectNode)row.tag : null;
857 if(node) prj = node.project;
861 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
866 if(!prj.GetConfigIsInDebugSession(config) ||
867 (!ide.DontTerminateDebugSession($"Project Rebuild") && DebugStopForMake(prj, rebuild, compiler, config)))
869 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
871 ide.outputView.buildBox.Logf($"Rebuilding project %s using the %s configuration...\n", prj.name, GetConfigName(config));
874 config.compilingModified = true;
875 config.makingModified = true;
876 }*/ // -- should this still be used depite the new solution of BuildType?
877 Build(prj, rebuild, compiler, config, mods.ctrl && mods.shift);
884 bool ProjectClean(MenuItem selection, Modifiers mods)
886 Project prj = project;
887 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
888 ProjectConfig config;
889 if(selection || !ide.activeClient)
891 DataRow row = fileList.currentRow;
892 ProjectNode node = row ? (ProjectNode)row.tag : null;
893 if(node) prj = node.project;
897 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
902 if(!prj.GetConfigIsInDebugSession(config) ||
903 (!ide.DontTerminateDebugSession($"Project Clean") && DebugStopForMake(prj, clean, compiler, config)))
905 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
907 ide.outputView.buildBox.Logf($"Cleaning project %s using the %s configuration...\n", prj.name, GetConfigName(config));
909 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
910 ide.AdjustBuildMenus();
911 ide.AdjustDebugMenus();
913 prj.Clean(compiler, config, false, mods.ctrl && mods.shift);
914 buildInProgress = none;
915 ide.AdjustBuildMenus();
916 ide.AdjustDebugMenus();
923 bool ProjectRealClean(MenuItem selection, Modifiers mods)
925 Project prj = project;
926 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
927 ProjectConfig config;
928 if(selection || !ide.activeClient)
930 DataRow row = fileList.currentRow;
931 ProjectNode node = row ? (ProjectNode)row.tag : null;
932 if(node) prj = node.project;
936 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
941 if(!prj.GetConfigIsInDebugSession(config) ||
942 (!ide.DontTerminateDebugSession($"Project Real Clean") && DebugStopForMake(prj, clean, compiler, config)))
944 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
946 ide.outputView.buildBox.Logf($"Removing intermediate objects directory for project %s using the %s configuration...\n", prj.name, GetConfigName(config));
948 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
949 ide.AdjustBuildMenus();
950 ide.AdjustDebugMenus();
952 prj.Clean(compiler, config, true, mods.ctrl && mods.shift);
953 buildInProgress = none;
954 ide.AdjustBuildMenus();
955 ide.AdjustDebugMenus();
962 bool ProjectRegenerate(MenuItem selection, Modifiers mods)
964 Project prj = project;
965 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
966 ShowOutputBuildLog(true);
967 if(selection || !ide.activeClient)
969 DataRow row = fileList.currentRow;
970 ProjectNode node = row ? (ProjectNode)row.tag : null;
976 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
981 DisplayCompiler(compiler, false);
982 ProjectPrepareCompiler(project, compiler);
983 ProjectPrepareMakefile(prj, force, compiler, prj.config);
988 bool Compile(ProjectNode node, bool justPrint)
991 char fileName[MAX_LOCATION];
993 Project prj = node.project;
994 ProjectConfig config = prj.config;
995 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
999 // Check if we have to save
1000 strcpy(fileName, prj.topNode.path);
1001 PathCatSlash(fileName, node.path);
1002 PathCatSlash(fileName, node.name);
1003 for(document = ide.firstChild; document; document = document.next)
1005 if(document.modifiedDocument)
1007 char documentFileName[MAX_LOCATION];
1008 if(!fstrcmp(GetSlashPathBuffer(documentFileName, document.fileName), fileName))
1009 if(!document.MenuFileSave(null, 0))
1014 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
1016 if(!node.GetIsExcluded(config))
1018 // Delete intermedaite files
1020 char extension[MAX_EXTENSION];
1021 DirExpression objDir = prj.GetObjDir(compiler, config);
1023 strcpy(fileName, prj.topNode.path);
1024 PathCatSlash(fileName, objDir.dir);
1025 PathCatSlash(fileName, node.name);
1026 StripExtension(fileName);
1027 strcat(fileName, ".o");
1028 if(FileExists(fileName))
1029 DeleteFile(fileName);
1031 GetExtension(node.name, extension);
1032 if(!strcmp(extension, "ec"))
1034 // Delete generated C file
1035 strcpy(fileName, prj.topNode.path);
1036 PathCat(fileName, objDir.dir);
1037 PathCat(fileName, node.name);
1038 StripExtension(fileName);
1039 strcat(fileName, ".c");
1040 if(FileExists(fileName))
1041 DeleteFile(fileName);
1043 // Delete symbol file
1044 strcpy(fileName, prj.topNode.path);
1045 PathCat(fileName, node.path);
1046 PathCat(fileName, node.name);
1047 StripExtension(fileName);
1048 strcat(fileName, ".sym");
1049 if(FileExists(fileName))
1050 DeleteFile(fileName);
1055 buildInProgress = compilingFile;
1056 ide.AdjustBuildMenus();
1058 //ide.outputView.ShowClearSelectTab(build);
1059 // this stuff doesn't even appear
1060 //ide.outputView.buildBox.Logf($"%s Compiler\n", compiler.name);
1062 ide.outputView.buildBox.Logf($"Compiling single file %s in project %s using the %s configuration...\n", node.name, prj.name, config.name);
1064 ide.outputView.buildBox.Logf($"Compiling single file %s in project %s...\n", node.name, prj.name);
1066 prj.Compile(node, compiler, config, justPrint);
1067 buildInProgress = none;
1068 ide.AdjustBuildMenus();
1077 bool ProjectNewFile(MenuItem selection, Modifiers mods)
1079 DataRow row = fileList.currentRow;
1082 char fileName[1024];
1083 char filePath[MAX_LOCATION];
1084 ProjectNode parentNode = (ProjectNode)row.tag;
1085 ProjectNode n, fileNode;
1086 parentNode.GetFileSysMatchingPath(filePath);
1087 MakePathRelative(filePath, parentNode.project.topNode.path, filePath);
1088 for(n = parentNode; n && n != parentNode.project.resNode; n = n.parent);
1089 sprintf(fileName, $"Untitled %d", documentID);
1090 fileNode = AddFile(parentNode, fileName, (bool)n, true);
1091 fileNode.path = CopyUnixPath(filePath);
1094 NodeProperties nodeProperties
1097 position = { position.x + 100, position.y + 100 };
1101 nodeProperties.Create(); // not modal?
1107 bool ProjectNewFolder(MenuItem selection, Modifiers mods)
1109 DataRow row = fileList.currentRow;
1112 ProjectNode parentNode = (ProjectNode)row.tag;
1113 NewFolder(parentNode, null, true);
1118 bool ResourcesAddFiles(MenuItem selection, Modifiers mods)
1124 bool ProjectAddFiles(MenuItem selection, Modifiers mods)
1130 bool ProjectImportFolder(MenuItem selection, Modifiers mods)
1132 DataRow row = fileList.currentRow;
1135 ProjectNode toNode = (ProjectNode)row.tag;
1136 ImportFolder(toNode);
1141 bool ProjectAddNewForm(MenuItem selection, Modifiers mods)
1143 CodeEditor codeEditor = CreateNew("Form", "form", "Window", null);
1144 codeEditor.EnsureUpToDate();
1148 bool ProjectAddNewGraph(MenuItem selection, Modifiers mods)
1150 CodeEditor codeEditor = CreateNew("Graph", "graph", "Block", null);
1152 codeEditor.EnsureUpToDate();
1156 bool ProjectRemove(MenuItem selection, Modifiers mods)
1158 DataRow row = fileList.currentRow;
1161 ProjectNode node = (ProjectNode)row.tag;
1162 if(node.type == project)
1163 RemoveSelectedNodes();
1168 bool ProjectUpdateMakefileForAllConfigs(Project project)
1170 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1172 for(config : project.configurations)
1173 ProjectPrepareMakefile(project, forceExists, compiler, config);
1180 bool MenuConfig(MenuItem selection, Modifiers mods)
1182 if(ProjectActiveConfig { master = parent, project = project }.Modal() == ok)
1187 bool MenuCompiler(MenuItem selection, Modifiers mods)
1189 ActiveCompilerDialog compilerDialog
1192 ideSettings = ideSettings, workspaceActiveCompiler = ide.workspace.compiler;
1194 incref compilerDialog;
1195 if(compilerDialog.Modal() == ok && strcmp(compilerDialog.workspaceActiveCompiler, ide.workspace.compiler))
1197 CompilerConfig compiler = ideSettings.GetCompilerConfig(compilerDialog.workspaceActiveCompiler);
1198 ide.workspace.compiler = compilerDialog.workspaceActiveCompiler;
1199 ide.projectView.ShowOutputBuildLog(true);
1200 ide.projectView.DisplayCompiler(compiler, false);
1202 for(prj : ide.workspace.projects)
1203 ide.projectView.ProjectPrepareCompiler(prj, compiler);
1206 delete compilerDialog;
1210 bool MenuSettings(MenuItem selection, Modifiers mods)
1212 ProjectNode node = GetSelectedNode(true);
1213 Project prj = node ? node.project : project;
1214 projectSettingsDialog = ProjectSettings { master = parent, project = prj, projectNode = node };
1215 projectSettingsDialog.Modal();
1222 bool FileProperties(MenuItem selection, Modifiers mods)
1224 DataRow row = fileList.currentRow;
1227 ProjectNode node = (ProjectNode)row.tag;
1228 NodeProperties { parent = parent, master = this, node = node,
1229 position = { position.x + 100, position.y + 100 } }.Create();
1234 bool FileOpenFile(MenuItem selection, Modifiers mods)
1236 OpenSelectedNodes();
1240 bool FileRemoveFile(MenuItem selection, Modifiers mods)
1242 RemoveSelectedNodes();
1246 bool FileCompile(MenuItem selection, Modifiers mods)
1248 DataRow row = fileList.currentRow;
1251 ProjectNode node = (ProjectNode)row.tag;
1252 if(!Compile(node, mods.ctrl && mods.shift))
1253 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
1258 Project GetSelectedProject(bool useSelection)
1260 Project prj = project;
1263 DataRow row = fileList.currentRow;
1264 ProjectNode node = row ? (ProjectNode)row.tag : null;
1271 void SelectNextProject(bool backwards)
1273 DataRow row = fileList.currentRow;
1274 DataRow currentRow = row;
1275 ProjectNode node = (ProjectNode)row.tag;
1276 if(node.type != project)
1277 row = node.project.topNode.row;
1279 row = row.previous ? row.previous : fileList.lastRow;
1281 row = row.next ? row.next : fileList.firstRow;
1282 if(row && row != currentRow)
1284 fileList.SelectRow(row);
1285 fileList.currentRow = row;
1289 ProjectNode GetSelectedNode(bool useSelection)
1291 ProjectNode node = null;
1294 DataRow row = fileList.currentRow;
1296 node = (ProjectNode)row.tag;
1301 bool MenuBrowseFolder(MenuItem selection, Modifiers mods)
1303 char folder[MAX_LOCATION];
1305 ProjectNode node = GetSelectedNode(true);
1307 node = project.topNode;
1310 strcpy(folder, prj.topNode.path);
1311 if(node != prj.topNode)
1312 PathCatSlash(folder, node.path);
1317 bool Run(MenuItem selection, Modifiers mods)
1319 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1320 ProjectConfig config = project.config;
1321 String args = new char[maxPathLen];
1323 if(ide.workspace.commandLineArgs)
1324 //ide.debugger.GetCommandLineArgs(args);
1325 strcpy(args, ide.workspace.commandLineArgs);
1326 if(ide.debugger.isActive)
1327 project.Run(args, compiler, config);
1328 /*else if(config.targetType == sharedLibrary || config.targetType == staticLibrary)
1329 MessageBox { master = ide, type = ok, text = "Run", contents = "Shared and static libraries cannot be run like executables." }.Modal();*/
1330 else if(BuildInterrim(project, run, compiler, config, false))
1331 project.Run(args, compiler, config);
1339 bool result = false;
1340 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1341 ProjectConfig config = project.config;
1342 TargetTypes targetType = project.GetTargetType(config);
1343 if(targetType == sharedLibrary || targetType == staticLibrary)
1344 MessageBox { master = ide, type = ok, text = $"Run", contents = $"Shared and static libraries cannot be run like executables." }.Modal();
1345 else if(project.GetCompress(config))
1346 MessageBox { master = ide, text = $"Starting Debug", contents = $"Debugging compressed applications is not supported\n" }.Modal();
1347 else if(project.GetDebug(config) ||
1348 MessageBox { master = ide, type = okCancel, text = $"Starting Debug", contents = $"Attempting to debug non-debug configuration\nProceed anyways?" }.Modal() == ok)
1350 if(/*!IsProjectModified() ||*/ BuildInterrim(project, start, compiler, config, false))
1352 if(compiler.type.isVC)
1354 //bool result = false;
1355 char oldwd[MAX_LOCATION];
1356 PathBackup pathBackup { };
1357 char command[MAX_LOCATION];
1359 ide.SetPath(false, compiler, config);
1361 GetWorkingDir(oldwd, sizeof(oldwd));
1362 ChangeWorkingDir(project.topNode.path);
1364 sprintf(command, "%s /useenv %s.sln /projectconfig \"%s|Win32\" /command \"%s\"" , "devenv", project.name, config.name, "Debug.Start");
1366 ChangeWorkingDir(oldwd);
1372 ide.debugger.Start(compiler, config);
1381 void GoToError(const char * line)
1385 while(isspace(*line)) line++;
1386 colon = strstr(line, ":");
1391 bool lookForLineNumber = true;
1393 // deal with linking error
1394 if(colon && colon[1] == ' ')
1396 colon = strstr(colon + 1, ":");
1397 if(colon && !colon[1])
1399 colon = strstr(line, ":");
1400 lookForLineNumber = false;
1402 else if(colon && !isdigit(colon[1]))
1405 colon = strstr(line, ":");
1408 // Don't be mistaken by the drive letter colon
1409 if(colon && (colon[1] == '/' || colon[1] == '\\'))
1410 colon = strstr(colon + 1, ":");
1411 if(colon && lookForLineNumber)
1415 char * par = RSearchString(line, "(", colon - line, true, false);
1416 if(par && strstr(par, ")"))
1418 else if((colon+1)[0] == ' ')
1420 // NOTE: This is the same thing as saying 'colon = line'
1421 for( ; colon != line; colon--)
1425 lineNumber = atoi(colon + 1);
1427 comma = strchr(colon, ',');
1429 col = atoi(comma+1);
1431 comma = strchr(colon+1, ':');
1433 col = atoi(comma+1);
1437 char moduleName[MAX_LOCATION], filePath[MAX_LOCATION];
1441 char * inFileIncludedFrom = strstr(line, stringInFileIncludedFrom);
1442 char * start = inFileIncludedFrom ? line + strlen(stringInFileIncludedFrom) : line;
1443 int len = (int)(colon - start);
1444 len = Min(len, MAX_LOCATION-1);
1446 strncpy(moduleName, start, len);
1447 moduleName[len] = '\0';
1450 strcpy(moduleName, line);
1452 // Remove stuff in brackets
1454 bracket = strstr(moduleName, "(");
1455 if(bracket) *bracket = '\0';
1457 MakeSlashPath(moduleName);
1461 // Check if it's one of our modules
1462 ProjectNode node = project.topNode.Find(moduleName, false);
1465 strcpy(moduleName, node.path);
1466 PathCatSlash(moduleName, node.name);
1469 moduleName[0] = '\0';
1473 CodeEditor codeEditor;
1474 strcpy(filePath, project.topNode.path);
1475 PathCatSlash(filePath, moduleName);
1477 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
1480 char name[MAX_LOCATION];
1481 // TOFIX: Improve on this, don't use only filename, make a function
1482 if(ide && ide.workspace)
1484 for(prj : ide.workspace.projects)
1486 if(prj.topNode.FindWithPath(moduleName, false))
1488 strcpy(filePath, prj.topNode.path);
1489 PathCatSlash(filePath, moduleName);
1490 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
1497 if(codeEditor && lineNumber)
1499 EditBox editBox = codeEditor.editBox;
1500 editBox.GoToLineNum(lineNumber - 1);
1501 editBox.GoToPosition(editBox.line, lineNumber - 1, col ? (col - 1) : 0);
1508 bool OpenNode(ProjectNode node)
1510 char filePath[MAX_LOCATION];
1511 node.GetFullFilePath(filePath);
1512 return ide.OpenFile(filePath, normal, true/*false Why was it opening hidden?*/, null, something, normal) ? true : false;
1515 void AddNode(ProjectNode node, DataRow addTo)
1517 DataRow row = addTo ? addTo.AddRow() : fileList.AddRow();
1519 row.tag = (int)node;
1522 if(node.type == resources)
1525 row.SetData(null, node);
1527 if(node.files && node.files.first && node.parent &&
1528 !(!node.parent.parent &&
1529 (!strcmpi(node.name, "notes") || !strcmpi(node.name, "sources") ||
1530 !strcmpi(node.name, "src") || !strcmpi(node.name, "tools"))))
1531 row.collapsed = true;
1532 else if(node.type == folder)
1533 node.icon = openFolder;
1537 for(child : node.files)
1538 AddNode(child, row);
1542 void DeleteNode(ProjectNode projectNode)
1544 if(projectNode.files)
1547 while(child = projectNode.files.first)
1550 fileList.DeleteRow(projectNode.row);
1551 projectNode.Delete();
1554 bool ProjectSave(MenuItem selection, Modifiers mods)
1556 DataRow row = fileList.currentRow;
1557 ProjectNode node = row ? (ProjectNode)row.tag : null;
1558 Project prj = node ? node.project : null;
1561 prj.StopMonitoring();
1562 if(prj.Save(prj.filePath))
1564 Project modPrj = null;
1565 prj.topNode.modified = false;
1566 for(p : ide.workspace.projects)
1568 if(p.topNode.modified)
1575 modifiedDocument = false;
1578 prj.StartMonitoring();
1583 bool ShowOutputBuildLog(bool cleanLog)
1585 OutputView output = ide.outputView;
1587 output.ShowClearSelectTab(build);
1590 output.SelectTab(build);
1598 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1599 ProjectConfig config = project.config;
1601 bool result = false;
1602 if(/*!IsProjectModified() ||*/ BuildInterrim(project, restart, compiler, config, false))
1604 // For Restart, compiler and config will only be used if for
1605 // whatever reason (if at all possible) the Debugger is in a
1606 // 'terminated' or 'none' state
1607 ide.debugger.Restart(compiler, config);
1617 ide.debugger.Resume();
1623 ide.debugger.Break();
1629 ide.debugger.Stop();
1633 bool DebugStepInto()
1635 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1636 ProjectConfig config = project.config;
1638 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config, false)))
1639 ide.debugger.StepInto(compiler, config);
1644 bool DebugStepOver(bool skip)
1646 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1647 ProjectConfig config = project.config;
1649 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config, false)))
1650 ide.debugger.StepOver(compiler, config, skip);
1656 bool DebugStepOut(bool skip)
1658 ide.debugger.StepOut(skip);
1662 void ImportFolder(ProjectNode toNode)
1666 //bool isFolder = toNode.type == folder;
1667 //bool isRes = toNode.isInResources;
1669 FileDialog fileDialog = importFileDialog;
1670 fileDialog.master = parent;
1671 if(fileDialog.Modal() == ok)
1673 ImportFolderFSI fsi { projectView = this };
1674 fsi.stack.Add(toNode);
1675 fsi.Iterate(fileDialog.filePath);
1681 ProjectNode NewFolder(ProjectNode parentNode, char * name, bool showProperties)
1685 ProjectNode folderNode;
1686 Project prj = parentNode.project;
1688 ProjectNode after = null;
1689 for(node : parentNode.files)
1691 if(node.type != folder)
1697 folderNode = parentNode.Add(prj, name, after, folder, folder, true);
1700 for(c = 0; c < 100; c++)
1703 sprintf(string, c ? "New Folder (%d)" : "New Folder", c);
1704 if((folderNode = parentNode.Add(prj, string, after, folder, folder, true)))
1711 NodeProperties nodeProperties;
1714 modifiedDocument = true;
1715 prj.topNode.modified = true;
1718 folderNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
1719 folderNode.row.tag = (int)folderNode;
1721 folderNode.row.SetData(null, folderNode);
1722 fileList.currentRow = folderNode.row;
1726 nodeProperties = NodeProperties
1728 parent, this, mode = newFolder, node = folderNode;
1729 position = { position.x + 100, position.y + 100 };
1731 nodeProperties.Create(); // Modal?
1739 void AddFiles(bool resources)
1741 FileDialog fileDialog = (!resources) ? this.fileDialog : resourceFileDialog;
1742 fileDialog.type = multiOpen;
1743 fileDialog.text = !resources ? $"Add Files to Project" : $"Add Resources to Project";
1744 fileDialog.master = parent;
1746 if(fileDialog.Modal() == ok)
1749 DataRow row = fileList.currentRow;
1750 ProjectNode parentNode = (ProjectNode)row.tag;
1751 bool addFailed = false;
1752 int numSelections = fileDialog.numSelections;
1753 char ** multiFilePaths = fileDialog.multiFilePaths;
1755 Array<String> nameConflictFiles { };
1757 for(c = 0; c < numSelections; c++)
1759 char * filePath = multiFilePaths[c];
1760 FileAttribs exists = FileExists(filePath);
1761 bool addThisFile = true;
1763 if(exists.isDirectory)
1764 addThisFile = false;
1767 if(MessageBox { master = ide, type = yesNo, text = filePath,
1768 contents = $"File doesn't exist. Create?" }.Modal() == yes)
1770 File f = FileOpen(filePath, write);
1778 MessageBox { master = ide, type = ok, text = filePath,
1779 contents = $"Couldn't create file."}.Modal();
1780 addThisFile = false;
1787 /*addFailed = */if(!AddFile(parentNode, filePath, resources, false))//;
1789 nameConflictFiles.Add(CopyString(filePath));
1797 char * part1 = $"The following file";
1798 char * opt1 = $" was ";
1799 char * opt2 = $"s were ";
1800 char * part2 = $"not added because of identical file name conflict within the project.\n\n";
1802 len += strlen(part1);
1803 len += strlen(part2);
1804 len += nameConflictFiles.count > 1 ? strlen(opt2) : strlen(opt1);
1805 for(s : nameConflictFiles)
1806 len += strlen(s) + 1;
1807 message = new char[len + 1];
1808 strcpy(message, part1);
1809 strcat(message, nameConflictFiles.count > 1 ? opt2 : opt1);
1810 strcat(message, part2);
1811 for(s : nameConflictFiles)
1814 strcat(message, "\n");
1816 MessageBox { master = ide, type = ok, text = $"Name Conflict",
1817 contents = message }.Modal();
1820 nameConflictFiles.Free();
1821 delete nameConflictFiles;
1825 ProjectNode AddFile(ProjectNode parentNode, char * filePath, bool resources, bool isTemporary)
1827 ProjectNode result = null;
1828 ProjectNode after = null;
1829 for(node : parentNode.files)
1831 if(node.type != folder && node.type != file && node.type)
1836 result = parentNode.Add(parentNode.project, filePath, after, file, NodeIcons::SelectFileIcon(filePath), !resources);
1842 modifiedDocument = true;
1843 parentNode.project.topNode.modified = true;
1844 parentNode.project.ModifiedAllConfigs(true, false, true, true);
1847 result.row = parentNode.row.AddRowAfter(after ? after.row : null);
1848 result.row.tag = (int)result;
1849 result.row.SetData(null, result);
1854 CodeEditor CreateNew(char * upper, char * lower, char * base, char * className)
1856 CodeEditor codeEditor = null;
1857 ProjectNode projectNode;
1858 ProjectNode after = null;
1859 DataRow row = fileList.currentRow;
1860 ProjectNode parentNode;
1863 if(!row) row = project.topNode.row;
1865 parentNode = (ProjectNode)row.tag;
1867 for(node : parentNode.files)
1869 if(node.type != folder && node.type != file && node.type)
1873 for(c = 1; c < 100; c++)
1876 sprintf(string, c ? "%s%d.ec" : "%s.ec", lower, c);
1877 if((projectNode = parentNode.Add(project, string, after, file, genFile, true)))
1883 char filePath[MAX_LOCATION];
1885 modifiedDocument = true;
1886 project.topNode.modified = true;
1888 project.ModifiedAllConfigs(true, false, false, true);
1889 projectNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
1890 projectNode.row.tag =(int)projectNode;
1892 projectNode.row.SetData(null, projectNode);
1893 fileList.currentRow = projectNode.row;
1895 strcpy(filePath, project.topNode.path);
1896 PathCat(filePath, projectNode.path);
1897 PathCat(filePath, projectNode.name);
1899 codeEditor = (CodeEditor)ide.FindWindow(filePath);
1902 Class baseClass = eSystem_FindClass(__thisModule, base);
1903 subclass(ClassDesignerBase) designerClass = eClass_GetDesigner(baseClass);
1906 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal);
1907 strcpy(name, projectNode.name);
1908 sprintf(name, "%s%d", upper, c);
1910 strcpy(className, name);
1912 designerClass.CreateNew(codeEditor.editBox, codeEditor.clientSize, name, base);
1914 //codeEditor.modifiedDocument = false;
1915 //codeEditor.designer.modifiedDocument = false;
1917 //Code_EnsureUpToDate(codeEditor);
1920 else // TODO: fix no symbols generated when ommiting {} for following else
1922 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal);
1926 codeEditor.ViewDesigner();
1927 codeEditor.codeModified = true;
1934 // Returns true if we opened something
1935 bool OpenSelectedNodes()
1937 bool result = false;
1941 fileList.GetMultiSelection(selection);
1942 for(item = selection.first; item; item = item.next)
1944 DataRow row = item.data;
1945 ProjectNode node = (ProjectNode)row.tag;
1946 if(node.type == file)
1953 selection.Free(null);
1957 void RemoveSelectedNodes()
1962 fileList.GetMultiSelection(selection);
1964 // Remove children of parents we're deleting
1965 for(item = selection.first; item; item = next)
1968 DataRow row = item.data;
1969 ProjectNode n, node = (ProjectNode)row.tag;
1970 bool remove = false;
1973 for(i = selection.first; i && !remove; i = i.next)
1975 ProjectNode iNode = (ProjectNode)((DataRow)i.data).tag;
1976 for(n = node.parent; n; n = n.parent)
1986 selection.Delete(item);
1989 for(item = selection.first; item; item = item.next)
1991 DataRow row = item.data;
1992 ProjectNode node = (ProjectNode)row.tag;
1993 ProjectNode resNode;
1994 for(resNode = node.parent; resNode; resNode = resNode.parent)
1995 if(resNode.type == resources)
1997 if(node.type == file)
1999 Project prj = node.project;
2001 modifiedDocument = true;
2002 prj.topNode.modified = true;
2004 prj.ModifiedAllConfigs(true, false, true, true);
2006 else if(node.type == folder)
2009 sprintf(message, $"Are you sure you want to remove the folder \"%s\"\n"
2010 "and all of its contents from the project?", node.name);
2011 if(MessageBox { master = ide, type = yesNo, text = $"Delete Folder", contents = message }.Modal() == yes)
2013 Project prj = node.project;
2014 if(node.containsFile)
2015 prj.ModifiedAllConfigs(true, false, true, true);
2017 modifiedDocument = true;
2018 prj.topNode.modified = true;
2021 else if(node.type == project && node != project.topNode && !buildInProgress)
2025 for(p : workspace.projects)
2027 if(p.topNode == node)
2033 sprintf(message, $"Are you sure you want to remove the \"%s\" project\n" "from this workspace?", node.name);
2034 if(MessageBox { master = ide, type = yesNo, text = $"Remove Project", contents = message }.Modal() == yes)
2039 workspace.RemoveProject(prj);
2040 //modifiedDocument = true; // when project view is a workspace view
2044 selection.Free(null);