2 public import static "ecere"
3 public import static "ec"
9 import "GlobalSettingsDialog"
10 import "NewProjectDialog"
11 import "FindInFilesDialog"
18 import "ProjectConfig"
20 import "NodeProperties"
21 import "ProjectSettings"
33 import "BreakpointsView"
34 import "CallStackView"
45 import "FileSystemIterator"
47 #if defined(__WIN32__)
48 define pathListSep = ";";
50 define pathListSep = ":";
53 define maxPathLen = 65 * MAX_LOCATION;
55 class PathBackup : struct
62 oldPath = new char[maxPathLen];
63 oldLDPath = new char[maxPathLen];
65 GetEnvironment("PATH", oldPath, maxPathLen);
66 #if defined(__APPLE__)
67 GetEnvironment("DYLD_LIBRARY_PATH", oldLDPath, maxPathLen);
69 GetEnvironment("LD_LIBRARY_PATH", oldLDPath, maxPathLen);
75 SetEnvironment("PATH", oldPath);
76 #if defined(__APPLE__)
77 SetEnvironment("DYLD_LIBRARY_PATH", oldLDPath);
79 SetEnvironment("LD_LIBRARY_PATH", oldLDPath);
86 enum OpenCreateIfFails { no, yes, something, whatever };
87 enum OpenMethod { normal, add };
89 static Array<FileFilter> fileFilters
91 { $"C/C++/eC Files (*.ec, *.eh, *.c, *.cpp, *.cc, *.cxx, *.h, *.hpp, *.hh, *.hxx)", "ec, eh, c, cpp, cc, cxx, h, hpp, hh, hxx" },
92 { $"Header Files for eC/C/C++ (*.eh, *.h, *.hpp, *.hh, *.hxx)", "eh, h, hpp, hh, hxx" },
93 { $"C/C++/eC Source Files (*.ec, *.c, *.cpp, *.cc, *.cxx)", "ec, c, cpp, cc, cxx" },
94 { $"Text files (*.txt, *.text, *.nfo, *.info)", "txt, text, nfo, info" },
95 { $"Web files (*.html, *.htm, *.xhtml, *.css, *.php, *.js, *.jsi, *.rb, *.xml)", "html, htm, xhtml, css, php, js, jsi, rb, xml" },
96 { $"Image Files (*.jpg, *.jpeg, *.bmp, *.pcx, *.png, *.gif)", "jpg, jpeg, bmp, pcx, png, gif" },
97 { $"3D Studio Model Files (*.3ds)", "3ds" },
98 { $"All files", null }
101 static Array<FileType> fileTypes
103 { $"Based on extension", null },
106 { $"3D Studio Model", "3ds" }
109 static Array<FileFilter> projectFilters
111 { $"Project Files (*.epj)", ProjectExtension }
114 static Array<FileType> projectTypes
116 { $"Project File", ProjectExtension }
119 static Array<FileFilter> findInFilesFileFilters
121 { $"eC Files (*.ec, *.eh)", "ec, eh" },
122 { $"C/C++/eC Files (*.ec, *.eh, *.c, *.cpp, *.cc, *.cxx, *.h, *.hpp, *.hh, *.hxx)", "ec, eh, c, cpp, cc, cxx, h, hpp, hh, hxx" },
123 { $"Header Files for eC/C/C++ (*.eh, *.h, *.hpp, *.hh, *.hxx)", "eh, h, hpp, hh, hxx" },
124 { $"C/C++/eC Source Files (*.ec, *.c, *.cpp, *.cc, *.cxx)", "ec, c, cpp, cc, cxx" },
125 { $"Text files (*.txt)", "txt" },
126 { $"All files", null }
129 FileDialog ideFileDialog
131 type = multiOpen, text = $"Open";
132 types = fileTypes.array, sizeTypes = fileTypes.count * sizeof(FileType), filters = fileFilters.array, sizeFilters = fileFilters.count * sizeof(FileFilter);
135 define openProjectFileDialogTitle = $"Open Project";
136 define addProjectFileDialogTitle = $"Open Additional Project";
137 FileDialog ideProjectFileDialog
140 types = projectTypes.array, sizeTypes = projectTypes.count * sizeof(FileType), filters = projectFilters.array, sizeFilters = projectFilters.count * sizeof(FileFilter);
143 GlobalSettingsDialog globalSettingsDialog
145 ideSettings = ideSettings;
146 settingsContainer = settingsContainer;
148 void OnGlobalSettingChange(GlobalSettingsChange globalSettingsChange)
150 switch(globalSettingsChange)
155 for(child = ide.firstChild; child; child = child.next)
157 if(child._class == class(CodeEditor))
159 CodeEditor codeEditor = (CodeEditor) child;
160 codeEditor.editBox.freeCaret = ideSettings.useFreeCaret;
161 // codeEditor.editBox.lineNumbers = ideSettings.showLineNumbers;
162 codeEditor.editBox.caretFollowsScrolling = ideSettings.caretFollowsScrolling;
163 codeEditor.OnPostCreate(); // Update editBox margin size
170 case compilerSettings:
172 ide.UpdateCompilerConfigs();
179 void DrawLineMarginIcon(Surface surface, BitmapResource resource, int line, int lineH, int scrollY, int boxH)
184 lineY = (line - 1) * lineH;
185 if(lineY + lineH > scrollY && lineY + lineH < scrollY + boxH)
187 Bitmap bitmap = resource.bitmap;
189 surface.Blit(bitmap, 0, lineY - scrollY + (lineH - bitmap.height) / 2 + 1, 0, 0, bitmap.width, bitmap.height);
194 #define IDEItem(x) (&((IDEWorkSpace)0).x)
196 class IDEToolbar : ToolBar
200 ToolButton buttonNewFile { this, toolTip = $"New file", menuItemPtr = IDEItem(fileNewItem) };
202 ToolButton buttonOpenFile { this, toolTip = $"Open file", menuItemPtr = IDEItem(fileOpenItem) };
204 // ToolButton buttonCloseFile { this, toolTip = $"Close file", menuItemPtr = IDEItem(fileCloseItem) };
206 ToolButton buttonSaveFile { this, toolTip = $"Save file", menuItemPtr = IDEItem(fileSaveItem) };
208 ToolButton buttonSaveAllFile { this, toolTip = $"Save all", menuItemPtr = IDEItem(fileSaveAllItem) };
210 ToolSeparator separator1 { this };
219 // ToolSeparator separator2 { this };
221 /* Project options */
223 ToolButton buttonNewProject { this, toolTip = $"New project", menuItemPtr = IDEItem(projectNewItem) };
225 ToolButton buttonOpenProject { this, toolTip = $"Open project", menuItemPtr = IDEItem(projectOpenItem) };
226 // Add project to workspace
227 ToolButton buttonAddProject { this, toolTip = $"Add project to workspace", menuItemPtr = IDEItem(projectAddItem), disabled = true; };
229 // ToolButton buttonCloseProject { this, toolTip = $"Close project", menuItemPtr = IDEItem(projectCloseItem), disabled = true; };
231 ToolSeparator separator3 { this };
233 /* Build/Execution options */
235 ToolButton buttonBuild { this, toolTip = $"Build project", menuItemPtr = IDEItem(projectBuildItem), disabled = true; };
237 ToolButton buttonReLink { this, toolTip = $"Relink project", menuItemPtr = IDEItem(projectLinkItem), disabled = true; };
239 ToolButton buttonRebuild { this, toolTip = $"Rebuild project", menuItemPtr = IDEItem(projectRebuildItem), disabled = true; };
241 ToolButton buttonClean { this, toolTip = $"Clean project", menuItemPtr = IDEItem(projectCleanItem), disabled = true; };
243 // ToolButton buttonRealClean { this, toolTip = $"Real clean project", menuItemPtr = IDEItem(projectRealCleanItem), disabled = true; };
244 // Regenerate Makefile
245 ToolButton buttonRegenerateMakefile { this, toolTip = $"Regenerate Makefile", menuItemPtr = IDEItem(projectRegenerateItem), disabled = true; };
246 // Compile actual file
248 ToolButton buttonRun { this, toolTip = $"Run", menuItemPtr = IDEItem(projectRunItem), disabled = true; };
250 ToolSeparator separator4 { this };
254 ToolButton buttonDebugStartResume { this, toolTip = $"Start", menuItemPtr = IDEItem(debugStartResumeItem), disabled = true; };
256 ToolButton buttonDebugRestart { this, toolTip = $"Restart", menuItemPtr = IDEItem(debugRestartItem), disabled = true; };
258 ToolButton buttonDebugPause { this, toolTip = $"Break", menuItemPtr = IDEItem(debugBreakItem), disabled = true; };
260 ToolButton buttonDebugStop { this, toolTip = $"Stop", menuItemPtr = IDEItem(debugStopItem), disabled = true; };
262 //ToolButton buttonRun { this, toolTip = $"Run", menuItemPtr = IDEItem(projectRunItem) };
264 ToolButton buttonDebugStepInto { this, toolTip = $"Step Into", menuItemPtr = IDEItem(debugStepIntoItem), disabled = true; };
266 ToolButton buttonDebugStepOver { this, toolTip = $"Step Over", menuItemPtr = IDEItem(debugStepOverItem), disabled = true; };
268 ToolButton buttonDebugStepOut { this, toolTip = $"Step Out", menuItemPtr = IDEItem(debugStepOutItem), disabled = true; };
270 ToolButton buttonDebugSkipStepOver { this, toolTip = $"Step Over Skipping Breakpoints", menuItemPtr = IDEItem(debugSkipStepOverItem), disabled = true; };
272 ToolSeparator separator5 { this };
274 Window spacer5 { this, size = { 4 } };
278 this, toolTip = $"Active Configuration(s)", size = { 160 };
279 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
283 for(prj : ide.workspace.projects)
285 for(cfg : prj.configurations)
287 if(cfg.name && !strcmp(cfg.name, row.string))
294 ide.UpdateToolBarActiveConfigs(true);
295 ide.projectView.Update(null);
301 Window spacer6 { this, size = { 4 } };
303 DropBox activeCompiler
305 this, toolTip = $"Active Compiler", size = { 160 };
306 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
308 if(row && strcmp(row.string, ide.workspace.compiler))
310 CompilerConfig compiler = ideSettings.GetCompilerConfig(row.string);
311 ide.workspace.compiler = row.string;
312 ide.projectView.ShowOutputBuildLog(true);
313 ide.projectView.DisplayCompiler(compiler, false);
314 for(prj : ide.workspace.projects)
315 ide.projectView.ProjectPrepareCompiler(prj, compiler);
317 ide.workspace.Save();
323 Window spacer7 { this, size = { 4 } };
327 class IDEMainFrame : Window
329 background = formColor;
330 borderStyle = sizable;
334 minClientSize = { 600, 300 };
336 icon = { ":icon.png" };
337 text = titleECEREIDE;
341 anchor = { top = 0, right = 0, bottom = 0 };
344 anchor = { left = 0, top = 0, right = 0, bottom = 0 };
351 isActiveClient = true;
353 direction = vertical;
354 background = formColor;
355 anchor = { left = 0, top = 0, right = 0, bottom = 0 };
363 ((IDEWorkSpace)master).toolBar = null;
366 IDEWorkSpace ideWorkSpace { stack, this, toolBar = toolBar };
369 define ide = ideMainFrame.ideWorkSpace;
371 class IDEWorkSpace : Window
373 background = Color { 85, 85, 85 };
376 hasVertScroll = true;
377 hasHorzScroll = true;
379 isActiveClient = true;
380 anchor = { left = 0, top = 0, right = 0, bottom = 0 };
384 MenuItem * driverItems, * skinItems;
385 StatusField pos { width = 150 };
386 StatusField ovr, caps, num;
388 BitmapResource back { ":ecereBack.jpg", window = this };
389 BitmapResource bmpBp { ":codeMarks/breakpoint.png", window = this };
390 BitmapResource bmpBpDisabled { ":codeMarks/breakpointDisabled.png", window = this };
391 BitmapResource bmpBpHalf { ":codeMarks/breakpointHalf.png", window = this };
392 BitmapResource bmpBpHalfDisabled { ":codeMarks/breakpointHalfDisabled.png", window = this };
393 BitmapResource bmpCursor { ":codeMarks/cursor.png", window = this };
394 BitmapResource bmpCursorError { ":codeMarks/cursorError.png", window = this };
395 BitmapResource bmpTopFrame { ":codeMarks/topFrame.png", window = this };
396 BitmapResource bmpTopFrameError { ":codeMarks/topFrameError.png", window = this };
397 BitmapResource bmpTopFrameHalf { ":codeMarks/topFrameHalf.png", window = this };
398 BitmapResource bmpTopFrameHalfError { ":codeMarks/topFrameHalfError.png", window = this };
400 Debugger debugger { };
402 ProjectView projectView;
404 OutputView outputView
408 void OnGotoError(char * line)
413 void OnCodeLocationParseAndGoTo(char * line)
415 ide.CodeLocationParseAndGoTo(line, ide.findInFilesDialog.findProject, ide.findInFilesDialog.findDir);
418 bool OnKeyDown(Key key, unichar ch)
423 if(!ide.findInFilesDialog || !ide.findInFilesDialog.SearchAbort())
424 ide.ShowCodeEditor();
427 ide.projectView.stopBuild = true;
431 OutputView::OnKeyDown(key, ch);
438 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
441 ide.RepositionWindows(false);
445 bool OnClose(bool parentClosing)
449 ide.RepositionWindows(false);
450 return parentClosing;
454 CallStackView callStackView
456 parent = this, font = { panelFont.faceName, panelFont.size };
458 void OnGotoLine(char * line)
461 stackLvl = atoi(line);
462 ide.debugger.GoToStackFrameLine(stackLvl, true);
465 void OnSelectFrame(int lineNumber)
467 ide.debugger.SelectFrame(lineNumber);
470 void OnToggleBreakpoint()
472 Debugger debugger = ide.debugger;
473 if(debugger.activeFrame && debugger.activeFrame.absoluteFile)
475 int line = debugger.activeFrame.line;
476 char name[MAX_LOCATION];
478 // TOFIX: Improve on this, don't use only filename, make a function
479 GetLastDirectory(debugger.activeFrame.absoluteFile, name);
480 if(ide && ide.workspace)
482 for(p : ide.workspace.projects)
484 if(p.topNode.Find(name, false))
492 for(p : ide.workspace.projects)
494 if(IsPathInsideOf(debugger.activeFrame.absoluteFile, p.topNode.path))
502 debugger.ToggleBreakpoint(debugger.activeFrame.absoluteFile, line, prj);
505 CodeEditor codeEditor = (CodeEditor)ide.FindWindow(debugger.activeFrame.absoluteFile);
506 if(codeEditor) { codeEditor.Update(null); Activate(); }
511 bool OnKeyDown(Key key, unichar ch)
515 case escape: ide.ShowCodeEditor(); break;
520 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
523 ide.RepositionWindows(false);
527 bool OnClose(bool parentClosing)
531 ide.RepositionWindows(false);
532 return parentClosing;
535 void OnRedraw(Surface surface)
538 int lineCursor, lineTopFrame, activeThread, hitThread;
539 int lineH, scrollY, boxH;
541 Breakpoint bp = null;
542 Debugger debugger = ide.debugger;
543 Frame activeFrame = debugger.activeFrame;
546 scrollY = editBox.scroll.y;
547 displaySystem.FontExtent(editBox.font.font, " ", 1, null, &lineH);
549 activeThread = debugger.activeThread;
550 hitThread = debugger.hitThread;
551 debugger.GetCallStackCursorLine(&error, &lineCursor, &lineTopFrame);
553 if(activeFrame && activeFrame.absoluteFile)
555 for(i : ide.workspace.breakpoints; i.type == user)
557 if(i.absoluteFilePath && i.absoluteFilePath[0] &&
558 !fstrcmp(i.absoluteFilePath, activeFrame.absoluteFile) &&
559 activeFrame.line == i.line)
568 DrawLineMarginIcon(surface,
569 /*(lineCursor == 1 || lineTopFrame == 1) ? */ide.bmpBpHalf/* : ide.bmpBp*/,
570 lineCursor /*1*/, lineH, scrollY, boxH);
573 if(activeThread && activeThread == hitThread && debugger.bpHit && debugger.bpHit.type == user)
574 DrawLineMarginIcon(surface,
575 (lineCursor == 1 || lineTopFrame == 1) ? ide.bmpBpHalf : ide.bmpBp,
576 1, lineH, scrollY, boxH);
578 DrawLineMarginIcon(surface, error ? ide.bmpCursorError : ide.bmpCursor, lineCursor, lineH, scrollY, boxH);
579 if(bp && lineCursor == 1) //activeThread && activeThread == hitThread && debugger.bpHit && debugger.bpHit.type == user)
580 bmp = error ? ide.bmpTopFrameHalfError : ide.bmpTopFrameHalf;
582 bmp = error ? ide.bmpTopFrameError : ide.bmpTopFrame;
583 DrawLineMarginIcon(surface, bmp, lineTopFrame, lineH, scrollY, boxH);
584 if(editBox.horzScroll && editBox.horzScroll.visible)
586 surface.SetBackground(control);
587 surface.Area(0, editBox.clientSize.h, 20 - 1, clientSize.h - 1);
592 WatchesView watchesView { parent = this };
593 ThreadsView threadsView
595 parent = this, font = { panelFont.faceName, panelFont.size };
597 bool OnKeyDown(Key key, unichar ch)
601 case escape: ide.ShowCodeEditor(); break;
606 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
609 ide.RepositionWindows(false);
613 bool OnClose(bool parentClosing)
617 ide.RepositionWindows(false);
618 return parentClosing;
621 void OnSelectThread(int threadId)
624 ide.debugger.SelectThread(threadId);
627 bool OnGetThreadsInfo(int * activeThread, int * hitThread, int * signalThread)
630 Debugger debugger = ide.debugger;
631 *activeThread = debugger.activeThread;
632 *hitThread = debugger.hitThread;
633 *signalThread = debugger.signalThread;
638 BreakpointsView breakpointsView { parent = this };
640 ToolBox toolBox { parent = this };
641 Sheet sheet { parent = this };
644 property char * tmpPrjDir { set { delete tmpPrjDir; if(value) tmpPrjDir = CopyString(value); } get { return tmpPrjDir; } };
646 Menu fileMenu { menu, $"File", f, hasMargin = true };
649 fileMenu, $"New", n, ctrlN;
650 bitmap = { ":actions/docNew.png" };
651 bool NotifySelect(MenuItem selection, Modifiers mods)
653 Window document = (Window)NewCodeEditor(this, normal, false);
654 document.NotifySaved = DocumentSaved;
658 MenuItem fileOpenItem
660 fileMenu, $"Open...", o, ctrlO;
661 bitmap = { ":actions/docOpen.png" };
662 bool NotifySelect(MenuItem selection, Modifiers mods)
664 if(!projectView && ideSettings.ideFileDialogLocation)
665 ideFileDialog.currentDirectory = ideSettings.ideFileDialogLocation;
668 if(ideFileDialog.Modal() == ok)
670 bool gotWhatWeWant = false;
672 int numSelections = ideFileDialog.numSelections;
673 char ** multiFilePaths = ideFileDialog.multiFilePaths;
675 for(c = 0; c < numSelections; c++)
677 if(OpenFile(multiFilePaths[c], normal, true, fileTypes[ideFileDialog.fileType].typeExtension, no, normal))
678 gotWhatWeWant = true;
681 MessageBox { type = yesNo, master = this, text = $"Error opening file",
682 contents = $"Open a different file?" }.Modal() == no)
684 if(!projectView && gotWhatWeWant)
685 ChangeFileDialogsDirectory(ideFileDialog.currentDirectory, true);
695 MenuItem fileCloseItem { fileMenu, $"Close", c, ctrlF4, NotifySelect = MenuFileClose };
696 MenuDivider { fileMenu };
697 MenuItem fileSaveItem
699 fileMenu, $"Save", s, ctrlS, bitmap = { ":actions/docSave.png" };
701 // For the toolbar button; clients can still override that for the menu item
702 bool Window::NotifySelect(MenuItem selection, Modifiers mods)
704 Window w = activeClient;
706 w.MenuFileSave(null, 0);
710 MenuItem fileSaveAsItem { fileMenu, $"Save As...", a };
711 MenuItem fileSaveAllItem { fileMenu, $"Save All", l, NotifySelect = MenuFileSaveAll, bitmap = { ":actions/docSaveAll.png" } };
712 MenuDivider { fileMenu };
715 fileMenu, $"Find In Files...", f, Key { f, ctrl = true , shift = true };
716 bool NotifySelect(MenuItem selection, Modifiers mods)
718 findInFilesDialog.replaceMode = false;
719 findInFilesDialog.Show();
723 MenuItem replaceInFiles
725 fileMenu, $"Replace In Files...", e, Key { r, ctrl = true , shift = true };
726 bool NotifySelect(MenuItem selection, Modifiers mods)
728 findInFilesDialog.replaceMode = true;
729 findInFilesDialog.Show();
733 MenuDivider { fileMenu };
734 MenuItem globalSettingsItem
736 fileMenu, $"Global Settings...", g;
737 bool NotifySelect(MenuItem selection, Modifiers mods)
739 globalSettingsDialog.master = this;
740 if(ide.workspace && ide.workspace.compiler)
741 globalSettingsDialog.workspaceActiveCompiler = ide.workspace.compiler;
742 else if(ideSettings.defaultCompiler)
743 globalSettingsDialog.workspaceActiveCompiler = ideSettings.defaultCompiler;
744 globalSettingsDialog.Modal();
748 MenuDivider { fileMenu };
749 Menu recentFiles { fileMenu, $"Recent Files", r };
750 Menu recentProjects { fileMenu, $"Recent Projects", p };
751 MenuDivider { fileMenu };
754 fileMenu, $"Exit", x, altF4, NotifySelect = MenuFileExit;
756 bool NotifySelect(MenuItem selection, Modifiers mods)
758 ideMainFrame.Destroy(0);
763 bool FileRecentFile(MenuItem selection, Modifiers mods)
766 for(file : ideSettings.recentFiles)
768 if(id == selection.id)
770 if(mods.ctrl) // Menu::OnLeftButtonUp -> modifiers.ctrl == true, modifiers == 18
771 // Menu::MenuItemSelection -> key.ctrl == false, key.modifiers.ctrl == false, key == 18
772 // removing the (Key) cast from Modifiers when calling MenuItemSelection in OnLeftButtonUp didn't help
774 // it never gets in here!!!
775 char * command = PrintString("ide ", file);
780 OpenFile(file, normal, true, null, no, normal);
788 bool FileRecentProject(MenuItem selection, Modifiers mods)
791 for(file : ideSettings.recentProjects)
793 if(id == selection.id)
795 if(mods.ctrl) // Menu::OnLeftButtonUp -> modifiers.ctrl == true, modifiers == 18
796 // Menu::MenuItemSelection -> key.ctrl == false, key.modifiers.ctrl == false, key == 18
797 // removing the (Key) cast from Modifiers when calling MenuItemSelection in OnLeftButtonUp didn't help
799 // it never gets in here!!!
800 char * command = PrintString("ide ", file);
805 OpenFile(file, normal, true, null, no, normal);
813 MenuPlacement editMenu { menu, $"Edit", e };
815 Menu projectMenu { menu, $"Menu"."Project", p, hasMargin = true };
816 MenuItem projectNewItem
818 projectMenu, $"New...", n, Key { n, true, true };
819 bitmap = { ":actions/projNew.png" };
820 bool NotifySelect(MenuItem selection, Modifiers mods)
822 if(!DontTerminateDebugSession($"New Project"))
823 if(MenuWindowCloseAll(null, 0))
825 NewProjectDialog newProjectDialog;
829 projectView.visible = false;
830 if(!projectView.Destroy(0))
834 newProjectDialog = { master = this };
835 newProjectDialog.Modal();
838 ideSettings.AddRecentProject(projectView.fileName);
839 ide.UpdateRecentMenus();
840 settingsContainer.Save();
846 MenuItem projectOpenItem
848 projectMenu, $"Open...", o, Key { o, true, true };
849 bitmap = { ":actions/projOpen.png" };
850 bool NotifySelect(MenuItem selection, Modifiers mods)
852 if(ideSettings.ideProjectFileDialogLocation)
853 ideProjectFileDialog.currentDirectory = ideSettings.ideProjectFileDialogLocation;
855 ideProjectFileDialog.text = openProjectFileDialogTitle;
856 if(ideProjectFileDialog.Modal() == ok)
858 OpenFile(ideProjectFileDialog.filePath, normal, true, projectTypes[ideProjectFileDialog.fileType].typeExtension, no, normal);
859 //ChangeProjectFileDialogDirectory(ideProjectFileDialog.currentDirectory);
864 MenuItem projectQuickItem
866 projectMenu, $"Quick...", q, f7, disabled = true;
867 bool NotifySelect(MenuItem selection, Modifiers mods)
870 QuickProjectDialog { this }.Modal();
874 MenuItem projectAddItem
876 projectMenu, $"Add project to workspace...", a, Key { a, true, true };
877 bitmap = { ":actions/projAdd.png" };
879 bool NotifySelect(MenuItem selection, Modifiers mods)
881 if(ideSettings.ideProjectFileDialogLocation)
882 ideProjectFileDialog.currentDirectory = ideSettings.ideProjectFileDialogLocation;
884 ideProjectFileDialog.text = addProjectFileDialogTitle;
887 if(ideProjectFileDialog.Modal() == ok)
889 if(OpenFile(ideProjectFileDialog.filePath, normal, true, projectTypes[ideProjectFileDialog.fileType].typeExtension, no, add))
891 if(MessageBox { type = yesNo, master = this, text = $"Error opening project file",
892 contents = $"Add a different project?" }.Modal() == no)
903 MenuItem projectCloseItem
905 projectMenu, $"Close", c, disabled = true;
906 bool NotifySelect(MenuItem selection, Modifiers mods)
910 if(!ide.DontTerminateDebugSession($"Project Close"))
912 if(findInFilesDialog)
913 findInFilesDialog.SearchStop();
914 projectView.visible = false;
915 if(projectView.Destroy(0))
916 MenuWindowCloseAll(null, 0);
918 char workingDir[MAX_LOCATION];
919 GetWorkingDir(workingDir, MAX_LOCATION);
920 findInFilesDialog.currentDirectory = workingDir;
921 ideMainFrame.text = titleECEREIDE;
928 MenuDivider { projectMenu };
929 MenuItem projectSettingsItem
931 projectMenu, $"Settings...", s, altF7, disabled = true;
932 bool NotifySelect(MenuItem selection, Modifiers mods)
934 projectView.MenuSettings(projectView.active ? selection : null, mods);
938 MenuDivider { projectMenu };
939 MenuItem projectBrowseFolderItem
941 projectMenu, $"Browse Project Folder", p, disabled = true;
942 bool NotifySelect(MenuItem selection, Modifiers mods)
945 projectView.MenuBrowseFolder(null, mods);
949 MenuDivider { projectMenu };
950 MenuItem projectRunItem
952 projectMenu, $"Run", r, ctrlF5, disabled = true;
953 bitmap = { ":actions/run.png" };
954 bool NotifySelect(MenuItem selection, Modifiers mods)
957 projectView.Run(null, mods);
961 MenuItem projectBuildItem
963 projectMenu, $"Build", b, f7, disabled = true;
964 bitmap = { ":actions/build.png" };
965 bool NotifySelect(MenuItem selection, Modifiers mods)
968 projectView.ProjectBuild(projectView.active ? selection : null, mods);
972 MenuItem projectLinkItem
974 projectMenu, $"Relink", l, disabled = true;
975 bitmap = { ":actions/relink.png" };
976 bool NotifySelect(MenuItem selection, Modifiers mods)
979 projectView.ProjectLink(projectView.active ? selection : null, mods);
983 MenuItem projectRebuildItem
985 projectMenu, $"Rebuild", d, shiftF7, disabled = true;
986 bitmap = { ":actions/rebuild.png" };
987 bool NotifySelect(MenuItem selection, Modifiers mods)
990 projectView.ProjectRebuild(projectView.active ? selection : null, mods);
994 MenuItem projectCleanItem
996 projectMenu, $"Clean", e, disabled = true;
997 bitmap = { ":actions/clean.png" };
998 bool NotifySelect(MenuItem selection, Modifiers mods)
1003 projectView.ProjectClean(projectView.active ? selection : null, mods);
1008 MenuItem projectRealCleanItem
1010 projectMenu, $"Real Clean", disabled = true;
1011 bitmap = { ":actions/clean.png" };
1012 bool NotifySelect(MenuItem selection, Modifiers mods)
1017 projectView.ProjectRealClean(projectView.active ? selection : null, mods);
1022 MenuItem projectRegenerateItem
1024 projectMenu, $"Regenerate Makefile", m, disabled = true;
1025 bitmap = { ":actions/regMakefile.png" };
1026 bool NotifySelect(MenuItem selection, Modifiers mods)
1029 projectView.ProjectRegenerate(projectView.active ? selection : null, mods);
1033 MenuItem projectCompileItem;
1034 Menu debugMenu { menu, $"Debug", d, hasMargin = true };
1035 MenuItem debugStartResumeItem
1037 debugMenu, $"Start", s, f5, disabled = true;
1038 bitmap = { ":actions/debug.png" };
1039 NotifySelect = MenuDebugStart;
1041 bool MenuDebugStart(MenuItem selection, Modifiers mods)
1045 debugStartResumeItem.disabled = true; // a very rare exception to calling AdjustDebugMenus
1046 if(!projectView.DebugStart())
1047 debugStartResumeItem.disabled = false; // same exception
1051 bool MenuDebugResume(MenuItem selection, Modifiers mods)
1054 projectView.DebugResume();
1057 MenuItem debugRestartItem
1059 debugMenu, $"Restart", r, Key { f5, ctrl = true, shift = true }, disabled = true;
1060 bitmap = { ":actions/restart.png" };
1061 bool NotifySelect(MenuItem selection, Modifiers mods)
1064 projectView.DebugRestart();
1068 MenuItem debugBreakItem
1070 debugMenu, $"Break", b, Key { pauseBreak, ctrl = true }, disabled = true;
1071 bitmap = { ":actions/pause.png" };
1072 bool NotifySelect(MenuItem selection, Modifiers mods)
1075 projectView.DebugBreak();
1079 MenuItem debugStopItem
1081 debugMenu, $"Stop", p, shiftF5, disabled = true;
1082 bitmap = { ":actions/stopDebug.png" };
1083 bool NotifySelect(MenuItem selection, Modifiers mods)
1086 projectView.DebugStop();
1090 MenuDivider { debugMenu };
1091 MenuItem debugStepIntoItem
1093 debugMenu, $"Step Into", i, f11, disabled = true;
1094 bitmap = { ":actions/stepInto.png" };
1095 bool NotifySelect(MenuItem selection, Modifiers mods)
1098 projectView.DebugStepInto();
1102 MenuItem debugStepOverItem
1104 debugMenu, $"Step Over", v, f10, disabled = true;
1105 bitmap = { ":actions/stepOver.png" };
1106 bool NotifySelect(MenuItem selection, Modifiers mods)
1109 projectView.DebugStepOver(false);
1113 MenuItem debugStepOutItem
1115 debugMenu, $"Step Out", o, shiftF11, disabled = true;
1116 bitmap = { ":actions/stepOut.png" };
1117 bool NotifySelect(MenuItem selection, Modifiers mods)
1120 projectView.DebugStepOut(false);
1124 MenuPlacement debugRunToCursorItem { debugMenu, $"Run To Cursor", c };
1125 MenuItem debugSkipStepOverItem
1127 debugMenu, $"Step Over Skipping Breakpoints", e, shiftF10, disabled = true;
1128 bool NotifySelect(MenuItem selection, Modifiers mods)
1131 projectView.DebugStepOver(true);
1135 MenuItem debugSkipStepOutItem
1137 debugMenu, $"Step Out Skipping Breakpoints", t, Key { f11, ctrl = true, shift = true }, disabled = true;
1138 bitmap = { ":actions/skipBreaks.png" };
1139 bool NotifySelect(MenuItem selection, Modifiers mods)
1142 projectView.DebugStepOut(true);
1146 MenuPlacement debugSkipRunToCursorItem { debugMenu, $"Run To Cursor Skipping Breakpoints", u };
1147 //MenuDivider { debugMenu };
1148 //MenuPlacement debugToggleBreakpoint { debugMenu, "Toggle Breakpoint", t };
1149 MenuPlacement imageMenu { menu, $"Image", i };
1150 Menu viewMenu { menu, $"View", v };
1151 MenuItem viewProjectItem
1153 viewMenu, $"Project View", j, alt0, disabled = true;
1154 bool NotifySelect(MenuItem selection, Modifiers mods)
1158 projectView.visible = true;
1159 projectView.Activate();
1164 MenuPlacement { viewMenu, $"View Designer" };
1165 MenuPlacement { viewMenu, $"View Code" };
1166 MenuPlacement { viewMenu, $"View Properties" };
1167 MenuPlacement { viewMenu, $"View Methods" };
1168 MenuItem viewDesignerItem
1170 viewMenu, $"View Designer", d, f8;
1171 bool NotifySelect(MenuItem selection, Modifiers mods)
1173 Window client = activeClient;
1174 Class dataType = client._class;
1175 if(!strcmp(dataType.name, "Designer"))
1177 client.visible = true;
1181 ((CodeEditor)client).ViewDesigner();
1185 MenuItem viewCodeItem
1187 viewMenu, $"View Code", c, f8;
1188 bool NotifySelect(MenuItem selection, Modifiers mods)
1190 Window client = activeClient;
1191 Class dataType = client._class;
1192 if(!strcmp(dataType.name, "Designer"))
1193 client = ((Designer)client).codeEditor;
1196 // Do this after so the caret isn't moved yet...
1197 client.visible = true;
1201 MenuItem viewPropertiesItem
1203 viewMenu, $"View Properties", p, f4;
1204 bool NotifySelect(MenuItem selection, Modifiers mods)
1206 sheet.visible = true;
1207 sheet.sheetSelected = properties;
1212 MenuItem viewMethodsItem
1214 viewMenu, $"View Methods", m, f4;
1215 bool NotifySelect(MenuItem selection, Modifiers mods)
1217 sheet.visible = true;
1218 sheet.sheetSelected = methods;
1223 MenuItem viewToolBoxItem
1225 viewMenu, $"View Toolbox", x, f12;
1226 bool NotifySelect(MenuItem selection, Modifiers mods)
1228 toolBox.visible = true;
1233 MenuItem viewOutputItem
1235 viewMenu, $"Output", o, alt2;
1236 bool NotifySelect(MenuItem selection, Modifiers mods)
1242 MenuItem viewWatchesItem
1244 viewMenu, $"Watches", w, alt3;
1245 bool NotifySelect(MenuItem selection, Modifiers mods)
1251 MenuItem viewThreadsItem
1253 viewMenu, $"Threads", t, alt4;
1254 bool NotifySelect(MenuItem selection, Modifiers mods)
1260 MenuItem viewBreakpointsItem
1262 viewMenu, $"Breakpoints", b, alt5;
1263 bool NotifySelect(MenuItem selection, Modifiers mods)
1265 breakpointsView.Show();
1269 MenuItem viewCallStackItem
1271 viewMenu, $"Call Stack", s, alt7;
1272 bool NotifySelect(MenuItem selection, Modifiers mods)
1274 callStackView.Show();
1278 MenuItem viewAllDebugViews
1280 viewMenu, $"All Debug Views", a, alt9;
1281 bool NotifySelect(MenuItem selection, Modifiers mods)
1286 callStackView.Show();
1287 breakpointsView.Show();
1291 #ifdef GDB_DEBUG_GUI
1292 MenuDivider { viewMenu };
1293 MenuItem viewGDBItem
1295 viewMenu, $"GDB Dialog", g, Key { f9, shift = true, ctrl = true };
1296 bool NotifySelect(MenuItem selection, Modifiers mods)
1303 MenuDivider { viewMenu };
1304 MenuItem viewColorPicker
1306 viewMenu, $"Color Picker...", c, Key { c, ctrl = true , shift = true };
1307 bool NotifySelect(MenuItem selection, Modifiers mods)
1309 ColorPicker colorPicker { master = this, parent = this, stayOnTop = true };
1310 colorPicker.Create();
1314 MenuDivider { viewMenu };
1318 viewMenu, "Full Screen", f, checkable = true;
1320 bool NotifySelect(MenuItem selection, Modifiers mods)
1322 app.fullScreen ^= true;
1324 anchor = { 0, 0, 0, 0 };
1329 Menu driversMenu { viewMenu, $"Graphics Driver", v };
1330 //Menu skinsMenu { viewMenu, "GUI Skins", k };
1331 Menu windowMenu { menu, $"Window", w };
1332 MenuItem { windowMenu, $"Close All", l, NotifySelect = MenuWindowCloseAll };
1333 MenuDivider { windowMenu };
1334 MenuItem { windowMenu, $"Next", n, f6, NotifySelect = MenuWindowNext };
1335 MenuItem { windowMenu, $"Previous", p, shiftF6, NotifySelect = MenuWindowPrevious };
1336 MenuDivider { windowMenu };
1337 MenuItem { windowMenu, $"Cascade", c, NotifySelect = MenuWindowCascade };
1338 MenuItem { windowMenu, $"Tile Horizontally", h, NotifySelect = MenuWindowTileHorz };
1339 MenuItem { windowMenu, $"Tile Vertically", v, NotifySelect = MenuWindowTileVert };
1340 MenuItem { windowMenu, $"Arrange Icons", a, NotifySelect = MenuWindowArrangeIcons };
1341 MenuDivider { windowMenu };
1342 MenuItem { windowMenu, $"Windows...", w, NotifySelect = MenuWindowWindows };
1343 Menu helpMenu { menu, $"Help", h };
1346 helpMenu, $"API Reference", r, f1;
1347 bool NotifySelect(MenuItem selection, Modifiers mods)
1349 Execute("documentor");
1353 MenuDivider { helpMenu };
1356 helpMenu, $"About...", a;
1357 bool NotifySelect(MenuItem selection, Modifiers mods)
1359 AboutIDE { master = this }.Modal();
1364 property ToolBox toolBox
1366 get { return toolBox; }
1369 property Sheet sheet
1371 get { return sheet; }
1374 property Project project
1376 get { return projectView ? projectView.project : null; }
1379 property Workspace workspace
1381 get { return projectView ? projectView.workspace : null; }
1384 FindInFilesDialog findInFilesDialog
1386 master = this, parent = this;
1387 filters = findInFilesFileFilters.array, sizeFilters = findInFilesFileFilters.count * sizeof(FileFilter);
1391 #ifdef GDB_DEBUG_GUI
1394 master = this, parent = this;
1395 anchor = { left = 100, top = 100, right = 100, bottom = 100 };
1397 void OnCommand(char * string)
1400 ide.debugger.SendGDBCommand(string);
1405 bool NotifySelectDisplayDriver(MenuItem selection, Modifiers mods)
1407 //app.driver = app.drivers[selection.id];
1409 app.driver = selection.id ? "OpenGL" : "X";
1411 app.driver = selection.id ? "OpenGL" : "GDI";
1413 delete ideSettings.displayDriver;
1414 ideSettings.displayDriver = CopyString(selection.id ? "OpenGL" : "Default");
1416 settingsContainer.Save();
1417 //SetDriverAndSkin();
1421 bool NotifySelectDisplaySkin(MenuItem selection, Modifiers mods)
1423 app.skin = app.skins[selection.id];
1428 void SetDriverAndSkin()
1431 for(c = 0; c < app.numSkins; c++)
1432 if(!strcmp(app.skins[c], app.skin))
1434 skinItems[c].checked = true;
1437 for(c = 0; c < app.numDrivers; c++)
1438 if(!strcmp(app.drivers[c], app.driver))
1440 driverItems[c].checked = true;
1445 ProjectView CreateProjectView(Workspace workspace, char * fileName)
1447 Project project = workspace.projects.firstIterator.data;
1448 projectView = ProjectView
1451 fileName = fileName;
1453 void NotifyDestroyed(Window window, DialogResult result)
1456 text = titleECEREIDE;
1461 projectView.Create();
1462 RepositionWindows(false);
1464 // Leave it after Create to avoid flicker due to seeing IDE without a project view
1465 projectView.workspace = workspace;
1466 projectView.project = project;
1467 ideMainFrame.SetText("%s - %s", project.topNode.name, titleECEREIDE);
1471 ide.breakpointsView.LoadFromWorkspace();
1472 ide.watchesView.LoadFromWorkspace();
1474 findInFilesDialog.projectNodeField.userData = projectView;
1477 char fileName[MAX_LOCATION];
1478 strcpy(fileName, project.topNode.path);
1479 PathCat(fileName, project.topNode.name);
1484 bool GetDebugMenusDisabled()
1488 Project project = projectView.project;
1490 if(project.GetTargetType(project.config) == executable)
1497 void RepositionWindows(bool expand)
1502 bool inDebugMode = debugger.isActive;
1503 bool callStackVisible = expand ? false : callStackView.visible;
1504 bool threadsVisible = expand ? false : threadsView.visible;
1505 bool watchesVisible = expand ? false : watchesView.visible;
1506 bool breakpointsVisible = expand ? false : breakpointsView.visible;
1507 bool toolBoxVisible = toolBox.visible;
1508 bool outputVisible = expand ? false : outputView.visible;
1509 int topDistance = (callStackVisible || threadsVisible) ? 200 : 0;
1510 int bottomDistance = (outputVisible || watchesVisible || breakpointsVisible) ? 240 : 0;
1512 for(child = firstChild; child; child = child.next)
1514 if(child._class == class(CodeEditor) || child._class == class(Designer) ||
1515 child._class == class(Sheet) || child._class == class(ProjectView))
1517 Anchor anchor = child.anchor;
1518 anchor.top = topDistance;
1519 anchor.bottom = bottomDistance;
1520 if(child._class == class(CodeEditor) || child._class == class(Designer))
1522 anchor.right = toolBoxVisible ? 150 : 0;
1524 child.anchor = anchor;
1528 if(child._class == class(OutputView) || child._class == class(CallStackView) || child._class == class(ThreadsView) || child._class == class(WatchesView) ||
1529 child._class == class(BreakpointsView))
1530 child.visible = false;
1533 // If this is not here, the IDE is not updated when doing Debug/Break then Alt-4 to show call stack (IDE not updated)
1538 bool ShowCodeEditor()
1541 activeClient.Activate();
1542 else if(projectView)
1544 projectView.visible = true;
1545 projectView.Activate();
1549 sheet.visible = true;
1555 bool ShouldStopBuild()
1557 return projectView.stopBuild;
1560 void DocumentSaved(Window document, char * fileName)
1562 ideSettings.AddRecentFile(fileName);
1563 ide.UpdateRecentMenus();
1564 ide.AdjustFileMenus();
1565 settingsContainer.Save();
1568 bool Window::OnFileModified(FileChange fileChange, char * param)
1571 sprintf(temp, $"The document %s was modified by another application.\n"
1572 "Would you like to reload it and lose your changes?", this.fileName);
1573 if(MessageBox { type = yesNo, master = this/*.parent*/,
1574 text = $"Document has been modified", contents = temp }.Modal() == yes)
1576 char * fileName = CopyString(this.fileName);
1577 WindowState state = this.state;
1578 Anchor anchor = this.anchor;
1579 Size size = this.size;
1581 this.modifiedDocument = false;
1583 this = ide.OpenFile(fileName, normal, true, null, no, normal);
1586 this.anchor = anchor;
1588 this.SetState(state, true, 0);
1596 void UpdateMakefiles()
1600 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
1601 for(prj : workspace.projects)
1602 projectView.ProjectUpdateMakefileForAllConfigs(prj);
1607 void UpdateCompilerConfigs()
1609 UpdateToolBarActiveCompilers();
1612 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
1613 projectView.ShowOutputBuildLog(true);
1614 projectView.DisplayCompiler(compiler, false);
1615 for(prj : workspace.projects)
1616 projectView.ProjectPrepareCompiler(prj, compiler);
1621 void UpdateToolBarActiveCompilers()
1623 toolBar.activeCompiler.Clear();
1624 for(compiler : ideSettings.compilerConfigs)
1626 DataRow row = toolBar.activeCompiler.AddString(compiler.name);
1627 if(workspace && workspace.compiler && !strcmp(compiler.name, workspace.compiler))
1628 toolBar.activeCompiler.currentRow = row;
1630 if(!toolBar.activeCompiler.currentRow)
1631 toolBar.activeCompiler.currentRow = toolBar.activeCompiler.firstRow;
1632 toolBar.activeCompiler.disabled = workspace == null;
1635 void UpdateToolBarActiveConfigs(bool selectionOnly)
1637 bool commonSelected = false;
1638 DataRow row = toolBar.activeConfig.currentRow;
1640 row = toolBar.activeConfig.FindRow(1);
1643 toolBar.activeConfig.Clear();
1644 row = toolBar.activeConfig.AddString("(Mixed)");
1649 char * configName = null;
1652 Map<String, int> configs { }; // TOIMP: just need sort but using map until containers have sort
1653 for(prj : workspace.projects)
1655 for(cfg : prj.configurations)
1658 configs[cfg.name] = 1;
1663 toolBar.activeConfig.AddString(&name);
1667 if(projectView && projectView.project)
1669 for(prj : workspace.projects)
1671 if(prj.config && prj.config.name)
1673 configName = prj.config.name;
1679 commonSelected = true;
1680 for(prj : workspace.projects)
1682 if(prj.config && (!prj.config.name || strcmp(prj.config.name, configName)))
1684 commonSelected = false;
1692 commonSelected = false;
1693 for(row = toolBar.activeConfig.firstRow; row; row = row.next)
1695 if(!strcmp(row.string, configName))
1697 toolBar.activeConfig.currentRow = row;
1698 commonSelected = true;
1705 toolBar.activeConfig.Sort(null, 0);
1707 toolBar.activeConfig.currentRow = row;
1708 toolBar.activeConfig.disabled = workspace == null;
1713 bool unavailable = !project;
1715 projectAddItem.disabled = unavailable;
1716 toolBar.buttonAddProject.disabled = unavailable;
1718 projectSettingsItem.disabled = unavailable;
1720 projectBrowseFolderItem.disabled = unavailable;
1722 viewProjectItem.disabled = unavailable;
1729 property bool hasOpenedCodeEditors
1734 for(w = firstChild; w; w = w.next)
1735 if(w._class == class(CodeEditor) &&
1736 w.isDocument && !w.closing && w.visible && w.created &&
1737 w.fileName && w.fileName[0])
1743 void AdjustFileMenus()
1745 bool unavailable = project != null || !hasOpenedCodeEditors; // are they supported source code (ec, c, cpp, etc) ?
1747 projectQuickItem.disabled = unavailable;
1750 void AdjustBuildMenus()
1752 bool unavailable = project && projectView.buildInProgress;
1754 projectNewItem.disabled = unavailable;
1755 toolBar.buttonNewProject.disabled = unavailable;
1756 projectOpenItem.disabled = unavailable;
1757 toolBar.buttonOpenProject.disabled = unavailable;
1759 unavailable = !project || projectView.buildInProgress;
1761 projectCloseItem.disabled = unavailable;
1762 // toolBar.buttonCloseProject.disabled = unavailable;
1764 projectRunItem.disabled = unavailable || project.GetTargetType(project.config) != executable;
1765 toolBar.buttonRun.disabled = unavailable || project.GetTargetType(project.config) != executable;
1766 projectBuildItem.disabled = unavailable;
1767 toolBar.buttonBuild.disabled = unavailable;
1768 projectLinkItem.disabled = unavailable;
1769 toolBar.buttonReLink.disabled = unavailable;
1770 projectRebuildItem.disabled = unavailable;
1771 toolBar.buttonRebuild.disabled = unavailable;
1772 projectCleanItem.disabled = unavailable;
1773 toolBar.buttonClean.disabled = unavailable;
1774 projectRealCleanItem.disabled = unavailable;
1775 // toolBar.buttonRealClean.disabled = unavailable;
1776 projectRegenerateItem.disabled = unavailable;
1777 toolBar.buttonRegenerateMakefile.disabled = unavailable;
1778 projectCompileItem.disabled = unavailable;
1780 if(projectView && projectView.popupMenu && projectView.popupMenu.menu && projectView.popupMenu.created)
1783 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectBuild, 0); if(menu) menu.disabled = unavailable;
1784 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectLink, 0); if(menu) menu.disabled = unavailable;
1785 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRebuild, 0); if(menu) menu.disabled = unavailable;
1786 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectClean, 0); if(menu) menu.disabled = unavailable;
1787 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRealClean, 0); if(menu) menu.disabled = unavailable;
1788 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRegenerate, 0); if(menu) menu.disabled = unavailable;
1789 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRemove, 0); if(menu) menu.disabled = unavailable;
1790 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileClean, 0); if(menu) menu.disabled = unavailable;
1791 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileCompile, 0); if(menu) menu.disabled = unavailable;
1792 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugPrecompile, 0); if(menu) menu.disabled = unavailable;
1793 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugCompile, 0); if(menu) menu.disabled = unavailable;
1794 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugGenerateSymbols, 0); if(menu) menu.disabled = unavailable;
1795 projectView.popupMenu.Update(null);
1799 void AdjustDebugMenus()
1801 bool unavailable = !project || project.GetTargetType(project.config) != executable ||
1802 projectView.buildInProgress == buildingMainProject;
1803 bool active = ide.debugger.isActive;
1804 bool executing = ide.debugger.state == running;
1805 //bool holding = ide.debugger.state == stopped;
1807 debugStartResumeItem.disabled = unavailable || executing;
1808 debugStartResumeItem.text = active ? $"Resume" : $"Start";
1809 debugStartResumeItem.NotifySelect = active ? MenuDebugResume : MenuDebugStart;
1812 toolBar.buttonDebugStartResume.disabled = unavailable || executing;
1813 toolBar.buttonDebugStartResume.toolTip = active ? $"Resume" : $"Start";
1816 debugBreakItem.disabled = unavailable || !executing;
1817 debugStopItem.disabled = unavailable || !active;
1818 debugRestartItem.disabled = unavailable || !active;
1821 toolBar.buttonDebugPause.disabled = unavailable || !executing;
1822 toolBar.buttonDebugStop.disabled = unavailable || !active;
1823 toolBar.buttonDebugRestart.disabled = unavailable || !active;
1826 debugStepIntoItem.disabled = unavailable || executing;
1827 debugStepOverItem.disabled = unavailable || executing;
1828 debugStepOutItem.disabled = unavailable || executing || !active;
1829 debugSkipStepOverItem.disabled = unavailable || executing;
1830 debugSkipStepOutItem.disabled = unavailable || executing || !active;
1833 toolBar.buttonDebugStepInto.disabled = unavailable || executing;
1834 toolBar.buttonDebugStepOver.disabled = unavailable || executing;
1835 toolBar.buttonDebugStepOut.disabled = unavailable || executing || !active;
1836 toolBar.buttonDebugSkipStepOver.disabled = unavailable || executing;
1837 // toolBar.buttonDebugSkipStepOutItem.disabled = unavailable || executing;
1839 if((Designer)GetActiveDesigner())
1841 CodeEditor codeEditor = ((Designer)GetActiveDesigner()).codeEditor;
1844 codeEditor.debugRunToCursor.disabled = unavailable || executing;
1845 codeEditor.debugSkipRunToCursor.disabled = unavailable || executing;
1850 void ChangeFileDialogsDirectory(char * directory, bool saveSettings)
1852 char tempString[MAX_LOCATION];
1853 strcpy(tempString, directory);
1854 if(saveSettings && !projectView)
1856 ideSettings.ideFileDialogLocation = directory;
1857 settingsContainer.Save();
1860 ideFileDialog.currentDirectory = tempString;
1861 codeEditorFileDialog.currentDirectory = tempString;
1862 codeEditorFormFileDialog.currentDirectory = tempString;
1865 void ChangeProjectFileDialogDirectory(char * directory)
1867 ideSettings.ideProjectFileDialogLocation = directory;
1868 settingsContainer.Save();
1871 Window FindWindow(char * filePath)
1873 Window document = null;
1875 // TOCHECK: Do we need to change slashes here?
1876 for(document = firstChild; document; document = document.next)
1878 char * fileName = document.fileName;
1879 if(document.isDocument && fileName && !fstrcmp(fileName, filePath))
1881 document.visible = true;
1882 document.Activate();
1889 bool DontTerminateDebugSession(char * title)
1891 if(debugger.isActive)
1893 if(MessageBox { type = yesNo, master = ide,
1894 contents = $"Do you want to terminate the debugging session in progress?",
1895 text = title }.Modal() == no)
1898 MessageBox msg { type = yesNo, master = ide,
1899 contents = "Do you want to terminate the debugging session in progress?",
1901 if(msg.Modal() == no)
1913 Window OpenFile(char * origFilePath, WindowState state, bool visible, char * type, OpenCreateIfFails createIfFails, OpenMethod openMethod)
1915 char extension[MAX_EXTENSION] = "";
1916 Window document = null;
1917 bool isProject = false;
1918 bool needFileModified = true;
1919 char winFilePath[MAX_LOCATION];
1920 char * filePath = strstr(origFilePath, "http://") == origFilePath ? strcpy(winFilePath, origFilePath) : GetSystemPathBuffer(winFilePath, origFilePath);
1924 GetExtension(filePath, extension);
1928 strcpy(extension, type);
1930 if(strcmp(extension, ProjectExtension))
1932 for(document = firstChild; document; document = document.next)
1934 char * fileName = document.fileName;
1935 if(document.isDocument && fileName && !fstrcmp(fileName, filePath) && document.created)
1937 document.visible = true;
1939 document.Activate();
1945 if(createIfFails == whatever)
1947 else if(!strcmp(extension, ProjectExtension) || !strcmp(extension, WorkspaceExtension))
1949 needFileModified = false;
1950 if(openMethod == normal)
1952 if(DontTerminateDebugSession($"Open Project"))
1955 if(MenuWindowCloseAll(null, 0))
1959 projectView.visible = false;
1960 projectView.Destroy(0);
1961 // Where did this come from? projectView = null;
1968 Workspace workspace = null;
1970 if(FileExists(filePath))
1972 if(!strcmp(extension, ProjectExtension))
1974 char workspaceFile[MAX_LOCATION];
1975 strcpy(workspaceFile, filePath);
1976 ChangeExtension(workspaceFile, WorkspaceExtension, workspaceFile);
1977 workspace = LoadWorkspace(workspaceFile, filePath);
1979 else if(!strcmp(extension, WorkspaceExtension))
1980 workspace = LoadWorkspace(filePath, null);
1983 //project = LoadProject(filePath, null);
1988 char absolutePath[MAX_LOCATION];
1989 CreateProjectView(workspace, filePath);
1990 document = projectView;
1992 workspace.DropInvalidBreakpoints();
1995 ide.projectView.ShowOutputBuildLog(true);
1997 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
1998 ide.projectView.DisplayCompiler(compiler, false);
2001 UpdateCompilerConfigs();
2004 char newWorkingDir[MAX_LOCATION];
2005 StripLastDirectory(filePath, newWorkingDir);
2006 ChangeFileDialogsDirectory(newWorkingDir, false);
2009 document.fileName = filePath;
2011 ideMainFrame.SetText("%s - %s", filePath, titleECEREIDE);
2013 // this crashes on starting ide with epj file, solution please?
2014 // app.UpdateDisplay();
2016 workspace.holdTracking = true;
2017 for(ofi : workspace.openedFiles)
2019 if(ofi.state != closed)
2021 Window file = OpenFile(ofi.path, normal, true, null, no, normal);
2024 char fileName[MAX_LOCATION];
2026 GetLastDirectory(ofi.path, fileName);
2027 node = projectView.project.topNode.Find(fileName, true);
2029 node.EnsureVisible();
2033 workspace.holdTracking = false;
2035 workspace.timer.Start();
2037 findInFilesDialog.mode = FindInFilesMode::project;
2038 findInFilesDialog.currentDirectory = ide.project.topNode.path;
2041 char location[MAX_LOCATION];
2042 StripLastDirectory(ide.project.topNode.path, location);
2043 ChangeProjectFileDialogDirectory(location);
2047 if(projectView.debugger)
2048 projectView.debugger.EvaluateWatches();
2055 if(MessageBox { type = yesNo, master = this, text = $"Error opening project", contents = $"Open a different project?" }.Modal() == yes)
2057 ideProjectFileDialog.text = openProjectFileDialogTitle;
2058 if(ideProjectFileDialog.Modal() == cancel)
2060 filePath = ideProjectFileDialog.filePath;
2061 GetExtension(filePath, extension);
2072 else if(openMethod == add)
2077 char slashFilePath[MAX_LOCATION];
2078 GetSlashPathBuffer(slashFilePath, filePath);
2079 for(p : workspace.projects)
2081 if(!fstrcmp(p.filePath, slashFilePath))
2089 MessageBox { type = ok, parent = parent, master = this, text = $"Same Project",
2090 contents = $"This project is already present in workspace." }.Modal();
2094 prj = LoadProject(filePath, null);
2097 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
2098 prj.StartMonitoring();
2099 workspace.projects.Add(prj);
2101 projectView.AddNode(prj.topNode, null);
2102 workspace.modified = true;
2104 findInFilesDialog.AddProjectItem(prj);
2105 projectView.ShowOutputBuildLog(true);
2106 projectView.DisplayCompiler(compiler, false);
2107 projectView.ProjectUpdateMakefileForAllConfigs(prj);
2111 char location[MAX_LOCATION];
2112 StripLastDirectory(prj.topNode.path, location);
2113 ChangeProjectFileDialogDirectory(location);
2116 // projectView is associated with the main project and not with the one just added but
2117 return projectView; // just to let the caller know something was opened
2125 else if(!strcmp(extension, "bmp") || !strcmp(extension, "pcx") ||
2126 !strcmp(extension, "jpg") || !strcmp(extension, "gif") ||
2127 !strcmp(extension, "jpeg") || !strcmp(extension, "png"))
2129 if(FileExists(filePath))
2130 document = PictureEdit { hasMaximize = true, hasMinimize = true, hasClose = true, borderStyle = sizable,
2131 hasVertScroll = true, hasHorzScroll = true, parent = this, state = state,
2132 visible = visible, bitmapFile = filePath, OnClose = PictureEditOnClose/*why?--GenericDocumentOnClose*/;
2135 MessageBox { type = ok, master = this, text = filePath, contents = $"File doesn't exist." }.Modal();
2138 else if(!strcmp(extension, "3ds"))
2140 if(FileExists(filePath))
2141 document = ModelView { hasMaximize = true, hasMinimize = true, hasClose = true, borderStyle = sizable,
2142 hasVertScroll = true, hasHorzScroll = true, parent = this, state = state,
2143 visible = visible, modelFile = filePath, OnClose = ModelViewOnClose/*why?--GenericDocumentOnClose*/
2147 MessageBox { type = ok, master = this, text = filePath, contents = $"File doesn't exist." }.Modal();
2150 else if(!strcmp(extension, "txt") || !strcmp(extension, "text") ||
2151 !strcmp(extension, "nfo") || !strcmp(extension, "info") ||
2152 !strcmp(extension, "htm") || !strcmp(extension, "html") ||
2153 !strcmp(extension, "css") || !strcmp(extension, "php") ||
2154 !strcmp(extension, "js"))
2156 CodeEditor editor { parent = this, state = state, visible = false };
2157 editor.updatingCode = true;
2158 if(editor.LoadFile(filePath))
2161 editor.visible = true;
2165 needFileModified = false;
2169 CodeEditor editor { parent = this, state = state, visible = false };
2170 if(editor.LoadFile(filePath))
2173 editor.visible = true;
2177 needFileModified = false;
2180 if(document && (document._class == class(PictureEdit) ||
2181 document._class == class(ModelView)))
2186 document.fileName = filePath;
2187 if(workspace && !workspace.holdTracking)
2188 workspace.UpdateOpenedFileInfo(filePath, opened);
2192 if(!document && createIfFails != no)
2194 if(createIfFails != yes && !needFileModified &&
2195 MessageBox { type = yesNo, master = this, text = filePath, contents = $"File doesn't exist. Create?" }.Modal() == yes)
2196 createIfFails = yes;
2197 if(createIfFails == yes || createIfFails == whatever)
2199 document = (Window)NewCodeEditor(this, state, true);
2201 document.fileName = filePath;
2207 if(projectView && document._class == class(CodeEditor) && workspace)
2209 int lineNumber, position;
2211 CodeEditor editor = (CodeEditor)document;
2212 editor.openedFileInfo = workspace.UpdateOpenedFileInfo(filePath, opened);
2213 editor.openedFileInfo.holdTracking = true;
2214 lineNumber = Max(editor.openedFileInfo.lineNumber - 1, 0);
2215 position = Max(editor.openedFileInfo.position - 1, 0);
2216 editor.editBox.GoToLineNum(lineNumber);
2217 editor.editBox.GoToPosition(editor.editBox.line, lineNumber, position);
2218 scroll.x = Max(editor.openedFileInfo.scroll.x, 0);
2219 scroll.y = Max(editor.openedFileInfo.scroll.y, 0);
2220 editor.editBox.scroll = scroll;
2221 editor.openedFileInfo.holdTracking = false;
2224 if(needFileModified)
2225 document.OnFileModified = OnFileModified;
2226 document.NotifySaved = DocumentSaved;
2229 ideSettings.AddRecentProject(document.fileName);
2231 ideSettings.AddRecentFile(document.fileName);
2232 ide.UpdateRecentMenus();
2233 ide.AdjustFileMenus();
2234 settingsContainer.Save();
2242 // TOCHECK: I can't use a generic one for both ModelView and PictureEdit both derived from Window
2243 /*bool Window::GenericDocumentOnClose(bool parentClosing)
2245 if(!parentClosing && ide.workspace)
2246 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2249 bool ModelView::ModelViewOnClose(bool parentClosing)
2251 if(!parentClosing && ide.workspace)
2252 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2255 bool PictureEdit::PictureEditOnClose(bool parentClosing)
2257 if(!parentClosing && ide.workspace)
2258 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2263 void OnUnloadGraphics(Window window)
2265 display.ClearMaterials();
2266 display.ClearTextures();
2267 display.ClearMeshes();
2271 bool OnActivate(bool active, Window swap, bool * goOnWithActivation, bool direct)
2273 caps.color = app.GetKeyState(capsState) ? black : Color { 128,128,128 };
2274 num.color = app.GetKeyState(numState) ? black : Color { 128,128,128 };
2278 bool OnKeyDown(Key key, unichar ch)
2283 projectView.Update(null);
2286 caps.color = app.GetKeyState(capsState) ? black : Color { 128,128,128 };
2289 num.color = app.GetKeyState(numState) ? black : Color { 128,128,128 };
2295 void GoToError(const char * line)
2298 projectView.GoToError(line);
2301 void CodeLocationParseAndGoTo(const char * text, Project project, const char * dir)
2304 char *colon = strchr(text, ':');
2305 char filePath[MAX_LOCATION];
2306 char completePath[MAX_LOCATION];
2307 int line = 0, col = 0;
2309 FileAttribs fileAttribs;
2311 if(colon && (colon[1] == '/' || colon[1] == '\\'))
2313 path = (colon - 1 > path) ? colon - 1 : path;
2314 colon = strstr(colon + 1, ":");
2316 while(isspace(*path)) path++;
2319 char * close = strchr(path, ')');
2323 strncpy(name, path+1, close - path - 1);
2324 name[close - path - 1] = '\0';
2325 for(p : ide.workspace.projects)
2327 if(!strcmp(p.name, name))
2337 prj = project ? project : (dir ? null : ide.project);
2340 strncpy(filePath, path, colon - path);
2341 filePath[colon - path] = '\0';
2342 line = atoi(colon + 1);
2343 colon = strstr(colon + 1, ":");
2345 col = atoi(colon + 1);
2347 else if(path - 1 >= text && *(path - 1) == '\"')
2349 colon = strchr(path, '\"');
2352 strncpy(filePath, path, colon - path);
2353 filePath[colon - path] = '\0';
2356 else if(path && !colon)
2358 strcpy(filePath, path);
2362 strcpy(completePath, prj.topNode.path);
2363 else if(dir && dir[0])
2364 strcpy(completePath, dir);
2366 completePath[0] = '\0';
2367 PathCat(completePath, filePath);
2369 fileAttribs = FileExists(completePath);
2370 if(fileAttribs.isFile)
2372 CodeEditor codeEditor = (CodeEditor)OpenFile(completePath, normal, true, "", no, normal);
2373 if(codeEditor && line)
2375 EditBox editBox = codeEditor.editBox;
2376 editBox.GoToLineNum(line - 1);
2377 editBox.GoToPosition(editBox.line, line - 1, col ? (col - 1) : 0);
2380 else if(fileAttribs.isDirectory)
2381 ShellOpen(completePath);
2384 void OnRedraw(Surface surface)
2386 Bitmap bitmap = back.bitmap;
2388 surface.Blit(bitmap, (clientSize.w - bitmap.width) / 2, (clientSize.h - bitmap.height) / 2, 0, 0, bitmap.width, bitmap.height);
2391 void SheetSelected(SheetType sheetSelected)
2393 if(activeChild == sheet)
2395 if(sheetSelected == methods)
2397 viewPropertiesItem.accelerator = f4;
2398 viewPropertiesItem.parent = viewMenu;
2399 viewMethodsItem.parent = null;
2403 viewMethodsItem.accelerator = f4;
2404 viewMethodsItem.parent = viewMenu;
2405 viewPropertiesItem.parent = null;
2410 viewMethodsItem.parent = viewMenu;
2411 viewPropertiesItem.parent = viewMenu;
2412 if(sheetSelected == methods)
2414 viewMethodsItem.accelerator = f4;
2415 viewPropertiesItem.accelerator = 0;
2419 viewMethodsItem.accelerator = 0;
2420 viewPropertiesItem.accelerator = f4;
2425 void OnActivateClient(Window client, Window previous)
2427 //if(!client || client != previous)
2430 if(!client || client != previous)
2433 dataType = previous._class;
2434 if(previous && !strcmp(dataType.name, "CodeEditor"))
2436 ((CodeEditor)previous).UpdateFormCode();
2438 else if(previous && !strcmp(dataType.name, "Designer"))
2440 ((Designer)previous).codeEditor.UpdateFormCode();
2445 dataType = client._class;
2446 if(client && !strcmp(dataType.name, "CodeEditor"))
2448 CodeEditor codeEditor = (CodeEditor)client;
2449 SetPrivateModule(codeEditor.privateModule);
2450 SetCurrentContext(codeEditor.globalContext);
2451 SetTopContext(codeEditor.globalContext);
2452 SetGlobalContext(codeEditor.globalContext);
2454 SetDefines(&codeEditor.defines);
2455 SetImports(&codeEditor.imports);
2457 SetActiveDesigner(codeEditor.designer);
2459 sheet.codeEditor = codeEditor;
2460 toolBox.codeEditor = codeEditor;
2462 viewDesignerItem.parent = viewMenu;
2463 if(activeChild != codeEditor)
2465 viewCodeItem.parent = viewMenu;
2466 viewDesignerItem.accelerator = 0;
2467 viewCodeItem.accelerator = f8;
2471 viewCodeItem.parent = null;
2472 viewDesignerItem.accelerator = f8;
2475 else if(client && !strcmp(dataType.name, "Designer"))
2477 CodeEditor codeEditor = ((Designer)client).codeEditor;
2480 SetPrivateModule(codeEditor.privateModule);
2481 SetCurrentContext(codeEditor.globalContext);
2482 SetTopContext(codeEditor.globalContext);
2483 SetGlobalContext(codeEditor.globalContext);
2484 SetDefines(&codeEditor.defines);
2485 SetImports(&codeEditor.imports);
2489 SetPrivateModule(null);
2490 SetCurrentContext(null);
2491 SetTopContext(null);
2492 SetGlobalContext(null);
2497 SetActiveDesigner((Designer)client);
2499 sheet.codeEditor = codeEditor;
2500 toolBox.codeEditor = codeEditor;
2502 viewCodeItem.parent = viewMenu;
2503 if(activeChild != client)
2505 viewDesignerItem.parent = viewMenu;
2506 viewDesignerItem.accelerator = f8;
2507 viewCodeItem.accelerator = 0;
2511 viewDesignerItem.parent = null;
2512 viewCodeItem.accelerator = f8;
2518 sheet.codeEditor = null;
2519 toolBox.codeEditor = null;
2520 SetActiveDesigner(null);
2522 viewDesignerItem.parent = null;
2523 viewCodeItem.parent = null;
2526 SheetSelected(sheet.sheetSelected);
2529 projectCompileItem = null;
2534 if(client && client._class == eSystem_FindClass(__thisModule, "CodeEditor")) // !strcmp(client._class.name, "CodeEditor")
2536 CodeEditor codeEditor = (CodeEditor)client;
2537 EditBox editBox = codeEditor.editBox;
2539 statusBar.AddField(pos);
2541 caps = { width = 40, text = $"CAPS", color = app.GetKeyState(capsState) ? black : Color { 128, 128, 128 } };
2542 statusBar.AddField(caps);
2544 ovr = { width = 30, text = $"OVR", color = editBox.overwrite ? black : Color { 128, 128, 128 } };
2545 statusBar.AddField(ovr);
2547 num = { width = 30, text = $"NUM", color = app.GetKeyState(numState) ? black : Color { 128, 128, 128 } };
2548 statusBar.AddField(num);
2550 //statusBar.text = "Ready";
2552 if(projectView && projectView.project)
2554 ProjectNode node = projectView.GetNodeFromWindow(client, null);
2558 sprintf(name, $"Compile %s", node.name);
2559 projectCompileItem =
2561 copyText = true, text = name, c, ctrlF7, disabled = projectView.buildInProgress;
2563 bool NotifySelect(MenuItem selection, Modifiers mods)
2567 bool result = false;
2568 ProjectNode node = null;
2569 for(p : ide.workspace.projects)
2571 node = projectView.GetNodeFromWindow(activeClient, p);
2572 //if(node && projectView.Compile(node.project, node, mods.ctrl && mods.shift))
2575 List<ProjectNode> nodes { };
2577 projectView.Compile(node.project, nodes, mods.ctrl && mods.shift, normal);
2585 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
2590 projectMenu.AddDynamic(projectCompileItem, ide, false);
2596 caps = ovr = num = null;
2601 bool OnClose(bool parentClosing)
2603 //return !projectView.buildInProgress;
2604 if(projectView && projectView.buildInProgress)
2606 if(DontTerminateDebugSession($"Close IDE"))
2608 if(findInFilesDialog)
2609 findInFilesDialog.SearchStop();
2612 workspace.timer.Stop();
2615 ideMainFrame.Destroy(0);
2622 bool passThrough = false;
2623 bool debugStart = false;
2624 DynamicString passArgs { };
2625 for(c = 1; c<app.argc; c++)
2627 if(!strcmp(app.argv[c], "-debug-start"))
2629 else if(!passThrough && !strcmp(app.argv[c], "-@"))
2631 else if(passThrough)
2633 passArgs.concat(" ");
2634 passArgs.concat(app.argv[c]);
2638 char fullPath[MAX_LOCATION];
2639 char parentPath[MAX_LOCATION];
2640 char ext[MAX_EXTENSION];
2642 FileAttribs dirAttribs;
2643 GetWorkingDir(fullPath, MAX_LOCATION);
2644 PathCat(fullPath, app.argv[c]);
2645 StripLastDirectory(fullPath, parentPath);
2646 GetExtension(app.argv[c], ext);
2647 isProject = !strcmpi(ext, "epj");
2649 if(isProject && c > (debugStart ? 2 : 1)) continue;
2651 // Create directory for projects (only)
2652 if(((dirAttribs = FileExists(parentPath)) && dirAttribs.isDirectory) || isProject)
2654 if(isProject && !FileExists(fullPath))
2656 // The NewProject will handle directory creation
2657 /*if(!dirAttribs.isDirectory)
2659 MakeDir(parentPath);
2660 dirAttribs = FileExists(parentPath);
2662 if(dirAttribs.isDirectory)*/
2664 char name[MAX_LOCATION];
2665 NewProjectDialog newProjectDialog;
2669 projectView.visible = false;
2670 if(!projectView.Destroy(0))
2674 newProjectDialog = { master = this };
2676 strcpy(name, app.argv[c]);
2677 StripExtension(name);
2678 GetLastDirectory(name, name);
2679 newProjectDialog.projectName.contents = name;
2680 newProjectDialog.projectName.NotifyModified(newProjectDialog, newProjectDialog.projectName);
2681 newProjectDialog.locationEditBox.path = parentPath;
2682 newProjectDialog.NotifyModifiedLocation(newProjectDialog.locationEditBox);
2684 newProjectDialog.Modal();
2687 ideSettings.AddRecentProject(projectView.fileName);
2688 ide.UpdateRecentMenus();
2689 settingsContainer.Save();
2692 // Open only one project
2696 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, null, yes, normal);
2698 else if(strstr(fullPath, "http://") == fullPath)
2699 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, null, yes, normal);
2702 if(passThrough && projectView && projectView.project && workspace)
2703 workspace.commandLineArgs = passArgs;
2706 ;//MenuDebugStart(debugStartResumeItem, 0); // <-- how TODO this without getting into the app.Wait lock
2708 UpdateToolBarActiveConfigs(false);
2709 UpdateToolBarActiveCompilers();
2715 // IS THIS NEEDED? WASN'T HERE BEFORE... Crashes on getting node's projectView otherwise
2718 projectView.visible = false;
2719 projectView.Destroy(0);
2722 #ifdef GDB_DEBUG_GUI
2723 gdbDialog.Destroy(0);
2728 void SetPath(bool projectsDirs, CompilerConfig compiler, ProjectConfig config)
2732 char * oldPaths[128];
2733 String oldList = new char[maxPathLen];
2734 Array<String> newExePaths { };
2735 //Map<String, bool> exePathExists { };
2737 #if defined(__unix__) || defined(__APPLE__)
2738 Array<String> newLibPaths { };
2739 Map<String, bool> libPathExists { };
2744 for(prj : workspace.projects)
2746 DirExpression targetDirExp;
2748 // SKIP FIRST PROJECT...
2749 if(prj == workspace.projects.firstIterator.data) continue;
2751 // NOTE: Right now the additional project config dir will be
2752 // obtained when the debugger is started, so toggling it
2753 // while building will change which library gets used.
2754 // To go with the initial state, e.g. when F5 was pressed,
2755 // we nould need to keep a list of all project's active
2756 // config upon startup.
2757 targetDirExp = prj.GetTargetDir(compiler, prj.config);
2759 /*if(prj.config.targetType == sharedLibrary && prj.config.debug)
2763 for(cfg = prj.configurations.first; cfg; cfg = cfg.next)
2764 if(cfg.targetType == sharedLibrary && cfg.debug && !strcmpi(cfg.name, "Debug"))
2768 for(cfg = prj.configurations.first; cfg; cfg = cfg.next)
2769 if(cfg.targetType == sharedLibrary && cfg.debug)
2773 if(targetDirExp.dir)
2775 char buffer[MAX_LOCATION];
2776 #if defined(__WIN32__)
2777 Array<String> paths = newExePaths;
2779 Array<String> paths = newLibPaths;
2781 GetSystemPathBuffer(buffer, prj.topNode.path);
2782 PathCat(buffer, targetDirExp.dir);
2785 if(!fstrcmp(p, buffer))
2792 paths.Add(CopyString(buffer));
2794 delete targetDirExp;
2798 for(item : compiler.executableDirs)
2801 for(p : newExePaths)
2803 if(!fstrcmp(p, item))
2810 newExePaths.Add(CopySystemPath(item));
2813 GetEnvironment("PATH", oldList, maxPathLen);
2815 printf("Old value of PATH: %s\n", oldList);
2817 count = TokenizeWith(oldList, sizeof(oldPaths) / sizeof(char *), oldPaths, pathListSep, false);
2818 for(c = 0; c < count; c++)
2821 for(p : newExePaths)
2823 if(!fstrcmp(p, oldPaths[c]))
2830 newExePaths.Add(CopySystemPath(oldPaths[c]));
2834 for(path : newExePaths)
2835 len += strlen(path) + 1;
2836 newList = new char[len + 1];
2838 for(path : newExePaths)
2840 strcat(newList, path);
2841 strcat(newList, pathListSep);
2843 newList[len - 1] = '\0';
2844 SetEnvironment("PATH", newList);
2846 printf("New value of PATH: %s\n", newList);
2853 #if defined(__unix__) || defined(__APPLE__)
2855 for(item : compiler.libraryDirs)
2857 if(!libPathExists[item]) // fstrcmp should be used
2859 newLibPaths.Add(item);
2860 libPathExists[item] = true;
2864 #if defined(__APPLE__)
2865 GetEnvironment("DYLD_LIBRARY_PATH", oldList, maxPathLen);
2867 GetEnvironment("LD_LIBRARY_PATH", oldList, maxPathLen);
2870 printf("Old value of [DY]LD_LIBRARY_PATH: %s\n", oldList);
2872 count = TokenizeWith(oldList, sizeof(oldPaths) / sizeof(char *), oldPaths, pathListSep, false);
2873 for(c = 0; c < count; c++)
2875 if(!libPathExists[oldPaths[c]]) // fstrcmp should be used
2877 newLibPaths.Add(oldPaths[c]);
2878 libPathExists[oldPaths[c]] = true;
2883 for(path : newLibPaths)
2884 len += strlen(path) + 1;
2885 newList = new char[len + 1];
2887 for(path : newLibPaths)
2889 strcat(newList, path);
2890 strcat(newList, pathListSep);
2892 newList[len - 1] = '\0';
2893 #if defined(__APPLE__)
2894 SetEnvironment("DYLD_LIBRARY_PATH", newList);
2896 SetEnvironment("LD_LIBRARY_PATH", newList);
2899 printf("New value of [DY]LD_LIBRARY_PATH: %s\n", newList);
2904 delete libPathExists;
2907 if(compiler.distccEnabled && compiler.distccHosts)
2908 SetEnvironment("DISTCC_HOSTS", compiler.distccHosts);
2913 void DestroyTemporaryProjectDir()
2915 if(tmpPrjDir && tmpPrjDir[0])
2917 if(FileExists(tmpPrjDir).isDirectory)
2918 DestroyDir(tmpPrjDir);
2919 property::tmpPrjDir = null;
2925 // Graphics Driver Menu
2929 app.currentSkin.selectionColor = selectionColor;
2930 app.currentSkin.selectionText = selectionText;
2934 driverItems = new MenuItem[app.numDrivers];
2935 for(c = 0; c < app.numDrivers; c++)
2937 driverItems[c] = MenuItem { driversMenu, app.drivers[c], NotifySelect = NotifySelectDisplayDriver };
2938 driverItems[c].id = c;
2939 driverItems[c].isRadio = true;
2942 driverItems = new MenuItem[2];
2943 #if defined(__unix__)
2944 driverItems[0] = MenuItem { driversMenu, "X", NotifySelect = NotifySelectDisplayDriver };
2945 driverItems[0].id = 0;
2946 driverItems[0].isRadio = true;
2948 driverItems[0] = MenuItem { driversMenu, "GDI", NotifySelect = NotifySelectDisplayDriver };
2949 driverItems[0].id = 0;
2950 driverItems[0].isRadio = true;
2952 driverItems[1] = MenuItem { driversMenu, "OpenGL", NotifySelect = NotifySelectDisplayDriver };
2953 driverItems[1].id = 1;
2954 driverItems[1].isRadio = true;
2956 /* skinItems = new MenuItem[app.numSkins];
2957 for(c = 0; c < app.numSkins; c++)
2959 skinItems[c] = MenuItem {skinsMenu, app.skins[c], NotifySelect = NotifySelectDisplaySkin };
2960 skinItems[c].id = c;
2961 skinItems[c].isRadio = true;
2964 ideFileDialog.master = this;
2965 ideProjectFileDialog.master = this;
2967 //SetDriverAndSkin();
2971 void UpdateRecentMenus()
2974 Menu fileMenu = menu.FindMenu($"File");
2975 Menu recentFiles = fileMenu.FindMenu($"Recent Files");
2976 Menu recentProjects = fileMenu.FindMenu($"Recent Projects");
2977 char itemName[MAX_LOCATION + 4];
2980 recentFiles.Clear();
2983 for(recent : ideSettings.recentFiles)
2985 sprintf(itemName, "%d %s", 1 + c, recent);
2986 MakeSystemPath(itemName);
2987 recentFiles.AddDynamic(MenuItem { copyText = true, text = itemName, (Key)k1 + c, id = c, NotifySelect = ide.FileRecentFile }, ide, true);
2991 recentProjects.Clear();
2993 for(recent : ideSettings.recentProjects)
2995 sprintf(itemName, "%d %s", 1 + c, recent);
2996 MakeSystemPath(itemName);
2997 recentProjects.AddDynamic(MenuItem { copyText = true, text = itemName, (Key)k1 + c, id = c, NotifySelect = ide.FileRecentProject }, ide, true);
3010 void DestroyDir(char * path)
3012 RecursiveDeleteFolderFSI fsi { };
3017 class RecursiveDeleteFolderFSI : NormalFileSystemIterator
3019 bool preserveRootFolder;
3021 void OutFolder(char * folderPath, bool isRoot)
3023 if(!(preserveRootFolder && isRoot))
3024 RemoveDir(folderPath);
3027 bool OnFile(char * filePath)
3029 DeleteFile(filePath);
3034 class IDEApp : GuiApplication
3036 //driver = "Win32Console";
3037 // driver = "OpenGL";
3042 SetLoggingMode(stdOut, null);
3043 //SetLoggingMode(debug, null);
3045 settingsContainer.Load();
3046 #if defined(__unix__) || defined(__APPLE__)
3047 app.driver = (ideSettings.displayDriver && !strcmp(ideSettings.displayDriver, "OpenGL")) ? ideSettings.displayDriver : "X";
3049 app.driver = (ideSettings.displayDriver && !strcmp(ideSettings.displayDriver, "OpenGL")) ? ideSettings.displayDriver : "GDI";
3051 ide.driverItems[ideSettings.displayDriver && !strcmp(ideSettings.displayDriver,"OpenGL")].checked = true;
3055 desktop.text = titleECEREIDE;
3058 for(c = 1; c<app.argc; c++)
3060 char fullPath[MAX_LOCATION];
3061 GetWorkingDir(fullPath, MAX_LOCATION);
3062 PathCat(fullPath, app.argv[c]);
3063 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, null, yes, normal);
3070 IDEMainFrame ideMainFrame { };
3072 define app = ((IDEApp)__thisModule);
3074 define titleECEREIDE = $"ECERE IDE (Debug)";
3076 define titleECEREIDE = $"ECERE IDE";