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 MenuDivider { popupContent };
263 MenuItem { popupContent, $"Clean", l, NotifySelect = FileClean }.disabled = buildMenuUnavailable;
264 MenuItem { popupContent, $"Compile", c, Key { f7, ctrl = true}, NotifySelect = FileCompile }.disabled = buildMenuUnavailable;
265 MenuDivider { popupContent };
266 MenuItem { popupContent, $"Remove", r, NotifySelect = FileRemoveFile };
267 MenuDivider { popupContent };
268 MenuItem { popupContent, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
269 MenuDivider { popupContent };
270 MenuItem { popupContent, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
271 MenuItem { popupContent, $"Properties..", p, Key { enter, alt = true }, NotifySelect = FileProperties };
273 else if(node.type == folder)
275 bool isInResources = node.isInResources;
277 MenuItem { popupContent, $"New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
278 MenuItem { popupContent, $"New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
279 MenuItem { popupContent, $"Import Folder...", i, NotifySelect = ProjectImportFolder };
282 MenuItem { popupContent, $"Add Resources to Folder...", f, NotifySelect = ResourcesAddFiles };
286 MenuItem { popupContent, $"Add Files to Folder...", f, NotifySelect = ProjectAddFiles };
290 MenuDivider { popupContent };
291 MenuItem { popupContent, $"Add New Form...", o, NotifySelect = ProjectAddNewForm };
292 MenuItem { popupContent, $"Add New Behavior Graph...", g, NotifySelect = ProjectAddNewGraph };
294 MenuDivider { popupContent };
295 MenuItem { popupContent, $"Clean", l, NotifySelect = FileClean }.disabled = buildMenuUnavailable;
296 MenuItem { popupContent, $"Compile", c, Key { f7, ctrl = true}, NotifySelect = FileCompile }.disabled = buildMenuUnavailable;
297 MenuDivider { popupContent };
298 MenuItem { popupContent, $"Remove", r, NotifySelect = FileRemoveFile };
299 MenuDivider { popupContent };
300 MenuItem { popupContent, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
301 MenuDivider { popupContent };
302 MenuItem { popupContent, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
303 MenuItem { popupContent, $"Properties...", p, Key { enter, alt = true }, NotifySelect = FileProperties };
308 master = this, menu = popupContent;
310 x + clientStart.x + absPosition.x - app.desktop.position.x,
311 y + clientStart.y + absPosition.y - app.desktop.position.y };
313 void NotifyDestroyed(Window window, DialogResult result)
324 bool NotifyKeyHit(ListBox listBox, DataRow row, Key key, unichar ch)
326 if(key == altUp || key == altDown)
328 SelectNextProject(key == altUp);
334 bool NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch)
338 ProjectNode node = (ProjectNode)row.tag;
341 case altEnter: case Key { keyPadEnter, alt = true }:
343 NodeProperties { parent = parent, master = this,
344 position = { position.x + 100, position.y + 100 }, node = node }.Create();
347 case enter: case keyPadEnter:
350 for(resNode = node.parent; resNode; resNode = resNode.parent)
351 if(resNode.type == resources)
353 if(node.type == project || (node.type == folder && !resNode))
358 else if(node.type == resources || node.type == folder)
367 if(node.type == project || node.type == folder || node.type == resources)
376 if(node.type == project || node.type == folder || node.type == resources)
378 NewFolder(node, null, true);
385 if(node.type == file)
387 FileCompile(null, (Modifiers)key);
392 case Key { space, shift = true }:
395 if(node.type == NodeTypes::project)
398 for(p : workspace.projects)
400 if(p.topNode == node)
406 prj.RotateActiveConfig(!key.shift);
417 case enter: case keyPadEnter: OpenSelectedNodes(); break;
418 case del: RemoveSelectedNodes(); break;
421 Window activeClient = ide.activeClient;
423 activeClient.Activate();
425 ide.RepositionWindows(true);
432 bool NotifyCollapse(ListBox listBox, DataRow row, bool collapsed)
434 ProjectNode node = (ProjectNode)row.tag;
435 if(node.type == folder)
436 node.icon = collapsed ? folder : openFolder;
441 FileDialog importFileDialog { autoCreate = false, type = selectDir, text = $"Import Folder" };
442 FileDialog projectFileDialog
444 autoCreate = false, filters = projectFilters.array, sizeFilters = projectFilters.count * sizeof(FileFilter);
445 types = projectTypes.array, sizeTypes = projectTypes.count * sizeof(FileType);
447 FileDialog fileDialog
449 autoCreate = false, mayNotExist = true, filters = fileFilters.array, sizeFilters = fileFilters.count * sizeof(FileFilter);
451 FileDialog resourceFileDialog
453 autoCreate = false, mayNotExist = true, filters = resourceFilters.array, sizeFilters = resourceFilters.count * sizeof(FileFilter);
456 Menu fileMenu { menu, $"File", f };
457 MenuItem { fileMenu, $"Save", s, Key { s, ctrl = true }, NotifySelect = MenuFileSave };
458 // MenuItem { fileMenu, "Save As...", a, NotifySelect = MenuFileSaveAs };
460 bool OnClose(bool parentClosing)
462 if(!parentClosing && visible)
472 DialogResult dialogRes;
475 strcpy(msg, $"You have modified projects.\nSave changes to ");
476 for(p : ide.workspace.projects)
478 if(p.topNode.modified)
480 if(!first) strcat(msg, ", ");
487 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = msg }.Modal();
491 // TOFIX: Precomp error if brackets are taken out
492 return (DialogResult)MenuFileSave(null, 0) != cancel;
494 else if(dialogRes == cancel)
496 modifiedDocument = false;
503 //if(ide.findInFilesDialog && ide.findInFilesDialog.created && ide.findInFilesDialog.mode != directory)
504 // ide.findInFilesDialog.SearchStop();
506 ide.outputView.buildBox.Clear();
507 ide.outputView.debugBox.Clear();
508 //ide.outputView.findBox.Clear();
509 ide.callStackView.Clear();
510 ide.watchesView.Clear();
511 ide.threadsView.Clear();
512 ide.breakpointsView.Clear();
513 ide.outputView.ShowClearSelectTab(find); // why this?
516 bool OnSaveFile(char * fileName)
518 for(prj : ide.workspace.projects)
520 if(prj.topNode.modified)
522 prj.StopMonitoring();
523 if(prj.Save(prj.filePath))
524 prj.topNode.modified = false;
525 prj.StartMonitoring();
528 modifiedDocument = false;
533 bool IsModuleInProject(char * filePath)
535 char moduleName[MAX_FILENAME]; //, modulePath[MAX_LOCATION];
536 GetLastDirectory(filePath, moduleName);
537 return project.topNode.Find(moduleName, false) != null;
540 bool GetRelativePath(char * filePath, char * relativePath)
542 return project.GetRelativePath(filePath, relativePath);
545 ProjectNode GetNodeFromWindow(Window document, Project project)
547 if(document.fileName)
549 char winFileName[MAX_LOCATION];
550 char * documentFileName = GetSlashPathBuffer(winFileName, document.fileName);
551 for(p : ide.workspace.projects)
553 Project prj = project ? project : p;
555 if((node = prj.topNode.FindByFullPath(documentFileName, false)))
563 // ((( UTILITY FUNCTIONS )))
565 // ************************************************************************
566 // *** These methods below are part of a sequence of events, and as ***
567 // *** such they must be passed the current compiler and project config ***
568 // ************************************************************************
569 bool DisplayCompiler(CompilerConfig compiler, bool cleanLog)
571 ide.outputView.buildBox.Logf($"%s Compiler\n", compiler ? compiler.name : $"{problem with compiler selection}");
575 bool ProjectPrepareForToolchain(Project project, PrepareMakefileMethod method, bool cleanLog, bool displayCompiler,
576 CompilerConfig compiler, ProjectConfig config)
579 char message[MAX_F_STRING];
580 LogBox logBox = ide.outputView.buildBox;
582 ShowOutputBuildLog(cleanLog);
585 DisplayCompiler(compiler, false);
587 ProjectPrepareCompiler(project, compiler);
588 ProjectPrepareMakefile(project, method, compiler, config);
592 bool ProjectPrepareCompiler(Project project, CompilerConfig compiler)
594 if(!project.GenerateCrossPlatformMk() || !project.GenerateCompilerCf(compiler))
595 ide.outputView.buildBox.Logf($"Error generating compiler configuration (Is the project/config directory writable?)\n");
599 // Note: Compiler is only passed in to for VisualStudio support
600 bool ProjectPrepareMakefile(Project project, PrepareMakefileMethod method, CompilerConfig compiler, ProjectConfig config)
602 if(compiler.type.isVC)
604 // I'm guessing we'll want to support generating VS files on Linux as well...
605 ide.statusBar.text = $"Generating Visual Studio Solution...";
607 //GenerateVSSolutionFile(project, compiler);
608 ide.statusBar.text = $"Generating Visual Studio Project...";
610 //GenerateVCProjectFile(project, compiler);
611 ide.statusBar.text = null;
617 char makefilePath[MAX_LOCATION];
618 char makefileName[MAX_LOCATION];
620 LogBox logBox = ide.outputView.buildBox;
622 strcpy(makefilePath, project.topNode.path);
623 project.CatMakeFileName(makefileName, config);
624 PathCatSlash(makefilePath, makefileName);
626 exists = FileExists(makefilePath);
627 if(method == force ||
628 (method == forceExists && exists) ||
629 (method == normal && (!exists || (config && config.makingModified))))
633 ide.statusBar.text = $"Generating Makefile & Dependencies..."; // Dependencies?
636 if((method == normal && !exists) || (method == force && !exists))
637 action = $"Generating ";
638 else if(method == force)
639 action = $"Regenerating ";
640 else if(method == normal || method == forceExists)
641 action = $"Updating ";
645 reason = $"Makefile doesn't exist. ";
646 else if(project.topNode.modified)
647 reason = $"Project has been modified. ";
651 //logBox.Logf("%s\n", makefileName);
652 logBox.Logf($"%s - %s%smakefile for %s config...\n", makefileName, reason, action, GetConfigName(config));
654 if(!project.GenerateMakefile(null, false, null, config))
655 ide.outputView.buildBox.Logf($"Error generating makefile (Is the project directory writable?)\n");
657 ide.statusBar.text = null;
665 bool BuildInterrim(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config, bool justPrint)
667 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
669 ide.outputView.buildBox.Logf($"Building project %s using the %s configuration...\n", prj.name, GetConfigName(config));
670 return Build(prj, buildType, compiler, config, justPrint);
675 bool DebugStopForMake(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config)
678 // TOFIX: DebugStop is being abused and backfiring on us.
679 // It's supposed to be the 'Debug/Stop' item, not unloading executable or anything else
681 // configIsInDebugSession seems to be used for two OPPOSITE things:
682 // If we're debugging another config, we need to unload the executable!
683 // In building, we want to stop if we're debugging the 'same' executable
684 if(buildType != run) ///* && prj == project*/ && prj.configIsInDebugSession)
686 if(buildType == start || buildType == restart)
688 if(ide.debugger && ide.debugger.isPrepared)
689 result = DebugStop();
693 if(ide.project == prj && ide.debugger && ide.debugger.prjConfig == config && ide.debugger.isPrepared)
694 result = DebugStop();
700 bool Build(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config, bool justPrint)
706 for(document = master.firstChild; document; document = document.next)
708 if(document.modifiedDocument)
710 ProjectNode node = GetNodeFromWindow(document, prj);
711 if(node && !document.MenuFileSave(null, 0))
720 DirExpression targetDir = prj.GetTargetDir(compiler, config);
722 DebugStopForMake(prj, buildType, compiler, config);
724 // TODO: Disabled until problems fixed... is it fixed?
725 if(buildType == rebuild || (config && config.compilingModified))
726 prj.Clean(compiler, config, false, justPrint);
729 if(buildType == relink || (config && config.linkingModified))
731 char target[MAX_LOCATION];
733 strcpy(target, prj.topNode.path);
734 PathCat(target, targetDir.dir);
735 prj.CatTargetFileName(target, compiler, config);
736 if(FileExists(target))
739 if(config && config.symbolGenModified)
741 DirExpression objDir = prj.GetObjDir(compiler, config);
742 char fileName[MAX_LOCATION];
743 char moduleName[MAX_FILENAME];
744 strcpy(fileName, prj.topNode.path);
745 PathCatSlash(fileName, objDir.dir);
746 strcpy(moduleName, prj.moduleName);
747 strcat(moduleName, ".main.ec");
748 PathCatSlash(fileName, moduleName);
749 if(FileExists(fileName))
750 DeleteFile(fileName);
751 ChangeExtension(fileName, "c", fileName);
752 if(FileExists(fileName))
753 DeleteFile(fileName);
754 ChangeExtension(fileName, "o", fileName);
755 if(FileExists(fileName))
756 DeleteFile(fileName);
761 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
762 ide.AdjustBuildMenus();
763 ide.AdjustDebugMenus();
765 result = prj.Build(buildType == run, null, compiler, config, justPrint);
769 config.compilingModified = false;
770 if(!ide.ShouldStopBuild())
771 config.linkingModified = false;
773 config.symbolGenModified = false;
775 buildInProgress = none;
776 ide.AdjustBuildMenus();
777 ide.AdjustDebugMenus();
779 ide.workspace.modified = true;
786 // ((( USER ACTIONS )))
788 // ************************************************************************
789 // *** Methods below should atomically start a process, and as such ***
790 // *** they can query compiler and config directly from ide and project ***
791 // *** but ONLY ONCE!!! ***
792 // ************************************************************************
794 bool ProjectBuild(MenuItem selection, Modifiers mods)
796 Project prj = project;
797 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
798 ProjectConfig config;
799 if(selection || !ide.activeClient)
801 DataRow row = fileList.currentRow;
802 ProjectNode node = row ? (ProjectNode)row.tag : null;
803 if(node) prj = node.project;
807 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
812 if(/*prj != project || */!prj.GetConfigIsInDebugSession(config) || !ide.DontTerminateDebugSession($"Project Build"))
814 BuildInterrim(prj, build, compiler, config, mods.ctrl && mods.shift);
820 bool ProjectLink(MenuItem selection, Modifiers mods)
822 Project prj = project;
823 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
824 ProjectConfig config;
825 if(selection || !ide.activeClient)
827 DataRow row = fileList.currentRow;
828 ProjectNode node = row ? (ProjectNode)row.tag : null;
829 if(node) prj = node.project;
833 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
838 if(!prj.GetConfigIsInDebugSession(config) ||
839 (!ide.DontTerminateDebugSession($"Project Link") && DebugStopForMake(prj, relink, compiler, config)))
841 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
843 ide.outputView.buildBox.Logf($"Relinking project %s using the %s configuration...\n", prj.name, GetConfigName(config));
845 config.linkingModified = true;
846 Build(prj, relink, compiler, config, mods.ctrl && mods.shift);
853 bool ProjectRebuild(MenuItem selection, Modifiers mods)
855 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
856 Project prj = project;
857 ProjectConfig config;
858 if(selection || !ide.activeClient)
860 DataRow row = fileList.currentRow;
861 ProjectNode node = row ? (ProjectNode)row.tag : null;
862 if(node) prj = node.project;
866 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
871 if(!prj.GetConfigIsInDebugSession(config) ||
872 (!ide.DontTerminateDebugSession($"Project Rebuild") && DebugStopForMake(prj, rebuild, compiler, config)))
874 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
876 ide.outputView.buildBox.Logf($"Rebuilding project %s using the %s configuration...\n", prj.name, GetConfigName(config));
879 config.compilingModified = true;
880 config.makingModified = true;
881 }*/ // -- should this still be used depite the new solution of BuildType?
882 Build(prj, rebuild, compiler, config, mods.ctrl && mods.shift);
889 bool ProjectClean(MenuItem selection, Modifiers mods)
891 Project prj = project;
892 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
893 ProjectConfig config;
894 if(selection || !ide.activeClient)
896 DataRow row = fileList.currentRow;
897 ProjectNode node = row ? (ProjectNode)row.tag : null;
898 if(node) prj = node.project;
902 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
907 if(!prj.GetConfigIsInDebugSession(config) ||
908 (!ide.DontTerminateDebugSession($"Project Clean") && DebugStopForMake(prj, clean, compiler, config)))
910 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
912 ide.outputView.buildBox.Logf($"Cleaning project %s using the %s configuration...\n", prj.name, GetConfigName(config));
914 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
915 ide.AdjustBuildMenus();
916 ide.AdjustDebugMenus();
918 prj.Clean(compiler, config, false, mods.ctrl && mods.shift);
919 buildInProgress = none;
920 ide.AdjustBuildMenus();
921 ide.AdjustDebugMenus();
928 bool ProjectRealClean(MenuItem selection, Modifiers mods)
930 Project prj = project;
931 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
932 ProjectConfig config;
933 if(selection || !ide.activeClient)
935 DataRow row = fileList.currentRow;
936 ProjectNode node = row ? (ProjectNode)row.tag : null;
937 if(node) prj = node.project;
941 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
946 if(!prj.GetConfigIsInDebugSession(config) ||
947 (!ide.DontTerminateDebugSession($"Project Real Clean") && DebugStopForMake(prj, clean, compiler, config)))
949 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
951 ide.outputView.buildBox.Logf($"Removing intermediate objects directory for project %s using the %s configuration...\n", prj.name, GetConfigName(config));
953 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
954 ide.AdjustBuildMenus();
955 ide.AdjustDebugMenus();
957 prj.Clean(compiler, config, true, mods.ctrl && mods.shift);
958 buildInProgress = none;
959 ide.AdjustBuildMenus();
960 ide.AdjustDebugMenus();
967 bool ProjectRegenerate(MenuItem selection, Modifiers mods)
969 Project prj = project;
970 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
971 ShowOutputBuildLog(true);
972 if(selection || !ide.activeClient)
974 DataRow row = fileList.currentRow;
975 ProjectNode node = row ? (ProjectNode)row.tag : null;
981 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
986 DisplayCompiler(compiler, false);
987 ProjectPrepareCompiler(project, compiler);
988 ProjectPrepareMakefile(prj, force, compiler, prj.config);
993 bool Compile(Project project, List<ProjectNode> nodes, bool justPrint)
996 char fileName[MAX_LOCATION];
998 ProjectConfig config = project.config;
1002 for(document = ide.firstChild; document; document = document.next)
1004 if(document.modifiedDocument)
1006 ProjectNode n = GetNodeFromWindow(document, project);
1009 if(n && n.IsInNode(node) && !document.MenuFileSave(null, 0))
1011 ide.outputView.buildBox.Logf($"Unable to save %s file.\n", node.name);
1021 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1023 if(ProjectPrepareForToolchain(project, normal, true, true, compiler, config))
1026 ide.outputView.buildBox.Logf($"Compiling specific file(s) in project %s using the %s configuration...\n",
1027 project.name, config.name);
1029 ide.outputView.buildBox.Logf($"Compiling specific file(s) in project %s...\n",
1032 buildInProgress = compilingFile;
1033 ide.AdjustBuildMenus();
1034 project.Compile(nodes, compiler, config, justPrint);
1035 buildInProgress = none;
1036 ide.AdjustBuildMenus();
1045 bool Clean(Project project, List<ProjectNode> nodes, bool justPrint)
1048 char fileName[MAX_LOCATION];
1050 ProjectConfig config = project.config;
1054 for(document = ide.firstChild; document; document = document.next)
1056 if(document.modifiedDocument)
1058 ProjectNode n = GetNodeFromWindow(document, project);
1061 if(n && n.IsInNode(node) && !document.MenuFileSave(null, 0))
1063 ide.outputView.buildBox.Logf($"Unable to save %s file.\n", node.name);
1073 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1075 if(ProjectPrepareForToolchain(project, normal, true, true, compiler, config))
1079 if(node.GetIsExcluded(config))
1080 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
1084 ide.outputView.buildBox.Logf($"Deleteing intermediate objects for %s %s in project %s using the %s configuration...\n",
1085 node.type == file ? $"single file" : $"folder", node.name, project.name, config.name);
1087 ide.outputView.buildBox.Logf($"Deleteing intermediate objects for %s %s in project %s...\n",
1088 node.type == file ? $"single file" : $"folder", node.name, project.name);
1090 node.DeleteIntermediateFiles(compiler, config);
1100 bool ProjectNewFile(MenuItem selection, Modifiers mods)
1102 DataRow row = fileList.currentRow;
1105 char fileName[1024];
1106 char filePath[MAX_LOCATION];
1107 ProjectNode parentNode = (ProjectNode)row.tag;
1108 ProjectNode n, fileNode;
1109 parentNode.GetFileSysMatchingPath(filePath);
1110 MakePathRelative(filePath, parentNode.project.topNode.path, filePath);
1111 for(n = parentNode; n && n != parentNode.project.resNode; n = n.parent);
1112 sprintf(fileName, $"Untitled %d", documentID);
1113 fileNode = AddFile(parentNode, fileName, (bool)n, true);
1114 fileNode.path = CopyUnixPath(filePath);
1117 NodeProperties nodeProperties
1120 position = { position.x + 100, position.y + 100 };
1124 nodeProperties.Create(); // not modal?
1130 bool ProjectNewFolder(MenuItem selection, Modifiers mods)
1132 DataRow row = fileList.currentRow;
1135 ProjectNode parentNode = (ProjectNode)row.tag;
1136 NewFolder(parentNode, null, true);
1141 bool ResourcesAddFiles(MenuItem selection, Modifiers mods)
1147 bool ProjectAddFiles(MenuItem selection, Modifiers mods)
1153 bool ProjectImportFolder(MenuItem selection, Modifiers mods)
1155 DataRow row = fileList.currentRow;
1158 ProjectNode toNode = (ProjectNode)row.tag;
1159 ImportFolder(toNode);
1164 bool ProjectAddNewForm(MenuItem selection, Modifiers mods)
1166 CodeEditor codeEditor = CreateNew("Form", "form", "Window", null);
1167 codeEditor.EnsureUpToDate();
1171 bool ProjectAddNewGraph(MenuItem selection, Modifiers mods)
1173 CodeEditor codeEditor = CreateNew("Graph", "graph", "Block", null);
1175 codeEditor.EnsureUpToDate();
1179 bool ProjectRemove(MenuItem selection, Modifiers mods)
1181 DataRow row = fileList.currentRow;
1184 ProjectNode node = (ProjectNode)row.tag;
1185 if(node.type == project)
1186 RemoveSelectedNodes();
1191 bool ProjectUpdateMakefileForAllConfigs(Project project)
1193 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1195 for(config : project.configurations)
1196 ProjectPrepareMakefile(project, forceExists, compiler, config);
1203 bool MenuConfig(MenuItem selection, Modifiers mods)
1205 if(ProjectActiveConfig { master = parent, project = project }.Modal() == ok)
1210 bool MenuCompiler(MenuItem selection, Modifiers mods)
1212 ActiveCompilerDialog compilerDialog
1215 ideSettings = ideSettings, workspaceActiveCompiler = ide.workspace.compiler;
1217 incref compilerDialog;
1218 if(compilerDialog.Modal() == ok && strcmp(compilerDialog.workspaceActiveCompiler, ide.workspace.compiler))
1220 CompilerConfig compiler = ideSettings.GetCompilerConfig(compilerDialog.workspaceActiveCompiler);
1221 ide.workspace.compiler = compilerDialog.workspaceActiveCompiler;
1222 ide.projectView.ShowOutputBuildLog(true);
1223 ide.projectView.DisplayCompiler(compiler, false);
1225 for(prj : ide.workspace.projects)
1226 ide.projectView.ProjectPrepareCompiler(prj, compiler);
1229 delete compilerDialog;
1233 bool MenuSettings(MenuItem selection, Modifiers mods)
1235 ProjectNode node = GetSelectedNode(true);
1236 Project prj = node ? node.project : project;
1237 projectSettingsDialog = ProjectSettings { master = parent, project = prj, projectNode = node };
1238 projectSettingsDialog.Modal();
1245 bool FileProperties(MenuItem selection, Modifiers mods)
1247 DataRow row = fileList.currentRow;
1250 ProjectNode node = (ProjectNode)row.tag;
1251 NodeProperties { parent = parent, master = this, node = node,
1252 position = { position.x + 100, position.y + 100 } }.Create();
1257 bool FileOpenFile(MenuItem selection, Modifiers mods)
1259 OpenSelectedNodes();
1263 bool FileRemoveFile(MenuItem selection, Modifiers mods)
1265 RemoveSelectedNodes();
1269 bool FileCompile(MenuItem selection, Modifiers mods)
1272 OldList selectedRows;
1273 Project project = null;
1274 List<ProjectNode> nodes { };
1275 fileList.GetMultiSelection(selectedRows);
1276 for(item = selectedRows.first; item; item = item.next)
1279 DataRow row = item.data;
1280 ProjectNode node = (ProjectNode)row.tag;
1282 project = node.project;
1283 else if(node.project != project)
1290 selectedRows.Free(null);
1292 Compile(project, nodes, mods.ctrl && mods.shift);
1294 ide.outputView.buildBox.Logf($"Please select files from a single project.\n");
1299 bool FileClean(MenuItem selection, Modifiers mods)
1302 OldList selectedRows;
1303 Project project = null;
1304 List<ProjectNode> nodes { };
1305 fileList.GetMultiSelection(selectedRows);
1306 for(item = selectedRows.first; item; item = item.next)
1309 DataRow row = item.data;
1310 ProjectNode node = (ProjectNode)row.tag;
1312 project = node.project;
1313 else if(node.project != project)
1320 selectedRows.Free(null);
1322 Clean(project, nodes, mods.ctrl && mods.shift);
1324 ide.outputView.buildBox.Logf($"Please select files from a single project.\n");
1329 Project GetSelectedProject(bool useSelection)
1331 Project prj = project;
1334 DataRow row = fileList.currentRow;
1335 ProjectNode node = row ? (ProjectNode)row.tag : null;
1342 void SelectNextProject(bool backwards)
1344 DataRow row = fileList.currentRow;
1345 DataRow currentRow = row;
1346 ProjectNode node = (ProjectNode)row.tag;
1347 if(node.type != project)
1348 row = node.project.topNode.row;
1350 row = row.previous ? row.previous : fileList.lastRow;
1352 row = row.next ? row.next : fileList.firstRow;
1353 if(row && row != currentRow)
1355 fileList.SelectRow(row);
1356 fileList.currentRow = row;
1360 ProjectNode GetSelectedNode(bool useSelection)
1362 ProjectNode node = null;
1365 DataRow row = fileList.currentRow;
1367 node = (ProjectNode)row.tag;
1372 bool MenuBrowseFolder(MenuItem selection, Modifiers mods)
1374 char folder[MAX_LOCATION];
1376 ProjectNode node = GetSelectedNode(true);
1378 node = project.topNode;
1381 strcpy(folder, prj.topNode.path);
1382 if(node != prj.topNode)
1383 PathCatSlash(folder, node.path);
1388 bool Run(MenuItem selection, Modifiers mods)
1390 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1391 ProjectConfig config = project.config;
1392 String args = new char[maxPathLen];
1394 if(ide.workspace.commandLineArgs)
1395 //ide.debugger.GetCommandLineArgs(args);
1396 strcpy(args, ide.workspace.commandLineArgs);
1397 if(ide.debugger.isActive)
1398 project.Run(args, compiler, config);
1399 /*else if(config.targetType == sharedLibrary || config.targetType == staticLibrary)
1400 MessageBox { master = ide, type = ok, text = "Run", contents = "Shared and static libraries cannot be run like executables." }.Modal();*/
1401 else if(BuildInterrim(project, run, compiler, config, false))
1402 project.Run(args, compiler, config);
1410 bool result = false;
1411 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1412 ProjectConfig config = project.config;
1413 TargetTypes targetType = project.GetTargetType(config);
1414 if(targetType == sharedLibrary || targetType == staticLibrary)
1415 MessageBox { master = ide, type = ok, text = $"Run", contents = $"Shared and static libraries cannot be run like executables." }.Modal();
1416 else if(project.GetCompress(config))
1417 MessageBox { master = ide, text = $"Starting Debug", contents = $"Debugging compressed applications is not supported\n" }.Modal();
1418 else if(project.GetDebug(config) ||
1419 MessageBox { master = ide, type = okCancel, text = $"Starting Debug", contents = $"Attempting to debug non-debug configuration\nProceed anyways?" }.Modal() == ok)
1421 if(/*!IsProjectModified() ||*/ BuildInterrim(project, start, compiler, config, false))
1423 if(compiler.type.isVC)
1425 //bool result = false;
1426 char oldwd[MAX_LOCATION];
1427 PathBackup pathBackup { };
1428 char command[MAX_LOCATION];
1430 ide.SetPath(false, compiler, config);
1432 GetWorkingDir(oldwd, sizeof(oldwd));
1433 ChangeWorkingDir(project.topNode.path);
1435 sprintf(command, "%s /useenv %s.sln /projectconfig \"%s|Win32\" /command \"%s\"" , "devenv", project.name, config.name, "Debug.Start");
1437 ChangeWorkingDir(oldwd);
1443 ide.debugger.Start(compiler, config);
1452 void GoToError(const char * line)
1456 while(isspace(*line)) line++;
1457 colon = strstr(line, ":");
1462 bool lookForLineNumber = true;
1464 // deal with linking error
1465 if(colon && colon[1] == ' ')
1467 colon = strstr(colon + 1, ":");
1468 if(colon && !colon[1])
1470 colon = strstr(line, ":");
1471 lookForLineNumber = false;
1473 else if(colon && !isdigit(colon[1]))
1476 colon = strstr(line, ":");
1479 // Don't be mistaken by the drive letter colon
1480 if(colon && (colon[1] == '/' || colon[1] == '\\'))
1481 colon = strstr(colon + 1, ":");
1482 if(colon && lookForLineNumber)
1486 char * par = RSearchString(line, "(", colon - line, true, false);
1487 if(par && strstr(par, ")"))
1489 else if((colon+1)[0] == ' ')
1491 // NOTE: This is the same thing as saying 'colon = line'
1492 for( ; colon != line; colon--)
1496 lineNumber = atoi(colon + 1);
1498 comma = strchr(colon, ',');
1500 col = atoi(comma+1);
1502 comma = strchr(colon+1, ':');
1504 col = atoi(comma+1);
1508 char moduleName[MAX_LOCATION], filePath[MAX_LOCATION];
1512 char * inFileIncludedFrom = strstr(line, stringInFileIncludedFrom);
1513 char * start = inFileIncludedFrom ? line + strlen(stringInFileIncludedFrom) : line;
1514 int len = (int)(colon - start);
1515 len = Min(len, MAX_LOCATION-1);
1517 strncpy(moduleName, start, len);
1518 moduleName[len] = '\0';
1521 strcpy(moduleName, line);
1523 // Remove stuff in brackets
1525 bracket = strstr(moduleName, "(");
1526 if(bracket) *bracket = '\0';
1528 MakeSlashPath(moduleName);
1532 // Check if it's one of our modules
1533 ProjectNode node = project.topNode.Find(moduleName, false);
1536 strcpy(moduleName, node.path);
1537 PathCatSlash(moduleName, node.name);
1540 moduleName[0] = '\0';
1544 CodeEditor codeEditor;
1545 strcpy(filePath, project.topNode.path);
1546 PathCatSlash(filePath, moduleName);
1548 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
1551 char name[MAX_LOCATION];
1552 // TOFIX: Improve on this, don't use only filename, make a function
1553 if(ide && ide.workspace)
1555 for(prj : ide.workspace.projects)
1557 if(prj.topNode.FindWithPath(moduleName, false))
1559 strcpy(filePath, prj.topNode.path);
1560 PathCatSlash(filePath, moduleName);
1561 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
1568 if(codeEditor && lineNumber)
1570 EditBox editBox = codeEditor.editBox;
1571 editBox.GoToLineNum(lineNumber - 1);
1572 editBox.GoToPosition(editBox.line, lineNumber - 1, col ? (col - 1) : 0);
1579 bool OpenNode(ProjectNode node)
1581 char filePath[MAX_LOCATION];
1582 node.GetFullFilePath(filePath);
1583 return ide.OpenFile(filePath, normal, true/*false Why was it opening hidden?*/, null, something, normal) ? true : false;
1586 void AddNode(ProjectNode node, DataRow addTo)
1588 DataRow row = addTo ? addTo.AddRow() : fileList.AddRow();
1590 row.tag = (int)node;
1593 if(node.type == resources)
1596 row.SetData(null, node);
1598 if(node.files && node.files.first && node.parent &&
1599 !(!node.parent.parent &&
1600 (!strcmpi(node.name, "notes") || !strcmpi(node.name, "sources") ||
1601 !strcmpi(node.name, "src") || !strcmpi(node.name, "tools"))))
1602 row.collapsed = true;
1603 else if(node.type == folder)
1604 node.icon = openFolder;
1608 for(child : node.files)
1609 AddNode(child, row);
1613 void DeleteNode(ProjectNode projectNode)
1615 if(projectNode.files)
1618 while(child = projectNode.files.first)
1621 fileList.DeleteRow(projectNode.row);
1622 projectNode.Delete();
1625 bool ProjectSave(MenuItem selection, Modifiers mods)
1627 DataRow row = fileList.currentRow;
1628 ProjectNode node = row ? (ProjectNode)row.tag : null;
1629 Project prj = node ? node.project : null;
1632 prj.StopMonitoring();
1633 if(prj.Save(prj.filePath))
1635 Project modPrj = null;
1636 prj.topNode.modified = false;
1637 for(p : ide.workspace.projects)
1639 if(p.topNode.modified)
1646 modifiedDocument = false;
1649 prj.StartMonitoring();
1654 bool ShowOutputBuildLog(bool cleanLog)
1656 OutputView output = ide.outputView;
1658 output.ShowClearSelectTab(build);
1661 output.SelectTab(build);
1669 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1670 ProjectConfig config = project.config;
1672 bool result = false;
1673 if(/*!IsProjectModified() ||*/ BuildInterrim(project, restart, compiler, config, false))
1675 // For Restart, compiler and config will only be used if for
1676 // whatever reason (if at all possible) the Debugger is in a
1677 // 'terminated' or 'none' state
1678 ide.debugger.Restart(compiler, config);
1688 ide.debugger.Resume();
1694 ide.debugger.Break();
1700 ide.debugger.Stop();
1704 bool DebugStepInto()
1706 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1707 ProjectConfig config = project.config;
1709 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config, false)))
1710 ide.debugger.StepInto(compiler, config);
1715 bool DebugStepOver(bool skip)
1717 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1718 ProjectConfig config = project.config;
1720 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config, false)))
1721 ide.debugger.StepOver(compiler, config, skip);
1727 bool DebugStepOut(bool skip)
1729 ide.debugger.StepOut(skip);
1733 void ImportFolder(ProjectNode toNode)
1737 //bool isFolder = toNode.type == folder;
1738 //bool isRes = toNode.isInResources;
1740 FileDialog fileDialog = importFileDialog;
1741 fileDialog.master = parent;
1742 if(fileDialog.Modal() == ok)
1744 ImportFolderFSI fsi { projectView = this };
1745 fsi.stack.Add(toNode);
1746 fsi.Iterate(fileDialog.filePath);
1752 ProjectNode NewFolder(ProjectNode parentNode, char * name, bool showProperties)
1756 ProjectNode folderNode;
1757 Project prj = parentNode.project;
1759 ProjectNode after = null;
1760 for(node : parentNode.files)
1762 if(node.type != folder)
1768 folderNode = parentNode.Add(prj, name, after, folder, folder, true);
1771 for(c = 0; c < 100; c++)
1774 sprintf(string, c ? "New Folder (%d)" : "New Folder", c);
1775 if((folderNode = parentNode.Add(prj, string, after, folder, folder, true)))
1782 NodeProperties nodeProperties;
1785 modifiedDocument = true;
1786 prj.topNode.modified = true;
1789 folderNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
1790 folderNode.row.tag = (int)folderNode;
1792 folderNode.row.SetData(null, folderNode);
1793 fileList.currentRow = folderNode.row;
1797 nodeProperties = NodeProperties
1799 parent, this, mode = newFolder, node = folderNode;
1800 position = { position.x + 100, position.y + 100 };
1802 nodeProperties.Create(); // Modal?
1810 void AddFiles(bool resources)
1812 FileDialog fileDialog = (!resources) ? this.fileDialog : resourceFileDialog;
1813 fileDialog.type = multiOpen;
1814 fileDialog.text = !resources ? $"Add Files to Project" : $"Add Resources to Project";
1815 fileDialog.master = parent;
1817 if(fileDialog.Modal() == ok)
1820 DataRow row = fileList.currentRow;
1821 ProjectNode parentNode = (ProjectNode)row.tag;
1822 bool addFailed = false;
1823 int numSelections = fileDialog.numSelections;
1824 char ** multiFilePaths = fileDialog.multiFilePaths;
1826 Array<String> nameConflictFiles { };
1828 for(c = 0; c < numSelections; c++)
1830 char * filePath = multiFilePaths[c];
1831 FileAttribs exists = FileExists(filePath);
1832 bool addThisFile = true;
1834 if(exists.isDirectory)
1835 addThisFile = false;
1838 if(MessageBox { master = ide, type = yesNo, text = filePath,
1839 contents = $"File doesn't exist. Create?" }.Modal() == yes)
1841 File f = FileOpen(filePath, write);
1849 MessageBox { master = ide, type = ok, text = filePath,
1850 contents = $"Couldn't create file."}.Modal();
1851 addThisFile = false;
1858 /*addFailed = */if(!AddFile(parentNode, filePath, resources, false))//;
1860 nameConflictFiles.Add(CopyString(filePath));
1868 char * part1 = $"The following file";
1869 char * opt1 = $" was ";
1870 char * opt2 = $"s were ";
1871 char * part2 = $"not added because of identical file name conflict within the project.\n\n";
1873 len += strlen(part1);
1874 len += strlen(part2);
1875 len += nameConflictFiles.count > 1 ? strlen(opt2) : strlen(opt1);
1876 for(s : nameConflictFiles)
1877 len += strlen(s) + 1;
1878 message = new char[len + 1];
1879 strcpy(message, part1);
1880 strcat(message, nameConflictFiles.count > 1 ? opt2 : opt1);
1881 strcat(message, part2);
1882 for(s : nameConflictFiles)
1885 strcat(message, "\n");
1887 MessageBox { master = ide, type = ok, text = $"Name Conflict",
1888 contents = message }.Modal();
1891 nameConflictFiles.Free();
1892 delete nameConflictFiles;
1896 ProjectNode AddFile(ProjectNode parentNode, char * filePath, bool resources, bool isTemporary)
1898 ProjectNode result = null;
1899 ProjectNode after = null;
1900 for(node : parentNode.files)
1902 if(node.type != folder && node.type != file && node.type)
1907 result = parentNode.Add(parentNode.project, filePath, after, file, NodeIcons::SelectFileIcon(filePath), !resources);
1913 modifiedDocument = true;
1914 parentNode.project.topNode.modified = true;
1915 parentNode.project.ModifiedAllConfigs(true, false, true, true);
1918 result.row = parentNode.row.AddRowAfter(after ? after.row : null);
1919 result.row.tag = (int)result;
1920 result.row.SetData(null, result);
1925 CodeEditor CreateNew(char * upper, char * lower, char * base, char * className)
1927 CodeEditor codeEditor = null;
1928 ProjectNode projectNode;
1929 ProjectNode after = null;
1930 DataRow row = fileList.currentRow;
1931 ProjectNode parentNode;
1934 if(!row) row = project.topNode.row;
1936 parentNode = (ProjectNode)row.tag;
1938 for(node : parentNode.files)
1940 if(node.type != folder && node.type != file && node.type)
1944 for(c = 1; c < 100; c++)
1947 sprintf(string, c ? "%s%d.ec" : "%s.ec", lower, c);
1948 if((projectNode = parentNode.Add(project, string, after, file, genFile, true)))
1954 char filePath[MAX_LOCATION];
1956 modifiedDocument = true;
1957 project.topNode.modified = true;
1959 project.ModifiedAllConfigs(true, false, false, true);
1960 projectNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
1961 projectNode.row.tag =(int)projectNode;
1963 projectNode.row.SetData(null, projectNode);
1964 fileList.currentRow = projectNode.row;
1966 strcpy(filePath, project.topNode.path);
1967 PathCat(filePath, projectNode.path);
1968 PathCat(filePath, projectNode.name);
1970 codeEditor = (CodeEditor)ide.FindWindow(filePath);
1973 Class baseClass = eSystem_FindClass(__thisModule, base);
1974 subclass(ClassDesignerBase) designerClass = eClass_GetDesigner(baseClass);
1977 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal);
1978 strcpy(name, projectNode.name);
1979 sprintf(name, "%s%d", upper, c);
1981 strcpy(className, name);
1983 designerClass.CreateNew(codeEditor.editBox, codeEditor.clientSize, name, base);
1985 //codeEditor.modifiedDocument = false;
1986 //codeEditor.designer.modifiedDocument = false;
1988 //Code_EnsureUpToDate(codeEditor);
1991 else // TODO: fix no symbols generated when ommiting {} for following else
1993 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal);
1997 codeEditor.ViewDesigner();
1998 codeEditor.codeModified = true;
2005 // Returns true if we opened something
2006 bool OpenSelectedNodes()
2008 bool result = false;
2012 fileList.GetMultiSelection(selection);
2013 for(item = selection.first; item; item = item.next)
2015 DataRow row = item.data;
2016 ProjectNode node = (ProjectNode)row.tag;
2017 if(node.type == file)
2024 selection.Free(null);
2028 void RemoveSelectedNodes()
2033 fileList.GetMultiSelection(selection);
2035 // Remove children of parents we're deleting
2036 for(item = selection.first; item; item = next)
2039 DataRow row = item.data;
2040 ProjectNode n, node = (ProjectNode)row.tag;
2041 bool remove = false;
2044 for(i = selection.first; i && !remove; i = i.next)
2046 ProjectNode iNode = (ProjectNode)((DataRow)i.data).tag;
2047 for(n = node.parent; n; n = n.parent)
2057 selection.Delete(item);
2060 for(item = selection.first; item; item = item.next)
2062 DataRow row = item.data;
2063 ProjectNode node = (ProjectNode)row.tag;
2064 ProjectNode resNode;
2065 for(resNode = node.parent; resNode; resNode = resNode.parent)
2066 if(resNode.type == resources)
2068 if(node.type == file)
2070 Project prj = node.project;
2072 modifiedDocument = true;
2073 prj.topNode.modified = true;
2075 prj.ModifiedAllConfigs(true, false, true, true);
2077 else if(node.type == folder)
2080 sprintf(message, $"Are you sure you want to remove the folder \"%s\"\n"
2081 "and all of its contents from the project?", node.name);
2082 if(MessageBox { master = ide, type = yesNo, text = $"Delete Folder", contents = message }.Modal() == yes)
2084 Project prj = node.project;
2085 if(node.containsFile)
2086 prj.ModifiedAllConfigs(true, false, true, true);
2088 modifiedDocument = true;
2089 prj.topNode.modified = true;
2092 else if(node.type == project && node != project.topNode && !buildInProgress)
2096 for(p : workspace.projects)
2098 if(p.topNode == node)
2104 sprintf(message, $"Are you sure you want to remove the \"%s\" project\n" "from this workspace?", node.name);
2105 if(MessageBox { master = ide, type = yesNo, text = $"Remove Project", contents = message }.Modal() == yes)
2110 workspace.RemoveProject(prj);
2111 //modifiedDocument = true; // when project view is a workspace view
2115 selection.Free(null);