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 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;
960 MenuDivider { projectMenu };
961 MenuItem projectSettingsItem
963 projectMenu, $"Settings...", s, altF7, disabled = true;
964 bool NotifySelect(MenuItem selection, Modifiers mods)
966 projectView.MenuSettings(projectView.active ? selection : null, mods);
970 MenuDivider { projectMenu };
971 MenuItem projectBrowseFolderItem
973 projectMenu, $"Browse Project Folder", p, disabled = true;
974 bool NotifySelect(MenuItem selection, Modifiers mods)
977 projectView.MenuBrowseFolder(null, mods);
981 MenuDivider { projectMenu };
982 MenuItem projectRunItem
984 projectMenu, $"Run", r, ctrlF5, disabled = true;
985 bitmap = { ":actions/run.png" };
986 bool NotifySelect(MenuItem selection, Modifiers mods)
989 projectView.Run(null, mods);
993 MenuItem projectBuildItem
995 projectMenu, $"Build", b, f7, disabled = true;
996 bitmap = { ":actions/build.png" };
997 bool NotifySelect(MenuItem selection, Modifiers mods)
1001 if(projectView.buildInProgress == none)
1002 projectView.ProjectBuild(projectView.active ? selection : null, mods);
1004 projectView.stopBuild = true;
1009 MenuItem projectLinkItem
1011 projectMenu, $"Relink", l, disabled = true;
1012 bitmap = { ":actions/relink.png" };
1013 bool NotifySelect(MenuItem selection, Modifiers mods)
1016 projectView.ProjectLink(projectView.active ? selection : null, mods);
1020 MenuItem projectRebuildItem
1022 projectMenu, $"Rebuild", d, shiftF7, disabled = true;
1023 bitmap = { ":actions/rebuild.png" };
1024 bool NotifySelect(MenuItem selection, Modifiers mods)
1027 projectView.ProjectRebuild(projectView.active ? selection : null, mods);
1031 MenuItem projectCleanItem
1033 projectMenu, $"Clean", e, disabled = true;
1034 bitmap = { ":actions/clean.png" };
1035 bool NotifySelect(MenuItem selection, Modifiers mods)
1040 projectView.ProjectClean(projectView.active ? selection : null, mods);
1045 MenuItem projectRealCleanItem
1047 projectMenu, $"Real Clean", disabled = true;
1048 bitmap = { ":actions/clean.png" };
1049 bool NotifySelect(MenuItem selection, Modifiers mods)
1054 projectView.ProjectRealClean(projectView.active ? selection : null, mods);
1059 MenuItem projectRegenerateItem
1061 projectMenu, $"Regenerate Makefile", m, disabled = true;
1062 bitmap = { ":actions/regMakefile.png" };
1063 bool NotifySelect(MenuItem selection, Modifiers mods)
1066 projectView.ProjectRegenerate(projectView.active ? selection : null, mods);
1070 MenuItem projectCompileItem;
1071 Menu debugMenu { menu, $"Debug", d, hasMargin = true };
1072 MenuItem debugStartResumeItem
1074 debugMenu, $"Start", s, f5, disabled = true;
1075 bitmap = { ":actions/debug.png" };
1076 NotifySelect = MenuDebugStart;
1078 bool MenuDebugStart(MenuItem selection, Modifiers mods)
1082 debugStartResumeItem.disabled = true; // a very rare exception to calling AdjustDebugMenus
1083 if(!projectView.DebugStart())
1084 debugStartResumeItem.disabled = false; // same exception
1088 bool MenuDebugResume(MenuItem selection, Modifiers mods)
1091 projectView.DebugResume();
1094 MenuItem debugRestartItem
1096 debugMenu, $"Restart", r, Key { f5, ctrl = true, shift = true }, disabled = true;
1097 bitmap = { ":actions/restart.png" };
1098 bool NotifySelect(MenuItem selection, Modifiers mods)
1101 projectView.DebugRestart();
1105 MenuItem debugBreakItem
1107 debugMenu, $"Break", b, Key { pauseBreak, ctrl = true }, disabled = true;
1108 bitmap = { ":actions/pause.png" };
1109 bool NotifySelect(MenuItem selection, Modifiers mods)
1111 if(projectView && projectView.buildInProgress != none)
1114 projectView.DebugBreak();
1118 MenuItem debugStopItem
1120 debugMenu, $"Stop", p, shiftF5, disabled = true;
1121 bitmap = { ":actions/stopDebug.png" };
1122 bool NotifySelect(MenuItem selection, Modifiers mods)
1125 projectView.DebugStop();
1129 MenuDivider { debugMenu };
1130 MenuItem debugStepIntoItem
1132 debugMenu, $"Step Into", i, f11, disabled = true;
1133 bitmap = { ":actions/stepInto.png" };
1134 bool NotifySelect(MenuItem selection, Modifiers mods)
1137 projectView.DebugStepInto();
1141 MenuItem debugStepOverItem
1143 debugMenu, $"Step Over", v, f10, disabled = true;
1144 bitmap = { ":actions/stepOver.png" };
1145 bool NotifySelect(MenuItem selection, Modifiers mods)
1148 projectView.DebugStepOver(false);
1152 MenuItem debugStepOutItem
1154 debugMenu, $"Step Out", o, shiftF11, disabled = true;
1155 bitmap = { ":actions/stepOut.png" };
1156 bool NotifySelect(MenuItem selection, Modifiers mods)
1159 projectView.DebugStepOut(false);
1163 MenuPlacement debugRunToCursorItem { debugMenu, $"Run To Cursor", c };
1164 MenuItem debugSkipStepOverItem
1166 debugMenu, $"Step Over Skipping Breakpoints", e, shiftF10, disabled = true;
1167 bool NotifySelect(MenuItem selection, Modifiers mods)
1170 projectView.DebugStepOver(true);
1174 MenuItem debugSkipStepOutItem
1176 debugMenu, $"Step Out Skipping Breakpoints", t, Key { f11, ctrl = true, shift = true }, disabled = true;
1177 bitmap = { ":actions/skipBreaks.png" };
1178 bool NotifySelect(MenuItem selection, Modifiers mods)
1181 projectView.DebugStepOut(true);
1185 MenuPlacement debugSkipRunToCursorItem { debugMenu, $"Run To Cursor Skipping Breakpoints", u };
1186 //MenuDivider { debugMenu };
1187 //MenuPlacement debugToggleBreakpoint { debugMenu, "Toggle Breakpoint", t };
1188 MenuPlacement imageMenu { menu, $"Image", i };
1189 Menu viewMenu { menu, $"View", v };
1190 MenuItem viewProjectItem
1192 viewMenu, $"Project View", j, alt0, disabled = true;
1193 bool NotifySelect(MenuItem selection, Modifiers mods)
1197 projectView.visible = true;
1198 projectView.Activate();
1203 MenuPlacement { viewMenu, $"View Designer" };
1204 MenuPlacement { viewMenu, $"View Code" };
1205 MenuPlacement { viewMenu, $"View Properties" };
1206 MenuPlacement { viewMenu, $"View Methods" };
1207 MenuItem viewDesignerItem
1209 viewMenu, $"View Designer", d, f8;
1210 bool NotifySelect(MenuItem selection, Modifiers mods)
1212 Window client = activeClient;
1213 Class dataType = client._class;
1214 if(!strcmp(dataType.name, "Designer"))
1216 client.visible = true;
1220 ((CodeEditor)client).ViewDesigner();
1224 MenuItem viewCodeItem
1226 viewMenu, $"View Code", c, f8;
1227 bool NotifySelect(MenuItem selection, Modifiers mods)
1229 Window client = activeClient;
1230 Class dataType = client._class;
1231 if(!strcmp(dataType.name, "Designer"))
1232 client = ((Designer)client).codeEditor;
1235 // Do this after so the caret isn't moved yet...
1236 client.visible = true;
1240 MenuItem viewPropertiesItem
1242 viewMenu, $"View Properties", p, f4;
1243 bool NotifySelect(MenuItem selection, Modifiers mods)
1245 sheet.visible = true;
1246 sheet.sheetSelected = properties;
1251 MenuItem viewMethodsItem
1253 viewMenu, $"View Methods", m, f4;
1254 bool NotifySelect(MenuItem selection, Modifiers mods)
1256 sheet.visible = true;
1257 sheet.sheetSelected = methods;
1262 MenuItem viewToolBoxItem
1264 viewMenu, $"View Toolbox", x, f12;
1265 bool NotifySelect(MenuItem selection, Modifiers mods)
1267 toolBox.visible = true;
1272 MenuItem viewOutputItem
1274 viewMenu, $"Output", o, alt2;
1275 bool NotifySelect(MenuItem selection, Modifiers mods)
1281 MenuItem viewWatchesItem
1283 viewMenu, $"Watches", w, alt3;
1284 bool NotifySelect(MenuItem selection, Modifiers mods)
1290 MenuItem viewThreadsItem
1292 viewMenu, $"Threads", t, alt4;
1293 bool NotifySelect(MenuItem selection, Modifiers mods)
1299 MenuItem viewBreakpointsItem
1301 viewMenu, $"Breakpoints", b, alt5;
1302 bool NotifySelect(MenuItem selection, Modifiers mods)
1304 breakpointsView.Show();
1308 MenuItem viewCallStackItem
1310 viewMenu, $"Call Stack", s, alt7;
1311 bool NotifySelect(MenuItem selection, Modifiers mods)
1313 callStackView.Show();
1317 MenuItem viewAllDebugViews
1319 viewMenu, $"All Debug Views", a, alt9;
1320 bool NotifySelect(MenuItem selection, Modifiers mods)
1325 callStackView.Show();
1326 breakpointsView.Show();
1330 #ifdef GDB_DEBUG_GUI
1331 MenuDivider { viewMenu };
1332 MenuItem viewGDBItem
1334 viewMenu, $"GDB Dialog", g, Key { f9, shift = true, ctrl = true };
1335 bool NotifySelect(MenuItem selection, Modifiers mods)
1342 MenuDivider { viewMenu };
1343 MenuItem viewColorPicker
1345 viewMenu, $"Color Picker...", c, Key { c, ctrl = true , shift = true };
1346 bool NotifySelect(MenuItem selection, Modifiers mods)
1348 ColorPicker colorPicker { master = this, parent = this, stayOnTop = true };
1349 colorPicker.Create();
1353 MenuDivider { viewMenu };
1357 viewMenu, "Full Screen", f, checkable = true;
1359 bool NotifySelect(MenuItem selection, Modifiers mods)
1361 app.fullScreen ^= true;
1363 anchor = { 0, 0, 0, 0 };
1368 Menu driversMenu { viewMenu, $"Graphics Driver", v };
1369 //Menu skinsMenu { viewMenu, "GUI Skins", k };
1370 Menu windowMenu { menu, $"Window", w };
1371 MenuItem { windowMenu, $"Close All", l, NotifySelect = MenuWindowCloseAll };
1372 MenuDivider { windowMenu };
1373 MenuItem { windowMenu, $"Next", n, f6, NotifySelect = MenuWindowNext };
1374 MenuItem { windowMenu, $"Previous", p, shiftF6, NotifySelect = MenuWindowPrevious };
1375 MenuDivider { windowMenu };
1376 MenuItem { windowMenu, $"Cascade", c, NotifySelect = MenuWindowCascade };
1377 MenuItem { windowMenu, $"Tile Horizontally", h, NotifySelect = MenuWindowTileHorz };
1378 MenuItem { windowMenu, $"Tile Vertically", v, NotifySelect = MenuWindowTileVert };
1379 MenuItem { windowMenu, $"Arrange Icons", a, NotifySelect = MenuWindowArrangeIcons };
1380 MenuDivider { windowMenu };
1381 MenuItem { windowMenu, $"Windows...", w, NotifySelect = MenuWindowWindows };
1382 Menu helpMenu { menu, $"Help", h };
1385 helpMenu, $"API Reference", r, f1;
1386 bool NotifySelect(MenuItem selection, Modifiers mods)
1388 Execute("documentor");
1392 MenuDivider { helpMenu };
1395 helpMenu, $"About...", a;
1396 bool NotifySelect(MenuItem selection, Modifiers mods)
1398 AboutIDE { master = this }.Modal();
1403 property ToolBox toolBox
1405 get { return toolBox; }
1408 property Sheet sheet
1410 get { return sheet; }
1413 property Project project
1415 get { return projectView ? projectView.project : null; }
1418 property Workspace workspace
1420 get { return projectView ? projectView.workspace : null; }
1423 FindInFilesDialog findInFilesDialog
1426 filters = findInFilesFileFilters.array, sizeFilters = findInFilesFileFilters.count * sizeof(FileFilter);
1430 #ifdef GDB_DEBUG_GUI
1433 master = this, parent = this;
1434 anchor = { left = 100, top = 100, right = 100, bottom = 100 };
1436 void OnCommand(char * string)
1439 ide.debugger.SendGDBCommand(string);
1444 bool NotifySelectDisplayDriver(MenuItem selection, Modifiers mods)
1446 //app.driver = app.drivers[selection.id];
1447 #if defined(__unix__) || defined(__APPLE__)
1448 app.driver = selection.id ? "OpenGL" : "X";
1450 app.driver = selection.id ? "OpenGL" : "GDI";
1452 delete ideSettings.displayDriver;
1453 ideSettings.displayDriver = CopyString(selection.id ? "OpenGL" : "Default");
1455 settingsContainer.Save();
1456 //SetDriverAndSkin();
1460 bool NotifySelectDisplaySkin(MenuItem selection, Modifiers mods)
1462 app.skin = app.skins[selection.id];
1467 void SetDriverAndSkin()
1470 for(c = 0; c < app.numSkins; c++)
1471 if(!strcmp(app.skins[c], app.skin))
1473 skinItems[c].checked = true;
1476 for(c = 0; c < app.numDrivers; c++)
1477 if(!strcmp(app.drivers[c], app.driver))
1479 driverItems[c].checked = true;
1484 ProjectView CreateProjectView(Workspace workspace, char * fileName)
1486 Project project = workspace.projects.firstIterator.data;
1487 projectView = ProjectView
1490 fileName = fileName;
1492 void NotifyDestroyed(Window window, DialogResult result)
1495 text = titleECEREIDE;
1500 projectView.Create();
1501 RepositionWindows(false);
1503 // Leave it after Create to avoid flicker due to seeing IDE without a project view
1504 projectView.workspace = workspace;
1505 projectView.project = project;
1506 ideMainFrame.SetText("%s - %s", project.topNode.name, titleECEREIDE);
1510 ide.breakpointsView.LoadFromWorkspace();
1511 ide.watchesView.LoadFromWorkspace();
1513 findInFilesDialog.projectNodeField.userData = projectView;
1516 char fileName[MAX_LOCATION];
1517 strcpy(fileName, project.topNode.path);
1518 PathCat(fileName, project.topNode.name);
1523 bool GetDebugMenusDisabled()
1527 Project project = projectView.project;
1529 if(project.GetTargetType(project.config) == executable)
1536 void RepositionWindows(bool expand)
1541 bool inDebugMode = debugger.isActive;
1542 bool callStackVisible = expand ? false : callStackView.visible;
1543 bool threadsVisible = expand ? false : threadsView.visible;
1544 bool watchesVisible = expand ? false : watchesView.visible;
1545 bool breakpointsVisible = expand ? false : breakpointsView.visible;
1546 bool toolBoxVisible = toolBox.visible;
1547 bool outputVisible = expand ? false : outputView.visible;
1548 int topDistance = (callStackVisible || threadsVisible) ? 200 : 0;
1549 int bottomDistance = (outputVisible || watchesVisible || breakpointsVisible) ? 240 : 0;
1551 for(child = firstChild; child; child = child.next)
1553 if(child._class == class(CodeEditor) || child._class == class(Designer) ||
1554 child._class == class(Sheet) || child._class == class(ProjectView))
1556 Anchor anchor = child.anchor;
1557 anchor.top = topDistance;
1558 anchor.bottom = bottomDistance;
1559 if(child._class == class(CodeEditor) || child._class == class(Designer))
1561 anchor.right = toolBoxVisible ? 150 : 0;
1563 child.anchor = anchor;
1567 if(child._class == class(OutputView) || child._class == class(CallStackView) || child._class == class(ThreadsView) || child._class == class(WatchesView) ||
1568 child._class == class(BreakpointsView))
1569 child.visible = false;
1572 // If this is not here, the IDE is not updated when doing Debug/Break then Alt-4 to show call stack (IDE not updated)
1577 bool ShowCodeEditor()
1580 activeClient.Activate();
1581 else if(projectView)
1583 projectView.visible = true;
1584 projectView.Activate();
1588 sheet.visible = true;
1594 bool ShouldStopBuild()
1596 return projectView.stopBuild;
1599 void DocumentSaved(Window document, char * fileName)
1601 ideSettings.AddRecentFile(fileName);
1602 ide.UpdateRecentMenus();
1603 ide.AdjustFileMenus();
1604 settingsContainer.Save();
1607 bool Window::OnFileModified(FileChange fileChange, char * param)
1610 sprintf(temp, $"The document %s was modified by another application.\n"
1611 "Would you like to reload it and lose your changes?", this.fileName);
1612 if(MessageBox { type = yesNo, master = this/*.parent*/,
1613 text = $"Document has been modified", contents = temp }.Modal() == yes)
1615 char * fileName = CopyString(this.fileName);
1616 WindowState state = this.state;
1617 Anchor anchor = this.anchor;
1618 Size size = this.size;
1620 this.modifiedDocument = false;
1622 this = ide.OpenFile(fileName, normal, true, null, no, normal);
1625 this.anchor = anchor;
1627 this.SetState(state, true, 0);
1635 void UpdateMakefiles()
1639 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
1640 for(prj : workspace.projects)
1641 projectView.ProjectUpdateMakefileForAllConfigs(prj);
1646 void UpdateCompilerConfigs()
1648 UpdateToolBarActiveCompilers();
1651 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
1652 projectView.ShowOutputBuildLog(true);
1653 projectView.DisplayCompiler(compiler, false);
1654 for(prj : workspace.projects)
1655 projectView.ProjectPrepareCompiler(prj, compiler, false);
1660 void UpdateToolBarActiveCompilers()
1662 toolBar.activeCompiler.Clear();
1663 for(compiler : ideSettings.compilerConfigs)
1665 DataRow row = toolBar.activeCompiler.AddString(compiler.name);
1666 if(workspace && workspace.compiler && !strcmp(compiler.name, workspace.compiler))
1667 toolBar.activeCompiler.currentRow = row;
1669 if(!toolBar.activeCompiler.currentRow)
1670 toolBar.activeCompiler.currentRow = toolBar.activeCompiler.firstRow;
1671 toolBar.activeCompiler.disabled = workspace == null;
1674 void UpdateToolBarActiveConfigs(bool selectionOnly)
1676 bool commonSelected = false;
1677 DataRow row = toolBar.activeConfig.currentRow;
1679 row = toolBar.activeConfig.FindRow(1);
1682 toolBar.activeConfig.Clear();
1683 row = toolBar.activeConfig.AddString("(Mixed)");
1688 char * configName = null;
1691 Map<String, int> configs { }; // TOIMP: just need sort but using map until containers have sort
1692 for(prj : workspace.projects)
1694 for(cfg : prj.configurations)
1697 configs[cfg.name] = 1;
1702 toolBar.activeConfig.AddString(&name);
1706 if(projectView && projectView.project)
1708 for(prj : workspace.projects)
1710 if(prj.config && prj.config.name)
1712 configName = prj.config.name;
1718 commonSelected = true;
1719 for(prj : workspace.projects)
1721 if(prj.config && (!prj.config.name || strcmp(prj.config.name, configName)))
1723 commonSelected = false;
1731 commonSelected = false;
1732 for(row = toolBar.activeConfig.firstRow; row; row = row.next)
1734 if(!strcmp(row.string, configName))
1736 toolBar.activeConfig.currentRow = row;
1737 commonSelected = true;
1744 toolBar.activeConfig.Sort(null, 0);
1746 toolBar.activeConfig.currentRow = row;
1747 toolBar.activeConfig.disabled = workspace == null;
1752 bool unavailable = !project;
1754 projectAddItem.disabled = unavailable;
1755 toolBar.buttonAddProject.disabled = unavailable;
1757 projectSettingsItem.disabled = unavailable;
1759 projectBrowseFolderItem.disabled = unavailable;
1761 viewProjectItem.disabled = unavailable;
1763 toolBar.activeConfig.disabled = unavailable;
1764 toolBar.activeCompiler.disabled = unavailable;
1765 toolBar.activeBitDepth.disabled = unavailable;
1772 property bool hasOpenedCodeEditors
1777 for(w = firstChild; w; w = w.next)
1778 if(w._class == class(CodeEditor) &&
1779 w.isDocument && !w.closing && w.visible && w.created &&
1780 w.fileName && w.fileName[0])
1786 void AdjustFileMenus()
1788 bool unavailable = project != null || !hasOpenedCodeEditors; // are they supported source code (ec, c, cpp, etc) ?
1790 projectQuickItem.disabled = unavailable;
1793 void AdjustBuildMenus()
1795 bool unavailable = project && projectView.buildInProgress;
1797 projectNewItem.disabled = unavailable;
1798 toolBar.buttonNewProject.disabled = unavailable;
1799 projectOpenItem.disabled = unavailable;
1800 toolBar.buttonOpenProject.disabled = unavailable;
1802 unavailable = !project || projectView.buildInProgress;
1804 projectCloseItem.disabled = unavailable;
1805 // toolBar.buttonCloseProject.disabled = unavailable;
1807 projectRunItem.disabled = unavailable || project.GetTargetType(project.config) != executable;
1808 toolBar.buttonRun.disabled = unavailable || project.GetTargetType(project.config) != executable;
1810 projectBuildItem.disabled = false;
1811 projectBuildItem.text = unavailable ? $"Stop Build" : $"Build";
1812 projectBuildItem.accelerator = unavailable ? Key { pauseBreak, ctrl = true } : f7;
1814 projectLinkItem.disabled = unavailable;
1815 toolBar.buttonReLink.disabled = unavailable;
1816 projectRebuildItem.disabled = unavailable;
1817 toolBar.buttonRebuild.disabled = unavailable;
1818 projectCleanItem.disabled = unavailable;
1819 toolBar.buttonClean.disabled = unavailable;
1820 projectRealCleanItem.disabled = unavailable;
1821 // toolBar.buttonRealClean.disabled = unavailable;
1822 projectRegenerateItem.disabled = unavailable;
1823 toolBar.buttonRegenerateMakefile.disabled = unavailable;
1824 projectCompileItem.disabled = unavailable;
1826 AdjustPopupBuildMenus();
1829 void AdjustPopupBuildMenus()
1831 bool unavailable = !project || projectView.buildInProgress;
1833 if(projectView && projectView.popupMenu && projectView.popupMenu.menu && projectView.popupMenu.created)
1836 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectBuild, 0);
1839 menu.disabled = false;
1840 menu.text = unavailable ? $"Stop Build" : $"Build";
1841 menu.accelerator = unavailable ? Key { pauseBreak, ctrl = true } : f7;
1844 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectLink, 0); if(menu) menu.disabled = unavailable;
1845 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRebuild, 0); if(menu) menu.disabled = unavailable;
1846 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectClean, 0); if(menu) menu.disabled = unavailable;
1847 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRealClean, 0); if(menu) menu.disabled = unavailable;
1848 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRegenerate, 0); if(menu) menu.disabled = unavailable;
1849 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRemove, 0); if(menu) menu.disabled = unavailable;
1850 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileClean, 0); if(menu) menu.disabled = unavailable;
1851 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileCompile, 0); if(menu) menu.disabled = unavailable;
1852 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugPrecompile, 0); if(menu) menu.disabled = unavailable;
1853 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugCompile, 0); if(menu) menu.disabled = unavailable;
1854 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugGenerateSymbols, 0); if(menu) menu.disabled = unavailable;
1855 projectView.popupMenu.Update(null);
1859 void AdjustDebugMenus()
1861 bool unavailable = !project || project.GetTargetType(project.config) != executable ||
1862 projectView.buildInProgress == buildingMainProject;
1863 bool active = ide.debugger.isActive;
1864 bool executing = ide.debugger.state == running;
1865 //bool holding = ide.debugger.state == stopped;
1867 debugStartResumeItem.disabled = unavailable || executing;
1868 debugStartResumeItem.text = active ? $"Resume" : $"Start";
1869 debugStartResumeItem.NotifySelect = active ? MenuDebugResume : MenuDebugStart;
1872 toolBar.buttonDebugStartResume.disabled = unavailable || executing;
1873 toolBar.buttonDebugStartResume.toolTip = active ? $"Resume" : $"Start";
1876 debugBreakItem.disabled = unavailable || !executing;
1877 debugStopItem.disabled = unavailable || !active;
1878 debugRestartItem.disabled = unavailable || !active;
1881 toolBar.buttonDebugPause.disabled = unavailable || !executing;
1882 toolBar.buttonDebugStop.disabled = unavailable || !active;
1883 toolBar.buttonDebugRestart.disabled = unavailable || !active;
1886 debugStepIntoItem.disabled = unavailable || executing;
1887 debugStepOverItem.disabled = unavailable || executing;
1888 debugStepOutItem.disabled = unavailable || executing || !active;
1889 debugSkipStepOverItem.disabled = unavailable || executing;
1890 debugSkipStepOutItem.disabled = unavailable || executing || !active;
1893 toolBar.buttonDebugStepInto.disabled = unavailable || executing;
1894 toolBar.buttonDebugStepOver.disabled = unavailable || executing;
1895 toolBar.buttonDebugStepOut.disabled = unavailable || executing || !active;
1896 toolBar.buttonDebugSkipStepOver.disabled = unavailable || executing;
1897 // toolBar.buttonDebugSkipStepOutItem.disabled = unavailable || executing;
1899 if((Designer)GetActiveDesigner())
1901 CodeEditor codeEditor = ((Designer)GetActiveDesigner()).codeEditor;
1904 codeEditor.debugRunToCursor.disabled = unavailable || executing;
1905 codeEditor.debugSkipRunToCursor.disabled = unavailable || executing;
1910 void ChangeFileDialogsDirectory(char * directory, bool saveSettings)
1912 char tempString[MAX_LOCATION];
1913 strcpy(tempString, directory);
1914 if(saveSettings && !projectView)
1916 ideSettings.ideFileDialogLocation = directory;
1917 settingsContainer.Save();
1920 ideFileDialog.currentDirectory = tempString;
1921 codeEditorFileDialog.currentDirectory = tempString;
1922 codeEditorFormFileDialog.currentDirectory = tempString;
1925 void ChangeProjectFileDialogDirectory(char * directory)
1927 ideSettings.ideProjectFileDialogLocation = directory;
1928 settingsContainer.Save();
1931 Window FindWindow(char * filePath)
1933 Window document = null;
1935 // TOCHECK: Do we need to change slashes here?
1936 for(document = firstChild; document; document = document.next)
1938 char * fileName = document.fileName;
1939 if(document.isDocument && fileName && !fstrcmp(fileName, filePath))
1941 document.visible = true;
1942 document.Activate();
1949 bool DontTerminateDebugSession(char * title)
1951 if(debugger.isActive)
1953 if(MessageBox { type = yesNo, master = ide,
1954 contents = $"Do you want to terminate the debugging session in progress?",
1955 text = title }.Modal() == no)
1958 MessageBox msg { type = yesNo, master = ide,
1959 contents = "Do you want to terminate the debugging session in progress?",
1961 if(msg.Modal() == no)
1973 Window OpenFile(char * origFilePath, WindowState state, bool visible, char * type, OpenCreateIfFails createIfFails, OpenMethod openMethod)
1975 char extension[MAX_EXTENSION] = "";
1976 Window document = null;
1977 bool isProject = false;
1978 bool needFileModified = true;
1979 char winFilePath[MAX_LOCATION];
1980 char * filePath = strstr(origFilePath, "http://") == origFilePath ? strcpy(winFilePath, origFilePath) : GetSystemPathBuffer(winFilePath, origFilePath);
1984 GetExtension(filePath, extension);
1988 strcpy(extension, type);
1990 if(strcmp(extension, ProjectExtension))
1992 for(document = firstChild; document; document = document.next)
1994 char * fileName = document.fileName;
1995 if(document.isDocument && fileName && !fstrcmp(fileName, filePath) && document.created)
1997 document.visible = true;
1999 document.Activate();
2005 if(createIfFails == whatever)
2007 else if(!strcmp(extension, ProjectExtension) || !strcmp(extension, WorkspaceExtension))
2009 needFileModified = false;
2010 if(openMethod == normal)
2012 if(DontTerminateDebugSession($"Open Project"))
2015 if(MenuWindowCloseAll(null, 0))
2019 projectView.visible = false;
2020 projectView.Destroy(0);
2021 // Where did this come from? projectView = null;
2028 Workspace workspace = null;
2030 if(FileExists(filePath))
2032 if(!strcmp(extension, ProjectExtension))
2034 char workspaceFile[MAX_LOCATION];
2035 strcpy(workspaceFile, filePath);
2036 ChangeExtension(workspaceFile, WorkspaceExtension, workspaceFile);
2037 workspace = LoadWorkspace(workspaceFile, filePath);
2039 else if(!strcmp(extension, WorkspaceExtension))
2040 workspace = LoadWorkspace(filePath, null);
2043 //project = LoadProject(filePath, null);
2048 char absolutePath[MAX_LOCATION];
2049 CreateProjectView(workspace, filePath);
2050 document = projectView;
2052 workspace.DropInvalidBreakpoints();
2055 ide.projectView.ShowOutputBuildLog(true);
2057 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
2058 ide.projectView.DisplayCompiler(compiler, false);
2061 UpdateCompilerConfigs();
2064 char newWorkingDir[MAX_LOCATION];
2065 StripLastDirectory(filePath, newWorkingDir);
2066 ChangeFileDialogsDirectory(newWorkingDir, false);
2069 document.fileName = filePath;
2071 ideMainFrame.SetText("%s - %s", filePath, titleECEREIDE);
2073 // this crashes on starting ide with epj file, solution please?
2074 // app.UpdateDisplay();
2076 workspace.holdTracking = true;
2077 for(ofi : workspace.openedFiles)
2079 if(ofi.state != closed)
2081 Window file = OpenFile(ofi.path, normal, true, null, no, normal);
2084 char fileName[MAX_LOCATION];
2086 GetLastDirectory(ofi.path, fileName);
2087 node = projectView.project.topNode.Find(fileName, true);
2089 node.EnsureVisible();
2093 workspace.holdTracking = false;
2095 workspace.timer.Start();
2097 findInFilesDialog.mode = FindInFilesMode::project;
2098 findInFilesDialog.currentDirectory = ide.project.topNode.path;
2101 char location[MAX_LOCATION];
2102 StripLastDirectory(ide.project.topNode.path, location);
2103 ChangeProjectFileDialogDirectory(location);
2107 if(projectView.debugger)
2108 projectView.debugger.EvaluateWatches();
2115 if(MessageBox { type = yesNo, master = this, text = $"Error opening project", contents = $"Open a different project?" }.Modal() == yes)
2117 ideProjectFileDialog.text = openProjectFileDialogTitle;
2118 if(ideProjectFileDialog.Modal() == cancel)
2120 filePath = ideProjectFileDialog.filePath;
2121 GetExtension(filePath, extension);
2132 else if(openMethod == add)
2137 char slashFilePath[MAX_LOCATION];
2138 GetSlashPathBuffer(slashFilePath, filePath);
2139 for(p : workspace.projects)
2141 if(!fstrcmp(p.filePath, slashFilePath))
2149 MessageBox { type = ok, parent = parent, master = this, text = $"Same Project",
2150 contents = $"This project is already present in workspace." }.Modal();
2154 prj = LoadProject(filePath, null);
2157 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
2158 prj.StartMonitoring();
2159 workspace.projects.Add(prj);
2161 projectView.AddNode(prj.topNode, null);
2162 workspace.modified = true;
2164 findInFilesDialog.AddProjectItem(prj);
2165 projectView.ShowOutputBuildLog(true);
2166 projectView.DisplayCompiler(compiler, false);
2167 projectView.ProjectUpdateMakefileForAllConfigs(prj);
2171 char location[MAX_LOCATION];
2172 StripLastDirectory(prj.topNode.path, location);
2173 ChangeProjectFileDialogDirectory(location);
2176 // projectView is associated with the main project and not with the one just added but
2177 return projectView; // just to let the caller know something was opened
2185 else if(!strcmp(extension, "bmp") || !strcmp(extension, "pcx") ||
2186 !strcmp(extension, "jpg") || !strcmp(extension, "gif") ||
2187 !strcmp(extension, "jpeg") || !strcmp(extension, "png"))
2189 if(FileExists(filePath))
2190 document = PictureEdit { hasMaximize = true, hasMinimize = true, hasClose = true, borderStyle = sizable,
2191 hasVertScroll = true, hasHorzScroll = true, parent = this, state = state,
2192 visible = visible, bitmapFile = filePath, OnClose = PictureEditOnClose/*why?--GenericDocumentOnClose*/;
2195 MessageBox { type = ok, master = this, text = filePath, contents = $"File doesn't exist." }.Modal();
2198 else if(!strcmp(extension, "3ds"))
2200 if(FileExists(filePath))
2201 document = ModelView { hasMaximize = true, hasMinimize = true, hasClose = true, borderStyle = sizable,
2202 hasVertScroll = true, hasHorzScroll = true, parent = this, state = state,
2203 visible = visible, modelFile = filePath, OnClose = ModelViewOnClose/*why?--GenericDocumentOnClose*/
2207 MessageBox { type = ok, master = this, text = filePath, contents = $"File doesn't exist." }.Modal();
2210 else if(!strcmp(extension, "txt") || !strcmp(extension, "text") ||
2211 !strcmp(extension, "nfo") || !strcmp(extension, "info") ||
2212 !strcmp(extension, "htm") || !strcmp(extension, "html") ||
2213 !strcmp(extension, "css") || !strcmp(extension, "php") ||
2214 !strcmp(extension, "js"))
2216 CodeEditor editor { parent = this, state = state, visible = false };
2217 editor.updatingCode = true;
2218 if(editor.LoadFile(filePath))
2221 editor.visible = true;
2225 needFileModified = false;
2229 CodeEditor editor { parent = this, state = state, visible = false };
2230 if(editor.LoadFile(filePath))
2233 editor.visible = true;
2237 needFileModified = false;
2240 if(document && (document._class == class(PictureEdit) ||
2241 document._class == class(ModelView)))
2246 document.fileName = filePath;
2247 if(workspace && !workspace.holdTracking)
2248 workspace.UpdateOpenedFileInfo(filePath, opened);
2252 if(!document && createIfFails != no)
2254 if(createIfFails != yes && !needFileModified &&
2255 MessageBox { type = yesNo, master = this, text = filePath, contents = $"File doesn't exist. Create?" }.Modal() == yes)
2256 createIfFails = yes;
2257 if(createIfFails == yes || createIfFails == whatever)
2259 document = (Window)NewCodeEditor(this, state, true);
2261 document.fileName = filePath;
2267 if(projectView && document._class == class(CodeEditor) && workspace)
2269 int lineNumber, position;
2271 CodeEditor editor = (CodeEditor)document;
2272 editor.openedFileInfo = workspace.UpdateOpenedFileInfo(filePath, opened);
2273 editor.openedFileInfo.holdTracking = true;
2274 lineNumber = Max(editor.openedFileInfo.lineNumber - 1, 0);
2275 position = Max(editor.openedFileInfo.position - 1, 0);
2276 editor.editBox.GoToLineNum(lineNumber);
2277 editor.editBox.GoToPosition(editor.editBox.line, lineNumber, position);
2278 scroll.x = Max(editor.openedFileInfo.scroll.x, 0);
2279 scroll.y = Max(editor.openedFileInfo.scroll.y, 0);
2280 editor.editBox.scroll = scroll;
2281 editor.openedFileInfo.holdTracking = false;
2284 if(needFileModified)
2285 document.OnFileModified = OnFileModified;
2286 document.NotifySaved = DocumentSaved;
2289 ideSettings.AddRecentProject(document.fileName);
2291 ideSettings.AddRecentFile(document.fileName);
2292 ide.UpdateRecentMenus();
2293 ide.AdjustFileMenus();
2294 settingsContainer.Save();
2302 // TOCHECK: I can't use a generic one for both ModelView and PictureEdit both derived from Window
2303 /*bool Window::GenericDocumentOnClose(bool parentClosing)
2305 if(!parentClosing && ide.workspace)
2306 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2309 bool ModelView::ModelViewOnClose(bool parentClosing)
2311 if(!parentClosing && ide.workspace)
2312 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2315 bool PictureEdit::PictureEditOnClose(bool parentClosing)
2317 if(!parentClosing && ide.workspace)
2318 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2323 void OnUnloadGraphics(Window window)
2325 display.ClearMaterials();
2326 display.ClearTextures();
2327 display.ClearMeshes();
2331 bool OnActivate(bool active, Window swap, bool * goOnWithActivation, bool direct)
2333 caps.color = app.GetKeyState(capsState) ? black : Color { 128,128,128 };
2334 num.color = app.GetKeyState(numState) ? black : Color { 128,128,128 };
2338 bool OnKeyDown(Key key, unichar ch)
2343 projectView.Update(null);
2346 caps.color = app.GetKeyState(capsState) ? black : Color { 128,128,128 };
2349 num.color = app.GetKeyState(numState) ? black : Color { 128,128,128 };
2355 void GoToError(const char * line)
2358 projectView.GoToError(line);
2361 void CodeLocationParseAndGoTo(const char * text, Project project, const char * dir)
2364 char *colon = strchr(text, ':');
2365 char filePath[MAX_LOCATION];
2366 char completePath[MAX_LOCATION];
2367 int line = 0, col = 0;
2369 FileAttribs fileAttribs;
2371 if(colon && (colon[1] == '/' || colon[1] == '\\'))
2373 path = (colon - 1 > path) ? colon - 1 : path;
2374 colon = strstr(colon + 1, ":");
2376 while(isspace(*path)) path++;
2379 char * close = strchr(path, ')');
2383 strncpy(name, path+1, close - path - 1);
2384 name[close - path - 1] = '\0';
2385 for(p : ide.workspace.projects)
2387 if(!strcmp(p.name, name))
2397 prj = project ? project : (dir ? null : ide.project);
2400 strncpy(filePath, path, colon - path);
2401 filePath[colon - path] = '\0';
2402 line = atoi(colon + 1);
2403 colon = strstr(colon + 1, ":");
2405 col = atoi(colon + 1);
2407 else if(path - 1 >= text && *(path - 1) == '\"')
2409 colon = strchr(path, '\"');
2412 strncpy(filePath, path, colon - path);
2413 filePath[colon - path] = '\0';
2416 else if(path && !colon)
2418 strcpy(filePath, path);
2422 strcpy(completePath, prj.topNode.path);
2423 else if(dir && dir[0])
2424 strcpy(completePath, dir);
2426 completePath[0] = '\0';
2427 PathCat(completePath, filePath);
2429 fileAttribs = FileExists(completePath);
2430 if(fileAttribs.isFile)
2432 CodeEditor codeEditor = (CodeEditor)OpenFile(completePath, normal, true, "", no, normal);
2433 if(codeEditor && line)
2435 EditBox editBox = codeEditor.editBox;
2436 editBox.GoToLineNum(line - 1);
2437 editBox.GoToPosition(editBox.line, line - 1, col ? (col - 1) : 0);
2440 else if(fileAttribs.isDirectory)
2441 ShellOpen(completePath);
2444 void OnRedraw(Surface surface)
2446 Bitmap bitmap = back.bitmap;
2448 surface.Blit(bitmap, (clientSize.w - bitmap.width) / 2, (clientSize.h - bitmap.height) / 2, 0, 0, bitmap.width, bitmap.height);
2451 void SheetSelected(SheetType sheetSelected)
2453 if(activeChild == sheet)
2455 if(sheetSelected == methods)
2457 viewPropertiesItem.accelerator = f4;
2458 viewPropertiesItem.parent = viewMenu;
2459 viewMethodsItem.parent = null;
2463 viewMethodsItem.accelerator = f4;
2464 viewMethodsItem.parent = viewMenu;
2465 viewPropertiesItem.parent = null;
2470 viewMethodsItem.parent = viewMenu;
2471 viewPropertiesItem.parent = viewMenu;
2472 if(sheetSelected == methods)
2474 viewMethodsItem.accelerator = f4;
2475 viewPropertiesItem.accelerator = 0;
2479 viewMethodsItem.accelerator = 0;
2480 viewPropertiesItem.accelerator = f4;
2485 void OnActivateClient(Window client, Window previous)
2487 //if(!client || client != previous)
2490 if(!client || client != previous)
2493 dataType = previous._class;
2494 if(previous && !strcmp(dataType.name, "CodeEditor"))
2496 ((CodeEditor)previous).UpdateFormCode();
2498 else if(previous && !strcmp(dataType.name, "Designer"))
2500 ((Designer)previous).codeEditor.UpdateFormCode();
2505 dataType = client._class;
2506 if(client && !strcmp(dataType.name, "CodeEditor"))
2508 CodeEditor codeEditor = (CodeEditor)client;
2509 SetPrivateModule(codeEditor.privateModule);
2510 SetCurrentContext(codeEditor.globalContext);
2511 SetTopContext(codeEditor.globalContext);
2512 SetGlobalContext(codeEditor.globalContext);
2514 SetDefines(&codeEditor.defines);
2515 SetImports(&codeEditor.imports);
2517 SetActiveDesigner(codeEditor.designer);
2519 sheet.codeEditor = codeEditor;
2520 toolBox.codeEditor = codeEditor;
2522 viewDesignerItem.parent = viewMenu;
2523 if(activeChild != codeEditor)
2525 viewCodeItem.parent = viewMenu;
2526 viewDesignerItem.accelerator = 0;
2527 viewCodeItem.accelerator = f8;
2531 viewCodeItem.parent = null;
2532 viewDesignerItem.accelerator = f8;
2535 else if(client && !strcmp(dataType.name, "Designer"))
2537 CodeEditor codeEditor = ((Designer)client).codeEditor;
2540 SetPrivateModule(codeEditor.privateModule);
2541 SetCurrentContext(codeEditor.globalContext);
2542 SetTopContext(codeEditor.globalContext);
2543 SetGlobalContext(codeEditor.globalContext);
2544 SetDefines(&codeEditor.defines);
2545 SetImports(&codeEditor.imports);
2549 SetPrivateModule(null);
2550 SetCurrentContext(null);
2551 SetTopContext(null);
2552 SetGlobalContext(null);
2557 SetActiveDesigner((Designer)client);
2559 sheet.codeEditor = codeEditor;
2560 toolBox.codeEditor = codeEditor;
2562 viewCodeItem.parent = viewMenu;
2563 if(activeChild != client)
2565 viewDesignerItem.parent = viewMenu;
2566 viewDesignerItem.accelerator = f8;
2567 viewCodeItem.accelerator = 0;
2571 viewDesignerItem.parent = null;
2572 viewCodeItem.accelerator = f8;
2578 sheet.codeEditor = null;
2579 toolBox.codeEditor = null;
2580 SetActiveDesigner(null);
2582 viewDesignerItem.parent = null;
2583 viewCodeItem.parent = null;
2586 SheetSelected(sheet.sheetSelected);
2589 projectCompileItem = null;
2594 if(client && client._class == eSystem_FindClass(__thisModule, "CodeEditor")) // !strcmp(client._class.name, "CodeEditor")
2596 CodeEditor codeEditor = (CodeEditor)client;
2597 EditBox editBox = codeEditor.editBox;
2599 statusBar.AddField(pos);
2601 caps = { width = 40, text = $"CAPS", color = app.GetKeyState(capsState) ? black : Color { 128, 128, 128 } };
2602 statusBar.AddField(caps);
2604 ovr = { width = 30, text = $"OVR", color = editBox.overwrite ? black : Color { 128, 128, 128 } };
2605 statusBar.AddField(ovr);
2607 num = { width = 30, text = $"NUM", color = app.GetKeyState(numState) ? black : Color { 128, 128, 128 } };
2608 statusBar.AddField(num);
2610 //statusBar.text = "Ready";
2612 if(projectView && projectView.project)
2614 bool isCObject = false;
2615 ProjectNode node = projectView.GetNodeFromWindow(client, null, false);
2616 if(!node && (node = projectView.GetNodeFromWindow(client, null, true)))
2620 char nodeName[MAX_FILENAME];
2621 char name[MAX_FILENAME+96];
2623 ChangeExtension(node.name, "c", nodeName);
2624 sprintf(name, $"Compile %s", isCObject ? nodeName : node.name);
2625 projectCompileItem =
2627 copyText = true, text = name, c, ctrlF7, disabled = projectView.buildInProgress;
2629 bool NotifySelect(MenuItem selection, Modifiers mods)
2633 bool result = false;
2634 bool isCObject = false;
2635 ProjectNode node = null;
2636 for(p : ide.workspace.projects)
2638 node = projectView.GetNodeFromWindow(activeClient, p, false);
2641 if(!node && (node = projectView.GetNodeFromWindow(activeClient, null, true)))
2645 List<ProjectNode> nodes { };
2647 projectView.Compile(node.project, nodes, mods.ctrl && mods.shift, isCObject ? cObject : normal);
2652 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
2657 projectMenu.AddDynamic(projectCompileItem, ide, false);
2663 caps = ovr = num = null;
2668 bool OnClose(bool parentClosing)
2670 //return !projectView.buildInProgress;
2671 if(projectView && projectView.buildInProgress)
2673 if(DontTerminateDebugSession($"Close IDE"))
2675 if(findInFilesDialog)
2676 findInFilesDialog.SearchStop();
2679 workspace.timer.Stop();
2682 ideMainFrame.Destroy(0);
2689 bool passThrough = false;
2690 bool debugStart = false;
2691 DynamicString passArgs { };
2692 for(c = 1; c<app.argc; c++)
2694 if(!strcmp(app.argv[c], "-debug-start"))
2696 else if(!passThrough && !strcmp(app.argv[c], "-@"))
2698 else if(passThrough)
2700 passArgs.concat(" ");
2701 passArgs.concat(app.argv[c]);
2705 char fullPath[MAX_LOCATION];
2706 char parentPath[MAX_LOCATION];
2707 char ext[MAX_EXTENSION];
2709 FileAttribs dirAttribs;
2710 GetWorkingDir(fullPath, MAX_LOCATION);
2711 PathCat(fullPath, app.argv[c]);
2712 StripLastDirectory(fullPath, parentPath);
2713 GetExtension(app.argv[c], ext);
2714 isProject = !strcmpi(ext, "epj");
2716 if(isProject && c > (debugStart ? 2 : 1)) continue;
2718 // Create directory for projects (only)
2719 if(((dirAttribs = FileExists(parentPath)) && dirAttribs.isDirectory) || isProject)
2721 if(isProject && !FileExists(fullPath))
2723 // The NewProject will handle directory creation
2724 /*if(!dirAttribs.isDirectory)
2726 MakeDir(parentPath);
2727 dirAttribs = FileExists(parentPath);
2729 if(dirAttribs.isDirectory)*/
2731 char name[MAX_LOCATION];
2732 NewProjectDialog newProjectDialog;
2736 projectView.visible = false;
2737 if(!projectView.Destroy(0))
2741 newProjectDialog = { master = this };
2743 strcpy(name, app.argv[c]);
2744 StripExtension(name);
2745 GetLastDirectory(name, name);
2746 newProjectDialog.projectName.contents = name;
2747 newProjectDialog.projectName.NotifyModified(newProjectDialog, newProjectDialog.projectName);
2748 newProjectDialog.locationEditBox.path = parentPath;
2749 newProjectDialog.NotifyModifiedLocation(newProjectDialog.locationEditBox);
2751 newProjectDialog.Modal();
2754 ideSettings.AddRecentProject(projectView.fileName);
2755 ide.UpdateRecentMenus();
2756 settingsContainer.Save();
2759 // Open only one project
2763 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, null, yes, normal);
2765 else if(strstr(fullPath, "http://") == fullPath)
2766 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, null, yes, normal);
2769 if(passThrough && projectView && projectView.project && workspace)
2770 workspace.commandLineArgs = passArgs;
2773 ;//MenuDebugStart(debugStartResumeItem, 0); // <-- how TODO this without getting into the app.Wait lock
2775 UpdateToolBarActiveConfigs(false);
2776 UpdateToolBarActiveCompilers();
2782 // IS THIS NEEDED? WASN'T HERE BEFORE... Crashes on getting node's projectView otherwise
2785 projectView.visible = false;
2786 projectView.Destroy(0);
2789 #ifdef GDB_DEBUG_GUI
2790 gdbDialog.Destroy(0);
2795 void SetPath(bool projectsDirs, CompilerConfig compiler, ProjectConfig config, int bitDepth)
2799 char * oldPaths[128];
2800 String oldList = new char[maxPathLen];
2801 Array<String> newExePaths { };
2802 //Map<String, bool> exePathExists { };
2804 #if defined(__unix__) || defined(__APPLE__)
2805 Array<String> newLibPaths { };
2806 Map<String, bool> libPathExists { };
2811 for(prj : workspace.projects)
2813 DirExpression targetDirExp;
2815 // SKIP FIRST PROJECT...
2816 if(prj == workspace.projects.firstIterator.data) continue;
2818 // NOTE: Right now the additional project config dir will be
2819 // obtained when the debugger is started, so toggling it
2820 // while building will change which library gets used.
2821 // To go with the initial state, e.g. when F5 was pressed,
2822 // we nould need to keep a list of all project's active
2823 // config upon startup.
2824 targetDirExp = prj.GetTargetDir(compiler, prj.config, bitDepth);
2826 /*if(prj.config.targetType == sharedLibrary && prj.config.debug)
2830 for(cfg = prj.configurations.first; cfg; cfg = cfg.next)
2831 if(cfg.targetType == sharedLibrary && cfg.debug && !strcmpi(cfg.name, "Debug"))
2835 for(cfg = prj.configurations.first; cfg; cfg = cfg.next)
2836 if(cfg.targetType == sharedLibrary && cfg.debug)
2840 if(targetDirExp.dir)
2842 char buffer[MAX_LOCATION];
2843 #if defined(__WIN32__)
2844 Array<String> paths = newExePaths;
2846 Array<String> paths = newLibPaths;
2848 GetSystemPathBuffer(buffer, prj.topNode.path);
2849 PathCat(buffer, targetDirExp.dir);
2852 if(!fstrcmp(p, buffer))
2859 paths.Add(CopyString(buffer));
2861 delete targetDirExp;
2865 for(item : compiler.executableDirs)
2868 for(p : newExePaths)
2870 if(!fstrcmp(p, item))
2877 newExePaths.Add(CopySystemPath(item));
2880 GetEnvironment("PATH", oldList, maxPathLen);
2882 printf("Old value of PATH: %s\n", oldList);
2884 count = TokenizeWith(oldList, sizeof(oldPaths) / sizeof(char *), oldPaths, pathListSep, false);
2885 for(c = 0; c < count; c++)
2888 for(p : newExePaths)
2890 if(!fstrcmp(p, oldPaths[c]))
2897 newExePaths.Add(CopySystemPath(oldPaths[c]));
2901 for(path : newExePaths)
2902 len += strlen(path) + 1;
2903 newList = new char[len + 1];
2905 for(path : newExePaths)
2907 strcat(newList, path);
2908 strcat(newList, pathListSep);
2910 newList[len - 1] = '\0';
2911 SetEnvironment("PATH", newList);
2913 printf("New value of PATH: %s\n", newList);
2920 #if defined(__unix__) || defined(__APPLE__)
2922 for(item : compiler.libraryDirs)
2924 if(!libPathExists[item]) // fstrcmp should be used
2926 newLibPaths.Add(item);
2927 libPathExists[item] = true;
2931 #if defined(__APPLE__)
2932 GetEnvironment("DYLD_LIBRARY_PATH", oldList, maxPathLen);
2934 GetEnvironment("LD_LIBRARY_PATH", oldList, maxPathLen);
2937 printf("Old value of [DY]LD_LIBRARY_PATH: %s\n", oldList);
2939 count = TokenizeWith(oldList, sizeof(oldPaths) / sizeof(char *), oldPaths, pathListSep, false);
2940 for(c = 0; c < count; c++)
2942 if(!libPathExists[oldPaths[c]]) // fstrcmp should be used
2944 newLibPaths.Add(oldPaths[c]);
2945 libPathExists[oldPaths[c]] = true;
2950 for(path : newLibPaths)
2951 len += strlen(path) + 1;
2952 newList = new char[len + 1];
2954 for(path : newLibPaths)
2956 strcat(newList, path);
2957 strcat(newList, pathListSep);
2959 newList[len - 1] = '\0';
2960 #if defined(__APPLE__)
2961 SetEnvironment("DYLD_LIBRARY_PATH", newList);
2963 SetEnvironment("LD_LIBRARY_PATH", newList);
2966 printf("New value of [DY]LD_LIBRARY_PATH: %s\n", newList);
2971 delete libPathExists;
2974 if(compiler.distccEnabled && compiler.distccHosts)
2975 SetEnvironment("DISTCC_HOSTS", compiler.distccHosts);
2980 void DestroyTemporaryProjectDir()
2982 if(tmpPrjDir && tmpPrjDir[0])
2984 if(FileExists(tmpPrjDir).isDirectory)
2985 DestroyDir(tmpPrjDir);
2986 property::tmpPrjDir = null;
2992 // Graphics Driver Menu
2996 app.currentSkin.selectionColor = selectionColor;
2997 app.currentSkin.selectionText = selectionText;
3001 driverItems = new MenuItem[app.numDrivers];
3002 for(c = 0; c < app.numDrivers; c++)
3004 driverItems[c] = MenuItem { driversMenu, app.drivers[c], NotifySelect = NotifySelectDisplayDriver };
3005 driverItems[c].id = c;
3006 driverItems[c].isRadio = true;
3009 driverItems = new MenuItem[2];
3010 #if defined(__unix__)
3011 driverItems[0] = MenuItem { driversMenu, "X", NotifySelect = NotifySelectDisplayDriver };
3012 driverItems[0].id = 0;
3013 driverItems[0].isRadio = true;
3015 driverItems[0] = MenuItem { driversMenu, "GDI", NotifySelect = NotifySelectDisplayDriver };
3016 driverItems[0].id = 0;
3017 driverItems[0].isRadio = true;
3019 driverItems[1] = MenuItem { driversMenu, "OpenGL", NotifySelect = NotifySelectDisplayDriver };
3020 driverItems[1].id = 1;
3021 driverItems[1].isRadio = true;
3023 /* skinItems = new MenuItem[app.numSkins];
3024 for(c = 0; c < app.numSkins; c++)
3026 skinItems[c] = MenuItem {skinsMenu, app.skins[c], NotifySelect = NotifySelectDisplaySkin };
3027 skinItems[c].id = c;
3028 skinItems[c].isRadio = true;
3031 ideFileDialog.master = this;
3032 ideProjectFileDialog.master = this;
3034 //SetDriverAndSkin();
3038 void UpdateRecentMenus()
3041 Menu fileMenu = menu.FindMenu($"File");
3042 Menu recentFiles = fileMenu.FindMenu($"Recent Files");
3043 Menu recentProjects = fileMenu.FindMenu($"Recent Projects");
3044 char itemName[MAX_LOCATION + 4];
3047 recentFiles.Clear();
3050 for(recent : ideSettings.recentFiles)
3052 sprintf(itemName, "%d %s", 1 + c, recent);
3053 MakeSystemPath(itemName);
3054 recentFiles.AddDynamic(MenuItem { copyText = true, text = itemName, (Key)k1 + c, id = c, NotifySelect = ide.FileRecentFile }, ide, true);
3058 recentProjects.Clear();
3060 for(recent : ideSettings.recentProjects)
3062 sprintf(itemName, "%d %s", 1 + c, recent);
3063 MakeSystemPath(itemName);
3064 recentProjects.AddDynamic(MenuItem { copyText = true, text = itemName, (Key)k1 + c, id = c, NotifySelect = ide.FileRecentProject }, ide, true);
3077 void DestroyDir(char * path)
3079 RecursiveDeleteFolderFSI fsi { };
3084 class RecursiveDeleteFolderFSI : NormalFileSystemIterator
3086 bool preserveRootFolder;
3088 void OutFolder(char * folderPath, bool isRoot)
3090 if(!(preserveRootFolder && isRoot))
3091 RemoveDir(folderPath);
3094 bool OnFile(char * filePath)
3096 DeleteFile(filePath);
3101 class IDEApp : GuiApplication
3103 //driver = "Win32Console";
3104 // driver = "OpenGL";
3108 TempFile includeFile { };
3112 SetLoggingMode(stdOut, null);
3113 //SetLoggingMode(debug, null);
3115 settingsContainer.Load();
3116 #if defined(__unix__) || defined(__APPLE__)
3117 app.driver = (ideSettings.displayDriver && !strcmp(ideSettings.displayDriver, "OpenGL")) ? ideSettings.displayDriver : "X";
3119 app.driver = (ideSettings.displayDriver && !strcmp(ideSettings.displayDriver, "OpenGL")) ? ideSettings.displayDriver : "GDI";
3121 ide.driverItems[ideSettings.displayDriver && !strcmp(ideSettings.displayDriver,"OpenGL")].checked = true;
3125 desktop.text = titleECEREIDE;
3128 for(c = 1; c<app.argc; c++)
3130 char fullPath[MAX_LOCATION];
3131 GetWorkingDir(fullPath, MAX_LOCATION);
3132 PathCat(fullPath, app.argv[c]);
3133 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, null, yes, normal);
3137 if(!LoadIncludeFile())
3138 PrintLn("error: unable to load :crossplatform.mk file inside ide binary.");
3143 bool LoadIncludeFile()
3145 bool result = false;
3146 File include = FileOpen(":crossplatform.mk", read);
3149 File f = includeFile;
3152 for(; !include.Eof(); )
3155 int count = include.Read(buffer, 1, 4096);
3156 f.Write(buffer, 1, count);
3166 IDEMainFrame ideMainFrame { };
3168 define app = ((IDEApp)__thisModule);
3170 define titleECEREIDE = $"ECERE IDE (Debug)";
3172 define titleECEREIDE = $"ECERE IDE";