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 bool NotifySelect(MenuItem selection, Modifiers mods)
1200 if(projectView) projectView.DebugStepOver(true);
1204 MenuItem debugStepOutItem
1206 debugMenu, $"Step Out", o, shiftF11, disabled = true;
1207 bitmap = { ":actions/stepOut.png" };
1208 bool NotifySelect(MenuItem selection, Modifiers mods)
1210 if(projectView) projectView.DebugStepOut(false);
1214 MenuItem debugSkipStepOutItem
1216 debugMenu, $"Step Out Skipping Breakpoints", n, Key { f11, ctrl = true, shift = true }, disabled = true;
1217 bitmap = { ":actions/skipBreaks.png" };
1218 bool NotifySelect(MenuItem selection, Modifiers mods)
1220 if(projectView) projectView.DebugStepOut(true);
1225 MenuItem debugStepUntilItem
1227 debugMenu, $"Step Over Until Next Line", x, disabled = true;
1228 bool NotifySelect(MenuItem selection, Modifiers mods)
1230 if(projectView) projectView.DebugStepUntil(false);
1234 MenuItem debugSkipStepUntilItem
1236 debugMenu, $"Step Over Until Next Line Skipping Breakpoints", e, Key { f10, shift = true, alt = true }, disabled = true;
1237 bool NotifySelect(MenuItem selection, Modifiers mods)
1239 if(projectView) projectView.DebugStepUntil(true);
1244 MenuPlacement debugRunToCursorItem { debugMenu, $"Run To Cursor", c };
1245 MenuPlacement debugSkipRunToCursorItem { debugMenu, $"Run To Cursor Skipping Breakpoints", u };
1246 MenuPlacement debugRunToCursorAtSameLevelItem { debugMenu, $"Run To Cursor At Same Level", l };
1247 MenuPlacement debugSkipRunToCursorAtSameLevelItem { debugMenu, $"Run To Cursor At Same Level Skipping Breakpoints", g };
1249 MenuPlacement debugBpRunToCursorItem { debugMenu, $"BP Run To Cursor" };
1250 MenuPlacement debugBpSkipRunToCursorItem { debugMenu, $"BP Run To Cursor Skipping Breakpoints" };
1251 MenuPlacement debugBpRunToCursorAtSameLevelItem { debugMenu, $"BP Run To Cursor At Same Level" };
1252 MenuPlacement debugBpSkipRunToCursorAtSameLevelItem { debugMenu, $"BP Run To Cursor At Same Level Skipping Breakpoints" };
1254 //MenuDivider { debugMenu };
1255 //MenuPlacement debugToggleBreakpoint { debugMenu, "Toggle Breakpoint", t };
1256 MenuPlacement imageMenu { menu, $"Image", i };
1257 Menu viewMenu { menu, $"View", v };
1258 MenuItem viewProjectItem
1260 viewMenu, $"Project View", j, alt0, disabled = true;
1261 bool NotifySelect(MenuItem selection, Modifiers mods)
1265 projectView.visible = true;
1266 projectView.Activate();
1271 MenuPlacement { viewMenu, $"View Designer" };
1272 MenuPlacement { viewMenu, $"View Code" };
1273 MenuPlacement { viewMenu, $"View Properties" };
1274 MenuPlacement { viewMenu, $"View Methods" };
1275 MenuItem viewDesignerItem
1277 viewMenu, $"View Designer", d, f8;
1278 bool NotifySelect(MenuItem selection, Modifiers mods)
1280 Window client = activeClient;
1281 Class dataType = client._class;
1282 if(!strcmp(dataType.name, "Designer"))
1284 client.visible = true;
1288 ((CodeEditor)client).ViewDesigner();
1292 MenuItem viewCodeItem
1294 viewMenu, $"View Code", c, f8;
1295 bool NotifySelect(MenuItem selection, Modifiers mods)
1297 Window client = activeClient;
1298 Class dataType = client._class;
1299 if(!strcmp(dataType.name, "Designer"))
1300 client = ((Designer)client).codeEditor;
1303 // Do this after so the caret isn't moved yet...
1304 client.visible = true;
1308 MenuItem viewPropertiesItem
1310 viewMenu, $"View Properties", p, f4;
1311 bool NotifySelect(MenuItem selection, Modifiers mods)
1313 sheet.visible = true;
1314 sheet.sheetSelected = properties;
1319 MenuItem viewMethodsItem
1321 viewMenu, $"View Methods", m, f4;
1322 bool NotifySelect(MenuItem selection, Modifiers mods)
1324 sheet.visible = true;
1325 sheet.sheetSelected = methods;
1330 MenuItem viewToolBoxItem
1332 viewMenu, $"View Toolbox", x, f12;
1333 bool NotifySelect(MenuItem selection, Modifiers mods)
1335 toolBox.visible = true;
1340 MenuItem viewOutputItem
1342 viewMenu, $"Output", o, alt2;
1343 bool NotifySelect(MenuItem selection, Modifiers mods)
1349 MenuItem viewWatchesItem
1351 viewMenu, $"Watches", w, alt3;
1352 bool NotifySelect(MenuItem selection, Modifiers mods)
1358 MenuItem viewThreadsItem
1360 viewMenu, $"Threads", t, alt4;
1361 bool NotifySelect(MenuItem selection, Modifiers mods)
1367 MenuItem viewBreakpointsItem
1369 viewMenu, $"Breakpoints", b, alt5;
1370 bool NotifySelect(MenuItem selection, Modifiers mods)
1372 breakpointsView.Show();
1376 MenuItem viewCallStackItem
1378 viewMenu, $"Call Stack", s, alt7;
1379 bool NotifySelect(MenuItem selection, Modifiers mods)
1381 callStackView.Show();
1385 MenuItem viewAllDebugViews
1387 viewMenu, $"All Debug Views", a, alt9;
1388 bool NotifySelect(MenuItem selection, Modifiers mods)
1393 callStackView.Show();
1394 breakpointsView.Show();
1398 #ifdef GDB_DEBUG_GUI
1399 MenuDivider { viewMenu };
1400 MenuItem viewGDBItem
1402 viewMenu, $"GDB Dialog", g, Key { f9, shift = true, ctrl = true };
1403 bool NotifySelect(MenuItem selection, Modifiers mods)
1410 MenuDivider { viewMenu };
1411 MenuItem viewColorPicker
1413 viewMenu, $"Color Picker...", l, Key { c, ctrl = true , shift = true };
1414 bool NotifySelect(MenuItem selection, Modifiers mods)
1416 ColorPicker colorPicker { master = this };
1417 colorPicker.Modal();
1421 MenuDivider { viewMenu };
1425 viewMenu, "Full Screen", f, checkable = true;
1427 bool NotifySelect(MenuItem selection, Modifiers mods)
1429 app.fullScreen ^= true;
1431 anchor = { 0, 0, 0, 0 };
1436 Menu driversMenu { viewMenu, $"Graphics Driver", v };
1437 //Menu skinsMenu { viewMenu, "GUI Skins", k };
1438 Menu windowMenu { menu, $"Window", w };
1439 MenuItem { windowMenu, $"Close All", l, NotifySelect = MenuWindowCloseAll };
1440 MenuDivider { windowMenu };
1441 MenuItem { windowMenu, $"Next", n, f6, NotifySelect = MenuWindowNext };
1442 MenuItem { windowMenu, $"Previous", p, shiftF6, NotifySelect = MenuWindowPrevious };
1443 MenuDivider { windowMenu };
1444 MenuItem { windowMenu, $"Cascade", c, NotifySelect = MenuWindowCascade };
1445 MenuItem { windowMenu, $"Tile Horizontally", h, NotifySelect = MenuWindowTileHorz };
1446 MenuItem { windowMenu, $"Tile Vertically", v, NotifySelect = MenuWindowTileVert };
1447 MenuItem { windowMenu, $"Arrange Icons", a, NotifySelect = MenuWindowArrangeIcons };
1448 MenuDivider { windowMenu };
1449 MenuItem { windowMenu, $"Windows...", w, NotifySelect = MenuWindowWindows };
1450 Menu helpMenu { menu, $"Help", h };
1453 helpMenu, $"API Reference", r, f1;
1454 bool NotifySelect(MenuItem selection, Modifiers mods)
1458 char * p = new char[MAX_LOCATION];
1460 strncpy(p, settingsContainer.moduleLocation, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
1461 PathCat(p, "documentor");
1462 #if defined(__WIN32__)
1463 ChangeExtension(p, "exe", p);
1465 if(!FileExists(p).isFile)
1466 strcpy(p, "documentor");
1468 documentor = DualPipeOpen({ input = true, output = true, showWindow = true }, p);
1473 Process_ShowWindows(documentor.GetProcessID());
1474 // documentor.Puts("Activate\n");
1479 MenuDivider { helpMenu };
1482 helpMenu, $"Ecere Tao of Programming [work in progress]", t;
1483 bool NotifySelect(MenuItem selection, Modifiers mods)
1485 FindAndShellOpenInstalledFile("doc", "Ecere Tao of Programming [work in progress].pdf");
1489 MenuDivider { helpMenu };
1492 helpMenu, $"Documentation Folder", d;
1493 bool NotifySelect(MenuItem selection, Modifiers mods)
1495 FindAndShellOpenInstalledFolder("doc");
1501 helpMenu, $"Samples Folder", s;
1502 bool NotifySelect(MenuItem selection, Modifiers mods)
1504 FindAndShellOpenInstalledFolder("samples");
1510 helpMenu, $"Extras Folder", x;
1511 bool NotifySelect(MenuItem selection, Modifiers mods)
1513 FindAndShellOpenInstalledFolder("extras");
1517 MenuDivider { helpMenu };
1520 helpMenu, $"Community Forums", f;
1521 bool NotifySelect(MenuItem selection, Modifiers mods)
1523 ShellOpen("http://ecere.com/forums");
1527 MenuDivider { helpMenu };
1530 helpMenu, $"About...", a;
1531 bool NotifySelect(MenuItem selection, Modifiers mods)
1533 AboutIDE { master = this }.Modal();
1538 property ToolBox toolBox
1540 get { return toolBox; }
1543 property Sheet sheet
1545 get { return sheet; }
1548 property Project project
1550 get { return projectView ? projectView.project : null; }
1553 property Workspace workspace
1555 get { return projectView ? projectView.workspace : null; }
1558 FindInFilesDialog findInFilesDialog
1561 filters = findInFilesFileFilters.array, sizeFilters = findInFilesFileFilters.count * sizeof(FileFilter);
1567 #ifdef GDB_DEBUG_GUI
1570 master = this, parent = this;
1571 //anchor = { left = 100, top = 100, right = 100, bottom = 100 };
1573 void OnCommand(char * string)
1576 ide.debugger.SendGDBCommand(string);
1581 bool NotifySelectDisplayDriver(MenuItem selection, Modifiers mods)
1583 //app.driver = app.drivers[selection.id];
1584 #if defined(__unix__) || defined(__APPLE__)
1585 app.driver = selection.id ? "OpenGL" : "X";
1587 app.driver = selection.id ? "OpenGL" : "GDI";
1589 delete ideSettings.displayDriver;
1590 ideSettings.displayDriver = CopyString(selection.id ? "OpenGL" : "Default");
1592 settingsContainer.Save();
1593 //SetDriverAndSkin();
1597 bool NotifySelectDisplaySkin(MenuItem selection, Modifiers mods)
1599 app.skin = app.skins[selection.id];
1604 void SetDriverAndSkin()
1607 for(c = 0; c < app.numSkins; c++)
1608 if(!strcmp(app.skins[c], app.skin))
1610 skinItems[c].checked = true;
1613 for(c = 0; c < app.numDrivers; c++)
1614 if(!strcmp(app.drivers[c], app.driver))
1616 driverItems[c].checked = true;
1621 ProjectView CreateProjectView(Workspace workspace, char * fileName)
1623 Project project = workspace.projects.firstIterator.data;
1624 projectView = ProjectView
1627 fileName = fileName;
1629 void NotifyDestroyed(Window window, DialogResult result)
1632 text = titleECEREIDE;
1637 projectView.Create();
1638 RepositionWindows(false);
1640 // Leave it after Create to avoid flicker due to seeing IDE without a project view
1641 projectView.workspace = workspace;
1642 projectView.project = project;
1643 ideMainFrame.SetText("%s - %s", project.topNode.name, titleECEREIDE);
1647 ide.breakpointsView.LoadFromWorkspace();
1648 ide.watchesView.LoadFromWorkspace();
1650 findInFilesDialog.projectNodeField.userData = projectView;
1653 char fileName[MAX_LOCATION];
1654 strcpy(fileName, project.topNode.path);
1655 PathCat(fileName, project.topNode.name);
1662 projectView.visible = false;
1663 if((!projectView || projectView.created == false || projectView.Destroy(0)) && MenuWindowCloseAll(null, 0))
1665 if(findInFilesDialog)
1667 char workingDir[MAX_LOCATION];
1668 GetWorkingDir(workingDir, MAX_LOCATION);
1669 findInFilesDialog.SearchStop();
1670 findInFilesDialog.currentDirectory = workingDir;
1672 ideMainFrame.text = titleECEREIDE;
1679 void RepositionWindows(bool expand)
1684 bool inDebugMode = debugger.isActive;
1685 bool callStackVisible = expand ? false : callStackView.visible;
1686 bool threadsVisible = expand ? false : threadsView.visible;
1687 bool watchesVisible = expand ? false : watchesView.visible;
1688 bool breakpointsVisible = expand ? false : breakpointsView.visible;
1689 bool toolBoxVisible = toolBox.visible;
1690 bool outputVisible = expand ? false : outputView.visible;
1691 int topDistance = (callStackVisible || threadsVisible) ? 200 : 0;
1692 int bottomDistance = (outputVisible || watchesVisible || breakpointsVisible) ? 240 : 0;
1694 for(child = firstChild; child; child = child.next)
1696 if(child._class == class(CodeEditor) || child._class == class(Designer) ||
1697 child._class == class(Sheet) || child._class == class(ProjectView))
1699 Anchor anchor = child.anchor;
1700 anchor.top = topDistance;
1701 anchor.bottom = bottomDistance;
1702 if(child._class == class(CodeEditor) || child._class == class(Designer))
1705 anchor.right = toolBoxVisible ? 150 : 0;
1707 child.anchor = anchor;
1711 if(child._class == class(OutputView) || child._class == class(CallStackView) || child._class == class(ThreadsView) || child._class == class(WatchesView) ||
1712 child._class == class(BreakpointsView))
1713 child.visible = false;
1716 // If this is not here, the IDE is not updated when doing Debug/Break then Alt-4 to show call stack (IDE not updated)
1721 bool ShowCodeEditor()
1724 activeClient.Activate();
1725 else if(projectView)
1727 projectView.visible = true;
1728 projectView.Activate();
1732 sheet.visible = true;
1738 void DocumentSaved(Window document, char * fileName)
1740 ideSettings.AddRecentFile(fileName);
1741 ide.UpdateRecentMenus();
1742 ide.AdjustFileMenus();
1743 settingsContainer.Save();
1746 bool Window::OnFileModified(FileChange fileChange, char * param)
1749 sprintf(temp, $"The document %s was modified by another application.\n"
1750 "Would you like to reload it and lose your changes?", this.fileName);
1751 if(MessageBox { type = yesNo, master = this/*.parent*/,
1752 text = $"Document has been modified", contents = temp }.Modal() == yes)
1754 bool noParsing = (this._class == class(CodeEditor) && ((CodeEditor)this).noParsing) ? true : false;
1755 char * fileName = CopyString(this.fileName);
1756 WindowState state = this.state;
1757 Anchor anchor = this.anchor;
1758 Size size = this.size;
1760 this.modifiedDocument = false;
1762 this = ide.OpenFile(fileName, normal, true, null, no, normal, noParsing);
1765 this.anchor = anchor;
1767 this.SetState(state, true, 0);
1775 void UpdateMakefiles()
1779 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
1780 for(prj : workspace.projects)
1781 projectView.ProjectUpdateMakefileForAllConfigs(prj);
1786 void UpdateCompilerConfigs(bool mute)
1788 UpdateToolBarActiveCompilers();
1791 bool silent = mute || (ide.projectView.buildInProgress == none ? false : true);
1792 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
1795 projectView.ShowOutputBuildLog(true);
1796 projectView.DisplayCompiler(compiler, false);
1798 for(prj : workspace.projects)
1799 projectView.ProjectPrepareCompiler(prj, compiler, silent);
1804 void UpdateToolBarActiveCompilers()
1806 toolBar.activeCompiler.Clear();
1807 for(compiler : ideSettings.compilerConfigs)
1809 DataRow row = toolBar.activeCompiler.AddString(compiler.name);
1810 if(workspace && workspace.compiler && !strcmp(compiler.name, workspace.compiler))
1811 toolBar.activeCompiler.currentRow = row;
1813 if(!toolBar.activeCompiler.currentRow && toolBar.activeCompiler.firstRow)
1814 toolBar.activeCompiler.SelectRow(toolBar.activeCompiler.firstRow);
1817 void UpdateToolBarActiveConfigs(bool selectionOnly)
1819 bool commonSelected = false;
1820 DataRow row = toolBar.activeConfig.currentRow;
1822 row = toolBar.activeConfig.FindRow(1);
1825 toolBar.activeConfig.Clear();
1826 row = toolBar.activeConfig.AddString($"(Mixed)");
1831 char * configName = null;
1834 Map<String, int> configs { }; // TOIMP: just need sort but using map until containers have sort
1835 for(prj : workspace.projects)
1837 for(cfg : prj.configurations)
1840 configs[cfg.name] = 1;
1845 toolBar.activeConfig.AddString(&name);
1849 if(projectView && projectView.project)
1851 for(prj : workspace.projects)
1853 if(prj.config && prj.config.name)
1855 configName = prj.config.name;
1861 commonSelected = true;
1862 for(prj : workspace.projects)
1864 if(prj.config && (!prj.config.name || strcmp(prj.config.name, configName)))
1866 commonSelected = false;
1874 commonSelected = false;
1875 for(row = toolBar.activeConfig.firstRow; row; row = row.next)
1877 if(!strcmp(row.string, configName))
1879 toolBar.activeConfig.currentRow = row;
1880 commonSelected = true;
1887 toolBar.activeConfig.Sort(null, 0);
1889 toolBar.activeConfig.currentRow = row;
1894 bool unavailable = !project;
1896 projectAddItem.disabled = unavailable;
1897 toolBar.buttonAddProject.disabled = unavailable;
1899 projectSettingsItem.disabled = unavailable;
1901 projectBrowseFolderItem.disabled = unavailable;
1903 viewProjectItem.disabled = unavailable;
1905 toolBar.activeConfig.disabled = unavailable;
1906 toolBar.activeCompiler.disabled = unavailable;
1907 toolBar.activeBitDepth.disabled = unavailable;
1910 debugUseValgrindItem.disabled = unavailable;
1911 AdjustValgrindMenus();
1920 void AdjustValgrindMenus()
1922 bool unavailable = !project || !debugUseValgrindItem.checked;
1923 debugValgrindNoLeakCheckItem.disabled = unavailable;
1924 debugValgrindSummaryLeakCheckItem.disabled = unavailable;
1925 debugValgrindYesLeakCheckItem.disabled = unavailable;
1926 debugValgrindFullLeakCheckItem.disabled = unavailable;
1928 debugValgrindTrackOriginsItem.disabled = unavailable;
1930 debugValgrindRSDefaultItem.disabled = unavailable;
1931 debugValgrindRS0Item.disabled = unavailable;
1932 debugValgrindRS16Item.disabled = unavailable;
1933 debugValgrindRS32Item.disabled = unavailable;
1934 debugValgrindRS64Item.disabled = unavailable;
1935 debugValgrindRS128Item.disabled = unavailable;
1936 debugValgrindRS256Item.disabled = unavailable;
1937 debugValgrindRS512Item.disabled = unavailable;
1941 property bool hasOpenedCodeEditors
1946 for(w = firstChild; w; w = w.next)
1947 if(w._class == class(CodeEditor) &&
1948 w.isDocument && !w.closing && w.visible && w.created &&
1949 w.fileName && w.fileName[0])
1955 void AdjustFileMenus()
1957 bool unavailable = project != null || !hasOpenedCodeEditors; // are they supported source code (ec, c, cpp, etc) ?
1959 projectQuickItem.disabled = unavailable;
1962 void AdjustBuildMenus()
1964 bool unavailable = project && projectView.buildInProgress;
1965 bool naForRun = unavailable || !project || project.GetTargetType(project.config) != executable;
1967 projectNewItem.disabled = unavailable;
1968 toolBar.buttonNewProject.disabled = unavailable;
1969 projectOpenItem.disabled = unavailable;
1970 toolBar.buttonOpenProject.disabled = unavailable;
1972 unavailable = !project || projectView.buildInProgress;
1974 projectCloseItem.disabled = unavailable;
1975 // toolBar.buttonCloseProject.disabled = unavailable;
1977 projectRunItem.disabled = naForRun;
1978 toolBar.buttonRun.disabled = naForRun;
1980 projectBuildItem.disabled = false;
1981 projectBuildItem.text = unavailable ? $"Stop Build" : $"Build";
1982 projectBuildItem.accelerator = unavailable ? Key { pauseBreak, ctrl = true } : f7;
1984 projectLinkItem.disabled = unavailable;
1985 toolBar.buttonReLink.disabled = unavailable;
1986 projectRebuildItem.disabled = unavailable;
1987 toolBar.buttonRebuild.disabled = unavailable;
1988 projectCleanItem.disabled = unavailable;
1989 toolBar.buttonClean.disabled = unavailable;
1990 projectCleanTargetItem.disabled = unavailable;
1991 projectRealCleanItem.disabled = unavailable;
1992 // toolBar.buttonRealClean.disabled = unavailable;
1993 projectRegenerateItem.disabled = unavailable;
1994 toolBar.buttonRegenerateMakefile.disabled = unavailable;
1995 #ifdef IDE_SHOW_INSTALL_MENU_BUTTON
1996 projectInstallItem.disabled = unavailable;
1997 toolBar.buttonInstall.disabled = unavailable;
1999 projectCompileItem.disabled = unavailable;
2001 AdjustPopupBuildMenus();
2004 void AdjustPopupBuildMenus()
2006 bool unavailable = !project || projectView.buildInProgress;
2008 if(projectView && projectView.popupMenu && projectView.popupMenu.menu && projectView.popupMenu.created)
2011 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectBuild, 0);
2014 menu.disabled = false;
2015 menu.text = unavailable ? $"Stop Build" : $"Build";
2016 menu.accelerator = unavailable ? Key { pauseBreak, ctrl = true } : f7;
2019 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectLink, 0); if(menu) menu.disabled = unavailable;
2020 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRebuild, 0); if(menu) menu.disabled = unavailable;
2021 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectCleanTarget, 0); if(menu) menu.disabled = unavailable;
2022 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectClean, 0); if(menu) menu.disabled = unavailable;
2023 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRealClean, 0); if(menu) menu.disabled = unavailable;
2024 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRegenerate, 0); if(menu) menu.disabled = unavailable;
2025 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectInstall, 0); if(menu) menu.disabled = unavailable;
2026 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRemove, 0); if(menu) menu.disabled = unavailable;
2027 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileClean, 0); if(menu) menu.disabled = unavailable;
2028 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileCompile, 0); if(menu) menu.disabled = unavailable;
2029 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugPrecompile, 0); if(menu) menu.disabled = unavailable;
2030 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugCompile, 0); if(menu) menu.disabled = unavailable;
2031 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugGenerateSymbols, 0); if(menu) menu.disabled = unavailable;
2032 projectView.popupMenu.Update(null);
2036 property bool areDebugMenusUnavailable { get {
2038 project.GetTargetType(project.config) != executable ||
2039 projectView.buildInProgress == buildingMainProject;
2042 property bool isBreakpointTogglingUnavailable { get { return !project; } }
2043 property bool isDebuggerRunning { get { if(ide.debugger) return ide.debugger.state == running; return false; } }
2044 property bool isDebuggerStopped { get { if(ide.debugger) return ide.debugger.state == stopped; return false; } }
2046 void AdjustDebugMenus()
2048 bool unavailable = areDebugMenusUnavailable;
2049 bool running = isDebuggerRunning;
2050 bool stopped = isDebuggerStopped;
2051 bool active = debugger.isActive;
2052 bool noBreakpointToggle = !project;
2054 bool isNotRunning = unavailable || !running;
2055 bool isNotNotRunning = unavailable || running;
2056 bool isNotStopped = unavailable || !stopped;
2057 bool isNotActive = unavailable || !active;
2059 debugStartResumeItem.disabled = isNotNotRunning;
2060 debugStartResumeItem.text = active ? $"Resume" : $"Start";
2061 debugStartResumeItem.NotifySelect = active ? MenuDebugResume : MenuDebugStart;
2064 toolBar.buttonDebugStartResume.disabled = isNotNotRunning;
2065 toolBar.buttonDebugStartResume.toolTip = active ? $"Resume" : $"Start";
2068 debugBreakItem.disabled = isNotRunning;
2069 debugStopItem.disabled = isNotActive;
2070 debugRestartItem.disabled = isNotActive;
2073 toolBar.buttonDebugPause.disabled = isNotRunning;
2074 toolBar.buttonDebugStop.disabled = isNotActive;
2075 toolBar.buttonDebugRestart.disabled = isNotActive;
2078 debugStepIntoItem.disabled = isNotNotRunning;
2079 debugStepOverItem.disabled = isNotNotRunning;
2080 debugSkipStepOverItem.disabled = isNotNotRunning;
2081 debugStepOutItem.disabled = isNotStopped;
2082 debugSkipStepOutItem.disabled = isNotStopped;
2084 debugStepUntilItem.disabled = isNotStopped;
2085 debugSkipStepUntilItem.disabled = isNotStopped;
2089 toolBar.buttonDebugStepInto.disabled = isNotNotRunning;
2090 toolBar.buttonDebugStepOver.disabled = isNotNotRunning;
2091 toolBar.buttonDebugSkipStepOver.disabled = isNotNotRunning;
2092 toolBar.buttonDebugStepOut.disabled = isNotStopped;
2093 //toolBar.buttonDebugSkipStepOutItem.disabled = isNotNotRunning;
2095 if((Designer)GetActiveDesigner())
2097 CodeEditor codeEditor = ((Designer)GetActiveDesigner()).codeEditor;
2099 codeEditor.AdjustDebugMenus();
2103 void ChangeFileDialogsDirectory(char * directory, bool saveSettings)
2105 char tempString[MAX_LOCATION];
2106 strcpy(tempString, directory);
2107 if(saveSettings && !projectView)
2109 ideSettings.ideFileDialogLocation = directory;
2110 settingsContainer.Save();
2113 ideFileDialog.currentDirectory = tempString;
2114 codeEditorFileDialog.currentDirectory = tempString;
2115 codeEditorFormFileDialog.currentDirectory = tempString;
2118 void ChangeProjectFileDialogDirectory(char * directory)
2120 ideSettings.ideProjectFileDialogLocation = directory;
2121 settingsContainer.Save();
2124 Window FindWindow(char * filePath)
2126 Window document = null;
2128 // TOCHECK: Do we need to change slashes here?
2129 for(document = firstChild; document; document = document.next)
2131 char * fileName = document.fileName;
2132 if(document.isDocument && fileName && !fstrcmp(fileName, filePath))
2134 document.visible = true;
2135 document.Activate();
2142 bool DontTerminateDebugSession(char * title)
2144 if(debugger.isActive)
2146 if(MessageBox { type = yesNo, master = ide,
2147 contents = $"Do you want to terminate the debugging session in progress?",
2148 text = title }.Modal() == no)
2151 MessageBox msg { type = yesNo, master = ide,
2152 contents = "Do you want to terminate the debugging session in progress?",
2154 if(msg.Modal() == no)
2166 Window OpenFile(char * origFilePath, WindowState state, bool visible, char * type, OpenCreateIfFails createIfFails, OpenMethod openMethod, bool noParsing)
2168 char extension[MAX_EXTENSION] = "";
2169 Window document = null;
2170 bool isProject = false;
2171 bool needFileModified = true;
2172 char winFilePath[MAX_LOCATION];
2173 char * filePath = strstr(origFilePath, "http://") == origFilePath ? strcpy(winFilePath, origFilePath) : GetSystemPathBuffer(winFilePath, origFilePath);
2177 GetExtension(filePath, extension);
2181 strcpy(extension, type);
2183 if(strcmp(extension, ProjectExtension))
2185 for(document = firstChild; document; document = document.next)
2187 char * fileName = document.fileName;
2188 if(document.isDocument && fileName && !fstrcmp(fileName, filePath) && document.created)
2190 document.visible = true;
2192 document.Activate();
2198 if(createIfFails == whatever)
2200 else if(!strcmp(extension, ProjectExtension) || !strcmp(extension, WorkspaceExtension))
2202 needFileModified = false;
2203 if(openMethod == normal)
2205 if(DontTerminateDebugSession($"Open Project"))
2215 Workspace workspace = null;
2217 if(FileExists(filePath))
2219 if(!strcmp(extension, ProjectExtension))
2221 char workspaceFile[MAX_LOCATION];
2222 strcpy(workspaceFile, filePath);
2223 ChangeExtension(workspaceFile, WorkspaceExtension, workspaceFile);
2224 workspace = LoadWorkspace(workspaceFile, filePath);
2226 else if(!strcmp(extension, WorkspaceExtension))
2227 workspace = LoadWorkspace(filePath, null);
2230 //project = LoadProject(filePath, null);
2235 char absolutePath[MAX_LOCATION];
2236 CreateProjectView(workspace, filePath);
2237 document = projectView;
2239 workspace.ParseLoadedBreakpoints();
2240 workspace.DropInvalidBreakpoints(null);
2243 ide.projectView.ShowOutputBuildLog(true);
2245 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
2246 ide.projectView.DisplayCompiler(compiler, false);
2249 UpdateCompilerConfigs(false);
2252 char newWorkingDir[MAX_LOCATION];
2253 StripLastDirectory(filePath, newWorkingDir);
2254 ChangeFileDialogsDirectory(newWorkingDir, false);
2257 document.fileName = filePath;
2259 ideMainFrame.SetText("%s - %s", filePath, titleECEREIDE);
2261 // this crashes on starting ide with epj file, solution please?
2262 // app.UpdateDisplay();
2264 workspace.holdTracking = true;
2265 for(ofi : workspace.openedFiles)
2267 if(ofi.state != closed)
2269 Window file = OpenFile(ofi.path, normal, true, null, no, normal, noParsing);
2272 char fileName[MAX_LOCATION];
2274 GetLastDirectory(ofi.path, fileName);
2275 node = projectView.project.topNode.Find(fileName, true);
2277 node.EnsureVisible();
2281 ide.RepositionWindows(false);
2282 workspace.holdTracking = false;
2284 workspace.timer.Start();
2286 #if !defined(__WIN32__)
2287 // Valgrind Debug menu updates
2288 debugUseValgrindItem.checked = workspace.useValgrind;
2290 debugValgrindNoLeakCheckItem.checked = workspace.vgLeakCheck == no;
2291 debugValgrindSummaryLeakCheckItem.checked = workspace.vgLeakCheck == summary;
2292 debugValgrindYesLeakCheckItem.checked = workspace.vgLeakCheck == yes;
2293 debugValgrindFullLeakCheckItem.checked = workspace.vgLeakCheck == full;
2295 debugValgrindRSDefaultItem.checked = workspace.vgRedzoneSize == -1;
2296 debugValgrindRS0Item.checked = workspace.vgRedzoneSize == 0;
2297 debugValgrindRS16Item.checked = workspace.vgRedzoneSize == 16;
2298 debugValgrindRS32Item.checked = workspace.vgRedzoneSize == 32;
2299 debugValgrindRS64Item.checked = workspace.vgRedzoneSize == 64;
2300 debugValgrindRS128Item.checked = workspace.vgRedzoneSize == 128;
2301 debugValgrindRS256Item.checked = workspace.vgRedzoneSize == 256;
2302 debugValgrindRS512Item.checked = workspace.vgRedzoneSize == 512;
2304 debugValgrindTrackOriginsItem.checked = workspace.vgTrackOrigins;
2307 findInFilesDialog.mode = FindInFilesMode::project;
2308 findInFilesDialog.currentDirectory = ide.project.topNode.path;
2311 char location[MAX_LOCATION];
2312 StripLastDirectory(ide.project.topNode.path, location);
2313 ChangeProjectFileDialogDirectory(location);
2320 if(MessageBox { type = yesNo, master = this, text = $"Error opening project", contents = $"Open a different project?" }.Modal() == yes)
2322 ideProjectFileDialog.text = openProjectFileDialogTitle;
2323 if(ideProjectFileDialog.Modal() == cancel)
2325 filePath = ideProjectFileDialog.filePath;
2326 GetExtension(filePath, extension);
2337 else if(openMethod == add)
2342 char slashFilePath[MAX_LOCATION];
2343 GetSlashPathBuffer(slashFilePath, filePath);
2344 for(p : workspace.projects)
2346 if(!fstrcmp(p.filePath, slashFilePath))
2354 MessageBox { type = ok, parent = parent, master = this, text = $"Same Project",
2355 contents = $"This project is already present in workspace." }.Modal();
2359 prj = LoadProject(filePath, null);
2362 char * activeConfigName = null;
2363 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
2364 prj.StartMonitoring();
2365 workspace.projects.Add(prj);
2366 if(toolBar.activeConfig.currentRow && toolBar.activeConfig.currentRow != toolBar.activeConfig.firstRow &&
2367 toolBar.activeConfig.currentRow.string && toolBar.activeConfig.currentRow.string[0])
2368 activeConfigName = toolBar.activeConfig.currentRow.string;
2369 if(activeConfigName)
2371 for(cfg : prj.configurations)
2373 if(cfg.name && !strcmp(cfg.name, activeConfigName))
2381 projectView.AddNode(prj.topNode, null);
2382 workspace.modified = true;
2384 findInFilesDialog.AddProjectItem(prj);
2385 projectView.ShowOutputBuildLog(true);
2386 projectView.DisplayCompiler(compiler, false);
2387 projectView.ProjectUpdateMakefileForAllConfigs(prj);
2391 char location[MAX_LOCATION];
2392 StripLastDirectory(prj.topNode.path, location);
2393 ChangeProjectFileDialogDirectory(location);
2396 // projectView is associated with the main project and not with the one just added but
2397 return projectView; // just to let the caller know something was opened
2405 else if(!strcmp(extension, "bmp") || !strcmp(extension, "pcx") ||
2406 !strcmp(extension, "jpg") || !strcmp(extension, "gif") ||
2407 !strcmp(extension, "jpeg") || !strcmp(extension, "png"))
2409 if(FileExists(filePath))
2410 document = PictureEdit { hasMaximize = true, hasMinimize = true, hasClose = true, borderStyle = sizable,
2411 hasVertScroll = true, hasHorzScroll = true, parent = this, state = state,
2412 visible = visible, bitmapFile = filePath, OnClose = PictureEditOnClose/*why?--GenericDocumentOnClose*/;
2415 MessageBox { type = ok, master = this, text = filePath, contents = $"File doesn't exist." }.Modal();
2418 else if(!strcmp(extension, "3ds"))
2420 if(FileExists(filePath))
2421 document = ModelView { hasMaximize = true, hasMinimize = true, hasClose = true, borderStyle = sizable,
2422 hasVertScroll = true, hasHorzScroll = true, parent = this, state = state,
2423 visible = visible, modelFile = filePath, OnClose = ModelViewOnClose/*why?--GenericDocumentOnClose*/
2427 MessageBox { type = ok, master = this, text = filePath, contents = $"File doesn't exist." }.Modal();
2430 else if(!strcmp(extension, "txt") || !strcmp(extension, "text") ||
2431 !strcmp(extension, "nfo") || !strcmp(extension, "info") ||
2432 !strcmp(extension, "htm") || !strcmp(extension, "html") ||
2433 !strcmp(extension, "css") || !strcmp(extension, "php") ||
2434 !strcmp(extension, "js"))
2436 CodeEditor editor { parent = this, state = state, visible = false, noParsing = noParsing };
2437 editor.updatingCode = true;
2438 if(editor.LoadFile(filePath))
2441 editor.visible = true;
2445 needFileModified = false;
2449 CodeEditor editor { parent = this, state = state, visible = false, noParsing = noParsing };
2450 if(editor.LoadFile(filePath))
2453 editor.visible = true;
2457 needFileModified = false;
2460 if(document && (document._class == class(PictureEdit) ||
2461 document._class == class(ModelView)))
2466 document.fileName = filePath;
2467 if(workspace && !workspace.holdTracking)
2468 workspace.UpdateOpenedFileInfo(filePath, opened);
2472 if(!document && createIfFails != no)
2474 if(createIfFails != yes && !needFileModified &&
2475 MessageBox { type = yesNo, master = this, text = filePath, contents = $"File doesn't exist. Create?" }.Modal() == yes)
2476 createIfFails = yes;
2477 if(createIfFails == yes || createIfFails == whatever)
2479 document = (Window)NewCodeEditor(this, state, true);
2481 document.fileName = filePath;
2487 if(projectView && document._class == class(CodeEditor) && workspace)
2489 int lineNumber, position;
2491 CodeEditor editor = (CodeEditor)document;
2492 editor.openedFileInfo = workspace.UpdateOpenedFileInfo(filePath, opened);
2493 editor.openedFileInfo.holdTracking = true;
2494 lineNumber = Max(editor.openedFileInfo.lineNumber - 1, 0);
2495 position = Max(editor.openedFileInfo.position - 1, 0);
2496 editor.editBox.GoToLineNum(lineNumber);
2497 editor.editBox.GoToPosition(editor.editBox.line, lineNumber, position);
2498 scroll.x = Max(editor.openedFileInfo.scroll.x, 0);
2499 scroll.y = Max(editor.openedFileInfo.scroll.y, 0);
2500 editor.editBox.scroll = scroll;
2501 editor.openedFileInfo.holdTracking = false;
2504 if(needFileModified)
2505 document.OnFileModified = OnFileModified;
2506 document.NotifySaved = DocumentSaved;
2509 ideSettings.AddRecentProject(document.fileName);
2511 ideSettings.AddRecentFile(document.fileName);
2512 ide.UpdateRecentMenus();
2513 ide.AdjustFileMenus();
2514 settingsContainer.Save();
2522 // TOCHECK: I can't use a generic one for both ModelView and PictureEdit both derived from Window
2523 /*bool Window::GenericDocumentOnClose(bool parentClosing)
2525 if(!parentClosing && ide.workspace)
2526 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2529 bool ModelView::ModelViewOnClose(bool parentClosing)
2531 if(!parentClosing && ide.workspace)
2532 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2535 bool PictureEdit::PictureEditOnClose(bool parentClosing)
2537 if(!parentClosing && ide.workspace)
2538 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2543 void OnUnloadGraphics(Window window)
2545 display.ClearMaterials();
2546 display.ClearTextures();
2547 display.ClearMeshes();
2551 bool OnActivate(bool active, Window swap, bool * goOnWithActivation, bool direct)
2553 caps.color = app.GetKeyState(capsState) ? black : Color { 128,128,128 };
2554 num.color = app.GetKeyState(numState) ? black : Color { 128,128,128 };
2558 bool OnKeyDown(Key key, unichar ch)
2563 projectView.Update(null);
2566 caps.color = app.GetKeyState(capsState) ? black : Color { 128,128,128 };
2569 num.color = app.GetKeyState(numState) ? black : Color { 128,128,128 };
2575 void GoToError(const char * line, bool noParsing)
2578 projectView.GoToError(line, noParsing);
2581 void CodeLocationParseAndGoTo(const char * text, Project project, const char * dir)
2585 char *colon = strchr(text, ':');
2586 char filePath[MAX_LOCATION] = "";
2587 char completePath[MAX_LOCATION];
2588 int line = 0, col = 0;
2589 int len = strlen(text);
2591 FileAttribs fileAttribs;
2593 // support for valgrind output
2594 if((s = strstr(text, "==")) && (s = strstr(s+2, "==")) && (s = strstr(s+2, ":")) && (s = strstr(s+1, ":")))
2605 /*for(s=colon; *s; s++)
2614 //line = atoi(colon+1);
2616 // support for "Found n match(es) in "file/path";
2617 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)
2623 if(colon && (colon[1] == '/' || colon[1] == '\\'))
2625 path = (colon - 1 > path) ? colon - 1 : path;
2626 colon = strstr(colon + 1, ":");
2628 if(*path == '*' && (s = strchr(path+1, '*')))
2630 while(isspace(*path)) path++;
2634 char * close = strchr(path, ')');
2638 strncpy(name, path+1, close - path - 1);
2639 name[close - path - 1] = '\0';
2640 for(p : ide.workspace.projects)
2642 if(!strcmp(p.name, name))
2652 prj = project ? project : (dir ? null : ide.project);
2655 strncpy(filePath, path, colon - path);
2656 filePath[colon - path] = '\0';
2657 line = atoi(colon + 1);
2658 colon = strstr(colon + 1, ":");
2660 col = atoi(colon + 1);
2662 else if(path - 1 >= text && *(path - 1) == '\"')
2664 colon = strchr(path, '\"');
2667 strncpy(filePath, path, colon - path);
2668 filePath[colon - path] = '\0';
2671 else if(path && !colon)
2673 strcpy(filePath, path);
2679 strcpy(completePath, prj.topNode.path);
2680 else if(dir && dir[0])
2681 strcpy(completePath, dir);
2683 completePath[0] = '\0';
2684 PathCat(completePath, filePath);
2686 if((fileAttribs = FileExists(completePath)))
2687 CodeLocationGoTo(completePath, fileAttribs, line, col);
2688 else if(ide.workspace)
2691 for(p : ide.workspace.projects)
2693 strcpy(completePath, p.topNode.path);
2694 PathCat(completePath, filePath);
2695 if((fileAttribs = FileExists(completePath)).isFile)
2697 CodeLocationGoTo(completePath, fileAttribs, line, col);
2704 for(p : ide.workspace.projects)
2706 ProjectNode node = p.topNode.Find(filePath, false);
2709 node.GetFullFilePath(completePath);
2710 if((fileAttribs = FileExists(completePath)).isFile)
2712 CodeLocationGoTo(completePath, fileAttribs, line, col);
2722 void CodeLocationGoTo(const char * path, const FileAttribs fileAttribs, int line, int col)
2724 if(fileAttribs.isFile)
2726 char ext[MAX_EXTENSION];
2727 GetExtension(path, ext);
2728 if(!strcmp(ext, "mp3") || !strcmp(ext, "flac") || !strcmp(ext, "ogg") || !strcmp(ext, "avi") || !strcmp(ext, "mkv"))
2730 else if(!strcmp(ext, "a") || !strcmp(ext, "o") || !strcmp(ext, "lib") || !strcmp(ext, "dll") || !strcmp(ext, "exe"))
2732 char dirPath[MAX_LOCATION];
2733 StripLastDirectory(path, dirPath);
2738 CodeEditor codeEditor = (CodeEditor)OpenFile(path, normal, true, ext, no, normal, false);
2739 if(codeEditor && line)
2741 EditBox editBox = codeEditor.editBox;
2742 editBox.GoToLineNum(line - 1);
2743 editBox.GoToPosition(editBox.line, line - 1, col ? (col - 1) : 0);
2747 else if(fileAttribs.isDirectory)
2751 void OnRedraw(Surface surface)
2753 Bitmap bitmap = back.bitmap;
2755 surface.Blit(bitmap, (clientSize.w - bitmap.width) / 2, (clientSize.h - bitmap.height) / 2, 0, 0, bitmap.width, bitmap.height);
2758 void SheetSelected(SheetType sheetSelected)
2760 if(activeChild == sheet)
2762 if(sheetSelected == methods)
2764 viewPropertiesItem.accelerator = f4;
2765 viewPropertiesItem.parent = viewMenu;
2766 viewMethodsItem.parent = null;
2770 viewMethodsItem.accelerator = f4;
2771 viewMethodsItem.parent = viewMenu;
2772 viewPropertiesItem.parent = null;
2777 viewMethodsItem.parent = viewMenu;
2778 viewPropertiesItem.parent = viewMenu;
2779 if(sheetSelected == methods)
2781 viewMethodsItem.accelerator = f4;
2782 viewPropertiesItem.accelerator = 0;
2786 viewMethodsItem.accelerator = 0;
2787 viewPropertiesItem.accelerator = f4;
2792 void OnActivateClient(Window client, Window previous)
2794 //if(!client || client != previous)
2797 if(!client || client != previous)
2800 dataType = previous._class;
2801 if(previous && !strcmp(dataType.name, "CodeEditor"))
2803 ((CodeEditor)previous).UpdateFormCode();
2805 else if(previous && !strcmp(dataType.name, "Designer"))
2807 ((Designer)previous).codeEditor.UpdateFormCode();
2812 dataType = client._class;
2813 if(client && !strcmp(dataType.name, "CodeEditor"))
2815 CodeEditor codeEditor = (CodeEditor)client;
2816 SetPrivateModule(codeEditor.privateModule);
2817 SetCurrentContext(codeEditor.globalContext);
2818 SetTopContext(codeEditor.globalContext);
2819 SetGlobalContext(codeEditor.globalContext);
2821 SetDefines(&codeEditor.defines);
2822 SetImports(&codeEditor.imports);
2824 SetActiveDesigner(codeEditor.designer);
2826 sheet.codeEditor = codeEditor;
2827 toolBox.codeEditor = codeEditor;
2829 viewDesignerItem.parent = viewMenu;
2830 if(activeChild != codeEditor)
2832 viewCodeItem.parent = viewMenu;
2833 viewDesignerItem.accelerator = 0;
2834 viewCodeItem.accelerator = f8;
2838 viewCodeItem.parent = null;
2839 viewDesignerItem.accelerator = f8;
2842 else if(client && !strcmp(dataType.name, "Designer"))
2844 CodeEditor codeEditor = ((Designer)client).codeEditor;
2847 SetPrivateModule(codeEditor.privateModule);
2848 SetCurrentContext(codeEditor.globalContext);
2849 SetTopContext(codeEditor.globalContext);
2850 SetGlobalContext(codeEditor.globalContext);
2851 SetDefines(&codeEditor.defines);
2852 SetImports(&codeEditor.imports);
2856 SetPrivateModule(null);
2857 SetCurrentContext(null);
2858 SetTopContext(null);
2859 SetGlobalContext(null);
2864 SetActiveDesigner((Designer)client);
2866 sheet.codeEditor = codeEditor;
2867 toolBox.codeEditor = codeEditor;
2869 viewCodeItem.parent = viewMenu;
2870 if(activeChild != client)
2872 viewDesignerItem.parent = viewMenu;
2873 viewDesignerItem.accelerator = f8;
2874 viewCodeItem.accelerator = 0;
2878 viewDesignerItem.parent = null;
2879 viewCodeItem.accelerator = f8;
2885 sheet.codeEditor = null;
2886 toolBox.codeEditor = null;
2887 SetActiveDesigner(null);
2889 viewDesignerItem.parent = null;
2890 viewCodeItem.parent = null;
2893 SheetSelected(sheet.sheetSelected);
2896 projectCompileItem = null;
2901 if(client && client._class == eSystem_FindClass(__thisModule, "CodeEditor")) // !strcmp(client._class.name, "CodeEditor")
2903 CodeEditor codeEditor = (CodeEditor)client;
2904 EditBox editBox = codeEditor.editBox;
2906 statusBar.AddField(pos);
2908 caps = { width = 40, text = $"CAPS", color = app.GetKeyState(capsState) ? black : Color { 128, 128, 128 } };
2909 statusBar.AddField(caps);
2911 ovr = { width = 30, text = $"OVR", color = (editBox && editBox.overwrite) ? black : Color { 128, 128, 128 } };
2912 statusBar.AddField(ovr);
2914 num = { width = 30, text = $"NUM", color = app.GetKeyState(numState) ? black : Color { 128, 128, 128 } };
2915 statusBar.AddField(num);
2917 //statusBar.text = "Ready";
2919 if(projectView && projectView.project)
2921 bool isCObject = false;
2922 ProjectNode node = projectView.GetNodeFromWindow(client, null, false, false);
2923 if(!node && (node = projectView.GetNodeFromWindow(client, null, false, true)))
2927 char nodeName[MAX_FILENAME];
2928 char name[MAX_FILENAME+96];
2930 ChangeExtension(node.name, "c", nodeName);
2931 sprintf(name, $"Compile %s", isCObject ? nodeName : node.name);
2932 projectCompileItem =
2934 copyText = true, text = name, c, ctrlF7, disabled = projectView.buildInProgress;
2936 bool NotifySelect(MenuItem selection, Modifiers mods)
2940 bool result = false;
2941 bool isCObject = false;
2942 ProjectNode node = null;
2943 for(p : ide.workspace.projects)
2945 node = projectView.GetNodeFromWindow(activeClient, p, true, false);
2948 if(!node && (node = projectView.GetNodeFromWindow(activeClient, null, true, true)))
2952 List<ProjectNode> nodes { };
2954 projectView.Compile(node.project, nodes, mods.ctrl && mods.shift, isCObject ? cObject : normal);
2959 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
2964 projectMenu.AddDynamic(projectCompileItem, ide, false);
2970 caps = ovr = num = null;
2975 bool OnClose(bool parentClosing)
2977 //return !projectView.buildInProgress;
2978 if(projectView && projectView.buildInProgress)
2980 if(DontTerminateDebugSession($"Close IDE"))
2982 if(findInFilesDialog)
2983 findInFilesDialog.SearchStop();
2986 workspace.timer.Stop();
2989 ideMainFrame.Destroy(0);
2996 bool passThrough = false;
2997 bool debugStart = false;
2998 bool debugWorkDir = false;
2999 char * passDebugWorkDir = null;
3000 bool openAsText = false;
3001 DynamicString passArgs { };
3004 for(c = 1; c<app.argc; c++)
3008 char * arg = app.argv[c];
3009 char * buf = new char[strlen(arg)*2+1];
3011 passArgs.concat(" ");
3013 passArgs.concat(buf);
3016 else if(debugWorkDir)
3018 passDebugWorkDir = CopyString(app.argv[c]);
3019 StripQuotes(passDebugWorkDir, passDebugWorkDir);
3020 debugWorkDir = false;
3022 else if(!strcmp(app.argv[c], "-t"))
3024 else if(!strcmp(app.argv[c], "-no-parsing"))
3025 ide.noParsing = true;
3026 else if(!strcmp(app.argv[c], "-debug-start"))
3028 else if(!strcmp(app.argv[c], "-debug-work-dir"))
3029 debugWorkDir = true;
3030 else if(!strcmp(app.argv[c], "-@"))
3034 char fullPath[MAX_LOCATION];
3035 char parentPath[MAX_LOCATION];
3036 char ext[MAX_EXTENSION];
3038 FileAttribs dirAttribs;
3039 GetWorkingDir(fullPath, MAX_LOCATION);
3040 PathCat(fullPath, app.argv[c]);
3041 StripLastDirectory(fullPath, parentPath);
3042 GetExtension(app.argv[c], ext);
3043 isProject = !openAsText && !strcmpi(ext, "epj");
3045 if(isProject && c > (debugStart ? 2 : 1)) continue;
3047 // Create directory for projects (only)
3048 if(((dirAttribs = FileExists(parentPath)) && dirAttribs.isDirectory) || isProject)
3050 if(isProject && !FileExists(fullPath))
3052 char name[MAX_LOCATION];
3053 NewProjectDialog newProjectDialog;
3057 projectView.visible = false;
3058 if(!projectView.Destroy(0))
3062 newProjectDialog = { master = this };
3064 strcpy(name, app.argv[c]);
3065 StripExtension(name);
3066 GetLastDirectory(name, name);
3067 newProjectDialog.projectName.contents = name;
3068 newProjectDialog.projectName.NotifyModified(newProjectDialog, newProjectDialog.projectName);
3069 newProjectDialog.locationEditBox.path = parentPath;
3070 newProjectDialog.NotifyModifiedLocation(newProjectDialog.locationEditBox);
3072 incref newProjectDialog;
3073 newProjectDialog.Modal();
3076 ideSettings.AddRecentProject(projectView.fileName);
3077 ide.UpdateRecentMenus();
3078 settingsContainer.Save();
3080 delete newProjectDialog;
3081 // Open only one project
3085 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, openAsText ? "txt" : null, yes, normal, false);
3087 else if(strstr(fullPath, "http://") == fullPath)
3088 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, openAsText ? "txt" : null, yes, normal, false);
3091 if(passThrough && projectView && projectView.project && workspace)
3092 workspace.commandLineArgs = passArgs;
3093 if(passDebugWorkDir && projectView && projectView.project && workspace)
3095 workspace.debugDir = passDebugWorkDir;
3096 delete passDebugWorkDir;
3099 ;//MenuDebugStart(debugStartResumeItem, 0); // <-- how TODO this without getting into the app.Wait lock
3101 UpdateToolBarActiveConfigs(false);
3102 UpdateToolBarActiveCompilers();
3109 // IS THIS NEEDED? WASN'T HERE BEFORE... Crashes on getting node's projectView otherwise
3112 projectView.visible = false;
3113 projectView.Destroy(0);
3116 #ifdef GDB_DEBUG_GUI
3117 gdbDialog.Destroy(0);
3122 void SetPath(bool projectsDirs, CompilerConfig compiler, ProjectConfig config, int bitDepth)
3126 char * oldPaths[128];
3127 String oldList = new char[maxPathLen];
3128 Array<String> newExePaths { };
3129 //Map<String, bool> exePathExists { };
3131 #if defined(__unix__) || defined(__APPLE__)
3132 Array<String> newLibPaths { };
3133 Map<String, bool> libPathExists { };
3138 for(prj : workspace.projects)
3140 DirExpression targetDirExp;
3142 // SKIP FIRST PROJECT...
3143 if(prj == workspace.projects.firstIterator.data) continue;
3145 // NOTE: Right now the additional project config dir will be
3146 // obtained when the debugger is started, so toggling it
3147 // while building will change which library gets used.
3148 // To go with the initial state, e.g. when F5 was pressed,
3149 // we nould need to keep a list of all project's active
3150 // config upon startup.
3151 targetDirExp = prj.GetTargetDir(compiler, prj.config, bitDepth);
3153 /*if(prj.config.targetType == sharedLibrary && prj.config.debug)
3157 for(cfg = prj.configurations.first; cfg; cfg = cfg.next)
3158 if(cfg.targetType == sharedLibrary && cfg.debug && !strcmpi(cfg.name, "Debug"))
3162 for(cfg = prj.configurations.first; cfg; cfg = cfg.next)
3163 if(cfg.targetType == sharedLibrary && cfg.debug)
3167 if(targetDirExp.dir)
3169 char buffer[MAX_LOCATION];
3170 #if defined(__WIN32__)
3171 Array<String> paths = newExePaths;
3173 Array<String> paths = newLibPaths;
3175 GetSystemPathBuffer(buffer, prj.topNode.path);
3176 PathCat(buffer, targetDirExp.dir);
3179 if(!fstrcmp(p, buffer))
3186 paths.Add(CopyString(buffer));
3188 delete targetDirExp;
3192 for(item : compiler.executableDirs)
3195 for(p : newExePaths)
3197 if(!fstrcmp(p, item))
3204 newExePaths.Add(CopySystemPath(item));
3207 GetEnvironment("PATH", oldList, maxPathLen);
3209 printf("Old value of PATH: %s\n", oldList);
3211 count = TokenizeWith(oldList, sizeof(oldPaths) / sizeof(char *), oldPaths, pathListSep, false);
3212 for(c = 0; c < count; c++)
3215 for(p : newExePaths)
3217 if(!fstrcmp(p, oldPaths[c]))
3224 newExePaths.Add(CopySystemPath(oldPaths[c]));
3228 for(path : newExePaths)
3229 len += strlen(path) + 1;
3230 newList = new char[len + 1];
3232 for(path : newExePaths)
3234 strcat(newList, path);
3235 strcat(newList, pathListSep);
3237 newList[len - 1] = '\0';
3238 SetEnvironment("PATH", newList);
3240 printf("New value of PATH: %s\n", newList);
3247 #if defined(__unix__) || defined(__APPLE__)
3249 for(item : compiler.libraryDirs)
3251 if(!libPathExists[item]) // fstrcmp should be used
3253 String s = CopyString(item);
3255 libPathExists[s] = true;
3259 #if defined(__APPLE__)
3260 GetEnvironment("DYLD_LIBRARY_PATH", oldList, maxPathLen);
3262 GetEnvironment("LD_LIBRARY_PATH", oldList, maxPathLen);
3265 printf("Old value of [DY]LD_LIBRARY_PATH: %s\n", oldList);
3267 count = TokenizeWith(oldList, sizeof(oldPaths) / sizeof(char *), oldPaths, pathListSep, false);
3268 for(c = 0; c < count; c++)
3270 if(!libPathExists[oldPaths[c]]) // fstrcmp should be used
3272 String s = CopyString(oldPaths[c]);
3274 libPathExists[s] = true;
3279 for(path : newLibPaths)
3280 len += strlen(path) + 1;
3281 newList = new char[len + 1];
3283 for(path : newLibPaths)
3285 strcat(newList, path);
3286 strcat(newList, pathListSep);
3288 newList[len - 1] = '\0';
3289 #if defined(__APPLE__)
3290 SetEnvironment("DYLD_LIBRARY_PATH", newList);
3292 SetEnvironment("LD_LIBRARY_PATH", newList);
3295 printf("New value of [DY]LD_LIBRARY_PATH: %s\n", newList);
3301 delete libPathExists;
3304 if(compiler.distccEnabled && compiler.distccHosts)
3305 SetEnvironment("DISTCC_HOSTS", compiler.distccHosts);
3310 void DestroyTemporaryProjectDir()
3312 if(tmpPrjDir && tmpPrjDir[0])
3314 if(FileExists(tmpPrjDir).isDirectory)
3315 DestroyDir(tmpPrjDir);
3316 property::tmpPrjDir = null;
3322 // Graphics Driver Menu
3326 app.currentSkin.selectionColor = selectionColor;
3327 app.currentSkin.selectionText = selectionText;
3331 driverItems = new MenuItem[app.numDrivers];
3332 for(c = 0; c < app.numDrivers; c++)
3334 driverItems[c] = MenuItem { driversMenu, app.drivers[c], NotifySelect = NotifySelectDisplayDriver };
3335 driverItems[c].id = c;
3336 driverItems[c].isRadio = true;
3339 driverItems = new MenuItem[2];
3340 #if defined(__unix__)
3341 driverItems[0] = MenuItem { driversMenu, "X", NotifySelect = NotifySelectDisplayDriver };
3342 driverItems[0].id = 0;
3343 driverItems[0].isRadio = true;
3345 driverItems[0] = MenuItem { driversMenu, "GDI", NotifySelect = NotifySelectDisplayDriver };
3346 driverItems[0].id = 0;
3347 driverItems[0].isRadio = true;
3349 driverItems[1] = MenuItem { driversMenu, "OpenGL", NotifySelect = NotifySelectDisplayDriver };
3350 driverItems[1].id = 1;
3351 driverItems[1].isRadio = true;
3353 /* skinItems = new MenuItem[app.numSkins];
3354 for(c = 0; c < app.numSkins; c++)
3356 skinItems[c] = MenuItem {skinsMenu, app.skins[c], NotifySelect = NotifySelectDisplaySkin };
3357 skinItems[c].id = c;
3358 skinItems[c].isRadio = true;
3361 ideFileDialog.master = this;
3362 ideProjectFileDialog.master = this;
3364 //SetDriverAndSkin();
3368 void UpdateRecentMenus()
3371 Menu fileMenu = menu.FindMenu($"File");
3372 Menu recentFiles = fileMenu.FindMenu($"Recent Files");
3373 Menu recentProjects = fileMenu.FindMenu($"Recent Projects");
3374 char * itemPath = new char[MAX_LOCATION];
3375 char * itemName = new char[MAX_LOCATION+4];
3378 recentFiles.Clear();
3381 for(recent : ideSettings.recentFiles)
3383 strncpy(itemPath, recent, MAX_LOCATION); itemPath[MAX_LOCATION-1] = '\0';
3384 MakeSystemPath(itemPath);
3385 snprintf(itemName, MAX_LOCATION+4, "%d %s", 1 + c, itemPath); itemName[MAX_LOCATION+4-1] = '\0';
3386 recentFiles.AddDynamic(MenuItem { copyText = true, text = itemName, (Key)k1 + c, id = c, NotifySelect = ide.FileRecentFile }, ide, true);
3390 recentProjects.Clear();
3392 for(recent : ideSettings.recentProjects)
3394 strncpy(itemPath, recent, MAX_LOCATION); itemPath[MAX_LOCATION-1] = '\0';
3395 MakeSystemPath(itemPath);
3396 snprintf(itemName, MAX_LOCATION+4, "%d %s", 1 + c, itemPath); itemName[MAX_LOCATION+4-1] = '\0';
3397 recentProjects.AddDynamic(MenuItem { copyText = true, text = itemName, (Key)k1 + c, id = c, NotifySelect = ide.FileRecentProject }, ide, true);
3412 documentor.Puts("Quit\n");
3419 void DestroyDir(char * path)
3421 RecursiveDeleteFolderFSI fsi { };
3426 #if defined(__WIN32__)
3427 define sdkDirName = "Ecere SDK";
3429 define sdkDirName = "ecere";
3432 void FindAndShellOpenInstalledFolder(char * name)
3434 char * p = new char[MAX_LOCATION];
3435 char * v = new char[maxPathLen];
3438 Array<String> paths { };
3440 strncpy(p, settingsContainer.moduleLocation, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3441 StripLastDirectory(p, p);
3443 paths.Add(CopyString(p));
3444 #if defined(__WIN32__)
3445 GetEnvironment("ECERE_SDK_SRC", v, maxPathLen);
3448 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3449 PathCat(p, name); paths.Add(CopyString(p));
3451 GetEnvironment("AppData", v, maxPathLen);
3454 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3455 PathCat(p, sdkDirName); PathCat(p, name); paths.Add(CopyString(p));
3457 GetEnvironment("ProgramFiles", v, maxPathLen);
3460 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3461 PathCat(p, sdkDirName); PathCat(p, name); paths.Add(CopyString(p));
3463 GetEnvironment("ProgramFiles(x86)", v, maxPathLen);
3466 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3467 PathCat(p, sdkDirName); PathCat(p, name); paths.Add(CopyString(p));
3469 GetEnvironment("SystemDrive", v, maxPathLen);
3472 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3473 PathCat(p, "Program Files"); PathCat(p, sdkDirName); PathCat(p, name); paths.Add(CopyString(p));
3476 GetEnvironment("XDG_DATA_DIRS", v, maxPathLen);
3477 numTokens = TokenizeWith(v, sizeof(tokens) / sizeof(byte *), tokens, ":", false);
3478 for(c=0; c<numTokens; c++)
3480 strncpy(p, tokens[c], MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3481 PathCat(p, sdkDirName); PathCat(p, name); paths.Add(CopyString(p));
3486 strncpy(p, path, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3487 if(FileExists(p).isDirectory)
3499 void FindAndShellOpenInstalledFile(char * subdir, char * name)
3501 char * p = new char[MAX_LOCATION];
3502 char * v = new char[maxPathLen];
3505 Array<String> paths { };
3507 strncpy(p, settingsContainer.moduleLocation, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3508 paths.Add(CopyString(p));
3509 StripLastDirectory(p, p);
3511 paths.Add(CopyString(p));
3512 #if defined(__WIN32__)
3513 GetEnvironment("ECERE_SDK_SRC", v, maxPathLen);
3516 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3517 PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3519 GetEnvironment("AppData", v, maxPathLen);
3522 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3523 PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3525 GetEnvironment("ProgramFiles", v, maxPathLen);
3528 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3529 PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3531 GetEnvironment("ProgramFiles(x86)", v, maxPathLen);
3534 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3535 PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3537 GetEnvironment("SystemDrive", v, maxPathLen);
3540 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3541 PathCat(p, "Program Files"); PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3544 GetEnvironment("XDG_DATA_DIRS", v, maxPathLen);
3545 numTokens = TokenizeWith(v, sizeof(tokens) / sizeof(byte *), tokens, ":", false);
3546 for(c=0; c<numTokens; c++)
3548 strncpy(p, tokens[c], MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3549 PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3554 strncpy(p, path, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3556 if(FileExists(p).isFile)
3568 class RecursiveDeleteFolderFSI : NormalFileSystemIterator
3570 bool preserveRootFolder;
3572 void OutFolder(char * folderPath, bool isRoot)
3574 if(!(preserveRootFolder && isRoot))
3575 RemoveDir(folderPath);
3578 bool OnFile(char * filePath)
3580 DeleteFile(filePath);
3585 class IDEApp : GuiApplication
3587 //driver = "Win32Console";
3588 // driver = "OpenGL";
3592 TempFile includeFile { };
3596 char ext[MAX_EXTENSION];
3597 SetLoggingMode(stdOut, null);
3598 //SetLoggingMode(debug, null);
3600 settingsContainer.Load();
3601 if(argc > 1 && !strcmpi(GetExtension(argv[1], ext), "3ds"))
3603 app.driver = "OpenGL";
3604 ide.driverItems[1].checked = true;
3608 #if defined(__unix__) || defined(__APPLE__)
3609 app.driver = (ideSettings.displayDriver && !strcmp(ideSettings.displayDriver, "OpenGL")) ? ideSettings.displayDriver : "X";
3611 app.driver = (ideSettings.displayDriver && !strcmp(ideSettings.displayDriver, "OpenGL")) ? ideSettings.displayDriver : "GDI";
3613 ide.driverItems[ideSettings.displayDriver && !strcmp(ideSettings.displayDriver,"OpenGL")].checked = true;
3618 desktop.text = titleECEREIDE;
3621 for(c = 1; c<app.argc; c++)
3623 char fullPath[MAX_LOCATION];
3624 GetWorkingDir(fullPath, MAX_LOCATION);
3625 PathCat(fullPath, app.argv[c]);
3626 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, null, yes, normal, false);
3630 if(!LoadIncludeFile())
3631 PrintLn("error: unable to load :crossplatform.mk file inside ide binary.");
3636 bool Cycle(bool idle)
3640 if(ide.documentor.Peek())
3643 ide.documentor.GetLine(line, sizeof(line));
3644 if(!strcmpi(line, "Exited"))
3646 ide.documentor.CloseInput();
3647 ide.documentor.CloseOutput();
3648 ide.documentor.Wait();
3649 delete ide.documentor;
3652 if(ide.documentor && ide.documentor.eof)
3654 ide.documentor.CloseInput();
3655 ide.documentor.CloseOutput();
3656 ide.documentor.Wait();
3657 delete ide.documentor;
3663 bool LoadIncludeFile()
3665 bool result = false;
3666 File include = FileOpen(":crossplatform.mk", read);
3669 File f = includeFile;
3672 for(; !include.Eof(); )
3675 int count = include.Read(buffer, 1, 4096);
3676 f.Write(buffer, 1, count);
3686 IDEMainFrame ideMainFrame { };
3688 define app = ((IDEApp)__thisModule);
3690 define titleECEREIDE = $"ECERE IDE (Debug)";
3692 define titleECEREIDE = $"ECERE IDE";