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 char name[MAX_LOCATION];
487 // TOFIX: Improve on this, don't use only filename, make a function
488 GetLastDirectory(debugger.activeFrame.absoluteFile, name);
489 if(ide && ide.workspace)
491 for(p : ide.workspace.projects)
493 if(p.topNode.Find(name, false))
501 for(p : ide.workspace.projects)
503 if(IsPathInsideOf(debugger.activeFrame.absoluteFile, p.topNode.path))
511 debugger.ToggleBreakpoint(debugger.activeFrame.absoluteFile, line, prj);
514 CodeEditor codeEditor = (CodeEditor)ide.FindWindow(debugger.activeFrame.absoluteFile);
515 if(codeEditor) { codeEditor.Update(null); Activate(); }
520 bool OnKeyDown(Key key, unichar ch)
524 case escape: ide.ShowCodeEditor(); break;
529 bool OnClose(bool parentClosing)
533 ide.RepositionWindows(false);
534 return parentClosing;
537 void OnRedraw(Surface surface)
539 Debugger debugger = ide.debugger;
540 Frame activeFrame = debugger.activeFrame;
544 int lineCursor, lineTopFrame, activeThread, hitThread;
545 int lineH, scrollY, boxH;
547 Breakpoint bp = null;
550 scrollY = editBox.scroll.y;
551 displaySystem.FontExtent(editBox.font.font, " ", 1, null, &lineH);
552 activeThread = debugger.activeThread;
553 hitThread = debugger.hitThread;
554 debugger.GetCallStackCursorLine(&error, &lineCursor, &lineTopFrame);
556 // TODO: improve bp drawing... it should be visible even if it's not on the activeFrame
557 if(activeFrame.absoluteFile)
559 for(i : ide.workspace.breakpoints; i.type == user)
561 if(i.absoluteFilePath && i.absoluteFilePath[0] &&
562 !fstrcmp(i.absoluteFilePath, activeFrame.absoluteFile) &&
563 activeFrame.line == i.line)
571 DrawLineMarginIcon(surface,
572 /*(lineCursor == 1 || lineTopFrame == 1) ? */ide.bmpBpHalf/* : ide.bmpBp*/,
573 lineCursor /*1*/, lineH, scrollY, boxH);
575 if(activeThread && activeThread == hitThread && debugger.bpHit && debugger.bpHit.type == user)
576 DrawLineMarginIcon(surface,
577 (lineCursor == 1 || lineTopFrame == 1) ? ide.bmpBpHalf : ide.bmpBp,
578 1, lineH, scrollY, boxH);
580 DrawLineMarginIcon(surface, error ? ide.bmpCursorError : ide.bmpCursor, lineCursor, lineH, scrollY, boxH);
581 if(bp && lineCursor == 1) //activeThread && activeThread == hitThread && debugger.bpHit && debugger.bpHit.type == user)
582 bmp = error ? ide.bmpTopFrameHalfError : ide.bmpTopFrameHalf;
584 bmp = error ? ide.bmpTopFrameError : ide.bmpTopFrame;
585 DrawLineMarginIcon(surface, bmp, lineTopFrame, lineH, scrollY, boxH);
587 if(editBox.horzScroll && editBox.horzScroll.visible)
589 surface.SetBackground(control);
590 surface.Area(0, editBox.clientSize.h, 20 - 1, clientSize.h - 1);
595 WatchesView watchesView { parent = this };
596 ThreadsView threadsView
598 parent = this, font = { panelFont.faceName, panelFont.size };
600 bool OnKeyDown(Key key, unichar ch)
604 case escape: ide.ShowCodeEditor(); break;
609 bool OnClose(bool parentClosing)
613 ide.RepositionWindows(false);
614 return parentClosing;
617 void OnSelectThread(int threadId)
620 ide.debugger.SelectThread(threadId);
623 bool OnGetThreadsInfo(int * activeThread, int * hitThread, int * signalThread)
626 Debugger debugger = ide.debugger;
627 *activeThread = debugger.activeThread;
628 *hitThread = debugger.hitThread;
629 *signalThread = debugger.signalThread;
634 BreakpointsView breakpointsView { parent = this };
636 ToolBox toolBox { parent = this };
637 Sheet sheet { parent = this };
640 property char * tmpPrjDir { set { delete tmpPrjDir; if(value) tmpPrjDir = CopyString(value); } get { return tmpPrjDir; } };
642 Menu fileMenu { menu, $"File", f, hasMargin = true };
645 fileMenu, $"New", n, ctrlN;
646 bitmap = { ":actions/docNew.png" };
647 bool NotifySelect(MenuItem selection, Modifiers mods)
649 Window document = (Window)NewCodeEditor(this, normal, false);
650 document.NotifySaved = DocumentSaved;
654 MenuItem fileOpenItem
656 fileMenu, $"Open...", o, ctrlO;
657 bitmap = { ":actions/docOpen.png" };
658 bool NotifySelect(MenuItem selection, Modifiers mods)
660 if(!projectView && ideSettings.ideFileDialogLocation)
661 ideFileDialog.currentDirectory = ideSettings.ideFileDialogLocation;
664 if(ideFileDialog.Modal() == ok)
666 bool gotWhatWeWant = false;
668 int numSelections = ideFileDialog.numSelections;
669 char ** multiFilePaths = ideFileDialog.multiFilePaths;
671 for(c = 0; c < numSelections; c++)
673 if(OpenFile(multiFilePaths[c], normal, true, fileTypes[ideFileDialog.fileType].typeExtension, no, normal, mods.ctrl && mods.shift))
674 gotWhatWeWant = true;
677 MessageBox { type = yesNo, master = this, text = $"Error opening file",
678 contents = $"Open a different file?" }.Modal() == no)
680 if(!projectView && gotWhatWeWant)
681 ChangeFileDialogsDirectory(ideFileDialog.currentDirectory, true);
682 ide.RepositionWindows(false);
692 MenuItem fileCloseItem { fileMenu, $"Close", c, ctrlF4, NotifySelect = MenuFileClose };
693 MenuDivider { fileMenu };
694 MenuItem fileSaveItem
696 fileMenu, $"Save", s, ctrlS, bitmap = { ":actions/docSave.png" };
698 // For the toolbar button; clients can still override that for the menu item
699 bool Window::NotifySelect(MenuItem selection, Modifiers mods)
701 Window w = activeClient;
703 w.MenuFileSave(null, 0);
707 MenuItem fileSaveAsItem { fileMenu, $"Save As...", a };
708 MenuItem fileSaveAllItem { fileMenu, $"Save All", l, NotifySelect = MenuFileSaveAll, bitmap = { ":actions/docSaveAll.png" } };
709 MenuDivider { fileMenu };
712 fileMenu, $"Find In Files...", f, Key { f, ctrl = true , shift = true };
713 bool NotifySelect(MenuItem selection, Modifiers mods)
715 findInFilesDialog.replaceMode = false;
716 findInFilesDialog.Show();
720 MenuItem replaceInFiles
722 fileMenu, $"Replace In Files...", e, Key { r, ctrl = true , shift = true };
723 bool NotifySelect(MenuItem selection, Modifiers mods)
725 findInFilesDialog.replaceMode = true;
726 findInFilesDialog.Show();
730 MenuDivider { fileMenu };
731 MenuItem globalSettingsItem
733 fileMenu, $"Global Settings...", g;
734 bool NotifySelect(MenuItem selection, Modifiers mods)
736 globalSettingsDialog.master = this;
737 if(ide.workspace && ide.workspace.compiler)
738 globalSettingsDialog.workspaceActiveCompiler = ide.workspace.compiler;
739 else if(ideSettings.defaultCompiler)
740 globalSettingsDialog.workspaceActiveCompiler = ideSettings.defaultCompiler;
741 globalSettingsDialog.Modal();
745 MenuDivider { fileMenu };
746 Menu recentFiles { fileMenu, $"Recent Files", r };
747 Menu recentProjects { fileMenu, $"Recent Projects", p };
748 MenuDivider { fileMenu };
751 fileMenu, $"Exit", x, altF4;
753 bool NotifySelect(MenuItem selection, Modifiers mods)
755 ideMainFrame.Destroy(0);
760 bool FileRecentFile(MenuItem selection, Modifiers mods)
763 for(file : ideSettings.recentFiles)
765 if(id == selection.id)
768 char extension[MAX_EXTENSION] = "";
769 GetExtension(file, extension);
770 isProjectFile = (!strcmpi(extension, "epj") || !strcmpi(extension, "ews"));
773 char * command = PrintString("ide ", isProjectFile ? "-t " : "", file);
779 OpenFile(file, normal, true, isProjectFile ? "txt" : null, no, normal, mods.ctrl && mods.shift);
780 ide.RepositionWindows(false);
789 bool FileRecentProject(MenuItem selection, Modifiers mods)
792 for(file : ideSettings.recentProjects)
794 if(id == selection.id)
798 char * command = PrintString("ide ", file);
803 OpenFile(file, normal, true, null, no, normal, mods.ctrl && mods.shift);
811 MenuPlacement editMenu { menu, $"Edit", e };
813 Menu projectMenu { menu, $"Menu"."Project", p, hasMargin = true };
814 MenuItem projectNewItem
816 projectMenu, $"New...", n, Key { n, true, true };
817 bitmap = { ":actions/projNew.png" };
818 bool NotifySelect(MenuItem selection, Modifiers mods)
820 if(!DontTerminateDebugSession($"New Project"))
823 NewProjectDialog newProjectDialog { master = this };
824 incref newProjectDialog;
825 result = newProjectDialog.Modal();
830 newProjectDialog.CreateNewProject();
833 ideSettings.AddRecentProject(projectView.fileName);
834 ide.UpdateRecentMenus();
835 settingsContainer.Save();
839 delete newProjectDialog;
844 MenuItem projectOpenItem
846 projectMenu, $"Open...", o, Key { o, true, true };
847 bitmap = { ":actions/projOpen.png" };
848 bool NotifySelect(MenuItem selection, Modifiers mods)
850 if(ideSettings.ideProjectFileDialogLocation)
851 ideProjectFileDialog.currentDirectory = ideSettings.ideProjectFileDialogLocation;
853 ideProjectFileDialog.text = openProjectFileDialogTitle;
854 if(ideProjectFileDialog.Modal() == ok)
856 OpenFile(ideProjectFileDialog.filePath, normal, true, projectTypes[ideProjectFileDialog.fileType].typeExtension, no, normal, mods.ctrl && mods.shift);
857 //ChangeProjectFileDialogDirectory(ideProjectFileDialog.currentDirectory);
862 MenuItem projectQuickItem
864 projectMenu, $"Quick...", q, f7, disabled = true;
865 bool NotifySelect(MenuItem selection, Modifiers mods)
868 QuickProjectDialog { this }.Modal();
872 MenuItem projectAddItem
874 projectMenu, $"Add project to workspace...", a, Key { a, true, true };
875 bitmap = { ":actions/projAdd.png" };
877 bool NotifySelect(MenuItem selection, Modifiers mods)
879 if(ideSettings.ideProjectFileDialogLocation)
880 ideProjectFileDialog.currentDirectory = ideSettings.ideProjectFileDialogLocation;
882 ideProjectFileDialog.text = addProjectFileDialogTitle;
885 if(ideProjectFileDialog.Modal() == ok)
887 if(OpenFile(ideProjectFileDialog.filePath, normal, true, projectTypes[ideProjectFileDialog.fileType].typeExtension, no, add, mods.ctrl && mods.shift))
889 if(MessageBox { type = yesNo, master = this, text = $"Error opening project file",
890 contents = $"Add a different project?" }.Modal() == no)
901 MenuItem projectCloseItem
903 projectMenu, $"Close", c, disabled = true;
904 bool NotifySelect(MenuItem selection, Modifiers mods)
908 if(!ide.DontTerminateDebugSession($"Project Close"))
914 MenuDivider { projectMenu };
915 MenuItem projectSettingsItem
917 projectMenu, $"Settings...", s, altF7, disabled = true;
918 bool NotifySelect(MenuItem selection, Modifiers mods)
920 projectView.MenuSettings(projectView.active ? selection : null, mods);
924 MenuDivider { projectMenu };
925 MenuItem projectBrowseFolderItem
927 projectMenu, $"Browse Project Folder", p, disabled = true;
928 bool NotifySelect(MenuItem selection, Modifiers mods)
931 projectView.MenuBrowseFolder(null, mods);
935 MenuDivider { projectMenu };
936 MenuItem projectRunItem
938 projectMenu, $"Run", r, ctrlF5, disabled = true;
939 bitmap = { ":actions/run.png" };
940 bool NotifySelect(MenuItem selection, Modifiers mods)
943 projectView.Run(null, mods);
947 MenuItem projectBuildItem
949 projectMenu, $"Build", b, f7, disabled = true;
950 bitmap = { ":actions/build.png" };
951 bool NotifySelect(MenuItem selection, Modifiers mods)
955 if(projectView.buildInProgress == none)
956 projectView.ProjectBuild(projectView.active ? selection : null, mods);
958 projectView.stopBuild = true;
963 MenuItem projectLinkItem
965 projectMenu, $"Relink", l, disabled = true;
966 bitmap = { ":actions/relink.png" };
967 bool NotifySelect(MenuItem selection, Modifiers mods)
970 projectView.ProjectLink(projectView.active ? selection : null, mods);
974 MenuItem projectRebuildItem
976 projectMenu, $"Rebuild", d, shiftF7, disabled = true;
977 bitmap = { ":actions/rebuild.png" };
978 bool NotifySelect(MenuItem selection, Modifiers mods)
981 projectView.ProjectRebuild(projectView.active ? selection : null, mods);
985 MenuItem projectCleanTargetItem
987 projectMenu, $"Clean Target", g, disabled = true;
988 bitmap = { ":actions/clean.png" };
989 bool NotifySelect(MenuItem selection, Modifiers mods)
994 projectView.ProjectCleanTarget(projectView.active ? selection : null, mods);
999 MenuItem projectCleanItem
1001 projectMenu, $"Clean", e, disabled = true;
1002 bitmap = { ":actions/clean.png" };
1003 bool NotifySelect(MenuItem selection, Modifiers mods)
1008 projectView.ProjectClean(projectView.active ? selection : null, mods);
1013 MenuItem projectRealCleanItem
1015 projectMenu, $"Real Clean", disabled = true;
1016 bitmap = { ":actions/clean.png" };
1017 bool NotifySelect(MenuItem selection, Modifiers mods)
1022 projectView.ProjectRealClean(projectView.active ? selection : null, mods);
1027 MenuItem projectRegenerateItem
1029 projectMenu, $"Regenerate Makefile", m, disabled = true;
1030 bitmap = { ":actions/regMakefile.png" };
1031 bool NotifySelect(MenuItem selection, Modifiers mods)
1034 projectView.ProjectRegenerate(projectView.active ? selection : null, mods);
1038 MenuItem projectInstallItem
1040 #ifdef IDE_SHOW_INSTALL_MENU_BUTTON
1041 projectMenu, $"Install", t, disabled = true;
1043 bitmap = { ":status/software-update-available.png" };
1044 bool NotifySelect(MenuItem selection, Modifiers mods)
1047 projectView.ProjectInstall(projectView.active ? selection : null, mods);
1051 MenuItem projectCompileItem;
1052 Menu debugMenu { menu, $"Debug", d, hasMargin = true };
1053 MenuItem debugStartResumeItem
1055 debugMenu, $"Start", s, f5, disabled = true;
1056 bitmap = { ":actions/debug.png" };
1057 NotifySelect = MenuDebugStart;
1059 bool MenuDebugStart(MenuItem selection, Modifiers mods)
1063 debugStartResumeItem.disabled = true; // a very rare exception to calling AdjustDebugMenus
1064 if(!projectView.DebugStart())
1065 debugStartResumeItem.disabled = false; // same exception
1069 bool MenuDebugResume(MenuItem selection, Modifiers mods)
1072 projectView.DebugResume();
1075 MenuItem debugRestartItem
1077 debugMenu, $"Restart", r, Key { f5, ctrl = true, shift = true }, disabled = true;
1078 bitmap = { ":actions/restart.png" };
1079 bool NotifySelect(MenuItem selection, Modifiers mods)
1082 projectView.DebugRestart();
1086 MenuItem debugBreakItem
1088 debugMenu, $"Break", b, Key { pauseBreak, ctrl = true }, disabled = true;
1089 bitmap = { ":actions/pause.png" };
1090 bool NotifySelect(MenuItem selection, Modifiers mods)
1092 if(projectView && projectView.buildInProgress != none)
1095 projectView.DebugBreak();
1099 MenuItem debugStopItem
1101 debugMenu, $"Stop", p, shiftF5, disabled = true;
1102 bitmap = { ":actions/stopDebug.png" };
1103 bool NotifySelect(MenuItem selection, Modifiers mods)
1106 projectView.DebugStop();
1111 MenuDivider { debugMenu };
1112 MenuItem debugUseValgrindItem
1114 debugMenu, $"Use Valgrind", d, disabled = true, checkable = true;
1115 bool NotifySelect(MenuItem selection, Modifiers mods)
1119 ide.workspace.useValgrind = selection.checked;
1120 ide.workspace.Save();
1122 ide.AdjustValgrindMenus();
1126 Menu debugValgrindLeakCheckItem { debugMenu, $"Valgrind Leak Check", h };
1127 MenuItem debugValgrindNoLeakCheckItem { debugValgrindLeakCheckItem, $"No" , f, id = ValgrindLeakCheck::no , checkable = true, disabled = true; NotifySelect = ValgrindLCSelect; }
1128 MenuItem debugValgrindSummaryLeakCheckItem { debugValgrindLeakCheckItem, $"Summary", f, id = ValgrindLeakCheck::summary, checkable = true, disabled = true; NotifySelect = ValgrindLCSelect, checked = true; }
1129 MenuItem debugValgrindYesLeakCheckItem { debugValgrindLeakCheckItem, $"Yes" , f, id = ValgrindLeakCheck::yes , checkable = true, disabled = true; NotifySelect = ValgrindLCSelect; }
1130 MenuItem debugValgrindFullLeakCheckItem { debugValgrindLeakCheckItem, $"Full" , f, id = ValgrindLeakCheck::full , checkable = true, disabled = true; NotifySelect = ValgrindLCSelect; }
1131 bool ValgrindLCSelect(MenuItem selection, Modifiers mods)
1135 if(selection.checked)
1137 ValgrindLeakCheck vgLeakCheck = (ValgrindLeakCheck)selection.id;
1139 debugValgrindNoLeakCheckItem.checked = debugValgrindNoLeakCheckItem.id == vgLeakCheck;
1140 debugValgrindSummaryLeakCheckItem.checked = debugValgrindSummaryLeakCheckItem.id == vgLeakCheck;
1141 debugValgrindYesLeakCheckItem.checked = debugValgrindYesLeakCheckItem.id == vgLeakCheck;
1142 debugValgrindFullLeakCheckItem.checked = debugValgrindFullLeakCheckItem.id == vgLeakCheck;
1144 ide.workspace.vgLeakCheck = vgLeakCheck;
1145 ide.workspace.Save();
1148 selection.checked = true;
1152 Menu debugValgrindRedzoneSizeItem { debugMenu, $"Valgrind Redzone Size", z };
1153 MenuItem debugValgrindRSDefaultItem { debugValgrindRedzoneSizeItem, $"Default", f, id = -1, checkable = true, disabled = true; NotifySelect = ValgrindRSSelect, checked = true; }
1154 MenuItem debugValgrindRS0Item { debugValgrindRedzoneSizeItem, $"0" , f, id = 0, checkable = true, disabled = true; NotifySelect = ValgrindRSSelect; }
1155 MenuItem debugValgrindRS16Item { debugValgrindRedzoneSizeItem, $"16" , f, id = 16, checkable = true, disabled = true; NotifySelect = ValgrindRSSelect; }
1156 MenuItem debugValgrindRS32Item { debugValgrindRedzoneSizeItem, $"32" , f, id = 32, checkable = true, disabled = true; NotifySelect = ValgrindRSSelect; }
1157 MenuItem debugValgrindRS64Item { debugValgrindRedzoneSizeItem, $"64" , f, id = 64, checkable = true, disabled = true; NotifySelect = ValgrindRSSelect; }
1158 MenuItem debugValgrindRS128Item { debugValgrindRedzoneSizeItem, $"128" , f, id = 128, checkable = true, disabled = true; NotifySelect = ValgrindRSSelect; }
1159 MenuItem debugValgrindRS256Item { debugValgrindRedzoneSizeItem, $"256" , f, id = 256, checkable = true, disabled = true; NotifySelect = ValgrindRSSelect; }
1160 MenuItem debugValgrindRS512Item { debugValgrindRedzoneSizeItem, $"512" , f, id = 512, checkable = true, disabled = true; NotifySelect = ValgrindRSSelect; }
1161 bool ValgrindRSSelect(MenuItem selection, Modifiers mods)
1165 if(selection.checked)
1167 int vgRedzoneSize = (int)selection.id;
1169 debugValgrindRSDefaultItem.checked = debugValgrindRSDefaultItem.id == vgRedzoneSize;
1170 debugValgrindRS0Item.checked = debugValgrindRS0Item.id == vgRedzoneSize;
1171 debugValgrindRS16Item.checked = debugValgrindRS16Item.id == vgRedzoneSize;
1172 debugValgrindRS32Item.checked = debugValgrindRS32Item.id == vgRedzoneSize;
1173 debugValgrindRS64Item.checked = debugValgrindRS64Item.id == vgRedzoneSize;
1174 debugValgrindRS128Item.checked = debugValgrindRS128Item.id == vgRedzoneSize;
1175 debugValgrindRS256Item.checked = debugValgrindRS256Item.id == vgRedzoneSize;
1176 debugValgrindRS512Item.checked = debugValgrindRS512Item.id == vgRedzoneSize;
1178 ide.workspace.vgRedzoneSize = vgRedzoneSize;
1179 ide.workspace.Save();
1182 selection.checked = true;
1186 MenuItem debugValgrindTrackOriginsItem
1188 debugMenu, $"Valgrind Track Origins", k, checkable = true, disabled = true;
1189 bool NotifySelect(MenuItem selection, Modifiers mods)
1193 ide.workspace.vgTrackOrigins = selection.checked;
1194 ide.workspace.Save();
1200 MenuDivider { debugMenu };
1201 MenuItem debugStepIntoItem
1203 debugMenu, $"Step Into", i, f11, disabled = true;
1204 bitmap = { ":actions/stepInto.png" };
1205 bool NotifySelect(MenuItem selection, Modifiers mods)
1208 projectView.DebugStepInto();
1212 MenuItem debugStepOverItem
1214 debugMenu, $"Step Over", v, f10, disabled = true;
1215 bitmap = { ":actions/stepOver.png" };
1216 bool NotifySelect(MenuItem selection, Modifiers mods)
1219 projectView.DebugStepOver(false);
1223 MenuItem debugStepOutItem
1225 debugMenu, $"Step Out", o, shiftF11, disabled = true;
1226 bitmap = { ":actions/stepOut.png" };
1227 bool NotifySelect(MenuItem selection, Modifiers mods)
1230 projectView.DebugStepOut(false);
1234 MenuPlacement debugRunToCursorItem { debugMenu, $"Run To Cursor", c };
1235 MenuItem debugSkipStepOverItem
1237 debugMenu, $"Step Over Skipping Breakpoints", e, shiftF10, disabled = true;
1238 bool NotifySelect(MenuItem selection, Modifiers mods)
1241 projectView.DebugStepOver(true);
1245 MenuItem debugSkipStepOutItem
1247 debugMenu, $"Step Out Skipping Breakpoints", t, Key { f11, ctrl = true, shift = true }, disabled = true;
1248 bitmap = { ":actions/skipBreaks.png" };
1249 bool NotifySelect(MenuItem selection, Modifiers mods)
1252 projectView.DebugStepOut(true);
1256 MenuPlacement debugSkipRunToCursorItem { debugMenu, $"Run To Cursor Skipping Breakpoints", u };
1257 MenuPlacement debugSkipRunToCursorAtSameLevelItem { debugMenu, $"Run To Cursor At Same Level Skipping Breakpoints", l };
1258 //MenuDivider { debugMenu };
1259 //MenuPlacement debugToggleBreakpoint { debugMenu, "Toggle Breakpoint", t };
1260 MenuPlacement imageMenu { menu, $"Image", i };
1261 Menu viewMenu { menu, $"View", v };
1262 MenuItem viewProjectItem
1264 viewMenu, $"Project View", j, alt0, disabled = true;
1265 bool NotifySelect(MenuItem selection, Modifiers mods)
1269 projectView.visible = true;
1270 projectView.Activate();
1275 MenuPlacement { viewMenu, $"View Designer" };
1276 MenuPlacement { viewMenu, $"View Code" };
1277 MenuPlacement { viewMenu, $"View Properties" };
1278 MenuPlacement { viewMenu, $"View Methods" };
1279 MenuItem viewDesignerItem
1281 viewMenu, $"View Designer", d, f8;
1282 bool NotifySelect(MenuItem selection, Modifiers mods)
1284 Window client = activeClient;
1285 Class dataType = client._class;
1286 if(!strcmp(dataType.name, "Designer"))
1288 client.visible = true;
1292 ((CodeEditor)client).ViewDesigner();
1296 MenuItem viewCodeItem
1298 viewMenu, $"View Code", c, f8;
1299 bool NotifySelect(MenuItem selection, Modifiers mods)
1301 Window client = activeClient;
1302 Class dataType = client._class;
1303 if(!strcmp(dataType.name, "Designer"))
1304 client = ((Designer)client).codeEditor;
1307 // Do this after so the caret isn't moved yet...
1308 client.visible = true;
1312 MenuItem viewPropertiesItem
1314 viewMenu, $"View Properties", p, f4;
1315 bool NotifySelect(MenuItem selection, Modifiers mods)
1317 sheet.visible = true;
1318 sheet.sheetSelected = properties;
1323 MenuItem viewMethodsItem
1325 viewMenu, $"View Methods", m, f4;
1326 bool NotifySelect(MenuItem selection, Modifiers mods)
1328 sheet.visible = true;
1329 sheet.sheetSelected = methods;
1334 MenuItem viewToolBoxItem
1336 viewMenu, $"View Toolbox", x, f12;
1337 bool NotifySelect(MenuItem selection, Modifiers mods)
1339 toolBox.visible = true;
1344 MenuItem viewOutputItem
1346 viewMenu, $"Output", o, alt2;
1347 bool NotifySelect(MenuItem selection, Modifiers mods)
1353 MenuItem viewWatchesItem
1355 viewMenu, $"Watches", w, alt3;
1356 bool NotifySelect(MenuItem selection, Modifiers mods)
1362 MenuItem viewThreadsItem
1364 viewMenu, $"Threads", t, alt4;
1365 bool NotifySelect(MenuItem selection, Modifiers mods)
1371 MenuItem viewBreakpointsItem
1373 viewMenu, $"Breakpoints", b, alt5;
1374 bool NotifySelect(MenuItem selection, Modifiers mods)
1376 breakpointsView.Show();
1380 MenuItem viewCallStackItem
1382 viewMenu, $"Call Stack", s, alt7;
1383 bool NotifySelect(MenuItem selection, Modifiers mods)
1385 callStackView.Show();
1389 MenuItem viewAllDebugViews
1391 viewMenu, $"All Debug Views", a, alt9;
1392 bool NotifySelect(MenuItem selection, Modifiers mods)
1397 callStackView.Show();
1398 breakpointsView.Show();
1402 #ifdef GDB_DEBUG_GUI
1403 MenuDivider { viewMenu };
1404 MenuItem viewGDBItem
1406 viewMenu, $"GDB Dialog", g, Key { f9, shift = true, ctrl = true };
1407 bool NotifySelect(MenuItem selection, Modifiers mods)
1414 MenuDivider { viewMenu };
1415 MenuItem viewColorPicker
1417 viewMenu, $"Color Picker...", c, Key { c, ctrl = true , shift = true };
1418 bool NotifySelect(MenuItem selection, Modifiers mods)
1420 ColorPicker colorPicker { master = this };
1421 colorPicker.Modal();
1425 MenuDivider { viewMenu };
1429 viewMenu, "Full Screen", f, checkable = true;
1431 bool NotifySelect(MenuItem selection, Modifiers mods)
1433 app.fullScreen ^= true;
1435 anchor = { 0, 0, 0, 0 };
1440 Menu driversMenu { viewMenu, $"Graphics Driver", v };
1441 //Menu skinsMenu { viewMenu, "GUI Skins", k };
1442 Menu windowMenu { menu, $"Window", w };
1443 MenuItem { windowMenu, $"Close All", l, NotifySelect = MenuWindowCloseAll };
1444 MenuDivider { windowMenu };
1445 MenuItem { windowMenu, $"Next", n, f6, NotifySelect = MenuWindowNext };
1446 MenuItem { windowMenu, $"Previous", p, shiftF6, NotifySelect = MenuWindowPrevious };
1447 MenuDivider { windowMenu };
1448 MenuItem { windowMenu, $"Cascade", c, NotifySelect = MenuWindowCascade };
1449 MenuItem { windowMenu, $"Tile Horizontally", h, NotifySelect = MenuWindowTileHorz };
1450 MenuItem { windowMenu, $"Tile Vertically", v, NotifySelect = MenuWindowTileVert };
1451 MenuItem { windowMenu, $"Arrange Icons", a, NotifySelect = MenuWindowArrangeIcons };
1452 MenuDivider { windowMenu };
1453 MenuItem { windowMenu, $"Windows...", w, NotifySelect = MenuWindowWindows };
1454 Menu helpMenu { menu, $"Help", h };
1457 helpMenu, $"API Reference", r, f1;
1458 bool NotifySelect(MenuItem selection, Modifiers mods)
1462 char * p = new char[MAX_LOCATION];
1464 strncpy(p, settingsContainer.moduleLocation, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
1465 PathCat(p, "documentor");
1466 #if defined(__WIN32__)
1467 ChangeExtension(p, "exe", p);
1469 if(!FileExists(p).isFile)
1470 strcpy(p, "documentor");
1472 documentor = DualPipeOpen({ input = true, output = true, showWindow = true }, p);
1477 Process_ShowWindows(documentor.GetProcessID());
1478 // documentor.Puts("Activate\n");
1483 MenuDivider { helpMenu };
1486 helpMenu, $"Ecere Tao of Programming [work in progress]", t;
1487 bool NotifySelect(MenuItem selection, Modifiers mods)
1489 FindAndShellOpenInstalledFile("doc", "Ecere Tao of Programming [work in progress].pdf");
1493 MenuDivider { helpMenu };
1496 helpMenu, $"Documentation Folder", d;
1497 bool NotifySelect(MenuItem selection, Modifiers mods)
1499 FindAndShellOpenInstalledFolder("doc");
1505 helpMenu, $"Samples Folder", s;
1506 bool NotifySelect(MenuItem selection, Modifiers mods)
1508 FindAndShellOpenInstalledFolder("samples");
1514 helpMenu, $"Extras Folder", x;
1515 bool NotifySelect(MenuItem selection, Modifiers mods)
1517 FindAndShellOpenInstalledFolder("extras");
1521 MenuDivider { helpMenu };
1524 helpMenu, $"Community Forums", f;
1525 bool NotifySelect(MenuItem selection, Modifiers mods)
1527 ShellOpen("http://ecere.com/forums");
1531 MenuDivider { helpMenu };
1534 helpMenu, $"About...", a;
1535 bool NotifySelect(MenuItem selection, Modifiers mods)
1537 AboutIDE { master = this }.Modal();
1542 property ToolBox toolBox
1544 get { return toolBox; }
1547 property Sheet sheet
1549 get { return sheet; }
1552 property Project project
1554 get { return projectView ? projectView.project : null; }
1557 property Workspace workspace
1559 get { return projectView ? projectView.workspace : null; }
1562 FindInFilesDialog findInFilesDialog
1565 filters = findInFilesFileFilters.array, sizeFilters = findInFilesFileFilters.count * sizeof(FileFilter);
1571 #ifdef GDB_DEBUG_GUI
1574 master = this, parent = this;
1575 //anchor = { left = 100, top = 100, right = 100, bottom = 100 };
1577 void OnCommand(char * string)
1580 ide.debugger.SendGDBCommand(string);
1585 bool NotifySelectDisplayDriver(MenuItem selection, Modifiers mods)
1587 //app.driver = app.drivers[selection.id];
1588 #if defined(__unix__) || defined(__APPLE__)
1589 app.driver = selection.id ? "OpenGL" : "X";
1591 app.driver = selection.id ? "OpenGL" : "GDI";
1593 delete ideSettings.displayDriver;
1594 ideSettings.displayDriver = CopyString(selection.id ? "OpenGL" : "Default");
1596 settingsContainer.Save();
1597 //SetDriverAndSkin();
1601 bool NotifySelectDisplaySkin(MenuItem selection, Modifiers mods)
1603 app.skin = app.skins[selection.id];
1608 void SetDriverAndSkin()
1611 for(c = 0; c < app.numSkins; c++)
1612 if(!strcmp(app.skins[c], app.skin))
1614 skinItems[c].checked = true;
1617 for(c = 0; c < app.numDrivers; c++)
1618 if(!strcmp(app.drivers[c], app.driver))
1620 driverItems[c].checked = true;
1625 ProjectView CreateProjectView(Workspace workspace, char * fileName)
1627 Project project = workspace.projects.firstIterator.data;
1628 projectView = ProjectView
1631 fileName = fileName;
1633 void NotifyDestroyed(Window window, DialogResult result)
1636 text = titleECEREIDE;
1641 projectView.Create();
1642 RepositionWindows(false);
1644 // Leave it after Create to avoid flicker due to seeing IDE without a project view
1645 projectView.workspace = workspace;
1646 projectView.project = project;
1647 ideMainFrame.SetText("%s - %s", project.topNode.name, titleECEREIDE);
1651 ide.breakpointsView.LoadFromWorkspace();
1652 ide.watchesView.LoadFromWorkspace();
1654 findInFilesDialog.projectNodeField.userData = projectView;
1657 char fileName[MAX_LOCATION];
1658 strcpy(fileName, project.topNode.path);
1659 PathCat(fileName, project.topNode.name);
1666 projectView.visible = false;
1667 if((!projectView || projectView.created == false || projectView.Destroy(0)) && MenuWindowCloseAll(null, 0))
1669 if(findInFilesDialog)
1671 char workingDir[MAX_LOCATION];
1672 GetWorkingDir(workingDir, MAX_LOCATION);
1673 findInFilesDialog.SearchStop();
1674 findInFilesDialog.currentDirectory = workingDir;
1676 ideMainFrame.text = titleECEREIDE;
1683 void RepositionWindows(bool expand)
1688 bool inDebugMode = debugger.isActive;
1689 bool callStackVisible = expand ? false : callStackView.visible;
1690 bool threadsVisible = expand ? false : threadsView.visible;
1691 bool watchesVisible = expand ? false : watchesView.visible;
1692 bool breakpointsVisible = expand ? false : breakpointsView.visible;
1693 bool toolBoxVisible = toolBox.visible;
1694 bool outputVisible = expand ? false : outputView.visible;
1695 int topDistance = (callStackVisible || threadsVisible) ? 200 : 0;
1696 int bottomDistance = (outputVisible || watchesVisible || breakpointsVisible) ? 240 : 0;
1698 for(child = firstChild; child; child = child.next)
1700 if(child._class == class(CodeEditor) || child._class == class(Designer) ||
1701 child._class == class(Sheet) || child._class == class(ProjectView))
1703 Anchor anchor = child.anchor;
1704 anchor.top = topDistance;
1705 anchor.bottom = bottomDistance;
1706 if(child._class == class(CodeEditor) || child._class == class(Designer))
1709 anchor.right = toolBoxVisible ? 150 : 0;
1711 child.anchor = anchor;
1715 if(child._class == class(OutputView) || child._class == class(CallStackView) || child._class == class(ThreadsView) || child._class == class(WatchesView) ||
1716 child._class == class(BreakpointsView))
1717 child.visible = false;
1720 // If this is not here, the IDE is not updated when doing Debug/Break then Alt-4 to show call stack (IDE not updated)
1725 bool ShowCodeEditor()
1728 activeClient.Activate();
1729 else if(projectView)
1731 projectView.visible = true;
1732 projectView.Activate();
1736 sheet.visible = true;
1742 void DocumentSaved(Window document, char * fileName)
1744 ideSettings.AddRecentFile(fileName);
1745 ide.UpdateRecentMenus();
1746 ide.AdjustFileMenus();
1747 settingsContainer.Save();
1750 bool Window::OnFileModified(FileChange fileChange, char * param)
1753 sprintf(temp, $"The document %s was modified by another application.\n"
1754 "Would you like to reload it and lose your changes?", this.fileName);
1755 if(MessageBox { type = yesNo, master = this/*.parent*/,
1756 text = $"Document has been modified", contents = temp }.Modal() == yes)
1758 bool noParsing = (this._class == class(CodeEditor) && ((CodeEditor)this).noParsing) ? true : false;
1759 char * fileName = CopyString(this.fileName);
1760 WindowState state = this.state;
1761 Anchor anchor = this.anchor;
1762 Size size = this.size;
1764 this.modifiedDocument = false;
1766 this = ide.OpenFile(fileName, normal, true, null, no, normal, noParsing);
1769 this.anchor = anchor;
1771 this.SetState(state, true, 0);
1779 void UpdateMakefiles()
1783 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
1784 for(prj : workspace.projects)
1785 projectView.ProjectUpdateMakefileForAllConfigs(prj);
1790 void UpdateCompilerConfigs(bool mute)
1792 UpdateToolBarActiveCompilers();
1795 bool silent = mute || (ide.projectView.buildInProgress == none ? false : true);
1796 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
1799 projectView.ShowOutputBuildLog(true);
1800 projectView.DisplayCompiler(compiler, false);
1802 for(prj : workspace.projects)
1803 projectView.ProjectPrepareCompiler(prj, compiler, silent);
1808 void UpdateToolBarActiveCompilers()
1810 toolBar.activeCompiler.Clear();
1811 for(compiler : ideSettings.compilerConfigs)
1813 DataRow row = toolBar.activeCompiler.AddString(compiler.name);
1814 if(workspace && workspace.compiler && !strcmp(compiler.name, workspace.compiler))
1815 toolBar.activeCompiler.currentRow = row;
1817 if(!toolBar.activeCompiler.currentRow && toolBar.activeCompiler.firstRow)
1818 toolBar.activeCompiler.SelectRow(toolBar.activeCompiler.firstRow);
1821 void UpdateToolBarActiveConfigs(bool selectionOnly)
1823 bool commonSelected = false;
1824 DataRow row = toolBar.activeConfig.currentRow;
1826 row = toolBar.activeConfig.FindRow(1);
1829 toolBar.activeConfig.Clear();
1830 row = toolBar.activeConfig.AddString($"(Mixed)");
1835 char * configName = null;
1838 Map<String, int> configs { }; // TOIMP: just need sort but using map until containers have sort
1839 for(prj : workspace.projects)
1841 for(cfg : prj.configurations)
1844 configs[cfg.name] = 1;
1849 toolBar.activeConfig.AddString(&name);
1853 if(projectView && projectView.project)
1855 for(prj : workspace.projects)
1857 if(prj.config && prj.config.name)
1859 configName = prj.config.name;
1865 commonSelected = true;
1866 for(prj : workspace.projects)
1868 if(prj.config && (!prj.config.name || strcmp(prj.config.name, configName)))
1870 commonSelected = false;
1878 commonSelected = false;
1879 for(row = toolBar.activeConfig.firstRow; row; row = row.next)
1881 if(!strcmp(row.string, configName))
1883 toolBar.activeConfig.currentRow = row;
1884 commonSelected = true;
1891 toolBar.activeConfig.Sort(null, 0);
1893 toolBar.activeConfig.currentRow = row;
1898 bool unavailable = !project;
1900 projectAddItem.disabled = unavailable;
1901 toolBar.buttonAddProject.disabled = unavailable;
1903 projectSettingsItem.disabled = unavailable;
1905 projectBrowseFolderItem.disabled = unavailable;
1907 viewProjectItem.disabled = unavailable;
1909 toolBar.activeConfig.disabled = unavailable;
1910 toolBar.activeCompiler.disabled = unavailable;
1911 toolBar.activeBitDepth.disabled = unavailable;
1914 debugUseValgrindItem.disabled = unavailable;
1915 AdjustValgrindMenus();
1924 void AdjustValgrindMenus()
1926 bool unavailable = !project || !debugUseValgrindItem.checked;
1927 debugValgrindNoLeakCheckItem.disabled = unavailable;
1928 debugValgrindSummaryLeakCheckItem.disabled = unavailable;
1929 debugValgrindYesLeakCheckItem.disabled = unavailable;
1930 debugValgrindFullLeakCheckItem.disabled = unavailable;
1932 debugValgrindTrackOriginsItem.disabled = unavailable;
1934 debugValgrindRSDefaultItem.disabled = unavailable;
1935 debugValgrindRS0Item.disabled = unavailable;
1936 debugValgrindRS16Item.disabled = unavailable;
1937 debugValgrindRS32Item.disabled = unavailable;
1938 debugValgrindRS64Item.disabled = unavailable;
1939 debugValgrindRS128Item.disabled = unavailable;
1940 debugValgrindRS256Item.disabled = unavailable;
1941 debugValgrindRS512Item.disabled = unavailable;
1945 property bool hasOpenedCodeEditors
1950 for(w = firstChild; w; w = w.next)
1951 if(w._class == class(CodeEditor) &&
1952 w.isDocument && !w.closing && w.visible && w.created &&
1953 w.fileName && w.fileName[0])
1959 void AdjustFileMenus()
1961 bool unavailable = project != null || !hasOpenedCodeEditors; // are they supported source code (ec, c, cpp, etc) ?
1963 projectQuickItem.disabled = unavailable;
1966 void AdjustBuildMenus()
1968 bool unavailable = project && projectView.buildInProgress;
1969 bool naForRun = unavailable || !project || project.GetTargetType(project.config) != executable;
1971 projectNewItem.disabled = unavailable;
1972 toolBar.buttonNewProject.disabled = unavailable;
1973 projectOpenItem.disabled = unavailable;
1974 toolBar.buttonOpenProject.disabled = unavailable;
1976 unavailable = !project || projectView.buildInProgress;
1978 projectCloseItem.disabled = unavailable;
1979 // toolBar.buttonCloseProject.disabled = unavailable;
1981 projectRunItem.disabled = naForRun;
1982 toolBar.buttonRun.disabled = naForRun;
1984 projectBuildItem.disabled = false;
1985 projectBuildItem.text = unavailable ? $"Stop Build" : $"Build";
1986 projectBuildItem.accelerator = unavailable ? Key { pauseBreak, ctrl = true } : f7;
1988 projectLinkItem.disabled = unavailable;
1989 toolBar.buttonReLink.disabled = unavailable;
1990 projectRebuildItem.disabled = unavailable;
1991 toolBar.buttonRebuild.disabled = unavailable;
1992 projectCleanItem.disabled = unavailable;
1993 toolBar.buttonClean.disabled = unavailable;
1994 projectCleanTargetItem.disabled = unavailable;
1995 projectRealCleanItem.disabled = unavailable;
1996 // toolBar.buttonRealClean.disabled = unavailable;
1997 projectRegenerateItem.disabled = unavailable;
1998 toolBar.buttonRegenerateMakefile.disabled = unavailable;
1999 #ifdef IDE_SHOW_INSTALL_MENU_BUTTON
2000 projectInstallItem.disabled = unavailable;
2001 toolBar.buttonInstall.disabled = unavailable;
2003 projectCompileItem.disabled = unavailable;
2005 AdjustPopupBuildMenus();
2008 void AdjustPopupBuildMenus()
2010 bool unavailable = !project || projectView.buildInProgress;
2012 if(projectView && projectView.popupMenu && projectView.popupMenu.menu && projectView.popupMenu.created)
2015 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectBuild, 0);
2018 menu.disabled = false;
2019 menu.text = unavailable ? $"Stop Build" : $"Build";
2020 menu.accelerator = unavailable ? Key { pauseBreak, ctrl = true } : f7;
2023 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectLink, 0); if(menu) menu.disabled = unavailable;
2024 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRebuild, 0); if(menu) menu.disabled = unavailable;
2025 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectCleanTarget, 0); if(menu) menu.disabled = unavailable;
2026 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectClean, 0); if(menu) menu.disabled = unavailable;
2027 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRealClean, 0); if(menu) menu.disabled = unavailable;
2028 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRegenerate, 0); if(menu) menu.disabled = unavailable;
2029 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectInstall, 0); if(menu) menu.disabled = unavailable;
2030 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRemove, 0); if(menu) menu.disabled = unavailable;
2031 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileClean, 0); if(menu) menu.disabled = unavailable;
2032 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileCompile, 0); if(menu) menu.disabled = unavailable;
2033 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugPrecompile, 0); if(menu) menu.disabled = unavailable;
2034 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugCompile, 0); if(menu) menu.disabled = unavailable;
2035 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugGenerateSymbols, 0); if(menu) menu.disabled = unavailable;
2036 projectView.popupMenu.Update(null);
2040 property bool areDebugMenusUnavailable { get {
2042 project.GetTargetType(project.config) != executable ||
2043 projectView.buildInProgress == buildingMainProject;
2046 property bool isBreakpointTogglingUnavailable { get {
2050 property bool isDebuggerExecuting { get {
2054 return ide.debugger.state == running;
2057 void AdjustDebugMenus()
2059 bool unavailable = areDebugMenusUnavailable;
2060 bool active = debugger.isActive;
2061 bool bpNoToggle = isBreakpointTogglingUnavailable;
2062 bool executing = isDebuggerExecuting;
2063 //bool holding = debugger.state == stopped;
2065 debugStartResumeItem.disabled = unavailable || executing;
2066 debugStartResumeItem.text = active ? $"Resume" : $"Start";
2067 debugStartResumeItem.NotifySelect = active ? MenuDebugResume : MenuDebugStart;
2070 toolBar.buttonDebugStartResume.disabled = unavailable || executing;
2071 toolBar.buttonDebugStartResume.toolTip = active ? $"Resume" : $"Start";
2074 debugBreakItem.disabled = unavailable || !executing;
2075 debugStopItem.disabled = unavailable || !active;
2076 debugRestartItem.disabled = unavailable || !active;
2079 toolBar.buttonDebugPause.disabled = unavailable || !executing;
2080 toolBar.buttonDebugStop.disabled = unavailable || !active;
2081 toolBar.buttonDebugRestart.disabled = unavailable || !active;
2084 debugStepIntoItem.disabled = unavailable || executing;
2085 debugStepOverItem.disabled = unavailable || executing;
2086 debugStepOutItem.disabled = unavailable || executing || !active;
2087 debugSkipStepOverItem.disabled = unavailable || executing;
2088 debugSkipStepOutItem.disabled = unavailable || executing || !active;
2091 toolBar.buttonDebugStepInto.disabled = unavailable || executing;
2092 toolBar.buttonDebugStepOver.disabled = unavailable || executing;
2093 toolBar.buttonDebugStepOut.disabled = unavailable || executing || !active;
2094 toolBar.buttonDebugSkipStepOver.disabled = unavailable || executing;
2095 // toolBar.buttonDebugSkipStepOutItem.disabled = unavailable || executing;
2097 if((Designer)GetActiveDesigner())
2099 CodeEditor codeEditor = ((Designer)GetActiveDesigner()).codeEditor;
2101 codeEditor.AdjustDebugMenus(unavailable, bpNoToggle, executing);
2105 void ChangeFileDialogsDirectory(char * directory, bool saveSettings)
2107 char tempString[MAX_LOCATION];
2108 strcpy(tempString, directory);
2109 if(saveSettings && !projectView)
2111 ideSettings.ideFileDialogLocation = directory;
2112 settingsContainer.Save();
2115 ideFileDialog.currentDirectory = tempString;
2116 codeEditorFileDialog.currentDirectory = tempString;
2117 codeEditorFormFileDialog.currentDirectory = tempString;
2120 void ChangeProjectFileDialogDirectory(char * directory)
2122 ideSettings.ideProjectFileDialogLocation = directory;
2123 settingsContainer.Save();
2126 Window FindWindow(char * filePath)
2128 Window document = null;
2130 // TOCHECK: Do we need to change slashes here?
2131 for(document = firstChild; document; document = document.next)
2133 char * fileName = document.fileName;
2134 if(document.isDocument && fileName && !fstrcmp(fileName, filePath))
2136 document.visible = true;
2137 document.Activate();
2144 bool DontTerminateDebugSession(char * title)
2146 if(debugger.isActive)
2148 if(MessageBox { type = yesNo, master = ide,
2149 contents = $"Do you want to terminate the debugging session in progress?",
2150 text = title }.Modal() == no)
2153 MessageBox msg { type = yesNo, master = ide,
2154 contents = "Do you want to terminate the debugging session in progress?",
2156 if(msg.Modal() == no)
2168 Window OpenFile(char * origFilePath, WindowState state, bool visible, char * type, OpenCreateIfFails createIfFails, OpenMethod openMethod, bool noParsing)
2170 char extension[MAX_EXTENSION] = "";
2171 Window document = null;
2172 bool isProject = false;
2173 bool needFileModified = true;
2174 char winFilePath[MAX_LOCATION];
2175 char * filePath = strstr(origFilePath, "http://") == origFilePath ? strcpy(winFilePath, origFilePath) : GetSystemPathBuffer(winFilePath, origFilePath);
2179 GetExtension(filePath, extension);
2183 strcpy(extension, type);
2185 if(strcmp(extension, ProjectExtension))
2187 for(document = firstChild; document; document = document.next)
2189 char * fileName = document.fileName;
2190 if(document.isDocument && fileName && !fstrcmp(fileName, filePath) && document.created)
2192 document.visible = true;
2194 document.Activate();
2200 if(createIfFails == whatever)
2202 else if(!strcmp(extension, ProjectExtension) || !strcmp(extension, WorkspaceExtension))
2204 needFileModified = false;
2205 if(openMethod == normal)
2207 if(DontTerminateDebugSession($"Open Project"))
2217 Workspace workspace = null;
2219 if(FileExists(filePath))
2221 if(!strcmp(extension, ProjectExtension))
2223 char workspaceFile[MAX_LOCATION];
2224 strcpy(workspaceFile, filePath);
2225 ChangeExtension(workspaceFile, WorkspaceExtension, workspaceFile);
2226 workspace = LoadWorkspace(workspaceFile, filePath);
2228 else if(!strcmp(extension, WorkspaceExtension))
2229 workspace = LoadWorkspace(filePath, null);
2232 //project = LoadProject(filePath, null);
2237 char absolutePath[MAX_LOCATION];
2238 CreateProjectView(workspace, filePath);
2239 document = projectView;
2241 workspace.DropInvalidBreakpoints();
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);
2318 if(projectView.debugger)
2319 projectView.debugger.EvaluateWatches();
2326 if(MessageBox { type = yesNo, master = this, text = $"Error opening project", contents = $"Open a different project?" }.Modal() == yes)
2328 ideProjectFileDialog.text = openProjectFileDialogTitle;
2329 if(ideProjectFileDialog.Modal() == cancel)
2331 filePath = ideProjectFileDialog.filePath;
2332 GetExtension(filePath, extension);
2343 else if(openMethod == add)
2348 char slashFilePath[MAX_LOCATION];
2349 GetSlashPathBuffer(slashFilePath, filePath);
2350 for(p : workspace.projects)
2352 if(!fstrcmp(p.filePath, slashFilePath))
2360 MessageBox { type = ok, parent = parent, master = this, text = $"Same Project",
2361 contents = $"This project is already present in workspace." }.Modal();
2365 prj = LoadProject(filePath, null);
2368 char * activeConfigName = null;
2369 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
2370 prj.StartMonitoring();
2371 workspace.projects.Add(prj);
2372 if(toolBar.activeConfig.currentRow && toolBar.activeConfig.currentRow != toolBar.activeConfig.firstRow &&
2373 toolBar.activeConfig.currentRow.string && toolBar.activeConfig.currentRow.string[0])
2374 activeConfigName = toolBar.activeConfig.currentRow.string;
2375 if(activeConfigName)
2377 for(cfg : prj.configurations)
2379 if(cfg.name && !strcmp(cfg.name, activeConfigName))
2387 projectView.AddNode(prj.topNode, null);
2388 workspace.modified = true;
2390 findInFilesDialog.AddProjectItem(prj);
2391 projectView.ShowOutputBuildLog(true);
2392 projectView.DisplayCompiler(compiler, false);
2393 projectView.ProjectUpdateMakefileForAllConfigs(prj);
2397 char location[MAX_LOCATION];
2398 StripLastDirectory(prj.topNode.path, location);
2399 ChangeProjectFileDialogDirectory(location);
2402 // projectView is associated with the main project and not with the one just added but
2403 return projectView; // just to let the caller know something was opened
2411 else if(!strcmp(extension, "bmp") || !strcmp(extension, "pcx") ||
2412 !strcmp(extension, "jpg") || !strcmp(extension, "gif") ||
2413 !strcmp(extension, "jpeg") || !strcmp(extension, "png"))
2415 if(FileExists(filePath))
2416 document = PictureEdit { hasMaximize = true, hasMinimize = true, hasClose = true, borderStyle = sizable,
2417 hasVertScroll = true, hasHorzScroll = true, parent = this, state = state,
2418 visible = visible, bitmapFile = filePath, OnClose = PictureEditOnClose/*why?--GenericDocumentOnClose*/;
2421 MessageBox { type = ok, master = this, text = filePath, contents = $"File doesn't exist." }.Modal();
2424 else if(!strcmp(extension, "3ds"))
2426 if(FileExists(filePath))
2427 document = ModelView { hasMaximize = true, hasMinimize = true, hasClose = true, borderStyle = sizable,
2428 hasVertScroll = true, hasHorzScroll = true, parent = this, state = state,
2429 visible = visible, modelFile = filePath, OnClose = ModelViewOnClose/*why?--GenericDocumentOnClose*/
2433 MessageBox { type = ok, master = this, text = filePath, contents = $"File doesn't exist." }.Modal();
2436 else if(!strcmp(extension, "txt") || !strcmp(extension, "text") ||
2437 !strcmp(extension, "nfo") || !strcmp(extension, "info") ||
2438 !strcmp(extension, "htm") || !strcmp(extension, "html") ||
2439 !strcmp(extension, "css") || !strcmp(extension, "php") ||
2440 !strcmp(extension, "js"))
2442 CodeEditor editor { parent = this, state = state, visible = false, noParsing = noParsing };
2443 editor.updatingCode = true;
2444 if(editor.LoadFile(filePath))
2447 editor.visible = true;
2451 needFileModified = false;
2455 CodeEditor editor { parent = this, state = state, visible = false, noParsing = noParsing };
2456 if(editor.LoadFile(filePath))
2459 editor.visible = true;
2463 needFileModified = false;
2466 if(document && (document._class == class(PictureEdit) ||
2467 document._class == class(ModelView)))
2472 document.fileName = filePath;
2473 if(workspace && !workspace.holdTracking)
2474 workspace.UpdateOpenedFileInfo(filePath, opened);
2478 if(!document && createIfFails != no)
2480 if(createIfFails != yes && !needFileModified &&
2481 MessageBox { type = yesNo, master = this, text = filePath, contents = $"File doesn't exist. Create?" }.Modal() == yes)
2482 createIfFails = yes;
2483 if(createIfFails == yes || createIfFails == whatever)
2485 document = (Window)NewCodeEditor(this, state, true);
2487 document.fileName = filePath;
2493 if(projectView && document._class == class(CodeEditor) && workspace)
2495 int lineNumber, position;
2497 CodeEditor editor = (CodeEditor)document;
2498 editor.openedFileInfo = workspace.UpdateOpenedFileInfo(filePath, opened);
2499 editor.openedFileInfo.holdTracking = true;
2500 lineNumber = Max(editor.openedFileInfo.lineNumber - 1, 0);
2501 position = Max(editor.openedFileInfo.position - 1, 0);
2502 editor.editBox.GoToLineNum(lineNumber);
2503 editor.editBox.GoToPosition(editor.editBox.line, lineNumber, position);
2504 scroll.x = Max(editor.openedFileInfo.scroll.x, 0);
2505 scroll.y = Max(editor.openedFileInfo.scroll.y, 0);
2506 editor.editBox.scroll = scroll;
2507 editor.openedFileInfo.holdTracking = false;
2510 if(needFileModified)
2511 document.OnFileModified = OnFileModified;
2512 document.NotifySaved = DocumentSaved;
2515 ideSettings.AddRecentProject(document.fileName);
2517 ideSettings.AddRecentFile(document.fileName);
2518 ide.UpdateRecentMenus();
2519 ide.AdjustFileMenus();
2520 settingsContainer.Save();
2528 // TOCHECK: I can't use a generic one for both ModelView and PictureEdit both derived from Window
2529 /*bool Window::GenericDocumentOnClose(bool parentClosing)
2531 if(!parentClosing && ide.workspace)
2532 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2535 bool ModelView::ModelViewOnClose(bool parentClosing)
2537 if(!parentClosing && ide.workspace)
2538 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2541 bool PictureEdit::PictureEditOnClose(bool parentClosing)
2543 if(!parentClosing && ide.workspace)
2544 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2549 void OnUnloadGraphics(Window window)
2551 display.ClearMaterials();
2552 display.ClearTextures();
2553 display.ClearMeshes();
2557 bool OnActivate(bool active, Window swap, bool * goOnWithActivation, bool direct)
2559 caps.color = app.GetKeyState(capsState) ? black : Color { 128,128,128 };
2560 num.color = app.GetKeyState(numState) ? black : Color { 128,128,128 };
2564 bool OnKeyDown(Key key, unichar ch)
2569 projectView.Update(null);
2572 caps.color = app.GetKeyState(capsState) ? black : Color { 128,128,128 };
2575 num.color = app.GetKeyState(numState) ? black : Color { 128,128,128 };
2581 void GoToError(const char * line, bool noParsing)
2584 projectView.GoToError(line, noParsing);
2587 void CodeLocationParseAndGoTo(const char * text, Project project, const char * dir)
2591 char *colon = strchr(text, ':');
2592 char filePath[MAX_LOCATION] = "";
2593 char completePath[MAX_LOCATION];
2594 int line = 0, col = 0;
2595 int len = strlen(text);
2597 FileAttribs fileAttribs;
2599 // support for valgrind output
2600 if((s = strstr(text, "==")) && (s = strstr(s+2, "==")) && (s = strstr(s+2, ":")) && (s = strstr(s+1, ":")))
2611 /*for(s=colon; *s; s++)
2620 //line = atoi(colon+1);
2622 // support for "Found n match(es) in "file/path";
2623 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)
2629 if(colon && (colon[1] == '/' || colon[1] == '\\'))
2631 path = (colon - 1 > path) ? colon - 1 : path;
2632 colon = strstr(colon + 1, ":");
2634 if(*path == '*' && (s = strchr(path+1, '*')))
2636 while(isspace(*path)) path++;
2640 char * close = strchr(path, ')');
2644 strncpy(name, path+1, close - path - 1);
2645 name[close - path - 1] = '\0';
2646 for(p : ide.workspace.projects)
2648 if(!strcmp(p.name, name))
2658 prj = project ? project : (dir ? null : ide.project);
2661 strncpy(filePath, path, colon - path);
2662 filePath[colon - path] = '\0';
2663 line = atoi(colon + 1);
2664 colon = strstr(colon + 1, ":");
2666 col = atoi(colon + 1);
2668 else if(path - 1 >= text && *(path - 1) == '\"')
2670 colon = strchr(path, '\"');
2673 strncpy(filePath, path, colon - path);
2674 filePath[colon - path] = '\0';
2677 else if(path && !colon)
2679 strcpy(filePath, path);
2685 strcpy(completePath, prj.topNode.path);
2686 else if(dir && dir[0])
2687 strcpy(completePath, dir);
2689 completePath[0] = '\0';
2690 PathCat(completePath, filePath);
2692 if((fileAttribs = FileExists(completePath)))
2693 CodeLocationGoTo(completePath, fileAttribs, line, col);
2694 else if(ide.workspace)
2697 for(p : ide.workspace.projects)
2699 strcpy(completePath, p.topNode.path);
2700 PathCat(completePath, filePath);
2701 if((fileAttribs = FileExists(completePath)).isFile)
2703 CodeLocationGoTo(completePath, fileAttribs, line, col);
2710 for(p : ide.workspace.projects)
2712 ProjectNode node = p.topNode.Find(filePath, false);
2715 node.GetFullFilePath(completePath);
2716 if((fileAttribs = FileExists(completePath)).isFile)
2718 CodeLocationGoTo(completePath, fileAttribs, line, col);
2728 void CodeLocationGoTo(const char * path, const FileAttribs fileAttribs, int line, int col)
2730 if(fileAttribs.isFile)
2732 char ext[MAX_EXTENSION];
2733 GetExtension(path, ext);
2734 if(!strcmp(ext, "mp3") || !strcmp(ext, "flac") || !strcmp(ext, "ogg") || !strcmp(ext, "avi") || !strcmp(ext, "mkv"))
2736 else if(!strcmp(ext, "a") || !strcmp(ext, "o") || !strcmp(ext, "lib") || !strcmp(ext, "dll") || !strcmp(ext, "exe"))
2738 char dirPath[MAX_LOCATION];
2739 StripLastDirectory(path, dirPath);
2744 CodeEditor codeEditor = (CodeEditor)OpenFile(path, normal, true, ext, no, normal, false);
2745 if(codeEditor && line)
2747 EditBox editBox = codeEditor.editBox;
2748 editBox.GoToLineNum(line - 1);
2749 editBox.GoToPosition(editBox.line, line - 1, col ? (col - 1) : 0);
2753 else if(fileAttribs.isDirectory)
2757 void OnRedraw(Surface surface)
2759 Bitmap bitmap = back.bitmap;
2761 surface.Blit(bitmap, (clientSize.w - bitmap.width) / 2, (clientSize.h - bitmap.height) / 2, 0, 0, bitmap.width, bitmap.height);
2764 void SheetSelected(SheetType sheetSelected)
2766 if(activeChild == sheet)
2768 if(sheetSelected == methods)
2770 viewPropertiesItem.accelerator = f4;
2771 viewPropertiesItem.parent = viewMenu;
2772 viewMethodsItem.parent = null;
2776 viewMethodsItem.accelerator = f4;
2777 viewMethodsItem.parent = viewMenu;
2778 viewPropertiesItem.parent = null;
2783 viewMethodsItem.parent = viewMenu;
2784 viewPropertiesItem.parent = viewMenu;
2785 if(sheetSelected == methods)
2787 viewMethodsItem.accelerator = f4;
2788 viewPropertiesItem.accelerator = 0;
2792 viewMethodsItem.accelerator = 0;
2793 viewPropertiesItem.accelerator = f4;
2798 void OnActivateClient(Window client, Window previous)
2800 //if(!client || client != previous)
2803 if(!client || client != previous)
2806 dataType = previous._class;
2807 if(previous && !strcmp(dataType.name, "CodeEditor"))
2809 ((CodeEditor)previous).UpdateFormCode();
2811 else if(previous && !strcmp(dataType.name, "Designer"))
2813 ((Designer)previous).codeEditor.UpdateFormCode();
2818 dataType = client._class;
2819 if(client && !strcmp(dataType.name, "CodeEditor"))
2821 CodeEditor codeEditor = (CodeEditor)client;
2822 SetPrivateModule(codeEditor.privateModule);
2823 SetCurrentContext(codeEditor.globalContext);
2824 SetTopContext(codeEditor.globalContext);
2825 SetGlobalContext(codeEditor.globalContext);
2827 SetDefines(&codeEditor.defines);
2828 SetImports(&codeEditor.imports);
2830 SetActiveDesigner(codeEditor.designer);
2832 sheet.codeEditor = codeEditor;
2833 toolBox.codeEditor = codeEditor;
2835 viewDesignerItem.parent = viewMenu;
2836 if(activeChild != codeEditor)
2838 viewCodeItem.parent = viewMenu;
2839 viewDesignerItem.accelerator = 0;
2840 viewCodeItem.accelerator = f8;
2844 viewCodeItem.parent = null;
2845 viewDesignerItem.accelerator = f8;
2848 else if(client && !strcmp(dataType.name, "Designer"))
2850 CodeEditor codeEditor = ((Designer)client).codeEditor;
2853 SetPrivateModule(codeEditor.privateModule);
2854 SetCurrentContext(codeEditor.globalContext);
2855 SetTopContext(codeEditor.globalContext);
2856 SetGlobalContext(codeEditor.globalContext);
2857 SetDefines(&codeEditor.defines);
2858 SetImports(&codeEditor.imports);
2862 SetPrivateModule(null);
2863 SetCurrentContext(null);
2864 SetTopContext(null);
2865 SetGlobalContext(null);
2870 SetActiveDesigner((Designer)client);
2872 sheet.codeEditor = codeEditor;
2873 toolBox.codeEditor = codeEditor;
2875 viewCodeItem.parent = viewMenu;
2876 if(activeChild != client)
2878 viewDesignerItem.parent = viewMenu;
2879 viewDesignerItem.accelerator = f8;
2880 viewCodeItem.accelerator = 0;
2884 viewDesignerItem.parent = null;
2885 viewCodeItem.accelerator = f8;
2891 sheet.codeEditor = null;
2892 toolBox.codeEditor = null;
2893 SetActiveDesigner(null);
2895 viewDesignerItem.parent = null;
2896 viewCodeItem.parent = null;
2899 SheetSelected(sheet.sheetSelected);
2902 projectCompileItem = null;
2907 if(client && client._class == eSystem_FindClass(__thisModule, "CodeEditor")) // !strcmp(client._class.name, "CodeEditor")
2909 CodeEditor codeEditor = (CodeEditor)client;
2910 EditBox editBox = codeEditor.editBox;
2912 statusBar.AddField(pos);
2914 caps = { width = 40, text = $"CAPS", color = app.GetKeyState(capsState) ? black : Color { 128, 128, 128 } };
2915 statusBar.AddField(caps);
2917 ovr = { width = 30, text = $"OVR", color = (editBox && editBox.overwrite) ? black : Color { 128, 128, 128 } };
2918 statusBar.AddField(ovr);
2920 num = { width = 30, text = $"NUM", color = app.GetKeyState(numState) ? black : Color { 128, 128, 128 } };
2921 statusBar.AddField(num);
2923 //statusBar.text = "Ready";
2925 if(projectView && projectView.project)
2927 bool isCObject = false;
2928 ProjectNode node = projectView.GetNodeFromWindow(client, null, false, false);
2929 if(!node && (node = projectView.GetNodeFromWindow(client, null, false, true)))
2933 char nodeName[MAX_FILENAME];
2934 char name[MAX_FILENAME+96];
2936 ChangeExtension(node.name, "c", nodeName);
2937 sprintf(name, $"Compile %s", isCObject ? nodeName : node.name);
2938 projectCompileItem =
2940 copyText = true, text = name, c, ctrlF7, disabled = projectView.buildInProgress;
2942 bool NotifySelect(MenuItem selection, Modifiers mods)
2946 bool result = false;
2947 bool isCObject = false;
2948 ProjectNode node = null;
2949 for(p : ide.workspace.projects)
2951 node = projectView.GetNodeFromWindow(activeClient, p, true, false);
2954 if(!node && (node = projectView.GetNodeFromWindow(activeClient, null, true, true)))
2958 List<ProjectNode> nodes { };
2960 projectView.Compile(node.project, nodes, mods.ctrl && mods.shift, isCObject ? cObject : normal);
2965 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
2970 projectMenu.AddDynamic(projectCompileItem, ide, false);
2976 caps = ovr = num = null;
2981 bool OnClose(bool parentClosing)
2983 //return !projectView.buildInProgress;
2984 if(projectView && projectView.buildInProgress)
2986 if(DontTerminateDebugSession($"Close IDE"))
2988 if(findInFilesDialog)
2989 findInFilesDialog.SearchStop();
2992 workspace.timer.Stop();
2995 ideMainFrame.Destroy(0);
3002 bool passThrough = false;
3003 bool debugStart = false;
3004 bool debugWorkDir = false;
3005 char * passDebugWorkDir = null;
3006 bool openAsText = false;
3007 DynamicString passArgs { };
3010 for(c = 1; c<app.argc; c++)
3014 char * arg = app.argv[c];
3015 char * buf = new char[strlen(arg)*2+1];
3017 passArgs.concat(" ");
3019 passArgs.concat(buf);
3022 else if(debugWorkDir)
3024 passDebugWorkDir = CopyString(app.argv[c]);
3025 StripQuotes(passDebugWorkDir, passDebugWorkDir);
3026 debugWorkDir = false;
3028 else if(!strcmp(app.argv[c], "-t"))
3030 else if(!strcmp(app.argv[c], "-no-parsing"))
3031 ide.noParsing = true;
3032 else if(!strcmp(app.argv[c], "-debug-start"))
3034 else if(!strcmp(app.argv[c], "-debug-work-dir"))
3035 debugWorkDir = true;
3036 else if(!strcmp(app.argv[c], "-@"))
3040 char fullPath[MAX_LOCATION];
3041 char parentPath[MAX_LOCATION];
3042 char ext[MAX_EXTENSION];
3044 FileAttribs dirAttribs;
3045 GetWorkingDir(fullPath, MAX_LOCATION);
3046 PathCat(fullPath, app.argv[c]);
3047 StripLastDirectory(fullPath, parentPath);
3048 GetExtension(app.argv[c], ext);
3049 isProject = !openAsText && !strcmpi(ext, "epj");
3051 if(isProject && c > (debugStart ? 2 : 1)) continue;
3053 // Create directory for projects (only)
3054 if(((dirAttribs = FileExists(parentPath)) && dirAttribs.isDirectory) || isProject)
3056 if(isProject && !FileExists(fullPath))
3058 char name[MAX_LOCATION];
3059 NewProjectDialog newProjectDialog;
3063 projectView.visible = false;
3064 if(!projectView.Destroy(0))
3068 newProjectDialog = { master = this };
3070 strcpy(name, app.argv[c]);
3071 StripExtension(name);
3072 GetLastDirectory(name, name);
3073 newProjectDialog.projectName.contents = name;
3074 newProjectDialog.projectName.NotifyModified(newProjectDialog, newProjectDialog.projectName);
3075 newProjectDialog.locationEditBox.path = parentPath;
3076 newProjectDialog.NotifyModifiedLocation(newProjectDialog.locationEditBox);
3078 incref newProjectDialog;
3079 newProjectDialog.Modal();
3082 ideSettings.AddRecentProject(projectView.fileName);
3083 ide.UpdateRecentMenus();
3084 settingsContainer.Save();
3086 delete newProjectDialog;
3087 // Open only one project
3091 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, openAsText ? "txt" : null, yes, normal, false);
3093 else if(strstr(fullPath, "http://") == fullPath)
3094 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, openAsText ? "txt" : null, yes, normal, false);
3097 if(passThrough && projectView && projectView.project && workspace)
3098 workspace.commandLineArgs = passArgs;
3099 if(passDebugWorkDir && projectView && projectView.project && workspace)
3101 workspace.debugDir = passDebugWorkDir;
3102 delete passDebugWorkDir;
3105 ;//MenuDebugStart(debugStartResumeItem, 0); // <-- how TODO this without getting into the app.Wait lock
3107 UpdateToolBarActiveConfigs(false);
3108 UpdateToolBarActiveCompilers();
3115 // IS THIS NEEDED? WASN'T HERE BEFORE... Crashes on getting node's projectView otherwise
3118 projectView.visible = false;
3119 projectView.Destroy(0);
3122 #ifdef GDB_DEBUG_GUI
3123 gdbDialog.Destroy(0);
3128 void SetPath(bool projectsDirs, CompilerConfig compiler, ProjectConfig config, int bitDepth)
3132 char * oldPaths[128];
3133 String oldList = new char[maxPathLen];
3134 Array<String> newExePaths { };
3135 //Map<String, bool> exePathExists { };
3137 #if defined(__unix__) || defined(__APPLE__)
3138 Array<String> newLibPaths { };
3139 Map<String, bool> libPathExists { };
3144 for(prj : workspace.projects)
3146 DirExpression targetDirExp;
3148 // SKIP FIRST PROJECT...
3149 if(prj == workspace.projects.firstIterator.data) continue;
3151 // NOTE: Right now the additional project config dir will be
3152 // obtained when the debugger is started, so toggling it
3153 // while building will change which library gets used.
3154 // To go with the initial state, e.g. when F5 was pressed,
3155 // we nould need to keep a list of all project's active
3156 // config upon startup.
3157 targetDirExp = prj.GetTargetDir(compiler, prj.config, bitDepth);
3159 /*if(prj.config.targetType == sharedLibrary && prj.config.debug)
3163 for(cfg = prj.configurations.first; cfg; cfg = cfg.next)
3164 if(cfg.targetType == sharedLibrary && cfg.debug && !strcmpi(cfg.name, "Debug"))
3168 for(cfg = prj.configurations.first; cfg; cfg = cfg.next)
3169 if(cfg.targetType == sharedLibrary && cfg.debug)
3173 if(targetDirExp.dir)
3175 char buffer[MAX_LOCATION];
3176 #if defined(__WIN32__)
3177 Array<String> paths = newExePaths;
3179 Array<String> paths = newLibPaths;
3181 GetSystemPathBuffer(buffer, prj.topNode.path);
3182 PathCat(buffer, targetDirExp.dir);
3185 if(!fstrcmp(p, buffer))
3192 paths.Add(CopyString(buffer));
3194 delete targetDirExp;
3198 for(item : compiler.executableDirs)
3201 for(p : newExePaths)
3203 if(!fstrcmp(p, item))
3210 newExePaths.Add(CopySystemPath(item));
3213 GetEnvironment("PATH", oldList, maxPathLen);
3215 printf("Old value of PATH: %s\n", oldList);
3217 count = TokenizeWith(oldList, sizeof(oldPaths) / sizeof(char *), oldPaths, pathListSep, false);
3218 for(c = 0; c < count; c++)
3221 for(p : newExePaths)
3223 if(!fstrcmp(p, oldPaths[c]))
3230 newExePaths.Add(CopySystemPath(oldPaths[c]));
3234 for(path : newExePaths)
3235 len += strlen(path) + 1;
3236 newList = new char[len + 1];
3238 for(path : newExePaths)
3240 strcat(newList, path);
3241 strcat(newList, pathListSep);
3243 newList[len - 1] = '\0';
3244 SetEnvironment("PATH", newList);
3246 printf("New value of PATH: %s\n", newList);
3253 #if defined(__unix__) || defined(__APPLE__)
3255 for(item : compiler.libraryDirs)
3257 if(!libPathExists[item]) // fstrcmp should be used
3259 String s = CopyString(item);
3261 libPathExists[s] = true;
3265 #if defined(__APPLE__)
3266 GetEnvironment("DYLD_LIBRARY_PATH", oldList, maxPathLen);
3268 GetEnvironment("LD_LIBRARY_PATH", oldList, maxPathLen);
3271 printf("Old value of [DY]LD_LIBRARY_PATH: %s\n", oldList);
3273 count = TokenizeWith(oldList, sizeof(oldPaths) / sizeof(char *), oldPaths, pathListSep, false);
3274 for(c = 0; c < count; c++)
3276 if(!libPathExists[oldPaths[c]]) // fstrcmp should be used
3278 String s = CopyString(oldPaths[c]);
3280 libPathExists[s] = true;
3285 for(path : newLibPaths)
3286 len += strlen(path) + 1;
3287 newList = new char[len + 1];
3289 for(path : newLibPaths)
3291 strcat(newList, path);
3292 strcat(newList, pathListSep);
3294 newList[len - 1] = '\0';
3295 #if defined(__APPLE__)
3296 SetEnvironment("DYLD_LIBRARY_PATH", newList);
3298 SetEnvironment("LD_LIBRARY_PATH", newList);
3301 printf("New value of [DY]LD_LIBRARY_PATH: %s\n", newList);
3307 delete libPathExists;
3310 if(compiler.distccEnabled && compiler.distccHosts)
3311 SetEnvironment("DISTCC_HOSTS", compiler.distccHosts);
3316 void DestroyTemporaryProjectDir()
3318 if(tmpPrjDir && tmpPrjDir[0])
3320 if(FileExists(tmpPrjDir).isDirectory)
3321 DestroyDir(tmpPrjDir);
3322 property::tmpPrjDir = null;
3328 // Graphics Driver Menu
3332 app.currentSkin.selectionColor = selectionColor;
3333 app.currentSkin.selectionText = selectionText;
3337 driverItems = new MenuItem[app.numDrivers];
3338 for(c = 0; c < app.numDrivers; c++)
3340 driverItems[c] = MenuItem { driversMenu, app.drivers[c], NotifySelect = NotifySelectDisplayDriver };
3341 driverItems[c].id = c;
3342 driverItems[c].isRadio = true;
3345 driverItems = new MenuItem[2];
3346 #if defined(__unix__)
3347 driverItems[0] = MenuItem { driversMenu, "X", NotifySelect = NotifySelectDisplayDriver };
3348 driverItems[0].id = 0;
3349 driverItems[0].isRadio = true;
3351 driverItems[0] = MenuItem { driversMenu, "GDI", NotifySelect = NotifySelectDisplayDriver };
3352 driverItems[0].id = 0;
3353 driverItems[0].isRadio = true;
3355 driverItems[1] = MenuItem { driversMenu, "OpenGL", NotifySelect = NotifySelectDisplayDriver };
3356 driverItems[1].id = 1;
3357 driverItems[1].isRadio = true;
3359 /* skinItems = new MenuItem[app.numSkins];
3360 for(c = 0; c < app.numSkins; c++)
3362 skinItems[c] = MenuItem {skinsMenu, app.skins[c], NotifySelect = NotifySelectDisplaySkin };
3363 skinItems[c].id = c;
3364 skinItems[c].isRadio = true;
3367 ideFileDialog.master = this;
3368 ideProjectFileDialog.master = this;
3370 //SetDriverAndSkin();
3374 void UpdateRecentMenus()
3377 Menu fileMenu = menu.FindMenu($"File");
3378 Menu recentFiles = fileMenu.FindMenu($"Recent Files");
3379 Menu recentProjects = fileMenu.FindMenu($"Recent Projects");
3380 char * itemPath = new char[MAX_LOCATION];
3381 char * itemName = new char[MAX_LOCATION+4];
3384 recentFiles.Clear();
3387 for(recent : ideSettings.recentFiles)
3389 strncpy(itemPath, recent, MAX_LOCATION); itemPath[MAX_LOCATION-1] = '\0';
3390 MakeSystemPath(itemPath);
3391 snprintf(itemName, MAX_LOCATION+4, "%d %s", 1 + c, itemPath); itemName[MAX_LOCATION+4-1] = '\0';
3392 recentFiles.AddDynamic(MenuItem { copyText = true, text = itemName, (Key)k1 + c, id = c, NotifySelect = ide.FileRecentFile }, ide, true);
3396 recentProjects.Clear();
3398 for(recent : ideSettings.recentProjects)
3400 strncpy(itemPath, recent, MAX_LOCATION); itemPath[MAX_LOCATION-1] = '\0';
3401 MakeSystemPath(itemPath);
3402 snprintf(itemName, MAX_LOCATION+4, "%d %s", 1 + c, itemPath); itemName[MAX_LOCATION+4-1] = '\0';
3403 recentProjects.AddDynamic(MenuItem { copyText = true, text = itemName, (Key)k1 + c, id = c, NotifySelect = ide.FileRecentProject }, ide, true);
3418 documentor.Puts("Quit\n");
3425 void DestroyDir(char * path)
3427 RecursiveDeleteFolderFSI fsi { };
3432 #if defined(__WIN32__)
3433 define sdkDirName = "Ecere SDK";
3435 define sdkDirName = "ecere";
3438 void FindAndShellOpenInstalledFolder(char * name)
3440 char * p = new char[MAX_LOCATION];
3441 char * v = new char[maxPathLen];
3444 Array<String> paths { };
3446 strncpy(p, settingsContainer.moduleLocation, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3447 StripLastDirectory(p, p);
3449 paths.Add(CopyString(p));
3450 #if defined(__WIN32__)
3451 GetEnvironment("ECERE_SDK_SRC", v, maxPathLen);
3454 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3455 PathCat(p, name); paths.Add(CopyString(p));
3457 GetEnvironment("AppData", 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", 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("ProgramFiles(x86)", v, maxPathLen);
3472 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3473 PathCat(p, sdkDirName); PathCat(p, name); paths.Add(CopyString(p));
3475 GetEnvironment("SystemDrive", v, maxPathLen);
3478 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3479 PathCat(p, "Program Files"); PathCat(p, sdkDirName); PathCat(p, name); paths.Add(CopyString(p));
3482 GetEnvironment("XDG_DATA_DIRS", v, maxPathLen);
3483 numTokens = TokenizeWith(v, sizeof(tokens) / sizeof(byte *), tokens, ":", false);
3484 for(c=0; c<numTokens; c++)
3486 strncpy(p, tokens[c], MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3487 PathCat(p, sdkDirName); PathCat(p, name); paths.Add(CopyString(p));
3492 strncpy(p, path, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3493 if(FileExists(p).isDirectory)
3505 void FindAndShellOpenInstalledFile(char * subdir, char * name)
3507 char * p = new char[MAX_LOCATION];
3508 char * v = new char[maxPathLen];
3511 Array<String> paths { };
3513 strncpy(p, settingsContainer.moduleLocation, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3514 paths.Add(CopyString(p));
3515 StripLastDirectory(p, p);
3517 paths.Add(CopyString(p));
3518 #if defined(__WIN32__)
3519 GetEnvironment("ECERE_SDK_SRC", 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("AppData", 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", 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("ProgramFiles(x86)", v, maxPathLen);
3540 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3541 PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3543 GetEnvironment("SystemDrive", v, maxPathLen);
3546 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3547 PathCat(p, "Program Files"); PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3550 GetEnvironment("XDG_DATA_DIRS", v, maxPathLen);
3551 numTokens = TokenizeWith(v, sizeof(tokens) / sizeof(byte *), tokens, ":", false);
3552 for(c=0; c<numTokens; c++)
3554 strncpy(p, tokens[c], MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3555 PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3560 strncpy(p, path, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3562 if(FileExists(p).isFile)
3574 class RecursiveDeleteFolderFSI : NormalFileSystemIterator
3576 bool preserveRootFolder;
3578 void OutFolder(char * folderPath, bool isRoot)
3580 if(!(preserveRootFolder && isRoot))
3581 RemoveDir(folderPath);
3584 bool OnFile(char * filePath)
3586 DeleteFile(filePath);
3591 class IDEApp : GuiApplication
3593 //driver = "Win32Console";
3594 // driver = "OpenGL";
3598 TempFile includeFile { };
3602 char ext[MAX_EXTENSION];
3603 SetLoggingMode(stdOut, null);
3604 //SetLoggingMode(debug, null);
3606 settingsContainer.Load();
3607 if(argc > 1 && !strcmpi(GetExtension(argv[1], ext), "3ds"))
3609 app.driver = "OpenGL";
3610 ide.driverItems[1].checked = true;
3614 #if defined(__unix__) || defined(__APPLE__)
3615 app.driver = (ideSettings.displayDriver && !strcmp(ideSettings.displayDriver, "OpenGL")) ? ideSettings.displayDriver : "X";
3617 app.driver = (ideSettings.displayDriver && !strcmp(ideSettings.displayDriver, "OpenGL")) ? ideSettings.displayDriver : "GDI";
3619 ide.driverItems[ideSettings.displayDriver && !strcmp(ideSettings.displayDriver,"OpenGL")].checked = true;
3624 desktop.text = titleECEREIDE;
3627 for(c = 1; c<app.argc; c++)
3629 char fullPath[MAX_LOCATION];
3630 GetWorkingDir(fullPath, MAX_LOCATION);
3631 PathCat(fullPath, app.argv[c]);
3632 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, null, yes, normal, false);
3636 if(!LoadIncludeFile())
3637 PrintLn("error: unable to load :crossplatform.mk file inside ide binary.");
3642 bool Cycle(bool idle)
3646 if(ide.documentor.Peek())
3649 ide.documentor.GetLine(line, sizeof(line));
3650 if(!strcmpi(line, "Exited"))
3652 ide.documentor.CloseInput();
3653 ide.documentor.CloseOutput();
3654 ide.documentor.Wait();
3655 delete ide.documentor;
3658 if(ide.documentor && ide.documentor.eof)
3660 ide.documentor.CloseInput();
3661 ide.documentor.CloseOutput();
3662 ide.documentor.Wait();
3663 delete ide.documentor;
3669 bool LoadIncludeFile()
3671 bool result = false;
3672 File include = FileOpen(":crossplatform.mk", read);
3675 File f = includeFile;
3678 for(; !include.Eof(); )
3681 int count = include.Read(buffer, 1, 4096);
3682 f.Write(buffer, 1, count);
3692 IDEMainFrame ideMainFrame { };
3694 define app = ((IDEApp)__thisModule);
3696 define titleECEREIDE = $"ECERE IDE (Debug)";
3698 define titleECEREIDE = $"ECERE IDE";