2 public import static "ecere"
3 public import static "ec"
9 import "GlobalSettingsDialog"
10 import "NewProjectDialog"
11 import "FindInFilesDialog"
18 import "ProjectConfig"
20 import "NodeProperties"
21 import "ProjectSettings"
33 import "BreakpointsView"
34 import "CallStackView"
45 import "FileSystemIterator"
47 #if defined(__WIN32__)
48 define pathListSep = ";";
50 define pathListSep = ":";
53 define maxPathLen = 65 * MAX_LOCATION;
55 class PathBackup : struct
62 oldPath = new char[maxPathLen];
63 oldLDPath = new char[maxPathLen];
65 GetEnvironment("PATH", oldPath, maxPathLen);
66 #if defined(__APPLE__)
67 GetEnvironment("DYLD_LIBRARY_PATH", oldLDPath, maxPathLen);
69 GetEnvironment("LD_LIBRARY_PATH", oldLDPath, maxPathLen);
75 SetEnvironment("PATH", oldPath);
76 #if defined(__APPLE__)
77 SetEnvironment("DYLD_LIBRARY_PATH", oldLDPath);
79 SetEnvironment("LD_LIBRARY_PATH", oldLDPath);
86 enum OpenCreateIfFails { no, yes, something, whatever };
87 enum OpenMethod { normal, add };
89 static Array<FileFilter> fileFilters
91 { $"C/C++/eC Files (*.ec, *.eh, *.c, *.cpp, *.cc, *.cxx, *.h, *.hpp, *.hh, *.hxx)", "ec, eh, c, cpp, cc, cxx, h, hpp, hh, hxx" },
92 { $"Header Files for eC/C/C++ (*.eh, *.h, *.hpp, *.hh, *.hxx)", "eh, h, hpp, hh, hxx" },
93 { $"C/C++/eC Source Files (*.ec, *.c, *.cpp, *.cc, *.cxx)", "ec, c, cpp, cc, cxx" },
94 { $"Text files (*.txt, *.text, *.nfo, *.info)", "txt, text, nfo, info" },
95 { $"Web files (*.html, *.htm, *.xhtml, *.css, *.php, *.js, *.jsi, *.rb, *.xml)", "html, htm, xhtml, css, php, js, jsi, rb, xml" },
96 { $"Image Files (*.jpg, *.jpeg, *.bmp, *.pcx, *.png, *.gif)", "jpg, jpeg, bmp, pcx, png, gif" },
97 { $"3D Studio Model Files (*.3ds)", "3ds" },
98 { $"All files", null }
101 static Array<FileType> fileTypes
103 { $"Based on extension", null },
106 { $"3D Studio Model", "3ds" }
109 static Array<FileFilter> projectFilters
111 { $"Project Files (*.epj)", ProjectExtension }
114 static Array<FileType> projectTypes
116 { $"Project File", ProjectExtension }
119 static Array<FileFilter> findInFilesFileFilters
121 { $"eC Files (*.ec, *.eh)", "ec, eh" },
122 { $"C/C++/eC Files (*.ec, *.eh, *.c, *.cpp, *.cc, *.cxx, *.h, *.hpp, *.hh, *.hxx)", "ec, eh, c, cpp, cc, cxx, h, hpp, hh, hxx" },
123 { $"Header Files for eC/C/C++ (*.eh, *.h, *.hpp, *.hh, *.hxx)", "eh, h, hpp, hh, hxx" },
124 { $"C/C++/eC Source Files (*.ec, *.c, *.cpp, *.cc, *.cxx)", "ec, c, cpp, cc, cxx" },
125 { $"Text files (*.txt)", "txt" },
126 { $"All files", null }
129 FileDialog ideFileDialog
131 type = multiOpen, text = $"Open";
132 types = fileTypes.array, sizeTypes = fileTypes.count * sizeof(FileType), filters = fileFilters.array, sizeFilters = fileFilters.count * sizeof(FileFilter);
135 define openProjectFileDialogTitle = $"Open Project";
136 define addProjectFileDialogTitle = $"Open Additional Project";
137 FileDialog ideProjectFileDialog
140 types = projectTypes.array, sizeTypes = projectTypes.count * sizeof(FileType), filters = projectFilters.array, sizeFilters = projectFilters.count * sizeof(FileFilter);
143 GlobalSettingsDialog globalSettingsDialog
145 ideSettings = ideSettings;
146 settingsContainer = settingsContainer;
148 void OnGlobalSettingChange(GlobalSettingsChange globalSettingsChange)
150 switch(globalSettingsChange)
155 for(child = ide.firstChild; child; child = child.next)
157 if(child._class == class(CodeEditor))
159 CodeEditor codeEditor = (CodeEditor) child;
160 codeEditor.editBox.freeCaret = ideSettings.useFreeCaret;
161 // codeEditor.editBox.lineNumbers = ideSettings.showLineNumbers;
162 codeEditor.editBox.caretFollowsScrolling = ideSettings.caretFollowsScrolling;
163 codeEditor.OnPostCreate(); // Update editBox margin size
170 case compilerSettings:
172 ide.UpdateCompilerConfigs(true);
179 void DrawLineMarginIcon(Surface surface, BitmapResource resource, int line, int lineH, int scrollY, int boxH)
184 lineY = (line - 1) * lineH;
185 if(lineY + lineH > scrollY && lineY + lineH < scrollY + boxH)
187 Bitmap bitmap = resource.bitmap;
189 surface.Blit(bitmap, 0, lineY - scrollY + (lineH - bitmap.height) / 2 + 1, 0, 0, bitmap.width, bitmap.height);
194 #define IDEItem(x) (&((IDEWorkSpace)0).x)
196 class IDEToolbar : ToolBar
200 ToolButton buttonNewFile { this, toolTip = $"New file", menuItemPtr = IDEItem(fileNewItem) };
202 ToolButton buttonOpenFile { this, toolTip = $"Open file", menuItemPtr = IDEItem(fileOpenItem) };
204 // ToolButton buttonCloseFile { this, toolTip = $"Close file", menuItemPtr = IDEItem(fileCloseItem) };
206 ToolButton buttonSaveFile { this, toolTip = $"Save file", menuItemPtr = IDEItem(fileSaveItem) };
208 ToolButton buttonSaveAllFile { this, toolTip = $"Save all", menuItemPtr = IDEItem(fileSaveAllItem) };
210 ToolSeparator separator1 { this };
219 // ToolSeparator separator2 { this };
221 /* Project options */
223 ToolButton buttonNewProject { this, toolTip = $"New project", menuItemPtr = IDEItem(projectNewItem) };
225 ToolButton buttonOpenProject { this, toolTip = $"Open project", menuItemPtr = IDEItem(projectOpenItem) };
226 // Add project to workspace
227 ToolButton buttonAddProject { this, toolTip = $"Add project to workspace", menuItemPtr = IDEItem(projectAddItem), disabled = true; };
229 // ToolButton buttonCloseProject { this, toolTip = $"Close project", menuItemPtr = IDEItem(projectCloseItem), disabled = true; };
231 ToolSeparator separator3 { this };
233 /* Build/Execution options */
235 ToolButton buttonBuild { this, toolTip = $"Build project", menuItemPtr = IDEItem(projectBuildItem), disabled = true; };
237 ToolButton buttonReLink { this, toolTip = $"Relink project", menuItemPtr = IDEItem(projectLinkItem), disabled = true; };
239 ToolButton buttonRebuild { this, toolTip = $"Rebuild project", menuItemPtr = IDEItem(projectRebuildItem), disabled = true; };
241 ToolButton buttonClean { this, toolTip = $"Clean project", menuItemPtr = IDEItem(projectCleanItem), disabled = true; };
243 // ToolButton buttonRealClean { this, toolTip = $"Real clean project", menuItemPtr = IDEItem(projectRealCleanItem), disabled = true; };
244 // Regenerate Makefile
245 ToolButton buttonRegenerateMakefile { this, toolTip = $"Regenerate Makefile", menuItemPtr = IDEItem(projectRegenerateItem), disabled = true; };
246 // Compile actual file
248 ToolButton buttonRun { this, toolTip = $"Run", menuItemPtr = IDEItem(projectRunItem), disabled = true; };
249 #ifdef IDE_SHOW_INSTALL_MENU_BUTTON
250 ToolButton buttonInstall { this, toolTip = $"Install", menuItemPtr = IDEItem(projectInstallItem), disabled = true; };
253 ToolSeparator separator4 { this };
257 ToolButton buttonDebugStartResume { this, toolTip = $"Start", menuItemPtr = IDEItem(debugStartResumeItem), disabled = true; };
259 ToolButton buttonDebugRestart { this, toolTip = $"Restart", menuItemPtr = IDEItem(debugRestartItem), disabled = true; };
261 ToolButton buttonDebugPause { this, toolTip = $"Break", menuItemPtr = IDEItem(debugBreakItem), disabled = true; };
263 ToolButton buttonDebugStop { this, toolTip = $"Stop", menuItemPtr = IDEItem(debugStopItem), disabled = true; };
265 //ToolButton buttonRun { this, toolTip = $"Run", menuItemPtr = IDEItem(projectRunItem) };
267 ToolButton buttonDebugStepInto { this, toolTip = $"Step Into", menuItemPtr = IDEItem(debugStepIntoItem), disabled = true; };
269 ToolButton buttonDebugStepOver { this, toolTip = $"Step Over", menuItemPtr = IDEItem(debugStepOverItem), disabled = true; };
271 ToolButton buttonDebugStepOut { this, toolTip = $"Step Out", menuItemPtr = IDEItem(debugStepOutItem), disabled = true; };
273 ToolButton buttonDebugSkipStepOver { this, toolTip = $"Step Over Skipping Breakpoints", menuItemPtr = IDEItem(debugSkipStepOverItem), disabled = true; };
275 ToolSeparator separator5 { this };
277 Window spacer5 { this, size = { 4 } };
281 this, toolTip = $"Active Configuration(s)", size = { 160 }, disabled = true;
282 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
285 ide.workspace.SelectActiveConfig(row.string);
290 Window spacer6 { this, size = { 4 } };
292 DropBox activeCompiler
294 this, toolTip = $"Active Compiler", size = { 160 }, disabled = true;
295 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
297 if(ide.workspace && ide.projectView && row && strcmp(row.string, ide.workspace.compiler))
299 bool silent = ide.projectView.buildInProgress == none ? false : true;
300 CompilerConfig compiler = ideSettings.GetCompilerConfig(row.string);
301 ide.workspace.compiler = row.string;
302 ide.projectView.ShowOutputBuildLog(!silent);
304 ide.projectView.DisplayCompiler(compiler, false);
305 for(prj : ide.workspace.projects)
306 ide.projectView.ProjectPrepareCompiler(prj, compiler, silent);
308 ide.workspace.Save();
314 DropBox activeBitDepth
316 this, toolTip = $"Active Bit Depth", size = { 60 }, disabled = true;
317 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
319 if(ide.workspace && ide.projectView && row)
321 bool silent = ide.projectView.buildInProgress == none ? false : true;
322 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
323 ide.workspace.bitDepth = (int)row.tag;
324 ide.projectView.ShowOutputBuildLog(!silent);
326 ide.projectView.DisplayCompiler(compiler, false);
327 for(prj : ide.workspace.projects)
328 ide.projectView.ProjectPrepareCompiler(prj, compiler, silent);
330 ide.workspace.Save();
336 Window spacer7 { this, size = { 4 } };
341 row = activeBitDepth.AddString("Auto");
343 activeBitDepth.AddString("32 bit").tag = 32;
344 activeBitDepth.AddString("64 bit").tag = 64;
345 activeBitDepth.currentRow = row;
350 class IDEMainFrame : Window
352 background = formColor;
353 borderStyle = sizable;
357 minClientSize = { 600, 300 };
359 icon = { ":icon.png" };
360 text = titleECEREIDE;
364 anchor = { top = 0, right = 0, bottom = 0 };
367 anchor = { left = 0, top = 0, right = 0, bottom = 0 };
374 isActiveClient = true;
376 direction = vertical;
377 background = formColor;
378 anchor = { left = 0, top = 0, right = 0, bottom = 0 };
386 ((IDEWorkSpace)master).toolBar = null;
389 IDEWorkSpace ideWorkSpace { stack, this, toolBar = toolBar };
392 define ide = ideMainFrame.ideWorkSpace;
394 class IDEWorkSpace : Window
396 background = Color { 85, 85, 85 };
399 hasVertScroll = true;
400 hasHorzScroll = true;
402 isActiveClient = true;
403 anchor = { left = 0, top = 0, right = 0, bottom = 0 };
407 MenuItem * driverItems, * skinItems;
408 StatusField pos { width = 150 };
409 StatusField ovr, caps, num;
412 BitmapResource back { ":ecereBack.jpg", window = this };
413 BitmapResource bmpBp { ":codeMarks/breakpoint.png", window = this };
414 BitmapResource bmpBpDisabled { ":codeMarks/breakpointDisabled.png", window = this };
415 BitmapResource bmpBpHalf { ":codeMarks/breakpointHalf.png", window = this };
416 BitmapResource bmpBpHalfDisabled { ":codeMarks/breakpointHalfDisabled.png", window = this };
417 BitmapResource bmpCursor { ":codeMarks/cursor.png", window = this };
418 BitmapResource bmpCursorError { ":codeMarks/cursorError.png", window = this };
419 BitmapResource bmpTopFrame { ":codeMarks/topFrame.png", window = this };
420 BitmapResource bmpTopFrameError { ":codeMarks/topFrameError.png", window = this };
421 BitmapResource bmpTopFrameHalf { ":codeMarks/topFrameHalf.png", window = this };
422 BitmapResource bmpTopFrameHalfError { ":codeMarks/topFrameHalfError.png", window = this };
424 Debugger debugger { };
426 ProjectView projectView;
428 OutputView outputView
432 void OnGotoError(char * line, bool noParsing)
434 ide.GoToError(line, noParsing);
437 void OnCodeLocationParseAndGoTo(char * line)
439 ide.CodeLocationParseAndGoTo(line, ide.findInFilesDialog.findProject, ide.findInFilesDialog.findDir);
442 bool OnKeyDown(Key key, unichar ch)
447 if(activeBox != findBox || !ide.findInFilesDialog || !ide.findInFilesDialog.SearchAbort())
448 ide.ShowCodeEditor();
452 OutputView::OnKeyDown(key, ch);
459 bool OnClose(bool parentClosing)
463 ide.RepositionWindows(false);
464 return parentClosing;
468 CallStackView callStackView
470 parent = this, font = { panelFont.faceName, panelFont.size };
472 void OnSelectFrame(int frameIndex)
474 ide.debugger.GoToStackFrameLine(frameIndex, true, true);
476 ide.debugger.SelectFrame(frameIndex);
479 void OnToggleBreakpoint()
481 Debugger debugger = ide.debugger;
482 if(debugger.activeFrame && debugger.activeFrame.absoluteFile)
484 int line = debugger.activeFrame.line;
485 debugger.ToggleBreakpoint(debugger.activeFrame.absoluteFile, line);
488 CodeEditor codeEditor = (CodeEditor)ide.FindWindow(debugger.activeFrame.absoluteFile);
489 if(codeEditor) { codeEditor.Update(null); Activate(); }
494 bool OnKeyDown(Key key, unichar ch)
498 case escape: ide.ShowCodeEditor(); break;
503 bool OnClose(bool parentClosing)
507 ide.RepositionWindows(false);
508 return parentClosing;
511 void OnRedraw(Surface surface)
513 Debugger debugger = ide.debugger;
514 Frame activeFrame = debugger.activeFrame;
518 int lineCursor, lineTopFrame, activeThread, hitThread;
519 int lineH, scrollY, boxH;
521 Breakpoint bp = null;
524 scrollY = editBox.scroll.y;
525 displaySystem.FontExtent(editBox.font.font, " ", 1, null, &lineH);
526 activeThread = debugger.activeThread;
527 hitThread = debugger.hitThread;
528 debugger.GetCallStackCursorLine(&error, &lineCursor, &lineTopFrame);
530 // TODO: improve bp drawing... it should be visible even if it's not on the activeFrame
531 if(activeFrame.absoluteFile)
533 for(i : ide.workspace.breakpoints; i.type == user)
535 if(i.absoluteFilePath && i.absoluteFilePath[0] &&
536 !fstrcmp(i.absoluteFilePath, activeFrame.absoluteFile) &&
537 activeFrame.line == i.line)
545 DrawLineMarginIcon(surface,
546 /*(lineCursor == 1 || lineTopFrame == 1) ? */ide.bmpBpHalf/* : ide.bmpBp*/,
547 lineCursor /*1*/, lineH, scrollY, boxH);
549 if(activeThread && activeThread == hitThread && debugger.bpHit && debugger.bpHit.type == user)
550 DrawLineMarginIcon(surface,
551 (lineCursor == 1 || lineTopFrame == 1) ? ide.bmpBpHalf : ide.bmpBp,
552 1, lineH, scrollY, boxH);
554 DrawLineMarginIcon(surface, error ? ide.bmpCursorError : ide.bmpCursor, lineCursor, lineH, scrollY, boxH);
555 if(bp && lineCursor == 1) //activeThread && activeThread == hitThread && debugger.bpHit && debugger.bpHit.type == user)
556 bmp = error ? ide.bmpTopFrameHalfError : ide.bmpTopFrameHalf;
558 bmp = error ? ide.bmpTopFrameError : ide.bmpTopFrame;
559 DrawLineMarginIcon(surface, bmp, lineTopFrame, lineH, scrollY, boxH);
561 if(editBox.horzScroll && editBox.horzScroll.visible)
563 surface.SetBackground(control);
564 surface.Area(0, editBox.clientSize.h, 20 - 1, clientSize.h - 1);
569 WatchesView watchesView { parent = this };
570 ThreadsView threadsView
572 parent = this, font = { panelFont.faceName, panelFont.size };
574 bool OnKeyDown(Key key, unichar ch)
578 case escape: ide.ShowCodeEditor(); break;
583 bool OnClose(bool parentClosing)
587 ide.RepositionWindows(false);
588 return parentClosing;
591 void OnSelectThread(int threadId)
594 ide.debugger.SelectThread(threadId);
597 bool OnGetThreadsInfo(int * activeThread, int * hitThread, int * signalThread)
600 Debugger debugger = ide.debugger;
601 *activeThread = debugger.activeThread;
602 *hitThread = debugger.hitThread;
603 *signalThread = debugger.signalThread;
608 BreakpointsView breakpointsView { parent = this };
610 ToolBox toolBox { parent = this };
611 Sheet sheet { parent = this };
614 property char * tmpPrjDir { set { delete tmpPrjDir; if(value) tmpPrjDir = CopyString(value); } get { return tmpPrjDir; } };
616 Menu fileMenu { menu, $"File", f, hasMargin = true };
619 fileMenu, $"New", n, ctrlN;
620 bitmap = { ":actions/docNew.png" };
621 bool NotifySelect(MenuItem selection, Modifiers mods)
623 Window document = (Window)NewCodeEditor(this, normal, false);
624 document.NotifySaved = DocumentSaved;
628 MenuItem fileOpenItem
630 fileMenu, $"Open...", o, ctrlO;
631 bitmap = { ":actions/docOpen.png" };
632 bool NotifySelect(MenuItem selection, Modifiers mods)
634 if(!projectView && ideSettings.ideFileDialogLocation)
635 ideFileDialog.currentDirectory = ideSettings.ideFileDialogLocation;
638 if(ideFileDialog.Modal() == ok)
640 bool gotWhatWeWant = false;
642 int numSelections = ideFileDialog.numSelections;
643 char ** multiFilePaths = ideFileDialog.multiFilePaths;
645 for(c = 0; c < numSelections; c++)
647 if(OpenFile(multiFilePaths[c], normal, true, fileTypes[ideFileDialog.fileType].typeExtension, no, normal, mods.ctrl && mods.shift))
648 gotWhatWeWant = true;
651 MessageBox { type = yesNo, master = this, text = $"Error opening file",
652 contents = $"Open a different file?" }.Modal() == no)
654 if(!projectView && gotWhatWeWant)
655 ChangeFileDialogsDirectory(ideFileDialog.currentDirectory, true);
656 ide.RepositionWindows(false);
666 MenuItem fileCloseItem { fileMenu, $"Close", c, ctrlF4, NotifySelect = MenuFileClose };
667 MenuDivider { fileMenu };
668 MenuItem fileSaveItem
670 fileMenu, $"Save", s, ctrlS, bitmap = { ":actions/docSave.png" };
672 // For the toolbar button; clients can still override that for the menu item
673 bool Window::NotifySelect(MenuItem selection, Modifiers mods)
675 Window w = activeClient;
677 w.MenuFileSave(null, 0);
681 MenuItem fileSaveAsItem { fileMenu, $"Save As...", a };
682 MenuItem fileSaveAllItem { fileMenu, $"Save All", l, NotifySelect = MenuFileSaveAll, bitmap = { ":actions/docSaveAll.png" } };
683 MenuDivider { fileMenu };
686 fileMenu, $"Find In Files...", f, Key { f, ctrl = true , shift = true };
687 bool NotifySelect(MenuItem selection, Modifiers mods)
689 findInFilesDialog.replaceMode = false;
690 findInFilesDialog.Show();
694 MenuItem replaceInFiles
696 fileMenu, $"Replace In Files...", e, Key { r, ctrl = true , shift = true };
697 bool NotifySelect(MenuItem selection, Modifiers mods)
699 findInFilesDialog.replaceMode = true;
700 findInFilesDialog.Show();
704 MenuDivider { fileMenu };
705 MenuItem globalSettingsItem
707 fileMenu, $"Global Settings...", g;
708 bool NotifySelect(MenuItem selection, Modifiers mods)
710 globalSettingsDialog.master = this;
711 if(ide.workspace && ide.workspace.compiler)
712 globalSettingsDialog.workspaceActiveCompiler = ide.workspace.compiler;
713 else if(ideSettings.defaultCompiler)
714 globalSettingsDialog.workspaceActiveCompiler = ideSettings.defaultCompiler;
715 globalSettingsDialog.Modal();
719 MenuDivider { fileMenu };
720 Menu recentFiles { fileMenu, $"Recent Files", r };
721 Menu recentProjects { fileMenu, $"Recent Projects", p };
722 MenuDivider { fileMenu };
725 fileMenu, $"Exit", x, altF4;
727 bool NotifySelect(MenuItem selection, Modifiers mods)
729 ideMainFrame.Destroy(0);
734 bool FileRecentFile(MenuItem selection, Modifiers mods)
737 for(file : ideSettings.recentFiles)
739 if(id == selection.id)
742 char extension[MAX_EXTENSION] = "";
743 GetExtension(file, extension);
744 isProjectFile = (!strcmpi(extension, "epj") || !strcmpi(extension, "ews"));
747 char * command = PrintString("ide ", isProjectFile ? "-t " : "", file);
753 OpenFile(file, normal, true, isProjectFile ? "txt" : null, no, normal, mods.ctrl && mods.shift);
754 ide.RepositionWindows(false);
763 bool FileRecentProject(MenuItem selection, Modifiers mods)
766 for(file : ideSettings.recentProjects)
768 if(id == selection.id)
772 char * command = PrintString("ide ", file);
777 OpenFile(file, normal, true, null, no, normal, mods.ctrl && mods.shift);
785 MenuPlacement editMenu { menu, $"Edit", e };
787 Menu projectMenu { menu, $"Menu"."Project", p, hasMargin = true };
788 MenuItem projectNewItem
790 projectMenu, $"New...", n, Key { n, true, true };
791 bitmap = { ":actions/projNew.png" };
792 bool NotifySelect(MenuItem selection, Modifiers mods)
794 if(!DontTerminateDebugSession($"New Project"))
797 NewProjectDialog newProjectDialog { master = this };
798 incref newProjectDialog;
799 result = newProjectDialog.Modal();
804 newProjectDialog.CreateNewProject();
807 ideSettings.AddRecentProject(projectView.fileName);
808 ide.UpdateRecentMenus();
809 settingsContainer.Save();
813 delete newProjectDialog;
818 MenuItem projectOpenItem
820 projectMenu, $"Open...", o, Key { o, true, true };
821 bitmap = { ":actions/projOpen.png" };
822 bool NotifySelect(MenuItem selection, Modifiers mods)
824 if(ideSettings.ideProjectFileDialogLocation)
825 ideProjectFileDialog.currentDirectory = ideSettings.ideProjectFileDialogLocation;
827 ideProjectFileDialog.text = openProjectFileDialogTitle;
828 if(ideProjectFileDialog.Modal() == ok)
830 OpenFile(ideProjectFileDialog.filePath, normal, true, projectTypes[ideProjectFileDialog.fileType].typeExtension, no, normal, mods.ctrl && mods.shift);
831 //ChangeProjectFileDialogDirectory(ideProjectFileDialog.currentDirectory);
836 MenuItem projectQuickItem
838 projectMenu, $"Quick...", q, f7, disabled = true;
839 bool NotifySelect(MenuItem selection, Modifiers mods)
842 QuickProjectDialog { this }.Modal();
846 MenuItem projectAddItem
848 projectMenu, $"Add project to workspace...", a, Key { a, true, true };
849 bitmap = { ":actions/projAdd.png" };
851 bool NotifySelect(MenuItem selection, Modifiers mods)
853 if(ideSettings.ideProjectFileDialogLocation)
854 ideProjectFileDialog.currentDirectory = ideSettings.ideProjectFileDialogLocation;
856 ideProjectFileDialog.text = addProjectFileDialogTitle;
859 if(ideProjectFileDialog.Modal() == ok)
861 if(OpenFile(ideProjectFileDialog.filePath, normal, true, projectTypes[ideProjectFileDialog.fileType].typeExtension, no, add, mods.ctrl && mods.shift))
863 if(MessageBox { type = yesNo, master = this, text = $"Error opening project file",
864 contents = $"Add a different project?" }.Modal() == no)
875 MenuItem projectCloseItem
877 projectMenu, $"Close", c, disabled = true;
878 bool NotifySelect(MenuItem selection, Modifiers mods)
882 if(!ide.DontTerminateDebugSession($"Project Close"))
888 MenuDivider { projectMenu };
889 MenuItem projectSettingsItem
891 projectMenu, $"Settings...", s, altF7, disabled = true;
892 bool NotifySelect(MenuItem selection, Modifiers mods)
894 projectView.MenuSettings(projectView.active ? selection : null, mods);
898 MenuDivider { projectMenu };
899 MenuItem projectBrowseFolderItem
901 projectMenu, $"Browse Project Folder", p, disabled = true;
902 bool NotifySelect(MenuItem selection, Modifiers mods)
905 projectView.MenuBrowseFolder(null, mods);
909 MenuDivider { projectMenu };
910 MenuItem projectRunItem
912 projectMenu, $"Run", r, ctrlF5, disabled = true;
913 bitmap = { ":actions/run.png" };
914 bool NotifySelect(MenuItem selection, Modifiers mods)
917 projectView.Run(null, mods);
921 MenuItem projectBuildItem
923 projectMenu, $"Build", b, f7, disabled = true;
924 bitmap = { ":actions/build.png" };
925 bool NotifySelect(MenuItem selection, Modifiers mods)
929 if(projectView.buildInProgress == none)
930 projectView.ProjectBuild(projectView.active ? selection : null, mods);
932 projectView.stopBuild = true;
937 MenuItem projectLinkItem
939 projectMenu, $"Relink", l, disabled = true;
940 bitmap = { ":actions/relink.png" };
941 bool NotifySelect(MenuItem selection, Modifiers mods)
944 projectView.ProjectLink(projectView.active ? selection : null, mods);
948 MenuItem projectRebuildItem
950 projectMenu, $"Rebuild", d, shiftF7, disabled = true;
951 bitmap = { ":actions/rebuild.png" };
952 bool NotifySelect(MenuItem selection, Modifiers mods)
955 projectView.ProjectRebuild(projectView.active ? selection : null, mods);
959 MenuItem projectCleanTargetItem
961 projectMenu, $"Clean Target", g, disabled = true;
962 bitmap = { ":actions/clean.png" };
963 bool NotifySelect(MenuItem selection, Modifiers mods)
968 projectView.ProjectCleanTarget(projectView.active ? selection : null, mods);
973 MenuItem projectCleanItem
975 projectMenu, $"Clean", e, disabled = true;
976 bitmap = { ":actions/clean.png" };
977 bool NotifySelect(MenuItem selection, Modifiers mods)
982 projectView.ProjectClean(projectView.active ? selection : null, mods);
987 MenuItem projectRealCleanItem
989 projectMenu, $"Real Clean", disabled = true;
990 bitmap = { ":actions/clean.png" };
991 bool NotifySelect(MenuItem selection, Modifiers mods)
996 projectView.ProjectRealClean(projectView.active ? selection : null, mods);
1001 MenuItem projectRegenerateItem
1003 projectMenu, $"Regenerate Makefile", m, disabled = true;
1004 bitmap = { ":actions/regMakefile.png" };
1005 bool NotifySelect(MenuItem selection, Modifiers mods)
1008 projectView.ProjectRegenerate(projectView.active ? selection : null, mods);
1012 MenuItem projectInstallItem
1014 #ifdef IDE_SHOW_INSTALL_MENU_BUTTON
1015 projectMenu, $"Install", t, disabled = true;
1017 bitmap = { ":status/software-update-available.png" };
1018 bool NotifySelect(MenuItem selection, Modifiers mods)
1021 projectView.ProjectInstall(projectView.active ? selection : null, mods);
1025 MenuItem projectCompileItem;
1026 Menu debugMenu { menu, $"Debug", d, hasMargin = true };
1027 MenuItem debugStartResumeItem
1029 debugMenu, $"Start", s, f5, disabled = true;
1030 bitmap = { ":actions/debug.png" };
1031 NotifySelect = MenuDebugStart;
1033 bool MenuDebugStart(MenuItem selection, Modifiers mods)
1037 debugStartResumeItem.disabled = true; // a very rare exception to calling AdjustDebugMenus
1038 if(!projectView.DebugStart())
1039 debugStartResumeItem.disabled = false; // same exception
1043 bool MenuDebugResume(MenuItem selection, Modifiers mods)
1046 projectView.DebugResume();
1049 MenuItem debugRestartItem
1051 debugMenu, $"Restart", r, Key { f5, ctrl = true, shift = true }, disabled = true;
1052 bitmap = { ":actions/restart.png" };
1053 bool NotifySelect(MenuItem selection, Modifiers mods)
1056 projectView.DebugRestart();
1060 MenuItem debugBreakItem
1062 debugMenu, $"Break", b, Key { pauseBreak, ctrl = true }, disabled = true;
1063 bitmap = { ":actions/pause.png" };
1064 bool NotifySelect(MenuItem selection, Modifiers mods)
1066 if(projectView && projectView.buildInProgress != none)
1069 projectView.DebugBreak();
1073 MenuItem debugStopItem
1075 debugMenu, $"Stop", p, shiftF5, disabled = true;
1076 bitmap = { ":actions/stopDebug.png" };
1077 bool NotifySelect(MenuItem selection, Modifiers mods)
1080 projectView.DebugStop();
1085 MenuDivider { debugMenu };
1086 MenuItem debugUseValgrindItem
1088 debugMenu, $"Use Valgrind", d, disabled = true, checkable = true;
1089 bool NotifySelect(MenuItem selection, Modifiers mods)
1093 ide.workspace.useValgrind = selection.checked;
1094 ide.workspace.Save();
1096 ide.AdjustValgrindMenus();
1100 Menu debugValgrindLeakCheckItem { debugMenu, $"Valgrind Leak Check", h };
1101 MenuItem debugValgrindNoLeakCheckItem { debugValgrindLeakCheckItem, $"No" , f, id = ValgrindLeakCheck::no , checkable = true, disabled = true; NotifySelect = ValgrindLCSelect; }
1102 MenuItem debugValgrindSummaryLeakCheckItem { debugValgrindLeakCheckItem, $"Summary", f, id = ValgrindLeakCheck::summary, checkable = true, disabled = true; NotifySelect = ValgrindLCSelect, checked = true; }
1103 MenuItem debugValgrindYesLeakCheckItem { debugValgrindLeakCheckItem, $"Yes" , f, id = ValgrindLeakCheck::yes , checkable = true, disabled = true; NotifySelect = ValgrindLCSelect; }
1104 MenuItem debugValgrindFullLeakCheckItem { debugValgrindLeakCheckItem, $"Full" , f, id = ValgrindLeakCheck::full , checkable = true, disabled = true; NotifySelect = ValgrindLCSelect; }
1105 bool ValgrindLCSelect(MenuItem selection, Modifiers mods)
1109 if(selection.checked)
1111 ValgrindLeakCheck vgLeakCheck = (ValgrindLeakCheck)selection.id;
1113 debugValgrindNoLeakCheckItem.checked = debugValgrindNoLeakCheckItem.id == vgLeakCheck;
1114 debugValgrindSummaryLeakCheckItem.checked = debugValgrindSummaryLeakCheckItem.id == vgLeakCheck;
1115 debugValgrindYesLeakCheckItem.checked = debugValgrindYesLeakCheckItem.id == vgLeakCheck;
1116 debugValgrindFullLeakCheckItem.checked = debugValgrindFullLeakCheckItem.id == vgLeakCheck;
1118 ide.workspace.vgLeakCheck = vgLeakCheck;
1119 ide.workspace.Save();
1122 selection.checked = true;
1126 Menu debugValgrindRedzoneSizeItem { debugMenu, $"Valgrind Redzone Size", z };
1127 MenuItem debugValgrindRSDefaultItem { debugValgrindRedzoneSizeItem, $"Default", f, id = -1, checkable = true, disabled = true; NotifySelect = ValgrindRSSelect, checked = true; }
1128 MenuItem debugValgrindRS0Item { debugValgrindRedzoneSizeItem, $"0" , f, id = 0, checkable = true, disabled = true; NotifySelect = ValgrindRSSelect; }
1129 MenuItem debugValgrindRS16Item { debugValgrindRedzoneSizeItem, $"16" , f, id = 16, checkable = true, disabled = true; NotifySelect = ValgrindRSSelect; }
1130 MenuItem debugValgrindRS32Item { debugValgrindRedzoneSizeItem, $"32" , f, id = 32, checkable = true, disabled = true; NotifySelect = ValgrindRSSelect; }
1131 MenuItem debugValgrindRS64Item { debugValgrindRedzoneSizeItem, $"64" , f, id = 64, checkable = true, disabled = true; NotifySelect = ValgrindRSSelect; }
1132 MenuItem debugValgrindRS128Item { debugValgrindRedzoneSizeItem, $"128" , f, id = 128, checkable = true, disabled = true; NotifySelect = ValgrindRSSelect; }
1133 MenuItem debugValgrindRS256Item { debugValgrindRedzoneSizeItem, $"256" , f, id = 256, checkable = true, disabled = true; NotifySelect = ValgrindRSSelect; }
1134 MenuItem debugValgrindRS512Item { debugValgrindRedzoneSizeItem, $"512" , f, id = 512, checkable = true, disabled = true; NotifySelect = ValgrindRSSelect; }
1135 bool ValgrindRSSelect(MenuItem selection, Modifiers mods)
1139 if(selection.checked)
1141 int vgRedzoneSize = (int)selection.id;
1143 debugValgrindRSDefaultItem.checked = debugValgrindRSDefaultItem.id == vgRedzoneSize;
1144 debugValgrindRS0Item.checked = debugValgrindRS0Item.id == vgRedzoneSize;
1145 debugValgrindRS16Item.checked = debugValgrindRS16Item.id == vgRedzoneSize;
1146 debugValgrindRS32Item.checked = debugValgrindRS32Item.id == vgRedzoneSize;
1147 debugValgrindRS64Item.checked = debugValgrindRS64Item.id == vgRedzoneSize;
1148 debugValgrindRS128Item.checked = debugValgrindRS128Item.id == vgRedzoneSize;
1149 debugValgrindRS256Item.checked = debugValgrindRS256Item.id == vgRedzoneSize;
1150 debugValgrindRS512Item.checked = debugValgrindRS512Item.id == vgRedzoneSize;
1152 ide.workspace.vgRedzoneSize = vgRedzoneSize;
1153 ide.workspace.Save();
1156 selection.checked = true;
1160 MenuItem debugValgrindTrackOriginsItem
1162 debugMenu, $"Valgrind Track Origins", k, checkable = true, disabled = true;
1163 bool NotifySelect(MenuItem selection, Modifiers mods)
1167 ide.workspace.vgTrackOrigins = selection.checked;
1168 ide.workspace.Save();
1174 MenuDivider { debugMenu };
1175 MenuItem debugStepIntoItem
1177 debugMenu, $"Step Into", i, f11, disabled = true;
1178 bitmap = { ":actions/stepInto.png" };
1179 bool NotifySelect(MenuItem selection, Modifiers mods)
1181 if(projectView) projectView.DebugStepInto();
1185 MenuItem debugStepOverItem
1187 debugMenu, $"Step Over", v, f10, disabled = true;
1188 bitmap = { ":actions/stepOver.png" };
1189 bool NotifySelect(MenuItem selection, Modifiers mods)
1191 if(projectView) projectView.DebugStepOver(false);
1195 MenuItem debugSkipStepOverItem
1197 debugMenu, $"Step Over Skipping Breakpoints", e, shiftF10, disabled = true;
1198 bitmap = { ":actions/stepOverSkipBreak.png" };
1199 bool NotifySelect(MenuItem selection, Modifiers mods)
1201 if(projectView) projectView.DebugStepOver(true);
1205 MenuItem debugStepOutItem
1207 debugMenu, $"Step Out", o, shiftF11, disabled = true;
1208 bitmap = { ":actions/stepOut.png" };
1209 bool NotifySelect(MenuItem selection, Modifiers mods)
1211 if(projectView) projectView.DebugStepOut(false);
1215 MenuItem debugSkipStepOutItem
1217 debugMenu, $"Step Out Skipping Breakpoints", n, Key { f11, ctrl = true, shift = true }, disabled = true;
1218 bitmap = { ":actions/skipBreaks.png" };
1219 bool NotifySelect(MenuItem selection, Modifiers mods)
1221 if(projectView) projectView.DebugStepOut(true);
1226 MenuItem debugStepUntilItem
1228 debugMenu, $"Step Over Until Next Line", x, disabled = true;
1229 bool NotifySelect(MenuItem selection, Modifiers mods)
1231 if(projectView) projectView.DebugStepUntil(false);
1235 MenuItem debugSkipStepUntilItem
1237 debugMenu, $"Step Over Until Next Line Skipping Breakpoints", e, Key { f10, shift = true, alt = true }, disabled = true;
1238 bool NotifySelect(MenuItem selection, Modifiers mods)
1240 if(projectView) projectView.DebugStepUntil(true);
1245 MenuPlacement debugRunToCursorItem { debugMenu, $"Run To Cursor", c };
1246 MenuPlacement debugSkipRunToCursorItem { debugMenu, $"Run To Cursor Skipping Breakpoints", u };
1247 MenuPlacement debugRunToCursorAtSameLevelItem { debugMenu, $"Run To Cursor At Same Level", l };
1248 MenuPlacement debugSkipRunToCursorAtSameLevelItem { debugMenu, $"Run To Cursor At Same Level Skipping Breakpoints", g };
1250 MenuPlacement debugBpRunToCursorItem { debugMenu, $"BP Run To Cursor" };
1251 MenuPlacement debugBpSkipRunToCursorItem { debugMenu, $"BP Run To Cursor Skipping Breakpoints" };
1252 MenuPlacement debugBpRunToCursorAtSameLevelItem { debugMenu, $"BP Run To Cursor At Same Level" };
1253 MenuPlacement debugBpSkipRunToCursorAtSameLevelItem { debugMenu, $"BP Run To Cursor At Same Level Skipping Breakpoints" };
1255 //MenuDivider { debugMenu };
1256 //MenuPlacement debugToggleBreakpoint { debugMenu, "Toggle Breakpoint", t };
1257 MenuPlacement imageMenu { menu, $"Image", i };
1258 Menu viewMenu { menu, $"View", v };
1259 MenuItem viewProjectItem
1261 viewMenu, $"Project View", j, alt0, disabled = true;
1262 bool NotifySelect(MenuItem selection, Modifiers mods)
1266 projectView.visible = true;
1267 projectView.Activate();
1272 MenuPlacement { viewMenu, $"View Designer" };
1273 MenuPlacement { viewMenu, $"View Code" };
1274 MenuPlacement { viewMenu, $"View Properties" };
1275 MenuPlacement { viewMenu, $"View Methods" };
1276 MenuItem viewDesignerItem
1278 viewMenu, $"View Designer", d, f8;
1279 bool NotifySelect(MenuItem selection, Modifiers mods)
1281 Window client = activeClient;
1282 Class dataType = client._class;
1283 if(!strcmp(dataType.name, "Designer"))
1285 client.visible = true;
1289 ((CodeEditor)client).ViewDesigner();
1293 MenuItem viewCodeItem
1295 viewMenu, $"View Code", c, f8;
1296 bool NotifySelect(MenuItem selection, Modifiers mods)
1298 Window client = activeClient;
1299 Class dataType = client._class;
1300 if(!strcmp(dataType.name, "Designer"))
1301 client = ((Designer)client).codeEditor;
1304 // Do this after so the caret isn't moved yet...
1305 client.visible = true;
1309 MenuItem viewPropertiesItem
1311 viewMenu, $"View Properties", p, f4;
1312 bool NotifySelect(MenuItem selection, Modifiers mods)
1314 sheet.visible = true;
1315 sheet.sheetSelected = properties;
1320 MenuItem viewMethodsItem
1322 viewMenu, $"View Methods", m, f4;
1323 bool NotifySelect(MenuItem selection, Modifiers mods)
1325 sheet.visible = true;
1326 sheet.sheetSelected = methods;
1331 MenuItem viewToolBoxItem
1333 viewMenu, $"View Toolbox", x, f12;
1334 bool NotifySelect(MenuItem selection, Modifiers mods)
1336 toolBox.visible = true;
1341 MenuItem viewOutputItem
1343 viewMenu, $"Output", o, alt2;
1344 bool NotifySelect(MenuItem selection, Modifiers mods)
1350 MenuItem viewWatchesItem
1352 viewMenu, $"Watches", w, alt3;
1353 bool NotifySelect(MenuItem selection, Modifiers mods)
1359 MenuItem viewThreadsItem
1361 viewMenu, $"Threads", t, alt4;
1362 bool NotifySelect(MenuItem selection, Modifiers mods)
1368 MenuItem viewBreakpointsItem
1370 viewMenu, $"Breakpoints", b, alt5;
1371 bool NotifySelect(MenuItem selection, Modifiers mods)
1373 breakpointsView.Show();
1377 MenuItem viewCallStackItem
1379 viewMenu, $"Call Stack", s, alt7;
1380 bool NotifySelect(MenuItem selection, Modifiers mods)
1382 callStackView.Show();
1386 MenuItem viewAllDebugViews
1388 viewMenu, $"All Debug Views", a, alt9;
1389 bool NotifySelect(MenuItem selection, Modifiers mods)
1394 callStackView.Show();
1395 breakpointsView.Show();
1399 #ifdef GDB_DEBUG_GUI
1400 MenuDivider { viewMenu };
1401 MenuItem viewGDBItem
1403 viewMenu, $"GDB Dialog", g, Key { f9, shift = true, ctrl = true };
1404 bool NotifySelect(MenuItem selection, Modifiers mods)
1411 MenuDivider { viewMenu };
1412 MenuItem viewColorPicker
1414 viewMenu, $"Color Picker...", l, Key { c, ctrl = true , shift = true };
1415 bool NotifySelect(MenuItem selection, Modifiers mods)
1417 ColorPicker colorPicker { master = this };
1418 colorPicker.Modal();
1422 MenuDivider { viewMenu };
1426 viewMenu, "Full Screen", f, checkable = true;
1428 bool NotifySelect(MenuItem selection, Modifiers mods)
1430 app.fullScreen ^= true;
1432 anchor = { 0, 0, 0, 0 };
1437 Menu driversMenu { viewMenu, $"Graphics Driver", v };
1438 //Menu skinsMenu { viewMenu, "GUI Skins", k };
1439 Menu windowMenu { menu, $"Window", w };
1440 MenuItem { windowMenu, $"Close All", l, NotifySelect = MenuWindowCloseAll };
1441 MenuDivider { windowMenu };
1442 MenuItem { windowMenu, $"Next", n, f6, NotifySelect = MenuWindowNext };
1443 MenuItem { windowMenu, $"Previous", p, shiftF6, NotifySelect = MenuWindowPrevious };
1444 MenuDivider { windowMenu };
1445 MenuItem { windowMenu, $"Cascade", c, NotifySelect = MenuWindowCascade };
1446 MenuItem { windowMenu, $"Tile Horizontally", h, NotifySelect = MenuWindowTileHorz };
1447 MenuItem { windowMenu, $"Tile Vertically", v, NotifySelect = MenuWindowTileVert };
1448 MenuItem { windowMenu, $"Arrange Icons", a, NotifySelect = MenuWindowArrangeIcons };
1449 MenuDivider { windowMenu };
1450 MenuItem { windowMenu, $"Windows...", w, NotifySelect = MenuWindowWindows };
1451 Menu helpMenu { menu, $"Help", h };
1454 helpMenu, $"API Reference", r, f1;
1455 bool NotifySelect(MenuItem selection, Modifiers mods)
1459 char * p = new char[MAX_LOCATION];
1461 strncpy(p, settingsContainer.moduleLocation, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
1462 PathCat(p, "documentor");
1463 #if defined(__WIN32__)
1464 ChangeExtension(p, "exe", p);
1466 if(!FileExists(p).isFile)
1467 strcpy(p, "documentor");
1469 documentor = DualPipeOpen({ input = true, output = true, showWindow = true }, p);
1474 Process_ShowWindows(documentor.GetProcessID());
1475 // documentor.Puts("Activate\n");
1480 MenuDivider { helpMenu };
1483 helpMenu, $"Ecere Tao of Programming [work in progress]", t;
1484 bool NotifySelect(MenuItem selection, Modifiers mods)
1486 FindAndShellOpenInstalledFile("doc", "Ecere Tao of Programming [work in progress].pdf");
1490 MenuDivider { helpMenu };
1493 helpMenu, $"Documentation Folder", d;
1494 bool NotifySelect(MenuItem selection, Modifiers mods)
1496 FindAndShellOpenInstalledFolder("doc");
1502 helpMenu, $"Samples Folder", s;
1503 bool NotifySelect(MenuItem selection, Modifiers mods)
1505 FindAndShellOpenInstalledFolder("samples");
1511 helpMenu, $"Extras Folder", x;
1512 bool NotifySelect(MenuItem selection, Modifiers mods)
1514 FindAndShellOpenInstalledFolder("extras");
1518 MenuDivider { helpMenu };
1521 helpMenu, $"Community Forums", f;
1522 bool NotifySelect(MenuItem selection, Modifiers mods)
1524 ShellOpen("http://ecere.com/forums");
1528 MenuDivider { helpMenu };
1531 helpMenu, $"About...", a;
1532 bool NotifySelect(MenuItem selection, Modifiers mods)
1534 AboutIDE { master = this }.Modal();
1539 property ToolBox toolBox
1541 get { return toolBox; }
1544 property Sheet sheet
1546 get { return sheet; }
1549 property Project project
1551 get { return projectView ? projectView.project : null; }
1554 property Workspace workspace
1556 get { return projectView ? projectView.workspace : null; }
1559 FindInFilesDialog findInFilesDialog
1562 filters = findInFilesFileFilters.array, sizeFilters = findInFilesFileFilters.count * sizeof(FileFilter);
1568 #ifdef GDB_DEBUG_GUI
1571 master = this, parent = this;
1572 //anchor = { left = 100, top = 100, right = 100, bottom = 100 };
1574 void OnCommand(char * string)
1577 ide.debugger.SendGDBCommand(string);
1582 bool NotifySelectDisplayDriver(MenuItem selection, Modifiers mods)
1584 //app.driver = app.drivers[selection.id];
1585 #if defined(__unix__) || defined(__APPLE__)
1586 app.driver = selection.id ? "OpenGL" : "X";
1588 app.driver = selection.id ? "OpenGL" : "GDI";
1590 delete ideSettings.displayDriver;
1591 ideSettings.displayDriver = CopyString(selection.id ? "OpenGL" : "Default");
1593 settingsContainer.Save();
1594 //SetDriverAndSkin();
1598 bool NotifySelectDisplaySkin(MenuItem selection, Modifiers mods)
1600 app.skin = app.skins[selection.id];
1605 void SetDriverAndSkin()
1608 for(c = 0; c < app.numSkins; c++)
1609 if(!strcmp(app.skins[c], app.skin))
1611 skinItems[c].checked = true;
1614 for(c = 0; c < app.numDrivers; c++)
1615 if(!strcmp(app.drivers[c], app.driver))
1617 driverItems[c].checked = true;
1622 ProjectView CreateProjectView(Workspace workspace, char * fileName)
1624 Project project = workspace.projects.firstIterator.data;
1625 projectView = ProjectView
1628 fileName = fileName;
1630 void NotifyDestroyed(Window window, DialogResult result)
1633 text = titleECEREIDE;
1638 projectView.Create();
1639 RepositionWindows(false);
1641 // Leave it after Create to avoid flicker due to seeing IDE without a project view
1642 projectView.workspace = workspace;
1643 projectView.project = project;
1644 ideMainFrame.SetText("%s - %s", project.topNode.name, titleECEREIDE);
1648 ide.breakpointsView.LoadFromWorkspace();
1649 ide.watchesView.LoadFromWorkspace();
1651 findInFilesDialog.projectNodeField.userData = projectView;
1654 char fileName[MAX_LOCATION];
1655 strcpy(fileName, project.topNode.path);
1656 PathCat(fileName, project.topNode.name);
1663 projectView.visible = false;
1664 if((!projectView || projectView.created == false || projectView.Destroy(0)) && MenuWindowCloseAll(null, 0))
1666 if(findInFilesDialog)
1668 char workingDir[MAX_LOCATION];
1669 GetWorkingDir(workingDir, MAX_LOCATION);
1670 findInFilesDialog.SearchStop();
1671 findInFilesDialog.currentDirectory = workingDir;
1673 ideMainFrame.text = titleECEREIDE;
1680 void RepositionWindows(bool expand)
1685 bool inDebugMode = debugger.isActive;
1686 bool callStackVisible = expand ? false : callStackView.visible;
1687 bool threadsVisible = expand ? false : threadsView.visible;
1688 bool watchesVisible = expand ? false : watchesView.visible;
1689 bool breakpointsVisible = expand ? false : breakpointsView.visible;
1690 bool toolBoxVisible = toolBox.visible;
1691 bool outputVisible = expand ? false : outputView.visible;
1692 int topDistance = (callStackVisible || threadsVisible) ? 200 : 0;
1693 int bottomDistance = (outputVisible || watchesVisible || breakpointsVisible) ? 240 : 0;
1695 for(child = firstChild; child; child = child.next)
1697 if(child._class == class(CodeEditor) || child._class == class(Designer) ||
1698 child._class == class(Sheet) || child._class == class(ProjectView))
1700 Anchor anchor = child.anchor;
1701 anchor.top = topDistance;
1702 anchor.bottom = bottomDistance;
1703 if(child._class == class(CodeEditor) || child._class == class(Designer))
1706 anchor.right = toolBoxVisible ? 150 : 0;
1708 child.anchor = anchor;
1712 if(child._class == class(OutputView) || child._class == class(CallStackView) || child._class == class(ThreadsView) || child._class == class(WatchesView) ||
1713 child._class == class(BreakpointsView))
1714 child.visible = false;
1717 // If this is not here, the IDE is not updated when doing Debug/Break then Alt-4 to show call stack (IDE not updated)
1722 bool ShowCodeEditor()
1725 activeClient.Activate();
1726 else if(projectView)
1728 projectView.visible = true;
1729 projectView.Activate();
1733 sheet.visible = true;
1739 void DocumentSaved(Window document, char * fileName)
1741 ideSettings.AddRecentFile(fileName);
1742 ide.UpdateRecentMenus();
1743 ide.AdjustFileMenus();
1744 settingsContainer.Save();
1747 bool Window::OnFileModified(FileChange fileChange, char * param)
1750 sprintf(temp, $"The document %s was modified by another application.\n"
1751 "Would you like to reload it and lose your changes?", this.fileName);
1752 if(MessageBox { type = yesNo, master = this/*.parent*/,
1753 text = $"Document has been modified", contents = temp }.Modal() == yes)
1755 bool noParsing = (this._class == class(CodeEditor) && ((CodeEditor)this).noParsing) ? true : false;
1756 char * fileName = CopyString(this.fileName);
1757 WindowState state = this.state;
1758 Anchor anchor = this.anchor;
1759 Size size = this.size;
1761 this.modifiedDocument = false;
1763 this = ide.OpenFile(fileName, normal, true, null, no, normal, noParsing);
1766 this.anchor = anchor;
1768 this.SetState(state, true, 0);
1776 void UpdateMakefiles()
1780 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
1781 for(prj : workspace.projects)
1782 projectView.ProjectUpdateMakefileForAllConfigs(prj);
1787 void UpdateCompilerConfigs(bool mute)
1789 UpdateToolBarActiveCompilers();
1792 bool silent = mute || (ide.projectView.buildInProgress == none ? false : true);
1793 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
1796 projectView.ShowOutputBuildLog(true);
1797 projectView.DisplayCompiler(compiler, false);
1799 for(prj : workspace.projects)
1800 projectView.ProjectPrepareCompiler(prj, compiler, silent);
1805 void UpdateToolBarActiveCompilers()
1807 toolBar.activeCompiler.Clear();
1808 for(compiler : ideSettings.compilerConfigs)
1810 DataRow row = toolBar.activeCompiler.AddString(compiler.name);
1811 if(workspace && workspace.compiler && !strcmp(compiler.name, workspace.compiler))
1812 toolBar.activeCompiler.currentRow = row;
1814 if(!toolBar.activeCompiler.currentRow && toolBar.activeCompiler.firstRow)
1815 toolBar.activeCompiler.SelectRow(toolBar.activeCompiler.firstRow);
1818 void UpdateToolBarActiveConfigs(bool selectionOnly)
1820 bool commonSelected = false;
1821 DataRow row = toolBar.activeConfig.currentRow;
1823 row = toolBar.activeConfig.FindRow(1);
1826 toolBar.activeConfig.Clear();
1827 row = toolBar.activeConfig.AddString($"(Mixed)");
1832 char * configName = null;
1835 Map<String, int> configs { }; // TOIMP: just need sort but using map until containers have sort
1836 for(prj : workspace.projects)
1838 for(cfg : prj.configurations)
1841 configs[cfg.name] = 1;
1846 toolBar.activeConfig.AddString(&name);
1850 if(projectView && projectView.project)
1852 for(prj : workspace.projects)
1854 if(prj.config && prj.config.name)
1856 configName = prj.config.name;
1862 commonSelected = true;
1863 for(prj : workspace.projects)
1865 if(prj.config && (!prj.config.name || strcmp(prj.config.name, configName)))
1867 commonSelected = false;
1875 commonSelected = false;
1876 for(row = toolBar.activeConfig.firstRow; row; row = row.next)
1878 if(!strcmp(row.string, configName))
1880 toolBar.activeConfig.currentRow = row;
1881 commonSelected = true;
1888 toolBar.activeConfig.Sort(null, 0);
1890 toolBar.activeConfig.currentRow = row;
1895 bool unavailable = !project;
1897 projectAddItem.disabled = unavailable;
1898 toolBar.buttonAddProject.disabled = unavailable;
1900 projectSettingsItem.disabled = unavailable;
1902 projectBrowseFolderItem.disabled = unavailable;
1904 viewProjectItem.disabled = unavailable;
1906 toolBar.activeConfig.disabled = unavailable;
1907 toolBar.activeCompiler.disabled = unavailable;
1908 toolBar.activeBitDepth.disabled = unavailable;
1911 debugUseValgrindItem.disabled = unavailable;
1912 AdjustValgrindMenus();
1921 void AdjustValgrindMenus()
1923 bool unavailable = !project || !debugUseValgrindItem.checked;
1924 debugValgrindNoLeakCheckItem.disabled = unavailable;
1925 debugValgrindSummaryLeakCheckItem.disabled = unavailable;
1926 debugValgrindYesLeakCheckItem.disabled = unavailable;
1927 debugValgrindFullLeakCheckItem.disabled = unavailable;
1929 debugValgrindTrackOriginsItem.disabled = unavailable;
1931 debugValgrindRSDefaultItem.disabled = unavailable;
1932 debugValgrindRS0Item.disabled = unavailable;
1933 debugValgrindRS16Item.disabled = unavailable;
1934 debugValgrindRS32Item.disabled = unavailable;
1935 debugValgrindRS64Item.disabled = unavailable;
1936 debugValgrindRS128Item.disabled = unavailable;
1937 debugValgrindRS256Item.disabled = unavailable;
1938 debugValgrindRS512Item.disabled = unavailable;
1942 property bool hasOpenedCodeEditors
1947 for(w = firstChild; w; w = w.next)
1948 if(w._class == class(CodeEditor) &&
1949 w.isDocument && !w.closing && w.visible && w.created &&
1950 w.fileName && w.fileName[0])
1956 void AdjustFileMenus()
1958 bool unavailable = project != null || !hasOpenedCodeEditors; // are they supported source code (ec, c, cpp, etc) ?
1960 projectQuickItem.disabled = unavailable;
1963 void AdjustBuildMenus()
1965 bool unavailable = project && projectView.buildInProgress;
1966 bool naForRun = unavailable || !project || project.GetTargetType(project.config) != executable;
1968 projectNewItem.disabled = unavailable;
1969 toolBar.buttonNewProject.disabled = unavailable;
1970 projectOpenItem.disabled = unavailable;
1971 toolBar.buttonOpenProject.disabled = unavailable;
1973 unavailable = !project || projectView.buildInProgress;
1975 projectCloseItem.disabled = unavailable;
1976 // toolBar.buttonCloseProject.disabled = unavailable;
1978 projectRunItem.disabled = naForRun;
1979 toolBar.buttonRun.disabled = naForRun;
1981 projectBuildItem.disabled = false;
1982 projectBuildItem.text = unavailable ? $"Stop Build" : $"Build";
1983 projectBuildItem.accelerator = unavailable ? Key { pauseBreak, ctrl = true } : f7;
1985 projectLinkItem.disabled = unavailable;
1986 toolBar.buttonReLink.disabled = unavailable;
1987 projectRebuildItem.disabled = unavailable;
1988 toolBar.buttonRebuild.disabled = unavailable;
1989 projectCleanItem.disabled = unavailable;
1990 toolBar.buttonClean.disabled = unavailable;
1991 projectCleanTargetItem.disabled = unavailable;
1992 projectRealCleanItem.disabled = unavailable;
1993 // toolBar.buttonRealClean.disabled = unavailable;
1994 projectRegenerateItem.disabled = unavailable;
1995 toolBar.buttonRegenerateMakefile.disabled = unavailable;
1996 #ifdef IDE_SHOW_INSTALL_MENU_BUTTON
1997 projectInstallItem.disabled = unavailable;
1998 toolBar.buttonInstall.disabled = unavailable;
2000 projectCompileItem.disabled = unavailable;
2002 AdjustPopupBuildMenus();
2005 void AdjustPopupBuildMenus()
2007 bool unavailable = !project || projectView.buildInProgress;
2009 if(projectView && projectView.popupMenu && projectView.popupMenu.menu && projectView.popupMenu.created)
2012 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectBuild, 0);
2015 menu.disabled = false;
2016 menu.text = unavailable ? $"Stop Build" : $"Build";
2017 menu.accelerator = unavailable ? Key { pauseBreak, ctrl = true } : f7;
2020 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectLink, 0); if(menu) menu.disabled = unavailable;
2021 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRebuild, 0); if(menu) menu.disabled = unavailable;
2022 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectCleanTarget, 0); if(menu) menu.disabled = unavailable;
2023 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectClean, 0); if(menu) menu.disabled = unavailable;
2024 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRealClean, 0); if(menu) menu.disabled = unavailable;
2025 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRegenerate, 0); if(menu) menu.disabled = unavailable;
2026 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectInstall, 0); if(menu) menu.disabled = unavailable;
2027 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRemove, 0); if(menu) menu.disabled = unavailable;
2028 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileClean, 0); if(menu) menu.disabled = unavailable;
2029 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileCompile, 0); if(menu) menu.disabled = unavailable;
2030 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugPrecompile, 0); if(menu) menu.disabled = unavailable;
2031 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugCompile, 0); if(menu) menu.disabled = unavailable;
2032 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugGenerateSymbols, 0); if(menu) menu.disabled = unavailable;
2033 projectView.popupMenu.Update(null);
2037 property bool areDebugMenusUnavailable { get {
2039 project.GetTargetType(project.config) != executable ||
2040 projectView.buildInProgress == buildingMainProject;
2043 property bool isBreakpointTogglingUnavailable { get { return !project; } }
2044 property bool isDebuggerRunning { get { if(ide.debugger) return ide.debugger.state == running; return false; } }
2045 property bool isDebuggerStopped { get { if(ide.debugger) return ide.debugger.state == stopped; return false; } }
2047 void AdjustDebugMenus()
2049 bool unavailable = areDebugMenusUnavailable;
2050 bool running = isDebuggerRunning;
2051 bool stopped = isDebuggerStopped;
2052 bool active = debugger.isActive;
2053 bool noBreakpointToggle = !project;
2055 bool isNotRunning = unavailable || !running;
2056 bool isNotNotRunning = unavailable || running;
2057 bool isNotStopped = unavailable || !stopped;
2058 bool isNotActive = unavailable || !active;
2060 debugStartResumeItem.disabled = isNotNotRunning;
2061 debugStartResumeItem.text = active ? $"Resume" : $"Start";
2062 debugStartResumeItem.NotifySelect = active ? MenuDebugResume : MenuDebugStart;
2065 toolBar.buttonDebugStartResume.disabled = isNotNotRunning;
2066 toolBar.buttonDebugStartResume.toolTip = active ? $"Resume" : $"Start";
2069 debugBreakItem.disabled = isNotRunning;
2070 debugStopItem.disabled = isNotActive;
2071 debugRestartItem.disabled = isNotActive;
2074 toolBar.buttonDebugPause.disabled = isNotRunning;
2075 toolBar.buttonDebugStop.disabled = isNotActive;
2076 toolBar.buttonDebugRestart.disabled = isNotActive;
2079 debugStepIntoItem.disabled = isNotNotRunning;
2080 debugStepOverItem.disabled = isNotNotRunning;
2081 debugSkipStepOverItem.disabled = isNotNotRunning;
2082 debugStepOutItem.disabled = isNotStopped;
2083 debugSkipStepOutItem.disabled = isNotStopped;
2085 debugStepUntilItem.disabled = isNotStopped;
2086 debugSkipStepUntilItem.disabled = isNotStopped;
2090 toolBar.buttonDebugStepInto.disabled = isNotNotRunning;
2091 toolBar.buttonDebugStepOver.disabled = isNotNotRunning;
2092 toolBar.buttonDebugSkipStepOver.disabled = isNotNotRunning;
2093 toolBar.buttonDebugStepOut.disabled = isNotStopped;
2094 //toolBar.buttonDebugSkipStepOutItem.disabled = isNotNotRunning;
2096 if((Designer)GetActiveDesigner())
2098 CodeEditor codeEditor = ((Designer)GetActiveDesigner()).codeEditor;
2100 codeEditor.AdjustDebugMenus();
2104 void ChangeFileDialogsDirectory(char * directory, bool saveSettings)
2106 char tempString[MAX_LOCATION];
2107 strcpy(tempString, directory);
2108 if(saveSettings && !projectView)
2110 ideSettings.ideFileDialogLocation = directory;
2111 settingsContainer.Save();
2114 ideFileDialog.currentDirectory = tempString;
2115 codeEditorFileDialog.currentDirectory = tempString;
2116 codeEditorFormFileDialog.currentDirectory = tempString;
2119 void ChangeProjectFileDialogDirectory(char * directory)
2121 ideSettings.ideProjectFileDialogLocation = directory;
2122 settingsContainer.Save();
2125 Window FindWindow(char * filePath)
2127 Window document = null;
2129 // TOCHECK: Do we need to change slashes here?
2130 for(document = firstChild; document; document = document.next)
2132 char * fileName = document.fileName;
2133 if(document.isDocument && fileName && !fstrcmp(fileName, filePath))
2135 document.visible = true;
2136 document.Activate();
2143 bool DontTerminateDebugSession(char * title)
2145 if(debugger.isActive)
2147 if(MessageBox { type = yesNo, master = ide,
2148 contents = $"Do you want to terminate the debugging session in progress?",
2149 text = title }.Modal() == no)
2152 MessageBox msg { type = yesNo, master = ide,
2153 contents = "Do you want to terminate the debugging session in progress?",
2155 if(msg.Modal() == no)
2167 Window OpenFile(char * origFilePath, WindowState state, bool visible, char * type, OpenCreateIfFails createIfFails, OpenMethod openMethod, bool noParsing)
2169 char extension[MAX_EXTENSION] = "";
2170 Window document = null;
2171 bool isProject = false;
2172 bool needFileModified = true;
2173 char winFilePath[MAX_LOCATION];
2174 char * filePath = strstr(origFilePath, "http://") == origFilePath ? strcpy(winFilePath, origFilePath) : GetSystemPathBuffer(winFilePath, origFilePath);
2178 GetExtension(filePath, extension);
2182 strcpy(extension, type);
2184 if(strcmp(extension, ProjectExtension))
2186 for(document = firstChild; document; document = document.next)
2188 char * fileName = document.fileName;
2189 if(document.isDocument && fileName && !fstrcmp(fileName, filePath) && document.created)
2191 document.visible = true;
2193 document.Activate();
2199 if(createIfFails == whatever)
2201 else if(!strcmp(extension, ProjectExtension) || !strcmp(extension, WorkspaceExtension))
2203 needFileModified = false;
2204 if(openMethod == normal)
2206 if(DontTerminateDebugSession($"Open Project"))
2216 Workspace workspace = null;
2218 if(FileExists(filePath))
2220 if(!strcmp(extension, ProjectExtension))
2222 char workspaceFile[MAX_LOCATION];
2223 strcpy(workspaceFile, filePath);
2224 ChangeExtension(workspaceFile, WorkspaceExtension, workspaceFile);
2225 workspace = LoadWorkspace(workspaceFile, filePath);
2227 else if(!strcmp(extension, WorkspaceExtension))
2228 workspace = LoadWorkspace(filePath, null);
2231 //project = LoadProject(filePath, null);
2236 char absolutePath[MAX_LOCATION];
2237 CreateProjectView(workspace, filePath);
2238 document = projectView;
2240 workspace.ParseLoadedBreakpoints();
2241 workspace.DropInvalidBreakpoints(null);
2244 ide.projectView.ShowOutputBuildLog(true);
2246 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
2247 ide.projectView.DisplayCompiler(compiler, false);
2250 UpdateCompilerConfigs(false);
2253 char newWorkingDir[MAX_LOCATION];
2254 StripLastDirectory(filePath, newWorkingDir);
2255 ChangeFileDialogsDirectory(newWorkingDir, false);
2258 document.fileName = filePath;
2260 ideMainFrame.SetText("%s - %s", filePath, titleECEREIDE);
2262 // this crashes on starting ide with epj file, solution please?
2263 // app.UpdateDisplay();
2265 workspace.holdTracking = true;
2266 for(ofi : workspace.openedFiles)
2268 if(ofi.state != closed)
2270 Window file = OpenFile(ofi.path, normal, true, null, no, normal, noParsing);
2273 char fileName[MAX_LOCATION];
2275 GetLastDirectory(ofi.path, fileName);
2276 node = projectView.project.topNode.Find(fileName, true);
2278 node.EnsureVisible();
2282 ide.RepositionWindows(false);
2283 workspace.holdTracking = false;
2285 workspace.timer.Start();
2287 #if !defined(__WIN32__)
2288 // Valgrind Debug menu updates
2289 debugUseValgrindItem.checked = workspace.useValgrind;
2291 debugValgrindNoLeakCheckItem.checked = workspace.vgLeakCheck == no;
2292 debugValgrindSummaryLeakCheckItem.checked = workspace.vgLeakCheck == summary;
2293 debugValgrindYesLeakCheckItem.checked = workspace.vgLeakCheck == yes;
2294 debugValgrindFullLeakCheckItem.checked = workspace.vgLeakCheck == full;
2296 debugValgrindRSDefaultItem.checked = workspace.vgRedzoneSize == -1;
2297 debugValgrindRS0Item.checked = workspace.vgRedzoneSize == 0;
2298 debugValgrindRS16Item.checked = workspace.vgRedzoneSize == 16;
2299 debugValgrindRS32Item.checked = workspace.vgRedzoneSize == 32;
2300 debugValgrindRS64Item.checked = workspace.vgRedzoneSize == 64;
2301 debugValgrindRS128Item.checked = workspace.vgRedzoneSize == 128;
2302 debugValgrindRS256Item.checked = workspace.vgRedzoneSize == 256;
2303 debugValgrindRS512Item.checked = workspace.vgRedzoneSize == 512;
2305 debugValgrindTrackOriginsItem.checked = workspace.vgTrackOrigins;
2308 findInFilesDialog.mode = FindInFilesMode::project;
2309 findInFilesDialog.currentDirectory = ide.project.topNode.path;
2312 char location[MAX_LOCATION];
2313 StripLastDirectory(ide.project.topNode.path, location);
2314 ChangeProjectFileDialogDirectory(location);
2321 if(MessageBox { type = yesNo, master = this, text = $"Error opening project", contents = $"Open a different project?" }.Modal() == yes)
2323 ideProjectFileDialog.text = openProjectFileDialogTitle;
2324 if(ideProjectFileDialog.Modal() == cancel)
2326 filePath = ideProjectFileDialog.filePath;
2327 GetExtension(filePath, extension);
2338 else if(openMethod == add)
2343 char slashFilePath[MAX_LOCATION];
2344 GetSlashPathBuffer(slashFilePath, filePath);
2345 for(p : workspace.projects)
2347 if(!fstrcmp(p.filePath, slashFilePath))
2355 MessageBox { type = ok, parent = parent, master = this, text = $"Same Project",
2356 contents = $"This project is already present in workspace." }.Modal();
2360 prj = LoadProject(filePath, null);
2363 char * activeConfigName = null;
2364 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
2365 prj.StartMonitoring();
2366 workspace.projects.Add(prj);
2367 if(toolBar.activeConfig.currentRow && toolBar.activeConfig.currentRow != toolBar.activeConfig.firstRow &&
2368 toolBar.activeConfig.currentRow.string && toolBar.activeConfig.currentRow.string[0])
2369 activeConfigName = toolBar.activeConfig.currentRow.string;
2370 if(activeConfigName)
2372 for(cfg : prj.configurations)
2374 if(cfg.name && !strcmp(cfg.name, activeConfigName))
2382 projectView.AddNode(prj.topNode, null);
2383 workspace.modified = true;
2385 findInFilesDialog.AddProjectItem(prj);
2386 projectView.ShowOutputBuildLog(true);
2387 projectView.DisplayCompiler(compiler, false);
2388 projectView.ProjectUpdateMakefileForAllConfigs(prj);
2392 char location[MAX_LOCATION];
2393 StripLastDirectory(prj.topNode.path, location);
2394 ChangeProjectFileDialogDirectory(location);
2397 // projectView is associated with the main project and not with the one just added but
2398 return projectView; // just to let the caller know something was opened
2406 else if(!strcmp(extension, "bmp") || !strcmp(extension, "pcx") ||
2407 !strcmp(extension, "jpg") || !strcmp(extension, "gif") ||
2408 !strcmp(extension, "jpeg") || !strcmp(extension, "png"))
2410 if(FileExists(filePath))
2411 document = PictureEdit { hasMaximize = true, hasMinimize = true, hasClose = true, borderStyle = sizable,
2412 hasVertScroll = true, hasHorzScroll = true, parent = this, state = state,
2413 visible = visible, bitmapFile = filePath, OnClose = PictureEditOnClose/*why?--GenericDocumentOnClose*/;
2416 MessageBox { type = ok, master = this, text = filePath, contents = $"File doesn't exist." }.Modal();
2419 else if(!strcmp(extension, "3ds"))
2421 if(FileExists(filePath))
2422 document = ModelView { hasMaximize = true, hasMinimize = true, hasClose = true, borderStyle = sizable,
2423 hasVertScroll = true, hasHorzScroll = true, parent = this, state = state,
2424 visible = visible, modelFile = filePath, OnClose = ModelViewOnClose/*why?--GenericDocumentOnClose*/
2428 MessageBox { type = ok, master = this, text = filePath, contents = $"File doesn't exist." }.Modal();
2431 else if(!strcmp(extension, "txt") || !strcmp(extension, "text") ||
2432 !strcmp(extension, "nfo") || !strcmp(extension, "info") ||
2433 !strcmp(extension, "htm") || !strcmp(extension, "html") ||
2434 !strcmp(extension, "css") || !strcmp(extension, "php") ||
2435 !strcmp(extension, "js"))
2437 CodeEditor editor { parent = this, state = state, visible = false, noParsing = noParsing };
2438 editor.updatingCode = true;
2439 if(editor.LoadFile(filePath))
2442 editor.visible = true;
2446 needFileModified = false;
2450 CodeEditor editor { parent = this, state = state, visible = false, noParsing = noParsing };
2451 if(editor.LoadFile(filePath))
2454 editor.visible = true;
2458 needFileModified = false;
2461 if(document && (document._class == class(PictureEdit) ||
2462 document._class == class(ModelView)))
2467 document.fileName = filePath;
2468 if(workspace && !workspace.holdTracking)
2469 workspace.UpdateOpenedFileInfo(filePath, opened);
2473 if(!document && createIfFails != no)
2475 if(createIfFails != yes && !needFileModified &&
2476 MessageBox { type = yesNo, master = this, text = filePath, contents = $"File doesn't exist. Create?" }.Modal() == yes)
2477 createIfFails = yes;
2478 if(createIfFails == yes || createIfFails == whatever)
2480 document = (Window)NewCodeEditor(this, state, true);
2482 document.fileName = filePath;
2488 if(projectView && document._class == class(CodeEditor) && workspace)
2490 int lineNumber, position;
2492 CodeEditor editor = (CodeEditor)document;
2493 editor.openedFileInfo = workspace.UpdateOpenedFileInfo(filePath, opened);
2494 editor.openedFileInfo.holdTracking = true;
2495 lineNumber = Max(editor.openedFileInfo.lineNumber - 1, 0);
2496 position = Max(editor.openedFileInfo.position - 1, 0);
2497 editor.editBox.GoToLineNum(lineNumber);
2498 editor.editBox.GoToPosition(editor.editBox.line, lineNumber, position);
2499 scroll.x = Max(editor.openedFileInfo.scroll.x, 0);
2500 scroll.y = Max(editor.openedFileInfo.scroll.y, 0);
2501 editor.editBox.scroll = scroll;
2502 editor.openedFileInfo.holdTracking = false;
2505 if(needFileModified)
2506 document.OnFileModified = OnFileModified;
2507 document.NotifySaved = DocumentSaved;
2510 ideSettings.AddRecentProject(document.fileName);
2512 ideSettings.AddRecentFile(document.fileName);
2513 ide.UpdateRecentMenus();
2514 ide.AdjustFileMenus();
2515 settingsContainer.Save();
2523 // TOCHECK: I can't use a generic one for both ModelView and PictureEdit both derived from Window
2524 /*bool Window::GenericDocumentOnClose(bool parentClosing)
2526 if(!parentClosing && ide.workspace)
2527 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2530 bool ModelView::ModelViewOnClose(bool parentClosing)
2532 if(!parentClosing && ide.workspace)
2533 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2536 bool PictureEdit::PictureEditOnClose(bool parentClosing)
2538 if(!parentClosing && ide.workspace)
2539 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2544 void OnUnloadGraphics(Window window)
2546 display.ClearMaterials();
2547 display.ClearTextures();
2548 display.ClearMeshes();
2552 bool OnActivate(bool active, Window swap, bool * goOnWithActivation, bool direct)
2554 caps.color = app.GetKeyState(capsState) ? black : Color { 128,128,128 };
2555 num.color = app.GetKeyState(numState) ? black : Color { 128,128,128 };
2559 bool OnKeyDown(Key key, unichar ch)
2564 projectView.Update(null);
2567 caps.color = app.GetKeyState(capsState) ? black : Color { 128,128,128 };
2570 num.color = app.GetKeyState(numState) ? black : Color { 128,128,128 };
2576 void GoToError(const char * line, bool noParsing)
2579 projectView.GoToError(line, noParsing);
2582 void CodeLocationParseAndGoTo(const char * text, Project project, const char * dir)
2586 char *colon = strchr(text, ':');
2587 char filePath[MAX_LOCATION] = "";
2588 char completePath[MAX_LOCATION];
2589 int line = 0, col = 0;
2590 int len = strlen(text);
2592 FileAttribs fileAttribs;
2594 // support for valgrind output
2595 if((s = strstr(text, "==")) && (s = strstr(s+2, "==")) && (s = strstr(s+2, ":")) && (s = strstr(s+1, ":")))
2606 /*for(s=colon; *s; s++)
2615 //line = atoi(colon+1);
2617 // support for "Found n match(es) in "file/path";
2618 else if(path[len-1] == '\"' && strstr(path, $"Found %d match%s in \"%s\"%s\n\n"."Found") && strstr(path, $"match") && strstr(path, $"in") && (s = strstr(path, "\"")) && s != path+len-1)
2624 if(colon && (colon[1] == '/' || colon[1] == '\\'))
2626 path = (colon - 1 > path) ? colon - 1 : path;
2627 colon = strstr(colon + 1, ":");
2629 if(*path == '*' && (s = strchr(path+1, '*')))
2631 while(isspace(*path)) path++;
2635 char * close = strchr(path, ')');
2639 strncpy(name, path+1, close - path - 1);
2640 name[close - path - 1] = '\0';
2641 for(p : ide.workspace.projects)
2643 if(!strcmp(p.name, name))
2653 prj = project ? project : (dir ? null : ide.project);
2656 strncpy(filePath, path, colon - path);
2657 filePath[colon - path] = '\0';
2658 line = atoi(colon + 1);
2659 colon = strstr(colon + 1, ":");
2661 col = atoi(colon + 1);
2663 else if(path - 1 >= text && *(path - 1) == '\"')
2665 colon = strchr(path, '\"');
2668 strncpy(filePath, path, colon - path);
2669 filePath[colon - path] = '\0';
2672 else if(path && !colon)
2674 strcpy(filePath, path);
2680 strcpy(completePath, prj.topNode.path);
2681 else if(dir && dir[0])
2682 strcpy(completePath, dir);
2684 completePath[0] = '\0';
2685 PathCat(completePath, filePath);
2687 if((fileAttribs = FileExists(completePath)))
2688 CodeLocationGoTo(completePath, fileAttribs, line, col);
2689 else if(ide.workspace)
2692 for(p : ide.workspace.projects)
2694 strcpy(completePath, p.topNode.path);
2695 PathCat(completePath, filePath);
2696 if((fileAttribs = FileExists(completePath)).isFile)
2698 CodeLocationGoTo(completePath, fileAttribs, line, col);
2705 for(p : ide.workspace.projects)
2707 ProjectNode node = p.topNode.Find(filePath, false);
2710 node.GetFullFilePath(completePath);
2711 if((fileAttribs = FileExists(completePath)).isFile)
2713 CodeLocationGoTo(completePath, fileAttribs, line, col);
2723 void CodeLocationGoTo(const char * path, const FileAttribs fileAttribs, int line, int col)
2725 if(fileAttribs.isFile)
2727 char ext[MAX_EXTENSION];
2728 GetExtension(path, ext);
2729 if(!strcmp(ext, "mp3") || !strcmp(ext, "flac") || !strcmp(ext, "ogg") || !strcmp(ext, "avi") || !strcmp(ext, "mkv"))
2731 else if(!strcmp(ext, "a") || !strcmp(ext, "o") || !strcmp(ext, "lib") || !strcmp(ext, "dll") || !strcmp(ext, "exe"))
2733 char dirPath[MAX_LOCATION];
2734 StripLastDirectory(path, dirPath);
2739 CodeEditor codeEditor = (CodeEditor)OpenFile(path, normal, true, ext, no, normal, false);
2740 if(codeEditor && line)
2742 EditBox editBox = codeEditor.editBox;
2743 editBox.GoToLineNum(line - 1);
2744 editBox.GoToPosition(editBox.line, line - 1, col ? (col - 1) : 0);
2748 else if(fileAttribs.isDirectory)
2752 void OnRedraw(Surface surface)
2754 Bitmap bitmap = back.bitmap;
2756 surface.Blit(bitmap, (clientSize.w - bitmap.width) / 2, (clientSize.h - bitmap.height) / 2, 0, 0, bitmap.width, bitmap.height);
2759 void SheetSelected(SheetType sheetSelected)
2761 if(activeChild == sheet)
2763 if(sheetSelected == methods)
2765 viewPropertiesItem.accelerator = f4;
2766 viewPropertiesItem.parent = viewMenu;
2767 viewMethodsItem.parent = null;
2771 viewMethodsItem.accelerator = f4;
2772 viewMethodsItem.parent = viewMenu;
2773 viewPropertiesItem.parent = null;
2778 viewMethodsItem.parent = viewMenu;
2779 viewPropertiesItem.parent = viewMenu;
2780 if(sheetSelected == methods)
2782 viewMethodsItem.accelerator = f4;
2783 viewPropertiesItem.accelerator = 0;
2787 viewMethodsItem.accelerator = 0;
2788 viewPropertiesItem.accelerator = f4;
2793 void OnActivateClient(Window client, Window previous)
2795 //if(!client || client != previous)
2798 if(!client || client != previous)
2801 dataType = previous._class;
2802 if(previous && !strcmp(dataType.name, "CodeEditor"))
2804 ((CodeEditor)previous).UpdateFormCode();
2806 else if(previous && !strcmp(dataType.name, "Designer"))
2808 ((Designer)previous).codeEditor.UpdateFormCode();
2813 dataType = client._class;
2814 if(client && !strcmp(dataType.name, "CodeEditor"))
2816 CodeEditor codeEditor = (CodeEditor)client;
2817 SetPrivateModule(codeEditor.privateModule);
2818 SetCurrentContext(codeEditor.globalContext);
2819 SetTopContext(codeEditor.globalContext);
2820 SetGlobalContext(codeEditor.globalContext);
2822 SetDefines(&codeEditor.defines);
2823 SetImports(&codeEditor.imports);
2825 SetActiveDesigner(codeEditor.designer);
2827 sheet.codeEditor = codeEditor;
2828 toolBox.codeEditor = codeEditor;
2830 viewDesignerItem.parent = viewMenu;
2831 if(activeChild != codeEditor)
2833 viewCodeItem.parent = viewMenu;
2834 viewDesignerItem.accelerator = 0;
2835 viewCodeItem.accelerator = f8;
2839 viewCodeItem.parent = null;
2840 viewDesignerItem.accelerator = f8;
2843 else if(client && !strcmp(dataType.name, "Designer"))
2845 CodeEditor codeEditor = ((Designer)client).codeEditor;
2848 SetPrivateModule(codeEditor.privateModule);
2849 SetCurrentContext(codeEditor.globalContext);
2850 SetTopContext(codeEditor.globalContext);
2851 SetGlobalContext(codeEditor.globalContext);
2852 SetDefines(&codeEditor.defines);
2853 SetImports(&codeEditor.imports);
2857 SetPrivateModule(null);
2858 SetCurrentContext(null);
2859 SetTopContext(null);
2860 SetGlobalContext(null);
2865 SetActiveDesigner((Designer)client);
2867 sheet.codeEditor = codeEditor;
2868 toolBox.codeEditor = codeEditor;
2870 viewCodeItem.parent = viewMenu;
2871 if(activeChild != client)
2873 viewDesignerItem.parent = viewMenu;
2874 viewDesignerItem.accelerator = f8;
2875 viewCodeItem.accelerator = 0;
2879 viewDesignerItem.parent = null;
2880 viewCodeItem.accelerator = f8;
2886 sheet.codeEditor = null;
2887 toolBox.codeEditor = null;
2888 SetActiveDesigner(null);
2890 viewDesignerItem.parent = null;
2891 viewCodeItem.parent = null;
2894 SheetSelected(sheet.sheetSelected);
2897 projectCompileItem = null;
2902 if(client && client._class == eSystem_FindClass(__thisModule, "CodeEditor")) // !strcmp(client._class.name, "CodeEditor")
2904 CodeEditor codeEditor = (CodeEditor)client;
2905 EditBox editBox = codeEditor.editBox;
2907 statusBar.AddField(pos);
2909 caps = { width = 40, text = $"CAPS", color = app.GetKeyState(capsState) ? black : Color { 128, 128, 128 } };
2910 statusBar.AddField(caps);
2912 ovr = { width = 30, text = $"OVR", color = (editBox && editBox.overwrite) ? black : Color { 128, 128, 128 } };
2913 statusBar.AddField(ovr);
2915 num = { width = 30, text = $"NUM", color = app.GetKeyState(numState) ? black : Color { 128, 128, 128 } };
2916 statusBar.AddField(num);
2918 //statusBar.text = "Ready";
2920 if(projectView && projectView.project)
2922 bool isCObject = false;
2923 ProjectNode node = projectView.GetNodeFromWindow(client, null, false, false);
2924 if(!node && (node = projectView.GetNodeFromWindow(client, null, false, true)))
2928 char nodeName[MAX_FILENAME];
2929 char name[MAX_FILENAME+96];
2931 ChangeExtension(node.name, "c", nodeName);
2932 sprintf(name, $"Compile %s", isCObject ? nodeName : node.name);
2933 projectCompileItem =
2935 copyText = true, text = name, c, ctrlF7, disabled = projectView.buildInProgress;
2937 bool NotifySelect(MenuItem selection, Modifiers mods)
2941 bool result = false;
2942 bool isCObject = false;
2943 ProjectNode node = null;
2944 for(p : ide.workspace.projects)
2946 node = projectView.GetNodeFromWindow(activeClient, p, true, false);
2949 if(!node && (node = projectView.GetNodeFromWindow(activeClient, null, true, true)))
2953 List<ProjectNode> nodes { };
2955 projectView.Compile(node.project, nodes, mods.ctrl && mods.shift, isCObject ? cObject : normal);
2960 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
2965 projectMenu.AddDynamic(projectCompileItem, ide, false);
2971 caps = ovr = num = null;
2976 bool OnClose(bool parentClosing)
2978 //return !projectView.buildInProgress;
2979 if(projectView && projectView.buildInProgress)
2981 if(DontTerminateDebugSession($"Close IDE"))
2983 if(findInFilesDialog)
2984 findInFilesDialog.SearchStop();
2987 workspace.timer.Stop();
2990 ideMainFrame.Destroy(0);
2997 bool passThrough = false;
2998 bool debugStart = false;
2999 bool debugWorkDir = false;
3000 char * passDebugWorkDir = null;
3001 bool openAsText = false;
3002 DynamicString passArgs { };
3005 for(c = 1; c<app.argc; c++)
3009 char * arg = app.argv[c];
3010 char * buf = new char[strlen(arg)*2+1];
3012 passArgs.concat(" ");
3014 passArgs.concat(buf);
3017 else if(debugWorkDir)
3019 passDebugWorkDir = CopyString(app.argv[c]);
3020 StripQuotes(passDebugWorkDir, passDebugWorkDir);
3021 debugWorkDir = false;
3023 else if(!strcmp(app.argv[c], "-t"))
3025 else if(!strcmp(app.argv[c], "-no-parsing"))
3026 ide.noParsing = true;
3027 else if(!strcmp(app.argv[c], "-debug-start"))
3029 else if(!strcmp(app.argv[c], "-debug-work-dir"))
3030 debugWorkDir = true;
3031 else if(!strcmp(app.argv[c], "-@"))
3035 char fullPath[MAX_LOCATION];
3036 char parentPath[MAX_LOCATION];
3037 char ext[MAX_EXTENSION];
3039 FileAttribs dirAttribs;
3040 GetWorkingDir(fullPath, MAX_LOCATION);
3041 PathCat(fullPath, app.argv[c]);
3042 StripLastDirectory(fullPath, parentPath);
3043 GetExtension(app.argv[c], ext);
3044 isProject = !openAsText && !strcmpi(ext, "epj");
3046 if(isProject && c > (debugStart ? 2 : 1)) continue;
3048 // Create directory for projects (only)
3049 if(((dirAttribs = FileExists(parentPath)) && dirAttribs.isDirectory) || isProject)
3051 if(isProject && !FileExists(fullPath))
3053 char name[MAX_LOCATION];
3054 NewProjectDialog newProjectDialog;
3058 projectView.visible = false;
3059 if(!projectView.Destroy(0))
3063 newProjectDialog = { master = this };
3065 strcpy(name, app.argv[c]);
3066 StripExtension(name);
3067 GetLastDirectory(name, name);
3068 newProjectDialog.projectName.contents = name;
3069 newProjectDialog.projectName.NotifyModified(newProjectDialog, newProjectDialog.projectName);
3070 newProjectDialog.locationEditBox.path = parentPath;
3071 newProjectDialog.NotifyModifiedLocation(newProjectDialog.locationEditBox);
3073 incref newProjectDialog;
3074 newProjectDialog.Modal();
3077 ideSettings.AddRecentProject(projectView.fileName);
3078 ide.UpdateRecentMenus();
3079 settingsContainer.Save();
3081 delete newProjectDialog;
3082 // Open only one project
3086 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, openAsText ? "txt" : null, yes, normal, false);
3088 else if(strstr(fullPath, "http://") == fullPath)
3089 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, openAsText ? "txt" : null, yes, normal, false);
3092 if(passThrough && projectView && projectView.project && workspace)
3093 workspace.commandLineArgs = passArgs;
3094 if(passDebugWorkDir && projectView && projectView.project && workspace)
3096 workspace.debugDir = passDebugWorkDir;
3097 delete passDebugWorkDir;
3100 ;//MenuDebugStart(debugStartResumeItem, 0); // <-- how TODO this without getting into the app.Wait lock
3102 UpdateToolBarActiveConfigs(false);
3103 UpdateToolBarActiveCompilers();
3110 // IS THIS NEEDED? WASN'T HERE BEFORE... Crashes on getting node's projectView otherwise
3113 projectView.visible = false;
3114 projectView.Destroy(0);
3117 #ifdef GDB_DEBUG_GUI
3118 gdbDialog.Destroy(0);
3123 void SetPath(bool projectsDirs, CompilerConfig compiler, ProjectConfig config, int bitDepth)
3127 char * oldPaths[128];
3128 String oldList = new char[maxPathLen];
3129 Array<String> newExePaths { };
3130 //Map<String, bool> exePathExists { };
3132 #if defined(__unix__) || defined(__APPLE__)
3133 Array<String> newLibPaths { };
3134 Map<String, bool> libPathExists { };
3139 for(prj : workspace.projects)
3141 DirExpression targetDirExp;
3143 // SKIP FIRST PROJECT...
3144 if(prj == workspace.projects.firstIterator.data) continue;
3146 // NOTE: Right now the additional project config dir will be
3147 // obtained when the debugger is started, so toggling it
3148 // while building will change which library gets used.
3149 // To go with the initial state, e.g. when F5 was pressed,
3150 // we nould need to keep a list of all project's active
3151 // config upon startup.
3152 targetDirExp = prj.GetTargetDir(compiler, prj.config, bitDepth);
3154 /*if(prj.config.targetType == sharedLibrary && prj.config.debug)
3158 for(cfg = prj.configurations.first; cfg; cfg = cfg.next)
3159 if(cfg.targetType == sharedLibrary && cfg.debug && !strcmpi(cfg.name, "Debug"))
3163 for(cfg = prj.configurations.first; cfg; cfg = cfg.next)
3164 if(cfg.targetType == sharedLibrary && cfg.debug)
3168 if(targetDirExp.dir)
3170 char buffer[MAX_LOCATION];
3171 #if defined(__WIN32__)
3172 Array<String> paths = newExePaths;
3174 Array<String> paths = newLibPaths;
3176 GetSystemPathBuffer(buffer, prj.topNode.path);
3177 PathCat(buffer, targetDirExp.dir);
3180 if(!fstrcmp(p, buffer))
3187 paths.Add(CopyString(buffer));
3189 delete targetDirExp;
3193 for(item : compiler.executableDirs)
3196 for(p : newExePaths)
3198 if(!fstrcmp(p, item))
3205 newExePaths.Add(CopySystemPath(item));
3208 GetEnvironment("PATH", oldList, maxPathLen);
3210 printf("Old value of PATH: %s\n", oldList);
3212 count = TokenizeWith(oldList, sizeof(oldPaths) / sizeof(char *), oldPaths, pathListSep, false);
3213 for(c = 0; c < count; c++)
3216 for(p : newExePaths)
3218 if(!fstrcmp(p, oldPaths[c]))
3225 newExePaths.Add(CopySystemPath(oldPaths[c]));
3229 for(path : newExePaths)
3230 len += strlen(path) + 1;
3231 newList = new char[len + 1];
3233 for(path : newExePaths)
3235 strcat(newList, path);
3236 strcat(newList, pathListSep);
3238 newList[len - 1] = '\0';
3239 SetEnvironment("PATH", newList);
3241 printf("New value of PATH: %s\n", newList);
3248 #if defined(__unix__) || defined(__APPLE__)
3250 for(item : compiler.libraryDirs)
3252 if(!libPathExists[item]) // fstrcmp should be used
3254 String s = CopyString(item);
3256 libPathExists[s] = true;
3260 #if defined(__APPLE__)
3261 GetEnvironment("DYLD_LIBRARY_PATH", oldList, maxPathLen);
3263 GetEnvironment("LD_LIBRARY_PATH", oldList, maxPathLen);
3266 printf("Old value of [DY]LD_LIBRARY_PATH: %s\n", oldList);
3268 count = TokenizeWith(oldList, sizeof(oldPaths) / sizeof(char *), oldPaths, pathListSep, false);
3269 for(c = 0; c < count; c++)
3271 if(!libPathExists[oldPaths[c]]) // fstrcmp should be used
3273 String s = CopyString(oldPaths[c]);
3275 libPathExists[s] = true;
3280 for(path : newLibPaths)
3281 len += strlen(path) + 1;
3282 newList = new char[len + 1];
3284 for(path : newLibPaths)
3286 strcat(newList, path);
3287 strcat(newList, pathListSep);
3289 newList[len - 1] = '\0';
3290 #if defined(__APPLE__)
3291 SetEnvironment("DYLD_LIBRARY_PATH", newList);
3293 SetEnvironment("LD_LIBRARY_PATH", newList);
3296 printf("New value of [DY]LD_LIBRARY_PATH: %s\n", newList);
3302 delete libPathExists;
3305 if(compiler.distccEnabled && compiler.distccHosts)
3306 SetEnvironment("DISTCC_HOSTS", compiler.distccHosts);
3311 void DestroyTemporaryProjectDir()
3313 if(tmpPrjDir && tmpPrjDir[0])
3315 if(FileExists(tmpPrjDir).isDirectory)
3316 DestroyDir(tmpPrjDir);
3317 property::tmpPrjDir = null;
3323 // Graphics Driver Menu
3327 app.currentSkin.selectionColor = selectionColor;
3328 app.currentSkin.selectionText = selectionText;
3332 driverItems = new MenuItem[app.numDrivers];
3333 for(c = 0; c < app.numDrivers; c++)
3335 driverItems[c] = MenuItem { driversMenu, app.drivers[c], NotifySelect = NotifySelectDisplayDriver };
3336 driverItems[c].id = c;
3337 driverItems[c].isRadio = true;
3340 driverItems = new MenuItem[2];
3341 #if defined(__unix__)
3342 driverItems[0] = MenuItem { driversMenu, "X", NotifySelect = NotifySelectDisplayDriver };
3343 driverItems[0].id = 0;
3344 driverItems[0].isRadio = true;
3346 driverItems[0] = MenuItem { driversMenu, "GDI", NotifySelect = NotifySelectDisplayDriver };
3347 driverItems[0].id = 0;
3348 driverItems[0].isRadio = true;
3350 driverItems[1] = MenuItem { driversMenu, "OpenGL", NotifySelect = NotifySelectDisplayDriver };
3351 driverItems[1].id = 1;
3352 driverItems[1].isRadio = true;
3354 /* skinItems = new MenuItem[app.numSkins];
3355 for(c = 0; c < app.numSkins; c++)
3357 skinItems[c] = MenuItem {skinsMenu, app.skins[c], NotifySelect = NotifySelectDisplaySkin };
3358 skinItems[c].id = c;
3359 skinItems[c].isRadio = true;
3362 ideFileDialog.master = this;
3363 ideProjectFileDialog.master = this;
3365 //SetDriverAndSkin();
3369 void UpdateRecentMenus()
3372 Menu fileMenu = menu.FindMenu($"File");
3373 Menu recentFiles = fileMenu.FindMenu($"Recent Files");
3374 Menu recentProjects = fileMenu.FindMenu($"Recent Projects");
3375 char * itemPath = new char[MAX_LOCATION];
3376 char * itemName = new char[MAX_LOCATION+4];
3379 recentFiles.Clear();
3382 for(recent : ideSettings.recentFiles)
3384 strncpy(itemPath, recent, MAX_LOCATION); itemPath[MAX_LOCATION-1] = '\0';
3385 MakeSystemPath(itemPath);
3386 snprintf(itemName, MAX_LOCATION+4, "%d %s", 1 + c, itemPath); itemName[MAX_LOCATION+4-1] = '\0';
3387 recentFiles.AddDynamic(MenuItem { copyText = true, text = itemName, (Key)k1 + c, id = c, NotifySelect = ide.FileRecentFile }, ide, true);
3391 recentProjects.Clear();
3393 for(recent : ideSettings.recentProjects)
3395 strncpy(itemPath, recent, MAX_LOCATION); itemPath[MAX_LOCATION-1] = '\0';
3396 MakeSystemPath(itemPath);
3397 snprintf(itemName, MAX_LOCATION+4, "%d %s", 1 + c, itemPath); itemName[MAX_LOCATION+4-1] = '\0';
3398 recentProjects.AddDynamic(MenuItem { copyText = true, text = itemName, (Key)k1 + c, id = c, NotifySelect = ide.FileRecentProject }, ide, true);
3413 documentor.Puts("Quit\n");
3420 void DestroyDir(char * path)
3422 RecursiveDeleteFolderFSI fsi { };
3427 #if defined(__WIN32__)
3428 define sdkDirName = "Ecere SDK";
3430 define sdkDirName = "ecere";
3433 void FindAndShellOpenInstalledFolder(char * name)
3435 char * p = new char[MAX_LOCATION];
3436 char * v = new char[maxPathLen];
3439 Array<String> paths { };
3441 strncpy(p, settingsContainer.moduleLocation, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3442 StripLastDirectory(p, p);
3444 paths.Add(CopyString(p));
3445 #if defined(__WIN32__)
3446 GetEnvironment("ECERE_SDK_SRC", v, maxPathLen);
3449 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3450 PathCat(p, name); paths.Add(CopyString(p));
3452 GetEnvironment("AppData", v, maxPathLen);
3455 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3456 PathCat(p, sdkDirName); PathCat(p, name); paths.Add(CopyString(p));
3458 GetEnvironment("ProgramFiles", v, maxPathLen);
3461 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3462 PathCat(p, sdkDirName); PathCat(p, name); paths.Add(CopyString(p));
3464 GetEnvironment("ProgramFiles(x86)", v, maxPathLen);
3467 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3468 PathCat(p, sdkDirName); PathCat(p, name); paths.Add(CopyString(p));
3470 GetEnvironment("SystemDrive", v, maxPathLen);
3473 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3474 PathCat(p, "Program Files"); PathCat(p, sdkDirName); PathCat(p, name); paths.Add(CopyString(p));
3477 GetEnvironment("XDG_DATA_DIRS", v, maxPathLen);
3478 numTokens = TokenizeWith(v, sizeof(tokens) / sizeof(byte *), tokens, ":", false);
3479 for(c=0; c<numTokens; c++)
3481 strncpy(p, tokens[c], MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3482 PathCat(p, sdkDirName); PathCat(p, name); paths.Add(CopyString(p));
3487 strncpy(p, path, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3488 if(FileExists(p).isDirectory)
3500 void FindAndShellOpenInstalledFile(char * subdir, char * name)
3502 char * p = new char[MAX_LOCATION];
3503 char * v = new char[maxPathLen];
3506 Array<String> paths { };
3508 strncpy(p, settingsContainer.moduleLocation, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3509 paths.Add(CopyString(p));
3510 StripLastDirectory(p, p);
3512 paths.Add(CopyString(p));
3513 #if defined(__WIN32__)
3514 GetEnvironment("ECERE_SDK_SRC", v, maxPathLen);
3517 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3518 PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3520 GetEnvironment("AppData", v, maxPathLen);
3523 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3524 PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3526 GetEnvironment("ProgramFiles", v, maxPathLen);
3529 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3530 PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3532 GetEnvironment("ProgramFiles(x86)", v, maxPathLen);
3535 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3536 PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3538 GetEnvironment("SystemDrive", v, maxPathLen);
3541 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3542 PathCat(p, "Program Files"); PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3545 GetEnvironment("XDG_DATA_DIRS", v, maxPathLen);
3546 numTokens = TokenizeWith(v, sizeof(tokens) / sizeof(byte *), tokens, ":", false);
3547 for(c=0; c<numTokens; c++)
3549 strncpy(p, tokens[c], MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3550 PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3555 strncpy(p, path, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3557 if(FileExists(p).isFile)
3569 class RecursiveDeleteFolderFSI : NormalFileSystemIterator
3571 bool preserveRootFolder;
3573 void OutFolder(char * folderPath, bool isRoot)
3575 if(!(preserveRootFolder && isRoot))
3576 RemoveDir(folderPath);
3579 bool OnFile(char * filePath)
3581 DeleteFile(filePath);
3586 class IDEApp : GuiApplication
3588 //driver = "Win32Console";
3589 // driver = "OpenGL";
3593 TempFile includeFile { };
3597 char ext[MAX_EXTENSION];
3598 SetLoggingMode(stdOut, null);
3599 //SetLoggingMode(debug, null);
3601 settingsContainer.Load();
3602 if(argc > 1 && !strcmpi(GetExtension(argv[1], ext), "3ds"))
3604 app.driver = "OpenGL";
3605 ide.driverItems[1].checked = true;
3609 #if defined(__unix__) || defined(__APPLE__)
3610 app.driver = (ideSettings.displayDriver && !strcmp(ideSettings.displayDriver, "OpenGL")) ? ideSettings.displayDriver : "X";
3612 app.driver = (ideSettings.displayDriver && !strcmp(ideSettings.displayDriver, "OpenGL")) ? ideSettings.displayDriver : "GDI";
3614 ide.driverItems[ideSettings.displayDriver && !strcmp(ideSettings.displayDriver,"OpenGL")].checked = true;
3619 desktop.text = titleECEREIDE;
3622 for(c = 1; c<app.argc; c++)
3624 char fullPath[MAX_LOCATION];
3625 GetWorkingDir(fullPath, MAX_LOCATION);
3626 PathCat(fullPath, app.argv[c]);
3627 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, null, yes, normal, false);
3631 if(!LoadIncludeFile())
3632 PrintLn("error: unable to load :crossplatform.mk file inside ide binary.");
3637 bool Cycle(bool idle)
3641 if(ide.documentor.Peek())
3644 ide.documentor.GetLine(line, sizeof(line));
3645 if(!strcmpi(line, "Exited"))
3647 ide.documentor.CloseInput();
3648 ide.documentor.CloseOutput();
3649 ide.documentor.Wait();
3650 delete ide.documentor;
3653 if(ide.documentor && ide.documentor.eof)
3655 ide.documentor.CloseInput();
3656 ide.documentor.CloseOutput();
3657 ide.documentor.Wait();
3658 delete ide.documentor;
3664 bool LoadIncludeFile()
3666 bool result = false;
3667 File include = FileOpen(":crossplatform.mk", read);
3670 File f = includeFile;
3673 for(; !include.Eof(); )
3676 int count = include.Read(buffer, 1, 4096);
3677 f.Write(buffer, 1, count);
3687 IDEMainFrame ideMainFrame { };
3689 define app = ((IDEApp)__thisModule);
3691 define titleECEREIDE = $"ECERE IDE (Debug)";
3693 define titleECEREIDE = $"ECERE IDE";