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 Window spacer7 { this, size = { 4 } };
329 class IDEMainFrame : Window
331 background = formColor;
332 borderStyle = sizable;
336 minClientSize = { 600, 300 };
338 icon = { ":icon.png" };
339 text = titleECEREIDE;
343 anchor = { top = 0, right = 0, bottom = 0 };
346 anchor = { left = 0, top = 0, right = 0, bottom = 0 };
353 isActiveClient = true;
355 direction = vertical;
356 background = formColor;
357 anchor = { left = 0, top = 0, right = 0, bottom = 0 };
365 ((IDEWorkSpace)master).toolBar = null;
368 IDEWorkSpace ideWorkSpace { stack, this, toolBar = toolBar };
371 define ide = ideMainFrame.ideWorkSpace;
373 class IDEWorkSpace : Window
375 background = Color { 85, 85, 85 };
378 hasVertScroll = true;
379 hasHorzScroll = true;
381 isActiveClient = true;
382 anchor = { left = 0, top = 0, right = 0, bottom = 0 };
386 MenuItem * driverItems, * skinItems;
387 StatusField pos { width = 150 };
388 StatusField ovr, caps, num;
390 BitmapResource back { ":ecereBack.jpg", window = this };
391 BitmapResource bmpBp { ":codeMarks/breakpoint.png", window = this };
392 BitmapResource bmpBpDisabled { ":codeMarks/breakpointDisabled.png", window = this };
393 BitmapResource bmpBpHalf { ":codeMarks/breakpointHalf.png", window = this };
394 BitmapResource bmpBpHalfDisabled { ":codeMarks/breakpointHalfDisabled.png", window = this };
395 BitmapResource bmpCursor { ":codeMarks/cursor.png", window = this };
396 BitmapResource bmpCursorError { ":codeMarks/cursorError.png", window = this };
397 BitmapResource bmpTopFrame { ":codeMarks/topFrame.png", window = this };
398 BitmapResource bmpTopFrameError { ":codeMarks/topFrameError.png", window = this };
399 BitmapResource bmpTopFrameHalf { ":codeMarks/topFrameHalf.png", window = this };
400 BitmapResource bmpTopFrameHalfError { ":codeMarks/topFrameHalfError.png", window = this };
402 Debugger debugger { };
404 ProjectView projectView;
406 OutputView outputView
410 void OnGotoError(char * line)
415 void OnCodeLocationParseAndGoTo(char * line)
417 ide.CodeLocationParseAndGoTo(line, ide.findInFilesDialog.findProject, ide.findInFilesDialog.findDir);
420 bool OnKeyDown(Key key, unichar ch)
425 if(!ide.findInFilesDialog || !ide.findInFilesDialog.SearchAbort())
426 ide.ShowCodeEditor();
429 ide.projectView.stopBuild = true;
433 OutputView::OnKeyDown(key, ch);
440 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
443 ide.RepositionWindows(false);
447 bool OnClose(bool parentClosing)
451 ide.RepositionWindows(false);
452 return parentClosing;
456 CallStackView callStackView
458 parent = this, font = { panelFont.faceName, panelFont.size };
460 void OnGotoLine(char * line)
463 stackLvl = atoi(line);
464 ide.debugger.GoToStackFrameLine(stackLvl, true);
467 void OnSelectFrame(int lineNumber)
469 ide.debugger.SelectFrame(lineNumber);
472 void OnToggleBreakpoint()
474 Debugger debugger = ide.debugger;
475 if(debugger.activeFrame && debugger.activeFrame.absoluteFile)
477 int line = debugger.activeFrame.line;
478 char name[MAX_LOCATION];
480 // TOFIX: Improve on this, don't use only filename, make a function
481 GetLastDirectory(debugger.activeFrame.absoluteFile, name);
482 if(ide && ide.workspace)
484 for(p : ide.workspace.projects)
486 if(p.topNode.Find(name, false))
494 for(p : ide.workspace.projects)
496 if(IsPathInsideOf(debugger.activeFrame.absoluteFile, p.topNode.path))
504 debugger.ToggleBreakpoint(debugger.activeFrame.absoluteFile, line, prj);
507 CodeEditor codeEditor = (CodeEditor)ide.FindWindow(debugger.activeFrame.absoluteFile);
508 if(codeEditor) { codeEditor.Update(null); Activate(); }
513 bool OnKeyDown(Key key, unichar ch)
517 case escape: ide.ShowCodeEditor(); break;
522 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
525 ide.RepositionWindows(false);
529 bool OnClose(bool parentClosing)
533 ide.RepositionWindows(false);
534 return parentClosing;
537 void OnRedraw(Surface surface)
539 Debugger debugger = ide.debugger;
540 Frame activeFrame = debugger.activeFrame;
544 int lineCursor, lineTopFrame, activeThread, hitThread;
545 int lineH, scrollY, boxH;
547 Breakpoint bp = null;
550 scrollY = editBox.scroll.y;
551 displaySystem.FontExtent(editBox.font.font, " ", 1, null, &lineH);
552 activeThread = debugger.activeThread;
553 hitThread = debugger.hitThread;
554 debugger.GetCallStackCursorLine(&error, &lineCursor, &lineTopFrame);
556 // TODO: improve bp drawing... it should be visible even if it's not on the activeFrame
557 if(activeFrame.absoluteFile)
559 for(i : ide.workspace.breakpoints; i.type == user)
561 if(i.absoluteFilePath && i.absoluteFilePath[0] &&
562 !fstrcmp(i.absoluteFilePath, activeFrame.absoluteFile) &&
563 activeFrame.line == i.line)
571 DrawLineMarginIcon(surface,
572 /*(lineCursor == 1 || lineTopFrame == 1) ? */ide.bmpBpHalf/* : ide.bmpBp*/,
573 lineCursor /*1*/, lineH, scrollY, boxH);
575 if(activeThread && activeThread == hitThread && debugger.bpHit && debugger.bpHit.type == user)
576 DrawLineMarginIcon(surface,
577 (lineCursor == 1 || lineTopFrame == 1) ? ide.bmpBpHalf : ide.bmpBp,
578 1, lineH, scrollY, boxH);
580 DrawLineMarginIcon(surface, error ? ide.bmpCursorError : ide.bmpCursor, lineCursor, lineH, scrollY, boxH);
581 if(bp && lineCursor == 1) //activeThread && activeThread == hitThread && debugger.bpHit && debugger.bpHit.type == user)
582 bmp = error ? ide.bmpTopFrameHalfError : ide.bmpTopFrameHalf;
584 bmp = error ? ide.bmpTopFrameError : ide.bmpTopFrame;
585 DrawLineMarginIcon(surface, bmp, lineTopFrame, lineH, scrollY, boxH);
587 if(editBox.horzScroll && editBox.horzScroll.visible)
589 surface.SetBackground(control);
590 surface.Area(0, editBox.clientSize.h, 20 - 1, clientSize.h - 1);
595 WatchesView watchesView { parent = this };
596 ThreadsView threadsView
598 parent = this, font = { panelFont.faceName, panelFont.size };
600 bool OnKeyDown(Key key, unichar ch)
604 case escape: ide.ShowCodeEditor(); break;
609 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
612 ide.RepositionWindows(false);
616 bool OnClose(bool parentClosing)
620 ide.RepositionWindows(false);
621 return parentClosing;
624 void OnSelectThread(int threadId)
627 ide.debugger.SelectThread(threadId);
630 bool OnGetThreadsInfo(int * activeThread, int * hitThread, int * signalThread)
633 Debugger debugger = ide.debugger;
634 *activeThread = debugger.activeThread;
635 *hitThread = debugger.hitThread;
636 *signalThread = debugger.signalThread;
641 BreakpointsView breakpointsView { parent = this };
643 ToolBox toolBox { parent = this };
644 Sheet sheet { parent = this };
647 property char * tmpPrjDir { set { delete tmpPrjDir; if(value) tmpPrjDir = CopyString(value); } get { return tmpPrjDir; } };
649 Menu fileMenu { menu, $"File", f, hasMargin = true };
652 fileMenu, $"New", n, ctrlN;
653 bitmap = { ":actions/docNew.png" };
654 bool NotifySelect(MenuItem selection, Modifiers mods)
656 Window document = (Window)NewCodeEditor(this, normal, false);
657 document.NotifySaved = DocumentSaved;
661 MenuItem fileOpenItem
663 fileMenu, $"Open...", o, ctrlO;
664 bitmap = { ":actions/docOpen.png" };
665 bool NotifySelect(MenuItem selection, Modifiers mods)
667 if(!projectView && ideSettings.ideFileDialogLocation)
668 ideFileDialog.currentDirectory = ideSettings.ideFileDialogLocation;
671 if(ideFileDialog.Modal() == ok)
673 bool gotWhatWeWant = false;
675 int numSelections = ideFileDialog.numSelections;
676 char ** multiFilePaths = ideFileDialog.multiFilePaths;
678 for(c = 0; c < numSelections; c++)
680 if(OpenFile(multiFilePaths[c], normal, true, fileTypes[ideFileDialog.fileType].typeExtension, no, normal))
681 gotWhatWeWant = true;
684 MessageBox { type = yesNo, master = this, text = $"Error opening file",
685 contents = $"Open a different file?" }.Modal() == no)
687 if(!projectView && gotWhatWeWant)
688 ChangeFileDialogsDirectory(ideFileDialog.currentDirectory, true);
698 MenuItem fileCloseItem { fileMenu, $"Close", c, ctrlF4, NotifySelect = MenuFileClose };
699 MenuDivider { fileMenu };
700 MenuItem fileSaveItem
702 fileMenu, $"Save", s, ctrlS, bitmap = { ":actions/docSave.png" };
704 // For the toolbar button; clients can still override that for the menu item
705 bool Window::NotifySelect(MenuItem selection, Modifiers mods)
707 Window w = activeClient;
709 w.MenuFileSave(null, 0);
713 MenuItem fileSaveAsItem { fileMenu, $"Save As...", a };
714 MenuItem fileSaveAllItem { fileMenu, $"Save All", l, NotifySelect = MenuFileSaveAll, bitmap = { ":actions/docSaveAll.png" } };
715 MenuDivider { fileMenu };
718 fileMenu, $"Find In Files...", f, Key { f, ctrl = true , shift = true };
719 bool NotifySelect(MenuItem selection, Modifiers mods)
721 findInFilesDialog.replaceMode = false;
722 findInFilesDialog.Show();
726 MenuItem replaceInFiles
728 fileMenu, $"Replace In Files...", e, Key { r, ctrl = true , shift = true };
729 bool NotifySelect(MenuItem selection, Modifiers mods)
731 findInFilesDialog.replaceMode = true;
732 findInFilesDialog.Show();
736 MenuDivider { fileMenu };
737 MenuItem globalSettingsItem
739 fileMenu, $"Global Settings...", g;
740 bool NotifySelect(MenuItem selection, Modifiers mods)
742 globalSettingsDialog.master = this;
743 if(ide.workspace && ide.workspace.compiler)
744 globalSettingsDialog.workspaceActiveCompiler = ide.workspace.compiler;
745 else if(ideSettings.defaultCompiler)
746 globalSettingsDialog.workspaceActiveCompiler = ideSettings.defaultCompiler;
747 globalSettingsDialog.Modal();
751 MenuDivider { fileMenu };
752 Menu recentFiles { fileMenu, $"Recent Files", r };
753 Menu recentProjects { fileMenu, $"Recent Projects", p };
754 MenuDivider { fileMenu };
757 fileMenu, $"Exit", x, altF4, NotifySelect = MenuFileExit;
759 bool NotifySelect(MenuItem selection, Modifiers mods)
761 ideMainFrame.Destroy(0);
766 bool FileRecentFile(MenuItem selection, Modifiers mods)
769 for(file : ideSettings.recentFiles)
771 if(id == selection.id)
773 if(mods.ctrl) // Menu::OnLeftButtonUp -> modifiers.ctrl == true, modifiers == 18
774 // Menu::MenuItemSelection -> key.ctrl == false, key.modifiers.ctrl == false, key == 18
775 // removing the (Key) cast from Modifiers when calling MenuItemSelection in OnLeftButtonUp didn't help
777 // it never gets in here!!!
778 char * command = PrintString("ide ", file);
783 OpenFile(file, normal, true, null, no, normal);
791 bool FileRecentProject(MenuItem selection, Modifiers mods)
794 for(file : ideSettings.recentProjects)
796 if(id == selection.id)
798 if(mods.ctrl) // Menu::OnLeftButtonUp -> modifiers.ctrl == true, modifiers == 18
799 // Menu::MenuItemSelection -> key.ctrl == false, key.modifiers.ctrl == false, key == 18
800 // removing the (Key) cast from Modifiers when calling MenuItemSelection in OnLeftButtonUp didn't help
802 // it never gets in here!!!
803 char * command = PrintString("ide ", file);
808 OpenFile(file, normal, true, null, no, normal);
816 MenuPlacement editMenu { menu, $"Edit", e };
818 Menu projectMenu { menu, $"Menu"."Project", p, hasMargin = true };
819 MenuItem projectNewItem
821 projectMenu, $"New...", n, Key { n, true, true };
822 bitmap = { ":actions/projNew.png" };
823 bool NotifySelect(MenuItem selection, Modifiers mods)
825 if(!DontTerminateDebugSession($"New Project"))
826 if(MenuWindowCloseAll(null, 0))
828 NewProjectDialog newProjectDialog;
832 projectView.visible = false;
833 if(!projectView.Destroy(0))
837 newProjectDialog = { master = this };
838 newProjectDialog.Modal();
841 ideSettings.AddRecentProject(projectView.fileName);
842 ide.UpdateRecentMenus();
843 settingsContainer.Save();
849 MenuItem projectOpenItem
851 projectMenu, $"Open...", o, Key { o, true, true };
852 bitmap = { ":actions/projOpen.png" };
853 bool NotifySelect(MenuItem selection, Modifiers mods)
855 if(ideSettings.ideProjectFileDialogLocation)
856 ideProjectFileDialog.currentDirectory = ideSettings.ideProjectFileDialogLocation;
858 ideProjectFileDialog.text = openProjectFileDialogTitle;
859 if(ideProjectFileDialog.Modal() == ok)
861 OpenFile(ideProjectFileDialog.filePath, normal, true, projectTypes[ideProjectFileDialog.fileType].typeExtension, no, normal);
862 //ChangeProjectFileDialogDirectory(ideProjectFileDialog.currentDirectory);
867 MenuItem projectQuickItem
869 projectMenu, $"Quick...", q, f7, disabled = true;
870 bool NotifySelect(MenuItem selection, Modifiers mods)
873 QuickProjectDialog { this }.Modal();
877 MenuItem projectAddItem
879 projectMenu, $"Add project to workspace...", a, Key { a, true, true };
880 bitmap = { ":actions/projAdd.png" };
882 bool NotifySelect(MenuItem selection, Modifiers mods)
884 if(ideSettings.ideProjectFileDialogLocation)
885 ideProjectFileDialog.currentDirectory = ideSettings.ideProjectFileDialogLocation;
887 ideProjectFileDialog.text = addProjectFileDialogTitle;
890 if(ideProjectFileDialog.Modal() == ok)
892 if(OpenFile(ideProjectFileDialog.filePath, normal, true, projectTypes[ideProjectFileDialog.fileType].typeExtension, no, add))
894 if(MessageBox { type = yesNo, master = this, text = $"Error opening project file",
895 contents = $"Add a different project?" }.Modal() == no)
906 MenuItem projectCloseItem
908 projectMenu, $"Close", c, disabled = true;
909 bool NotifySelect(MenuItem selection, Modifiers mods)
913 if(!ide.DontTerminateDebugSession($"Project Close"))
915 if(findInFilesDialog)
916 findInFilesDialog.SearchStop();
917 projectView.visible = false;
918 if(projectView.Destroy(0))
919 MenuWindowCloseAll(null, 0);
921 char workingDir[MAX_LOCATION];
922 GetWorkingDir(workingDir, MAX_LOCATION);
923 findInFilesDialog.currentDirectory = workingDir;
924 ideMainFrame.text = titleECEREIDE;
931 MenuDivider { projectMenu };
932 MenuItem projectSettingsItem
934 projectMenu, $"Settings...", s, altF7, disabled = true;
935 bool NotifySelect(MenuItem selection, Modifiers mods)
937 projectView.MenuSettings(projectView.active ? selection : null, mods);
941 MenuDivider { projectMenu };
942 MenuItem projectBrowseFolderItem
944 projectMenu, $"Browse Project Folder", p, disabled = true;
945 bool NotifySelect(MenuItem selection, Modifiers mods)
948 projectView.MenuBrowseFolder(null, mods);
952 MenuDivider { projectMenu };
953 MenuItem projectRunItem
955 projectMenu, $"Run", r, ctrlF5, disabled = true;
956 bitmap = { ":actions/run.png" };
957 bool NotifySelect(MenuItem selection, Modifiers mods)
960 projectView.Run(null, mods);
964 MenuItem projectBuildItem
966 projectMenu, $"Build", b, f7, disabled = true;
967 bitmap = { ":actions/build.png" };
968 bool NotifySelect(MenuItem selection, Modifiers mods)
971 projectView.ProjectBuild(projectView.active ? selection : null, mods);
975 MenuItem projectLinkItem
977 projectMenu, $"Relink", l, disabled = true;
978 bitmap = { ":actions/relink.png" };
979 bool NotifySelect(MenuItem selection, Modifiers mods)
982 projectView.ProjectLink(projectView.active ? selection : null, mods);
986 MenuItem projectRebuildItem
988 projectMenu, $"Rebuild", d, shiftF7, disabled = true;
989 bitmap = { ":actions/rebuild.png" };
990 bool NotifySelect(MenuItem selection, Modifiers mods)
993 projectView.ProjectRebuild(projectView.active ? selection : null, mods);
997 MenuItem projectCleanItem
999 projectMenu, $"Clean", e, disabled = true;
1000 bitmap = { ":actions/clean.png" };
1001 bool NotifySelect(MenuItem selection, Modifiers mods)
1006 projectView.ProjectClean(projectView.active ? selection : null, mods);
1011 MenuItem projectRealCleanItem
1013 projectMenu, $"Real Clean", disabled = true;
1014 bitmap = { ":actions/clean.png" };
1015 bool NotifySelect(MenuItem selection, Modifiers mods)
1020 projectView.ProjectRealClean(projectView.active ? selection : null, mods);
1025 MenuItem projectRegenerateItem
1027 projectMenu, $"Regenerate Makefile", m, disabled = true;
1028 bitmap = { ":actions/regMakefile.png" };
1029 bool NotifySelect(MenuItem selection, Modifiers mods)
1032 projectView.ProjectRegenerate(projectView.active ? selection : null, mods);
1036 MenuItem projectCompileItem;
1037 Menu debugMenu { menu, $"Debug", d, hasMargin = true };
1038 MenuItem debugStartResumeItem
1040 debugMenu, $"Start", s, f5, disabled = true;
1041 bitmap = { ":actions/debug.png" };
1042 NotifySelect = MenuDebugStart;
1044 bool MenuDebugStart(MenuItem selection, Modifiers mods)
1048 debugStartResumeItem.disabled = true; // a very rare exception to calling AdjustDebugMenus
1049 if(!projectView.DebugStart())
1050 debugStartResumeItem.disabled = false; // same exception
1054 bool MenuDebugResume(MenuItem selection, Modifiers mods)
1057 projectView.DebugResume();
1060 MenuItem debugRestartItem
1062 debugMenu, $"Restart", r, Key { f5, ctrl = true, shift = true }, disabled = true;
1063 bitmap = { ":actions/restart.png" };
1064 bool NotifySelect(MenuItem selection, Modifiers mods)
1067 projectView.DebugRestart();
1071 MenuItem debugBreakItem
1073 debugMenu, $"Break", b, Key { pauseBreak, ctrl = true }, disabled = true;
1074 bitmap = { ":actions/pause.png" };
1075 bool NotifySelect(MenuItem selection, Modifiers mods)
1078 projectView.DebugBreak();
1082 MenuItem debugStopItem
1084 debugMenu, $"Stop", p, shiftF5, disabled = true;
1085 bitmap = { ":actions/stopDebug.png" };
1086 bool NotifySelect(MenuItem selection, Modifiers mods)
1089 projectView.DebugStop();
1093 MenuDivider { debugMenu };
1094 MenuItem debugStepIntoItem
1096 debugMenu, $"Step Into", i, f11, disabled = true;
1097 bitmap = { ":actions/stepInto.png" };
1098 bool NotifySelect(MenuItem selection, Modifiers mods)
1101 projectView.DebugStepInto();
1105 MenuItem debugStepOverItem
1107 debugMenu, $"Step Over", v, f10, disabled = true;
1108 bitmap = { ":actions/stepOver.png" };
1109 bool NotifySelect(MenuItem selection, Modifiers mods)
1112 projectView.DebugStepOver(false);
1116 MenuItem debugStepOutItem
1118 debugMenu, $"Step Out", o, shiftF11, disabled = true;
1119 bitmap = { ":actions/stepOut.png" };
1120 bool NotifySelect(MenuItem selection, Modifiers mods)
1123 projectView.DebugStepOut(false);
1127 MenuPlacement debugRunToCursorItem { debugMenu, $"Run To Cursor", c };
1128 MenuItem debugSkipStepOverItem
1130 debugMenu, $"Step Over Skipping Breakpoints", e, shiftF10, disabled = true;
1131 bool NotifySelect(MenuItem selection, Modifiers mods)
1134 projectView.DebugStepOver(true);
1138 MenuItem debugSkipStepOutItem
1140 debugMenu, $"Step Out Skipping Breakpoints", t, Key { f11, ctrl = true, shift = true }, disabled = true;
1141 bitmap = { ":actions/skipBreaks.png" };
1142 bool NotifySelect(MenuItem selection, Modifiers mods)
1145 projectView.DebugStepOut(true);
1149 MenuPlacement debugSkipRunToCursorItem { debugMenu, $"Run To Cursor Skipping Breakpoints", u };
1150 //MenuDivider { debugMenu };
1151 //MenuPlacement debugToggleBreakpoint { debugMenu, "Toggle Breakpoint", t };
1152 MenuPlacement imageMenu { menu, $"Image", i };
1153 Menu viewMenu { menu, $"View", v };
1154 MenuItem viewProjectItem
1156 viewMenu, $"Project View", j, alt0, disabled = true;
1157 bool NotifySelect(MenuItem selection, Modifiers mods)
1161 projectView.visible = true;
1162 projectView.Activate();
1167 MenuPlacement { viewMenu, $"View Designer" };
1168 MenuPlacement { viewMenu, $"View Code" };
1169 MenuPlacement { viewMenu, $"View Properties" };
1170 MenuPlacement { viewMenu, $"View Methods" };
1171 MenuItem viewDesignerItem
1173 viewMenu, $"View Designer", d, f8;
1174 bool NotifySelect(MenuItem selection, Modifiers mods)
1176 Window client = activeClient;
1177 Class dataType = client._class;
1178 if(!strcmp(dataType.name, "Designer"))
1180 client.visible = true;
1184 ((CodeEditor)client).ViewDesigner();
1188 MenuItem viewCodeItem
1190 viewMenu, $"View Code", c, f8;
1191 bool NotifySelect(MenuItem selection, Modifiers mods)
1193 Window client = activeClient;
1194 Class dataType = client._class;
1195 if(!strcmp(dataType.name, "Designer"))
1196 client = ((Designer)client).codeEditor;
1199 // Do this after so the caret isn't moved yet...
1200 client.visible = true;
1204 MenuItem viewPropertiesItem
1206 viewMenu, $"View Properties", p, f4;
1207 bool NotifySelect(MenuItem selection, Modifiers mods)
1209 sheet.visible = true;
1210 sheet.sheetSelected = properties;
1215 MenuItem viewMethodsItem
1217 viewMenu, $"View Methods", m, f4;
1218 bool NotifySelect(MenuItem selection, Modifiers mods)
1220 sheet.visible = true;
1221 sheet.sheetSelected = methods;
1226 MenuItem viewToolBoxItem
1228 viewMenu, $"View Toolbox", x, f12;
1229 bool NotifySelect(MenuItem selection, Modifiers mods)
1231 toolBox.visible = true;
1236 MenuItem viewOutputItem
1238 viewMenu, $"Output", o, alt2;
1239 bool NotifySelect(MenuItem selection, Modifiers mods)
1245 MenuItem viewWatchesItem
1247 viewMenu, $"Watches", w, alt3;
1248 bool NotifySelect(MenuItem selection, Modifiers mods)
1254 MenuItem viewThreadsItem
1256 viewMenu, $"Threads", t, alt4;
1257 bool NotifySelect(MenuItem selection, Modifiers mods)
1263 MenuItem viewBreakpointsItem
1265 viewMenu, $"Breakpoints", b, alt5;
1266 bool NotifySelect(MenuItem selection, Modifiers mods)
1268 breakpointsView.Show();
1272 MenuItem viewCallStackItem
1274 viewMenu, $"Call Stack", s, alt7;
1275 bool NotifySelect(MenuItem selection, Modifiers mods)
1277 callStackView.Show();
1281 MenuItem viewAllDebugViews
1283 viewMenu, $"All Debug Views", a, alt9;
1284 bool NotifySelect(MenuItem selection, Modifiers mods)
1289 callStackView.Show();
1290 breakpointsView.Show();
1294 #ifdef GDB_DEBUG_GUI
1295 MenuDivider { viewMenu };
1296 MenuItem viewGDBItem
1298 viewMenu, $"GDB Dialog", g, Key { f9, shift = true, ctrl = true };
1299 bool NotifySelect(MenuItem selection, Modifiers mods)
1306 MenuDivider { viewMenu };
1307 MenuItem viewColorPicker
1309 viewMenu, $"Color Picker...", c, Key { c, ctrl = true , shift = true };
1310 bool NotifySelect(MenuItem selection, Modifiers mods)
1312 ColorPicker colorPicker { master = this, parent = this, stayOnTop = true };
1313 colorPicker.Create();
1317 MenuDivider { viewMenu };
1321 viewMenu, "Full Screen", f, checkable = true;
1323 bool NotifySelect(MenuItem selection, Modifiers mods)
1325 app.fullScreen ^= true;
1327 anchor = { 0, 0, 0, 0 };
1332 Menu driversMenu { viewMenu, $"Graphics Driver", v };
1333 //Menu skinsMenu { viewMenu, "GUI Skins", k };
1334 Menu windowMenu { menu, $"Window", w };
1335 MenuItem { windowMenu, $"Close All", l, NotifySelect = MenuWindowCloseAll };
1336 MenuDivider { windowMenu };
1337 MenuItem { windowMenu, $"Next", n, f6, NotifySelect = MenuWindowNext };
1338 MenuItem { windowMenu, $"Previous", p, shiftF6, NotifySelect = MenuWindowPrevious };
1339 MenuDivider { windowMenu };
1340 MenuItem { windowMenu, $"Cascade", c, NotifySelect = MenuWindowCascade };
1341 MenuItem { windowMenu, $"Tile Horizontally", h, NotifySelect = MenuWindowTileHorz };
1342 MenuItem { windowMenu, $"Tile Vertically", v, NotifySelect = MenuWindowTileVert };
1343 MenuItem { windowMenu, $"Arrange Icons", a, NotifySelect = MenuWindowArrangeIcons };
1344 MenuDivider { windowMenu };
1345 MenuItem { windowMenu, $"Windows...", w, NotifySelect = MenuWindowWindows };
1346 Menu helpMenu { menu, $"Help", h };
1349 helpMenu, $"API Reference", r, f1;
1350 bool NotifySelect(MenuItem selection, Modifiers mods)
1352 Execute("documentor");
1356 MenuDivider { helpMenu };
1359 helpMenu, $"About...", a;
1360 bool NotifySelect(MenuItem selection, Modifiers mods)
1362 AboutIDE { master = this }.Modal();
1367 property ToolBox toolBox
1369 get { return toolBox; }
1372 property Sheet sheet
1374 get { return sheet; }
1377 property Project project
1379 get { return projectView ? projectView.project : null; }
1382 property Workspace workspace
1384 get { return projectView ? projectView.workspace : null; }
1387 FindInFilesDialog findInFilesDialog
1389 master = this, parent = this;
1390 filters = findInFilesFileFilters.array, sizeFilters = findInFilesFileFilters.count * sizeof(FileFilter);
1394 #ifdef GDB_DEBUG_GUI
1397 master = this, parent = this;
1398 anchor = { left = 100, top = 100, right = 100, bottom = 100 };
1400 void OnCommand(char * string)
1403 ide.debugger.SendGDBCommand(string);
1408 bool NotifySelectDisplayDriver(MenuItem selection, Modifiers mods)
1410 //app.driver = app.drivers[selection.id];
1411 #if defined(__unix__) || defined(__APPLE__)
1412 app.driver = selection.id ? "OpenGL" : "X";
1414 app.driver = selection.id ? "OpenGL" : "GDI";
1416 delete ideSettings.displayDriver;
1417 ideSettings.displayDriver = CopyString(selection.id ? "OpenGL" : "Default");
1419 settingsContainer.Save();
1420 //SetDriverAndSkin();
1424 bool NotifySelectDisplaySkin(MenuItem selection, Modifiers mods)
1426 app.skin = app.skins[selection.id];
1431 void SetDriverAndSkin()
1434 for(c = 0; c < app.numSkins; c++)
1435 if(!strcmp(app.skins[c], app.skin))
1437 skinItems[c].checked = true;
1440 for(c = 0; c < app.numDrivers; c++)
1441 if(!strcmp(app.drivers[c], app.driver))
1443 driverItems[c].checked = true;
1448 ProjectView CreateProjectView(Workspace workspace, char * fileName)
1450 Project project = workspace.projects.firstIterator.data;
1451 projectView = ProjectView
1454 fileName = fileName;
1456 void NotifyDestroyed(Window window, DialogResult result)
1459 text = titleECEREIDE;
1464 projectView.Create();
1465 RepositionWindows(false);
1467 // Leave it after Create to avoid flicker due to seeing IDE without a project view
1468 projectView.workspace = workspace;
1469 projectView.project = project;
1470 ideMainFrame.SetText("%s - %s", project.topNode.name, titleECEREIDE);
1474 ide.breakpointsView.LoadFromWorkspace();
1475 ide.watchesView.LoadFromWorkspace();
1477 findInFilesDialog.projectNodeField.userData = projectView;
1480 char fileName[MAX_LOCATION];
1481 strcpy(fileName, project.topNode.path);
1482 PathCat(fileName, project.topNode.name);
1487 bool GetDebugMenusDisabled()
1491 Project project = projectView.project;
1493 if(project.GetTargetType(project.config) == executable)
1500 void RepositionWindows(bool expand)
1505 bool inDebugMode = debugger.isActive;
1506 bool callStackVisible = expand ? false : callStackView.visible;
1507 bool threadsVisible = expand ? false : threadsView.visible;
1508 bool watchesVisible = expand ? false : watchesView.visible;
1509 bool breakpointsVisible = expand ? false : breakpointsView.visible;
1510 bool toolBoxVisible = toolBox.visible;
1511 bool outputVisible = expand ? false : outputView.visible;
1512 int topDistance = (callStackVisible || threadsVisible) ? 200 : 0;
1513 int bottomDistance = (outputVisible || watchesVisible || breakpointsVisible) ? 240 : 0;
1515 for(child = firstChild; child; child = child.next)
1517 if(child._class == class(CodeEditor) || child._class == class(Designer) ||
1518 child._class == class(Sheet) || child._class == class(ProjectView))
1520 Anchor anchor = child.anchor;
1521 anchor.top = topDistance;
1522 anchor.bottom = bottomDistance;
1523 if(child._class == class(CodeEditor) || child._class == class(Designer))
1525 anchor.right = toolBoxVisible ? 150 : 0;
1527 child.anchor = anchor;
1531 if(child._class == class(OutputView) || child._class == class(CallStackView) || child._class == class(ThreadsView) || child._class == class(WatchesView) ||
1532 child._class == class(BreakpointsView))
1533 child.visible = false;
1536 // If this is not here, the IDE is not updated when doing Debug/Break then Alt-4 to show call stack (IDE not updated)
1541 bool ShowCodeEditor()
1544 activeClient.Activate();
1545 else if(projectView)
1547 projectView.visible = true;
1548 projectView.Activate();
1552 sheet.visible = true;
1558 bool ShouldStopBuild()
1560 return projectView.stopBuild;
1563 void DocumentSaved(Window document, char * fileName)
1565 ideSettings.AddRecentFile(fileName);
1566 ide.UpdateRecentMenus();
1567 ide.AdjustFileMenus();
1568 settingsContainer.Save();
1571 bool Window::OnFileModified(FileChange fileChange, char * param)
1574 sprintf(temp, $"The document %s was modified by another application.\n"
1575 "Would you like to reload it and lose your changes?", this.fileName);
1576 if(MessageBox { type = yesNo, master = this/*.parent*/,
1577 text = $"Document has been modified", contents = temp }.Modal() == yes)
1579 char * fileName = CopyString(this.fileName);
1580 WindowState state = this.state;
1581 Anchor anchor = this.anchor;
1582 Size size = this.size;
1584 this.modifiedDocument = false;
1586 this = ide.OpenFile(fileName, normal, true, null, no, normal);
1589 this.anchor = anchor;
1591 this.SetState(state, true, 0);
1599 void UpdateMakefiles()
1603 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
1604 for(prj : workspace.projects)
1605 projectView.ProjectUpdateMakefileForAllConfigs(prj);
1610 void UpdateCompilerConfigs()
1612 UpdateToolBarActiveCompilers();
1615 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
1616 projectView.ShowOutputBuildLog(true);
1617 projectView.DisplayCompiler(compiler, false);
1618 for(prj : workspace.projects)
1619 projectView.ProjectPrepareCompiler(prj, compiler, false);
1624 void UpdateToolBarActiveCompilers()
1626 toolBar.activeCompiler.Clear();
1627 for(compiler : ideSettings.compilerConfigs)
1629 DataRow row = toolBar.activeCompiler.AddString(compiler.name);
1630 if(workspace && workspace.compiler && !strcmp(compiler.name, workspace.compiler))
1631 toolBar.activeCompiler.currentRow = row;
1633 if(!toolBar.activeCompiler.currentRow)
1634 toolBar.activeCompiler.currentRow = toolBar.activeCompiler.firstRow;
1635 toolBar.activeCompiler.disabled = workspace == null;
1638 void UpdateToolBarActiveConfigs(bool selectionOnly)
1640 bool commonSelected = false;
1641 DataRow row = toolBar.activeConfig.currentRow;
1643 row = toolBar.activeConfig.FindRow(1);
1646 toolBar.activeConfig.Clear();
1647 row = toolBar.activeConfig.AddString("(Mixed)");
1652 char * configName = null;
1655 Map<String, int> configs { }; // TOIMP: just need sort but using map until containers have sort
1656 for(prj : workspace.projects)
1658 for(cfg : prj.configurations)
1661 configs[cfg.name] = 1;
1666 toolBar.activeConfig.AddString(&name);
1670 if(projectView && projectView.project)
1672 for(prj : workspace.projects)
1674 if(prj.config && prj.config.name)
1676 configName = prj.config.name;
1682 commonSelected = true;
1683 for(prj : workspace.projects)
1685 if(prj.config && (!prj.config.name || strcmp(prj.config.name, configName)))
1687 commonSelected = false;
1695 commonSelected = false;
1696 for(row = toolBar.activeConfig.firstRow; row; row = row.next)
1698 if(!strcmp(row.string, configName))
1700 toolBar.activeConfig.currentRow = row;
1701 commonSelected = true;
1708 toolBar.activeConfig.Sort(null, 0);
1710 toolBar.activeConfig.currentRow = row;
1711 toolBar.activeConfig.disabled = workspace == null;
1716 bool unavailable = !project;
1718 projectAddItem.disabled = unavailable;
1719 toolBar.buttonAddProject.disabled = unavailable;
1721 projectSettingsItem.disabled = unavailable;
1723 projectBrowseFolderItem.disabled = unavailable;
1725 viewProjectItem.disabled = unavailable;
1732 property bool hasOpenedCodeEditors
1737 for(w = firstChild; w; w = w.next)
1738 if(w._class == class(CodeEditor) &&
1739 w.isDocument && !w.closing && w.visible && w.created &&
1740 w.fileName && w.fileName[0])
1746 void AdjustFileMenus()
1748 bool unavailable = project != null || !hasOpenedCodeEditors; // are they supported source code (ec, c, cpp, etc) ?
1750 projectQuickItem.disabled = unavailable;
1753 void AdjustBuildMenus()
1755 bool unavailable = project && projectView.buildInProgress;
1757 projectNewItem.disabled = unavailable;
1758 toolBar.buttonNewProject.disabled = unavailable;
1759 projectOpenItem.disabled = unavailable;
1760 toolBar.buttonOpenProject.disabled = unavailable;
1762 unavailable = !project || projectView.buildInProgress;
1764 projectCloseItem.disabled = unavailable;
1765 // toolBar.buttonCloseProject.disabled = unavailable;
1767 projectRunItem.disabled = unavailable || project.GetTargetType(project.config) != executable;
1768 toolBar.buttonRun.disabled = unavailable || project.GetTargetType(project.config) != executable;
1769 projectBuildItem.disabled = unavailable;
1770 toolBar.buttonBuild.disabled = unavailable;
1771 projectLinkItem.disabled = unavailable;
1772 toolBar.buttonReLink.disabled = unavailable;
1773 projectRebuildItem.disabled = unavailable;
1774 toolBar.buttonRebuild.disabled = unavailable;
1775 projectCleanItem.disabled = unavailable;
1776 toolBar.buttonClean.disabled = unavailable;
1777 projectRealCleanItem.disabled = unavailable;
1778 // toolBar.buttonRealClean.disabled = unavailable;
1779 projectRegenerateItem.disabled = unavailable;
1780 toolBar.buttonRegenerateMakefile.disabled = unavailable;
1781 projectCompileItem.disabled = unavailable;
1783 if(projectView && projectView.popupMenu && projectView.popupMenu.menu && projectView.popupMenu.created)
1786 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectBuild, 0); if(menu) menu.disabled = unavailable;
1787 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectLink, 0); if(menu) menu.disabled = unavailable;
1788 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRebuild, 0); if(menu) menu.disabled = unavailable;
1789 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectClean, 0); if(menu) menu.disabled = unavailable;
1790 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRealClean, 0); if(menu) menu.disabled = unavailable;
1791 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRegenerate, 0); if(menu) menu.disabled = unavailable;
1792 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRemove, 0); if(menu) menu.disabled = unavailable;
1793 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileClean, 0); if(menu) menu.disabled = unavailable;
1794 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileCompile, 0); if(menu) menu.disabled = unavailable;
1795 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugPrecompile, 0); if(menu) menu.disabled = unavailable;
1796 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugCompile, 0); if(menu) menu.disabled = unavailable;
1797 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugGenerateSymbols, 0); if(menu) menu.disabled = unavailable;
1798 projectView.popupMenu.Update(null);
1802 void AdjustDebugMenus()
1804 bool unavailable = !project || project.GetTargetType(project.config) != executable ||
1805 projectView.buildInProgress == buildingMainProject;
1806 bool active = ide.debugger.isActive;
1807 bool executing = ide.debugger.state == running;
1808 //bool holding = ide.debugger.state == stopped;
1810 debugStartResumeItem.disabled = unavailable || executing;
1811 debugStartResumeItem.text = active ? $"Resume" : $"Start";
1812 debugStartResumeItem.NotifySelect = active ? MenuDebugResume : MenuDebugStart;
1815 toolBar.buttonDebugStartResume.disabled = unavailable || executing;
1816 toolBar.buttonDebugStartResume.toolTip = active ? $"Resume" : $"Start";
1819 debugBreakItem.disabled = unavailable || !executing;
1820 debugStopItem.disabled = unavailable || !active;
1821 debugRestartItem.disabled = unavailable || !active;
1824 toolBar.buttonDebugPause.disabled = unavailable || !executing;
1825 toolBar.buttonDebugStop.disabled = unavailable || !active;
1826 toolBar.buttonDebugRestart.disabled = unavailable || !active;
1829 debugStepIntoItem.disabled = unavailable || executing;
1830 debugStepOverItem.disabled = unavailable || executing;
1831 debugStepOutItem.disabled = unavailable || executing || !active;
1832 debugSkipStepOverItem.disabled = unavailable || executing;
1833 debugSkipStepOutItem.disabled = unavailable || executing || !active;
1836 toolBar.buttonDebugStepInto.disabled = unavailable || executing;
1837 toolBar.buttonDebugStepOver.disabled = unavailable || executing;
1838 toolBar.buttonDebugStepOut.disabled = unavailable || executing || !active;
1839 toolBar.buttonDebugSkipStepOver.disabled = unavailable || executing;
1840 // toolBar.buttonDebugSkipStepOutItem.disabled = unavailable || executing;
1842 if((Designer)GetActiveDesigner())
1844 CodeEditor codeEditor = ((Designer)GetActiveDesigner()).codeEditor;
1847 codeEditor.debugRunToCursor.disabled = unavailable || executing;
1848 codeEditor.debugSkipRunToCursor.disabled = unavailable || executing;
1853 void ChangeFileDialogsDirectory(char * directory, bool saveSettings)
1855 char tempString[MAX_LOCATION];
1856 strcpy(tempString, directory);
1857 if(saveSettings && !projectView)
1859 ideSettings.ideFileDialogLocation = directory;
1860 settingsContainer.Save();
1863 ideFileDialog.currentDirectory = tempString;
1864 codeEditorFileDialog.currentDirectory = tempString;
1865 codeEditorFormFileDialog.currentDirectory = tempString;
1868 void ChangeProjectFileDialogDirectory(char * directory)
1870 ideSettings.ideProjectFileDialogLocation = directory;
1871 settingsContainer.Save();
1874 Window FindWindow(char * filePath)
1876 Window document = null;
1878 // TOCHECK: Do we need to change slashes here?
1879 for(document = firstChild; document; document = document.next)
1881 char * fileName = document.fileName;
1882 if(document.isDocument && fileName && !fstrcmp(fileName, filePath))
1884 document.visible = true;
1885 document.Activate();
1892 bool DontTerminateDebugSession(char * title)
1894 if(debugger.isActive)
1896 if(MessageBox { type = yesNo, master = ide,
1897 contents = $"Do you want to terminate the debugging session in progress?",
1898 text = title }.Modal() == no)
1901 MessageBox msg { type = yesNo, master = ide,
1902 contents = "Do you want to terminate the debugging session in progress?",
1904 if(msg.Modal() == no)
1916 Window OpenFile(char * origFilePath, WindowState state, bool visible, char * type, OpenCreateIfFails createIfFails, OpenMethod openMethod)
1918 char extension[MAX_EXTENSION] = "";
1919 Window document = null;
1920 bool isProject = false;
1921 bool needFileModified = true;
1922 char winFilePath[MAX_LOCATION];
1923 char * filePath = strstr(origFilePath, "http://") == origFilePath ? strcpy(winFilePath, origFilePath) : GetSystemPathBuffer(winFilePath, origFilePath);
1927 GetExtension(filePath, extension);
1931 strcpy(extension, type);
1933 if(strcmp(extension, ProjectExtension))
1935 for(document = firstChild; document; document = document.next)
1937 char * fileName = document.fileName;
1938 if(document.isDocument && fileName && !fstrcmp(fileName, filePath) && document.created)
1940 document.visible = true;
1942 document.Activate();
1948 if(createIfFails == whatever)
1950 else if(!strcmp(extension, ProjectExtension) || !strcmp(extension, WorkspaceExtension))
1952 needFileModified = false;
1953 if(openMethod == normal)
1955 if(DontTerminateDebugSession($"Open Project"))
1958 if(MenuWindowCloseAll(null, 0))
1962 projectView.visible = false;
1963 projectView.Destroy(0);
1964 // Where did this come from? projectView = null;
1971 Workspace workspace = null;
1973 if(FileExists(filePath))
1975 if(!strcmp(extension, ProjectExtension))
1977 char workspaceFile[MAX_LOCATION];
1978 strcpy(workspaceFile, filePath);
1979 ChangeExtension(workspaceFile, WorkspaceExtension, workspaceFile);
1980 workspace = LoadWorkspace(workspaceFile, filePath);
1982 else if(!strcmp(extension, WorkspaceExtension))
1983 workspace = LoadWorkspace(filePath, null);
1986 //project = LoadProject(filePath, null);
1991 char absolutePath[MAX_LOCATION];
1992 CreateProjectView(workspace, filePath);
1993 document = projectView;
1995 workspace.DropInvalidBreakpoints();
1998 ide.projectView.ShowOutputBuildLog(true);
2000 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
2001 ide.projectView.DisplayCompiler(compiler, false);
2004 UpdateCompilerConfigs();
2007 char newWorkingDir[MAX_LOCATION];
2008 StripLastDirectory(filePath, newWorkingDir);
2009 ChangeFileDialogsDirectory(newWorkingDir, false);
2012 document.fileName = filePath;
2014 ideMainFrame.SetText("%s - %s", filePath, titleECEREIDE);
2016 // this crashes on starting ide with epj file, solution please?
2017 // app.UpdateDisplay();
2019 workspace.holdTracking = true;
2020 for(ofi : workspace.openedFiles)
2022 if(ofi.state != closed)
2024 Window file = OpenFile(ofi.path, normal, true, null, no, normal);
2027 char fileName[MAX_LOCATION];
2029 GetLastDirectory(ofi.path, fileName);
2030 node = projectView.project.topNode.Find(fileName, true);
2032 node.EnsureVisible();
2036 workspace.holdTracking = false;
2038 workspace.timer.Start();
2040 findInFilesDialog.mode = FindInFilesMode::project;
2041 findInFilesDialog.currentDirectory = ide.project.topNode.path;
2044 char location[MAX_LOCATION];
2045 StripLastDirectory(ide.project.topNode.path, location);
2046 ChangeProjectFileDialogDirectory(location);
2050 if(projectView.debugger)
2051 projectView.debugger.EvaluateWatches();
2058 if(MessageBox { type = yesNo, master = this, text = $"Error opening project", contents = $"Open a different project?" }.Modal() == yes)
2060 ideProjectFileDialog.text = openProjectFileDialogTitle;
2061 if(ideProjectFileDialog.Modal() == cancel)
2063 filePath = ideProjectFileDialog.filePath;
2064 GetExtension(filePath, extension);
2075 else if(openMethod == add)
2080 char slashFilePath[MAX_LOCATION];
2081 GetSlashPathBuffer(slashFilePath, filePath);
2082 for(p : workspace.projects)
2084 if(!fstrcmp(p.filePath, slashFilePath))
2092 MessageBox { type = ok, parent = parent, master = this, text = $"Same Project",
2093 contents = $"This project is already present in workspace." }.Modal();
2097 prj = LoadProject(filePath, null);
2100 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
2101 prj.StartMonitoring();
2102 workspace.projects.Add(prj);
2104 projectView.AddNode(prj.topNode, null);
2105 workspace.modified = true;
2107 findInFilesDialog.AddProjectItem(prj);
2108 projectView.ShowOutputBuildLog(true);
2109 projectView.DisplayCompiler(compiler, false);
2110 projectView.ProjectUpdateMakefileForAllConfigs(prj);
2114 char location[MAX_LOCATION];
2115 StripLastDirectory(prj.topNode.path, location);
2116 ChangeProjectFileDialogDirectory(location);
2119 // projectView is associated with the main project and not with the one just added but
2120 return projectView; // just to let the caller know something was opened
2128 else if(!strcmp(extension, "bmp") || !strcmp(extension, "pcx") ||
2129 !strcmp(extension, "jpg") || !strcmp(extension, "gif") ||
2130 !strcmp(extension, "jpeg") || !strcmp(extension, "png"))
2132 if(FileExists(filePath))
2133 document = PictureEdit { hasMaximize = true, hasMinimize = true, hasClose = true, borderStyle = sizable,
2134 hasVertScroll = true, hasHorzScroll = true, parent = this, state = state,
2135 visible = visible, bitmapFile = filePath, OnClose = PictureEditOnClose/*why?--GenericDocumentOnClose*/;
2138 MessageBox { type = ok, master = this, text = filePath, contents = $"File doesn't exist." }.Modal();
2141 else if(!strcmp(extension, "3ds"))
2143 if(FileExists(filePath))
2144 document = ModelView { hasMaximize = true, hasMinimize = true, hasClose = true, borderStyle = sizable,
2145 hasVertScroll = true, hasHorzScroll = true, parent = this, state = state,
2146 visible = visible, modelFile = filePath, OnClose = ModelViewOnClose/*why?--GenericDocumentOnClose*/
2150 MessageBox { type = ok, master = this, text = filePath, contents = $"File doesn't exist." }.Modal();
2153 else if(!strcmp(extension, "txt") || !strcmp(extension, "text") ||
2154 !strcmp(extension, "nfo") || !strcmp(extension, "info") ||
2155 !strcmp(extension, "htm") || !strcmp(extension, "html") ||
2156 !strcmp(extension, "css") || !strcmp(extension, "php") ||
2157 !strcmp(extension, "js"))
2159 CodeEditor editor { parent = this, state = state, visible = false };
2160 editor.updatingCode = true;
2161 if(editor.LoadFile(filePath))
2164 editor.visible = true;
2168 needFileModified = false;
2172 CodeEditor editor { parent = this, state = state, visible = false };
2173 if(editor.LoadFile(filePath))
2176 editor.visible = true;
2180 needFileModified = false;
2183 if(document && (document._class == class(PictureEdit) ||
2184 document._class == class(ModelView)))
2189 document.fileName = filePath;
2190 if(workspace && !workspace.holdTracking)
2191 workspace.UpdateOpenedFileInfo(filePath, opened);
2195 if(!document && createIfFails != no)
2197 if(createIfFails != yes && !needFileModified &&
2198 MessageBox { type = yesNo, master = this, text = filePath, contents = $"File doesn't exist. Create?" }.Modal() == yes)
2199 createIfFails = yes;
2200 if(createIfFails == yes || createIfFails == whatever)
2202 document = (Window)NewCodeEditor(this, state, true);
2204 document.fileName = filePath;
2210 if(projectView && document._class == class(CodeEditor) && workspace)
2212 int lineNumber, position;
2214 CodeEditor editor = (CodeEditor)document;
2215 editor.openedFileInfo = workspace.UpdateOpenedFileInfo(filePath, opened);
2216 editor.openedFileInfo.holdTracking = true;
2217 lineNumber = Max(editor.openedFileInfo.lineNumber - 1, 0);
2218 position = Max(editor.openedFileInfo.position - 1, 0);
2219 editor.editBox.GoToLineNum(lineNumber);
2220 editor.editBox.GoToPosition(editor.editBox.line, lineNumber, position);
2221 scroll.x = Max(editor.openedFileInfo.scroll.x, 0);
2222 scroll.y = Max(editor.openedFileInfo.scroll.y, 0);
2223 editor.editBox.scroll = scroll;
2224 editor.openedFileInfo.holdTracking = false;
2227 if(needFileModified)
2228 document.OnFileModified = OnFileModified;
2229 document.NotifySaved = DocumentSaved;
2232 ideSettings.AddRecentProject(document.fileName);
2234 ideSettings.AddRecentFile(document.fileName);
2235 ide.UpdateRecentMenus();
2236 ide.AdjustFileMenus();
2237 settingsContainer.Save();
2245 // TOCHECK: I can't use a generic one for both ModelView and PictureEdit both derived from Window
2246 /*bool Window::GenericDocumentOnClose(bool parentClosing)
2248 if(!parentClosing && ide.workspace)
2249 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2252 bool ModelView::ModelViewOnClose(bool parentClosing)
2254 if(!parentClosing && ide.workspace)
2255 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2258 bool PictureEdit::PictureEditOnClose(bool parentClosing)
2260 if(!parentClosing && ide.workspace)
2261 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2266 void OnUnloadGraphics(Window window)
2268 display.ClearMaterials();
2269 display.ClearTextures();
2270 display.ClearMeshes();
2274 bool OnActivate(bool active, Window swap, bool * goOnWithActivation, bool direct)
2276 caps.color = app.GetKeyState(capsState) ? black : Color { 128,128,128 };
2277 num.color = app.GetKeyState(numState) ? black : Color { 128,128,128 };
2281 bool OnKeyDown(Key key, unichar ch)
2286 projectView.Update(null);
2289 caps.color = app.GetKeyState(capsState) ? black : Color { 128,128,128 };
2292 num.color = app.GetKeyState(numState) ? black : Color { 128,128,128 };
2298 void GoToError(const char * line)
2301 projectView.GoToError(line);
2304 void CodeLocationParseAndGoTo(const char * text, Project project, const char * dir)
2307 char *colon = strchr(text, ':');
2308 char filePath[MAX_LOCATION];
2309 char completePath[MAX_LOCATION];
2310 int line = 0, col = 0;
2312 FileAttribs fileAttribs;
2314 if(colon && (colon[1] == '/' || colon[1] == '\\'))
2316 path = (colon - 1 > path) ? colon - 1 : path;
2317 colon = strstr(colon + 1, ":");
2319 while(isspace(*path)) path++;
2322 char * close = strchr(path, ')');
2326 strncpy(name, path+1, close - path - 1);
2327 name[close - path - 1] = '\0';
2328 for(p : ide.workspace.projects)
2330 if(!strcmp(p.name, name))
2340 prj = project ? project : (dir ? null : ide.project);
2343 strncpy(filePath, path, colon - path);
2344 filePath[colon - path] = '\0';
2345 line = atoi(colon + 1);
2346 colon = strstr(colon + 1, ":");
2348 col = atoi(colon + 1);
2350 else if(path - 1 >= text && *(path - 1) == '\"')
2352 colon = strchr(path, '\"');
2355 strncpy(filePath, path, colon - path);
2356 filePath[colon - path] = '\0';
2359 else if(path && !colon)
2361 strcpy(filePath, path);
2365 strcpy(completePath, prj.topNode.path);
2366 else if(dir && dir[0])
2367 strcpy(completePath, dir);
2369 completePath[0] = '\0';
2370 PathCat(completePath, filePath);
2372 fileAttribs = FileExists(completePath);
2373 if(fileAttribs.isFile)
2375 CodeEditor codeEditor = (CodeEditor)OpenFile(completePath, normal, true, "", no, normal);
2376 if(codeEditor && line)
2378 EditBox editBox = codeEditor.editBox;
2379 editBox.GoToLineNum(line - 1);
2380 editBox.GoToPosition(editBox.line, line - 1, col ? (col - 1) : 0);
2383 else if(fileAttribs.isDirectory)
2384 ShellOpen(completePath);
2387 void OnRedraw(Surface surface)
2389 Bitmap bitmap = back.bitmap;
2391 surface.Blit(bitmap, (clientSize.w - bitmap.width) / 2, (clientSize.h - bitmap.height) / 2, 0, 0, bitmap.width, bitmap.height);
2394 void SheetSelected(SheetType sheetSelected)
2396 if(activeChild == sheet)
2398 if(sheetSelected == methods)
2400 viewPropertiesItem.accelerator = f4;
2401 viewPropertiesItem.parent = viewMenu;
2402 viewMethodsItem.parent = null;
2406 viewMethodsItem.accelerator = f4;
2407 viewMethodsItem.parent = viewMenu;
2408 viewPropertiesItem.parent = null;
2413 viewMethodsItem.parent = viewMenu;
2414 viewPropertiesItem.parent = viewMenu;
2415 if(sheetSelected == methods)
2417 viewMethodsItem.accelerator = f4;
2418 viewPropertiesItem.accelerator = 0;
2422 viewMethodsItem.accelerator = 0;
2423 viewPropertiesItem.accelerator = f4;
2428 void OnActivateClient(Window client, Window previous)
2430 //if(!client || client != previous)
2433 if(!client || client != previous)
2436 dataType = previous._class;
2437 if(previous && !strcmp(dataType.name, "CodeEditor"))
2439 ((CodeEditor)previous).UpdateFormCode();
2441 else if(previous && !strcmp(dataType.name, "Designer"))
2443 ((Designer)previous).codeEditor.UpdateFormCode();
2448 dataType = client._class;
2449 if(client && !strcmp(dataType.name, "CodeEditor"))
2451 CodeEditor codeEditor = (CodeEditor)client;
2452 SetPrivateModule(codeEditor.privateModule);
2453 SetCurrentContext(codeEditor.globalContext);
2454 SetTopContext(codeEditor.globalContext);
2455 SetGlobalContext(codeEditor.globalContext);
2457 SetDefines(&codeEditor.defines);
2458 SetImports(&codeEditor.imports);
2460 SetActiveDesigner(codeEditor.designer);
2462 sheet.codeEditor = codeEditor;
2463 toolBox.codeEditor = codeEditor;
2465 viewDesignerItem.parent = viewMenu;
2466 if(activeChild != codeEditor)
2468 viewCodeItem.parent = viewMenu;
2469 viewDesignerItem.accelerator = 0;
2470 viewCodeItem.accelerator = f8;
2474 viewCodeItem.parent = null;
2475 viewDesignerItem.accelerator = f8;
2478 else if(client && !strcmp(dataType.name, "Designer"))
2480 CodeEditor codeEditor = ((Designer)client).codeEditor;
2483 SetPrivateModule(codeEditor.privateModule);
2484 SetCurrentContext(codeEditor.globalContext);
2485 SetTopContext(codeEditor.globalContext);
2486 SetGlobalContext(codeEditor.globalContext);
2487 SetDefines(&codeEditor.defines);
2488 SetImports(&codeEditor.imports);
2492 SetPrivateModule(null);
2493 SetCurrentContext(null);
2494 SetTopContext(null);
2495 SetGlobalContext(null);
2500 SetActiveDesigner((Designer)client);
2502 sheet.codeEditor = codeEditor;
2503 toolBox.codeEditor = codeEditor;
2505 viewCodeItem.parent = viewMenu;
2506 if(activeChild != client)
2508 viewDesignerItem.parent = viewMenu;
2509 viewDesignerItem.accelerator = f8;
2510 viewCodeItem.accelerator = 0;
2514 viewDesignerItem.parent = null;
2515 viewCodeItem.accelerator = f8;
2521 sheet.codeEditor = null;
2522 toolBox.codeEditor = null;
2523 SetActiveDesigner(null);
2525 viewDesignerItem.parent = null;
2526 viewCodeItem.parent = null;
2529 SheetSelected(sheet.sheetSelected);
2532 projectCompileItem = null;
2537 if(client && client._class == eSystem_FindClass(__thisModule, "CodeEditor")) // !strcmp(client._class.name, "CodeEditor")
2539 CodeEditor codeEditor = (CodeEditor)client;
2540 EditBox editBox = codeEditor.editBox;
2542 statusBar.AddField(pos);
2544 caps = { width = 40, text = $"CAPS", color = app.GetKeyState(capsState) ? black : Color { 128, 128, 128 } };
2545 statusBar.AddField(caps);
2547 ovr = { width = 30, text = $"OVR", color = editBox.overwrite ? black : Color { 128, 128, 128 } };
2548 statusBar.AddField(ovr);
2550 num = { width = 30, text = $"NUM", color = app.GetKeyState(numState) ? black : Color { 128, 128, 128 } };
2551 statusBar.AddField(num);
2553 //statusBar.text = "Ready";
2555 if(projectView && projectView.project)
2557 bool isCObject = false;
2558 ProjectNode node = projectView.GetNodeFromWindow(client, null, false);
2559 if(!node && (node = projectView.GetNodeFromWindow(client, null, true)))
2563 char nodeName[MAX_FILENAME];
2564 char name[MAX_FILENAME+96];
2566 ChangeExtension(node.name, "c", nodeName);
2567 sprintf(name, $"Compile %s", isCObject ? nodeName : node.name);
2568 projectCompileItem =
2570 copyText = true, text = name, c, ctrlF7, disabled = projectView.buildInProgress;
2572 bool NotifySelect(MenuItem selection, Modifiers mods)
2576 bool result = false;
2577 bool isCObject = false;
2578 ProjectNode node = null;
2579 for(p : ide.workspace.projects)
2581 node = projectView.GetNodeFromWindow(activeClient, p, false);
2584 if(!node && (node = projectView.GetNodeFromWindow(activeClient, null, true)))
2588 List<ProjectNode> nodes { };
2590 projectView.Compile(node.project, nodes, mods.ctrl && mods.shift, isCObject ? cObject : normal);
2595 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
2600 projectMenu.AddDynamic(projectCompileItem, ide, false);
2606 caps = ovr = num = null;
2611 bool OnClose(bool parentClosing)
2613 //return !projectView.buildInProgress;
2614 if(projectView && projectView.buildInProgress)
2616 if(DontTerminateDebugSession($"Close IDE"))
2618 if(findInFilesDialog)
2619 findInFilesDialog.SearchStop();
2622 workspace.timer.Stop();
2625 ideMainFrame.Destroy(0);
2632 bool passThrough = false;
2633 bool debugStart = false;
2634 DynamicString passArgs { };
2635 for(c = 1; c<app.argc; c++)
2637 if(!strcmp(app.argv[c], "-debug-start"))
2639 else if(!passThrough && !strcmp(app.argv[c], "-@"))
2641 else if(passThrough)
2643 passArgs.concat(" ");
2644 passArgs.concat(app.argv[c]);
2648 char fullPath[MAX_LOCATION];
2649 char parentPath[MAX_LOCATION];
2650 char ext[MAX_EXTENSION];
2652 FileAttribs dirAttribs;
2653 GetWorkingDir(fullPath, MAX_LOCATION);
2654 PathCat(fullPath, app.argv[c]);
2655 StripLastDirectory(fullPath, parentPath);
2656 GetExtension(app.argv[c], ext);
2657 isProject = !strcmpi(ext, "epj");
2659 if(isProject && c > (debugStart ? 2 : 1)) continue;
2661 // Create directory for projects (only)
2662 if(((dirAttribs = FileExists(parentPath)) && dirAttribs.isDirectory) || isProject)
2664 if(isProject && !FileExists(fullPath))
2666 // The NewProject will handle directory creation
2667 /*if(!dirAttribs.isDirectory)
2669 MakeDir(parentPath);
2670 dirAttribs = FileExists(parentPath);
2672 if(dirAttribs.isDirectory)*/
2674 char name[MAX_LOCATION];
2675 NewProjectDialog newProjectDialog;
2679 projectView.visible = false;
2680 if(!projectView.Destroy(0))
2684 newProjectDialog = { master = this };
2686 strcpy(name, app.argv[c]);
2687 StripExtension(name);
2688 GetLastDirectory(name, name);
2689 newProjectDialog.projectName.contents = name;
2690 newProjectDialog.projectName.NotifyModified(newProjectDialog, newProjectDialog.projectName);
2691 newProjectDialog.locationEditBox.path = parentPath;
2692 newProjectDialog.NotifyModifiedLocation(newProjectDialog.locationEditBox);
2694 newProjectDialog.Modal();
2697 ideSettings.AddRecentProject(projectView.fileName);
2698 ide.UpdateRecentMenus();
2699 settingsContainer.Save();
2702 // Open only one project
2706 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, null, yes, normal);
2708 else if(strstr(fullPath, "http://") == fullPath)
2709 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, null, yes, normal);
2712 if(passThrough && projectView && projectView.project && workspace)
2713 workspace.commandLineArgs = passArgs;
2716 ;//MenuDebugStart(debugStartResumeItem, 0); // <-- how TODO this without getting into the app.Wait lock
2718 UpdateToolBarActiveConfigs(false);
2719 UpdateToolBarActiveCompilers();
2725 // IS THIS NEEDED? WASN'T HERE BEFORE... Crashes on getting node's projectView otherwise
2728 projectView.visible = false;
2729 projectView.Destroy(0);
2732 #ifdef GDB_DEBUG_GUI
2733 gdbDialog.Destroy(0);
2738 void SetPath(bool projectsDirs, CompilerConfig compiler, ProjectConfig config)
2742 char * oldPaths[128];
2743 String oldList = new char[maxPathLen];
2744 Array<String> newExePaths { };
2745 //Map<String, bool> exePathExists { };
2747 #if defined(__unix__) || defined(__APPLE__)
2748 Array<String> newLibPaths { };
2749 Map<String, bool> libPathExists { };
2754 for(prj : workspace.projects)
2756 DirExpression targetDirExp;
2758 // SKIP FIRST PROJECT...
2759 if(prj == workspace.projects.firstIterator.data) continue;
2761 // NOTE: Right now the additional project config dir will be
2762 // obtained when the debugger is started, so toggling it
2763 // while building will change which library gets used.
2764 // To go with the initial state, e.g. when F5 was pressed,
2765 // we nould need to keep a list of all project's active
2766 // config upon startup.
2767 targetDirExp = prj.GetTargetDir(compiler, prj.config);
2769 /*if(prj.config.targetType == sharedLibrary && prj.config.debug)
2773 for(cfg = prj.configurations.first; cfg; cfg = cfg.next)
2774 if(cfg.targetType == sharedLibrary && cfg.debug && !strcmpi(cfg.name, "Debug"))
2778 for(cfg = prj.configurations.first; cfg; cfg = cfg.next)
2779 if(cfg.targetType == sharedLibrary && cfg.debug)
2783 if(targetDirExp.dir)
2785 char buffer[MAX_LOCATION];
2786 #if defined(__WIN32__)
2787 Array<String> paths = newExePaths;
2789 Array<String> paths = newLibPaths;
2791 GetSystemPathBuffer(buffer, prj.topNode.path);
2792 PathCat(buffer, targetDirExp.dir);
2795 if(!fstrcmp(p, buffer))
2802 paths.Add(CopyString(buffer));
2804 delete targetDirExp;
2808 for(item : compiler.executableDirs)
2811 for(p : newExePaths)
2813 if(!fstrcmp(p, item))
2820 newExePaths.Add(CopySystemPath(item));
2823 GetEnvironment("PATH", oldList, maxPathLen);
2825 printf("Old value of PATH: %s\n", oldList);
2827 count = TokenizeWith(oldList, sizeof(oldPaths) / sizeof(char *), oldPaths, pathListSep, false);
2828 for(c = 0; c < count; c++)
2831 for(p : newExePaths)
2833 if(!fstrcmp(p, oldPaths[c]))
2840 newExePaths.Add(CopySystemPath(oldPaths[c]));
2844 for(path : newExePaths)
2845 len += strlen(path) + 1;
2846 newList = new char[len + 1];
2848 for(path : newExePaths)
2850 strcat(newList, path);
2851 strcat(newList, pathListSep);
2853 newList[len - 1] = '\0';
2854 SetEnvironment("PATH", newList);
2856 printf("New value of PATH: %s\n", newList);
2863 #if defined(__unix__) || defined(__APPLE__)
2865 for(item : compiler.libraryDirs)
2867 if(!libPathExists[item]) // fstrcmp should be used
2869 newLibPaths.Add(item);
2870 libPathExists[item] = true;
2874 #if defined(__APPLE__)
2875 GetEnvironment("DYLD_LIBRARY_PATH", oldList, maxPathLen);
2877 GetEnvironment("LD_LIBRARY_PATH", oldList, maxPathLen);
2880 printf("Old value of [DY]LD_LIBRARY_PATH: %s\n", oldList);
2882 count = TokenizeWith(oldList, sizeof(oldPaths) / sizeof(char *), oldPaths, pathListSep, false);
2883 for(c = 0; c < count; c++)
2885 if(!libPathExists[oldPaths[c]]) // fstrcmp should be used
2887 newLibPaths.Add(oldPaths[c]);
2888 libPathExists[oldPaths[c]] = true;
2893 for(path : newLibPaths)
2894 len += strlen(path) + 1;
2895 newList = new char[len + 1];
2897 for(path : newLibPaths)
2899 strcat(newList, path);
2900 strcat(newList, pathListSep);
2902 newList[len - 1] = '\0';
2903 #if defined(__APPLE__)
2904 SetEnvironment("DYLD_LIBRARY_PATH", newList);
2906 SetEnvironment("LD_LIBRARY_PATH", newList);
2909 printf("New value of [DY]LD_LIBRARY_PATH: %s\n", newList);
2914 delete libPathExists;
2917 if(compiler.distccEnabled && compiler.distccHosts)
2918 SetEnvironment("DISTCC_HOSTS", compiler.distccHosts);
2923 void DestroyTemporaryProjectDir()
2925 if(tmpPrjDir && tmpPrjDir[0])
2927 if(FileExists(tmpPrjDir).isDirectory)
2928 DestroyDir(tmpPrjDir);
2929 property::tmpPrjDir = null;
2935 // Graphics Driver Menu
2939 app.currentSkin.selectionColor = selectionColor;
2940 app.currentSkin.selectionText = selectionText;
2944 driverItems = new MenuItem[app.numDrivers];
2945 for(c = 0; c < app.numDrivers; c++)
2947 driverItems[c] = MenuItem { driversMenu, app.drivers[c], NotifySelect = NotifySelectDisplayDriver };
2948 driverItems[c].id = c;
2949 driverItems[c].isRadio = true;
2952 driverItems = new MenuItem[2];
2953 #if defined(__unix__)
2954 driverItems[0] = MenuItem { driversMenu, "X", NotifySelect = NotifySelectDisplayDriver };
2955 driverItems[0].id = 0;
2956 driverItems[0].isRadio = true;
2958 driverItems[0] = MenuItem { driversMenu, "GDI", NotifySelect = NotifySelectDisplayDriver };
2959 driverItems[0].id = 0;
2960 driverItems[0].isRadio = true;
2962 driverItems[1] = MenuItem { driversMenu, "OpenGL", NotifySelect = NotifySelectDisplayDriver };
2963 driverItems[1].id = 1;
2964 driverItems[1].isRadio = true;
2966 /* skinItems = new MenuItem[app.numSkins];
2967 for(c = 0; c < app.numSkins; c++)
2969 skinItems[c] = MenuItem {skinsMenu, app.skins[c], NotifySelect = NotifySelectDisplaySkin };
2970 skinItems[c].id = c;
2971 skinItems[c].isRadio = true;
2974 ideFileDialog.master = this;
2975 ideProjectFileDialog.master = this;
2977 //SetDriverAndSkin();
2981 void UpdateRecentMenus()
2984 Menu fileMenu = menu.FindMenu($"File");
2985 Menu recentFiles = fileMenu.FindMenu($"Recent Files");
2986 Menu recentProjects = fileMenu.FindMenu($"Recent Projects");
2987 char itemName[MAX_LOCATION + 4];
2990 recentFiles.Clear();
2993 for(recent : ideSettings.recentFiles)
2995 sprintf(itemName, "%d %s", 1 + c, recent);
2996 MakeSystemPath(itemName);
2997 recentFiles.AddDynamic(MenuItem { copyText = true, text = itemName, (Key)k1 + c, id = c, NotifySelect = ide.FileRecentFile }, ide, true);
3001 recentProjects.Clear();
3003 for(recent : ideSettings.recentProjects)
3005 sprintf(itemName, "%d %s", 1 + c, recent);
3006 MakeSystemPath(itemName);
3007 recentProjects.AddDynamic(MenuItem { copyText = true, text = itemName, (Key)k1 + c, id = c, NotifySelect = ide.FileRecentProject }, ide, true);
3020 void DestroyDir(char * path)
3022 RecursiveDeleteFolderFSI fsi { };
3027 class RecursiveDeleteFolderFSI : NormalFileSystemIterator
3029 bool preserveRootFolder;
3031 void OutFolder(char * folderPath, bool isRoot)
3033 if(!(preserveRootFolder && isRoot))
3034 RemoveDir(folderPath);
3037 bool OnFile(char * filePath)
3039 DeleteFile(filePath);
3044 class IDEApp : GuiApplication
3046 //driver = "Win32Console";
3047 // driver = "OpenGL";
3051 TempFile includeFile { };
3055 SetLoggingMode(stdOut, null);
3056 //SetLoggingMode(debug, null);
3058 settingsContainer.Load();
3059 #if defined(__unix__) || defined(__APPLE__)
3060 app.driver = (ideSettings.displayDriver && !strcmp(ideSettings.displayDriver, "OpenGL")) ? ideSettings.displayDriver : "X";
3062 app.driver = (ideSettings.displayDriver && !strcmp(ideSettings.displayDriver, "OpenGL")) ? ideSettings.displayDriver : "GDI";
3064 ide.driverItems[ideSettings.displayDriver && !strcmp(ideSettings.displayDriver,"OpenGL")].checked = true;
3068 desktop.text = titleECEREIDE;
3071 for(c = 1; c<app.argc; c++)
3073 char fullPath[MAX_LOCATION];
3074 GetWorkingDir(fullPath, MAX_LOCATION);
3075 PathCat(fullPath, app.argv[c]);
3076 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, null, yes, normal);
3080 if(!LoadIncludeFile())
3081 PrintLn("error: unable to load :crossplatform.mk file inside ide binary.");
3086 bool LoadIncludeFile()
3088 bool result = false;
3089 File include = FileOpen(":crossplatform.mk", read);
3092 File f = includeFile;
3095 for(; !include.Eof(); )
3098 int count = include.Read(buffer, 1, 4096);
3099 f.Write(buffer, 1, count);
3109 IDEMainFrame ideMainFrame { };
3111 define app = ((IDEApp)__thisModule);
3113 define titleECEREIDE = $"ECERE IDE (Debug)";
3115 define titleECEREIDE = $"ECERE IDE";