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(true);
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 }, disabled = true;
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 }, disabled = true;
306 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
308 if(ide.workspace && ide.projectView && row && strcmp(row.string, ide.workspace.compiler))
310 bool silent = ide.projectView.buildInProgress == none ? false : true;
311 CompilerConfig compiler = ideSettings.GetCompilerConfig(row.string);
312 ide.workspace.compiler = row.string;
313 ide.projectView.ShowOutputBuildLog(!silent);
315 ide.projectView.DisplayCompiler(compiler, false);
316 for(prj : ide.workspace.projects)
317 ide.projectView.ProjectPrepareCompiler(prj, compiler, silent);
319 ide.workspace.Save();
325 DropBox activeBitDepth
327 this, toolTip = $"Active Bit Depth", size = { 60 }, disabled = true;
328 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
330 if(ide.workspace && ide.projectView && row)
332 bool silent = ide.projectView.buildInProgress == none ? false : true;
333 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
334 ide.workspace.bitDepth = (int)row.tag;
335 ide.projectView.ShowOutputBuildLog(!silent);
337 ide.projectView.DisplayCompiler(compiler, false);
338 for(prj : ide.workspace.projects)
339 ide.projectView.ProjectPrepareCompiler(prj, compiler, silent);
341 ide.workspace.Save();
347 Window spacer7 { this, size = { 4 } };
352 row = activeBitDepth.AddString("Auto");
354 activeBitDepth.AddString("32 bit").tag = 32;
355 activeBitDepth.AddString("64 bit").tag = 64;
356 activeBitDepth.currentRow = row;
361 class IDEMainFrame : Window
363 background = formColor;
364 borderStyle = sizable;
368 minClientSize = { 600, 300 };
370 icon = { ":icon.png" };
371 text = titleECEREIDE;
375 anchor = { top = 0, right = 0, bottom = 0 };
378 anchor = { left = 0, top = 0, right = 0, bottom = 0 };
385 isActiveClient = true;
387 direction = vertical;
388 background = formColor;
389 anchor = { left = 0, top = 0, right = 0, bottom = 0 };
397 ((IDEWorkSpace)master).toolBar = null;
400 IDEWorkSpace ideWorkSpace { stack, this, toolBar = toolBar };
403 define ide = ideMainFrame.ideWorkSpace;
405 class IDEWorkSpace : Window
407 background = Color { 85, 85, 85 };
410 hasVertScroll = true;
411 hasHorzScroll = true;
413 isActiveClient = true;
414 anchor = { left = 0, top = 0, right = 0, bottom = 0 };
418 MenuItem * driverItems, * skinItems;
419 StatusField pos { width = 150 };
420 StatusField ovr, caps, num;
422 BitmapResource back { ":ecereBack.jpg", window = this };
423 BitmapResource bmpBp { ":codeMarks/breakpoint.png", window = this };
424 BitmapResource bmpBpDisabled { ":codeMarks/breakpointDisabled.png", window = this };
425 BitmapResource bmpBpHalf { ":codeMarks/breakpointHalf.png", window = this };
426 BitmapResource bmpBpHalfDisabled { ":codeMarks/breakpointHalfDisabled.png", window = this };
427 BitmapResource bmpCursor { ":codeMarks/cursor.png", window = this };
428 BitmapResource bmpCursorError { ":codeMarks/cursorError.png", window = this };
429 BitmapResource bmpTopFrame { ":codeMarks/topFrame.png", window = this };
430 BitmapResource bmpTopFrameError { ":codeMarks/topFrameError.png", window = this };
431 BitmapResource bmpTopFrameHalf { ":codeMarks/topFrameHalf.png", window = this };
432 BitmapResource bmpTopFrameHalfError { ":codeMarks/topFrameHalfError.png", window = this };
434 Debugger debugger { };
436 ProjectView projectView;
438 OutputView outputView
442 void OnGotoError(char * line)
447 void OnCodeLocationParseAndGoTo(char * line)
449 ide.CodeLocationParseAndGoTo(line, ide.findInFilesDialog.findProject, ide.findInFilesDialog.findDir);
452 bool OnKeyDown(Key key, unichar ch)
457 if(!ide.findInFilesDialog || !ide.findInFilesDialog.SearchAbort())
458 ide.ShowCodeEditor();
462 OutputView::OnKeyDown(key, ch);
469 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
472 ide.RepositionWindows(false);
476 bool OnClose(bool parentClosing)
480 ide.RepositionWindows(false);
481 return parentClosing;
485 CallStackView callStackView
487 parent = this, font = { panelFont.faceName, panelFont.size };
489 void OnGotoLine(char * line)
492 stackLvl = atoi(line);
493 ide.debugger.GoToStackFrameLine(stackLvl, true);
496 void OnSelectFrame(int lineNumber)
498 ide.debugger.SelectFrame(lineNumber);
501 void OnToggleBreakpoint()
503 Debugger debugger = ide.debugger;
504 if(debugger.activeFrame && debugger.activeFrame.absoluteFile)
506 int line = debugger.activeFrame.line;
507 char name[MAX_LOCATION];
509 // TOFIX: Improve on this, don't use only filename, make a function
510 GetLastDirectory(debugger.activeFrame.absoluteFile, name);
511 if(ide && ide.workspace)
513 for(p : ide.workspace.projects)
515 if(p.topNode.Find(name, false))
523 for(p : ide.workspace.projects)
525 if(IsPathInsideOf(debugger.activeFrame.absoluteFile, p.topNode.path))
533 debugger.ToggleBreakpoint(debugger.activeFrame.absoluteFile, line, prj);
536 CodeEditor codeEditor = (CodeEditor)ide.FindWindow(debugger.activeFrame.absoluteFile);
537 if(codeEditor) { codeEditor.Update(null); Activate(); }
542 bool OnKeyDown(Key key, unichar ch)
546 case escape: ide.ShowCodeEditor(); break;
551 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
554 ide.RepositionWindows(false);
558 bool OnClose(bool parentClosing)
562 ide.RepositionWindows(false);
563 return parentClosing;
566 void OnRedraw(Surface surface)
568 Debugger debugger = ide.debugger;
569 Frame activeFrame = debugger.activeFrame;
573 int lineCursor, lineTopFrame, activeThread, hitThread;
574 int lineH, scrollY, boxH;
576 Breakpoint bp = null;
579 scrollY = editBox.scroll.y;
580 displaySystem.FontExtent(editBox.font.font, " ", 1, null, &lineH);
581 activeThread = debugger.activeThread;
582 hitThread = debugger.hitThread;
583 debugger.GetCallStackCursorLine(&error, &lineCursor, &lineTopFrame);
585 // TODO: improve bp drawing... it should be visible even if it's not on the activeFrame
586 if(activeFrame.absoluteFile)
588 for(i : ide.workspace.breakpoints; i.type == user)
590 if(i.absoluteFilePath && i.absoluteFilePath[0] &&
591 !fstrcmp(i.absoluteFilePath, activeFrame.absoluteFile) &&
592 activeFrame.line == i.line)
600 DrawLineMarginIcon(surface,
601 /*(lineCursor == 1 || lineTopFrame == 1) ? */ide.bmpBpHalf/* : ide.bmpBp*/,
602 lineCursor /*1*/, lineH, scrollY, boxH);
604 if(activeThread && activeThread == hitThread && debugger.bpHit && debugger.bpHit.type == user)
605 DrawLineMarginIcon(surface,
606 (lineCursor == 1 || lineTopFrame == 1) ? ide.bmpBpHalf : ide.bmpBp,
607 1, lineH, scrollY, boxH);
609 DrawLineMarginIcon(surface, error ? ide.bmpCursorError : ide.bmpCursor, lineCursor, lineH, scrollY, boxH);
610 if(bp && lineCursor == 1) //activeThread && activeThread == hitThread && debugger.bpHit && debugger.bpHit.type == user)
611 bmp = error ? ide.bmpTopFrameHalfError : ide.bmpTopFrameHalf;
613 bmp = error ? ide.bmpTopFrameError : ide.bmpTopFrame;
614 DrawLineMarginIcon(surface, bmp, lineTopFrame, lineH, scrollY, boxH);
616 if(editBox.horzScroll && editBox.horzScroll.visible)
618 surface.SetBackground(control);
619 surface.Area(0, editBox.clientSize.h, 20 - 1, clientSize.h - 1);
624 WatchesView watchesView { parent = this };
625 ThreadsView threadsView
627 parent = this, font = { panelFont.faceName, panelFont.size };
629 bool OnKeyDown(Key key, unichar ch)
633 case escape: ide.ShowCodeEditor(); break;
638 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
641 ide.RepositionWindows(false);
645 bool OnClose(bool parentClosing)
649 ide.RepositionWindows(false);
650 return parentClosing;
653 void OnSelectThread(int threadId)
656 ide.debugger.SelectThread(threadId);
659 bool OnGetThreadsInfo(int * activeThread, int * hitThread, int * signalThread)
662 Debugger debugger = ide.debugger;
663 *activeThread = debugger.activeThread;
664 *hitThread = debugger.hitThread;
665 *signalThread = debugger.signalThread;
670 BreakpointsView breakpointsView { parent = this };
672 ToolBox toolBox { parent = this };
673 Sheet sheet { parent = this };
676 property char * tmpPrjDir { set { delete tmpPrjDir; if(value) tmpPrjDir = CopyString(value); } get { return tmpPrjDir; } };
678 Menu fileMenu { menu, $"File", f, hasMargin = true };
681 fileMenu, $"New", n, ctrlN;
682 bitmap = { ":actions/docNew.png" };
683 bool NotifySelect(MenuItem selection, Modifiers mods)
685 Window document = (Window)NewCodeEditor(this, normal, false);
686 document.NotifySaved = DocumentSaved;
690 MenuItem fileOpenItem
692 fileMenu, $"Open...", o, ctrlO;
693 bitmap = { ":actions/docOpen.png" };
694 bool NotifySelect(MenuItem selection, Modifiers mods)
696 if(!projectView && ideSettings.ideFileDialogLocation)
697 ideFileDialog.currentDirectory = ideSettings.ideFileDialogLocation;
700 if(ideFileDialog.Modal() == ok)
702 bool gotWhatWeWant = false;
704 int numSelections = ideFileDialog.numSelections;
705 char ** multiFilePaths = ideFileDialog.multiFilePaths;
707 for(c = 0; c < numSelections; c++)
709 if(OpenFile(multiFilePaths[c], normal, true, fileTypes[ideFileDialog.fileType].typeExtension, no, normal))
710 gotWhatWeWant = true;
713 MessageBox { type = yesNo, master = this, text = $"Error opening file",
714 contents = $"Open a different file?" }.Modal() == no)
716 if(!projectView && gotWhatWeWant)
717 ChangeFileDialogsDirectory(ideFileDialog.currentDirectory, true);
727 MenuItem fileCloseItem { fileMenu, $"Close", c, ctrlF4, NotifySelect = MenuFileClose };
728 MenuDivider { fileMenu };
729 MenuItem fileSaveItem
731 fileMenu, $"Save", s, ctrlS, bitmap = { ":actions/docSave.png" };
733 // For the toolbar button; clients can still override that for the menu item
734 bool Window::NotifySelect(MenuItem selection, Modifiers mods)
736 Window w = activeClient;
738 w.MenuFileSave(null, 0);
742 MenuItem fileSaveAsItem { fileMenu, $"Save As...", a };
743 MenuItem fileSaveAllItem { fileMenu, $"Save All", l, NotifySelect = MenuFileSaveAll, bitmap = { ":actions/docSaveAll.png" } };
744 MenuDivider { fileMenu };
747 fileMenu, $"Find In Files...", f, Key { f, ctrl = true , shift = true };
748 bool NotifySelect(MenuItem selection, Modifiers mods)
750 findInFilesDialog.replaceMode = false;
751 findInFilesDialog.Show();
755 MenuItem replaceInFiles
757 fileMenu, $"Replace In Files...", e, Key { r, ctrl = true , shift = true };
758 bool NotifySelect(MenuItem selection, Modifiers mods)
760 findInFilesDialog.replaceMode = true;
761 findInFilesDialog.Show();
765 MenuDivider { fileMenu };
766 MenuItem globalSettingsItem
768 fileMenu, $"Global Settings...", g;
769 bool NotifySelect(MenuItem selection, Modifiers mods)
771 globalSettingsDialog.master = this;
772 if(ide.workspace && ide.workspace.compiler)
773 globalSettingsDialog.workspaceActiveCompiler = ide.workspace.compiler;
774 else if(ideSettings.defaultCompiler)
775 globalSettingsDialog.workspaceActiveCompiler = ideSettings.defaultCompiler;
776 globalSettingsDialog.Modal();
780 MenuDivider { fileMenu };
781 Menu recentFiles { fileMenu, $"Recent Files", r };
782 Menu recentProjects { fileMenu, $"Recent Projects", p };
783 MenuDivider { fileMenu };
786 fileMenu, $"Exit", x, altF4, NotifySelect = MenuFileExit;
788 bool NotifySelect(MenuItem selection, Modifiers mods)
790 ideMainFrame.Destroy(0);
795 bool FileRecentFile(MenuItem selection, Modifiers mods)
798 for(file : ideSettings.recentFiles)
800 if(id == selection.id)
802 if(mods.ctrl) // Menu::OnLeftButtonUp -> modifiers.ctrl == true, modifiers == 18
803 // Menu::MenuItemSelection -> key.ctrl == false, key.modifiers.ctrl == false, key == 18
804 // removing the (Key) cast from Modifiers when calling MenuItemSelection in OnLeftButtonUp didn't help
806 // it never gets in here!!!
807 char * command = PrintString("ide ", file);
812 OpenFile(file, normal, true, null, no, normal);
820 bool FileRecentProject(MenuItem selection, Modifiers mods)
823 for(file : ideSettings.recentProjects)
825 if(id == selection.id)
827 if(mods.ctrl) // Menu::OnLeftButtonUp -> modifiers.ctrl == true, modifiers == 18
828 // Menu::MenuItemSelection -> key.ctrl == false, key.modifiers.ctrl == false, key == 18
829 // removing the (Key) cast from Modifiers when calling MenuItemSelection in OnLeftButtonUp didn't help
831 // it never gets in here!!!
832 char * command = PrintString("ide ", file);
837 OpenFile(file, normal, true, null, no, normal);
845 MenuPlacement editMenu { menu, $"Edit", e };
847 Menu projectMenu { menu, $"Menu"."Project", p, hasMargin = true };
848 MenuItem projectNewItem
850 projectMenu, $"New...", n, Key { n, true, true };
851 bitmap = { ":actions/projNew.png" };
852 bool NotifySelect(MenuItem selection, Modifiers mods)
854 if(!DontTerminateDebugSession($"New Project"))
855 if(MenuWindowCloseAll(null, 0))
857 NewProjectDialog newProjectDialog;
861 projectView.visible = false;
862 if(!projectView.Destroy(0))
866 newProjectDialog = { master = this };
867 newProjectDialog.Modal();
870 ideSettings.AddRecentProject(projectView.fileName);
871 ide.UpdateRecentMenus();
872 settingsContainer.Save();
878 MenuItem projectOpenItem
880 projectMenu, $"Open...", o, Key { o, true, true };
881 bitmap = { ":actions/projOpen.png" };
882 bool NotifySelect(MenuItem selection, Modifiers mods)
884 if(ideSettings.ideProjectFileDialogLocation)
885 ideProjectFileDialog.currentDirectory = ideSettings.ideProjectFileDialogLocation;
887 ideProjectFileDialog.text = openProjectFileDialogTitle;
888 if(ideProjectFileDialog.Modal() == ok)
890 OpenFile(ideProjectFileDialog.filePath, normal, true, projectTypes[ideProjectFileDialog.fileType].typeExtension, no, normal);
891 //ChangeProjectFileDialogDirectory(ideProjectFileDialog.currentDirectory);
896 MenuItem projectQuickItem
898 projectMenu, $"Quick...", q, f7, disabled = true;
899 bool NotifySelect(MenuItem selection, Modifiers mods)
902 QuickProjectDialog { this }.Modal();
906 MenuItem projectAddItem
908 projectMenu, $"Add project to workspace...", a, Key { a, true, true };
909 bitmap = { ":actions/projAdd.png" };
911 bool NotifySelect(MenuItem selection, Modifiers mods)
913 if(ideSettings.ideProjectFileDialogLocation)
914 ideProjectFileDialog.currentDirectory = ideSettings.ideProjectFileDialogLocation;
916 ideProjectFileDialog.text = addProjectFileDialogTitle;
919 if(ideProjectFileDialog.Modal() == ok)
921 if(OpenFile(ideProjectFileDialog.filePath, normal, true, projectTypes[ideProjectFileDialog.fileType].typeExtension, no, add))
923 if(MessageBox { type = yesNo, master = this, text = $"Error opening project file",
924 contents = $"Add a different project?" }.Modal() == no)
935 MenuItem projectCloseItem
937 projectMenu, $"Close", c, disabled = true;
938 bool NotifySelect(MenuItem selection, Modifiers mods)
942 if(!ide.DontTerminateDebugSession($"Project Close"))
944 if(findInFilesDialog)
945 findInFilesDialog.SearchStop();
946 projectView.visible = false;
947 if(projectView.Destroy(0))
948 MenuWindowCloseAll(null, 0);
950 char workingDir[MAX_LOCATION];
951 GetWorkingDir(workingDir, MAX_LOCATION);
952 findInFilesDialog.currentDirectory = workingDir;
953 ideMainFrame.text = titleECEREIDE;
961 MenuDivider { projectMenu };
962 MenuItem projectSettingsItem
964 projectMenu, $"Settings...", s, altF7, disabled = true;
965 bool NotifySelect(MenuItem selection, Modifiers mods)
967 projectView.MenuSettings(projectView.active ? selection : null, mods);
971 MenuDivider { projectMenu };
972 MenuItem projectBrowseFolderItem
974 projectMenu, $"Browse Project Folder", p, disabled = true;
975 bool NotifySelect(MenuItem selection, Modifiers mods)
978 projectView.MenuBrowseFolder(null, mods);
982 MenuDivider { projectMenu };
983 MenuItem projectRunItem
985 projectMenu, $"Run", r, ctrlF5, disabled = true;
986 bitmap = { ":actions/run.png" };
987 bool NotifySelect(MenuItem selection, Modifiers mods)
990 projectView.Run(null, mods);
994 MenuItem projectBuildItem
996 projectMenu, $"Build", b, f7, disabled = true;
997 bitmap = { ":actions/build.png" };
998 bool NotifySelect(MenuItem selection, Modifiers mods)
1002 if(projectView.buildInProgress == none)
1003 projectView.ProjectBuild(projectView.active ? selection : null, mods);
1005 projectView.stopBuild = true;
1010 MenuItem projectLinkItem
1012 projectMenu, $"Relink", l, disabled = true;
1013 bitmap = { ":actions/relink.png" };
1014 bool NotifySelect(MenuItem selection, Modifiers mods)
1017 projectView.ProjectLink(projectView.active ? selection : null, mods);
1021 MenuItem projectRebuildItem
1023 projectMenu, $"Rebuild", d, shiftF7, disabled = true;
1024 bitmap = { ":actions/rebuild.png" };
1025 bool NotifySelect(MenuItem selection, Modifiers mods)
1028 projectView.ProjectRebuild(projectView.active ? selection : null, mods);
1032 MenuItem projectCleanItem
1034 projectMenu, $"Clean", e, disabled = true;
1035 bitmap = { ":actions/clean.png" };
1036 bool NotifySelect(MenuItem selection, Modifiers mods)
1041 projectView.ProjectClean(projectView.active ? selection : null, mods);
1046 MenuItem projectRealCleanItem
1048 projectMenu, $"Real Clean", disabled = true;
1049 bitmap = { ":actions/clean.png" };
1050 bool NotifySelect(MenuItem selection, Modifiers mods)
1055 projectView.ProjectRealClean(projectView.active ? selection : null, mods);
1060 MenuItem projectRegenerateItem
1062 projectMenu, $"Regenerate Makefile", m, disabled = true;
1063 bitmap = { ":actions/regMakefile.png" };
1064 bool NotifySelect(MenuItem selection, Modifiers mods)
1067 projectView.ProjectRegenerate(projectView.active ? selection : null, mods);
1071 MenuItem projectCompileItem;
1072 Menu debugMenu { menu, $"Debug", d, hasMargin = true };
1073 MenuItem debugStartResumeItem
1075 debugMenu, $"Start", s, f5, disabled = true;
1076 bitmap = { ":actions/debug.png" };
1077 NotifySelect = MenuDebugStart;
1079 bool MenuDebugStart(MenuItem selection, Modifiers mods)
1083 debugStartResumeItem.disabled = true; // a very rare exception to calling AdjustDebugMenus
1084 if(!projectView.DebugStart())
1085 debugStartResumeItem.disabled = false; // same exception
1089 bool MenuDebugResume(MenuItem selection, Modifiers mods)
1092 projectView.DebugResume();
1095 MenuItem debugRestartItem
1097 debugMenu, $"Restart", r, Key { f5, ctrl = true, shift = true }, disabled = true;
1098 bitmap = { ":actions/restart.png" };
1099 bool NotifySelect(MenuItem selection, Modifiers mods)
1102 projectView.DebugRestart();
1106 MenuItem debugBreakItem
1108 debugMenu, $"Break", b, Key { pauseBreak, ctrl = true }, disabled = true;
1109 bitmap = { ":actions/pause.png" };
1110 bool NotifySelect(MenuItem selection, Modifiers mods)
1112 if(projectView && projectView.buildInProgress != none)
1115 projectView.DebugBreak();
1119 MenuItem debugStopItem
1121 debugMenu, $"Stop", p, shiftF5, disabled = true;
1122 bitmap = { ":actions/stopDebug.png" };
1123 bool NotifySelect(MenuItem selection, Modifiers mods)
1126 projectView.DebugStop();
1130 MenuDivider { debugMenu };
1131 MenuItem debugStepIntoItem
1133 debugMenu, $"Step Into", i, f11, disabled = true;
1134 bitmap = { ":actions/stepInto.png" };
1135 bool NotifySelect(MenuItem selection, Modifiers mods)
1138 projectView.DebugStepInto();
1142 MenuItem debugStepOverItem
1144 debugMenu, $"Step Over", v, f10, disabled = true;
1145 bitmap = { ":actions/stepOver.png" };
1146 bool NotifySelect(MenuItem selection, Modifiers mods)
1149 projectView.DebugStepOver(false);
1153 MenuItem debugStepOutItem
1155 debugMenu, $"Step Out", o, shiftF11, disabled = true;
1156 bitmap = { ":actions/stepOut.png" };
1157 bool NotifySelect(MenuItem selection, Modifiers mods)
1160 projectView.DebugStepOut(false);
1164 MenuPlacement debugRunToCursorItem { debugMenu, $"Run To Cursor", c };
1165 MenuItem debugSkipStepOverItem
1167 debugMenu, $"Step Over Skipping Breakpoints", e, shiftF10, disabled = true;
1168 bool NotifySelect(MenuItem selection, Modifiers mods)
1171 projectView.DebugStepOver(true);
1175 MenuItem debugSkipStepOutItem
1177 debugMenu, $"Step Out Skipping Breakpoints", t, Key { f11, ctrl = true, shift = true }, disabled = true;
1178 bitmap = { ":actions/skipBreaks.png" };
1179 bool NotifySelect(MenuItem selection, Modifiers mods)
1182 projectView.DebugStepOut(true);
1186 MenuPlacement debugSkipRunToCursorItem { debugMenu, $"Run To Cursor Skipping Breakpoints", u };
1187 //MenuDivider { debugMenu };
1188 //MenuPlacement debugToggleBreakpoint { debugMenu, "Toggle Breakpoint", t };
1189 MenuPlacement imageMenu { menu, $"Image", i };
1190 Menu viewMenu { menu, $"View", v };
1191 MenuItem viewProjectItem
1193 viewMenu, $"Project View", j, alt0, disabled = true;
1194 bool NotifySelect(MenuItem selection, Modifiers mods)
1198 projectView.visible = true;
1199 projectView.Activate();
1204 MenuPlacement { viewMenu, $"View Designer" };
1205 MenuPlacement { viewMenu, $"View Code" };
1206 MenuPlacement { viewMenu, $"View Properties" };
1207 MenuPlacement { viewMenu, $"View Methods" };
1208 MenuItem viewDesignerItem
1210 viewMenu, $"View Designer", d, f8;
1211 bool NotifySelect(MenuItem selection, Modifiers mods)
1213 Window client = activeClient;
1214 Class dataType = client._class;
1215 if(!strcmp(dataType.name, "Designer"))
1217 client.visible = true;
1221 ((CodeEditor)client).ViewDesigner();
1225 MenuItem viewCodeItem
1227 viewMenu, $"View Code", c, f8;
1228 bool NotifySelect(MenuItem selection, Modifiers mods)
1230 Window client = activeClient;
1231 Class dataType = client._class;
1232 if(!strcmp(dataType.name, "Designer"))
1233 client = ((Designer)client).codeEditor;
1236 // Do this after so the caret isn't moved yet...
1237 client.visible = true;
1241 MenuItem viewPropertiesItem
1243 viewMenu, $"View Properties", p, f4;
1244 bool NotifySelect(MenuItem selection, Modifiers mods)
1246 sheet.visible = true;
1247 sheet.sheetSelected = properties;
1252 MenuItem viewMethodsItem
1254 viewMenu, $"View Methods", m, f4;
1255 bool NotifySelect(MenuItem selection, Modifiers mods)
1257 sheet.visible = true;
1258 sheet.sheetSelected = methods;
1263 MenuItem viewToolBoxItem
1265 viewMenu, $"View Toolbox", x, f12;
1266 bool NotifySelect(MenuItem selection, Modifiers mods)
1268 toolBox.visible = true;
1273 MenuItem viewOutputItem
1275 viewMenu, $"Output", o, alt2;
1276 bool NotifySelect(MenuItem selection, Modifiers mods)
1282 MenuItem viewWatchesItem
1284 viewMenu, $"Watches", w, alt3;
1285 bool NotifySelect(MenuItem selection, Modifiers mods)
1291 MenuItem viewThreadsItem
1293 viewMenu, $"Threads", t, alt4;
1294 bool NotifySelect(MenuItem selection, Modifiers mods)
1300 MenuItem viewBreakpointsItem
1302 viewMenu, $"Breakpoints", b, alt5;
1303 bool NotifySelect(MenuItem selection, Modifiers mods)
1305 breakpointsView.Show();
1309 MenuItem viewCallStackItem
1311 viewMenu, $"Call Stack", s, alt7;
1312 bool NotifySelect(MenuItem selection, Modifiers mods)
1314 callStackView.Show();
1318 MenuItem viewAllDebugViews
1320 viewMenu, $"All Debug Views", a, alt9;
1321 bool NotifySelect(MenuItem selection, Modifiers mods)
1326 callStackView.Show();
1327 breakpointsView.Show();
1331 #ifdef GDB_DEBUG_GUI
1332 MenuDivider { viewMenu };
1333 MenuItem viewGDBItem
1335 viewMenu, $"GDB Dialog", g, Key { f9, shift = true, ctrl = true };
1336 bool NotifySelect(MenuItem selection, Modifiers mods)
1343 MenuDivider { viewMenu };
1344 MenuItem viewColorPicker
1346 viewMenu, $"Color Picker...", c, Key { c, ctrl = true , shift = true };
1347 bool NotifySelect(MenuItem selection, Modifiers mods)
1349 ColorPicker colorPicker { master = this, parent = this, stayOnTop = true };
1350 colorPicker.Create();
1354 MenuDivider { viewMenu };
1358 viewMenu, "Full Screen", f, checkable = true;
1360 bool NotifySelect(MenuItem selection, Modifiers mods)
1362 app.fullScreen ^= true;
1364 anchor = { 0, 0, 0, 0 };
1369 Menu driversMenu { viewMenu, $"Graphics Driver", v };
1370 //Menu skinsMenu { viewMenu, "GUI Skins", k };
1371 Menu windowMenu { menu, $"Window", w };
1372 MenuItem { windowMenu, $"Close All", l, NotifySelect = MenuWindowCloseAll };
1373 MenuDivider { windowMenu };
1374 MenuItem { windowMenu, $"Next", n, f6, NotifySelect = MenuWindowNext };
1375 MenuItem { windowMenu, $"Previous", p, shiftF6, NotifySelect = MenuWindowPrevious };
1376 MenuDivider { windowMenu };
1377 MenuItem { windowMenu, $"Cascade", c, NotifySelect = MenuWindowCascade };
1378 MenuItem { windowMenu, $"Tile Horizontally", h, NotifySelect = MenuWindowTileHorz };
1379 MenuItem { windowMenu, $"Tile Vertically", v, NotifySelect = MenuWindowTileVert };
1380 MenuItem { windowMenu, $"Arrange Icons", a, NotifySelect = MenuWindowArrangeIcons };
1381 MenuDivider { windowMenu };
1382 MenuItem { windowMenu, $"Windows...", w, NotifySelect = MenuWindowWindows };
1383 Menu helpMenu { menu, $"Help", h };
1386 helpMenu, $"API Reference", r, f1;
1387 bool NotifySelect(MenuItem selection, Modifiers mods)
1389 Execute("documentor");
1393 MenuDivider { helpMenu };
1396 helpMenu, $"About...", a;
1397 bool NotifySelect(MenuItem selection, Modifiers mods)
1399 AboutIDE { master = this }.Modal();
1404 property ToolBox toolBox
1406 get { return toolBox; }
1409 property Sheet sheet
1411 get { return sheet; }
1414 property Project project
1416 get { return projectView ? projectView.project : null; }
1419 property Workspace workspace
1421 get { return projectView ? projectView.workspace : null; }
1424 FindInFilesDialog findInFilesDialog
1427 filters = findInFilesFileFilters.array, sizeFilters = findInFilesFileFilters.count * sizeof(FileFilter);
1431 #ifdef GDB_DEBUG_GUI
1434 master = this, parent = this;
1435 anchor = { left = 100, top = 100, right = 100, bottom = 100 };
1437 void OnCommand(char * string)
1440 ide.debugger.SendGDBCommand(string);
1445 bool NotifySelectDisplayDriver(MenuItem selection, Modifiers mods)
1447 //app.driver = app.drivers[selection.id];
1448 #if defined(__unix__) || defined(__APPLE__)
1449 app.driver = selection.id ? "OpenGL" : "X";
1451 app.driver = selection.id ? "OpenGL" : "GDI";
1453 delete ideSettings.displayDriver;
1454 ideSettings.displayDriver = CopyString(selection.id ? "OpenGL" : "Default");
1456 settingsContainer.Save();
1457 //SetDriverAndSkin();
1461 bool NotifySelectDisplaySkin(MenuItem selection, Modifiers mods)
1463 app.skin = app.skins[selection.id];
1468 void SetDriverAndSkin()
1471 for(c = 0; c < app.numSkins; c++)
1472 if(!strcmp(app.skins[c], app.skin))
1474 skinItems[c].checked = true;
1477 for(c = 0; c < app.numDrivers; c++)
1478 if(!strcmp(app.drivers[c], app.driver))
1480 driverItems[c].checked = true;
1485 ProjectView CreateProjectView(Workspace workspace, char * fileName)
1487 Project project = workspace.projects.firstIterator.data;
1488 projectView = ProjectView
1491 fileName = fileName;
1493 void NotifyDestroyed(Window window, DialogResult result)
1496 text = titleECEREIDE;
1501 projectView.Create();
1502 RepositionWindows(false);
1504 // Leave it after Create to avoid flicker due to seeing IDE without a project view
1505 projectView.workspace = workspace;
1506 projectView.project = project;
1507 ideMainFrame.SetText("%s - %s", project.topNode.name, titleECEREIDE);
1511 ide.breakpointsView.LoadFromWorkspace();
1512 ide.watchesView.LoadFromWorkspace();
1514 findInFilesDialog.projectNodeField.userData = projectView;
1517 char fileName[MAX_LOCATION];
1518 strcpy(fileName, project.topNode.path);
1519 PathCat(fileName, project.topNode.name);
1524 bool GetDebugMenusDisabled()
1528 Project project = projectView.project;
1530 if(project.GetTargetType(project.config) == executable)
1537 void RepositionWindows(bool expand)
1542 bool inDebugMode = debugger.isActive;
1543 bool callStackVisible = expand ? false : callStackView.visible;
1544 bool threadsVisible = expand ? false : threadsView.visible;
1545 bool watchesVisible = expand ? false : watchesView.visible;
1546 bool breakpointsVisible = expand ? false : breakpointsView.visible;
1547 bool toolBoxVisible = toolBox.visible;
1548 bool outputVisible = expand ? false : outputView.visible;
1549 int topDistance = (callStackVisible || threadsVisible) ? 200 : 0;
1550 int bottomDistance = (outputVisible || watchesVisible || breakpointsVisible) ? 240 : 0;
1552 for(child = firstChild; child; child = child.next)
1554 if(child._class == class(CodeEditor) || child._class == class(Designer) ||
1555 child._class == class(Sheet) || child._class == class(ProjectView))
1557 Anchor anchor = child.anchor;
1558 anchor.top = topDistance;
1559 anchor.bottom = bottomDistance;
1560 if(child._class == class(CodeEditor) || child._class == class(Designer))
1562 anchor.right = toolBoxVisible ? 150 : 0;
1564 child.anchor = anchor;
1568 if(child._class == class(OutputView) || child._class == class(CallStackView) || child._class == class(ThreadsView) || child._class == class(WatchesView) ||
1569 child._class == class(BreakpointsView))
1570 child.visible = false;
1573 // If this is not here, the IDE is not updated when doing Debug/Break then Alt-4 to show call stack (IDE not updated)
1578 bool ShowCodeEditor()
1581 activeClient.Activate();
1582 else if(projectView)
1584 projectView.visible = true;
1585 projectView.Activate();
1589 sheet.visible = true;
1595 bool ShouldStopBuild()
1597 return projectView.stopBuild;
1600 void DocumentSaved(Window document, char * fileName)
1602 ideSettings.AddRecentFile(fileName);
1603 ide.UpdateRecentMenus();
1604 ide.AdjustFileMenus();
1605 settingsContainer.Save();
1608 bool Window::OnFileModified(FileChange fileChange, char * param)
1611 sprintf(temp, $"The document %s was modified by another application.\n"
1612 "Would you like to reload it and lose your changes?", this.fileName);
1613 if(MessageBox { type = yesNo, master = this/*.parent*/,
1614 text = $"Document has been modified", contents = temp }.Modal() == yes)
1616 char * fileName = CopyString(this.fileName);
1617 WindowState state = this.state;
1618 Anchor anchor = this.anchor;
1619 Size size = this.size;
1621 this.modifiedDocument = false;
1623 this = ide.OpenFile(fileName, normal, true, null, no, normal);
1626 this.anchor = anchor;
1628 this.SetState(state, true, 0);
1636 void UpdateMakefiles()
1640 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
1641 for(prj : workspace.projects)
1642 projectView.ProjectUpdateMakefileForAllConfigs(prj);
1647 void UpdateCompilerConfigs(bool mute)
1649 UpdateToolBarActiveCompilers();
1652 bool silent = mute || (ide.projectView.buildInProgress == none ? false : true);
1653 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
1656 projectView.ShowOutputBuildLog(true);
1657 projectView.DisplayCompiler(compiler, false);
1659 for(prj : workspace.projects)
1660 projectView.ProjectPrepareCompiler(prj, compiler, silent);
1665 void UpdateToolBarActiveCompilers()
1667 toolBar.activeCompiler.Clear();
1668 for(compiler : ideSettings.compilerConfigs)
1670 DataRow row = toolBar.activeCompiler.AddString(compiler.name);
1671 if(workspace && workspace.compiler && !strcmp(compiler.name, workspace.compiler))
1672 toolBar.activeCompiler.currentRow = row;
1674 if(!toolBar.activeCompiler.currentRow && toolBar.activeCompiler.firstRow)
1675 toolBar.activeCompiler.SelectRow(toolBar.activeCompiler.firstRow);
1678 void UpdateToolBarActiveConfigs(bool selectionOnly)
1680 bool commonSelected = false;
1681 DataRow row = toolBar.activeConfig.currentRow;
1683 row = toolBar.activeConfig.FindRow(1);
1686 toolBar.activeConfig.Clear();
1687 row = toolBar.activeConfig.AddString("(Mixed)");
1692 char * configName = null;
1695 Map<String, int> configs { }; // TOIMP: just need sort but using map until containers have sort
1696 for(prj : workspace.projects)
1698 for(cfg : prj.configurations)
1701 configs[cfg.name] = 1;
1706 toolBar.activeConfig.AddString(&name);
1710 if(projectView && projectView.project)
1712 for(prj : workspace.projects)
1714 if(prj.config && prj.config.name)
1716 configName = prj.config.name;
1722 commonSelected = true;
1723 for(prj : workspace.projects)
1725 if(prj.config && (!prj.config.name || strcmp(prj.config.name, configName)))
1727 commonSelected = false;
1735 commonSelected = false;
1736 for(row = toolBar.activeConfig.firstRow; row; row = row.next)
1738 if(!strcmp(row.string, configName))
1740 toolBar.activeConfig.currentRow = row;
1741 commonSelected = true;
1748 toolBar.activeConfig.Sort(null, 0);
1750 toolBar.activeConfig.currentRow = row;
1755 bool unavailable = !project;
1757 projectAddItem.disabled = unavailable;
1758 toolBar.buttonAddProject.disabled = unavailable;
1760 projectSettingsItem.disabled = unavailable;
1762 projectBrowseFolderItem.disabled = unavailable;
1764 viewProjectItem.disabled = unavailable;
1766 toolBar.activeConfig.disabled = unavailable;
1767 toolBar.activeCompiler.disabled = unavailable;
1768 toolBar.activeBitDepth.disabled = unavailable;
1775 property bool hasOpenedCodeEditors
1780 for(w = firstChild; w; w = w.next)
1781 if(w._class == class(CodeEditor) &&
1782 w.isDocument && !w.closing && w.visible && w.created &&
1783 w.fileName && w.fileName[0])
1789 void AdjustFileMenus()
1791 bool unavailable = project != null || !hasOpenedCodeEditors; // are they supported source code (ec, c, cpp, etc) ?
1793 projectQuickItem.disabled = unavailable;
1796 void AdjustBuildMenus()
1798 bool unavailable = project && projectView.buildInProgress;
1800 projectNewItem.disabled = unavailable;
1801 toolBar.buttonNewProject.disabled = unavailable;
1802 projectOpenItem.disabled = unavailable;
1803 toolBar.buttonOpenProject.disabled = unavailable;
1805 unavailable = !project || projectView.buildInProgress;
1807 projectCloseItem.disabled = unavailable;
1808 // toolBar.buttonCloseProject.disabled = unavailable;
1810 projectRunItem.disabled = unavailable || project.GetTargetType(project.config) != executable;
1811 toolBar.buttonRun.disabled = unavailable || project.GetTargetType(project.config) != executable;
1813 projectBuildItem.disabled = false;
1814 projectBuildItem.text = unavailable ? $"Stop Build" : $"Build";
1815 projectBuildItem.accelerator = unavailable ? Key { pauseBreak, ctrl = true } : f7;
1817 projectLinkItem.disabled = unavailable;
1818 toolBar.buttonReLink.disabled = unavailable;
1819 projectRebuildItem.disabled = unavailable;
1820 toolBar.buttonRebuild.disabled = unavailable;
1821 projectCleanItem.disabled = unavailable;
1822 toolBar.buttonClean.disabled = unavailable;
1823 projectRealCleanItem.disabled = unavailable;
1824 // toolBar.buttonRealClean.disabled = unavailable;
1825 projectRegenerateItem.disabled = unavailable;
1826 toolBar.buttonRegenerateMakefile.disabled = unavailable;
1827 projectCompileItem.disabled = unavailable;
1829 AdjustPopupBuildMenus();
1832 void AdjustPopupBuildMenus()
1834 bool unavailable = !project || projectView.buildInProgress;
1836 if(projectView && projectView.popupMenu && projectView.popupMenu.menu && projectView.popupMenu.created)
1839 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectBuild, 0);
1842 menu.disabled = false;
1843 menu.text = unavailable ? $"Stop Build" : $"Build";
1844 menu.accelerator = unavailable ? Key { pauseBreak, ctrl = true } : f7;
1847 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectLink, 0); if(menu) menu.disabled = unavailable;
1848 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRebuild, 0); if(menu) menu.disabled = unavailable;
1849 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectClean, 0); if(menu) menu.disabled = unavailable;
1850 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRealClean, 0); if(menu) menu.disabled = unavailable;
1851 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRegenerate, 0); if(menu) menu.disabled = unavailable;
1852 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRemove, 0); if(menu) menu.disabled = unavailable;
1853 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileClean, 0); if(menu) menu.disabled = unavailable;
1854 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileCompile, 0); if(menu) menu.disabled = unavailable;
1855 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugPrecompile, 0); if(menu) menu.disabled = unavailable;
1856 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugCompile, 0); if(menu) menu.disabled = unavailable;
1857 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugGenerateSymbols, 0); if(menu) menu.disabled = unavailable;
1858 projectView.popupMenu.Update(null);
1862 void AdjustDebugMenus()
1864 bool unavailable = !project || project.GetTargetType(project.config) != executable ||
1865 projectView.buildInProgress == buildingMainProject;
1866 bool active = ide.debugger.isActive;
1867 bool executing = ide.debugger.state == running;
1868 //bool holding = ide.debugger.state == stopped;
1870 debugStartResumeItem.disabled = unavailable || executing;
1871 debugStartResumeItem.text = active ? $"Resume" : $"Start";
1872 debugStartResumeItem.NotifySelect = active ? MenuDebugResume : MenuDebugStart;
1875 toolBar.buttonDebugStartResume.disabled = unavailable || executing;
1876 toolBar.buttonDebugStartResume.toolTip = active ? $"Resume" : $"Start";
1879 debugBreakItem.disabled = unavailable || !executing;
1880 debugStopItem.disabled = unavailable || !active;
1881 debugRestartItem.disabled = unavailable || !active;
1884 toolBar.buttonDebugPause.disabled = unavailable || !executing;
1885 toolBar.buttonDebugStop.disabled = unavailable || !active;
1886 toolBar.buttonDebugRestart.disabled = unavailable || !active;
1889 debugStepIntoItem.disabled = unavailable || executing;
1890 debugStepOverItem.disabled = unavailable || executing;
1891 debugStepOutItem.disabled = unavailable || executing || !active;
1892 debugSkipStepOverItem.disabled = unavailable || executing;
1893 debugSkipStepOutItem.disabled = unavailable || executing || !active;
1896 toolBar.buttonDebugStepInto.disabled = unavailable || executing;
1897 toolBar.buttonDebugStepOver.disabled = unavailable || executing;
1898 toolBar.buttonDebugStepOut.disabled = unavailable || executing || !active;
1899 toolBar.buttonDebugSkipStepOver.disabled = unavailable || executing;
1900 // toolBar.buttonDebugSkipStepOutItem.disabled = unavailable || executing;
1902 if((Designer)GetActiveDesigner())
1904 CodeEditor codeEditor = ((Designer)GetActiveDesigner()).codeEditor;
1907 codeEditor.debugRunToCursor.disabled = unavailable || executing;
1908 codeEditor.debugSkipRunToCursor.disabled = unavailable || executing;
1913 void ChangeFileDialogsDirectory(char * directory, bool saveSettings)
1915 char tempString[MAX_LOCATION];
1916 strcpy(tempString, directory);
1917 if(saveSettings && !projectView)
1919 ideSettings.ideFileDialogLocation = directory;
1920 settingsContainer.Save();
1923 ideFileDialog.currentDirectory = tempString;
1924 codeEditorFileDialog.currentDirectory = tempString;
1925 codeEditorFormFileDialog.currentDirectory = tempString;
1928 void ChangeProjectFileDialogDirectory(char * directory)
1930 ideSettings.ideProjectFileDialogLocation = directory;
1931 settingsContainer.Save();
1934 Window FindWindow(char * filePath)
1936 Window document = null;
1938 // TOCHECK: Do we need to change slashes here?
1939 for(document = firstChild; document; document = document.next)
1941 char * fileName = document.fileName;
1942 if(document.isDocument && fileName && !fstrcmp(fileName, filePath))
1944 document.visible = true;
1945 document.Activate();
1952 bool DontTerminateDebugSession(char * title)
1954 if(debugger.isActive)
1956 if(MessageBox { type = yesNo, master = ide,
1957 contents = $"Do you want to terminate the debugging session in progress?",
1958 text = title }.Modal() == no)
1961 MessageBox msg { type = yesNo, master = ide,
1962 contents = "Do you want to terminate the debugging session in progress?",
1964 if(msg.Modal() == no)
1976 Window OpenFile(char * origFilePath, WindowState state, bool visible, char * type, OpenCreateIfFails createIfFails, OpenMethod openMethod)
1978 char extension[MAX_EXTENSION] = "";
1979 Window document = null;
1980 bool isProject = false;
1981 bool needFileModified = true;
1982 char winFilePath[MAX_LOCATION];
1983 char * filePath = strstr(origFilePath, "http://") == origFilePath ? strcpy(winFilePath, origFilePath) : GetSystemPathBuffer(winFilePath, origFilePath);
1987 GetExtension(filePath, extension);
1991 strcpy(extension, type);
1993 if(strcmp(extension, ProjectExtension))
1995 for(document = firstChild; document; document = document.next)
1997 char * fileName = document.fileName;
1998 if(document.isDocument && fileName && !fstrcmp(fileName, filePath) && document.created)
2000 document.visible = true;
2002 document.Activate();
2008 if(createIfFails == whatever)
2010 else if(!strcmp(extension, ProjectExtension) || !strcmp(extension, WorkspaceExtension))
2012 needFileModified = false;
2013 if(openMethod == normal)
2015 if(DontTerminateDebugSession($"Open Project"))
2018 if(MenuWindowCloseAll(null, 0))
2022 projectView.visible = false;
2023 projectView.Destroy(0);
2024 // Where did this come from? projectView = null;
2031 Workspace workspace = null;
2033 if(FileExists(filePath))
2035 if(!strcmp(extension, ProjectExtension))
2037 char workspaceFile[MAX_LOCATION];
2038 strcpy(workspaceFile, filePath);
2039 ChangeExtension(workspaceFile, WorkspaceExtension, workspaceFile);
2040 workspace = LoadWorkspace(workspaceFile, filePath);
2042 else if(!strcmp(extension, WorkspaceExtension))
2043 workspace = LoadWorkspace(filePath, null);
2046 //project = LoadProject(filePath, null);
2051 char absolutePath[MAX_LOCATION];
2052 CreateProjectView(workspace, filePath);
2053 document = projectView;
2055 workspace.DropInvalidBreakpoints();
2058 ide.projectView.ShowOutputBuildLog(true);
2060 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
2061 ide.projectView.DisplayCompiler(compiler, false);
2064 UpdateCompilerConfigs(false);
2067 char newWorkingDir[MAX_LOCATION];
2068 StripLastDirectory(filePath, newWorkingDir);
2069 ChangeFileDialogsDirectory(newWorkingDir, false);
2072 document.fileName = filePath;
2074 ideMainFrame.SetText("%s - %s", filePath, titleECEREIDE);
2076 // this crashes on starting ide with epj file, solution please?
2077 // app.UpdateDisplay();
2079 workspace.holdTracking = true;
2080 for(ofi : workspace.openedFiles)
2082 if(ofi.state != closed)
2084 Window file = OpenFile(ofi.path, normal, true, null, no, normal);
2087 char fileName[MAX_LOCATION];
2089 GetLastDirectory(ofi.path, fileName);
2090 node = projectView.project.topNode.Find(fileName, true);
2092 node.EnsureVisible();
2096 workspace.holdTracking = false;
2098 workspace.timer.Start();
2100 findInFilesDialog.mode = FindInFilesMode::project;
2101 findInFilesDialog.currentDirectory = ide.project.topNode.path;
2104 char location[MAX_LOCATION];
2105 StripLastDirectory(ide.project.topNode.path, location);
2106 ChangeProjectFileDialogDirectory(location);
2110 if(projectView.debugger)
2111 projectView.debugger.EvaluateWatches();
2118 if(MessageBox { type = yesNo, master = this, text = $"Error opening project", contents = $"Open a different project?" }.Modal() == yes)
2120 ideProjectFileDialog.text = openProjectFileDialogTitle;
2121 if(ideProjectFileDialog.Modal() == cancel)
2123 filePath = ideProjectFileDialog.filePath;
2124 GetExtension(filePath, extension);
2135 else if(openMethod == add)
2140 char slashFilePath[MAX_LOCATION];
2141 GetSlashPathBuffer(slashFilePath, filePath);
2142 for(p : workspace.projects)
2144 if(!fstrcmp(p.filePath, slashFilePath))
2152 MessageBox { type = ok, parent = parent, master = this, text = $"Same Project",
2153 contents = $"This project is already present in workspace." }.Modal();
2157 prj = LoadProject(filePath, null);
2160 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
2161 prj.StartMonitoring();
2162 workspace.projects.Add(prj);
2164 projectView.AddNode(prj.topNode, null);
2165 workspace.modified = true;
2167 findInFilesDialog.AddProjectItem(prj);
2168 projectView.ShowOutputBuildLog(true);
2169 projectView.DisplayCompiler(compiler, false);
2170 projectView.ProjectUpdateMakefileForAllConfigs(prj);
2174 char location[MAX_LOCATION];
2175 StripLastDirectory(prj.topNode.path, location);
2176 ChangeProjectFileDialogDirectory(location);
2179 // projectView is associated with the main project and not with the one just added but
2180 return projectView; // just to let the caller know something was opened
2188 else if(!strcmp(extension, "bmp") || !strcmp(extension, "pcx") ||
2189 !strcmp(extension, "jpg") || !strcmp(extension, "gif") ||
2190 !strcmp(extension, "jpeg") || !strcmp(extension, "png"))
2192 if(FileExists(filePath))
2193 document = PictureEdit { hasMaximize = true, hasMinimize = true, hasClose = true, borderStyle = sizable,
2194 hasVertScroll = true, hasHorzScroll = true, parent = this, state = state,
2195 visible = visible, bitmapFile = filePath, OnClose = PictureEditOnClose/*why?--GenericDocumentOnClose*/;
2198 MessageBox { type = ok, master = this, text = filePath, contents = $"File doesn't exist." }.Modal();
2201 else if(!strcmp(extension, "3ds"))
2203 if(FileExists(filePath))
2204 document = ModelView { hasMaximize = true, hasMinimize = true, hasClose = true, borderStyle = sizable,
2205 hasVertScroll = true, hasHorzScroll = true, parent = this, state = state,
2206 visible = visible, modelFile = filePath, OnClose = ModelViewOnClose/*why?--GenericDocumentOnClose*/
2210 MessageBox { type = ok, master = this, text = filePath, contents = $"File doesn't exist." }.Modal();
2213 else if(!strcmp(extension, "txt") || !strcmp(extension, "text") ||
2214 !strcmp(extension, "nfo") || !strcmp(extension, "info") ||
2215 !strcmp(extension, "htm") || !strcmp(extension, "html") ||
2216 !strcmp(extension, "css") || !strcmp(extension, "php") ||
2217 !strcmp(extension, "js"))
2219 CodeEditor editor { parent = this, state = state, visible = false };
2220 editor.updatingCode = true;
2221 if(editor.LoadFile(filePath))
2224 editor.visible = true;
2228 needFileModified = false;
2232 CodeEditor editor { parent = this, state = state, visible = false };
2233 if(editor.LoadFile(filePath))
2236 editor.visible = true;
2240 needFileModified = false;
2243 if(document && (document._class == class(PictureEdit) ||
2244 document._class == class(ModelView)))
2249 document.fileName = filePath;
2250 if(workspace && !workspace.holdTracking)
2251 workspace.UpdateOpenedFileInfo(filePath, opened);
2255 if(!document && createIfFails != no)
2257 if(createIfFails != yes && !needFileModified &&
2258 MessageBox { type = yesNo, master = this, text = filePath, contents = $"File doesn't exist. Create?" }.Modal() == yes)
2259 createIfFails = yes;
2260 if(createIfFails == yes || createIfFails == whatever)
2262 document = (Window)NewCodeEditor(this, state, true);
2264 document.fileName = filePath;
2270 if(projectView && document._class == class(CodeEditor) && workspace)
2272 int lineNumber, position;
2274 CodeEditor editor = (CodeEditor)document;
2275 editor.openedFileInfo = workspace.UpdateOpenedFileInfo(filePath, opened);
2276 editor.openedFileInfo.holdTracking = true;
2277 lineNumber = Max(editor.openedFileInfo.lineNumber - 1, 0);
2278 position = Max(editor.openedFileInfo.position - 1, 0);
2279 editor.editBox.GoToLineNum(lineNumber);
2280 editor.editBox.GoToPosition(editor.editBox.line, lineNumber, position);
2281 scroll.x = Max(editor.openedFileInfo.scroll.x, 0);
2282 scroll.y = Max(editor.openedFileInfo.scroll.y, 0);
2283 editor.editBox.scroll = scroll;
2284 editor.openedFileInfo.holdTracking = false;
2287 if(needFileModified)
2288 document.OnFileModified = OnFileModified;
2289 document.NotifySaved = DocumentSaved;
2292 ideSettings.AddRecentProject(document.fileName);
2294 ideSettings.AddRecentFile(document.fileName);
2295 ide.UpdateRecentMenus();
2296 ide.AdjustFileMenus();
2297 settingsContainer.Save();
2305 // TOCHECK: I can't use a generic one for both ModelView and PictureEdit both derived from Window
2306 /*bool Window::GenericDocumentOnClose(bool parentClosing)
2308 if(!parentClosing && ide.workspace)
2309 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2312 bool ModelView::ModelViewOnClose(bool parentClosing)
2314 if(!parentClosing && ide.workspace)
2315 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2318 bool PictureEdit::PictureEditOnClose(bool parentClosing)
2320 if(!parentClosing && ide.workspace)
2321 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2326 void OnUnloadGraphics(Window window)
2328 display.ClearMaterials();
2329 display.ClearTextures();
2330 display.ClearMeshes();
2334 bool OnActivate(bool active, Window swap, bool * goOnWithActivation, bool direct)
2336 caps.color = app.GetKeyState(capsState) ? black : Color { 128,128,128 };
2337 num.color = app.GetKeyState(numState) ? black : Color { 128,128,128 };
2341 bool OnKeyDown(Key key, unichar ch)
2346 projectView.Update(null);
2349 caps.color = app.GetKeyState(capsState) ? black : Color { 128,128,128 };
2352 num.color = app.GetKeyState(numState) ? black : Color { 128,128,128 };
2358 void GoToError(const char * line)
2361 projectView.GoToError(line);
2364 void CodeLocationParseAndGoTo(const char * text, Project project, const char * dir)
2367 char *colon = strchr(text, ':');
2368 char filePath[MAX_LOCATION];
2369 char completePath[MAX_LOCATION];
2370 int line = 0, col = 0;
2372 FileAttribs fileAttribs;
2374 if(colon && (colon[1] == '/' || colon[1] == '\\'))
2376 path = (colon - 1 > path) ? colon - 1 : path;
2377 colon = strstr(colon + 1, ":");
2379 while(isspace(*path)) path++;
2382 char * close = strchr(path, ')');
2386 strncpy(name, path+1, close - path - 1);
2387 name[close - path - 1] = '\0';
2388 for(p : ide.workspace.projects)
2390 if(!strcmp(p.name, name))
2400 prj = project ? project : (dir ? null : ide.project);
2403 strncpy(filePath, path, colon - path);
2404 filePath[colon - path] = '\0';
2405 line = atoi(colon + 1);
2406 colon = strstr(colon + 1, ":");
2408 col = atoi(colon + 1);
2410 else if(path - 1 >= text && *(path - 1) == '\"')
2412 colon = strchr(path, '\"');
2415 strncpy(filePath, path, colon - path);
2416 filePath[colon - path] = '\0';
2419 else if(path && !colon)
2421 strcpy(filePath, path);
2425 strcpy(completePath, prj.topNode.path);
2426 else if(dir && dir[0])
2427 strcpy(completePath, dir);
2429 completePath[0] = '\0';
2430 PathCat(completePath, filePath);
2432 fileAttribs = FileExists(completePath);
2433 if(fileAttribs.isFile)
2435 CodeEditor codeEditor = (CodeEditor)OpenFile(completePath, normal, true, "", no, normal);
2436 if(codeEditor && line)
2438 EditBox editBox = codeEditor.editBox;
2439 editBox.GoToLineNum(line - 1);
2440 editBox.GoToPosition(editBox.line, line - 1, col ? (col - 1) : 0);
2443 else if(fileAttribs.isDirectory)
2444 ShellOpen(completePath);
2447 void OnRedraw(Surface surface)
2449 Bitmap bitmap = back.bitmap;
2451 surface.Blit(bitmap, (clientSize.w - bitmap.width) / 2, (clientSize.h - bitmap.height) / 2, 0, 0, bitmap.width, bitmap.height);
2454 void SheetSelected(SheetType sheetSelected)
2456 if(activeChild == sheet)
2458 if(sheetSelected == methods)
2460 viewPropertiesItem.accelerator = f4;
2461 viewPropertiesItem.parent = viewMenu;
2462 viewMethodsItem.parent = null;
2466 viewMethodsItem.accelerator = f4;
2467 viewMethodsItem.parent = viewMenu;
2468 viewPropertiesItem.parent = null;
2473 viewMethodsItem.parent = viewMenu;
2474 viewPropertiesItem.parent = viewMenu;
2475 if(sheetSelected == methods)
2477 viewMethodsItem.accelerator = f4;
2478 viewPropertiesItem.accelerator = 0;
2482 viewMethodsItem.accelerator = 0;
2483 viewPropertiesItem.accelerator = f4;
2488 void OnActivateClient(Window client, Window previous)
2490 //if(!client || client != previous)
2493 if(!client || client != previous)
2496 dataType = previous._class;
2497 if(previous && !strcmp(dataType.name, "CodeEditor"))
2499 ((CodeEditor)previous).UpdateFormCode();
2501 else if(previous && !strcmp(dataType.name, "Designer"))
2503 ((Designer)previous).codeEditor.UpdateFormCode();
2508 dataType = client._class;
2509 if(client && !strcmp(dataType.name, "CodeEditor"))
2511 CodeEditor codeEditor = (CodeEditor)client;
2512 SetPrivateModule(codeEditor.privateModule);
2513 SetCurrentContext(codeEditor.globalContext);
2514 SetTopContext(codeEditor.globalContext);
2515 SetGlobalContext(codeEditor.globalContext);
2517 SetDefines(&codeEditor.defines);
2518 SetImports(&codeEditor.imports);
2520 SetActiveDesigner(codeEditor.designer);
2522 sheet.codeEditor = codeEditor;
2523 toolBox.codeEditor = codeEditor;
2525 viewDesignerItem.parent = viewMenu;
2526 if(activeChild != codeEditor)
2528 viewCodeItem.parent = viewMenu;
2529 viewDesignerItem.accelerator = 0;
2530 viewCodeItem.accelerator = f8;
2534 viewCodeItem.parent = null;
2535 viewDesignerItem.accelerator = f8;
2538 else if(client && !strcmp(dataType.name, "Designer"))
2540 CodeEditor codeEditor = ((Designer)client).codeEditor;
2543 SetPrivateModule(codeEditor.privateModule);
2544 SetCurrentContext(codeEditor.globalContext);
2545 SetTopContext(codeEditor.globalContext);
2546 SetGlobalContext(codeEditor.globalContext);
2547 SetDefines(&codeEditor.defines);
2548 SetImports(&codeEditor.imports);
2552 SetPrivateModule(null);
2553 SetCurrentContext(null);
2554 SetTopContext(null);
2555 SetGlobalContext(null);
2560 SetActiveDesigner((Designer)client);
2562 sheet.codeEditor = codeEditor;
2563 toolBox.codeEditor = codeEditor;
2565 viewCodeItem.parent = viewMenu;
2566 if(activeChild != client)
2568 viewDesignerItem.parent = viewMenu;
2569 viewDesignerItem.accelerator = f8;
2570 viewCodeItem.accelerator = 0;
2574 viewDesignerItem.parent = null;
2575 viewCodeItem.accelerator = f8;
2581 sheet.codeEditor = null;
2582 toolBox.codeEditor = null;
2583 SetActiveDesigner(null);
2585 viewDesignerItem.parent = null;
2586 viewCodeItem.parent = null;
2589 SheetSelected(sheet.sheetSelected);
2592 projectCompileItem = null;
2597 if(client && client._class == eSystem_FindClass(__thisModule, "CodeEditor")) // !strcmp(client._class.name, "CodeEditor")
2599 CodeEditor codeEditor = (CodeEditor)client;
2600 EditBox editBox = codeEditor.editBox;
2602 statusBar.AddField(pos);
2604 caps = { width = 40, text = $"CAPS", color = app.GetKeyState(capsState) ? black : Color { 128, 128, 128 } };
2605 statusBar.AddField(caps);
2607 ovr = { width = 30, text = $"OVR", color = editBox.overwrite ? black : Color { 128, 128, 128 } };
2608 statusBar.AddField(ovr);
2610 num = { width = 30, text = $"NUM", color = app.GetKeyState(numState) ? black : Color { 128, 128, 128 } };
2611 statusBar.AddField(num);
2613 //statusBar.text = "Ready";
2615 if(projectView && projectView.project)
2617 bool isCObject = false;
2618 ProjectNode node = projectView.GetNodeFromWindow(client, null, false);
2619 if(!node && (node = projectView.GetNodeFromWindow(client, null, true)))
2623 char nodeName[MAX_FILENAME];
2624 char name[MAX_FILENAME+96];
2626 ChangeExtension(node.name, "c", nodeName);
2627 sprintf(name, $"Compile %s", isCObject ? nodeName : node.name);
2628 projectCompileItem =
2630 copyText = true, text = name, c, ctrlF7, disabled = projectView.buildInProgress;
2632 bool NotifySelect(MenuItem selection, Modifiers mods)
2636 bool result = false;
2637 bool isCObject = false;
2638 ProjectNode node = null;
2639 for(p : ide.workspace.projects)
2641 node = projectView.GetNodeFromWindow(activeClient, p, false);
2644 if(!node && (node = projectView.GetNodeFromWindow(activeClient, null, true)))
2648 List<ProjectNode> nodes { };
2650 projectView.Compile(node.project, nodes, mods.ctrl && mods.shift, isCObject ? cObject : normal);
2655 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
2660 projectMenu.AddDynamic(projectCompileItem, ide, false);
2666 caps = ovr = num = null;
2671 bool OnClose(bool parentClosing)
2673 //return !projectView.buildInProgress;
2674 if(projectView && projectView.buildInProgress)
2676 if(DontTerminateDebugSession($"Close IDE"))
2678 if(findInFilesDialog)
2679 findInFilesDialog.SearchStop();
2682 workspace.timer.Stop();
2685 ideMainFrame.Destroy(0);
2692 bool passThrough = false;
2693 bool debugStart = false;
2694 DynamicString passArgs { };
2695 for(c = 1; c<app.argc; c++)
2697 if(!strcmp(app.argv[c], "-debug-start"))
2699 else if(!passThrough && !strcmp(app.argv[c], "-@"))
2701 else if(passThrough)
2703 passArgs.concat(" ");
2704 passArgs.concat(app.argv[c]);
2708 char fullPath[MAX_LOCATION];
2709 char parentPath[MAX_LOCATION];
2710 char ext[MAX_EXTENSION];
2712 FileAttribs dirAttribs;
2713 GetWorkingDir(fullPath, MAX_LOCATION);
2714 PathCat(fullPath, app.argv[c]);
2715 StripLastDirectory(fullPath, parentPath);
2716 GetExtension(app.argv[c], ext);
2717 isProject = !strcmpi(ext, "epj");
2719 if(isProject && c > (debugStart ? 2 : 1)) continue;
2721 // Create directory for projects (only)
2722 if(((dirAttribs = FileExists(parentPath)) && dirAttribs.isDirectory) || isProject)
2724 if(isProject && !FileExists(fullPath))
2726 // The NewProject will handle directory creation
2727 /*if(!dirAttribs.isDirectory)
2729 MakeDir(parentPath);
2730 dirAttribs = FileExists(parentPath);
2732 if(dirAttribs.isDirectory)*/
2734 char name[MAX_LOCATION];
2735 NewProjectDialog newProjectDialog;
2739 projectView.visible = false;
2740 if(!projectView.Destroy(0))
2744 newProjectDialog = { master = this };
2746 strcpy(name, app.argv[c]);
2747 StripExtension(name);
2748 GetLastDirectory(name, name);
2749 newProjectDialog.projectName.contents = name;
2750 newProjectDialog.projectName.NotifyModified(newProjectDialog, newProjectDialog.projectName);
2751 newProjectDialog.locationEditBox.path = parentPath;
2752 newProjectDialog.NotifyModifiedLocation(newProjectDialog.locationEditBox);
2754 newProjectDialog.Modal();
2757 ideSettings.AddRecentProject(projectView.fileName);
2758 ide.UpdateRecentMenus();
2759 settingsContainer.Save();
2762 // Open only one project
2766 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, null, yes, normal);
2768 else if(strstr(fullPath, "http://") == fullPath)
2769 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, null, yes, normal);
2772 if(passThrough && projectView && projectView.project && workspace)
2773 workspace.commandLineArgs = passArgs;
2776 ;//MenuDebugStart(debugStartResumeItem, 0); // <-- how TODO this without getting into the app.Wait lock
2778 UpdateToolBarActiveConfigs(false);
2779 UpdateToolBarActiveCompilers();
2785 // IS THIS NEEDED? WASN'T HERE BEFORE... Crashes on getting node's projectView otherwise
2788 projectView.visible = false;
2789 projectView.Destroy(0);
2792 #ifdef GDB_DEBUG_GUI
2793 gdbDialog.Destroy(0);
2798 void SetPath(bool projectsDirs, CompilerConfig compiler, ProjectConfig config, int bitDepth)
2802 char * oldPaths[128];
2803 String oldList = new char[maxPathLen];
2804 Array<String> newExePaths { };
2805 //Map<String, bool> exePathExists { };
2807 #if defined(__unix__) || defined(__APPLE__)
2808 Array<String> newLibPaths { };
2809 Map<String, bool> libPathExists { };
2814 for(prj : workspace.projects)
2816 DirExpression targetDirExp;
2818 // SKIP FIRST PROJECT...
2819 if(prj == workspace.projects.firstIterator.data) continue;
2821 // NOTE: Right now the additional project config dir will be
2822 // obtained when the debugger is started, so toggling it
2823 // while building will change which library gets used.
2824 // To go with the initial state, e.g. when F5 was pressed,
2825 // we nould need to keep a list of all project's active
2826 // config upon startup.
2827 targetDirExp = prj.GetTargetDir(compiler, prj.config, bitDepth);
2829 /*if(prj.config.targetType == sharedLibrary && prj.config.debug)
2833 for(cfg = prj.configurations.first; cfg; cfg = cfg.next)
2834 if(cfg.targetType == sharedLibrary && cfg.debug && !strcmpi(cfg.name, "Debug"))
2838 for(cfg = prj.configurations.first; cfg; cfg = cfg.next)
2839 if(cfg.targetType == sharedLibrary && cfg.debug)
2843 if(targetDirExp.dir)
2845 char buffer[MAX_LOCATION];
2846 #if defined(__WIN32__)
2847 Array<String> paths = newExePaths;
2849 Array<String> paths = newLibPaths;
2851 GetSystemPathBuffer(buffer, prj.topNode.path);
2852 PathCat(buffer, targetDirExp.dir);
2855 if(!fstrcmp(p, buffer))
2862 paths.Add(CopyString(buffer));
2864 delete targetDirExp;
2868 for(item : compiler.executableDirs)
2871 for(p : newExePaths)
2873 if(!fstrcmp(p, item))
2880 newExePaths.Add(CopySystemPath(item));
2883 GetEnvironment("PATH", oldList, maxPathLen);
2885 printf("Old value of PATH: %s\n", oldList);
2887 count = TokenizeWith(oldList, sizeof(oldPaths) / sizeof(char *), oldPaths, pathListSep, false);
2888 for(c = 0; c < count; c++)
2891 for(p : newExePaths)
2893 if(!fstrcmp(p, oldPaths[c]))
2900 newExePaths.Add(CopySystemPath(oldPaths[c]));
2904 for(path : newExePaths)
2905 len += strlen(path) + 1;
2906 newList = new char[len + 1];
2908 for(path : newExePaths)
2910 strcat(newList, path);
2911 strcat(newList, pathListSep);
2913 newList[len - 1] = '\0';
2914 SetEnvironment("PATH", newList);
2916 printf("New value of PATH: %s\n", newList);
2923 #if defined(__unix__) || defined(__APPLE__)
2925 for(item : compiler.libraryDirs)
2927 if(!libPathExists[item]) // fstrcmp should be used
2929 newLibPaths.Add(item);
2930 libPathExists[item] = true;
2934 #if defined(__APPLE__)
2935 GetEnvironment("DYLD_LIBRARY_PATH", oldList, maxPathLen);
2937 GetEnvironment("LD_LIBRARY_PATH", oldList, maxPathLen);
2940 printf("Old value of [DY]LD_LIBRARY_PATH: %s\n", oldList);
2942 count = TokenizeWith(oldList, sizeof(oldPaths) / sizeof(char *), oldPaths, pathListSep, false);
2943 for(c = 0; c < count; c++)
2945 if(!libPathExists[oldPaths[c]]) // fstrcmp should be used
2947 newLibPaths.Add(oldPaths[c]);
2948 libPathExists[oldPaths[c]] = true;
2953 for(path : newLibPaths)
2954 len += strlen(path) + 1;
2955 newList = new char[len + 1];
2957 for(path : newLibPaths)
2959 strcat(newList, path);
2960 strcat(newList, pathListSep);
2962 newList[len - 1] = '\0';
2963 #if defined(__APPLE__)
2964 SetEnvironment("DYLD_LIBRARY_PATH", newList);
2966 SetEnvironment("LD_LIBRARY_PATH", newList);
2969 printf("New value of [DY]LD_LIBRARY_PATH: %s\n", newList);
2974 delete libPathExists;
2977 if(compiler.distccEnabled && compiler.distccHosts)
2978 SetEnvironment("DISTCC_HOSTS", compiler.distccHosts);
2983 void DestroyTemporaryProjectDir()
2985 if(tmpPrjDir && tmpPrjDir[0])
2987 if(FileExists(tmpPrjDir).isDirectory)
2988 DestroyDir(tmpPrjDir);
2989 property::tmpPrjDir = null;
2995 // Graphics Driver Menu
2999 app.currentSkin.selectionColor = selectionColor;
3000 app.currentSkin.selectionText = selectionText;
3004 driverItems = new MenuItem[app.numDrivers];
3005 for(c = 0; c < app.numDrivers; c++)
3007 driverItems[c] = MenuItem { driversMenu, app.drivers[c], NotifySelect = NotifySelectDisplayDriver };
3008 driverItems[c].id = c;
3009 driverItems[c].isRadio = true;
3012 driverItems = new MenuItem[2];
3013 #if defined(__unix__)
3014 driverItems[0] = MenuItem { driversMenu, "X", NotifySelect = NotifySelectDisplayDriver };
3015 driverItems[0].id = 0;
3016 driverItems[0].isRadio = true;
3018 driverItems[0] = MenuItem { driversMenu, "GDI", NotifySelect = NotifySelectDisplayDriver };
3019 driverItems[0].id = 0;
3020 driverItems[0].isRadio = true;
3022 driverItems[1] = MenuItem { driversMenu, "OpenGL", NotifySelect = NotifySelectDisplayDriver };
3023 driverItems[1].id = 1;
3024 driverItems[1].isRadio = true;
3026 /* skinItems = new MenuItem[app.numSkins];
3027 for(c = 0; c < app.numSkins; c++)
3029 skinItems[c] = MenuItem {skinsMenu, app.skins[c], NotifySelect = NotifySelectDisplaySkin };
3030 skinItems[c].id = c;
3031 skinItems[c].isRadio = true;
3034 ideFileDialog.master = this;
3035 ideProjectFileDialog.master = this;
3037 //SetDriverAndSkin();
3041 void UpdateRecentMenus()
3044 Menu fileMenu = menu.FindMenu($"File");
3045 Menu recentFiles = fileMenu.FindMenu($"Recent Files");
3046 Menu recentProjects = fileMenu.FindMenu($"Recent Projects");
3047 char itemName[MAX_LOCATION + 4];
3050 recentFiles.Clear();
3053 for(recent : ideSettings.recentFiles)
3055 sprintf(itemName, "%d %s", 1 + c, recent);
3056 MakeSystemPath(itemName);
3057 recentFiles.AddDynamic(MenuItem { copyText = true, text = itemName, (Key)k1 + c, id = c, NotifySelect = ide.FileRecentFile }, ide, true);
3061 recentProjects.Clear();
3063 for(recent : ideSettings.recentProjects)
3065 sprintf(itemName, "%d %s", 1 + c, recent);
3066 MakeSystemPath(itemName);
3067 recentProjects.AddDynamic(MenuItem { copyText = true, text = itemName, (Key)k1 + c, id = c, NotifySelect = ide.FileRecentProject }, ide, true);
3080 void DestroyDir(char * path)
3082 RecursiveDeleteFolderFSI fsi { };
3087 class RecursiveDeleteFolderFSI : NormalFileSystemIterator
3089 bool preserveRootFolder;
3091 void OutFolder(char * folderPath, bool isRoot)
3093 if(!(preserveRootFolder && isRoot))
3094 RemoveDir(folderPath);
3097 bool OnFile(char * filePath)
3099 DeleteFile(filePath);
3104 class IDEApp : GuiApplication
3106 //driver = "Win32Console";
3107 // driver = "OpenGL";
3111 TempFile includeFile { };
3115 SetLoggingMode(stdOut, null);
3116 //SetLoggingMode(debug, null);
3118 settingsContainer.Load();
3119 #if defined(__unix__) || defined(__APPLE__)
3120 app.driver = (ideSettings.displayDriver && !strcmp(ideSettings.displayDriver, "OpenGL")) ? ideSettings.displayDriver : "X";
3122 app.driver = (ideSettings.displayDriver && !strcmp(ideSettings.displayDriver, "OpenGL")) ? ideSettings.displayDriver : "GDI";
3124 ide.driverItems[ideSettings.displayDriver && !strcmp(ideSettings.displayDriver,"OpenGL")].checked = true;
3128 desktop.text = titleECEREIDE;
3131 for(c = 1; c<app.argc; c++)
3133 char fullPath[MAX_LOCATION];
3134 GetWorkingDir(fullPath, MAX_LOCATION);
3135 PathCat(fullPath, app.argv[c]);
3136 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, null, yes, normal);
3140 if(!LoadIncludeFile())
3141 PrintLn("error: unable to load :crossplatform.mk file inside ide binary.");
3146 bool LoadIncludeFile()
3148 bool result = false;
3149 File include = FileOpen(":crossplatform.mk", read);
3152 File f = includeFile;
3155 for(; !include.Eof(); )
3158 int count = include.Read(buffer, 1, 4096);
3159 f.Write(buffer, 1, count);
3169 IDEMainFrame ideMainFrame { };
3171 define app = ((IDEApp)__thisModule);
3173 define titleECEREIDE = $"ECERE IDE (Debug)";
3175 define titleECEREIDE = $"ECERE IDE";