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(ProjectNode node, bool justPrint)
996 char fileName[MAX_LOCATION];
998 Project prj = node.project;
999 ProjectConfig config = prj.config;
1003 for(document = ide.firstChild; document; document = document.next)
1005 if(document.modifiedDocument)
1007 ProjectNode n = GetNodeFromWindow(document, prj);
1008 if(n && n.IsInNode(node) && !document.MenuFileSave(null, 0))
1018 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1020 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
1022 if(!node.GetIsExcluded(config))
1024 node.DeleteIntermediateFiles(compiler, config);
1026 buildInProgress = compilingFile;
1027 ide.AdjustBuildMenus();
1029 //ide.outputView.ShowClearSelectTab(build);
1030 // this stuff doesn't even appear
1031 //ide.outputView.buildBox.Logf($"%s Compiler\n", compiler.name);
1033 ide.outputView.buildBox.Logf($"Compiling %s %s in project %s using the %s configuration...\n",
1034 node.type == file ? $"single file" : $"folder", node.name, prj.name, config.name);
1036 ide.outputView.buildBox.Logf($"Compiling %s %s in project %s...\n",
1037 node.type == file ? $"single file" : $"folder", node.name, prj.name);
1039 prj.Compile(node, compiler, config, justPrint);
1040 buildInProgress = none;
1041 ide.AdjustBuildMenus();
1051 bool Clean(ProjectNode node, bool justPrint)
1054 char fileName[MAX_LOCATION];
1056 Project prj = node.project;
1057 ProjectConfig config = prj.config;
1061 for(document = ide.firstChild; document; document = document.next)
1063 if(document.modifiedDocument)
1065 ProjectNode n = GetNodeFromWindow(document, prj);
1066 if(n && n.IsInNode(node) && !document.MenuFileSave(null, 0))
1076 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1078 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
1080 if(!node.GetIsExcluded(config))
1082 node.DeleteIntermediateFiles(compiler, config);
1085 ide.outputView.buildBox.Logf($"Delete Intermediate Objects for %s %s in project %s using the %s configuration...\n",
1086 node.type == file ? $"single file" : $"folder", node.name, prj.name, config.name);
1088 ide.outputView.buildBox.Logf($"Delete Intermediate Objects for %s %s in project %s...\n",
1089 node.type == file ? $"single file" : $"folder", node.name, prj.name);
1099 bool ProjectNewFile(MenuItem selection, Modifiers mods)
1101 DataRow row = fileList.currentRow;
1104 char fileName[1024];
1105 char filePath[MAX_LOCATION];
1106 ProjectNode parentNode = (ProjectNode)row.tag;
1107 ProjectNode n, fileNode;
1108 parentNode.GetFileSysMatchingPath(filePath);
1109 MakePathRelative(filePath, parentNode.project.topNode.path, filePath);
1110 for(n = parentNode; n && n != parentNode.project.resNode; n = n.parent);
1111 sprintf(fileName, $"Untitled %d", documentID);
1112 fileNode = AddFile(parentNode, fileName, (bool)n, true);
1113 fileNode.path = CopyUnixPath(filePath);
1116 NodeProperties nodeProperties
1119 position = { position.x + 100, position.y + 100 };
1123 nodeProperties.Create(); // not modal?
1129 bool ProjectNewFolder(MenuItem selection, Modifiers mods)
1131 DataRow row = fileList.currentRow;
1134 ProjectNode parentNode = (ProjectNode)row.tag;
1135 NewFolder(parentNode, null, true);
1140 bool ResourcesAddFiles(MenuItem selection, Modifiers mods)
1146 bool ProjectAddFiles(MenuItem selection, Modifiers mods)
1152 bool ProjectImportFolder(MenuItem selection, Modifiers mods)
1154 DataRow row = fileList.currentRow;
1157 ProjectNode toNode = (ProjectNode)row.tag;
1158 ImportFolder(toNode);
1163 bool ProjectAddNewForm(MenuItem selection, Modifiers mods)
1165 CodeEditor codeEditor = CreateNew("Form", "form", "Window", null);
1166 codeEditor.EnsureUpToDate();
1170 bool ProjectAddNewGraph(MenuItem selection, Modifiers mods)
1172 CodeEditor codeEditor = CreateNew("Graph", "graph", "Block", null);
1174 codeEditor.EnsureUpToDate();
1178 bool ProjectRemove(MenuItem selection, Modifiers mods)
1180 DataRow row = fileList.currentRow;
1183 ProjectNode node = (ProjectNode)row.tag;
1184 if(node.type == project)
1185 RemoveSelectedNodes();
1190 bool ProjectUpdateMakefileForAllConfigs(Project project)
1192 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1194 for(config : project.configurations)
1195 ProjectPrepareMakefile(project, forceExists, compiler, config);
1202 bool MenuConfig(MenuItem selection, Modifiers mods)
1204 if(ProjectActiveConfig { master = parent, project = project }.Modal() == ok)
1209 bool MenuCompiler(MenuItem selection, Modifiers mods)
1211 ActiveCompilerDialog compilerDialog
1214 ideSettings = ideSettings, workspaceActiveCompiler = ide.workspace.compiler;
1216 incref compilerDialog;
1217 if(compilerDialog.Modal() == ok && strcmp(compilerDialog.workspaceActiveCompiler, ide.workspace.compiler))
1219 CompilerConfig compiler = ideSettings.GetCompilerConfig(compilerDialog.workspaceActiveCompiler);
1220 ide.workspace.compiler = compilerDialog.workspaceActiveCompiler;
1221 ide.projectView.ShowOutputBuildLog(true);
1222 ide.projectView.DisplayCompiler(compiler, false);
1224 for(prj : ide.workspace.projects)
1225 ide.projectView.ProjectPrepareCompiler(prj, compiler);
1228 delete compilerDialog;
1232 bool MenuSettings(MenuItem selection, Modifiers mods)
1234 ProjectNode node = GetSelectedNode(true);
1235 Project prj = node ? node.project : project;
1236 projectSettingsDialog = ProjectSettings { master = parent, project = prj, projectNode = node };
1237 projectSettingsDialog.Modal();
1244 bool FileProperties(MenuItem selection, Modifiers mods)
1246 DataRow row = fileList.currentRow;
1249 ProjectNode node = (ProjectNode)row.tag;
1250 NodeProperties { parent = parent, master = this, node = node,
1251 position = { position.x + 100, position.y + 100 } }.Create();
1256 bool FileOpenFile(MenuItem selection, Modifiers mods)
1258 OpenSelectedNodes();
1262 bool FileRemoveFile(MenuItem selection, Modifiers mods)
1264 RemoveSelectedNodes();
1268 bool FileCompile(MenuItem selection, Modifiers mods)
1270 DataRow row = fileList.currentRow;
1273 ProjectNode node = (ProjectNode)row.tag;
1274 if(!Compile(node, mods.ctrl && mods.shift))
1275 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
1280 bool FileClean(MenuItem selection, Modifiers mods)
1282 DataRow row = fileList.currentRow;
1285 ProjectNode node = (ProjectNode)row.tag;
1286 if(!Clean(node, mods.ctrl && mods.shift))
1287 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
1292 Project GetSelectedProject(bool useSelection)
1294 Project prj = project;
1297 DataRow row = fileList.currentRow;
1298 ProjectNode node = row ? (ProjectNode)row.tag : null;
1305 void SelectNextProject(bool backwards)
1307 DataRow row = fileList.currentRow;
1308 DataRow currentRow = row;
1309 ProjectNode node = (ProjectNode)row.tag;
1310 if(node.type != project)
1311 row = node.project.topNode.row;
1313 row = row.previous ? row.previous : fileList.lastRow;
1315 row = row.next ? row.next : fileList.firstRow;
1316 if(row && row != currentRow)
1318 fileList.SelectRow(row);
1319 fileList.currentRow = row;
1323 ProjectNode GetSelectedNode(bool useSelection)
1325 ProjectNode node = null;
1328 DataRow row = fileList.currentRow;
1330 node = (ProjectNode)row.tag;
1335 bool MenuBrowseFolder(MenuItem selection, Modifiers mods)
1337 char folder[MAX_LOCATION];
1339 ProjectNode node = GetSelectedNode(true);
1341 node = project.topNode;
1344 strcpy(folder, prj.topNode.path);
1345 if(node != prj.topNode)
1346 PathCatSlash(folder, node.path);
1351 bool Run(MenuItem selection, Modifiers mods)
1353 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1354 ProjectConfig config = project.config;
1355 String args = new char[maxPathLen];
1357 if(ide.workspace.commandLineArgs)
1358 //ide.debugger.GetCommandLineArgs(args);
1359 strcpy(args, ide.workspace.commandLineArgs);
1360 if(ide.debugger.isActive)
1361 project.Run(args, compiler, config);
1362 /*else if(config.targetType == sharedLibrary || config.targetType == staticLibrary)
1363 MessageBox { master = ide, type = ok, text = "Run", contents = "Shared and static libraries cannot be run like executables." }.Modal();*/
1364 else if(BuildInterrim(project, run, compiler, config, false))
1365 project.Run(args, compiler, config);
1373 bool result = false;
1374 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1375 ProjectConfig config = project.config;
1376 TargetTypes targetType = project.GetTargetType(config);
1377 if(targetType == sharedLibrary || targetType == staticLibrary)
1378 MessageBox { master = ide, type = ok, text = $"Run", contents = $"Shared and static libraries cannot be run like executables." }.Modal();
1379 else if(project.GetCompress(config))
1380 MessageBox { master = ide, text = $"Starting Debug", contents = $"Debugging compressed applications is not supported\n" }.Modal();
1381 else if(project.GetDebug(config) ||
1382 MessageBox { master = ide, type = okCancel, text = $"Starting Debug", contents = $"Attempting to debug non-debug configuration\nProceed anyways?" }.Modal() == ok)
1384 if(/*!IsProjectModified() ||*/ BuildInterrim(project, start, compiler, config, false))
1386 if(compiler.type.isVC)
1388 //bool result = false;
1389 char oldwd[MAX_LOCATION];
1390 PathBackup pathBackup { };
1391 char command[MAX_LOCATION];
1393 ide.SetPath(false, compiler, config);
1395 GetWorkingDir(oldwd, sizeof(oldwd));
1396 ChangeWorkingDir(project.topNode.path);
1398 sprintf(command, "%s /useenv %s.sln /projectconfig \"%s|Win32\" /command \"%s\"" , "devenv", project.name, config.name, "Debug.Start");
1400 ChangeWorkingDir(oldwd);
1406 ide.debugger.Start(compiler, config);
1415 void GoToError(const char * line)
1419 while(isspace(*line)) line++;
1420 colon = strstr(line, ":");
1425 bool lookForLineNumber = true;
1427 // deal with linking error
1428 if(colon && colon[1] == ' ')
1430 colon = strstr(colon + 1, ":");
1431 if(colon && !colon[1])
1433 colon = strstr(line, ":");
1434 lookForLineNumber = false;
1436 else if(colon && !isdigit(colon[1]))
1439 colon = strstr(line, ":");
1442 // Don't be mistaken by the drive letter colon
1443 if(colon && (colon[1] == '/' || colon[1] == '\\'))
1444 colon = strstr(colon + 1, ":");
1445 if(colon && lookForLineNumber)
1449 char * par = RSearchString(line, "(", colon - line, true, false);
1450 if(par && strstr(par, ")"))
1452 else if((colon+1)[0] == ' ')
1454 // NOTE: This is the same thing as saying 'colon = line'
1455 for( ; colon != line; colon--)
1459 lineNumber = atoi(colon + 1);
1461 comma = strchr(colon, ',');
1463 col = atoi(comma+1);
1465 comma = strchr(colon+1, ':');
1467 col = atoi(comma+1);
1471 char moduleName[MAX_LOCATION], filePath[MAX_LOCATION];
1475 char * inFileIncludedFrom = strstr(line, stringInFileIncludedFrom);
1476 char * start = inFileIncludedFrom ? line + strlen(stringInFileIncludedFrom) : line;
1477 int len = (int)(colon - start);
1478 len = Min(len, MAX_LOCATION-1);
1480 strncpy(moduleName, start, len);
1481 moduleName[len] = '\0';
1484 strcpy(moduleName, line);
1486 // Remove stuff in brackets
1488 bracket = strstr(moduleName, "(");
1489 if(bracket) *bracket = '\0';
1491 MakeSlashPath(moduleName);
1495 // Check if it's one of our modules
1496 ProjectNode node = project.topNode.Find(moduleName, false);
1499 strcpy(moduleName, node.path);
1500 PathCatSlash(moduleName, node.name);
1503 moduleName[0] = '\0';
1507 CodeEditor codeEditor;
1508 strcpy(filePath, project.topNode.path);
1509 PathCatSlash(filePath, moduleName);
1511 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
1514 char name[MAX_LOCATION];
1515 // TOFIX: Improve on this, don't use only filename, make a function
1516 if(ide && ide.workspace)
1518 for(prj : ide.workspace.projects)
1520 if(prj.topNode.FindWithPath(moduleName, false))
1522 strcpy(filePath, prj.topNode.path);
1523 PathCatSlash(filePath, moduleName);
1524 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
1531 if(codeEditor && lineNumber)
1533 EditBox editBox = codeEditor.editBox;
1534 editBox.GoToLineNum(lineNumber - 1);
1535 editBox.GoToPosition(editBox.line, lineNumber - 1, col ? (col - 1) : 0);
1542 bool OpenNode(ProjectNode node)
1544 char filePath[MAX_LOCATION];
1545 node.GetFullFilePath(filePath);
1546 return ide.OpenFile(filePath, normal, true/*false Why was it opening hidden?*/, null, something, normal) ? true : false;
1549 void AddNode(ProjectNode node, DataRow addTo)
1551 DataRow row = addTo ? addTo.AddRow() : fileList.AddRow();
1553 row.tag = (int)node;
1556 if(node.type == resources)
1559 row.SetData(null, node);
1561 if(node.files && node.files.first && node.parent &&
1562 !(!node.parent.parent &&
1563 (!strcmpi(node.name, "notes") || !strcmpi(node.name, "sources") ||
1564 !strcmpi(node.name, "src") || !strcmpi(node.name, "tools"))))
1565 row.collapsed = true;
1566 else if(node.type == folder)
1567 node.icon = openFolder;
1571 for(child : node.files)
1572 AddNode(child, row);
1576 void DeleteNode(ProjectNode projectNode)
1578 if(projectNode.files)
1581 while(child = projectNode.files.first)
1584 fileList.DeleteRow(projectNode.row);
1585 projectNode.Delete();
1588 bool ProjectSave(MenuItem selection, Modifiers mods)
1590 DataRow row = fileList.currentRow;
1591 ProjectNode node = row ? (ProjectNode)row.tag : null;
1592 Project prj = node ? node.project : null;
1595 prj.StopMonitoring();
1596 if(prj.Save(prj.filePath))
1598 Project modPrj = null;
1599 prj.topNode.modified = false;
1600 for(p : ide.workspace.projects)
1602 if(p.topNode.modified)
1609 modifiedDocument = false;
1612 prj.StartMonitoring();
1617 bool ShowOutputBuildLog(bool cleanLog)
1619 OutputView output = ide.outputView;
1621 output.ShowClearSelectTab(build);
1624 output.SelectTab(build);
1632 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1633 ProjectConfig config = project.config;
1635 bool result = false;
1636 if(/*!IsProjectModified() ||*/ BuildInterrim(project, restart, compiler, config, false))
1638 // For Restart, compiler and config will only be used if for
1639 // whatever reason (if at all possible) the Debugger is in a
1640 // 'terminated' or 'none' state
1641 ide.debugger.Restart(compiler, config);
1651 ide.debugger.Resume();
1657 ide.debugger.Break();
1663 ide.debugger.Stop();
1667 bool DebugStepInto()
1669 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1670 ProjectConfig config = project.config;
1672 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config, false)))
1673 ide.debugger.StepInto(compiler, config);
1678 bool DebugStepOver(bool skip)
1680 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1681 ProjectConfig config = project.config;
1683 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config, false)))
1684 ide.debugger.StepOver(compiler, config, skip);
1690 bool DebugStepOut(bool skip)
1692 ide.debugger.StepOut(skip);
1696 void ImportFolder(ProjectNode toNode)
1700 //bool isFolder = toNode.type == folder;
1701 //bool isRes = toNode.isInResources;
1703 FileDialog fileDialog = importFileDialog;
1704 fileDialog.master = parent;
1705 if(fileDialog.Modal() == ok)
1707 ImportFolderFSI fsi { projectView = this };
1708 fsi.stack.Add(toNode);
1709 fsi.Iterate(fileDialog.filePath);
1715 ProjectNode NewFolder(ProjectNode parentNode, char * name, bool showProperties)
1719 ProjectNode folderNode;
1720 Project prj = parentNode.project;
1722 ProjectNode after = null;
1723 for(node : parentNode.files)
1725 if(node.type != folder)
1731 folderNode = parentNode.Add(prj, name, after, folder, folder, true);
1734 for(c = 0; c < 100; c++)
1737 sprintf(string, c ? "New Folder (%d)" : "New Folder", c);
1738 if((folderNode = parentNode.Add(prj, string, after, folder, folder, true)))
1745 NodeProperties nodeProperties;
1748 modifiedDocument = true;
1749 prj.topNode.modified = true;
1752 folderNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
1753 folderNode.row.tag = (int)folderNode;
1755 folderNode.row.SetData(null, folderNode);
1756 fileList.currentRow = folderNode.row;
1760 nodeProperties = NodeProperties
1762 parent, this, mode = newFolder, node = folderNode;
1763 position = { position.x + 100, position.y + 100 };
1765 nodeProperties.Create(); // Modal?
1773 void AddFiles(bool resources)
1775 FileDialog fileDialog = (!resources) ? this.fileDialog : resourceFileDialog;
1776 fileDialog.type = multiOpen;
1777 fileDialog.text = !resources ? $"Add Files to Project" : $"Add Resources to Project";
1778 fileDialog.master = parent;
1780 if(fileDialog.Modal() == ok)
1783 DataRow row = fileList.currentRow;
1784 ProjectNode parentNode = (ProjectNode)row.tag;
1785 bool addFailed = false;
1786 int numSelections = fileDialog.numSelections;
1787 char ** multiFilePaths = fileDialog.multiFilePaths;
1789 Array<String> nameConflictFiles { };
1791 for(c = 0; c < numSelections; c++)
1793 char * filePath = multiFilePaths[c];
1794 FileAttribs exists = FileExists(filePath);
1795 bool addThisFile = true;
1797 if(exists.isDirectory)
1798 addThisFile = false;
1801 if(MessageBox { master = ide, type = yesNo, text = filePath,
1802 contents = $"File doesn't exist. Create?" }.Modal() == yes)
1804 File f = FileOpen(filePath, write);
1812 MessageBox { master = ide, type = ok, text = filePath,
1813 contents = $"Couldn't create file."}.Modal();
1814 addThisFile = false;
1821 /*addFailed = */if(!AddFile(parentNode, filePath, resources, false))//;
1823 nameConflictFiles.Add(CopyString(filePath));
1831 char * part1 = $"The following file";
1832 char * opt1 = $" was ";
1833 char * opt2 = $"s were ";
1834 char * part2 = $"not added because of identical file name conflict within the project.\n\n";
1836 len += strlen(part1);
1837 len += strlen(part2);
1838 len += nameConflictFiles.count > 1 ? strlen(opt2) : strlen(opt1);
1839 for(s : nameConflictFiles)
1840 len += strlen(s) + 1;
1841 message = new char[len + 1];
1842 strcpy(message, part1);
1843 strcat(message, nameConflictFiles.count > 1 ? opt2 : opt1);
1844 strcat(message, part2);
1845 for(s : nameConflictFiles)
1848 strcat(message, "\n");
1850 MessageBox { master = ide, type = ok, text = $"Name Conflict",
1851 contents = message }.Modal();
1854 nameConflictFiles.Free();
1855 delete nameConflictFiles;
1859 ProjectNode AddFile(ProjectNode parentNode, char * filePath, bool resources, bool isTemporary)
1861 ProjectNode result = null;
1862 ProjectNode after = null;
1863 for(node : parentNode.files)
1865 if(node.type != folder && node.type != file && node.type)
1870 result = parentNode.Add(parentNode.project, filePath, after, file, NodeIcons::SelectFileIcon(filePath), !resources);
1876 modifiedDocument = true;
1877 parentNode.project.topNode.modified = true;
1878 parentNode.project.ModifiedAllConfigs(true, false, true, true);
1881 result.row = parentNode.row.AddRowAfter(after ? after.row : null);
1882 result.row.tag = (int)result;
1883 result.row.SetData(null, result);
1888 CodeEditor CreateNew(char * upper, char * lower, char * base, char * className)
1890 CodeEditor codeEditor = null;
1891 ProjectNode projectNode;
1892 ProjectNode after = null;
1893 DataRow row = fileList.currentRow;
1894 ProjectNode parentNode;
1897 if(!row) row = project.topNode.row;
1899 parentNode = (ProjectNode)row.tag;
1901 for(node : parentNode.files)
1903 if(node.type != folder && node.type != file && node.type)
1907 for(c = 1; c < 100; c++)
1910 sprintf(string, c ? "%s%d.ec" : "%s.ec", lower, c);
1911 if((projectNode = parentNode.Add(project, string, after, file, genFile, true)))
1917 char filePath[MAX_LOCATION];
1919 modifiedDocument = true;
1920 project.topNode.modified = true;
1922 project.ModifiedAllConfigs(true, false, false, true);
1923 projectNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
1924 projectNode.row.tag =(int)projectNode;
1926 projectNode.row.SetData(null, projectNode);
1927 fileList.currentRow = projectNode.row;
1929 strcpy(filePath, project.topNode.path);
1930 PathCat(filePath, projectNode.path);
1931 PathCat(filePath, projectNode.name);
1933 codeEditor = (CodeEditor)ide.FindWindow(filePath);
1936 Class baseClass = eSystem_FindClass(__thisModule, base);
1937 subclass(ClassDesignerBase) designerClass = eClass_GetDesigner(baseClass);
1940 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal);
1941 strcpy(name, projectNode.name);
1942 sprintf(name, "%s%d", upper, c);
1944 strcpy(className, name);
1946 designerClass.CreateNew(codeEditor.editBox, codeEditor.clientSize, name, base);
1948 //codeEditor.modifiedDocument = false;
1949 //codeEditor.designer.modifiedDocument = false;
1951 //Code_EnsureUpToDate(codeEditor);
1954 else // TODO: fix no symbols generated when ommiting {} for following else
1956 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal);
1960 codeEditor.ViewDesigner();
1961 codeEditor.codeModified = true;
1968 // Returns true if we opened something
1969 bool OpenSelectedNodes()
1971 bool result = false;
1975 fileList.GetMultiSelection(selection);
1976 for(item = selection.first; item; item = item.next)
1978 DataRow row = item.data;
1979 ProjectNode node = (ProjectNode)row.tag;
1980 if(node.type == file)
1987 selection.Free(null);
1991 void RemoveSelectedNodes()
1996 fileList.GetMultiSelection(selection);
1998 // Remove children of parents we're deleting
1999 for(item = selection.first; item; item = next)
2002 DataRow row = item.data;
2003 ProjectNode n, node = (ProjectNode)row.tag;
2004 bool remove = false;
2007 for(i = selection.first; i && !remove; i = i.next)
2009 ProjectNode iNode = (ProjectNode)((DataRow)i.data).tag;
2010 for(n = node.parent; n; n = n.parent)
2020 selection.Delete(item);
2023 for(item = selection.first; item; item = item.next)
2025 DataRow row = item.data;
2026 ProjectNode node = (ProjectNode)row.tag;
2027 ProjectNode resNode;
2028 for(resNode = node.parent; resNode; resNode = resNode.parent)
2029 if(resNode.type == resources)
2031 if(node.type == file)
2033 Project prj = node.project;
2035 modifiedDocument = true;
2036 prj.topNode.modified = true;
2038 prj.ModifiedAllConfigs(true, false, true, true);
2040 else if(node.type == folder)
2043 sprintf(message, $"Are you sure you want to remove the folder \"%s\"\n"
2044 "and all of its contents from the project?", node.name);
2045 if(MessageBox { master = ide, type = yesNo, text = $"Delete Folder", contents = message }.Modal() == yes)
2047 Project prj = node.project;
2048 if(node.containsFile)
2049 prj.ModifiedAllConfigs(true, false, true, true);
2051 modifiedDocument = true;
2052 prj.topNode.modified = true;
2055 else if(node.type == project && node != project.topNode && !buildInProgress)
2059 for(p : workspace.projects)
2061 if(p.topNode == node)
2067 sprintf(message, $"Are you sure you want to remove the \"%s\" project\n" "from this workspace?", node.name);
2068 if(MessageBox { master = ide, type = yesNo, text = $"Remove Project", contents = message }.Modal() == yes)
2073 workspace.RemoveProject(prj);
2074 //modifiedDocument = true; // when project view is a workspace view
2078 selection.Free(null);