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)
286 for(prj : ide.workspace.projects)
288 for(cfg : prj.configurations)
290 if(cfg.name && !strcmp(cfg.name, row.string))
297 ide.UpdateToolBarActiveConfigs(true);
298 ide.projectView.Update(null);
304 Window spacer6 { this, size = { 4 } };
306 DropBox activeCompiler
308 this, toolTip = $"Active Compiler", size = { 160 }, disabled = true;
309 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
311 if(ide.workspace && ide.projectView && row && strcmp(row.string, ide.workspace.compiler))
313 bool silent = ide.projectView.buildInProgress == none ? false : true;
314 CompilerConfig compiler = ideSettings.GetCompilerConfig(row.string);
315 ide.workspace.compiler = row.string;
316 ide.projectView.ShowOutputBuildLog(!silent);
318 ide.projectView.DisplayCompiler(compiler, false);
319 for(prj : ide.workspace.projects)
320 ide.projectView.ProjectPrepareCompiler(prj, compiler, silent);
322 ide.workspace.Save();
328 DropBox activeBitDepth
330 this, toolTip = $"Active Bit Depth", size = { 60 }, disabled = true;
331 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
333 if(ide.workspace && ide.projectView && row)
335 bool silent = ide.projectView.buildInProgress == none ? false : true;
336 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
337 ide.workspace.bitDepth = (int)row.tag;
338 ide.projectView.ShowOutputBuildLog(!silent);
340 ide.projectView.DisplayCompiler(compiler, false);
341 for(prj : ide.workspace.projects)
342 ide.projectView.ProjectPrepareCompiler(prj, compiler, silent);
344 ide.workspace.Save();
350 Window spacer7 { this, size = { 4 } };
355 row = activeBitDepth.AddString("Auto");
357 activeBitDepth.AddString("32 bit").tag = 32;
358 activeBitDepth.AddString("64 bit").tag = 64;
359 activeBitDepth.currentRow = row;
364 class IDEMainFrame : Window
366 background = formColor;
367 borderStyle = sizable;
371 minClientSize = { 600, 300 };
373 icon = { ":icon.png" };
374 text = titleECEREIDE;
378 anchor = { top = 0, right = 0, bottom = 0 };
381 anchor = { left = 0, top = 0, right = 0, bottom = 0 };
388 isActiveClient = true;
390 direction = vertical;
391 background = formColor;
392 anchor = { left = 0, top = 0, right = 0, bottom = 0 };
400 ((IDEWorkSpace)master).toolBar = null;
403 IDEWorkSpace ideWorkSpace { stack, this, toolBar = toolBar };
406 define ide = ideMainFrame.ideWorkSpace;
408 class IDEWorkSpace : Window
410 background = Color { 85, 85, 85 };
413 hasVertScroll = true;
414 hasHorzScroll = true;
416 isActiveClient = true;
417 anchor = { left = 0, top = 0, right = 0, bottom = 0 };
421 MenuItem * driverItems, * skinItems;
422 StatusField pos { width = 150 };
423 StatusField ovr, caps, num;
425 BitmapResource back { ":ecereBack.jpg", window = this };
426 BitmapResource bmpBp { ":codeMarks/breakpoint.png", window = this };
427 BitmapResource bmpBpDisabled { ":codeMarks/breakpointDisabled.png", window = this };
428 BitmapResource bmpBpHalf { ":codeMarks/breakpointHalf.png", window = this };
429 BitmapResource bmpBpHalfDisabled { ":codeMarks/breakpointHalfDisabled.png", window = this };
430 BitmapResource bmpCursor { ":codeMarks/cursor.png", window = this };
431 BitmapResource bmpCursorError { ":codeMarks/cursorError.png", window = this };
432 BitmapResource bmpTopFrame { ":codeMarks/topFrame.png", window = this };
433 BitmapResource bmpTopFrameError { ":codeMarks/topFrameError.png", window = this };
434 BitmapResource bmpTopFrameHalf { ":codeMarks/topFrameHalf.png", window = this };
435 BitmapResource bmpTopFrameHalfError { ":codeMarks/topFrameHalfError.png", window = this };
437 Debugger debugger { };
439 ProjectView projectView;
441 OutputView outputView
445 void OnGotoError(char * line, bool noParsing)
447 ide.GoToError(line, noParsing);
450 void OnCodeLocationParseAndGoTo(char * line)
452 ide.CodeLocationParseAndGoTo(line, ide.findInFilesDialog.findProject, ide.findInFilesDialog.findDir);
455 bool OnKeyDown(Key key, unichar ch)
460 if(activeBox != findBox || !ide.findInFilesDialog || !ide.findInFilesDialog.SearchAbort())
461 ide.ShowCodeEditor();
465 OutputView::OnKeyDown(key, ch);
472 bool OnClose(bool parentClosing)
476 ide.RepositionWindows(false);
477 return parentClosing;
481 CallStackView callStackView
483 parent = this, font = { panelFont.faceName, panelFont.size };
485 void OnSelectFrame(int frameIndex)
487 ide.debugger.GoToStackFrameLine(frameIndex, true);
489 ide.debugger.SelectFrame(frameIndex);
492 void OnToggleBreakpoint()
494 Debugger debugger = ide.debugger;
495 if(debugger.activeFrame && debugger.activeFrame.absoluteFile)
497 int line = debugger.activeFrame.line;
498 char name[MAX_LOCATION];
500 // TOFIX: Improve on this, don't use only filename, make a function
501 GetLastDirectory(debugger.activeFrame.absoluteFile, name);
502 if(ide && ide.workspace)
504 for(p : ide.workspace.projects)
506 if(p.topNode.Find(name, false))
514 for(p : ide.workspace.projects)
516 if(IsPathInsideOf(debugger.activeFrame.absoluteFile, p.topNode.path))
524 debugger.ToggleBreakpoint(debugger.activeFrame.absoluteFile, line, prj);
527 CodeEditor codeEditor = (CodeEditor)ide.FindWindow(debugger.activeFrame.absoluteFile);
528 if(codeEditor) { codeEditor.Update(null); Activate(); }
533 bool OnKeyDown(Key key, unichar ch)
537 case escape: ide.ShowCodeEditor(); break;
542 bool OnClose(bool parentClosing)
546 ide.RepositionWindows(false);
547 return parentClosing;
550 void OnRedraw(Surface surface)
552 Debugger debugger = ide.debugger;
553 Frame activeFrame = debugger.activeFrame;
557 int lineCursor, lineTopFrame, activeThread, hitThread;
558 int lineH, scrollY, boxH;
560 Breakpoint bp = null;
563 scrollY = editBox.scroll.y;
564 displaySystem.FontExtent(editBox.font.font, " ", 1, null, &lineH);
565 activeThread = debugger.activeThread;
566 hitThread = debugger.hitThread;
567 debugger.GetCallStackCursorLine(&error, &lineCursor, &lineTopFrame);
569 // TODO: improve bp drawing... it should be visible even if it's not on the activeFrame
570 if(activeFrame.absoluteFile)
572 for(i : ide.workspace.breakpoints; i.type == user)
574 if(i.absoluteFilePath && i.absoluteFilePath[0] &&
575 !fstrcmp(i.absoluteFilePath, activeFrame.absoluteFile) &&
576 activeFrame.line == i.line)
584 DrawLineMarginIcon(surface,
585 /*(lineCursor == 1 || lineTopFrame == 1) ? */ide.bmpBpHalf/* : ide.bmpBp*/,
586 lineCursor /*1*/, lineH, scrollY, boxH);
588 if(activeThread && activeThread == hitThread && debugger.bpHit && debugger.bpHit.type == user)
589 DrawLineMarginIcon(surface,
590 (lineCursor == 1 || lineTopFrame == 1) ? ide.bmpBpHalf : ide.bmpBp,
591 1, lineH, scrollY, boxH);
593 DrawLineMarginIcon(surface, error ? ide.bmpCursorError : ide.bmpCursor, lineCursor, lineH, scrollY, boxH);
594 if(bp && lineCursor == 1) //activeThread && activeThread == hitThread && debugger.bpHit && debugger.bpHit.type == user)
595 bmp = error ? ide.bmpTopFrameHalfError : ide.bmpTopFrameHalf;
597 bmp = error ? ide.bmpTopFrameError : ide.bmpTopFrame;
598 DrawLineMarginIcon(surface, bmp, lineTopFrame, lineH, scrollY, boxH);
600 if(editBox.horzScroll && editBox.horzScroll.visible)
602 surface.SetBackground(control);
603 surface.Area(0, editBox.clientSize.h, 20 - 1, clientSize.h - 1);
608 WatchesView watchesView { parent = this };
609 ThreadsView threadsView
611 parent = this, font = { panelFont.faceName, panelFont.size };
613 bool OnKeyDown(Key key, unichar ch)
617 case escape: ide.ShowCodeEditor(); break;
622 bool OnClose(bool parentClosing)
626 ide.RepositionWindows(false);
627 return parentClosing;
630 void OnSelectThread(int threadId)
633 ide.debugger.SelectThread(threadId);
636 bool OnGetThreadsInfo(int * activeThread, int * hitThread, int * signalThread)
639 Debugger debugger = ide.debugger;
640 *activeThread = debugger.activeThread;
641 *hitThread = debugger.hitThread;
642 *signalThread = debugger.signalThread;
647 BreakpointsView breakpointsView { parent = this };
649 ToolBox toolBox { parent = this };
650 Sheet sheet { parent = this };
653 property char * tmpPrjDir { set { delete tmpPrjDir; if(value) tmpPrjDir = CopyString(value); } get { return tmpPrjDir; } };
655 Menu fileMenu { menu, $"File", f, hasMargin = true };
658 fileMenu, $"New", n, ctrlN;
659 bitmap = { ":actions/docNew.png" };
660 bool NotifySelect(MenuItem selection, Modifiers mods)
662 Window document = (Window)NewCodeEditor(this, normal, false);
663 document.NotifySaved = DocumentSaved;
667 MenuItem fileOpenItem
669 fileMenu, $"Open...", o, ctrlO;
670 bitmap = { ":actions/docOpen.png" };
671 bool NotifySelect(MenuItem selection, Modifiers mods)
673 if(!projectView && ideSettings.ideFileDialogLocation)
674 ideFileDialog.currentDirectory = ideSettings.ideFileDialogLocation;
677 if(ideFileDialog.Modal() == ok)
679 bool gotWhatWeWant = false;
681 int numSelections = ideFileDialog.numSelections;
682 char ** multiFilePaths = ideFileDialog.multiFilePaths;
684 for(c = 0; c < numSelections; c++)
686 if(OpenFile(multiFilePaths[c], normal, true, fileTypes[ideFileDialog.fileType].typeExtension, no, normal, mods.ctrl && mods.shift))
687 gotWhatWeWant = true;
690 MessageBox { type = yesNo, master = this, text = $"Error opening file",
691 contents = $"Open a different file?" }.Modal() == no)
693 if(!projectView && gotWhatWeWant)
694 ChangeFileDialogsDirectory(ideFileDialog.currentDirectory, true);
695 ide.RepositionWindows(false);
705 MenuItem fileCloseItem { fileMenu, $"Close", c, ctrlF4, NotifySelect = MenuFileClose };
706 MenuDivider { fileMenu };
707 MenuItem fileSaveItem
709 fileMenu, $"Save", s, ctrlS, bitmap = { ":actions/docSave.png" };
711 // For the toolbar button; clients can still override that for the menu item
712 bool Window::NotifySelect(MenuItem selection, Modifiers mods)
714 Window w = activeClient;
716 w.MenuFileSave(null, 0);
720 MenuItem fileSaveAsItem { fileMenu, $"Save As...", a };
721 MenuItem fileSaveAllItem { fileMenu, $"Save All", l, NotifySelect = MenuFileSaveAll, bitmap = { ":actions/docSaveAll.png" } };
722 MenuDivider { fileMenu };
725 fileMenu, $"Find In Files...", f, Key { f, ctrl = true , shift = true };
726 bool NotifySelect(MenuItem selection, Modifiers mods)
728 findInFilesDialog.replaceMode = false;
729 findInFilesDialog.Show();
733 MenuItem replaceInFiles
735 fileMenu, $"Replace In Files...", e, Key { r, ctrl = true , shift = true };
736 bool NotifySelect(MenuItem selection, Modifiers mods)
738 findInFilesDialog.replaceMode = true;
739 findInFilesDialog.Show();
743 MenuDivider { fileMenu };
744 MenuItem globalSettingsItem
746 fileMenu, $"Global Settings...", g;
747 bool NotifySelect(MenuItem selection, Modifiers mods)
749 globalSettingsDialog.master = this;
750 if(ide.workspace && ide.workspace.compiler)
751 globalSettingsDialog.workspaceActiveCompiler = ide.workspace.compiler;
752 else if(ideSettings.defaultCompiler)
753 globalSettingsDialog.workspaceActiveCompiler = ideSettings.defaultCompiler;
754 globalSettingsDialog.Modal();
758 MenuDivider { fileMenu };
759 Menu recentFiles { fileMenu, $"Recent Files", r };
760 Menu recentProjects { fileMenu, $"Recent Projects", p };
761 MenuDivider { fileMenu };
764 fileMenu, $"Exit", x, altF4;
766 bool NotifySelect(MenuItem selection, Modifiers mods)
768 ideMainFrame.Destroy(0);
773 bool FileRecentFile(MenuItem selection, Modifiers mods)
776 for(file : ideSettings.recentFiles)
778 if(id == selection.id)
781 char extension[MAX_EXTENSION] = "";
782 GetExtension(file, extension);
783 isProjectFile = (!strcmpi(extension, "epj") || !strcmpi(extension, "ews"));
786 char * command = PrintString("ide ", isProjectFile ? "-t " : "", file);
792 OpenFile(file, normal, true, isProjectFile ? "txt" : null, no, normal, mods.ctrl && mods.shift);
793 ide.RepositionWindows(false);
802 bool FileRecentProject(MenuItem selection, Modifiers mods)
805 for(file : ideSettings.recentProjects)
807 if(id == selection.id)
811 char * command = PrintString("ide ", file);
816 OpenFile(file, normal, true, null, no, normal, mods.ctrl && mods.shift);
824 MenuPlacement editMenu { menu, $"Edit", e };
826 Menu projectMenu { menu, $"Menu"."Project", p, hasMargin = true };
827 MenuItem projectNewItem
829 projectMenu, $"New...", n, Key { n, true, true };
830 bitmap = { ":actions/projNew.png" };
831 bool NotifySelect(MenuItem selection, Modifiers mods)
833 if(!DontTerminateDebugSession($"New Project"))
836 NewProjectDialog newProjectDialog { master = this };
837 result = newProjectDialog.Modal();
842 newProjectDialog.CreateNewProject();
845 ideSettings.AddRecentProject(projectView.fileName);
846 ide.UpdateRecentMenus();
847 settingsContainer.Save();
855 MenuItem projectOpenItem
857 projectMenu, $"Open...", o, Key { o, true, true };
858 bitmap = { ":actions/projOpen.png" };
859 bool NotifySelect(MenuItem selection, Modifiers mods)
861 if(ideSettings.ideProjectFileDialogLocation)
862 ideProjectFileDialog.currentDirectory = ideSettings.ideProjectFileDialogLocation;
864 ideProjectFileDialog.text = openProjectFileDialogTitle;
865 if(ideProjectFileDialog.Modal() == ok)
867 OpenFile(ideProjectFileDialog.filePath, normal, true, projectTypes[ideProjectFileDialog.fileType].typeExtension, no, normal, mods.ctrl && mods.shift);
868 //ChangeProjectFileDialogDirectory(ideProjectFileDialog.currentDirectory);
873 MenuItem projectQuickItem
875 projectMenu, $"Quick...", q, f7, disabled = true;
876 bool NotifySelect(MenuItem selection, Modifiers mods)
879 QuickProjectDialog { this }.Modal();
883 MenuItem projectAddItem
885 projectMenu, $"Add project to workspace...", a, Key { a, true, true };
886 bitmap = { ":actions/projAdd.png" };
888 bool NotifySelect(MenuItem selection, Modifiers mods)
890 if(ideSettings.ideProjectFileDialogLocation)
891 ideProjectFileDialog.currentDirectory = ideSettings.ideProjectFileDialogLocation;
893 ideProjectFileDialog.text = addProjectFileDialogTitle;
896 if(ideProjectFileDialog.Modal() == ok)
898 if(OpenFile(ideProjectFileDialog.filePath, normal, true, projectTypes[ideProjectFileDialog.fileType].typeExtension, no, add, mods.ctrl && mods.shift))
900 if(MessageBox { type = yesNo, master = this, text = $"Error opening project file",
901 contents = $"Add a different project?" }.Modal() == no)
912 MenuItem projectCloseItem
914 projectMenu, $"Close", c, disabled = true;
915 bool NotifySelect(MenuItem selection, Modifiers mods)
919 if(!ide.DontTerminateDebugSession($"Project Close"))
925 MenuDivider { projectMenu };
926 MenuItem projectSettingsItem
928 projectMenu, $"Settings...", s, altF7, disabled = true;
929 bool NotifySelect(MenuItem selection, Modifiers mods)
931 projectView.MenuSettings(projectView.active ? selection : null, mods);
935 MenuDivider { projectMenu };
936 MenuItem projectBrowseFolderItem
938 projectMenu, $"Browse Project Folder", p, disabled = true;
939 bool NotifySelect(MenuItem selection, Modifiers mods)
942 projectView.MenuBrowseFolder(null, mods);
946 MenuDivider { projectMenu };
947 MenuItem projectRunItem
949 projectMenu, $"Run", r, ctrlF5, disabled = true;
950 bitmap = { ":actions/run.png" };
951 bool NotifySelect(MenuItem selection, Modifiers mods)
954 projectView.Run(null, mods);
958 MenuItem projectBuildItem
960 projectMenu, $"Build", b, f7, disabled = true;
961 bitmap = { ":actions/build.png" };
962 bool NotifySelect(MenuItem selection, Modifiers mods)
966 if(projectView.buildInProgress == none)
967 projectView.ProjectBuild(projectView.active ? selection : null, mods);
969 projectView.stopBuild = true;
974 MenuItem projectLinkItem
976 projectMenu, $"Relink", l, disabled = true;
977 bitmap = { ":actions/relink.png" };
978 bool NotifySelect(MenuItem selection, Modifiers mods)
981 projectView.ProjectLink(projectView.active ? selection : null, mods);
985 MenuItem projectRebuildItem
987 projectMenu, $"Rebuild", d, shiftF7, disabled = true;
988 bitmap = { ":actions/rebuild.png" };
989 bool NotifySelect(MenuItem selection, Modifiers mods)
992 projectView.ProjectRebuild(projectView.active ? selection : null, mods);
996 MenuItem projectCleanTargetItem
998 projectMenu, $"Clean Target", g, disabled = true;
999 bitmap = { ":actions/clean.png" };
1000 bool NotifySelect(MenuItem selection, Modifiers mods)
1005 projectView.ProjectCleanTarget(projectView.active ? selection : null, mods);
1010 MenuItem projectCleanItem
1012 projectMenu, $"Clean", e, disabled = true;
1013 bitmap = { ":actions/clean.png" };
1014 bool NotifySelect(MenuItem selection, Modifiers mods)
1019 projectView.ProjectClean(projectView.active ? selection : null, mods);
1024 MenuItem projectRealCleanItem
1026 projectMenu, $"Real Clean", disabled = true;
1027 bitmap = { ":actions/clean.png" };
1028 bool NotifySelect(MenuItem selection, Modifiers mods)
1033 projectView.ProjectRealClean(projectView.active ? selection : null, mods);
1038 MenuItem projectRegenerateItem
1040 projectMenu, $"Regenerate Makefile", m, disabled = true;
1041 bitmap = { ":actions/regMakefile.png" };
1042 bool NotifySelect(MenuItem selection, Modifiers mods)
1045 projectView.ProjectRegenerate(projectView.active ? selection : null, mods);
1049 MenuItem projectInstallItem
1051 #ifdef IDE_SHOW_INSTALL_MENU_BUTTON
1052 projectMenu, $"Install", t, disabled = true;
1054 bitmap = { ":status/software-update-available.png" };
1055 bool NotifySelect(MenuItem selection, Modifiers mods)
1058 projectView.ProjectInstall(projectView.active ? selection : null, mods);
1062 MenuItem projectCompileItem;
1063 Menu debugMenu { menu, $"Debug", d, hasMargin = true };
1064 MenuItem debugStartResumeItem
1066 debugMenu, $"Start", s, f5, disabled = true;
1067 bitmap = { ":actions/debug.png" };
1068 NotifySelect = MenuDebugStart;
1070 bool MenuDebugStart(MenuItem selection, Modifiers mods)
1074 debugStartResumeItem.disabled = true; // a very rare exception to calling AdjustDebugMenus
1075 if(!projectView.DebugStart())
1076 debugStartResumeItem.disabled = false; // same exception
1080 bool MenuDebugResume(MenuItem selection, Modifiers mods)
1083 projectView.DebugResume();
1086 MenuItem debugRestartItem
1088 debugMenu, $"Restart", r, Key { f5, ctrl = true, shift = true }, disabled = true;
1089 bitmap = { ":actions/restart.png" };
1090 bool NotifySelect(MenuItem selection, Modifiers mods)
1093 projectView.DebugRestart();
1097 MenuItem debugBreakItem
1099 debugMenu, $"Break", b, Key { pauseBreak, ctrl = true }, disabled = true;
1100 bitmap = { ":actions/pause.png" };
1101 bool NotifySelect(MenuItem selection, Modifiers mods)
1103 if(projectView && projectView.buildInProgress != none)
1106 projectView.DebugBreak();
1110 MenuItem debugStopItem
1112 debugMenu, $"Stop", p, shiftF5, disabled = true;
1113 bitmap = { ":actions/stopDebug.png" };
1114 bool NotifySelect(MenuItem selection, Modifiers mods)
1117 projectView.DebugStop();
1121 MenuDivider { debugMenu };
1122 MenuItem debugStepIntoItem
1124 debugMenu, $"Step Into", i, f11, disabled = true;
1125 bitmap = { ":actions/stepInto.png" };
1126 bool NotifySelect(MenuItem selection, Modifiers mods)
1129 projectView.DebugStepInto();
1133 MenuItem debugStepOverItem
1135 debugMenu, $"Step Over", v, f10, disabled = true;
1136 bitmap = { ":actions/stepOver.png" };
1137 bool NotifySelect(MenuItem selection, Modifiers mods)
1140 projectView.DebugStepOver(false);
1144 MenuItem debugStepOutItem
1146 debugMenu, $"Step Out", o, shiftF11, disabled = true;
1147 bitmap = { ":actions/stepOut.png" };
1148 bool NotifySelect(MenuItem selection, Modifiers mods)
1151 projectView.DebugStepOut(false);
1155 MenuPlacement debugRunToCursorItem { debugMenu, $"Run To Cursor", c };
1156 MenuItem debugSkipStepOverItem
1158 debugMenu, $"Step Over Skipping Breakpoints", e, shiftF10, disabled = true;
1159 bool NotifySelect(MenuItem selection, Modifiers mods)
1162 projectView.DebugStepOver(true);
1166 MenuItem debugSkipStepOutItem
1168 debugMenu, $"Step Out Skipping Breakpoints", t, Key { f11, ctrl = true, shift = true }, disabled = true;
1169 bitmap = { ":actions/skipBreaks.png" };
1170 bool NotifySelect(MenuItem selection, Modifiers mods)
1173 projectView.DebugStepOut(true);
1177 MenuPlacement debugSkipRunToCursorItem { debugMenu, $"Run To Cursor Skipping Breakpoints", u };
1178 MenuPlacement debugSkipRunToCursorAtSameLevelItem { debugMenu, $"Run To Cursor At Same Level Skipping Breakpoints", s };
1179 //MenuDivider { debugMenu };
1180 //MenuPlacement debugToggleBreakpoint { debugMenu, "Toggle Breakpoint", t };
1181 MenuPlacement imageMenu { menu, $"Image", i };
1182 Menu viewMenu { menu, $"View", v };
1183 MenuItem viewProjectItem
1185 viewMenu, $"Project View", j, alt0, disabled = true;
1186 bool NotifySelect(MenuItem selection, Modifiers mods)
1190 projectView.visible = true;
1191 projectView.Activate();
1196 MenuPlacement { viewMenu, $"View Designer" };
1197 MenuPlacement { viewMenu, $"View Code" };
1198 MenuPlacement { viewMenu, $"View Properties" };
1199 MenuPlacement { viewMenu, $"View Methods" };
1200 MenuItem viewDesignerItem
1202 viewMenu, $"View Designer", d, f8;
1203 bool NotifySelect(MenuItem selection, Modifiers mods)
1205 Window client = activeClient;
1206 Class dataType = client._class;
1207 if(!strcmp(dataType.name, "Designer"))
1209 client.visible = true;
1213 ((CodeEditor)client).ViewDesigner();
1217 MenuItem viewCodeItem
1219 viewMenu, $"View Code", c, f8;
1220 bool NotifySelect(MenuItem selection, Modifiers mods)
1222 Window client = activeClient;
1223 Class dataType = client._class;
1224 if(!strcmp(dataType.name, "Designer"))
1225 client = ((Designer)client).codeEditor;
1228 // Do this after so the caret isn't moved yet...
1229 client.visible = true;
1233 MenuItem viewPropertiesItem
1235 viewMenu, $"View Properties", p, f4;
1236 bool NotifySelect(MenuItem selection, Modifiers mods)
1238 sheet.visible = true;
1239 sheet.sheetSelected = properties;
1244 MenuItem viewMethodsItem
1246 viewMenu, $"View Methods", m, f4;
1247 bool NotifySelect(MenuItem selection, Modifiers mods)
1249 sheet.visible = true;
1250 sheet.sheetSelected = methods;
1255 MenuItem viewToolBoxItem
1257 viewMenu, $"View Toolbox", x, f12;
1258 bool NotifySelect(MenuItem selection, Modifiers mods)
1260 toolBox.visible = true;
1265 MenuItem viewOutputItem
1267 viewMenu, $"Output", o, alt2;
1268 bool NotifySelect(MenuItem selection, Modifiers mods)
1274 MenuItem viewWatchesItem
1276 viewMenu, $"Watches", w, alt3;
1277 bool NotifySelect(MenuItem selection, Modifiers mods)
1283 MenuItem viewThreadsItem
1285 viewMenu, $"Threads", t, alt4;
1286 bool NotifySelect(MenuItem selection, Modifiers mods)
1292 MenuItem viewBreakpointsItem
1294 viewMenu, $"Breakpoints", b, alt5;
1295 bool NotifySelect(MenuItem selection, Modifiers mods)
1297 breakpointsView.Show();
1301 MenuItem viewCallStackItem
1303 viewMenu, $"Call Stack", s, alt7;
1304 bool NotifySelect(MenuItem selection, Modifiers mods)
1306 callStackView.Show();
1310 MenuItem viewAllDebugViews
1312 viewMenu, $"All Debug Views", a, alt9;
1313 bool NotifySelect(MenuItem selection, Modifiers mods)
1318 callStackView.Show();
1319 breakpointsView.Show();
1323 #ifdef GDB_DEBUG_GUI
1324 MenuDivider { viewMenu };
1325 MenuItem viewGDBItem
1327 viewMenu, $"GDB Dialog", g, Key { f9, shift = true, ctrl = true };
1328 bool NotifySelect(MenuItem selection, Modifiers mods)
1335 MenuDivider { viewMenu };
1336 MenuItem viewColorPicker
1338 viewMenu, $"Color Picker...", c, Key { c, ctrl = true , shift = true };
1339 bool NotifySelect(MenuItem selection, Modifiers mods)
1341 ColorPicker colorPicker { master = this };
1342 colorPicker.Modal();
1346 MenuDivider { viewMenu };
1350 viewMenu, "Full Screen", f, checkable = true;
1352 bool NotifySelect(MenuItem selection, Modifiers mods)
1354 app.fullScreen ^= true;
1356 anchor = { 0, 0, 0, 0 };
1361 Menu driversMenu { viewMenu, $"Graphics Driver", v };
1362 //Menu skinsMenu { viewMenu, "GUI Skins", k };
1363 Menu windowMenu { menu, $"Window", w };
1364 MenuItem { windowMenu, $"Close All", l, NotifySelect = MenuWindowCloseAll };
1365 MenuDivider { windowMenu };
1366 MenuItem { windowMenu, $"Next", n, f6, NotifySelect = MenuWindowNext };
1367 MenuItem { windowMenu, $"Previous", p, shiftF6, NotifySelect = MenuWindowPrevious };
1368 MenuDivider { windowMenu };
1369 MenuItem { windowMenu, $"Cascade", c, NotifySelect = MenuWindowCascade };
1370 MenuItem { windowMenu, $"Tile Horizontally", h, NotifySelect = MenuWindowTileHorz };
1371 MenuItem { windowMenu, $"Tile Vertically", v, NotifySelect = MenuWindowTileVert };
1372 MenuItem { windowMenu, $"Arrange Icons", a, NotifySelect = MenuWindowArrangeIcons };
1373 MenuDivider { windowMenu };
1374 MenuItem { windowMenu, $"Windows...", w, NotifySelect = MenuWindowWindows };
1375 Menu helpMenu { menu, $"Help", h };
1378 helpMenu, $"API Reference", r, f1;
1379 bool NotifySelect(MenuItem selection, Modifiers mods)
1381 char * p = new char[MAX_LOCATION];
1383 strncpy(p, settingsContainer.moduleLocation, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
1384 PathCat(p, "documentor");
1385 #if defined(__WIN32__)
1386 ChangeExtension(p, "exe", p);
1388 if(FileExists(p).isFile)
1391 Execute("documentor");
1396 MenuDivider { helpMenu };
1399 helpMenu, $"Ecere Tao of Programming [work in progress]", t;
1400 bool NotifySelect(MenuItem selection, Modifiers mods)
1402 FindAndShellOpenInstalledFile("doc", "Ecere Tao of Programming [work in progress].pdf");
1406 MenuDivider { helpMenu };
1409 helpMenu, $"Documentation Folder", d;
1410 bool NotifySelect(MenuItem selection, Modifiers mods)
1412 FindAndShellOpenInstalledFolder("doc");
1418 helpMenu, $"Samples Folder", s;
1419 bool NotifySelect(MenuItem selection, Modifiers mods)
1421 FindAndShellOpenInstalledFolder("samples");
1427 helpMenu, $"Extras Folder", x;
1428 bool NotifySelect(MenuItem selection, Modifiers mods)
1430 FindAndShellOpenInstalledFolder("extras");
1434 MenuDivider { helpMenu };
1437 helpMenu, $"Community Forums", f;
1438 bool NotifySelect(MenuItem selection, Modifiers mods)
1440 ShellOpen("http://ecere.com/forums");
1444 MenuDivider { helpMenu };
1447 helpMenu, $"About...", a;
1448 bool NotifySelect(MenuItem selection, Modifiers mods)
1450 AboutIDE { master = this }.Modal();
1455 property ToolBox toolBox
1457 get { return toolBox; }
1460 property Sheet sheet
1462 get { return sheet; }
1465 property Project project
1467 get { return projectView ? projectView.project : null; }
1470 property Workspace workspace
1472 get { return projectView ? projectView.workspace : null; }
1475 FindInFilesDialog findInFilesDialog
1478 filters = findInFilesFileFilters.array, sizeFilters = findInFilesFileFilters.count * sizeof(FileFilter);
1484 #ifdef GDB_DEBUG_GUI
1487 master = this, parent = this;
1488 anchor = { left = 100, top = 100, right = 100, bottom = 100 };
1490 void OnCommand(char * string)
1493 ide.debugger.SendGDBCommand(string);
1498 bool NotifySelectDisplayDriver(MenuItem selection, Modifiers mods)
1500 //app.driver = app.drivers[selection.id];
1501 #if defined(__unix__) || defined(__APPLE__)
1502 app.driver = selection.id ? "OpenGL" : "X";
1504 app.driver = selection.id ? "OpenGL" : "GDI";
1506 delete ideSettings.displayDriver;
1507 ideSettings.displayDriver = CopyString(selection.id ? "OpenGL" : "Default");
1509 settingsContainer.Save();
1510 //SetDriverAndSkin();
1514 bool NotifySelectDisplaySkin(MenuItem selection, Modifiers mods)
1516 app.skin = app.skins[selection.id];
1521 void SetDriverAndSkin()
1524 for(c = 0; c < app.numSkins; c++)
1525 if(!strcmp(app.skins[c], app.skin))
1527 skinItems[c].checked = true;
1530 for(c = 0; c < app.numDrivers; c++)
1531 if(!strcmp(app.drivers[c], app.driver))
1533 driverItems[c].checked = true;
1538 ProjectView CreateProjectView(Workspace workspace, char * fileName)
1540 Project project = workspace.projects.firstIterator.data;
1541 projectView = ProjectView
1544 fileName = fileName;
1546 void NotifyDestroyed(Window window, DialogResult result)
1549 text = titleECEREIDE;
1554 projectView.Create();
1555 RepositionWindows(false);
1557 // Leave it after Create to avoid flicker due to seeing IDE without a project view
1558 projectView.workspace = workspace;
1559 projectView.project = project;
1560 ideMainFrame.SetText("%s - %s", project.topNode.name, titleECEREIDE);
1564 ide.breakpointsView.LoadFromWorkspace();
1565 ide.watchesView.LoadFromWorkspace();
1567 findInFilesDialog.projectNodeField.userData = projectView;
1570 char fileName[MAX_LOCATION];
1571 strcpy(fileName, project.topNode.path);
1572 PathCat(fileName, project.topNode.name);
1579 projectView.visible = false;
1580 if((!projectView || projectView.created == false || projectView.Destroy(0)) && MenuWindowCloseAll(null, 0))
1582 if(findInFilesDialog)
1584 char workingDir[MAX_LOCATION];
1585 GetWorkingDir(workingDir, MAX_LOCATION);
1586 findInFilesDialog.SearchStop();
1587 findInFilesDialog.currentDirectory = workingDir;
1589 ideMainFrame.text = titleECEREIDE;
1596 void RepositionWindows(bool expand)
1601 bool inDebugMode = debugger.isActive;
1602 bool callStackVisible = expand ? false : callStackView.visible;
1603 bool threadsVisible = expand ? false : threadsView.visible;
1604 bool watchesVisible = expand ? false : watchesView.visible;
1605 bool breakpointsVisible = expand ? false : breakpointsView.visible;
1606 bool toolBoxVisible = toolBox.visible;
1607 bool outputVisible = expand ? false : outputView.visible;
1608 int topDistance = (callStackVisible || threadsVisible) ? 200 : 0;
1609 int bottomDistance = (outputVisible || watchesVisible || breakpointsVisible) ? 240 : 0;
1611 for(child = firstChild; child; child = child.next)
1613 if(child._class == class(CodeEditor) || child._class == class(Designer) ||
1614 child._class == class(Sheet) || child._class == class(ProjectView))
1616 Anchor anchor = child.anchor;
1617 anchor.top = topDistance;
1618 anchor.bottom = bottomDistance;
1619 if(child._class == class(CodeEditor) || child._class == class(Designer))
1622 anchor.right = toolBoxVisible ? 150 : 0;
1624 child.anchor = anchor;
1628 if(child._class == class(OutputView) || child._class == class(CallStackView) || child._class == class(ThreadsView) || child._class == class(WatchesView) ||
1629 child._class == class(BreakpointsView))
1630 child.visible = false;
1633 // If this is not here, the IDE is not updated when doing Debug/Break then Alt-4 to show call stack (IDE not updated)
1638 bool ShowCodeEditor()
1641 activeClient.Activate();
1642 else if(projectView)
1644 projectView.visible = true;
1645 projectView.Activate();
1649 sheet.visible = true;
1655 void DocumentSaved(Window document, char * fileName)
1657 ideSettings.AddRecentFile(fileName);
1658 ide.UpdateRecentMenus();
1659 ide.AdjustFileMenus();
1660 settingsContainer.Save();
1663 bool Window::OnFileModified(FileChange fileChange, char * param)
1666 sprintf(temp, $"The document %s was modified by another application.\n"
1667 "Would you like to reload it and lose your changes?", this.fileName);
1668 if(MessageBox { type = yesNo, master = this/*.parent*/,
1669 text = $"Document has been modified", contents = temp }.Modal() == yes)
1671 bool noParsing = (this._class == class(CodeEditor) && ((CodeEditor)this).noParsing) ? true : false;
1672 char * fileName = CopyString(this.fileName);
1673 WindowState state = this.state;
1674 Anchor anchor = this.anchor;
1675 Size size = this.size;
1677 this.modifiedDocument = false;
1679 this = ide.OpenFile(fileName, normal, true, null, no, normal, noParsing);
1682 this.anchor = anchor;
1684 this.SetState(state, true, 0);
1692 void UpdateMakefiles()
1696 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
1697 for(prj : workspace.projects)
1698 projectView.ProjectUpdateMakefileForAllConfigs(prj);
1703 void UpdateCompilerConfigs(bool mute)
1705 UpdateToolBarActiveCompilers();
1708 bool silent = mute || (ide.projectView.buildInProgress == none ? false : true);
1709 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
1712 projectView.ShowOutputBuildLog(true);
1713 projectView.DisplayCompiler(compiler, false);
1715 for(prj : workspace.projects)
1716 projectView.ProjectPrepareCompiler(prj, compiler, silent);
1721 void UpdateToolBarActiveCompilers()
1723 toolBar.activeCompiler.Clear();
1724 for(compiler : ideSettings.compilerConfigs)
1726 DataRow row = toolBar.activeCompiler.AddString(compiler.name);
1727 if(workspace && workspace.compiler && !strcmp(compiler.name, workspace.compiler))
1728 toolBar.activeCompiler.currentRow = row;
1730 if(!toolBar.activeCompiler.currentRow && toolBar.activeCompiler.firstRow)
1731 toolBar.activeCompiler.SelectRow(toolBar.activeCompiler.firstRow);
1734 void UpdateToolBarActiveConfigs(bool selectionOnly)
1736 bool commonSelected = false;
1737 DataRow row = toolBar.activeConfig.currentRow;
1739 row = toolBar.activeConfig.FindRow(1);
1742 toolBar.activeConfig.Clear();
1743 row = toolBar.activeConfig.AddString($"(Mixed)");
1748 char * configName = null;
1751 Map<String, int> configs { }; // TOIMP: just need sort but using map until containers have sort
1752 for(prj : workspace.projects)
1754 for(cfg : prj.configurations)
1757 configs[cfg.name] = 1;
1762 toolBar.activeConfig.AddString(&name);
1766 if(projectView && projectView.project)
1768 for(prj : workspace.projects)
1770 if(prj.config && prj.config.name)
1772 configName = prj.config.name;
1778 commonSelected = true;
1779 for(prj : workspace.projects)
1781 if(prj.config && (!prj.config.name || strcmp(prj.config.name, configName)))
1783 commonSelected = false;
1791 commonSelected = false;
1792 for(row = toolBar.activeConfig.firstRow; row; row = row.next)
1794 if(!strcmp(row.string, configName))
1796 toolBar.activeConfig.currentRow = row;
1797 commonSelected = true;
1804 toolBar.activeConfig.Sort(null, 0);
1806 toolBar.activeConfig.currentRow = row;
1811 bool unavailable = !project;
1813 projectAddItem.disabled = unavailable;
1814 toolBar.buttonAddProject.disabled = unavailable;
1816 projectSettingsItem.disabled = unavailable;
1818 projectBrowseFolderItem.disabled = unavailable;
1820 viewProjectItem.disabled = unavailable;
1822 toolBar.activeConfig.disabled = unavailable;
1823 toolBar.activeCompiler.disabled = unavailable;
1824 toolBar.activeBitDepth.disabled = unavailable;
1831 property bool hasOpenedCodeEditors
1836 for(w = firstChild; w; w = w.next)
1837 if(w._class == class(CodeEditor) &&
1838 w.isDocument && !w.closing && w.visible && w.created &&
1839 w.fileName && w.fileName[0])
1845 void AdjustFileMenus()
1847 bool unavailable = project != null || !hasOpenedCodeEditors; // are they supported source code (ec, c, cpp, etc) ?
1849 projectQuickItem.disabled = unavailable;
1852 void AdjustBuildMenus()
1854 bool unavailable = project && projectView.buildInProgress;
1856 projectNewItem.disabled = unavailable;
1857 toolBar.buttonNewProject.disabled = unavailable;
1858 projectOpenItem.disabled = unavailable;
1859 toolBar.buttonOpenProject.disabled = unavailable;
1861 unavailable = !project || projectView.buildInProgress;
1863 projectCloseItem.disabled = unavailable;
1864 // toolBar.buttonCloseProject.disabled = unavailable;
1866 projectRunItem.disabled = unavailable || project.GetTargetType(project.config) != executable;
1867 toolBar.buttonRun.disabled = unavailable || project.GetTargetType(project.config) != executable;
1869 projectBuildItem.disabled = false;
1870 projectBuildItem.text = unavailable ? $"Stop Build" : $"Build";
1871 projectBuildItem.accelerator = unavailable ? Key { pauseBreak, ctrl = true } : f7;
1873 projectLinkItem.disabled = unavailable;
1874 toolBar.buttonReLink.disabled = unavailable;
1875 projectRebuildItem.disabled = unavailable;
1876 toolBar.buttonRebuild.disabled = unavailable;
1877 projectCleanItem.disabled = unavailable;
1878 toolBar.buttonClean.disabled = unavailable;
1879 projectCleanTargetItem.disabled = unavailable;
1880 projectRealCleanItem.disabled = unavailable;
1881 // toolBar.buttonRealClean.disabled = unavailable;
1882 projectRegenerateItem.disabled = unavailable;
1883 toolBar.buttonRegenerateMakefile.disabled = unavailable;
1884 #ifdef IDE_SHOW_INSTALL_MENU_BUTTON
1885 projectInstallItem.disabled = unavailable;
1886 toolBar.buttonInstall.disabled = unavailable;
1888 projectCompileItem.disabled = unavailable;
1890 AdjustPopupBuildMenus();
1893 void AdjustPopupBuildMenus()
1895 bool unavailable = !project || projectView.buildInProgress;
1897 if(projectView && projectView.popupMenu && projectView.popupMenu.menu && projectView.popupMenu.created)
1900 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectBuild, 0);
1903 menu.disabled = false;
1904 menu.text = unavailable ? $"Stop Build" : $"Build";
1905 menu.accelerator = unavailable ? Key { pauseBreak, ctrl = true } : f7;
1908 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectLink, 0); if(menu) menu.disabled = unavailable;
1909 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRebuild, 0); if(menu) menu.disabled = unavailable;
1910 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectCleanTarget, 0); if(menu) menu.disabled = unavailable;
1911 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectClean, 0); if(menu) menu.disabled = unavailable;
1912 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRealClean, 0); if(menu) menu.disabled = unavailable;
1913 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRegenerate, 0); if(menu) menu.disabled = unavailable;
1914 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectInstall, 0); if(menu) menu.disabled = unavailable;
1915 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRemove, 0); if(menu) menu.disabled = unavailable;
1916 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileClean, 0); if(menu) menu.disabled = unavailable;
1917 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileCompile, 0); if(menu) menu.disabled = unavailable;
1918 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugPrecompile, 0); if(menu) menu.disabled = unavailable;
1919 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugCompile, 0); if(menu) menu.disabled = unavailable;
1920 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugGenerateSymbols, 0); if(menu) menu.disabled = unavailable;
1921 projectView.popupMenu.Update(null);
1925 property bool areDebugMenusUnavailable { get {
1927 project.GetTargetType(project.config) != executable ||
1928 projectView.buildInProgress == buildingMainProject;
1931 property bool isBreakpointTogglingUnavailable { get {
1935 property bool isDebuggerExecuting { get {
1939 return ide.debugger.state == running;
1942 void AdjustDebugMenus()
1944 bool unavailable = areDebugMenusUnavailable;
1945 bool active = debugger.isActive;
1946 bool bpNoToggle = isBreakpointTogglingUnavailable;
1947 bool executing = isDebuggerExecuting;
1948 //bool holding = debugger.state == stopped;
1950 debugStartResumeItem.disabled = unavailable || executing;
1951 debugStartResumeItem.text = active ? $"Resume" : $"Start";
1952 debugStartResumeItem.NotifySelect = active ? MenuDebugResume : MenuDebugStart;
1955 toolBar.buttonDebugStartResume.disabled = unavailable || executing;
1956 toolBar.buttonDebugStartResume.toolTip = active ? $"Resume" : $"Start";
1959 debugBreakItem.disabled = unavailable || !executing;
1960 debugStopItem.disabled = unavailable || !active;
1961 debugRestartItem.disabled = unavailable || !active;
1964 toolBar.buttonDebugPause.disabled = unavailable || !executing;
1965 toolBar.buttonDebugStop.disabled = unavailable || !active;
1966 toolBar.buttonDebugRestart.disabled = unavailable || !active;
1969 debugStepIntoItem.disabled = unavailable || executing;
1970 debugStepOverItem.disabled = unavailable || executing;
1971 debugStepOutItem.disabled = unavailable || executing || !active;
1972 debugSkipStepOverItem.disabled = unavailable || executing;
1973 debugSkipStepOutItem.disabled = unavailable || executing || !active;
1976 toolBar.buttonDebugStepInto.disabled = unavailable || executing;
1977 toolBar.buttonDebugStepOver.disabled = unavailable || executing;
1978 toolBar.buttonDebugStepOut.disabled = unavailable || executing || !active;
1979 toolBar.buttonDebugSkipStepOver.disabled = unavailable || executing;
1980 // toolBar.buttonDebugSkipStepOutItem.disabled = unavailable || executing;
1982 if((Designer)GetActiveDesigner())
1984 CodeEditor codeEditor = ((Designer)GetActiveDesigner()).codeEditor;
1986 codeEditor.AdjustDebugMenus(unavailable, bpNoToggle, executing);
1990 void ChangeFileDialogsDirectory(char * directory, bool saveSettings)
1992 char tempString[MAX_LOCATION];
1993 strcpy(tempString, directory);
1994 if(saveSettings && !projectView)
1996 ideSettings.ideFileDialogLocation = directory;
1997 settingsContainer.Save();
2000 ideFileDialog.currentDirectory = tempString;
2001 codeEditorFileDialog.currentDirectory = tempString;
2002 codeEditorFormFileDialog.currentDirectory = tempString;
2005 void ChangeProjectFileDialogDirectory(char * directory)
2007 ideSettings.ideProjectFileDialogLocation = directory;
2008 settingsContainer.Save();
2011 Window FindWindow(char * filePath)
2013 Window document = null;
2015 // TOCHECK: Do we need to change slashes here?
2016 for(document = firstChild; document; document = document.next)
2018 char * fileName = document.fileName;
2019 if(document.isDocument && fileName && !fstrcmp(fileName, filePath))
2021 document.visible = true;
2022 document.Activate();
2029 bool DontTerminateDebugSession(char * title)
2031 if(debugger.isActive)
2033 if(MessageBox { type = yesNo, master = ide,
2034 contents = $"Do you want to terminate the debugging session in progress?",
2035 text = title }.Modal() == no)
2038 MessageBox msg { type = yesNo, master = ide,
2039 contents = "Do you want to terminate the debugging session in progress?",
2041 if(msg.Modal() == no)
2053 Window OpenFile(char * origFilePath, WindowState state, bool visible, char * type, OpenCreateIfFails createIfFails, OpenMethod openMethod, bool noParsing)
2055 char extension[MAX_EXTENSION] = "";
2056 Window document = null;
2057 bool isProject = false;
2058 bool needFileModified = true;
2059 char winFilePath[MAX_LOCATION];
2060 char * filePath = strstr(origFilePath, "http://") == origFilePath ? strcpy(winFilePath, origFilePath) : GetSystemPathBuffer(winFilePath, origFilePath);
2064 GetExtension(filePath, extension);
2068 strcpy(extension, type);
2070 if(strcmp(extension, ProjectExtension))
2072 for(document = firstChild; document; document = document.next)
2074 char * fileName = document.fileName;
2075 if(document.isDocument && fileName && !fstrcmp(fileName, filePath) && document.created)
2077 document.visible = true;
2079 document.Activate();
2085 if(createIfFails == whatever)
2087 else if(!strcmp(extension, ProjectExtension) || !strcmp(extension, WorkspaceExtension))
2089 needFileModified = false;
2090 if(openMethod == normal)
2092 if(DontTerminateDebugSession($"Open Project"))
2102 Workspace workspace = null;
2104 if(FileExists(filePath))
2106 if(!strcmp(extension, ProjectExtension))
2108 char workspaceFile[MAX_LOCATION];
2109 strcpy(workspaceFile, filePath);
2110 ChangeExtension(workspaceFile, WorkspaceExtension, workspaceFile);
2111 workspace = LoadWorkspace(workspaceFile, filePath);
2113 else if(!strcmp(extension, WorkspaceExtension))
2114 workspace = LoadWorkspace(filePath, null);
2117 //project = LoadProject(filePath, null);
2122 char absolutePath[MAX_LOCATION];
2123 CreateProjectView(workspace, filePath);
2124 document = projectView;
2126 workspace.DropInvalidBreakpoints();
2129 ide.projectView.ShowOutputBuildLog(true);
2131 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
2132 ide.projectView.DisplayCompiler(compiler, false);
2135 UpdateCompilerConfigs(false);
2138 char newWorkingDir[MAX_LOCATION];
2139 StripLastDirectory(filePath, newWorkingDir);
2140 ChangeFileDialogsDirectory(newWorkingDir, false);
2143 document.fileName = filePath;
2145 ideMainFrame.SetText("%s - %s", filePath, titleECEREIDE);
2147 // this crashes on starting ide with epj file, solution please?
2148 // app.UpdateDisplay();
2150 workspace.holdTracking = true;
2151 for(ofi : workspace.openedFiles)
2153 if(ofi.state != closed)
2155 Window file = OpenFile(ofi.path, normal, true, null, no, normal, noParsing);
2158 char fileName[MAX_LOCATION];
2160 GetLastDirectory(ofi.path, fileName);
2161 node = projectView.project.topNode.Find(fileName, true);
2163 node.EnsureVisible();
2167 ide.RepositionWindows(false);
2168 workspace.holdTracking = false;
2170 workspace.timer.Start();
2172 findInFilesDialog.mode = FindInFilesMode::project;
2173 findInFilesDialog.currentDirectory = ide.project.topNode.path;
2176 char location[MAX_LOCATION];
2177 StripLastDirectory(ide.project.topNode.path, location);
2178 ChangeProjectFileDialogDirectory(location);
2182 if(projectView.debugger)
2183 projectView.debugger.EvaluateWatches();
2190 if(MessageBox { type = yesNo, master = this, text = $"Error opening project", contents = $"Open a different project?" }.Modal() == yes)
2192 ideProjectFileDialog.text = openProjectFileDialogTitle;
2193 if(ideProjectFileDialog.Modal() == cancel)
2195 filePath = ideProjectFileDialog.filePath;
2196 GetExtension(filePath, extension);
2207 else if(openMethod == add)
2212 char slashFilePath[MAX_LOCATION];
2213 GetSlashPathBuffer(slashFilePath, filePath);
2214 for(p : workspace.projects)
2216 if(!fstrcmp(p.filePath, slashFilePath))
2224 MessageBox { type = ok, parent = parent, master = this, text = $"Same Project",
2225 contents = $"This project is already present in workspace." }.Modal();
2229 prj = LoadProject(filePath, null);
2232 char * activeConfigName = null;
2233 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
2234 prj.StartMonitoring();
2235 workspace.projects.Add(prj);
2236 if(toolBar.activeConfig.currentRow && toolBar.activeConfig.currentRow != toolBar.activeConfig.firstRow &&
2237 toolBar.activeConfig.currentRow.string && toolBar.activeConfig.currentRow.string[0])
2238 activeConfigName = toolBar.activeConfig.currentRow.string;
2239 if(activeConfigName)
2241 for(cfg : prj.configurations)
2243 if(cfg.name && !strcmp(cfg.name, activeConfigName))
2251 projectView.AddNode(prj.topNode, null);
2252 workspace.modified = true;
2254 findInFilesDialog.AddProjectItem(prj);
2255 projectView.ShowOutputBuildLog(true);
2256 projectView.DisplayCompiler(compiler, false);
2257 projectView.ProjectUpdateMakefileForAllConfigs(prj);
2261 char location[MAX_LOCATION];
2262 StripLastDirectory(prj.topNode.path, location);
2263 ChangeProjectFileDialogDirectory(location);
2266 // projectView is associated with the main project and not with the one just added but
2267 return projectView; // just to let the caller know something was opened
2275 else if(!strcmp(extension, "bmp") || !strcmp(extension, "pcx") ||
2276 !strcmp(extension, "jpg") || !strcmp(extension, "gif") ||
2277 !strcmp(extension, "jpeg") || !strcmp(extension, "png"))
2279 if(FileExists(filePath))
2280 document = PictureEdit { hasMaximize = true, hasMinimize = true, hasClose = true, borderStyle = sizable,
2281 hasVertScroll = true, hasHorzScroll = true, parent = this, state = state,
2282 visible = visible, bitmapFile = filePath, OnClose = PictureEditOnClose/*why?--GenericDocumentOnClose*/;
2285 MessageBox { type = ok, master = this, text = filePath, contents = $"File doesn't exist." }.Modal();
2288 else if(!strcmp(extension, "3ds"))
2290 if(FileExists(filePath))
2291 document = ModelView { hasMaximize = true, hasMinimize = true, hasClose = true, borderStyle = sizable,
2292 hasVertScroll = true, hasHorzScroll = true, parent = this, state = state,
2293 visible = visible, modelFile = filePath, OnClose = ModelViewOnClose/*why?--GenericDocumentOnClose*/
2297 MessageBox { type = ok, master = this, text = filePath, contents = $"File doesn't exist." }.Modal();
2300 else if(!strcmp(extension, "txt") || !strcmp(extension, "text") ||
2301 !strcmp(extension, "nfo") || !strcmp(extension, "info") ||
2302 !strcmp(extension, "htm") || !strcmp(extension, "html") ||
2303 !strcmp(extension, "css") || !strcmp(extension, "php") ||
2304 !strcmp(extension, "js"))
2306 CodeEditor editor { parent = this, state = state, visible = false, noParsing = noParsing };
2307 editor.updatingCode = true;
2308 if(editor.LoadFile(filePath))
2311 editor.visible = true;
2315 needFileModified = false;
2319 CodeEditor editor { parent = this, state = state, visible = false, noParsing = noParsing };
2320 if(editor.LoadFile(filePath))
2323 editor.visible = true;
2327 needFileModified = false;
2330 if(document && (document._class == class(PictureEdit) ||
2331 document._class == class(ModelView)))
2336 document.fileName = filePath;
2337 if(workspace && !workspace.holdTracking)
2338 workspace.UpdateOpenedFileInfo(filePath, opened);
2342 if(!document && createIfFails != no)
2344 if(createIfFails != yes && !needFileModified &&
2345 MessageBox { type = yesNo, master = this, text = filePath, contents = $"File doesn't exist. Create?" }.Modal() == yes)
2346 createIfFails = yes;
2347 if(createIfFails == yes || createIfFails == whatever)
2349 document = (Window)NewCodeEditor(this, state, true);
2351 document.fileName = filePath;
2357 if(projectView && document._class == class(CodeEditor) && workspace)
2359 int lineNumber, position;
2361 CodeEditor editor = (CodeEditor)document;
2362 editor.openedFileInfo = workspace.UpdateOpenedFileInfo(filePath, opened);
2363 editor.openedFileInfo.holdTracking = true;
2364 lineNumber = Max(editor.openedFileInfo.lineNumber - 1, 0);
2365 position = Max(editor.openedFileInfo.position - 1, 0);
2366 editor.editBox.GoToLineNum(lineNumber);
2367 editor.editBox.GoToPosition(editor.editBox.line, lineNumber, position);
2368 scroll.x = Max(editor.openedFileInfo.scroll.x, 0);
2369 scroll.y = Max(editor.openedFileInfo.scroll.y, 0);
2370 editor.editBox.scroll = scroll;
2371 editor.openedFileInfo.holdTracking = false;
2374 if(needFileModified)
2375 document.OnFileModified = OnFileModified;
2376 document.NotifySaved = DocumentSaved;
2379 ideSettings.AddRecentProject(document.fileName);
2381 ideSettings.AddRecentFile(document.fileName);
2382 ide.UpdateRecentMenus();
2383 ide.AdjustFileMenus();
2384 settingsContainer.Save();
2392 // TOCHECK: I can't use a generic one for both ModelView and PictureEdit both derived from Window
2393 /*bool Window::GenericDocumentOnClose(bool parentClosing)
2395 if(!parentClosing && ide.workspace)
2396 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2399 bool ModelView::ModelViewOnClose(bool parentClosing)
2401 if(!parentClosing && ide.workspace)
2402 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2405 bool PictureEdit::PictureEditOnClose(bool parentClosing)
2407 if(!parentClosing && ide.workspace)
2408 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2413 void OnUnloadGraphics(Window window)
2415 display.ClearMaterials();
2416 display.ClearTextures();
2417 display.ClearMeshes();
2421 bool OnActivate(bool active, Window swap, bool * goOnWithActivation, bool direct)
2423 caps.color = app.GetKeyState(capsState) ? black : Color { 128,128,128 };
2424 num.color = app.GetKeyState(numState) ? black : Color { 128,128,128 };
2428 bool OnKeyDown(Key key, unichar ch)
2433 projectView.Update(null);
2436 caps.color = app.GetKeyState(capsState) ? black : Color { 128,128,128 };
2439 num.color = app.GetKeyState(numState) ? black : Color { 128,128,128 };
2445 void GoToError(const char * line, bool noParsing)
2448 projectView.GoToError(line, noParsing);
2451 void CodeLocationParseAndGoTo(const char * text, Project project, const char * dir)
2455 char *colon = strchr(text, ':');
2456 char filePath[MAX_LOCATION] = "";
2457 char completePath[MAX_LOCATION];
2458 int line = 0, col = 0;
2459 int len = strlen(text);
2461 FileAttribs fileAttribs;
2463 // support for valgrind output
2464 if((s = strstr(text, "==")) && (s = strstr(s+2, "==")) && (s = strstr(s+2, ":")) && (s = strstr(s+1, ":")))
2475 /*for(s=colon; *s; s++)
2484 //line = atoi(colon+1);
2486 // support for "Found n match(es) in "file/path";
2487 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)
2493 if(colon && (colon[1] == '/' || colon[1] == '\\'))
2495 path = (colon - 1 > path) ? colon - 1 : path;
2496 colon = strstr(colon + 1, ":");
2498 if(*path == '*' && (s = strchr(path+1, '*')))
2500 while(isspace(*path)) path++;
2504 char * close = strchr(path, ')');
2508 strncpy(name, path+1, close - path - 1);
2509 name[close - path - 1] = '\0';
2510 for(p : ide.workspace.projects)
2512 if(!strcmp(p.name, name))
2522 prj = project ? project : (dir ? null : ide.project);
2525 strncpy(filePath, path, colon - path);
2526 filePath[colon - path] = '\0';
2527 line = atoi(colon + 1);
2528 colon = strstr(colon + 1, ":");
2530 col = atoi(colon + 1);
2532 else if(path - 1 >= text && *(path - 1) == '\"')
2534 colon = strchr(path, '\"');
2537 strncpy(filePath, path, colon - path);
2538 filePath[colon - path] = '\0';
2541 else if(path && !colon)
2543 strcpy(filePath, path);
2549 strcpy(completePath, prj.topNode.path);
2550 else if(dir && dir[0])
2551 strcpy(completePath, dir);
2553 completePath[0] = '\0';
2554 PathCat(completePath, filePath);
2556 if((fileAttribs = FileExists(completePath)))
2557 CodeLocationGoTo(completePath, fileAttribs, line, col);
2558 else if(ide.workspace)
2561 for(p : ide.workspace.projects)
2563 strcpy(completePath, p.topNode.path);
2564 PathCat(completePath, filePath);
2565 if((fileAttribs = FileExists(completePath)).isFile)
2567 CodeLocationGoTo(completePath, fileAttribs, line, col);
2574 for(p : ide.workspace.projects)
2576 ProjectNode node = p.topNode.Find(filePath, false);
2579 node.GetFullFilePath(completePath);
2580 if((fileAttribs = FileExists(completePath)).isFile)
2582 CodeLocationGoTo(completePath, fileAttribs, line, col);
2592 void CodeLocationGoTo(const char * path, const FileAttribs fileAttribs, int line, int col)
2594 if(fileAttribs.isFile)
2596 char ext[MAX_EXTENSION];
2597 GetExtension(path, ext);
2598 if(!strcmp(ext, "mp3") || !strcmp(ext, "flac") || !strcmp(ext, "ogg") || !strcmp(ext, "avi") || !strcmp(ext, "mkv"))
2600 else if(!strcmp(ext, "a") || !strcmp(ext, "o") || !strcmp(ext, "lib") || !strcmp(ext, "dll") || !strcmp(ext, "exe"))
2602 char dirPath[MAX_LOCATION];
2603 StripLastDirectory(path, dirPath);
2608 CodeEditor codeEditor = (CodeEditor)OpenFile(path, normal, true, ext, no, normal, false);
2609 if(codeEditor && line)
2611 EditBox editBox = codeEditor.editBox;
2612 editBox.GoToLineNum(line - 1);
2613 editBox.GoToPosition(editBox.line, line - 1, col ? (col - 1) : 0);
2617 else if(fileAttribs.isDirectory)
2621 void OnRedraw(Surface surface)
2623 Bitmap bitmap = back.bitmap;
2625 surface.Blit(bitmap, (clientSize.w - bitmap.width) / 2, (clientSize.h - bitmap.height) / 2, 0, 0, bitmap.width, bitmap.height);
2628 void SheetSelected(SheetType sheetSelected)
2630 if(activeChild == sheet)
2632 if(sheetSelected == methods)
2634 viewPropertiesItem.accelerator = f4;
2635 viewPropertiesItem.parent = viewMenu;
2636 viewMethodsItem.parent = null;
2640 viewMethodsItem.accelerator = f4;
2641 viewMethodsItem.parent = viewMenu;
2642 viewPropertiesItem.parent = null;
2647 viewMethodsItem.parent = viewMenu;
2648 viewPropertiesItem.parent = viewMenu;
2649 if(sheetSelected == methods)
2651 viewMethodsItem.accelerator = f4;
2652 viewPropertiesItem.accelerator = 0;
2656 viewMethodsItem.accelerator = 0;
2657 viewPropertiesItem.accelerator = f4;
2662 void OnActivateClient(Window client, Window previous)
2664 //if(!client || client != previous)
2667 if(!client || client != previous)
2670 dataType = previous._class;
2671 if(previous && !strcmp(dataType.name, "CodeEditor"))
2673 ((CodeEditor)previous).UpdateFormCode();
2675 else if(previous && !strcmp(dataType.name, "Designer"))
2677 ((Designer)previous).codeEditor.UpdateFormCode();
2682 dataType = client._class;
2683 if(client && !strcmp(dataType.name, "CodeEditor"))
2685 CodeEditor codeEditor = (CodeEditor)client;
2686 SetPrivateModule(codeEditor.privateModule);
2687 SetCurrentContext(codeEditor.globalContext);
2688 SetTopContext(codeEditor.globalContext);
2689 SetGlobalContext(codeEditor.globalContext);
2691 SetDefines(&codeEditor.defines);
2692 SetImports(&codeEditor.imports);
2694 SetActiveDesigner(codeEditor.designer);
2696 sheet.codeEditor = codeEditor;
2697 toolBox.codeEditor = codeEditor;
2699 viewDesignerItem.parent = viewMenu;
2700 if(activeChild != codeEditor)
2702 viewCodeItem.parent = viewMenu;
2703 viewDesignerItem.accelerator = 0;
2704 viewCodeItem.accelerator = f8;
2708 viewCodeItem.parent = null;
2709 viewDesignerItem.accelerator = f8;
2712 else if(client && !strcmp(dataType.name, "Designer"))
2714 CodeEditor codeEditor = ((Designer)client).codeEditor;
2717 SetPrivateModule(codeEditor.privateModule);
2718 SetCurrentContext(codeEditor.globalContext);
2719 SetTopContext(codeEditor.globalContext);
2720 SetGlobalContext(codeEditor.globalContext);
2721 SetDefines(&codeEditor.defines);
2722 SetImports(&codeEditor.imports);
2726 SetPrivateModule(null);
2727 SetCurrentContext(null);
2728 SetTopContext(null);
2729 SetGlobalContext(null);
2734 SetActiveDesigner((Designer)client);
2736 sheet.codeEditor = codeEditor;
2737 toolBox.codeEditor = codeEditor;
2739 viewCodeItem.parent = viewMenu;
2740 if(activeChild != client)
2742 viewDesignerItem.parent = viewMenu;
2743 viewDesignerItem.accelerator = f8;
2744 viewCodeItem.accelerator = 0;
2748 viewDesignerItem.parent = null;
2749 viewCodeItem.accelerator = f8;
2755 sheet.codeEditor = null;
2756 toolBox.codeEditor = null;
2757 SetActiveDesigner(null);
2759 viewDesignerItem.parent = null;
2760 viewCodeItem.parent = null;
2763 SheetSelected(sheet.sheetSelected);
2766 projectCompileItem = null;
2771 if(client && client._class == eSystem_FindClass(__thisModule, "CodeEditor")) // !strcmp(client._class.name, "CodeEditor")
2773 CodeEditor codeEditor = (CodeEditor)client;
2774 EditBox editBox = codeEditor.editBox;
2776 statusBar.AddField(pos);
2778 caps = { width = 40, text = $"CAPS", color = app.GetKeyState(capsState) ? black : Color { 128, 128, 128 } };
2779 statusBar.AddField(caps);
2781 ovr = { width = 30, text = $"OVR", color = (editBox && editBox.overwrite) ? black : Color { 128, 128, 128 } };
2782 statusBar.AddField(ovr);
2784 num = { width = 30, text = $"NUM", color = app.GetKeyState(numState) ? black : Color { 128, 128, 128 } };
2785 statusBar.AddField(num);
2787 //statusBar.text = "Ready";
2789 if(projectView && projectView.project)
2791 bool isCObject = false;
2792 ProjectNode node = projectView.GetNodeFromWindow(client, null, false);
2793 if(!node && (node = projectView.GetNodeFromWindow(client, null, true)))
2797 char nodeName[MAX_FILENAME];
2798 char name[MAX_FILENAME+96];
2800 ChangeExtension(node.name, "c", nodeName);
2801 sprintf(name, $"Compile %s", isCObject ? nodeName : node.name);
2802 projectCompileItem =
2804 copyText = true, text = name, c, ctrlF7, disabled = projectView.buildInProgress;
2806 bool NotifySelect(MenuItem selection, Modifiers mods)
2810 bool result = false;
2811 bool isCObject = false;
2812 ProjectNode node = null;
2813 for(p : ide.workspace.projects)
2815 node = projectView.GetNodeFromWindow(activeClient, p, false);
2818 if(!node && (node = projectView.GetNodeFromWindow(activeClient, null, true)))
2822 List<ProjectNode> nodes { };
2824 projectView.Compile(node.project, nodes, mods.ctrl && mods.shift, isCObject ? cObject : normal);
2829 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
2834 projectMenu.AddDynamic(projectCompileItem, ide, false);
2840 caps = ovr = num = null;
2845 bool OnClose(bool parentClosing)
2847 //return !projectView.buildInProgress;
2848 if(projectView && projectView.buildInProgress)
2850 if(DontTerminateDebugSession($"Close IDE"))
2852 if(findInFilesDialog)
2853 findInFilesDialog.SearchStop();
2856 workspace.timer.Stop();
2859 ideMainFrame.Destroy(0);
2866 bool passThrough = false;
2867 bool debugStart = false;
2868 bool debugWorkDir = false;
2869 char * passDebugWorkDir = null;
2870 bool openAsText = false;
2871 DynamicString passArgs { };
2874 for(c = 1; c<app.argc; c++)
2878 char * arg = app.argv[c];
2879 char * buf = new char[strlen(arg)*2+1];
2881 passArgs.concat(" ");
2883 passArgs.concat(buf);
2886 else if(debugWorkDir)
2888 passDebugWorkDir = CopyString(app.argv[c]);
2889 StripQuotes(passDebugWorkDir, passDebugWorkDir);
2890 debugWorkDir = false;
2892 else if(!strcmp(app.argv[c], "-t"))
2894 else if(!strcmp(app.argv[c], "-no-parsing"))
2895 ide.noParsing = true;
2896 else if(!strcmp(app.argv[c], "-debug-start"))
2898 else if(!strcmp(app.argv[c], "-debug-work-dir"))
2899 debugWorkDir = true;
2900 else if(!strcmp(app.argv[c], "-@"))
2904 char fullPath[MAX_LOCATION];
2905 char parentPath[MAX_LOCATION];
2906 char ext[MAX_EXTENSION];
2908 FileAttribs dirAttribs;
2909 GetWorkingDir(fullPath, MAX_LOCATION);
2910 PathCat(fullPath, app.argv[c]);
2911 StripLastDirectory(fullPath, parentPath);
2912 GetExtension(app.argv[c], ext);
2913 isProject = !openAsText && !strcmpi(ext, "epj");
2915 if(isProject && c > (debugStart ? 2 : 1)) continue;
2917 // Create directory for projects (only)
2918 if(((dirAttribs = FileExists(parentPath)) && dirAttribs.isDirectory) || isProject)
2920 if(isProject && !FileExists(fullPath))
2922 char name[MAX_LOCATION];
2923 NewProjectDialog newProjectDialog;
2927 projectView.visible = false;
2928 if(!projectView.Destroy(0))
2932 newProjectDialog = { master = this };
2934 strcpy(name, app.argv[c]);
2935 StripExtension(name);
2936 GetLastDirectory(name, name);
2937 newProjectDialog.projectName.contents = name;
2938 newProjectDialog.projectName.NotifyModified(newProjectDialog, newProjectDialog.projectName);
2939 newProjectDialog.locationEditBox.path = parentPath;
2940 newProjectDialog.NotifyModifiedLocation(newProjectDialog.locationEditBox);
2942 incref newProjectDialog;
2943 newProjectDialog.Modal();
2946 ideSettings.AddRecentProject(projectView.fileName);
2947 ide.UpdateRecentMenus();
2948 settingsContainer.Save();
2950 delete newProjectDialog;
2951 // Open only one project
2955 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, openAsText ? "txt" : null, yes, normal, false);
2957 else if(strstr(fullPath, "http://") == fullPath)
2958 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, openAsText ? "txt" : null, yes, normal, false);
2961 if(passThrough && projectView && projectView.project && workspace)
2962 workspace.commandLineArgs = passArgs;
2963 if(passDebugWorkDir && projectView && projectView.project && workspace)
2965 workspace.debugDir = passDebugWorkDir;
2966 delete passDebugWorkDir;
2969 ;//MenuDebugStart(debugStartResumeItem, 0); // <-- how TODO this without getting into the app.Wait lock
2971 UpdateToolBarActiveConfigs(false);
2972 UpdateToolBarActiveCompilers();
2979 // IS THIS NEEDED? WASN'T HERE BEFORE... Crashes on getting node's projectView otherwise
2982 projectView.visible = false;
2983 projectView.Destroy(0);
2986 #ifdef GDB_DEBUG_GUI
2987 gdbDialog.Destroy(0);
2992 void SetPath(bool projectsDirs, CompilerConfig compiler, ProjectConfig config, int bitDepth)
2996 char * oldPaths[128];
2997 String oldList = new char[maxPathLen];
2998 Array<String> newExePaths { };
2999 //Map<String, bool> exePathExists { };
3001 #if defined(__unix__) || defined(__APPLE__)
3002 Array<String> newLibPaths { };
3003 Map<String, bool> libPathExists { };
3008 for(prj : workspace.projects)
3010 DirExpression targetDirExp;
3012 // SKIP FIRST PROJECT...
3013 if(prj == workspace.projects.firstIterator.data) continue;
3015 // NOTE: Right now the additional project config dir will be
3016 // obtained when the debugger is started, so toggling it
3017 // while building will change which library gets used.
3018 // To go with the initial state, e.g. when F5 was pressed,
3019 // we nould need to keep a list of all project's active
3020 // config upon startup.
3021 targetDirExp = prj.GetTargetDir(compiler, prj.config, bitDepth);
3023 /*if(prj.config.targetType == sharedLibrary && prj.config.debug)
3027 for(cfg = prj.configurations.first; cfg; cfg = cfg.next)
3028 if(cfg.targetType == sharedLibrary && cfg.debug && !strcmpi(cfg.name, "Debug"))
3032 for(cfg = prj.configurations.first; cfg; cfg = cfg.next)
3033 if(cfg.targetType == sharedLibrary && cfg.debug)
3037 if(targetDirExp.dir)
3039 char buffer[MAX_LOCATION];
3040 #if defined(__WIN32__)
3041 Array<String> paths = newExePaths;
3043 Array<String> paths = newLibPaths;
3045 GetSystemPathBuffer(buffer, prj.topNode.path);
3046 PathCat(buffer, targetDirExp.dir);
3049 if(!fstrcmp(p, buffer))
3056 paths.Add(CopyString(buffer));
3058 delete targetDirExp;
3062 for(item : compiler.executableDirs)
3065 for(p : newExePaths)
3067 if(!fstrcmp(p, item))
3074 newExePaths.Add(CopySystemPath(item));
3077 GetEnvironment("PATH", oldList, maxPathLen);
3079 printf("Old value of PATH: %s\n", oldList);
3081 count = TokenizeWith(oldList, sizeof(oldPaths) / sizeof(char *), oldPaths, pathListSep, false);
3082 for(c = 0; c < count; c++)
3085 for(p : newExePaths)
3087 if(!fstrcmp(p, oldPaths[c]))
3094 newExePaths.Add(CopySystemPath(oldPaths[c]));
3098 for(path : newExePaths)
3099 len += strlen(path) + 1;
3100 newList = new char[len + 1];
3102 for(path : newExePaths)
3104 strcat(newList, path);
3105 strcat(newList, pathListSep);
3107 newList[len - 1] = '\0';
3108 SetEnvironment("PATH", newList);
3110 printf("New value of PATH: %s\n", newList);
3117 #if defined(__unix__) || defined(__APPLE__)
3119 for(item : compiler.libraryDirs)
3121 if(!libPathExists[item]) // fstrcmp should be used
3123 String s = CopyString(item);
3125 libPathExists[s] = true;
3129 #if defined(__APPLE__)
3130 GetEnvironment("DYLD_LIBRARY_PATH", oldList, maxPathLen);
3132 GetEnvironment("LD_LIBRARY_PATH", oldList, maxPathLen);
3135 printf("Old value of [DY]LD_LIBRARY_PATH: %s\n", oldList);
3137 count = TokenizeWith(oldList, sizeof(oldPaths) / sizeof(char *), oldPaths, pathListSep, false);
3138 for(c = 0; c < count; c++)
3140 if(!libPathExists[oldPaths[c]]) // fstrcmp should be used
3142 String s = CopyString(oldPaths[c]);
3144 libPathExists[s] = true;
3149 for(path : newLibPaths)
3150 len += strlen(path) + 1;
3151 newList = new char[len + 1];
3153 for(path : newLibPaths)
3155 strcat(newList, path);
3156 strcat(newList, pathListSep);
3158 newList[len - 1] = '\0';
3159 #if defined(__APPLE__)
3160 SetEnvironment("DYLD_LIBRARY_PATH", newList);
3162 SetEnvironment("LD_LIBRARY_PATH", newList);
3165 printf("New value of [DY]LD_LIBRARY_PATH: %s\n", newList);
3171 delete libPathExists;
3174 if(compiler.distccEnabled && compiler.distccHosts)
3175 SetEnvironment("DISTCC_HOSTS", compiler.distccHosts);
3180 void DestroyTemporaryProjectDir()
3182 if(tmpPrjDir && tmpPrjDir[0])
3184 if(FileExists(tmpPrjDir).isDirectory)
3185 DestroyDir(tmpPrjDir);
3186 property::tmpPrjDir = null;
3192 // Graphics Driver Menu
3196 app.currentSkin.selectionColor = selectionColor;
3197 app.currentSkin.selectionText = selectionText;
3201 driverItems = new MenuItem[app.numDrivers];
3202 for(c = 0; c < app.numDrivers; c++)
3204 driverItems[c] = MenuItem { driversMenu, app.drivers[c], NotifySelect = NotifySelectDisplayDriver };
3205 driverItems[c].id = c;
3206 driverItems[c].isRadio = true;
3209 driverItems = new MenuItem[2];
3210 #if defined(__unix__)
3211 driverItems[0] = MenuItem { driversMenu, "X", NotifySelect = NotifySelectDisplayDriver };
3212 driverItems[0].id = 0;
3213 driverItems[0].isRadio = true;
3215 driverItems[0] = MenuItem { driversMenu, "GDI", NotifySelect = NotifySelectDisplayDriver };
3216 driverItems[0].id = 0;
3217 driverItems[0].isRadio = true;
3219 driverItems[1] = MenuItem { driversMenu, "OpenGL", NotifySelect = NotifySelectDisplayDriver };
3220 driverItems[1].id = 1;
3221 driverItems[1].isRadio = true;
3223 /* skinItems = new MenuItem[app.numSkins];
3224 for(c = 0; c < app.numSkins; c++)
3226 skinItems[c] = MenuItem {skinsMenu, app.skins[c], NotifySelect = NotifySelectDisplaySkin };
3227 skinItems[c].id = c;
3228 skinItems[c].isRadio = true;
3231 ideFileDialog.master = this;
3232 ideProjectFileDialog.master = this;
3234 //SetDriverAndSkin();
3238 void UpdateRecentMenus()
3241 Menu fileMenu = menu.FindMenu($"File");
3242 Menu recentFiles = fileMenu.FindMenu($"Recent Files");
3243 Menu recentProjects = fileMenu.FindMenu($"Recent Projects");
3244 char * itemPath = new char[MAX_LOCATION];
3245 char * itemName = new char[MAX_LOCATION+4];
3248 recentFiles.Clear();
3251 for(recent : ideSettings.recentFiles)
3253 strncpy(itemPath, recent, MAX_LOCATION); itemPath[MAX_LOCATION-1] = '\0';
3254 MakeSystemPath(itemPath);
3255 snprintf(itemName, MAX_LOCATION+4, "%d %s", 1 + c, itemPath); itemName[MAX_LOCATION+4-1] = '\0';
3256 recentFiles.AddDynamic(MenuItem { copyText = true, text = itemName, (Key)k1 + c, id = c, NotifySelect = ide.FileRecentFile }, ide, true);
3260 recentProjects.Clear();
3262 for(recent : ideSettings.recentProjects)
3264 strncpy(itemPath, recent, MAX_LOCATION); itemPath[MAX_LOCATION-1] = '\0';
3265 MakeSystemPath(itemPath);
3266 snprintf(itemName, MAX_LOCATION+4, "%d %s", 1 + c, itemPath); itemName[MAX_LOCATION+4-1] = '\0';
3267 recentProjects.AddDynamic(MenuItem { copyText = true, text = itemName, (Key)k1 + c, id = c, NotifySelect = ide.FileRecentProject }, ide, true);
3283 void DestroyDir(char * path)
3285 RecursiveDeleteFolderFSI fsi { };
3290 #if defined(__WIN32__)
3291 define sdkDirName = "Ecere SDK";
3293 define sdkDirName = "ecere";
3296 void FindAndShellOpenInstalledFolder(char * name)
3298 char * p = new char[MAX_LOCATION];
3299 char * v = new char[maxPathLen];
3302 Array<String> paths { };
3304 strncpy(p, settingsContainer.moduleLocation, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3305 StripLastDirectory(p, p);
3307 paths.Add(CopyString(p));
3308 #if defined(__WIN32__)
3309 GetEnvironment("ECERE_SDK_SRC", v, maxPathLen);
3312 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3313 PathCat(p, name); paths.Add(CopyString(p));
3315 GetEnvironment("AppData", v, maxPathLen);
3318 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3319 PathCat(p, sdkDirName); PathCat(p, name); paths.Add(CopyString(p));
3321 GetEnvironment("ProgramFiles", v, maxPathLen);
3324 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3325 PathCat(p, sdkDirName); PathCat(p, name); paths.Add(CopyString(p));
3327 GetEnvironment("ProgramFiles(x86)", v, maxPathLen);
3330 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3331 PathCat(p, sdkDirName); PathCat(p, name); paths.Add(CopyString(p));
3333 GetEnvironment("SystemDrive", v, maxPathLen);
3336 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3337 PathCat(p, "Program Files"); PathCat(p, sdkDirName); PathCat(p, name); paths.Add(CopyString(p));
3340 GetEnvironment("XDG_DATA_DIRS", v, maxPathLen);
3341 numTokens = TokenizeWith(v, sizeof(tokens) / sizeof(byte *), tokens, ":", false);
3342 for(c=0; c<numTokens; c++)
3344 strncpy(p, tokens[c], MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3345 PathCat(p, sdkDirName); PathCat(p, name); paths.Add(CopyString(p));
3350 strncpy(p, path, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3351 if(FileExists(p).isDirectory)
3363 void FindAndShellOpenInstalledFile(char * subdir, char * name)
3365 char * p = new char[MAX_LOCATION];
3366 char * v = new char[maxPathLen];
3369 Array<String> paths { };
3371 strncpy(p, settingsContainer.moduleLocation, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3372 paths.Add(CopyString(p));
3373 StripLastDirectory(p, p);
3375 paths.Add(CopyString(p));
3376 #if defined(__WIN32__)
3377 GetEnvironment("ECERE_SDK_SRC", v, maxPathLen);
3380 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3381 PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3383 GetEnvironment("AppData", v, maxPathLen);
3386 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3387 PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3389 GetEnvironment("ProgramFiles", v, maxPathLen);
3392 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3393 PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3395 GetEnvironment("ProgramFiles(x86)", v, maxPathLen);
3398 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3399 PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3401 GetEnvironment("SystemDrive", v, maxPathLen);
3404 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3405 PathCat(p, "Program Files"); PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3408 GetEnvironment("XDG_DATA_DIRS", v, maxPathLen);
3409 numTokens = TokenizeWith(v, sizeof(tokens) / sizeof(byte *), tokens, ":", false);
3410 for(c=0; c<numTokens; c++)
3412 strncpy(p, tokens[c], MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3413 PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3418 strncpy(p, path, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3420 if(FileExists(p).isFile)
3432 class RecursiveDeleteFolderFSI : NormalFileSystemIterator
3434 bool preserveRootFolder;
3436 void OutFolder(char * folderPath, bool isRoot)
3438 if(!(preserveRootFolder && isRoot))
3439 RemoveDir(folderPath);
3442 bool OnFile(char * filePath)
3444 DeleteFile(filePath);
3449 class IDEApp : GuiApplication
3451 //driver = "Win32Console";
3452 // driver = "OpenGL";
3456 TempFile includeFile { };
3460 char ext[MAX_EXTENSION];
3461 SetLoggingMode(stdOut, null);
3462 //SetLoggingMode(debug, null);
3464 settingsContainer.Load();
3465 if(argc > 1 && !strcmpi(GetExtension(argv[1], ext), "3ds"))
3467 app.driver = "OpenGL";
3468 ide.driverItems[1].checked = true;
3472 #if defined(__unix__) || defined(__APPLE__)
3473 app.driver = (ideSettings.displayDriver && !strcmp(ideSettings.displayDriver, "OpenGL")) ? ideSettings.displayDriver : "X";
3475 app.driver = (ideSettings.displayDriver && !strcmp(ideSettings.displayDriver, "OpenGL")) ? ideSettings.displayDriver : "GDI";
3477 ide.driverItems[ideSettings.displayDriver && !strcmp(ideSettings.displayDriver,"OpenGL")].checked = true;
3482 desktop.text = titleECEREIDE;
3485 for(c = 1; c<app.argc; c++)
3487 char fullPath[MAX_LOCATION];
3488 GetWorkingDir(fullPath, MAX_LOCATION);
3489 PathCat(fullPath, app.argv[c]);
3490 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, null, yes, normal, false);
3494 if(!LoadIncludeFile())
3495 PrintLn("error: unable to load :crossplatform.mk file inside ide binary.");
3500 bool LoadIncludeFile()
3502 bool result = false;
3503 File include = FileOpen(":crossplatform.mk", read);
3506 File f = includeFile;
3509 for(; !include.Eof(); )
3512 int count = include.Read(buffer, 1, 4096);
3513 f.Write(buffer, 1, count);
3523 IDEMainFrame ideMainFrame { };
3525 define app = ((IDEApp)__thisModule);
3527 define titleECEREIDE = $"ECERE IDE (Debug)";
3529 define titleECEREIDE = $"ECERE IDE";