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, $"Debug Generate Symbols", l, NotifySelect = FileDebugGenerateSymbols }.disabled = buildMenuUnavailable;
227 MenuDivider { popupContent };
228 MenuItem { popupContent, $"New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
229 MenuItem { popupContent, $"New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
230 MenuItem { popupContent, $"Import Folder...", i, NotifySelect = ProjectImportFolder };
231 MenuItem { popupContent, $"Add Files to Project...", f, NotifySelect = ProjectAddFiles };
232 MenuDivider { popupContent };
233 MenuItem { popupContent, $"Add New Form...", o, NotifySelect = ProjectAddNewForm };
234 // MenuItem { popupContent, "Add New Behavior Graph...", g, NotifySelect = ProjectAddNewGraph };
235 MenuDivider { popupContent };
236 if(node != ((Project)workspace.projects.first).topNode)
238 MenuItem { popupContent, $"Remove project from workspace", r, NotifySelect = ProjectRemove }.disabled = buildMenuUnavailable;
239 MenuDivider { popupContent };
241 MenuItem { popupContent, $"Active Configuration...", s, Key { f5, alt = true } , NotifySelect = MenuConfig };
242 MenuItem { popupContent, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
243 MenuDivider { popupContent };
244 MenuItem { popupContent, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
245 MenuDivider { popupContent };
246 MenuItem { popupContent, $"Save", v, Key { s, ctrl = true }, NotifySelect = ProjectSave }.disabled = !node.modified;
247 MenuDivider { popupContent };
248 MenuItem { popupContent, $"Properties...", p, Key { enter, alt = true }, NotifySelect = FileProperties };
250 else if(node.type == resources)
252 MenuItem { popupContent, $"New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
253 MenuItem { popupContent, $"New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
254 MenuItem { popupContent, $"Import Folder...", i, NotifySelect = ProjectImportFolder };
255 MenuItem { popupContent, $"Add Resources to Project...", f, NotifySelect = ResourcesAddFiles };
256 MenuItem { popupContent, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
257 MenuDivider { popupContent };
258 MenuItem { popupContent, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
259 MenuItem { popupContent, $"Properties...", p, Key { enter, alt = true }, NotifySelect = FileProperties };
261 else if(node.type == file)
263 MenuItem { popupContent, $"Open", o, NotifySelect = FileOpenFile };
264 MenuDivider { popupContent };
265 MenuItem { popupContent, $"Clean", l, NotifySelect = FileClean }.disabled = buildMenuUnavailable;
266 MenuItem { popupContent, $"Compile", c, Key { f7, ctrl = true}, NotifySelect = FileCompile }.disabled = buildMenuUnavailable;
267 MenuDivider { popupContent };
268 MenuItem { popupContent, $"Debug Precompile", l, NotifySelect = FileDebugPrecompile }.disabled = buildMenuUnavailable;
269 MenuItem { popupContent, $"Debug Compile", l, NotifySelect = FileDebugCompile }.disabled = buildMenuUnavailable;
270 MenuDivider { popupContent };
271 MenuItem { popupContent, $"Remove", r, NotifySelect = FileRemoveFile };
272 MenuDivider { popupContent };
273 MenuItem { popupContent, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
274 MenuDivider { popupContent };
275 MenuItem { popupContent, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
276 MenuItem { popupContent, $"Properties..", p, Key { enter, alt = true }, NotifySelect = FileProperties };
278 else if(node.type == folder)
280 bool isInResources = node.isInResources;
282 MenuItem { popupContent, $"New File...", l, Key { l, ctrl = true }, NotifySelect = ProjectNewFile };
283 MenuItem { popupContent, $"New Folder...", n, Key { f, ctrl = true }, NotifySelect = ProjectNewFolder };
284 MenuItem { popupContent, $"Import Folder...", i, NotifySelect = ProjectImportFolder };
287 MenuItem { popupContent, $"Add Resources to Folder...", f, NotifySelect = ResourcesAddFiles };
291 MenuItem { popupContent, $"Add Files to Folder...", f, NotifySelect = ProjectAddFiles };
295 MenuDivider { popupContent };
296 MenuItem { popupContent, $"Add New Form...", o, NotifySelect = ProjectAddNewForm };
297 MenuItem { popupContent, $"Add New Behavior Graph...", g, NotifySelect = ProjectAddNewGraph };
299 MenuDivider { popupContent };
300 MenuItem { popupContent, $"Clean", l, NotifySelect = FileClean }.disabled = buildMenuUnavailable;
301 MenuItem { popupContent, $"Compile", c, Key { f7, ctrl = true}, NotifySelect = FileCompile }.disabled = buildMenuUnavailable;
302 MenuDivider { popupContent };
303 MenuItem { popupContent, $"Remove", r, NotifySelect = FileRemoveFile };
304 MenuDivider { popupContent };
305 MenuItem { popupContent, $"Browse Folder", w, NotifySelect = MenuBrowseFolder };
306 MenuDivider { popupContent };
307 MenuItem { popupContent, $"Settings...", s, Key { f7, alt = true } , NotifySelect = MenuSettings };
308 MenuItem { popupContent, $"Properties...", p, Key { enter, alt = true }, NotifySelect = FileProperties };
313 master = this, menu = popupContent;
315 x + clientStart.x + absPosition.x - app.desktop.position.x,
316 y + clientStart.y + absPosition.y - app.desktop.position.y };
318 void NotifyDestroyed(Window window, DialogResult result)
329 bool NotifyKeyHit(ListBox listBox, DataRow row, Key key, unichar ch)
331 if(key == altUp || key == altDown)
333 SelectNextProject(key == altUp);
339 bool NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch)
343 ProjectNode node = (ProjectNode)row.tag;
346 case altEnter: case Key { keyPadEnter, alt = true }:
348 NodeProperties { parent = parent, master = this,
349 position = { position.x + 100, position.y + 100 }, node = node }.Create();
352 case enter: case keyPadEnter:
355 for(resNode = node.parent; resNode; resNode = resNode.parent)
356 if(resNode.type == resources)
358 if(node.type == project || (node.type == folder && !resNode))
363 else if(node.type == resources || node.type == folder)
372 if(node.type == project || node.type == folder || node.type == resources)
381 if(node.type == project || node.type == folder || node.type == resources)
383 NewFolder(node, null, true);
390 if(node.type == file)
392 FileCompile(null, (Modifiers)key);
397 case Key { space, shift = true }:
400 if(node.type == NodeTypes::project)
403 for(p : workspace.projects)
405 if(p.topNode == node)
411 prj.RotateActiveConfig(!key.shift);
422 case enter: case keyPadEnter: OpenSelectedNodes(); break;
423 case del: RemoveSelectedNodes(); break;
426 Window activeClient = ide.activeClient;
428 activeClient.Activate();
430 ide.RepositionWindows(true);
437 bool NotifyCollapse(ListBox listBox, DataRow row, bool collapsed)
439 ProjectNode node = (ProjectNode)row.tag;
440 if(node.type == folder)
441 node.icon = collapsed ? folder : openFolder;
446 FileDialog importFileDialog { autoCreate = false, type = selectDir, text = $"Import Folder" };
447 FileDialog projectFileDialog
449 autoCreate = false, filters = projectFilters.array, sizeFilters = projectFilters.count * sizeof(FileFilter);
450 types = projectTypes.array, sizeTypes = projectTypes.count * sizeof(FileType);
452 FileDialog fileDialog
454 autoCreate = false, mayNotExist = true, filters = fileFilters.array, sizeFilters = fileFilters.count * sizeof(FileFilter);
456 FileDialog resourceFileDialog
458 autoCreate = false, mayNotExist = true, filters = resourceFilters.array, sizeFilters = resourceFilters.count * sizeof(FileFilter);
461 Menu fileMenu { menu, $"File", f };
462 MenuItem { fileMenu, $"Save", s, Key { s, ctrl = true }, NotifySelect = MenuFileSave };
463 // MenuItem { fileMenu, "Save As...", a, NotifySelect = MenuFileSaveAs };
465 bool OnClose(bool parentClosing)
467 if(!parentClosing && visible)
477 DialogResult dialogRes;
480 strcpy(msg, $"You have modified projects.\nSave changes to ");
481 for(p : ide.workspace.projects)
483 if(p.topNode.modified)
485 if(!first) strcat(msg, ", ");
492 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = msg }.Modal();
496 // TOFIX: Precomp error if brackets are taken out
497 return (DialogResult)MenuFileSave(null, 0) != cancel;
499 else if(dialogRes == cancel)
501 modifiedDocument = false;
508 //if(ide.findInFilesDialog && ide.findInFilesDialog.created && ide.findInFilesDialog.mode != directory)
509 // ide.findInFilesDialog.SearchStop();
511 ide.outputView.buildBox.Clear();
512 ide.outputView.debugBox.Clear();
513 //ide.outputView.findBox.Clear();
514 ide.callStackView.Clear();
515 ide.watchesView.Clear();
516 ide.threadsView.Clear();
517 ide.breakpointsView.Clear();
518 ide.outputView.ShowClearSelectTab(find); // why this?
521 bool OnSaveFile(char * fileName)
523 for(prj : ide.workspace.projects)
525 if(prj.topNode.modified)
527 prj.StopMonitoring();
528 if(prj.Save(prj.filePath))
529 prj.topNode.modified = false;
530 prj.StartMonitoring();
533 modifiedDocument = false;
538 bool IsModuleInProject(char * filePath)
540 char moduleName[MAX_FILENAME]; //, modulePath[MAX_LOCATION];
541 GetLastDirectory(filePath, moduleName);
542 return project.topNode.Find(moduleName, false) != null;
545 bool GetRelativePath(char * filePath, char * relativePath)
547 return project.GetRelativePath(filePath, relativePath);
550 ProjectNode GetNodeFromWindow(Window document, Project project)
552 if(document.fileName)
554 char winFileName[MAX_LOCATION];
555 char * documentFileName = GetSlashPathBuffer(winFileName, document.fileName);
556 for(p : ide.workspace.projects)
558 Project prj = project ? project : p;
560 if((node = prj.topNode.FindByFullPath(documentFileName, false)))
568 // ((( UTILITY FUNCTIONS )))
570 // ************************************************************************
571 // *** These methods below are part of a sequence of events, and as ***
572 // *** such they must be passed the current compiler and project config ***
573 // ************************************************************************
574 bool DisplayCompiler(CompilerConfig compiler, bool cleanLog)
576 ide.outputView.buildBox.Logf($"%s Compiler\n", compiler ? compiler.name : $"{problem with compiler selection}");
580 bool ProjectPrepareForToolchain(Project project, PrepareMakefileMethod method, bool cleanLog, bool displayCompiler,
581 CompilerConfig compiler, ProjectConfig config)
584 char message[MAX_F_STRING];
585 LogBox logBox = ide.outputView.buildBox;
587 ShowOutputBuildLog(cleanLog);
590 DisplayCompiler(compiler, false);
592 ProjectPrepareCompiler(project, compiler);
593 ProjectPrepareMakefile(project, method, compiler, config);
597 bool ProjectPrepareCompiler(Project project, CompilerConfig compiler)
599 if(!project.GenerateCrossPlatformMk() || !project.GenerateCompilerCf(compiler))
600 ide.outputView.buildBox.Logf($"Error generating compiler configuration (Is the project/config directory writable?)\n");
604 // Note: Compiler is only passed in to for VisualStudio support
605 bool ProjectPrepareMakefile(Project project, PrepareMakefileMethod method, CompilerConfig compiler, ProjectConfig config)
607 if(compiler.type.isVC)
609 // I'm guessing we'll want to support generating VS files on Linux as well...
610 ide.statusBar.text = $"Generating Visual Studio Solution...";
612 //GenerateVSSolutionFile(project, compiler);
613 ide.statusBar.text = $"Generating Visual Studio Project...";
615 //GenerateVCProjectFile(project, compiler);
616 ide.statusBar.text = null;
622 char makefilePath[MAX_LOCATION];
623 char makefileName[MAX_LOCATION];
625 LogBox logBox = ide.outputView.buildBox;
627 strcpy(makefilePath, project.topNode.path);
628 project.CatMakeFileName(makefileName, config);
629 PathCatSlash(makefilePath, makefileName);
631 exists = FileExists(makefilePath);
632 if(method == force ||
633 (method == forceExists && exists) ||
634 (method == normal && (!exists || (config && config.makingModified))))
638 ide.statusBar.text = $"Generating Makefile & Dependencies..."; // Dependencies?
641 if((method == normal && !exists) || (method == force && !exists))
642 action = $"Generating ";
643 else if(method == force)
644 action = $"Regenerating ";
645 else if(method == normal || method == forceExists)
646 action = $"Updating ";
650 reason = $"Makefile doesn't exist. ";
651 else if(project.topNode.modified)
652 reason = $"Project has been modified. ";
656 //logBox.Logf("%s\n", makefileName);
657 logBox.Logf($"%s - %s%smakefile for %s config...\n", makefileName, reason, action, GetConfigName(config));
659 if(!project.GenerateMakefile(null, false, null, config))
660 ide.outputView.buildBox.Logf($"Error generating makefile (Is the project directory writable?)\n");
662 ide.statusBar.text = null;
670 bool BuildInterrim(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config, bool justPrint)
672 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
674 ide.outputView.buildBox.Logf($"Building project %s using the %s configuration...\n", prj.name, GetConfigName(config));
675 return Build(prj, buildType, compiler, config, justPrint);
680 bool DebugStopForMake(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config)
683 // TOFIX: DebugStop is being abused and backfiring on us.
684 // It's supposed to be the 'Debug/Stop' item, not unloading executable or anything else
686 // configIsInDebugSession seems to be used for two OPPOSITE things:
687 // If we're debugging another config, we need to unload the executable!
688 // In building, we want to stop if we're debugging the 'same' executable
689 if(buildType != run) ///* && prj == project*/ && prj.configIsInDebugSession)
691 if(buildType == start || buildType == restart)
693 if(ide.debugger && ide.debugger.isPrepared)
694 result = DebugStop();
698 if(ide.project == prj && ide.debugger && ide.debugger.prjConfig == config && ide.debugger.isPrepared)
699 result = DebugStop();
705 bool Build(Project prj, BuildType buildType, CompilerConfig compiler, ProjectConfig config, bool justPrint)
711 for(document = master.firstChild; document; document = document.next)
713 if(document.modifiedDocument)
715 ProjectNode node = GetNodeFromWindow(document, prj);
716 if(node && !document.MenuFileSave(null, 0))
725 DirExpression targetDir = prj.GetTargetDir(compiler, config);
727 DebugStopForMake(prj, buildType, compiler, config);
729 // TODO: Disabled until problems fixed... is it fixed?
730 if(buildType == rebuild || (config && config.compilingModified))
731 prj.Clean(compiler, config, false, justPrint);
734 if(buildType == relink || (config && config.linkingModified))
736 char target[MAX_LOCATION];
738 strcpy(target, prj.topNode.path);
739 PathCat(target, targetDir.dir);
740 prj.CatTargetFileName(target, compiler, config);
741 if(FileExists(target))
744 if(config && config.symbolGenModified)
746 DirExpression objDir = prj.GetObjDir(compiler, config);
747 char fileName[MAX_LOCATION];
748 char moduleName[MAX_FILENAME];
749 strcpy(fileName, prj.topNode.path);
750 PathCatSlash(fileName, objDir.dir);
751 strcpy(moduleName, prj.moduleName);
752 strcat(moduleName, ".main.ec");
753 PathCatSlash(fileName, moduleName);
754 if(FileExists(fileName))
755 DeleteFile(fileName);
756 ChangeExtension(fileName, "c", fileName);
757 if(FileExists(fileName))
758 DeleteFile(fileName);
759 ChangeExtension(fileName, "o", fileName);
760 if(FileExists(fileName))
761 DeleteFile(fileName);
766 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
767 ide.AdjustBuildMenus();
768 ide.AdjustDebugMenus();
770 result = prj.Build(buildType == run, null, compiler, config, justPrint, normal);
774 config.compilingModified = false;
775 if(!ide.ShouldStopBuild())
776 config.linkingModified = false;
778 config.symbolGenModified = false;
780 buildInProgress = none;
781 ide.AdjustBuildMenus();
782 ide.AdjustDebugMenus();
784 ide.workspace.modified = true;
791 // ((( USER ACTIONS )))
793 // ************************************************************************
794 // *** Methods below should atomically start a process, and as such ***
795 // *** they can query compiler and config directly from ide and project ***
796 // *** but ONLY ONCE!!! ***
797 // ************************************************************************
799 bool ProjectBuild(MenuItem selection, Modifiers mods)
801 Project prj = project;
802 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
803 ProjectConfig config;
804 if(selection || !ide.activeClient)
806 DataRow row = fileList.currentRow;
807 ProjectNode node = row ? (ProjectNode)row.tag : null;
808 if(node) prj = node.project;
812 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
817 if(/*prj != project || */!prj.GetConfigIsInDebugSession(config) || !ide.DontTerminateDebugSession($"Project Build"))
819 BuildInterrim(prj, build, compiler, config, mods.ctrl && mods.shift);
825 bool ProjectLink(MenuItem selection, Modifiers mods)
827 Project prj = project;
828 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
829 ProjectConfig config;
830 if(selection || !ide.activeClient)
832 DataRow row = fileList.currentRow;
833 ProjectNode node = row ? (ProjectNode)row.tag : null;
834 if(node) prj = node.project;
838 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
843 if(!prj.GetConfigIsInDebugSession(config) ||
844 (!ide.DontTerminateDebugSession($"Project Link") && DebugStopForMake(prj, relink, compiler, config)))
846 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
848 ide.outputView.buildBox.Logf($"Relinking project %s using the %s configuration...\n", prj.name, GetConfigName(config));
850 config.linkingModified = true;
851 Build(prj, relink, compiler, config, mods.ctrl && mods.shift);
858 bool ProjectRebuild(MenuItem selection, Modifiers mods)
860 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
861 Project prj = project;
862 ProjectConfig config;
863 if(selection || !ide.activeClient)
865 DataRow row = fileList.currentRow;
866 ProjectNode node = row ? (ProjectNode)row.tag : null;
867 if(node) prj = node.project;
871 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
876 if(!prj.GetConfigIsInDebugSession(config) ||
877 (!ide.DontTerminateDebugSession($"Project Rebuild") && DebugStopForMake(prj, rebuild, compiler, config)))
879 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
881 ide.outputView.buildBox.Logf($"Rebuilding project %s using the %s configuration...\n", prj.name, GetConfigName(config));
884 config.compilingModified = true;
885 config.makingModified = true;
886 }*/ // -- should this still be used depite the new solution of BuildType?
887 Build(prj, rebuild, compiler, config, mods.ctrl && mods.shift);
894 bool ProjectClean(MenuItem selection, Modifiers mods)
896 Project prj = project;
897 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
898 ProjectConfig config;
899 if(selection || !ide.activeClient)
901 DataRow row = fileList.currentRow;
902 ProjectNode node = row ? (ProjectNode)row.tag : null;
903 if(node) prj = node.project;
907 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
912 if(!prj.GetConfigIsInDebugSession(config) ||
913 (!ide.DontTerminateDebugSession($"Project Clean") && DebugStopForMake(prj, clean, compiler, config)))
915 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
917 ide.outputView.buildBox.Logf($"Cleaning project %s using the %s configuration...\n", prj.name, GetConfigName(config));
919 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
920 ide.AdjustBuildMenus();
921 ide.AdjustDebugMenus();
923 prj.Clean(compiler, config, false, mods.ctrl && mods.shift);
924 buildInProgress = none;
925 ide.AdjustBuildMenus();
926 ide.AdjustDebugMenus();
933 bool ProjectRealClean(MenuItem selection, Modifiers mods)
935 Project prj = project;
936 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
937 ProjectConfig config;
938 if(selection || !ide.activeClient)
940 DataRow row = fileList.currentRow;
941 ProjectNode node = row ? (ProjectNode)row.tag : null;
942 if(node) prj = node.project;
946 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
951 if(!prj.GetConfigIsInDebugSession(config) ||
952 (!ide.DontTerminateDebugSession($"Project Real Clean") && DebugStopForMake(prj, clean, compiler, config)))
954 if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
956 ide.outputView.buildBox.Logf($"Removing intermediate objects directory for project %s using the %s configuration...\n", prj.name, GetConfigName(config));
958 buildInProgress = prj == project ? buildingMainProject : buildingSecondaryProject;
959 ide.AdjustBuildMenus();
960 ide.AdjustDebugMenus();
962 prj.Clean(compiler, config, true, mods.ctrl && mods.shift);
963 buildInProgress = none;
964 ide.AdjustBuildMenus();
965 ide.AdjustDebugMenus();
972 bool ProjectRegenerate(MenuItem selection, Modifiers mods)
974 Project prj = project;
975 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
976 ShowOutputBuildLog(true);
977 if(selection || !ide.activeClient)
979 DataRow row = fileList.currentRow;
980 ProjectNode node = row ? (ProjectNode)row.tag : null;
986 ProjectNode node = GetNodeFromWindow(ide.activeClient, null);
991 DisplayCompiler(compiler, false);
992 ProjectPrepareCompiler(project, compiler);
993 ProjectPrepareMakefile(prj, force, compiler, prj.config);
998 bool Compile(Project project, List<ProjectNode> nodes, bool justPrint, SingleFileCompileMode mode)
1001 char fileName[MAX_LOCATION];
1003 ProjectConfig config = project.config;
1007 for(document = ide.firstChild; document; document = document.next)
1009 if(document.modifiedDocument)
1011 ProjectNode n = GetNodeFromWindow(document, project);
1014 if(n && n.IsInNode(node) && !document.MenuFileSave(null, 0))
1016 ide.outputView.buildBox.Logf($"Unable to save %s file.\n", node.name);
1026 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1028 if(ProjectPrepareForToolchain(project, normal, true, true, compiler, config))
1031 ide.outputView.buildBox.Logf($"%s specific file(s) in project %s using the %s configuration...\n",
1032 mode == normal ? $"Compiling" : $"Debug compiling", project.name, config.name);
1034 ide.outputView.buildBox.Logf($"%s specific file(s) in project %s...\n",
1035 mode == normal ? $"Compiling" : $"Debug compiling", project.name);
1037 buildInProgress = compilingFile;
1038 ide.AdjustBuildMenus();
1039 project.Compile(nodes, compiler, config, justPrint, mode);
1040 buildInProgress = none;
1041 ide.AdjustBuildMenus();
1050 bool Clean(Project project, List<ProjectNode> nodes, bool justPrint)
1053 char fileName[MAX_LOCATION];
1055 ProjectConfig config = project.config;
1059 for(document = ide.firstChild; document; document = document.next)
1061 if(document.modifiedDocument)
1063 ProjectNode n = GetNodeFromWindow(document, project);
1066 if(n && n.IsInNode(node) && !document.MenuFileSave(null, 0))
1068 ide.outputView.buildBox.Logf($"Unable to save %s file.\n", node.name);
1078 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1080 if(ProjectPrepareForToolchain(project, normal, true, true, compiler, config))
1084 if(node.GetIsExcluded(config))
1085 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
1089 ide.outputView.buildBox.Logf($"Deleteing intermediate objects for %s %s in project %s using the %s configuration...\n",
1090 node.type == file ? $"single file" : $"folder", node.name, project.name, config.name);
1092 ide.outputView.buildBox.Logf($"Deleteing intermediate objects for %s %s in project %s...\n",
1093 node.type == file ? $"single file" : $"folder", node.name, project.name);
1095 node.DeleteIntermediateFiles(compiler, config);
1105 bool ProjectNewFile(MenuItem selection, Modifiers mods)
1107 DataRow row = fileList.currentRow;
1110 char fileName[1024];
1111 char filePath[MAX_LOCATION];
1112 ProjectNode parentNode = (ProjectNode)row.tag;
1113 ProjectNode n, fileNode;
1114 parentNode.GetFileSysMatchingPath(filePath);
1115 MakePathRelative(filePath, parentNode.project.topNode.path, filePath);
1116 for(n = parentNode; n && n != parentNode.project.resNode; n = n.parent);
1117 sprintf(fileName, $"Untitled %d", documentID);
1118 fileNode = AddFile(parentNode, fileName, (bool)n, true);
1119 fileNode.path = CopyUnixPath(filePath);
1122 NodeProperties nodeProperties
1125 position = { position.x + 100, position.y + 100 };
1129 nodeProperties.Create(); // not modal?
1135 bool ProjectNewFolder(MenuItem selection, Modifiers mods)
1137 DataRow row = fileList.currentRow;
1140 ProjectNode parentNode = (ProjectNode)row.tag;
1141 NewFolder(parentNode, null, true);
1146 bool ResourcesAddFiles(MenuItem selection, Modifiers mods)
1152 bool ProjectAddFiles(MenuItem selection, Modifiers mods)
1158 bool ProjectImportFolder(MenuItem selection, Modifiers mods)
1160 DataRow row = fileList.currentRow;
1163 ProjectNode toNode = (ProjectNode)row.tag;
1164 ImportFolder(toNode);
1169 bool ProjectAddNewForm(MenuItem selection, Modifiers mods)
1171 CodeEditor codeEditor = CreateNew("Form", "form", "Window", null);
1172 codeEditor.EnsureUpToDate();
1176 bool ProjectAddNewGraph(MenuItem selection, Modifiers mods)
1178 CodeEditor codeEditor = CreateNew("Graph", "graph", "Block", null);
1180 codeEditor.EnsureUpToDate();
1184 bool ProjectRemove(MenuItem selection, Modifiers mods)
1186 DataRow row = fileList.currentRow;
1189 ProjectNode node = (ProjectNode)row.tag;
1190 if(node.type == project)
1191 RemoveSelectedNodes();
1196 bool ProjectUpdateMakefileForAllConfigs(Project project)
1198 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1200 for(config : project.configurations)
1201 ProjectPrepareMakefile(project, forceExists, compiler, config);
1208 bool MenuConfig(MenuItem selection, Modifiers mods)
1210 if(ProjectActiveConfig { master = parent, project = project }.Modal() == ok)
1215 bool MenuCompiler(MenuItem selection, Modifiers mods)
1217 ActiveCompilerDialog compilerDialog
1220 ideSettings = ideSettings, workspaceActiveCompiler = ide.workspace.compiler;
1222 incref compilerDialog;
1223 if(compilerDialog.Modal() == ok && strcmp(compilerDialog.workspaceActiveCompiler, ide.workspace.compiler))
1225 CompilerConfig compiler = ideSettings.GetCompilerConfig(compilerDialog.workspaceActiveCompiler);
1226 ide.workspace.compiler = compilerDialog.workspaceActiveCompiler;
1227 ide.projectView.ShowOutputBuildLog(true);
1228 ide.projectView.DisplayCompiler(compiler, false);
1230 for(prj : ide.workspace.projects)
1231 ide.projectView.ProjectPrepareCompiler(prj, compiler);
1234 delete compilerDialog;
1238 bool MenuSettings(MenuItem selection, Modifiers mods)
1240 ProjectNode node = GetSelectedNode(true);
1241 Project prj = node ? node.project : project;
1242 projectSettingsDialog = ProjectSettings { master = parent, project = prj, projectNode = node };
1243 projectSettingsDialog.Modal();
1250 bool FileProperties(MenuItem selection, Modifiers mods)
1252 DataRow row = fileList.currentRow;
1255 ProjectNode node = (ProjectNode)row.tag;
1256 NodeProperties { parent = parent, master = this, node = node,
1257 position = { position.x + 100, position.y + 100 } }.Create();
1262 bool FileOpenFile(MenuItem selection, Modifiers mods)
1264 OpenSelectedNodes();
1268 bool FileRemoveFile(MenuItem selection, Modifiers mods)
1270 RemoveSelectedNodes();
1274 bool FileCompile(MenuItem selection, Modifiers mods)
1277 OldList selectedRows;
1278 Project project = null;
1279 List<ProjectNode> nodes { };
1280 fileList.GetMultiSelection(selectedRows);
1281 for(item = selectedRows.first; item; item = item.next)
1284 DataRow row = item.data;
1285 ProjectNode node = (ProjectNode)row.tag;
1287 project = node.project;
1288 else if(node.project != project)
1295 selectedRows.Free(null);
1297 Compile(project, nodes, mods.ctrl && mods.shift, normal);
1299 ide.outputView.buildBox.Logf($"Please select files from a single project.\n");
1304 bool FileClean(MenuItem selection, Modifiers mods)
1307 OldList selectedRows;
1308 Project project = null;
1309 List<ProjectNode> nodes { };
1310 fileList.GetMultiSelection(selectedRows);
1311 for(item = selectedRows.first; item; item = item.next)
1314 DataRow row = item.data;
1315 ProjectNode node = (ProjectNode)row.tag;
1317 project = node.project;
1318 else if(node.project != project)
1325 selectedRows.Free(null);
1327 Clean(project, nodes, mods.ctrl && mods.shift);
1329 ide.outputView.buildBox.Logf($"Please select files from a single project.\n");
1334 bool FileDebugPrecompile(MenuItem selection, Modifiers mods)
1336 DataRow row = fileList.currentRow;
1337 ProjectNode node = row ? (ProjectNode)row.tag : null;
1340 List<ProjectNode> nodes { };
1342 Compile(node.project, nodes, mods.ctrl && mods.shift, debugPrecompile);
1347 bool FileDebugCompile(MenuItem selection, Modifiers mods)
1349 DataRow row = fileList.currentRow;
1350 ProjectNode node = row ? (ProjectNode)row.tag : null;
1353 List<ProjectNode> nodes { };
1355 Compile(node.project, nodes, mods.ctrl && mods.shift, debugCompile);
1360 bool FileDebugGenerateSymbols(MenuItem selection, Modifiers mods)
1362 DataRow row = fileList.currentRow;
1363 ProjectNode node = row ? (ProjectNode)row.tag : null;
1366 List<ProjectNode> nodes { };
1368 Compile(node.project, nodes, mods.ctrl && mods.shift, debugGenerateSymbols);
1373 Project GetSelectedProject(bool useSelection)
1375 Project prj = project;
1378 DataRow row = fileList.currentRow;
1379 ProjectNode node = row ? (ProjectNode)row.tag : null;
1386 void SelectNextProject(bool backwards)
1388 DataRow row = fileList.currentRow;
1389 DataRow currentRow = row;
1390 ProjectNode node = (ProjectNode)row.tag;
1391 if(node.type != project)
1392 row = node.project.topNode.row;
1394 row = row.previous ? row.previous : fileList.lastRow;
1396 row = row.next ? row.next : fileList.firstRow;
1397 if(row && row != currentRow)
1399 fileList.SelectRow(row);
1400 fileList.currentRow = row;
1404 ProjectNode GetSelectedNode(bool useSelection)
1406 ProjectNode node = null;
1409 DataRow row = fileList.currentRow;
1411 node = (ProjectNode)row.tag;
1416 bool MenuBrowseFolder(MenuItem selection, Modifiers mods)
1418 char folder[MAX_LOCATION];
1420 ProjectNode node = GetSelectedNode(true);
1422 node = project.topNode;
1425 strcpy(folder, prj.topNode.path);
1426 if(node != prj.topNode)
1427 PathCatSlash(folder, node.path);
1432 bool Run(MenuItem selection, Modifiers mods)
1434 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1435 ProjectConfig config = project.config;
1436 String args = new char[maxPathLen];
1438 if(ide.workspace.commandLineArgs)
1439 //ide.debugger.GetCommandLineArgs(args);
1440 strcpy(args, ide.workspace.commandLineArgs);
1441 if(ide.debugger.isActive)
1442 project.Run(args, compiler, config);
1443 /*else if(config.targetType == sharedLibrary || config.targetType == staticLibrary)
1444 MessageBox { master = ide, type = ok, text = "Run", contents = "Shared and static libraries cannot be run like executables." }.Modal();*/
1445 else if(BuildInterrim(project, run, compiler, config, false))
1446 project.Run(args, compiler, config);
1454 bool result = false;
1455 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1456 ProjectConfig config = project.config;
1457 TargetTypes targetType = project.GetTargetType(config);
1458 if(targetType == sharedLibrary || targetType == staticLibrary)
1459 MessageBox { master = ide, type = ok, text = $"Run", contents = $"Shared and static libraries cannot be run like executables." }.Modal();
1460 else if(project.GetCompress(config))
1461 MessageBox { master = ide, text = $"Starting Debug", contents = $"Debugging compressed applications is not supported\n" }.Modal();
1462 else if(project.GetDebug(config) ||
1463 MessageBox { master = ide, type = okCancel, text = $"Starting Debug", contents = $"Attempting to debug non-debug configuration\nProceed anyways?" }.Modal() == ok)
1465 if(/*!IsProjectModified() ||*/ BuildInterrim(project, start, compiler, config, false))
1467 if(compiler.type.isVC)
1469 //bool result = false;
1470 char oldwd[MAX_LOCATION];
1471 PathBackup pathBackup { };
1472 char command[MAX_LOCATION];
1474 ide.SetPath(false, compiler, config);
1476 GetWorkingDir(oldwd, sizeof(oldwd));
1477 ChangeWorkingDir(project.topNode.path);
1479 sprintf(command, "%s /useenv %s.sln /projectconfig \"%s|Win32\" /command \"%s\"" , "devenv", project.name, config.name, "Debug.Start");
1481 ChangeWorkingDir(oldwd);
1487 ide.debugger.Start(compiler, config);
1496 void GoToError(const char * line)
1500 while(isspace(*line)) line++;
1501 colon = strstr(line, ":");
1506 bool lookForLineNumber = true;
1508 // deal with linking error
1509 if(colon && colon[1] == ' ')
1511 colon = strstr(colon + 1, ":");
1512 if(colon && !colon[1])
1514 colon = strstr(line, ":");
1515 lookForLineNumber = false;
1517 else if(colon && !isdigit(colon[1]))
1520 colon = strstr(line, ":");
1523 // Don't be mistaken by the drive letter colon
1524 if(colon && (colon[1] == '/' || colon[1] == '\\'))
1525 colon = strstr(colon + 1, ":");
1526 if(colon && lookForLineNumber)
1530 char * par = RSearchString(line, "(", colon - line, true, false);
1531 if(par && strstr(par, ")"))
1533 else if((colon+1)[0] == ' ')
1535 // NOTE: This is the same thing as saying 'colon = line'
1536 for( ; colon != line; colon--)
1540 lineNumber = atoi(colon + 1);
1542 comma = strchr(colon, ',');
1544 col = atoi(comma+1);
1546 comma = strchr(colon+1, ':');
1548 col = atoi(comma+1);
1552 char moduleName[MAX_LOCATION], filePath[MAX_LOCATION];
1556 char * inFileIncludedFrom = strstr(line, stringInFileIncludedFrom);
1557 char * start = inFileIncludedFrom ? line + strlen(stringInFileIncludedFrom) : line;
1558 int len = (int)(colon - start);
1559 len = Min(len, MAX_LOCATION-1);
1561 strncpy(moduleName, start, len);
1562 moduleName[len] = '\0';
1565 strcpy(moduleName, line);
1567 // Remove stuff in brackets
1569 bracket = strstr(moduleName, "(");
1570 if(bracket) *bracket = '\0';
1572 MakeSlashPath(moduleName);
1576 // Check if it's one of our modules
1577 ProjectNode node = project.topNode.Find(moduleName, false);
1580 strcpy(moduleName, node.path);
1581 PathCatSlash(moduleName, node.name);
1584 moduleName[0] = '\0';
1588 CodeEditor codeEditor;
1589 strcpy(filePath, project.topNode.path);
1590 PathCatSlash(filePath, moduleName);
1592 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
1595 char name[MAX_LOCATION];
1596 // TOFIX: Improve on this, don't use only filename, make a function
1597 if(ide && ide.workspace)
1599 for(prj : ide.workspace.projects)
1601 if(prj.topNode.FindWithPath(moduleName, false))
1603 strcpy(filePath, prj.topNode.path);
1604 PathCatSlash(filePath, moduleName);
1605 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, true, null, no, normal);
1612 if(codeEditor && lineNumber)
1614 EditBox editBox = codeEditor.editBox;
1615 editBox.GoToLineNum(lineNumber - 1);
1616 editBox.GoToPosition(editBox.line, lineNumber - 1, col ? (col - 1) : 0);
1623 bool OpenNode(ProjectNode node)
1625 char filePath[MAX_LOCATION];
1626 node.GetFullFilePath(filePath);
1627 return ide.OpenFile(filePath, normal, true/*false Why was it opening hidden?*/, null, something, normal) ? true : false;
1630 void AddNode(ProjectNode node, DataRow addTo)
1632 DataRow row = addTo ? addTo.AddRow() : fileList.AddRow();
1634 row.tag = (int)node;
1637 if(node.type == resources)
1640 row.SetData(null, node);
1642 if(node.files && node.files.first && node.parent &&
1643 !(!node.parent.parent &&
1644 (!strcmpi(node.name, "notes") || !strcmpi(node.name, "sources") ||
1645 !strcmpi(node.name, "src") || !strcmpi(node.name, "tools"))))
1646 row.collapsed = true;
1647 else if(node.type == folder)
1648 node.icon = openFolder;
1652 for(child : node.files)
1653 AddNode(child, row);
1657 void DeleteNode(ProjectNode projectNode)
1659 if(projectNode.files)
1662 while(child = projectNode.files.first)
1665 fileList.DeleteRow(projectNode.row);
1666 projectNode.Delete();
1669 bool ProjectSave(MenuItem selection, Modifiers mods)
1671 DataRow row = fileList.currentRow;
1672 ProjectNode node = row ? (ProjectNode)row.tag : null;
1673 Project prj = node ? node.project : null;
1676 prj.StopMonitoring();
1677 if(prj.Save(prj.filePath))
1679 Project modPrj = null;
1680 prj.topNode.modified = false;
1681 for(p : ide.workspace.projects)
1683 if(p.topNode.modified)
1690 modifiedDocument = false;
1693 prj.StartMonitoring();
1698 bool ShowOutputBuildLog(bool cleanLog)
1700 OutputView output = ide.outputView;
1702 output.ShowClearSelectTab(build);
1705 output.SelectTab(build);
1713 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1714 ProjectConfig config = project.config;
1716 bool result = false;
1717 if(/*!IsProjectModified() ||*/ BuildInterrim(project, restart, compiler, config, false))
1719 // For Restart, compiler and config will only be used if for
1720 // whatever reason (if at all possible) the Debugger is in a
1721 // 'terminated' or 'none' state
1722 ide.debugger.Restart(compiler, config);
1732 ide.debugger.Resume();
1738 ide.debugger.Break();
1744 ide.debugger.Stop();
1748 bool DebugStepInto()
1750 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1751 ProjectConfig config = project.config;
1753 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config, false)))
1754 ide.debugger.StepInto(compiler, config);
1759 bool DebugStepOver(bool skip)
1761 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1762 ProjectConfig config = project.config;
1764 if((ide.debugger.isActive) || (!buildInProgress && BuildInterrim(project, start, compiler, config, false)))
1765 ide.debugger.StepOver(compiler, config, skip);
1771 bool DebugStepOut(bool skip)
1773 ide.debugger.StepOut(skip);
1777 void ImportFolder(ProjectNode toNode)
1781 //bool isFolder = toNode.type == folder;
1782 //bool isRes = toNode.isInResources;
1784 FileDialog fileDialog = importFileDialog;
1785 fileDialog.master = parent;
1786 if(fileDialog.Modal() == ok)
1788 ImportFolderFSI fsi { projectView = this };
1789 fsi.stack.Add(toNode);
1790 fsi.Iterate(fileDialog.filePath);
1796 ProjectNode NewFolder(ProjectNode parentNode, char * name, bool showProperties)
1800 ProjectNode folderNode;
1801 Project prj = parentNode.project;
1803 ProjectNode after = null;
1804 for(node : parentNode.files)
1806 if(node.type != folder)
1812 folderNode = parentNode.Add(prj, name, after, folder, folder, true);
1815 for(c = 0; c < 100; c++)
1818 sprintf(string, c ? "New Folder (%d)" : "New Folder", c);
1819 if((folderNode = parentNode.Add(prj, string, after, folder, folder, true)))
1826 NodeProperties nodeProperties;
1829 modifiedDocument = true;
1830 prj.topNode.modified = true;
1833 folderNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
1834 folderNode.row.tag = (int)folderNode;
1836 folderNode.row.SetData(null, folderNode);
1837 fileList.currentRow = folderNode.row;
1841 nodeProperties = NodeProperties
1843 parent, this, mode = newFolder, node = folderNode;
1844 position = { position.x + 100, position.y + 100 };
1846 nodeProperties.Create(); // Modal?
1854 void AddFiles(bool resources)
1856 FileDialog fileDialog = (!resources) ? this.fileDialog : resourceFileDialog;
1857 fileDialog.type = multiOpen;
1858 fileDialog.text = !resources ? $"Add Files to Project" : $"Add Resources to Project";
1859 fileDialog.master = parent;
1861 if(fileDialog.Modal() == ok)
1864 DataRow row = fileList.currentRow;
1865 ProjectNode parentNode = (ProjectNode)row.tag;
1866 bool addFailed = false;
1867 int numSelections = fileDialog.numSelections;
1868 char ** multiFilePaths = fileDialog.multiFilePaths;
1870 Array<String> nameConflictFiles { };
1872 for(c = 0; c < numSelections; c++)
1874 char * filePath = multiFilePaths[c];
1875 FileAttribs exists = FileExists(filePath);
1876 bool addThisFile = true;
1878 if(exists.isDirectory)
1879 addThisFile = false;
1882 if(MessageBox { master = ide, type = yesNo, text = filePath,
1883 contents = $"File doesn't exist. Create?" }.Modal() == yes)
1885 File f = FileOpen(filePath, write);
1893 MessageBox { master = ide, type = ok, text = filePath,
1894 contents = $"Couldn't create file."}.Modal();
1895 addThisFile = false;
1902 /*addFailed = */if(!AddFile(parentNode, filePath, resources, false))//;
1904 nameConflictFiles.Add(CopyString(filePath));
1912 char * part1 = $"The following file";
1913 char * opt1 = $" was ";
1914 char * opt2 = $"s were ";
1915 char * part2 = $"not added because of identical file name conflict within the project.\n\n";
1917 len += strlen(part1);
1918 len += strlen(part2);
1919 len += nameConflictFiles.count > 1 ? strlen(opt2) : strlen(opt1);
1920 for(s : nameConflictFiles)
1921 len += strlen(s) + 1;
1922 message = new char[len + 1];
1923 strcpy(message, part1);
1924 strcat(message, nameConflictFiles.count > 1 ? opt2 : opt1);
1925 strcat(message, part2);
1926 for(s : nameConflictFiles)
1929 strcat(message, "\n");
1931 MessageBox { master = ide, type = ok, text = $"Name Conflict",
1932 contents = message }.Modal();
1935 nameConflictFiles.Free();
1936 delete nameConflictFiles;
1940 ProjectNode AddFile(ProjectNode parentNode, char * filePath, bool resources, bool isTemporary)
1942 ProjectNode result = null;
1943 ProjectNode after = null;
1944 for(node : parentNode.files)
1946 if(node.type != folder && node.type != file && node.type)
1951 result = parentNode.Add(parentNode.project, filePath, after, file, NodeIcons::SelectFileIcon(filePath), !resources);
1957 modifiedDocument = true;
1958 parentNode.project.topNode.modified = true;
1959 parentNode.project.ModifiedAllConfigs(true, false, true, true);
1962 result.row = parentNode.row.AddRowAfter(after ? after.row : null);
1963 result.row.tag = (int)result;
1964 result.row.SetData(null, result);
1969 CodeEditor CreateNew(char * upper, char * lower, char * base, char * className)
1971 CodeEditor codeEditor = null;
1972 ProjectNode projectNode;
1973 ProjectNode after = null;
1974 DataRow row = fileList.currentRow;
1975 ProjectNode parentNode;
1978 if(!row) row = project.topNode.row;
1980 parentNode = (ProjectNode)row.tag;
1982 for(node : parentNode.files)
1984 if(node.type != folder && node.type != file && node.type)
1988 for(c = 1; c < 100; c++)
1991 sprintf(string, c ? "%s%d.ec" : "%s.ec", lower, c);
1992 if((projectNode = parentNode.Add(project, string, after, file, genFile, true)))
1998 char filePath[MAX_LOCATION];
2000 modifiedDocument = true;
2001 project.topNode.modified = true;
2003 project.ModifiedAllConfigs(true, false, false, true);
2004 projectNode.row = parentNode.row.AddRowAfter(after ? after.row : null);
2005 projectNode.row.tag =(int)projectNode;
2007 projectNode.row.SetData(null, projectNode);
2008 fileList.currentRow = projectNode.row;
2010 strcpy(filePath, project.topNode.path);
2011 PathCat(filePath, projectNode.path);
2012 PathCat(filePath, projectNode.name);
2014 codeEditor = (CodeEditor)ide.FindWindow(filePath);
2017 Class baseClass = eSystem_FindClass(__thisModule, base);
2018 subclass(ClassDesignerBase) designerClass = eClass_GetDesigner(baseClass);
2021 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal);
2022 strcpy(name, projectNode.name);
2023 sprintf(name, "%s%d", upper, c);
2025 strcpy(className, name);
2027 designerClass.CreateNew(codeEditor.editBox, codeEditor.clientSize, name, base);
2029 //codeEditor.modifiedDocument = false;
2030 //codeEditor.designer.modifiedDocument = false;
2032 //Code_EnsureUpToDate(codeEditor);
2035 else // TODO: fix no symbols generated when ommiting {} for following else
2037 codeEditor = (CodeEditor)ide.OpenFile(filePath, normal, false, null, whatever, normal);
2041 codeEditor.ViewDesigner();
2042 codeEditor.codeModified = true;
2049 // Returns true if we opened something
2050 bool OpenSelectedNodes()
2052 bool result = false;
2056 fileList.GetMultiSelection(selection);
2057 for(item = selection.first; item; item = item.next)
2059 DataRow row = item.data;
2060 ProjectNode node = (ProjectNode)row.tag;
2061 if(node.type == file)
2068 selection.Free(null);
2072 void RemoveSelectedNodes()
2077 fileList.GetMultiSelection(selection);
2079 // Remove children of parents we're deleting
2080 for(item = selection.first; item; item = next)
2083 DataRow row = item.data;
2084 ProjectNode n, node = (ProjectNode)row.tag;
2085 bool remove = false;
2088 for(i = selection.first; i && !remove; i = i.next)
2090 ProjectNode iNode = (ProjectNode)((DataRow)i.data).tag;
2091 for(n = node.parent; n; n = n.parent)
2101 selection.Delete(item);
2104 for(item = selection.first; item; item = item.next)
2106 DataRow row = item.data;
2107 ProjectNode node = (ProjectNode)row.tag;
2108 ProjectNode resNode;
2109 for(resNode = node.parent; resNode; resNode = resNode.parent)
2110 if(resNode.type == resources)
2112 if(node.type == file)
2114 Project prj = node.project;
2116 modifiedDocument = true;
2117 prj.topNode.modified = true;
2119 prj.ModifiedAllConfigs(true, false, true, true);
2121 else if(node.type == folder)
2124 sprintf(message, $"Are you sure you want to remove the folder \"%s\"\n"
2125 "and all of its contents from the project?", node.name);
2126 if(MessageBox { master = ide, type = yesNo, text = $"Delete Folder", contents = message }.Modal() == yes)
2128 Project prj = node.project;
2129 if(node.containsFile)
2130 prj.ModifiedAllConfigs(true, false, true, true);
2132 modifiedDocument = true;
2133 prj.topNode.modified = true;
2136 else if(node.type == project && node != project.topNode && !buildInProgress)
2140 for(p : workspace.projects)
2142 if(p.topNode == node)
2148 sprintf(message, $"Are you sure you want to remove the \"%s\" project\n" "from this workspace?", node.name);
2149 if(MessageBox { master = ide, type = yesNo, text = $"Remove Project", contents = message }.Modal() == yes)
2154 workspace.RemoveProject(prj);
2155 //modifiedDocument = true; // when project view is a workspace view
2159 selection.Free(null);