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 NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch)
323 ProjectNode node = (ProjectNode)row.tag;
326 case altEnter: case Key { keyPadEnter, alt = true }:
328 NodeProperties { parent = parent, master = this,
329 position = { position.x + 100, position.y + 100 }, node = node }.Create();
332 case enter: case keyPadEnter:
335 for(resNode = node.parent; resNode; resNode = resNode.parent)
336 if(resNode.type == resources)
338 if(node.type == project || (node.type == folder && !resNode))
343 else if(node.type == resources || node.type == folder)
352 if(node.type == project || node.type == folder || node.type == resources)
361 if(node.type == project || node.type == folder || node.type == resources)
363 NewFolder(node, null, true);
370 if(node.type == file)
372 FileCompile(null, (Modifiers)key);
377 case Key { space, shift = true }:
380 if(node.type == NodeTypes::project)
383 for(p : workspace.projects)
385 if(p.topNode == node)
391 prj.RotateActiveConfig(!key.shift);
402 case enter: case keyPadEnter: OpenSelectedNodes(); break;
403 case del: RemoveSelectedNodes(); break;
406 Window activeClient = ide.activeClient;
408 activeClient.Activate();
410 ide.RepositionWindows(true);
417 bool NotifyCollapse(ListBox listBox, DataRow row, bool collapsed)
419 ProjectNode node = (ProjectNode)row.tag;
420 if(node.type == folder)
421 node.icon = collapsed ? folder : openFolder;
426 FileDialog importFileDialog { autoCreate = false, type = selectDir, text = $"Import Folder" };
427 FileDialog projectFileDialog
429 autoCreate = false, filters = projectFilters.array, sizeFilters = projectFilters.count * sizeof(FileFilter);
430 types = projectTypes.array, sizeTypes = projectTypes.count * sizeof(FileType);
432 FileDialog fileDialog
434 autoCreate = false, mayNotExist = true, filters = fileFilters.array, sizeFilters = fileFilters.count * sizeof(FileFilter);
436 FileDialog resourceFileDialog
438 autoCreate = false, mayNotExist = true, filters = resourceFilters.array, sizeFilters = resourceFilters.count * sizeof(FileFilter);
441 Menu fileMenu { menu, $"File", f };
442 MenuItem { fileMenu, $"Save", s, Key { s, ctrl = true }, NotifySelect = MenuFileSave };
443 // MenuItem { fileMenu, "Save As...", a, NotifySelect = MenuFileSaveAs };
445 bool OnClose(bool parentClosing)
447 if(!parentClosing && visible)
457 DialogResult dialogRes;
460 strcpy(msg, $"You have modified projects.\nSave changes to ");
461 for(p : ide.workspace.projects)
463 if(p.topNode.modified)
465 if(!first) strcat(msg, ", ");
472 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = msg }.Modal();
476 // TOFIX: Precomp error if brackets are taken out
477 return (DialogResult)MenuFileSave(null, 0) != cancel;
479 else if(dialogRes == cancel)
481 modifiedDocument = false;
488 //if(ide.findInFilesDialog && ide.findInFilesDialog.created && ide.findInFilesDialog.mode != directory)
489 // ide.findInFilesDialog.SearchStop();
491 ide.outputView.buildBox.Clear();
492 ide.outputView.debugBox.Clear();
493 //ide.outputView.findBox.Clear();
494 ide.callStackView.Clear();
495 ide.watchesView.Clear();
496 ide.threadsView.Clear();
497 ide.breakpointsView.Clear();
498 ide.outputView.ShowClearSelectTab(find); // why this?
501 bool OnSaveFile(char * fileName)
503 for(prj : ide.workspace.projects)
505 if(prj.topNode.modified)
507 prj.StopMonitoring();
508 if(prj.Save(prj.filePath))
510 // ShowOutputBuildLog(true);
511 // DisplayCompiler(compiler, false);
512 // ProjectUpdateMakefileForAllConfigs(prj);
513 prj.topNode.modified = false;
515 prj.StartMonitoring();
518 modifiedDocument = false;
523 bool IsModuleInProject(char * filePath)
525 char moduleName[MAX_FILENAME]; //, modulePath[MAX_LOCATION];
526 GetLastDirectory(filePath, moduleName);
527 return project.topNode.Find(moduleName, false) != null;
530 bool GetRelativePath(char * filePath, char * relativePath)
532 return project.GetRelativePath(filePath, relativePath);
535 ProjectNode GetNodeFromWindow(Window document, Project project)
537 if(document.fileName)
539 char winFileName[MAX_LOCATION];
540 char * documentFileName = GetSlashPathBuffer(winFileName, document.fileName);
541 for(p : ide.workspace.projects)
543 Project prj = project ? project : p;
545 if((node = prj.topNode.FindByFullPath(documentFileName, false)))
553 // ((( UTILITY FUNCTIONS )))
555 // ************************************************************************
556 // *** These methods below are part of a sequence of events, and as ***
557 // *** such they must be passed the current compiler and project config ***
558 // ************************************************************************
559 bool DisplayCompiler(CompilerConfig compiler, bool cleanLog)
561 ide.outputView.buildBox.Logf($"%s Compiler\n", compiler ? compiler.name : $"{problem with compiler selection}");
564 bool ProjectPrepareForToolchain(Project project, PrepareMakefileMethod method, bool cleanLog, bool displayCompiler,
565 CompilerConfig compiler, ProjectConfig config)
568 char message[MAX_F_STRING];
569 LogBox logBox = ide.outputView.buildBox;
571 ShowOutputBuildLog(cleanLog);
574 DisplayCompiler(compiler, false);
576 ProjectPrepareMakefile(project, method, false, false, compiler, config);
580 bool ProjectPrepareMakefile(Project project, PrepareMakefileMethod method, bool cleanLog, bool displayCompiler,
581 CompilerConfig compiler, ProjectConfig config)
583 char makefilePath[MAX_LOCATION];
584 char makefileName[MAX_LOCATION];
586 LogBox logBox = ide.outputView.buildBox;
589 DisplayCompiler(compiler, false);
591 strcpy(makefilePath, project.topNode.path);
592 project.CatMakeFileName(makefileName, config);
593 PathCatSlash(makefilePath, makefileName);
595 exists = FileExists(makefilePath);
596 if((method == normal && (!exists || config.makingModified/*|| project.topNode.modified*/)) ||
597 (method == forceExists && exists) ||
598 method == force) // || config.makingModified || makefileDirty
602 ide.statusBar.text = $"Generating Makefile & Dependencies..."; // Dependencies?
605 if((method == normal && !exists) || (method == force && !exists))
606 action = $"Generating ";
607 else if(method == force)
608 action = $"Regenerating ";
609 else if(method == normal || method == forceExists)
610 action = $"Updating ";
614 reason = $"Makefile doesn't exist. ";
615 else if(project.topNode.modified)
616 reason = $"Project has been modified. ";
620 //logBox.Logf("%s\n", makefileName);
621 logBox.Logf($"%s - %s%smakefile for %s config...\n", makefileName, reason, action, GetConfigName(config));
623 project.GenerateCrossPlatformCf();
624 project.GenerateCompilerMk(compiler);
625 project.GenerateMakefile(null, false, null, compiler, config);
627 ide.statusBar.text = null;
634 bool BuildInterrim(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config)
636 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
638 ide.outputView.buildBox.Logf($"Building project %s using the %s configuration...\n", prj.name, GetConfigName(config));
639 return Build(prj, buildType, compiler, config);
644 bool DebugStopForMake(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config)
647 // TOFIX: DebugStop is being abused and backfiring on us.
648 // It's supposed to be the 'Debug/Stop' item, not unloading executable or anything else
650 // configIsInDebugSession seems to be used for two OPPOSITE things:
651 // If we're debugging another config, we need to unload the executable!
652 // In building, we want to stop if we're debugging the 'same' executable
653 if(buildType != run) ///* && prj == project*/ && prj.configIsInDebugSession)
655 if(buildType == start || buildType == restart)
657 if(ide.debugger && ide.debugger.isPrepared)
658 result = DebugStop();
662 if(ide.project == prj && ide.debugger && ide.debugger.prjConfig == config && ide.debugger.isPrepared)
663 result = DebugStop();
669 bool Build(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config)
675 for(document = master.firstChild; document; document = document.next)
677 if(document.modifiedDocument)
679 ProjectNode node = GetNodeFromWindow(document, prj);
680 if(node && !document.MenuFileSave(null, 0))
689 DirExpression targetDir = prj.GetTargetDir(compiler, config);
691 DebugStopForMake(prj, buildType, compiler, config);
693 // TODO: Disabled until problems fixed... is it fixed?
694 if(buildType == rebuild || (config && config.compilingModified))
695 prj.Clean(compiler, config, false);
698 if(buildType == relink || (config && config.linkingModified))
700 char target[MAX_LOCATION];
702 strcpy(target, prj.topNode.path);
703 PathCat(target, targetDir.dir);
704 prj.CatTargetFileName(target, compiler, config);
705 if(FileExists(target))
708 if(config && config.symbolGenModified)
710 DirExpression objDir = prj.GetObjDir(compiler, config);
711 char fileName[MAX_LOCATION];
712 char moduleName[MAX_FILENAME];
713 strcpy(fileName, prj.topNode.path);
714 PathCatSlash(fileName, objDir.dir);
715 strcpy(moduleName, prj.moduleName);
716 strcat(moduleName, ".main.ec");
717 PathCatSlash(fileName, moduleName);
718 if(FileExists(fileName))
719 DeleteFile(fileName);
720 ChangeExtension(fileName, "c", fileName);
721 if(FileExists(fileName))
722 DeleteFile(fileName);
723 ChangeExtension(fileName, "o", fileName);
724 if(FileExists(fileName))
725 DeleteFile(fileName);
730 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
731 ide.AdjustBuildMenus();
732 ide.AdjustDebugMenus();
734 result = prj.Build(buildType == run, null, compiler, config);
738 config.compilingModified = false;
739 if(!ide.ShouldStopBuild())
740 config.linkingModified = false;
742 config.symbolGenModified = false;
744 buildInProgress = none;
745 ide.AdjustBuildMenus();
746 ide.AdjustDebugMenus();
748 ide.workspace.modified = true;
755 // ((( USER ACTIONS )))
757 // ************************************************************************
758 // *** Methods below should atomically start a process, and as such ***
759 // *** they can query compiler and config directly from ide and project ***
760 // *** but ONLY ONCE!!! ***
761 // ************************************************************************
763 bool ProjectBuild(MenuItem selection, Modifiers mods)
765 Project prj = project;
766 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
767 ProjectConfig config;
768 if(selection || !ide.activeClient)
770 DataRow row = fileList.currentRow;
771 ProjectNode node = row ? (ProjectNode)row.tag : null;
772 if(node) prj = node.project;
776 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
781 if(/*prj != project || */!prj.GetConfigIsInDebugSession(config) || !ide.DontTerminateDebugSession($"Project Build"))
783 BuildInterrim(prj, build, compiler, config);
789 bool ProjectLink(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.GetConfigIsInDebugSession(config) ||
808 (!ide.DontTerminateDebugSession($"Project Link") && DebugStopForMake(prj, relink, compiler, config)))
810 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
812 ide.outputView.buildBox.Logf($"Relinking project %s using the %s configuration...\n", prj.name, GetConfigName(config));
814 config.linkingModified = true;
815 Build(prj, relink, compiler, config);
822 bool ProjectRebuild(MenuItem selection, Modifiers mods)
824 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
825 Project prj = project;
826 ProjectConfig config;
827 if(selection || !ide.activeClient)
829 DataRow row = fileList.currentRow;
830 ProjectNode node = row ? (ProjectNode)row.tag : null;
831 if(node) prj = node.project;
835 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
840 if(!prj.GetConfigIsInDebugSession(config) ||
841 (!ide.DontTerminateDebugSession($"Project Rebuild") && DebugStopForMake(prj, rebuild, compiler, config)))
843 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
845 ide.outputView.buildBox.Logf($"Rebuilding project %s using the %s configuration...\n", prj.name, GetConfigName(config));
848 config.compilingModified = true;
849 config.makingModified = true;
850 }*/ // -- should this still be used depite the new solution of BuildType?
851 Build(prj, rebuild, compiler, config);
858 bool ProjectClean(MenuItem selection, Modifiers mods)
860 Project prj = project;
861 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
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 Clean") && DebugStopForMake(prj, clean, compiler, config)))
879 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
881 ide.outputView.buildBox.Logf($"Cleaning project %s using the %s configuration...\n", prj.name, GetConfigName(config));
883 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
884 ide.AdjustBuildMenus();
885 ide.AdjustDebugMenus();
887 prj.Clean(compiler, config, false);
888 buildInProgress = none;
889 ide.AdjustBuildMenus();
890 ide.AdjustDebugMenus();
897 bool ProjectRealClean(MenuItem selection, Modifiers mods)
899 Project prj = project;
900 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
901 ProjectConfig config;
902 if(selection || !ide.activeClient)
904 DataRow row = fileList.currentRow;
905 ProjectNode node = row ? (ProjectNode)row.tag : null;
906 if(node) prj = node.project;
910 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
915 if(!prj.GetConfigIsInDebugSession(config) ||
916 (!ide.DontTerminateDebugSession($"Project Real Clean") && DebugStopForMake(prj, clean, compiler, config)))
918 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
920 ide.outputView.buildBox.Logf($"Removing intermediate objects directory for project %s using the %s configuration...\n", prj.name, GetConfigName(config));
922 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
923 ide.AdjustBuildMenus();
924 ide.AdjustDebugMenus();
926 prj.Clean(compiler, config, true);
927 buildInProgress = none;
928 ide.AdjustBuildMenus();
929 ide.AdjustDebugMenus();
936 bool ProjectRegenerate(MenuItem selection, Modifiers mods)
938 Project prj = project;
939 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
940 ShowOutputBuildLog(true);
941 if(selection || !ide.activeClient)
943 DataRow row = fileList.currentRow;
944 ProjectNode node = row ? (ProjectNode)row.tag : null;
950 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
955 ProjectPrepareMakefile(prj, force, true, true, compiler, prj.config);
960 bool Compile(ProjectNode node)
963 char fileName[MAX_LOCATION];
965 Project prj = node.project;
966 ProjectConfig config = prj.config;
967 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
971 // Check if we have to save
972 strcpy(fileName, prj.topNode.path);
973 PathCatSlash(fileName, node.path);
974 PathCatSlash(fileName, node.name);
975 for(document = ide.firstChild; document; document = document.next)
977 if(document.modifiedDocument)
979 char documentFileName[MAX_LOCATION];
980 if(!fstrcmp(GetSlashPathBuffer(documentFileName, document.fileName), fileName))
981 if(!document.MenuFileSave(null, 0))
986 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
988 if(!node.GetIsExcluded(config))
990 // Delete intermedaite files
992 char extension[MAX_EXTENSION];
993 DirExpression objDir = prj.GetObjDir(compiler, config);
995 strcpy(fileName, prj.topNode.path);
996 PathCatSlash(fileName, objDir.dir);
997 PathCatSlash(fileName, node.name);
998 StripExtension(fileName);
999 strcat(fileName, ".o");
1000 if(FileExists(fileName))
1001 DeleteFile(fileName);
1003 GetExtension(node.name, extension);
1004 if(!strcmp(extension, "ec"))
1006 // Delete generated C file
1007 strcpy(fileName, prj.topNode.path);
1008 PathCat(fileName, objDir.dir);
1009 PathCat(fileName, node.name);
1010 StripExtension(fileName);
1011 strcat(fileName, ".c");
1012 if(FileExists(fileName))
1013 DeleteFile(fileName);
1015 // Delete symbol file
1016 strcpy(fileName, prj.topNode.path);
1017 PathCat(fileName, node.path);
1018 PathCat(fileName, node.name);
1019 StripExtension(fileName);
1020 strcat(fileName, ".sym");
1021 if(FileExists(fileName))
1022 DeleteFile(fileName);
1027 buildInProgress = compilingFile;
1028 ide.AdjustBuildMenus();
1030 //ide.outputView.ShowClearSelectTab(build);
1031 // this stuff doesn't even appear
1032 //ide.outputView.buildBox.Logf($"%s Compiler\n", compiler.name);
1034 ide.outputView.buildBox.Logf($"Compiling single file %s in project %s using the %s configuration...\n", node.name, prj.name, config.name);
1036 ide.outputView.buildBox.Logf($"Compiling single file %s in project %s...\n", node.name, prj.name);
1038 prj.Compile(node, compiler, config);
1039 buildInProgress = none;
1040 ide.AdjustBuildMenus();
1049 bool ProjectNewFile(MenuItem selection, Modifiers mods)
1051 DataRow row = fileList.currentRow;
1054 char fileName[1024];
1055 char filePath[MAX_LOCATION];
1056 ProjectNode parentNode = (ProjectNode)row.tag;
1057 ProjectNode n, fileNode;
1058 parentNode.GetFileSysMatchingPath(filePath);
1059 MakePathRelative(filePath, parentNode.project.topNode.path, filePath);
1060 for(n = parentNode; n && n != parentNode.project.resNode; n = n.parent);
1061 sprintf(fileName, $"Untitled %d", documentID);
1062 fileNode = AddFile(parentNode, fileName, (bool)n, true);
1063 fileNode.path = CopyUnixPath(filePath);
1066 NodeProperties nodeProperties
1069 position = { position.x + 100, position.y + 100 };
1073 nodeProperties.Create(); // not modal?
1079 bool ProjectNewFolder(MenuItem selection, Modifiers mods)
1081 DataRow row = fileList.currentRow;
1084 ProjectNode parentNode = (ProjectNode)row.tag;
1085 NewFolder(parentNode, null, true);
1090 bool ResourcesAddFiles(MenuItem selection, Modifiers mods)
1096 bool ProjectAddFiles(MenuItem selection, Modifiers mods)
1102 bool ProjectImportFolder(MenuItem selection, Modifiers mods)
1104 DataRow row = fileList.currentRow;
1107 ProjectNode toNode = (ProjectNode)row.tag;
1108 ImportFolder(toNode);
1113 bool ProjectAddNewForm(MenuItem selection, Modifiers mods)
1115 CodeEditor codeEditor = CreateNew("Form", "form", "Window", null);
1116 codeEditor.EnsureUpToDate();
1120 bool ProjectAddNewGraph(MenuItem selection, Modifiers mods)
1122 CodeEditor codeEditor = CreateNew("Graph", "graph", "Block", null);
1124 codeEditor.EnsureUpToDate();
1128 bool ProjectRemove(MenuItem selection, Modifiers mods)
1130 DataRow row = fileList.currentRow;
1133 ProjectNode node = (ProjectNode)row.tag;
1134 if(node.type == project)
1135 RemoveSelectedNodes();
1140 bool ProjectUpdateMakefileForAllConfigs(Project project)
1142 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1144 for(config : project.configurations)
1146 ProjectPrepareMakefile(project, forceExists, false, false,
1154 bool MenuConfig(MenuItem selection, Modifiers mods)
1156 if(ProjectActiveConfig { master = parent, project = project }.Modal() == ok)
1161 bool MenuCompiler(MenuItem selection, Modifiers mods)
1163 ActiveCompilerDialog compilerDialog
1166 ideSettings = ideSettings, workspaceActiveCompiler = ide.workspace.compiler;
1168 incref compilerDialog;
1169 if(compilerDialog.Modal() == ok && strcmp(compilerDialog.workspaceActiveCompiler, ide.workspace.compiler))
1171 CompilerConfig compiler = ideSettings.GetCompilerConfig(compilerDialog.workspaceActiveCompiler);
1172 ide.workspace.compiler = compilerDialog.workspaceActiveCompiler;
1173 ide.projectView.ShowOutputBuildLog(true);
1174 ide.projectView.DisplayCompiler(compiler, false);
1175 for(prj : ide.workspace.projects)
1176 ide.projectView.ProjectUpdateMakefileForAllConfigs(prj);
1179 delete compilerDialog;
1183 bool MenuSettings(MenuItem selection, Modifiers mods)
1185 ProjectNode node = GetSelectedNode(true);
1186 Project prj = node ? node.project : project;
1187 projectSettingsDialog = ProjectSettings { master = parent, project = prj, projectNode = node };
1188 projectSettingsDialog.Modal();
1195 bool FileProperties(MenuItem selection, Modifiers mods)
1197 DataRow row = fileList.currentRow;
1200 ProjectNode node = (ProjectNode)row.tag;
1201 NodeProperties { parent = parent, master = this, node = node,
1202 position = { position.x + 100, position.y + 100 } }.Create();
1207 bool FileOpenFile(MenuItem selection, Modifiers mods)
1209 OpenSelectedNodes();
1213 bool FileRemoveFile(MenuItem selection, Modifiers mods)
1215 RemoveSelectedNodes();
1219 bool FileCompile(MenuItem selection, Modifiers mods)
1221 DataRow row = fileList.currentRow;
1224 ProjectNode node = (ProjectNode)row.tag;
1226 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
1231 Project GetSelectedProject(bool useSelection)
1233 Project prj = project;
1236 DataRow row = fileList.currentRow;
1237 ProjectNode node = row ? (ProjectNode)row.tag : null;
1244 ProjectNode GetSelectedNode(bool useSelection)
1246 ProjectNode node = null;
1249 DataRow row = fileList.currentRow;
1251 node = (ProjectNode)row.tag;
1256 bool MenuBrowseFolder(MenuItem selection, Modifiers mods)
1258 char folder[MAX_LOCATION];
1260 ProjectNode node = GetSelectedNode(true);
1262 node = project.topNode;
1265 strcpy(folder, prj.topNode.path);
1266 if(node != prj.topNode)
1267 PathCatSlash(folder, node.path);
1271 bool Run(MenuItem selection, Modifiers mods)
1273 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1274 ProjectConfig config = project.config;
1275 String args = new char[maxPathLen];
1277 if(ide.workspace.commandLineArgs)
1278 //ide.debugger.GetCommandLineArgs(args);
1279 strcpy(args, ide.workspace.commandLineArgs);
1280 if(ide.debugger.isActive)
1281 project.Run(args, compiler, config);
1282 /*else if(config.targetType == sharedLibrary || config.targetType == staticLibrary)
1283 MessageBox { master = ide, type = ok, text = "Run", contents = "Shared and static libraries cannot be run like executables." }.Modal();*/
1284 else if(BuildInterrim(project, run, compiler, config))
1285 project.Run(args, compiler, config);
1293 bool result = false;
1294 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1295 ProjectConfig config = project.config;
1296 TargetTypes targetType = project.GetTargetType(config);
1297 if(targetType == sharedLibrary || targetType == staticLibrary)
1298 MessageBox { master = ide, type = ok, text = $"Run", contents = $"Shared and static libraries cannot be run like executables." }.Modal();
1299 else if(project.GetCompress(config))
1300 MessageBox { master = ide, text = $"Starting Debug", contents = $"Debugging compressed applications is not supported\n" }.Modal();
1301 else if(project.GetDebug(config) ||
1302 MessageBox { master = ide, type = okCancel, text = $"Starting Debug", contents = $"Attempting to debug non-debug configuration\nProceed anyways?" }.Modal() == ok)
1304 if(/*!IsProjectModified() ||*/ BuildInterrim(project, start, compiler, config))
1306 if(compiler.type.isVC)
1308 //bool result = false;
1309 char oldwd[MAX_LOCATION];
1310 PathBackup pathBackup { };
1311 char command[MAX_LOCATION];
1313 ide.SetPath(false, compiler, config);
1315 GetWorkingDir(oldwd, sizeof(oldwd));
1316 ChangeWorkingDir(project.topNode.path);
1318 sprintf(command, "%s /useenv %s.sln /projectconfig \"%s|Win32\" /command \"%s\"" , "devenv", project.name, config.name, "Debug.Start");
1319 //ide.outputView.buildBox.Logf("command: %s\n", command);
1321 ChangeWorkingDir(oldwd);
1327 ide.debugger.Start(compiler, config);
1336 void GoToError(const char * line)
1340 while(isspace(*line)) line++;
1341 colon = strstr(line, ":");
1346 bool lookForLineNumber = true;
1348 // deal with linking error
1349 if(colon && colon[1] == ' ')
1351 colon = strstr(colon + 1, ":");
1352 if(colon && !colon[1])
1354 colon = strstr(line, ":");
1355 lookForLineNumber = false;
1357 else if(colon && !isdigit(colon[1]))
1360 colon = strstr(line, ":");
1363 // Don't be mistaken by the drive letter colon
1364 if(colon && (colon[1] == '/' || colon[1] == '\\'))
1365 colon = strstr(colon + 1, ":");
1366 if(colon && lookForLineNumber)
1370 char * par = RSearchString(line, "(", colon - line, true, false);
1371 if(par && strstr(par, ")"))
1373 else if((colon+1)[0] == ' ')
1375 // NOTE: This is the same thing as saying 'colon = line'
1376 for( ; colon != line; colon--)
1380 lineNumber = atoi(colon + 1);
1382 comma = strchr(colon, ',');
1384 col = atoi(comma+1);
1386 comma = strchr(colon+1, ':');
1388 col = atoi(comma+1);
1392 char moduleName[MAX_LOCATION], filePath[MAX_LOCATION];
1396 char * inFileIncludedFrom = strstr(line, stringInFileIncludedFrom);
1397 char * start = inFileIncludedFrom ? line + strlen(stringInFileIncludedFrom) : line;
1398 int len = (int)(colon - start);
1399 len = Min(len, MAX_LOCATION-1);
1401 strncpy(moduleName, start, len);
1402 moduleName[len] = '\0';
1405 strcpy(moduleName, line);
1407 // Remove stuff in brackets
1409 bracket = strstr(moduleName, "(");
1410 if(bracket) *bracket = '\0';
1412 MakeSlashPath(moduleName);
1416 // Check if it's one of our modules
1417 ProjectNode node = project.topNode.Find(moduleName, false);
1420 strcpy(moduleName, node.path);
1421 PathCatSlash(moduleName, node.name);
1424 moduleName[0] = '\0';
1428 CodeEditor codeEditor;
1429 strcpy(filePath, project.topNode.path);
1430 PathCatSlash(filePath, moduleName);
1432 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
1435 char name[MAX_LOCATION];
1436 // TOFIX: Improve on this, don't use only filename, make a function
1437 if(ide && ide.workspace)
1439 for(prj : ide.workspace.projects)
1441 if(prj.topNode.FindWithPath(moduleName, false))
1443 strcpy(filePath, prj.topNode.path);
1444 PathCatSlash(filePath, moduleName);
1445 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
1452 if(codeEditor && lineNumber)
1454 EditBox editBox = codeEditor.editBox;
1455 editBox.GoToLineNum(lineNumber - 1);
1456 editBox.GoToPosition(editBox.line, lineNumber - 1, col ? (col - 1) : 0);
1463 bool OpenNode(ProjectNode node)
1465 char filePath[MAX_LOCATION];
1466 node.GetFullFilePath(filePath);
1467 return ide.OpenFile(filePath, normal, true/*false Why was it opening hidden?*/, null, something, normal) ? true : false;
1470 void AddNode(ProjectNode node, DataRow addTo)
1472 DataRow row = addTo ? addTo.AddRow() : fileList.AddRow();
1474 row.tag = (int)node;
1477 if(node.type == resources)
1480 row.SetData(null, node);
1482 if(node.files && node.files.first && node.parent &&
1483 !(!node.parent.parent &&
1484 (!strcmpi(node.name, "notes") || !strcmpi(node.name, "sources") ||
1485 !strcmpi(node.name, "src") || !strcmpi(node.name, "tools"))))
1486 row.collapsed = true;
1487 else if(node.type == folder)
1488 node.icon = openFolder;
1492 for(child : node.files)
1493 AddNode(child, row);
1497 void DeleteNode(ProjectNode projectNode)
1499 if(projectNode.files)
1502 while(child = projectNode.files.first)
1505 fileList.DeleteRow(projectNode.row);
1506 projectNode.Delete();
1509 bool ProjectSave(MenuItem selection, Modifiers mods)
1511 DataRow row = fileList.currentRow;
1512 ProjectNode node = row ? (ProjectNode)row.tag : null;
1513 Project prj = node ? node.project : null;
1516 prj.StopMonitoring();
1517 if(prj.Save(prj.filePath))
1519 Project modPrj = null;
1520 // ShowOutputBuildLog(true);
1521 // DisplayCompiler(compiler, false);
1522 // ProjectUpdateMakefileForAllConfigs(prj);
1523 prj.topNode.modified = false;
1524 for(p : ide.workspace.projects)
1526 if(p.topNode.modified)
1533 modifiedDocument = false;
1536 prj.StartMonitoring();
1541 bool ShowOutputBuildLog(bool cleanLog)
1543 OutputView output = ide.outputView;
1545 output.ShowClearSelectTab(build);
1548 output.SelectTab(build);
1555 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1556 ProjectConfig config = project.config;
1558 bool result = false;
1559 if(/*!IsProjectModified() ||*/ BuildInterrim(project, restart, compiler, config))
1561 // For Restart, compiler and config will only be used if for
1562 // whatever reason (if at all possible) the Debugger is in a
1563 // 'terminated' or 'none' state
1564 ide.debugger.Restart(compiler, config);
1574 ide.debugger.Resume();
1580 ide.debugger.Break();
1586 ide.debugger.Stop();
1590 bool DebugStepInto()
1592 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1593 ProjectConfig config = project.config;
1595 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config)))
1596 ide.debugger.StepInto(compiler, config);
1601 bool DebugStepOver(bool skip)
1603 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1604 ProjectConfig config = project.config;
1606 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config)))
1607 ide.debugger.StepOver(compiler, config, skip);
1613 bool DebugStepOut(bool skip)
1615 ide.debugger.StepOut(skip);
1619 void ImportFolder(ProjectNode toNode)
1623 //bool isFolder = toNode.type == folder;
1624 //bool isRes = toNode.isInResources;
1626 FileDialog fileDialog = importFileDialog;
1627 fileDialog.master = parent;
1628 if(fileDialog.Modal() == ok)
1630 ImportFolderFSI fsi { projectView = this };
1631 fsi.stack.Add(toNode);
1632 fsi.Iterate(fileDialog.filePath);
1638 ProjectNode NewFolder(ProjectNode parentNode, char * name, bool showProperties)
1642 ProjectNode folderNode;
1643 Project prj = parentNode.project;
1645 ProjectNode after = null;
1646 for(node : parentNode.files)
1648 if(node.type != folder)
1654 folderNode = parentNode.Add(prj, name, after, folder, folder, true);
1657 for(c = 0; c < 100; c++)
1660 sprintf(string, c ? "New Folder (%d)" : "New Folder", c);
1661 if((folderNode = parentNode.Add(prj, string, after, folder, folder, true)))
1668 NodeProperties nodeProperties;
1671 modifiedDocument = true;
1672 prj.topNode.modified = true;
1675 folderNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
1676 folderNode.row.tag = (int)folderNode;
1678 folderNode.row.SetData(null, folderNode);
1679 fileList.currentRow = folderNode.row;
1683 nodeProperties = NodeProperties
1685 parent, this, mode = newFolder, node = folderNode;
1686 position = { position.x + 100, position.y + 100 };
1688 nodeProperties.Create(); // Modal?
1696 void AddFiles(bool resources)
1698 FileDialog fileDialog = (!resources) ? this.fileDialog : resourceFileDialog;
1699 fileDialog.type = multiOpen;
1700 fileDialog.text = !resources ? $"Add Files to Project" : $"Add Resources to Project";
1701 fileDialog.master = parent;
1703 if(fileDialog.Modal() == ok)
1706 DataRow row = fileList.currentRow;
1707 ProjectNode parentNode = (ProjectNode)row.tag;
1708 bool addFailed = false;
1709 int numSelections = fileDialog.numSelections;
1710 char ** multiFilePaths = fileDialog.multiFilePaths;
1712 Array<String> nameConflictFiles { };
1714 for(c = 0; c < numSelections; c++)
1716 char * filePath = multiFilePaths[c];
1717 FileAttribs exists = FileExists(filePath);
1718 bool addThisFile = true;
1720 if(exists.isDirectory)
1721 addThisFile = false;
1724 if(MessageBox { master = ide, type = yesNo, text = filePath,
1725 contents = $"File doesn't exist. Create?" }.Modal() == yes)
1727 File f = FileOpen(filePath, write);
1735 MessageBox { master = ide, type = ok, text = filePath,
1736 contents = $"Couldn't create file."}.Modal();
1737 addThisFile = false;
1744 /*addFailed = */if(!AddFile(parentNode, filePath, resources, false))//;
1746 nameConflictFiles.Add(CopyString(filePath));
1754 char * part1 = $"The following file";
1755 char * opt1 = $" was ";
1756 char * opt2 = $"s were ";
1757 char * part2 = $"not added because of identical file name conflict within the project.\n\n";
1759 len += strlen(part1);
1760 len += strlen(part2);
1761 len += nameConflictFiles.count > 1 ? strlen(opt2) : strlen(opt1);
1762 for(s : nameConflictFiles)
1763 len += strlen(s) + 1;
1764 message = new char[len + 1];
1765 strcpy(message, part1);
1766 strcat(message, nameConflictFiles.count > 1 ? opt2 : opt1);
1767 strcat(message, part2);
1768 for(s : nameConflictFiles)
1771 strcat(message, "\n");
1773 MessageBox { master = ide, type = ok, text = $"Name Conflict",
1774 contents = message }.Modal();
1777 nameConflictFiles.Free();
1778 delete nameConflictFiles;
1782 ProjectNode AddFile(ProjectNode parentNode, char * filePath, bool resources, bool isTemporary)
1784 ProjectNode result = null;
1785 ProjectNode after = null;
1786 for(node : parentNode.files)
1788 if(node.type != folder && node.type != file && node.type)
1793 result = parentNode.Add(parentNode.project, filePath, after, file, NodeIcons::SelectFileIcon(filePath), !resources);
1799 modifiedDocument = true;
1800 parentNode.project.topNode.modified = true;
1801 parentNode.project.ModifiedAllConfigs(true, false, true, true);
1804 result.row = parentNode.row.AddRowAfter(after ? after.row : null);
1805 result.row.tag = (int)result;
1806 result.row.SetData(null, result);
1811 CodeEditor CreateNew(char * upper, char * lower, char * base, char * className)
1813 CodeEditor codeEditor = null;
1814 ProjectNode projectNode;
1815 ProjectNode after = null;
1816 DataRow row = fileList.currentRow;
1817 ProjectNode parentNode;
1820 if(!row) row = project.topNode.row;
1822 parentNode = (ProjectNode)row.tag;
1824 for(node : parentNode.files)
1826 if(node.type != folder && node.type != file && node.type)
1830 for(c = 1; c < 100; c++)
1833 sprintf(string, c ? "%s%d.ec" : "%s.ec", lower, c);
1834 if((projectNode = parentNode.Add(project, string, after, file, genFile, true)))
1840 char filePath[MAX_LOCATION];
1842 modifiedDocument = true;
1843 project.topNode.modified = true;
1845 project.ModifiedAllConfigs(true, false, false, true);
1846 projectNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
1847 projectNode.row.tag =(int)projectNode;
1849 projectNode.row.SetData(null, projectNode);
1850 fileList.currentRow = projectNode.row;
1852 strcpy(filePath, project.topNode.path);
1853 PathCat(filePath, projectNode.path);
1854 PathCat(filePath, projectNode.name);
1856 codeEditor = (CodeEditor)ide.FindWindow(filePath);
1859 Class baseClass = eSystem_FindClass(__thisModule, base);
1860 subclass(ClassDesignerBase) designerClass = eClass_GetDesigner(baseClass);
1863 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal);
1864 strcpy(name, projectNode.name);
1865 sprintf(name, "%s%d", upper, c);
1867 strcpy(className, name);
1869 designerClass.CreateNew(codeEditor.editBox, codeEditor.clientSize, name, base);
1871 //codeEditor.modifiedDocument = false;
1872 //codeEditor.designer.modifiedDocument = false;
1874 //Code_EnsureUpToDate(codeEditor);
1877 else // TODO: fix no symbols generated when ommiting {} for following else
1879 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal);
1883 codeEditor.ViewDesigner();
1884 codeEditor.codeModified = true;
1891 // Returns true if we opened something
1892 bool OpenSelectedNodes()
1894 bool result = false;
1898 fileList.GetMultiSelection(selection);
1899 for(item = selection.first; item; item = item.next)
1901 DataRow row = item.data;
1902 ProjectNode node = (ProjectNode)row.tag;
1903 if(node.type == file)
1910 selection.Free(null);
1914 void RemoveSelectedNodes()
1919 fileList.GetMultiSelection(selection);
1921 // Remove children of parents we're deleting
1922 for(item = selection.first; item; item = next)
1925 DataRow row = item.data;
1926 ProjectNode n, node = (ProjectNode)row.tag;
1927 bool remove = false;
1930 for(i = selection.first; i && !remove; i = i.next)
1932 ProjectNode iNode = (ProjectNode)((DataRow)i.data).tag;
1933 for(n = node.parent; n; n = n.parent)
1943 selection.Delete(item);
1946 for(item = selection.first; item; item = item.next)
1948 DataRow row = item.data;
1949 ProjectNode node = (ProjectNode)row.tag;
1950 ProjectNode resNode;
1951 for(resNode = node.parent; resNode; resNode = resNode.parent)
1952 if(resNode.type == resources)
1954 if(node.type == file)
1956 Project prj = node.project;
1958 modifiedDocument = true;
1959 prj.topNode.modified = true;
1961 prj.ModifiedAllConfigs(true, false, true, true);
1963 else if(node.type == folder)
1966 sprintf(message, $"Are you sure you want to remove the folder \"%s\"\n"
1967 "and all of its contents from the project?", node.name);
1968 if(MessageBox { master = ide, type = yesNo, text = $"Delete Folder", contents = message }.Modal() == yes)
1970 Project prj = node.project;
1971 if(node.containsFile)
1972 prj.ModifiedAllConfigs(true, false, true, true);
1974 modifiedDocument = true;
1975 prj.topNode.modified = true;
1978 else if(node.type == project && node != project.topNode && !buildInProgress)
1982 for(p : workspace.projects)
1984 if(p.topNode == node)
1990 sprintf(message, $"Are you sure you want to remove the \"%s\" project\n" "from this workspace?", node.name);
1991 if(MessageBox { master = ide, type = yesNo, text = $"Remove Project", contents = message }.Modal() == yes)
1996 workspace.RemoveProject(prj);
1997 //modifiedDocument = true; // when project view is a workspace view
2001 selection.Free(null);