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; };
250 ToolSeparator separator4 { this };
254 ToolButton buttonDebugStartResume { this, toolTip = $"Start", menuItemPtr = IDEItem(debugStartResumeItem), disabled = true; };
256 ToolButton buttonDebugRestart { this, toolTip = $"Restart", menuItemPtr = IDEItem(debugRestartItem), disabled = true; };
258 ToolButton buttonDebugPause { this, toolTip = $"Break", menuItemPtr = IDEItem(debugBreakItem), disabled = true; };
260 ToolButton buttonDebugStop { this, toolTip = $"Stop", menuItemPtr = IDEItem(debugStopItem), disabled = true; };
262 //ToolButton buttonRun { this, toolTip = $"Run", menuItemPtr = IDEItem(projectRunItem) };
264 ToolButton buttonDebugStepInto { this, toolTip = $"Step Into", menuItemPtr = IDEItem(debugStepIntoItem), disabled = true; };
266 ToolButton buttonDebugStepOver { this, toolTip = $"Step Over", menuItemPtr = IDEItem(debugStepOverItem), disabled = true; };
268 ToolButton buttonDebugStepOut { this, toolTip = $"Step Out", menuItemPtr = IDEItem(debugStepOutItem), disabled = true; };
270 ToolButton buttonDebugSkipStepOver { this, toolTip = $"Step Over Skipping Breakpoints", menuItemPtr = IDEItem(debugSkipStepOverItem), disabled = true; };
272 ToolSeparator separator5 { this };
274 Window spacer5 { this, size = { 4 } };
278 this, toolTip = $"Active Configuration(s)", size = { 160 }, disabled = true;
279 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
283 for(prj : ide.workspace.projects)
285 for(cfg : prj.configurations)
287 if(cfg.name && !strcmp(cfg.name, row.string))
294 ide.UpdateToolBarActiveConfigs(true);
295 ide.projectView.Update(null);
301 Window spacer6 { this, size = { 4 } };
303 DropBox activeCompiler
305 this, toolTip = $"Active Compiler", size = { 160 }, disabled = true;
306 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
308 if(ide.workspace && ide.projectView && row && strcmp(row.string, ide.workspace.compiler))
310 bool silent = ide.projectView.buildInProgress == none ? false : true;
311 CompilerConfig compiler = ideSettings.GetCompilerConfig(row.string);
312 ide.workspace.compiler = row.string;
313 ide.projectView.ShowOutputBuildLog(!silent);
315 ide.projectView.DisplayCompiler(compiler, false);
316 for(prj : ide.workspace.projects)
317 ide.projectView.ProjectPrepareCompiler(prj, compiler, silent);
319 ide.workspace.Save();
325 DropBox activeBitDepth
327 this, toolTip = $"Active Bit Depth", size = { 60 }, disabled = true;
328 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
330 if(ide.workspace && ide.projectView && row)
332 bool silent = ide.projectView.buildInProgress == none ? false : true;
333 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
334 ide.workspace.bitDepth = (int)row.tag;
335 ide.projectView.ShowOutputBuildLog(!silent);
337 ide.projectView.DisplayCompiler(compiler, false);
338 for(prj : ide.workspace.projects)
339 ide.projectView.ProjectPrepareCompiler(prj, compiler, silent);
341 ide.workspace.Save();
347 Window spacer7 { this, size = { 4 } };
352 row = activeBitDepth.AddString("Auto");
354 activeBitDepth.AddString("32 bit").tag = 32;
355 activeBitDepth.AddString("64 bit").tag = 64;
356 activeBitDepth.currentRow = row;
361 class IDEMainFrame : Window
363 background = formColor;
364 borderStyle = sizable;
368 minClientSize = { 600, 300 };
370 icon = { ":icon.png" };
371 text = titleECEREIDE;
375 anchor = { top = 0, right = 0, bottom = 0 };
378 anchor = { left = 0, top = 0, right = 0, bottom = 0 };
385 isActiveClient = true;
387 direction = vertical;
388 background = formColor;
389 anchor = { left = 0, top = 0, right = 0, bottom = 0 };
397 ((IDEWorkSpace)master).toolBar = null;
400 IDEWorkSpace ideWorkSpace { stack, this, toolBar = toolBar };
403 define ide = ideMainFrame.ideWorkSpace;
405 class IDEWorkSpace : Window
407 background = Color { 85, 85, 85 };
410 hasVertScroll = true;
411 hasHorzScroll = true;
413 isActiveClient = true;
414 anchor = { left = 0, top = 0, right = 0, bottom = 0 };
418 MenuItem * driverItems, * skinItems;
419 StatusField pos { width = 150 };
420 StatusField ovr, caps, num;
422 BitmapResource back { ":ecereBack.jpg", window = this };
423 BitmapResource bmpBp { ":codeMarks/breakpoint.png", window = this };
424 BitmapResource bmpBpDisabled { ":codeMarks/breakpointDisabled.png", window = this };
425 BitmapResource bmpBpHalf { ":codeMarks/breakpointHalf.png", window = this };
426 BitmapResource bmpBpHalfDisabled { ":codeMarks/breakpointHalfDisabled.png", window = this };
427 BitmapResource bmpCursor { ":codeMarks/cursor.png", window = this };
428 BitmapResource bmpCursorError { ":codeMarks/cursorError.png", window = this };
429 BitmapResource bmpTopFrame { ":codeMarks/topFrame.png", window = this };
430 BitmapResource bmpTopFrameError { ":codeMarks/topFrameError.png", window = this };
431 BitmapResource bmpTopFrameHalf { ":codeMarks/topFrameHalf.png", window = this };
432 BitmapResource bmpTopFrameHalfError { ":codeMarks/topFrameHalfError.png", window = this };
434 Debugger debugger { };
436 ProjectView projectView;
438 OutputView outputView
442 void OnGotoError(char * line, bool noParsing)
444 ide.GoToError(line, noParsing);
447 void OnCodeLocationParseAndGoTo(char * line)
449 ide.CodeLocationParseAndGoTo(line, ide.findInFilesDialog.findProject, ide.findInFilesDialog.findDir);
452 bool OnKeyDown(Key key, unichar ch)
457 if(activeBox != findBox || !ide.findInFilesDialog || !ide.findInFilesDialog.SearchAbort())
458 ide.ShowCodeEditor();
462 OutputView::OnKeyDown(key, ch);
469 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
472 ide.RepositionWindows(false);
476 bool OnClose(bool parentClosing)
480 ide.RepositionWindows(false);
481 return parentClosing;
485 CallStackView callStackView
487 parent = this, font = { panelFont.faceName, panelFont.size };
489 void OnSelectFrame(int frameIndex)
491 ide.debugger.GoToStackFrameLine(frameIndex, true);
493 ide.debugger.SelectFrame(frameIndex);
496 void OnToggleBreakpoint()
498 Debugger debugger = ide.debugger;
499 if(debugger.activeFrame && debugger.activeFrame.absoluteFile)
501 int line = debugger.activeFrame.line;
502 char name[MAX_LOCATION];
504 // TOFIX: Improve on this, don't use only filename, make a function
505 GetLastDirectory(debugger.activeFrame.absoluteFile, name);
506 if(ide && ide.workspace)
508 for(p : ide.workspace.projects)
510 if(p.topNode.Find(name, false))
518 for(p : ide.workspace.projects)
520 if(IsPathInsideOf(debugger.activeFrame.absoluteFile, p.topNode.path))
528 debugger.ToggleBreakpoint(debugger.activeFrame.absoluteFile, line, prj);
531 CodeEditor codeEditor = (CodeEditor)ide.FindWindow(debugger.activeFrame.absoluteFile);
532 if(codeEditor) { codeEditor.Update(null); Activate(); }
537 bool OnKeyDown(Key key, unichar ch)
541 case escape: ide.ShowCodeEditor(); break;
546 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
549 ide.RepositionWindows(false);
553 bool OnClose(bool parentClosing)
557 ide.RepositionWindows(false);
558 return parentClosing;
561 void OnRedraw(Surface surface)
563 Debugger debugger = ide.debugger;
564 Frame activeFrame = debugger.activeFrame;
568 int lineCursor, lineTopFrame, activeThread, hitThread;
569 int lineH, scrollY, boxH;
571 Breakpoint bp = null;
574 scrollY = editBox.scroll.y;
575 displaySystem.FontExtent(editBox.font.font, " ", 1, null, &lineH);
576 activeThread = debugger.activeThread;
577 hitThread = debugger.hitThread;
578 debugger.GetCallStackCursorLine(&error, &lineCursor, &lineTopFrame);
580 // TODO: improve bp drawing... it should be visible even if it's not on the activeFrame
581 if(activeFrame.absoluteFile)
583 for(i : ide.workspace.breakpoints; i.type == user)
585 if(i.absoluteFilePath && i.absoluteFilePath[0] &&
586 !fstrcmp(i.absoluteFilePath, activeFrame.absoluteFile) &&
587 activeFrame.line == i.line)
595 DrawLineMarginIcon(surface,
596 /*(lineCursor == 1 || lineTopFrame == 1) ? */ide.bmpBpHalf/* : ide.bmpBp*/,
597 lineCursor /*1*/, lineH, scrollY, boxH);
599 if(activeThread && activeThread == hitThread && debugger.bpHit && debugger.bpHit.type == user)
600 DrawLineMarginIcon(surface,
601 (lineCursor == 1 || lineTopFrame == 1) ? ide.bmpBpHalf : ide.bmpBp,
602 1, lineH, scrollY, boxH);
604 DrawLineMarginIcon(surface, error ? ide.bmpCursorError : ide.bmpCursor, lineCursor, lineH, scrollY, boxH);
605 if(bp && lineCursor == 1) //activeThread && activeThread == hitThread && debugger.bpHit && debugger.bpHit.type == user)
606 bmp = error ? ide.bmpTopFrameHalfError : ide.bmpTopFrameHalf;
608 bmp = error ? ide.bmpTopFrameError : ide.bmpTopFrame;
609 DrawLineMarginIcon(surface, bmp, lineTopFrame, lineH, scrollY, boxH);
611 if(editBox.horzScroll && editBox.horzScroll.visible)
613 surface.SetBackground(control);
614 surface.Area(0, editBox.clientSize.h, 20 - 1, clientSize.h - 1);
619 WatchesView watchesView { parent = this };
620 ThreadsView threadsView
622 parent = this, font = { panelFont.faceName, panelFont.size };
624 bool OnKeyDown(Key key, unichar ch)
628 case escape: ide.ShowCodeEditor(); break;
633 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
636 ide.RepositionWindows(false);
640 bool OnClose(bool parentClosing)
644 ide.RepositionWindows(false);
645 return parentClosing;
648 void OnSelectThread(int threadId)
651 ide.debugger.SelectThread(threadId);
654 bool OnGetThreadsInfo(int * activeThread, int * hitThread, int * signalThread)
657 Debugger debugger = ide.debugger;
658 *activeThread = debugger.activeThread;
659 *hitThread = debugger.hitThread;
660 *signalThread = debugger.signalThread;
665 BreakpointsView breakpointsView { parent = this };
667 ToolBox toolBox { parent = this };
668 Sheet sheet { parent = this };
671 property char * tmpPrjDir { set { delete tmpPrjDir; if(value) tmpPrjDir = CopyString(value); } get { return tmpPrjDir; } };
673 Menu fileMenu { menu, $"File", f, hasMargin = true };
676 fileMenu, $"New", n, ctrlN;
677 bitmap = { ":actions/docNew.png" };
678 bool NotifySelect(MenuItem selection, Modifiers mods)
680 Window document = (Window)NewCodeEditor(this, normal, false);
681 document.NotifySaved = DocumentSaved;
685 MenuItem fileOpenItem
687 fileMenu, $"Open...", o, ctrlO;
688 bitmap = { ":actions/docOpen.png" };
689 bool NotifySelect(MenuItem selection, Modifiers mods)
691 if(!projectView && ideSettings.ideFileDialogLocation)
692 ideFileDialog.currentDirectory = ideSettings.ideFileDialogLocation;
695 if(ideFileDialog.Modal() == ok)
697 bool gotWhatWeWant = false;
699 int numSelections = ideFileDialog.numSelections;
700 char ** multiFilePaths = ideFileDialog.multiFilePaths;
702 for(c = 0; c < numSelections; c++)
704 if(OpenFile(multiFilePaths[c], normal, true, fileTypes[ideFileDialog.fileType].typeExtension, no, normal, mods.ctrl && mods.shift))
705 gotWhatWeWant = true;
708 MessageBox { type = yesNo, master = this, text = $"Error opening file",
709 contents = $"Open a different file?" }.Modal() == no)
711 if(!projectView && gotWhatWeWant)
712 ChangeFileDialogsDirectory(ideFileDialog.currentDirectory, true);
722 MenuItem fileCloseItem { fileMenu, $"Close", c, ctrlF4, NotifySelect = MenuFileClose };
723 MenuDivider { fileMenu };
724 MenuItem fileSaveItem
726 fileMenu, $"Save", s, ctrlS, bitmap = { ":actions/docSave.png" };
728 // For the toolbar button; clients can still override that for the menu item
729 bool Window::NotifySelect(MenuItem selection, Modifiers mods)
731 Window w = activeClient;
733 w.MenuFileSave(null, 0);
737 MenuItem fileSaveAsItem { fileMenu, $"Save As...", a };
738 MenuItem fileSaveAllItem { fileMenu, $"Save All", l, NotifySelect = MenuFileSaveAll, bitmap = { ":actions/docSaveAll.png" } };
739 MenuDivider { fileMenu };
742 fileMenu, $"Find In Files...", f, Key { f, ctrl = true , shift = true };
743 bool NotifySelect(MenuItem selection, Modifiers mods)
745 findInFilesDialog.replaceMode = false;
746 findInFilesDialog.Show();
750 MenuItem replaceInFiles
752 fileMenu, $"Replace In Files...", e, Key { r, ctrl = true , shift = true };
753 bool NotifySelect(MenuItem selection, Modifiers mods)
755 findInFilesDialog.replaceMode = true;
756 findInFilesDialog.Show();
760 MenuDivider { fileMenu };
761 MenuItem globalSettingsItem
763 fileMenu, $"Global Settings...", g;
764 bool NotifySelect(MenuItem selection, Modifiers mods)
766 globalSettingsDialog.master = this;
767 if(ide.workspace && ide.workspace.compiler)
768 globalSettingsDialog.workspaceActiveCompiler = ide.workspace.compiler;
769 else if(ideSettings.defaultCompiler)
770 globalSettingsDialog.workspaceActiveCompiler = ideSettings.defaultCompiler;
771 globalSettingsDialog.Modal();
775 MenuDivider { fileMenu };
776 Menu recentFiles { fileMenu, $"Recent Files", r };
777 Menu recentProjects { fileMenu, $"Recent Projects", p };
778 MenuDivider { fileMenu };
781 fileMenu, $"Exit", x, altF4;
783 bool NotifySelect(MenuItem selection, Modifiers mods)
785 ideMainFrame.Destroy(0);
790 bool FileRecentFile(MenuItem selection, Modifiers mods)
793 for(file : ideSettings.recentFiles)
795 if(id == selection.id)
798 char extension[MAX_EXTENSION] = "";
799 GetExtension(file, extension);
800 isProjectFile = (!strcmpi(extension, "epj") || !strcmpi(extension, "ews"));
803 char * command = PrintString("ide ", isProjectFile ? "-t " : "", file);
808 OpenFile(file, normal, true, isProjectFile ? "txt" : null, no, normal, mods.ctrl && mods.shift);
816 bool FileRecentProject(MenuItem selection, Modifiers mods)
819 for(file : ideSettings.recentProjects)
821 if(id == selection.id)
825 char * command = PrintString("ide ", file);
830 OpenFile(file, normal, true, null, no, normal, mods.ctrl && mods.shift);
838 MenuPlacement editMenu { menu, $"Edit", e };
840 Menu projectMenu { menu, $"Menu"."Project", p, hasMargin = true };
841 MenuItem projectNewItem
843 projectMenu, $"New...", n, Key { n, true, true };
844 bitmap = { ":actions/projNew.png" };
845 bool NotifySelect(MenuItem selection, Modifiers mods)
847 if(!DontTerminateDebugSession($"New Project"))
850 NewProjectDialog newProjectDialog { master = this };
851 result = newProjectDialog.Modal();
856 newProjectDialog.CreateNewProject();
859 ideSettings.AddRecentProject(projectView.fileName);
860 ide.UpdateRecentMenus();
861 settingsContainer.Save();
869 MenuItem projectOpenItem
871 projectMenu, $"Open...", o, Key { o, true, true };
872 bitmap = { ":actions/projOpen.png" };
873 bool NotifySelect(MenuItem selection, Modifiers mods)
875 if(ideSettings.ideProjectFileDialogLocation)
876 ideProjectFileDialog.currentDirectory = ideSettings.ideProjectFileDialogLocation;
878 ideProjectFileDialog.text = openProjectFileDialogTitle;
879 if(ideProjectFileDialog.Modal() == ok)
881 OpenFile(ideProjectFileDialog.filePath, normal, true, projectTypes[ideProjectFileDialog.fileType].typeExtension, no, normal, mods.ctrl && mods.shift);
882 //ChangeProjectFileDialogDirectory(ideProjectFileDialog.currentDirectory);
887 MenuItem projectQuickItem
889 projectMenu, $"Quick...", q, f7, disabled = true;
890 bool NotifySelect(MenuItem selection, Modifiers mods)
893 QuickProjectDialog { this }.Modal();
897 MenuItem projectAddItem
899 projectMenu, $"Add project to workspace...", a, Key { a, true, true };
900 bitmap = { ":actions/projAdd.png" };
902 bool NotifySelect(MenuItem selection, Modifiers mods)
904 if(ideSettings.ideProjectFileDialogLocation)
905 ideProjectFileDialog.currentDirectory = ideSettings.ideProjectFileDialogLocation;
907 ideProjectFileDialog.text = addProjectFileDialogTitle;
910 if(ideProjectFileDialog.Modal() == ok)
912 if(OpenFile(ideProjectFileDialog.filePath, normal, true, projectTypes[ideProjectFileDialog.fileType].typeExtension, no, add, mods.ctrl && mods.shift))
914 if(MessageBox { type = yesNo, master = this, text = $"Error opening project file",
915 contents = $"Add a different project?" }.Modal() == no)
926 MenuItem projectCloseItem
928 projectMenu, $"Close", c, disabled = true;
929 bool NotifySelect(MenuItem selection, Modifiers mods)
933 if(!ide.DontTerminateDebugSession($"Project Close"))
939 MenuDivider { projectMenu };
940 MenuItem projectSettingsItem
942 projectMenu, $"Settings...", s, altF7, disabled = true;
943 bool NotifySelect(MenuItem selection, Modifiers mods)
945 projectView.MenuSettings(projectView.active ? selection : null, mods);
949 MenuDivider { projectMenu };
950 MenuItem projectBrowseFolderItem
952 projectMenu, $"Browse Project Folder", p, disabled = true;
953 bool NotifySelect(MenuItem selection, Modifiers mods)
956 projectView.MenuBrowseFolder(null, mods);
960 MenuDivider { projectMenu };
961 MenuItem projectRunItem
963 projectMenu, $"Run", r, ctrlF5, disabled = true;
964 bitmap = { ":actions/run.png" };
965 bool NotifySelect(MenuItem selection, Modifiers mods)
968 projectView.Run(null, mods);
972 MenuItem projectBuildItem
974 projectMenu, $"Build", b, f7, disabled = true;
975 bitmap = { ":actions/build.png" };
976 bool NotifySelect(MenuItem selection, Modifiers mods)
980 if(projectView.buildInProgress == none)
981 projectView.ProjectBuild(projectView.active ? selection : null, mods);
983 projectView.stopBuild = true;
988 MenuItem projectLinkItem
990 projectMenu, $"Relink", l, disabled = true;
991 bitmap = { ":actions/relink.png" };
992 bool NotifySelect(MenuItem selection, Modifiers mods)
995 projectView.ProjectLink(projectView.active ? selection : null, mods);
999 MenuItem projectRebuildItem
1001 projectMenu, $"Rebuild", d, shiftF7, disabled = true;
1002 bitmap = { ":actions/rebuild.png" };
1003 bool NotifySelect(MenuItem selection, Modifiers mods)
1006 projectView.ProjectRebuild(projectView.active ? selection : null, mods);
1010 MenuItem projectCleanTargetItem
1012 projectMenu, $"Clean Target", g, disabled = true;
1013 bitmap = { ":actions/clean.png" };
1014 bool NotifySelect(MenuItem selection, Modifiers mods)
1019 projectView.ProjectCleanTarget(projectView.active ? selection : null, mods);
1024 MenuItem projectCleanItem
1026 projectMenu, $"Clean", e, disabled = true;
1027 bitmap = { ":actions/clean.png" };
1028 bool NotifySelect(MenuItem selection, Modifiers mods)
1033 projectView.ProjectClean(projectView.active ? selection : null, mods);
1038 MenuItem projectRealCleanItem
1040 projectMenu, $"Real Clean", disabled = true;
1041 bitmap = { ":actions/clean.png" };
1042 bool NotifySelect(MenuItem selection, Modifiers mods)
1047 projectView.ProjectRealClean(projectView.active ? selection : null, mods);
1052 MenuItem projectRegenerateItem
1054 projectMenu, $"Regenerate Makefile", m, disabled = true;
1055 bitmap = { ":actions/regMakefile.png" };
1056 bool NotifySelect(MenuItem selection, Modifiers mods)
1059 projectView.ProjectRegenerate(projectView.active ? selection : null, mods);
1063 MenuItem projectCompileItem;
1064 Menu debugMenu { menu, $"Debug", d, hasMargin = true };
1065 MenuItem debugStartResumeItem
1067 debugMenu, $"Start", s, f5, disabled = true;
1068 bitmap = { ":actions/debug.png" };
1069 NotifySelect = MenuDebugStart;
1071 bool MenuDebugStart(MenuItem selection, Modifiers mods)
1075 debugStartResumeItem.disabled = true; // a very rare exception to calling AdjustDebugMenus
1076 if(!projectView.DebugStart())
1077 debugStartResumeItem.disabled = false; // same exception
1081 bool MenuDebugResume(MenuItem selection, Modifiers mods)
1084 projectView.DebugResume();
1087 MenuItem debugRestartItem
1089 debugMenu, $"Restart", r, Key { f5, ctrl = true, shift = true }, disabled = true;
1090 bitmap = { ":actions/restart.png" };
1091 bool NotifySelect(MenuItem selection, Modifiers mods)
1094 projectView.DebugRestart();
1098 MenuItem debugBreakItem
1100 debugMenu, $"Break", b, Key { pauseBreak, ctrl = true }, disabled = true;
1101 bitmap = { ":actions/pause.png" };
1102 bool NotifySelect(MenuItem selection, Modifiers mods)
1104 if(projectView && projectView.buildInProgress != none)
1107 projectView.DebugBreak();
1111 MenuItem debugStopItem
1113 debugMenu, $"Stop", p, shiftF5, disabled = true;
1114 bitmap = { ":actions/stopDebug.png" };
1115 bool NotifySelect(MenuItem selection, Modifiers mods)
1118 projectView.DebugStop();
1122 MenuDivider { debugMenu };
1123 MenuItem debugStepIntoItem
1125 debugMenu, $"Step Into", i, f11, disabled = true;
1126 bitmap = { ":actions/stepInto.png" };
1127 bool NotifySelect(MenuItem selection, Modifiers mods)
1130 projectView.DebugStepInto();
1134 MenuItem debugStepOverItem
1136 debugMenu, $"Step Over", v, f10, disabled = true;
1137 bitmap = { ":actions/stepOver.png" };
1138 bool NotifySelect(MenuItem selection, Modifiers mods)
1141 projectView.DebugStepOver(false);
1145 MenuItem debugStepOutItem
1147 debugMenu, $"Step Out", o, shiftF11, disabled = true;
1148 bitmap = { ":actions/stepOut.png" };
1149 bool NotifySelect(MenuItem selection, Modifiers mods)
1152 projectView.DebugStepOut(false);
1156 MenuPlacement debugRunToCursorItem { debugMenu, $"Run To Cursor", c };
1157 MenuItem debugSkipStepOverItem
1159 debugMenu, $"Step Over Skipping Breakpoints", e, shiftF10, disabled = true;
1160 bool NotifySelect(MenuItem selection, Modifiers mods)
1163 projectView.DebugStepOver(true);
1167 MenuItem debugSkipStepOutItem
1169 debugMenu, $"Step Out Skipping Breakpoints", t, Key { f11, ctrl = true, shift = true }, disabled = true;
1170 bitmap = { ":actions/skipBreaks.png" };
1171 bool NotifySelect(MenuItem selection, Modifiers mods)
1174 projectView.DebugStepOut(true);
1178 MenuPlacement debugSkipRunToCursorItem { debugMenu, $"Run To Cursor Skipping Breakpoints", u };
1179 MenuPlacement debugSkipRunToCursorAtSameLevelItem { debugMenu, $"Run To Cursor At Same Level Skipping Breakpoints", s };
1180 //MenuDivider { debugMenu };
1181 //MenuPlacement debugToggleBreakpoint { debugMenu, "Toggle Breakpoint", t };
1182 MenuPlacement imageMenu { menu, $"Image", i };
1183 Menu viewMenu { menu, $"View", v };
1184 MenuItem viewProjectItem
1186 viewMenu, $"Project View", j, alt0, disabled = true;
1187 bool NotifySelect(MenuItem selection, Modifiers mods)
1191 projectView.visible = true;
1192 projectView.Activate();
1197 MenuPlacement { viewMenu, $"View Designer" };
1198 MenuPlacement { viewMenu, $"View Code" };
1199 MenuPlacement { viewMenu, $"View Properties" };
1200 MenuPlacement { viewMenu, $"View Methods" };
1201 MenuItem viewDesignerItem
1203 viewMenu, $"View Designer", d, f8;
1204 bool NotifySelect(MenuItem selection, Modifiers mods)
1206 Window client = activeClient;
1207 Class dataType = client._class;
1208 if(!strcmp(dataType.name, "Designer"))
1210 client.visible = true;
1214 ((CodeEditor)client).ViewDesigner();
1218 MenuItem viewCodeItem
1220 viewMenu, $"View Code", c, f8;
1221 bool NotifySelect(MenuItem selection, Modifiers mods)
1223 Window client = activeClient;
1224 Class dataType = client._class;
1225 if(!strcmp(dataType.name, "Designer"))
1226 client = ((Designer)client).codeEditor;
1229 // Do this after so the caret isn't moved yet...
1230 client.visible = true;
1234 MenuItem viewPropertiesItem
1236 viewMenu, $"View Properties", p, f4;
1237 bool NotifySelect(MenuItem selection, Modifiers mods)
1239 sheet.visible = true;
1240 sheet.sheetSelected = properties;
1245 MenuItem viewMethodsItem
1247 viewMenu, $"View Methods", m, f4;
1248 bool NotifySelect(MenuItem selection, Modifiers mods)
1250 sheet.visible = true;
1251 sheet.sheetSelected = methods;
1256 MenuItem viewToolBoxItem
1258 viewMenu, $"View Toolbox", x, f12;
1259 bool NotifySelect(MenuItem selection, Modifiers mods)
1261 toolBox.visible = true;
1266 MenuItem viewOutputItem
1268 viewMenu, $"Output", o, alt2;
1269 bool NotifySelect(MenuItem selection, Modifiers mods)
1275 MenuItem viewWatchesItem
1277 viewMenu, $"Watches", w, alt3;
1278 bool NotifySelect(MenuItem selection, Modifiers mods)
1284 MenuItem viewThreadsItem
1286 viewMenu, $"Threads", t, alt4;
1287 bool NotifySelect(MenuItem selection, Modifiers mods)
1293 MenuItem viewBreakpointsItem
1295 viewMenu, $"Breakpoints", b, alt5;
1296 bool NotifySelect(MenuItem selection, Modifiers mods)
1298 breakpointsView.Show();
1302 MenuItem viewCallStackItem
1304 viewMenu, $"Call Stack", s, alt7;
1305 bool NotifySelect(MenuItem selection, Modifiers mods)
1307 callStackView.Show();
1311 MenuItem viewAllDebugViews
1313 viewMenu, $"All Debug Views", a, alt9;
1314 bool NotifySelect(MenuItem selection, Modifiers mods)
1319 callStackView.Show();
1320 breakpointsView.Show();
1324 #ifdef GDB_DEBUG_GUI
1325 MenuDivider { viewMenu };
1326 MenuItem viewGDBItem
1328 viewMenu, $"GDB Dialog", g, Key { f9, shift = true, ctrl = true };
1329 bool NotifySelect(MenuItem selection, Modifiers mods)
1336 MenuDivider { viewMenu };
1337 MenuItem viewColorPicker
1339 viewMenu, $"Color Picker...", c, Key { c, ctrl = true , shift = true };
1340 bool NotifySelect(MenuItem selection, Modifiers mods)
1342 ColorPicker colorPicker { master = this };
1343 colorPicker.Modal();
1347 MenuDivider { viewMenu };
1351 viewMenu, "Full Screen", f, checkable = true;
1353 bool NotifySelect(MenuItem selection, Modifiers mods)
1355 app.fullScreen ^= true;
1357 anchor = { 0, 0, 0, 0 };
1362 Menu driversMenu { viewMenu, $"Graphics Driver", v };
1363 //Menu skinsMenu { viewMenu, "GUI Skins", k };
1364 Menu windowMenu { menu, $"Window", w };
1365 MenuItem { windowMenu, $"Close All", l, NotifySelect = MenuWindowCloseAll };
1366 MenuDivider { windowMenu };
1367 MenuItem { windowMenu, $"Next", n, f6, NotifySelect = MenuWindowNext };
1368 MenuItem { windowMenu, $"Previous", p, shiftF6, NotifySelect = MenuWindowPrevious };
1369 MenuDivider { windowMenu };
1370 MenuItem { windowMenu, $"Cascade", c, NotifySelect = MenuWindowCascade };
1371 MenuItem { windowMenu, $"Tile Horizontally", h, NotifySelect = MenuWindowTileHorz };
1372 MenuItem { windowMenu, $"Tile Vertically", v, NotifySelect = MenuWindowTileVert };
1373 MenuItem { windowMenu, $"Arrange Icons", a, NotifySelect = MenuWindowArrangeIcons };
1374 MenuDivider { windowMenu };
1375 MenuItem { windowMenu, $"Windows...", w, NotifySelect = MenuWindowWindows };
1376 Menu helpMenu { menu, $"Help", h };
1379 helpMenu, $"API Reference", r, f1;
1380 bool NotifySelect(MenuItem selection, Modifiers mods)
1382 char * p = new char[MAX_LOCATION];
1384 strncpy(p, settingsContainer.moduleLocation, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
1385 PathCat(p, "documentor");
1386 #if defined(__WIN32__)
1387 ChangeExtension(p, "exe", p);
1389 if(FileExists(p).isFile)
1392 Execute("documentor");
1397 MenuDivider { helpMenu };
1400 helpMenu, $"Ecere Tao of Programming [work in progress]", t;
1401 bool NotifySelect(MenuItem selection, Modifiers mods)
1403 FindAndShellOpenInstalledFile("doc", "Ecere Tao of Programming [work in progress].pdf");
1407 MenuDivider { helpMenu };
1410 helpMenu, $"Documentation Folder", d;
1411 bool NotifySelect(MenuItem selection, Modifiers mods)
1413 FindAndShellOpenInstalledFolder("doc");
1419 helpMenu, $"Samples Folder", s;
1420 bool NotifySelect(MenuItem selection, Modifiers mods)
1422 FindAndShellOpenInstalledFolder("samples");
1428 helpMenu, $"Extras Folder", x;
1429 bool NotifySelect(MenuItem selection, Modifiers mods)
1431 FindAndShellOpenInstalledFolder("extras");
1435 MenuDivider { helpMenu };
1438 helpMenu, $"Community Forums", f;
1439 bool NotifySelect(MenuItem selection, Modifiers mods)
1441 ShellOpen("http://ecere.com/forums");
1445 MenuDivider { helpMenu };
1448 helpMenu, $"About...", a;
1449 bool NotifySelect(MenuItem selection, Modifiers mods)
1451 AboutIDE { master = this }.Modal();
1456 property ToolBox toolBox
1458 get { return toolBox; }
1461 property Sheet sheet
1463 get { return sheet; }
1466 property Project project
1468 get { return projectView ? projectView.project : null; }
1471 property Workspace workspace
1473 get { return projectView ? projectView.workspace : null; }
1476 FindInFilesDialog findInFilesDialog
1479 filters = findInFilesFileFilters.array, sizeFilters = findInFilesFileFilters.count * sizeof(FileFilter);
1485 #ifdef GDB_DEBUG_GUI
1488 master = this, parent = this;
1489 anchor = { left = 100, top = 100, right = 100, bottom = 100 };
1491 void OnCommand(char * string)
1494 ide.debugger.SendGDBCommand(string);
1499 bool NotifySelectDisplayDriver(MenuItem selection, Modifiers mods)
1501 //app.driver = app.drivers[selection.id];
1502 #if defined(__unix__) || defined(__APPLE__)
1503 app.driver = selection.id ? "OpenGL" : "X";
1505 app.driver = selection.id ? "OpenGL" : "GDI";
1507 delete ideSettings.displayDriver;
1508 ideSettings.displayDriver = CopyString(selection.id ? "OpenGL" : "Default");
1510 settingsContainer.Save();
1511 //SetDriverAndSkin();
1515 bool NotifySelectDisplaySkin(MenuItem selection, Modifiers mods)
1517 app.skin = app.skins[selection.id];
1522 void SetDriverAndSkin()
1525 for(c = 0; c < app.numSkins; c++)
1526 if(!strcmp(app.skins[c], app.skin))
1528 skinItems[c].checked = true;
1531 for(c = 0; c < app.numDrivers; c++)
1532 if(!strcmp(app.drivers[c], app.driver))
1534 driverItems[c].checked = true;
1539 ProjectView CreateProjectView(Workspace workspace, char * fileName)
1541 Project project = workspace.projects.firstIterator.data;
1542 projectView = ProjectView
1545 fileName = fileName;
1547 void NotifyDestroyed(Window window, DialogResult result)
1550 text = titleECEREIDE;
1555 projectView.Create();
1556 RepositionWindows(false);
1558 // Leave it after Create to avoid flicker due to seeing IDE without a project view
1559 projectView.workspace = workspace;
1560 projectView.project = project;
1561 ideMainFrame.SetText("%s - %s", project.topNode.name, titleECEREIDE);
1565 ide.breakpointsView.LoadFromWorkspace();
1566 ide.watchesView.LoadFromWorkspace();
1568 findInFilesDialog.projectNodeField.userData = projectView;
1571 char fileName[MAX_LOCATION];
1572 strcpy(fileName, project.topNode.path);
1573 PathCat(fileName, project.topNode.name);
1580 projectView.visible = false;
1581 if((!projectView || projectView.created == false || projectView.Destroy(0)) && MenuWindowCloseAll(null, 0))
1583 if(findInFilesDialog)
1585 char workingDir[MAX_LOCATION];
1586 GetWorkingDir(workingDir, MAX_LOCATION);
1587 findInFilesDialog.SearchStop();
1588 findInFilesDialog.currentDirectory = workingDir;
1590 ideMainFrame.text = titleECEREIDE;
1597 void RepositionWindows(bool expand)
1602 bool inDebugMode = debugger.isActive;
1603 bool callStackVisible = expand ? false : callStackView.visible;
1604 bool threadsVisible = expand ? false : threadsView.visible;
1605 bool watchesVisible = expand ? false : watchesView.visible;
1606 bool breakpointsVisible = expand ? false : breakpointsView.visible;
1607 bool toolBoxVisible = toolBox.visible;
1608 bool outputVisible = expand ? false : outputView.visible;
1609 int topDistance = (callStackVisible || threadsVisible) ? 200 : 0;
1610 int bottomDistance = (outputVisible || watchesVisible || breakpointsVisible) ? 240 : 0;
1612 for(child = firstChild; child; child = child.next)
1614 if(child._class == class(CodeEditor) || child._class == class(Designer) ||
1615 child._class == class(Sheet) || child._class == class(ProjectView))
1617 Anchor anchor = child.anchor;
1618 anchor.top = topDistance;
1619 anchor.bottom = bottomDistance;
1620 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 projectCompileItem.disabled = unavailable;
1886 AdjustPopupBuildMenus();
1889 void AdjustPopupBuildMenus()
1891 bool unavailable = !project || projectView.buildInProgress;
1893 if(projectView && projectView.popupMenu && projectView.popupMenu.menu && projectView.popupMenu.created)
1896 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectBuild, 0);
1899 menu.disabled = false;
1900 menu.text = unavailable ? $"Stop Build" : $"Build";
1901 menu.accelerator = unavailable ? Key { pauseBreak, ctrl = true } : f7;
1904 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectLink, 0); if(menu) menu.disabled = unavailable;
1905 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRebuild, 0); if(menu) menu.disabled = unavailable;
1906 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectCleanTarget, 0); if(menu) menu.disabled = unavailable;
1907 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectClean, 0); if(menu) menu.disabled = unavailable;
1908 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRealClean, 0); if(menu) menu.disabled = unavailable;
1909 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRegenerate, 0); if(menu) menu.disabled = unavailable;
1910 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRemove, 0); if(menu) menu.disabled = unavailable;
1911 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileClean, 0); if(menu) menu.disabled = unavailable;
1912 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileCompile, 0); if(menu) menu.disabled = unavailable;
1913 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugPrecompile, 0); if(menu) menu.disabled = unavailable;
1914 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugCompile, 0); if(menu) menu.disabled = unavailable;
1915 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugGenerateSymbols, 0); if(menu) menu.disabled = unavailable;
1916 projectView.popupMenu.Update(null);
1920 property bool areDebugMenusUnavailable { get {
1922 project.GetTargetType(project.config) != executable ||
1923 projectView.buildInProgress == buildingMainProject;
1926 property bool isBreakpointTogglingUnavailable { get {
1930 property bool isDebuggerExecuting { get {
1934 return ide.debugger.state == running;
1937 void AdjustDebugMenus()
1939 bool unavailable = areDebugMenusUnavailable;
1940 bool active = debugger.isActive;
1941 bool bpNoToggle = isBreakpointTogglingUnavailable;
1942 bool executing = isDebuggerExecuting;
1943 //bool holding = debugger.state == stopped;
1945 debugStartResumeItem.disabled = unavailable || executing;
1946 debugStartResumeItem.text = active ? $"Resume" : $"Start";
1947 debugStartResumeItem.NotifySelect = active ? MenuDebugResume : MenuDebugStart;
1950 toolBar.buttonDebugStartResume.disabled = unavailable || executing;
1951 toolBar.buttonDebugStartResume.toolTip = active ? $"Resume" : $"Start";
1954 debugBreakItem.disabled = unavailable || !executing;
1955 debugStopItem.disabled = unavailable || !active;
1956 debugRestartItem.disabled = unavailable || !active;
1959 toolBar.buttonDebugPause.disabled = unavailable || !executing;
1960 toolBar.buttonDebugStop.disabled = unavailable || !active;
1961 toolBar.buttonDebugRestart.disabled = unavailable || !active;
1964 debugStepIntoItem.disabled = unavailable || executing;
1965 debugStepOverItem.disabled = unavailable || executing;
1966 debugStepOutItem.disabled = unavailable || executing || !active;
1967 debugSkipStepOverItem.disabled = unavailable || executing;
1968 debugSkipStepOutItem.disabled = unavailable || executing || !active;
1971 toolBar.buttonDebugStepInto.disabled = unavailable || executing;
1972 toolBar.buttonDebugStepOver.disabled = unavailable || executing;
1973 toolBar.buttonDebugStepOut.disabled = unavailable || executing || !active;
1974 toolBar.buttonDebugSkipStepOver.disabled = unavailable || executing;
1975 // toolBar.buttonDebugSkipStepOutItem.disabled = unavailable || executing;
1977 if((Designer)GetActiveDesigner())
1979 CodeEditor codeEditor = ((Designer)GetActiveDesigner()).codeEditor;
1981 codeEditor.AdjustDebugMenus(unavailable, bpNoToggle, executing);
1985 void ChangeFileDialogsDirectory(char * directory, bool saveSettings)
1987 char tempString[MAX_LOCATION];
1988 strcpy(tempString, directory);
1989 if(saveSettings && !projectView)
1991 ideSettings.ideFileDialogLocation = directory;
1992 settingsContainer.Save();
1995 ideFileDialog.currentDirectory = tempString;
1996 codeEditorFileDialog.currentDirectory = tempString;
1997 codeEditorFormFileDialog.currentDirectory = tempString;
2000 void ChangeProjectFileDialogDirectory(char * directory)
2002 ideSettings.ideProjectFileDialogLocation = directory;
2003 settingsContainer.Save();
2006 Window FindWindow(char * filePath)
2008 Window document = null;
2010 // TOCHECK: Do we need to change slashes here?
2011 for(document = firstChild; document; document = document.next)
2013 char * fileName = document.fileName;
2014 if(document.isDocument && fileName && !fstrcmp(fileName, filePath))
2016 document.visible = true;
2017 document.Activate();
2024 bool DontTerminateDebugSession(char * title)
2026 if(debugger.isActive)
2028 if(MessageBox { type = yesNo, master = ide,
2029 contents = $"Do you want to terminate the debugging session in progress?",
2030 text = title }.Modal() == no)
2033 MessageBox msg { type = yesNo, master = ide,
2034 contents = "Do you want to terminate the debugging session in progress?",
2036 if(msg.Modal() == no)
2048 Window OpenFile(char * origFilePath, WindowState state, bool visible, char * type, OpenCreateIfFails createIfFails, OpenMethod openMethod, bool noParsing)
2050 char extension[MAX_EXTENSION] = "";
2051 Window document = null;
2052 bool isProject = false;
2053 bool needFileModified = true;
2054 char winFilePath[MAX_LOCATION];
2055 char * filePath = strstr(origFilePath, "http://") == origFilePath ? strcpy(winFilePath, origFilePath) : GetSystemPathBuffer(winFilePath, origFilePath);
2059 GetExtension(filePath, extension);
2063 strcpy(extension, type);
2065 if(strcmp(extension, ProjectExtension))
2067 for(document = firstChild; document; document = document.next)
2069 char * fileName = document.fileName;
2070 if(document.isDocument && fileName && !fstrcmp(fileName, filePath) && document.created)
2072 document.visible = true;
2074 document.Activate();
2080 if(createIfFails == whatever)
2082 else if(!strcmp(extension, ProjectExtension) || !strcmp(extension, WorkspaceExtension))
2084 needFileModified = false;
2085 if(openMethod == normal)
2087 if(DontTerminateDebugSession($"Open Project"))
2097 Workspace workspace = null;
2099 if(FileExists(filePath))
2101 if(!strcmp(extension, ProjectExtension))
2103 char workspaceFile[MAX_LOCATION];
2104 strcpy(workspaceFile, filePath);
2105 ChangeExtension(workspaceFile, WorkspaceExtension, workspaceFile);
2106 workspace = LoadWorkspace(workspaceFile, filePath);
2108 else if(!strcmp(extension, WorkspaceExtension))
2109 workspace = LoadWorkspace(filePath, null);
2112 //project = LoadProject(filePath, null);
2117 char absolutePath[MAX_LOCATION];
2118 CreateProjectView(workspace, filePath);
2119 document = projectView;
2121 workspace.DropInvalidBreakpoints();
2124 ide.projectView.ShowOutputBuildLog(true);
2126 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
2127 ide.projectView.DisplayCompiler(compiler, false);
2130 UpdateCompilerConfigs(false);
2133 char newWorkingDir[MAX_LOCATION];
2134 StripLastDirectory(filePath, newWorkingDir);
2135 ChangeFileDialogsDirectory(newWorkingDir, false);
2138 document.fileName = filePath;
2140 ideMainFrame.SetText("%s - %s", filePath, titleECEREIDE);
2142 // this crashes on starting ide with epj file, solution please?
2143 // app.UpdateDisplay();
2145 workspace.holdTracking = true;
2146 for(ofi : workspace.openedFiles)
2148 if(ofi.state != closed)
2150 Window file = OpenFile(ofi.path, normal, true, null, no, normal, noParsing);
2153 char fileName[MAX_LOCATION];
2155 GetLastDirectory(ofi.path, fileName);
2156 node = projectView.project.topNode.Find(fileName, true);
2158 node.EnsureVisible();
2162 workspace.holdTracking = false;
2164 workspace.timer.Start();
2166 findInFilesDialog.mode = FindInFilesMode::project;
2167 findInFilesDialog.currentDirectory = ide.project.topNode.path;
2170 char location[MAX_LOCATION];
2171 StripLastDirectory(ide.project.topNode.path, location);
2172 ChangeProjectFileDialogDirectory(location);
2176 if(projectView.debugger)
2177 projectView.debugger.EvaluateWatches();
2184 if(MessageBox { type = yesNo, master = this, text = $"Error opening project", contents = $"Open a different project?" }.Modal() == yes)
2186 ideProjectFileDialog.text = openProjectFileDialogTitle;
2187 if(ideProjectFileDialog.Modal() == cancel)
2189 filePath = ideProjectFileDialog.filePath;
2190 GetExtension(filePath, extension);
2201 else if(openMethod == add)
2206 char slashFilePath[MAX_LOCATION];
2207 GetSlashPathBuffer(slashFilePath, filePath);
2208 for(p : workspace.projects)
2210 if(!fstrcmp(p.filePath, slashFilePath))
2218 MessageBox { type = ok, parent = parent, master = this, text = $"Same Project",
2219 contents = $"This project is already present in workspace." }.Modal();
2223 prj = LoadProject(filePath, null);
2226 char * activeConfigName = null;
2227 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
2228 prj.StartMonitoring();
2229 workspace.projects.Add(prj);
2230 if(toolBar.activeConfig.currentRow && toolBar.activeConfig.currentRow != toolBar.activeConfig.firstRow &&
2231 toolBar.activeConfig.currentRow.string && toolBar.activeConfig.currentRow.string[0])
2232 activeConfigName = toolBar.activeConfig.currentRow.string;
2233 if(activeConfigName)
2235 for(cfg : prj.configurations)
2237 if(cfg.name && !strcmp(cfg.name, activeConfigName))
2245 projectView.AddNode(prj.topNode, null);
2246 workspace.modified = true;
2248 findInFilesDialog.AddProjectItem(prj);
2249 projectView.ShowOutputBuildLog(true);
2250 projectView.DisplayCompiler(compiler, false);
2251 projectView.ProjectUpdateMakefileForAllConfigs(prj);
2255 char location[MAX_LOCATION];
2256 StripLastDirectory(prj.topNode.path, location);
2257 ChangeProjectFileDialogDirectory(location);
2260 // projectView is associated with the main project and not with the one just added but
2261 return projectView; // just to let the caller know something was opened
2269 else if(!strcmp(extension, "bmp") || !strcmp(extension, "pcx") ||
2270 !strcmp(extension, "jpg") || !strcmp(extension, "gif") ||
2271 !strcmp(extension, "jpeg") || !strcmp(extension, "png"))
2273 if(FileExists(filePath))
2274 document = PictureEdit { hasMaximize = true, hasMinimize = true, hasClose = true, borderStyle = sizable,
2275 hasVertScroll = true, hasHorzScroll = true, parent = this, state = state,
2276 visible = visible, bitmapFile = filePath, OnClose = PictureEditOnClose/*why?--GenericDocumentOnClose*/;
2279 MessageBox { type = ok, master = this, text = filePath, contents = $"File doesn't exist." }.Modal();
2282 else if(!strcmp(extension, "3ds"))
2284 if(FileExists(filePath))
2285 document = ModelView { hasMaximize = true, hasMinimize = true, hasClose = true, borderStyle = sizable,
2286 hasVertScroll = true, hasHorzScroll = true, parent = this, state = state,
2287 visible = visible, modelFile = filePath, OnClose = ModelViewOnClose/*why?--GenericDocumentOnClose*/
2291 MessageBox { type = ok, master = this, text = filePath, contents = $"File doesn't exist." }.Modal();
2294 else if(!strcmp(extension, "txt") || !strcmp(extension, "text") ||
2295 !strcmp(extension, "nfo") || !strcmp(extension, "info") ||
2296 !strcmp(extension, "htm") || !strcmp(extension, "html") ||
2297 !strcmp(extension, "css") || !strcmp(extension, "php") ||
2298 !strcmp(extension, "js"))
2300 CodeEditor editor { parent = this, state = state, visible = false, noParsing = noParsing };
2301 editor.updatingCode = true;
2302 if(editor.LoadFile(filePath))
2305 editor.visible = true;
2309 needFileModified = false;
2313 CodeEditor editor { parent = this, state = state, visible = false, noParsing = noParsing };
2314 if(editor.LoadFile(filePath))
2317 editor.visible = true;
2321 needFileModified = false;
2324 if(document && (document._class == class(PictureEdit) ||
2325 document._class == class(ModelView)))
2330 document.fileName = filePath;
2331 if(workspace && !workspace.holdTracking)
2332 workspace.UpdateOpenedFileInfo(filePath, opened);
2336 if(!document && createIfFails != no)
2338 if(createIfFails != yes && !needFileModified &&
2339 MessageBox { type = yesNo, master = this, text = filePath, contents = $"File doesn't exist. Create?" }.Modal() == yes)
2340 createIfFails = yes;
2341 if(createIfFails == yes || createIfFails == whatever)
2343 document = (Window)NewCodeEditor(this, state, true);
2345 document.fileName = filePath;
2351 if(projectView && document._class == class(CodeEditor) && workspace)
2353 int lineNumber, position;
2355 CodeEditor editor = (CodeEditor)document;
2356 editor.openedFileInfo = workspace.UpdateOpenedFileInfo(filePath, opened);
2357 editor.openedFileInfo.holdTracking = true;
2358 lineNumber = Max(editor.openedFileInfo.lineNumber - 1, 0);
2359 position = Max(editor.openedFileInfo.position - 1, 0);
2360 editor.editBox.GoToLineNum(lineNumber);
2361 editor.editBox.GoToPosition(editor.editBox.line, lineNumber, position);
2362 scroll.x = Max(editor.openedFileInfo.scroll.x, 0);
2363 scroll.y = Max(editor.openedFileInfo.scroll.y, 0);
2364 editor.editBox.scroll = scroll;
2365 editor.openedFileInfo.holdTracking = false;
2368 if(needFileModified)
2369 document.OnFileModified = OnFileModified;
2370 document.NotifySaved = DocumentSaved;
2373 ideSettings.AddRecentProject(document.fileName);
2375 ideSettings.AddRecentFile(document.fileName);
2376 ide.UpdateRecentMenus();
2377 ide.AdjustFileMenus();
2378 settingsContainer.Save();
2386 // TOCHECK: I can't use a generic one for both ModelView and PictureEdit both derived from Window
2387 /*bool Window::GenericDocumentOnClose(bool parentClosing)
2389 if(!parentClosing && ide.workspace)
2390 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2393 bool ModelView::ModelViewOnClose(bool parentClosing)
2395 if(!parentClosing && ide.workspace)
2396 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2399 bool PictureEdit::PictureEditOnClose(bool parentClosing)
2401 if(!parentClosing && ide.workspace)
2402 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2407 void OnUnloadGraphics(Window window)
2409 display.ClearMaterials();
2410 display.ClearTextures();
2411 display.ClearMeshes();
2415 bool OnActivate(bool active, Window swap, bool * goOnWithActivation, bool direct)
2417 caps.color = app.GetKeyState(capsState) ? black : Color { 128,128,128 };
2418 num.color = app.GetKeyState(numState) ? black : Color { 128,128,128 };
2422 bool OnKeyDown(Key key, unichar ch)
2427 projectView.Update(null);
2430 caps.color = app.GetKeyState(capsState) ? black : Color { 128,128,128 };
2433 num.color = app.GetKeyState(numState) ? black : Color { 128,128,128 };
2439 void GoToError(const char * line, bool noParsing)
2442 projectView.GoToError(line, noParsing);
2445 void CodeLocationParseAndGoTo(const char * text, Project project, const char * dir)
2449 char *colon = strchr(text, ':');
2450 char filePath[MAX_LOCATION] = "";
2451 char completePath[MAX_LOCATION];
2452 int line = 0, col = 0;
2453 int len = strlen(text);
2455 FileAttribs fileAttribs;
2457 // support for valgrind output
2458 if((s = strstr(text, "==")) && (s = strstr(s+2, "==")) && (s = strstr(s+2, ":")) && (s = strstr(s+1, ":")))
2469 /*for(s=colon; *s; s++)
2478 //line = atoi(colon+1);
2480 // support for "Found n match(es) in "file/path";
2481 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)
2487 if(colon && (colon[1] == '/' || colon[1] == '\\'))
2489 path = (colon - 1 > path) ? colon - 1 : path;
2490 colon = strstr(colon + 1, ":");
2492 if(*path == '*' && (s = strchr(path+1, '*')))
2494 while(isspace(*path)) path++;
2498 char * close = strchr(path, ')');
2502 strncpy(name, path+1, close - path - 1);
2503 name[close - path - 1] = '\0';
2504 for(p : ide.workspace.projects)
2506 if(!strcmp(p.name, name))
2516 prj = project ? project : (dir ? null : ide.project);
2519 strncpy(filePath, path, colon - path);
2520 filePath[colon - path] = '\0';
2521 line = atoi(colon + 1);
2522 colon = strstr(colon + 1, ":");
2524 col = atoi(colon + 1);
2526 else if(path - 1 >= text && *(path - 1) == '\"')
2528 colon = strchr(path, '\"');
2531 strncpy(filePath, path, colon - path);
2532 filePath[colon - path] = '\0';
2535 else if(path && !colon)
2537 strcpy(filePath, path);
2543 strcpy(completePath, prj.topNode.path);
2544 else if(dir && dir[0])
2545 strcpy(completePath, dir);
2547 completePath[0] = '\0';
2548 PathCat(completePath, filePath);
2550 if((fileAttribs = FileExists(completePath)))
2551 CodeLocationGoTo(completePath, fileAttribs, line, col);
2552 else if(ide.workspace)
2555 for(p : ide.workspace.projects)
2557 strcpy(completePath, p.topNode.path);
2558 PathCat(completePath, filePath);
2559 if((fileAttribs = FileExists(completePath)).isFile)
2561 CodeLocationGoTo(completePath, fileAttribs, line, col);
2568 for(p : ide.workspace.projects)
2570 ProjectNode node = p.topNode.Find(filePath, false);
2573 node.GetFullFilePath(completePath);
2574 if((fileAttribs = FileExists(completePath)).isFile)
2576 CodeLocationGoTo(completePath, fileAttribs, line, col);
2586 void CodeLocationGoTo(const char * path, const FileAttribs fileAttribs, int line, int col)
2588 if(fileAttribs.isFile)
2590 char ext[MAX_EXTENSION];
2591 GetExtension(path, ext);
2592 if(!strcmp(ext, "mp3") || !strcmp(ext, "flac") || !strcmp(ext, "ogg") || !strcmp(ext, "avi") || !strcmp(ext, "mkv"))
2594 else if(!strcmp(ext, "a") || !strcmp(ext, "o") || !strcmp(ext, "lib") || !strcmp(ext, "dll") || !strcmp(ext, "exe"))
2596 char dirPath[MAX_LOCATION];
2597 StripLastDirectory(path, dirPath);
2602 CodeEditor codeEditor = (CodeEditor)OpenFile(path, normal, true, ext, no, normal, false);
2603 if(codeEditor && line)
2605 EditBox editBox = codeEditor.editBox;
2606 editBox.GoToLineNum(line - 1);
2607 editBox.GoToPosition(editBox.line, line - 1, col ? (col - 1) : 0);
2611 else if(fileAttribs.isDirectory)
2615 void OnRedraw(Surface surface)
2617 Bitmap bitmap = back.bitmap;
2619 surface.Blit(bitmap, (clientSize.w - bitmap.width) / 2, (clientSize.h - bitmap.height) / 2, 0, 0, bitmap.width, bitmap.height);
2622 void SheetSelected(SheetType sheetSelected)
2624 if(activeChild == sheet)
2626 if(sheetSelected == methods)
2628 viewPropertiesItem.accelerator = f4;
2629 viewPropertiesItem.parent = viewMenu;
2630 viewMethodsItem.parent = null;
2634 viewMethodsItem.accelerator = f4;
2635 viewMethodsItem.parent = viewMenu;
2636 viewPropertiesItem.parent = null;
2641 viewMethodsItem.parent = viewMenu;
2642 viewPropertiesItem.parent = viewMenu;
2643 if(sheetSelected == methods)
2645 viewMethodsItem.accelerator = f4;
2646 viewPropertiesItem.accelerator = 0;
2650 viewMethodsItem.accelerator = 0;
2651 viewPropertiesItem.accelerator = f4;
2656 void OnActivateClient(Window client, Window previous)
2658 //if(!client || client != previous)
2661 if(!client || client != previous)
2664 dataType = previous._class;
2665 if(previous && !strcmp(dataType.name, "CodeEditor"))
2667 ((CodeEditor)previous).UpdateFormCode();
2669 else if(previous && !strcmp(dataType.name, "Designer"))
2671 ((Designer)previous).codeEditor.UpdateFormCode();
2676 dataType = client._class;
2677 if(client && !strcmp(dataType.name, "CodeEditor"))
2679 CodeEditor codeEditor = (CodeEditor)client;
2680 SetPrivateModule(codeEditor.privateModule);
2681 SetCurrentContext(codeEditor.globalContext);
2682 SetTopContext(codeEditor.globalContext);
2683 SetGlobalContext(codeEditor.globalContext);
2685 SetDefines(&codeEditor.defines);
2686 SetImports(&codeEditor.imports);
2688 SetActiveDesigner(codeEditor.designer);
2690 sheet.codeEditor = codeEditor;
2691 toolBox.codeEditor = codeEditor;
2693 viewDesignerItem.parent = viewMenu;
2694 if(activeChild != codeEditor)
2696 viewCodeItem.parent = viewMenu;
2697 viewDesignerItem.accelerator = 0;
2698 viewCodeItem.accelerator = f8;
2702 viewCodeItem.parent = null;
2703 viewDesignerItem.accelerator = f8;
2706 else if(client && !strcmp(dataType.name, "Designer"))
2708 CodeEditor codeEditor = ((Designer)client).codeEditor;
2711 SetPrivateModule(codeEditor.privateModule);
2712 SetCurrentContext(codeEditor.globalContext);
2713 SetTopContext(codeEditor.globalContext);
2714 SetGlobalContext(codeEditor.globalContext);
2715 SetDefines(&codeEditor.defines);
2716 SetImports(&codeEditor.imports);
2720 SetPrivateModule(null);
2721 SetCurrentContext(null);
2722 SetTopContext(null);
2723 SetGlobalContext(null);
2728 SetActiveDesigner((Designer)client);
2730 sheet.codeEditor = codeEditor;
2731 toolBox.codeEditor = codeEditor;
2733 viewCodeItem.parent = viewMenu;
2734 if(activeChild != client)
2736 viewDesignerItem.parent = viewMenu;
2737 viewDesignerItem.accelerator = f8;
2738 viewCodeItem.accelerator = 0;
2742 viewDesignerItem.parent = null;
2743 viewCodeItem.accelerator = f8;
2749 sheet.codeEditor = null;
2750 toolBox.codeEditor = null;
2751 SetActiveDesigner(null);
2753 viewDesignerItem.parent = null;
2754 viewCodeItem.parent = null;
2757 SheetSelected(sheet.sheetSelected);
2760 projectCompileItem = null;
2765 if(client && client._class == eSystem_FindClass(__thisModule, "CodeEditor")) // !strcmp(client._class.name, "CodeEditor")
2767 CodeEditor codeEditor = (CodeEditor)client;
2768 EditBox editBox = codeEditor.editBox;
2770 statusBar.AddField(pos);
2772 caps = { width = 40, text = $"CAPS", color = app.GetKeyState(capsState) ? black : Color { 128, 128, 128 } };
2773 statusBar.AddField(caps);
2775 ovr = { width = 30, text = $"OVR", color = (editBox && editBox.overwrite) ? black : Color { 128, 128, 128 } };
2776 statusBar.AddField(ovr);
2778 num = { width = 30, text = $"NUM", color = app.GetKeyState(numState) ? black : Color { 128, 128, 128 } };
2779 statusBar.AddField(num);
2781 //statusBar.text = "Ready";
2783 if(projectView && projectView.project)
2785 bool isCObject = false;
2786 ProjectNode node = projectView.GetNodeFromWindow(client, null, false);
2787 if(!node && (node = projectView.GetNodeFromWindow(client, null, true)))
2791 char nodeName[MAX_FILENAME];
2792 char name[MAX_FILENAME+96];
2794 ChangeExtension(node.name, "c", nodeName);
2795 sprintf(name, $"Compile %s", isCObject ? nodeName : node.name);
2796 projectCompileItem =
2798 copyText = true, text = name, c, ctrlF7, disabled = projectView.buildInProgress;
2800 bool NotifySelect(MenuItem selection, Modifiers mods)
2804 bool result = false;
2805 bool isCObject = false;
2806 ProjectNode node = null;
2807 for(p : ide.workspace.projects)
2809 node = projectView.GetNodeFromWindow(activeClient, p, false);
2812 if(!node && (node = projectView.GetNodeFromWindow(activeClient, null, true)))
2816 List<ProjectNode> nodes { };
2818 projectView.Compile(node.project, nodes, mods.ctrl && mods.shift, isCObject ? cObject : normal);
2823 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
2828 projectMenu.AddDynamic(projectCompileItem, ide, false);
2834 caps = ovr = num = null;
2839 bool OnClose(bool parentClosing)
2841 //return !projectView.buildInProgress;
2842 if(projectView && projectView.buildInProgress)
2844 if(DontTerminateDebugSession($"Close IDE"))
2846 if(findInFilesDialog)
2847 findInFilesDialog.SearchStop();
2850 workspace.timer.Stop();
2853 ideMainFrame.Destroy(0);
2860 bool passThrough = false;
2861 bool debugStart = false;
2862 bool debugWorkDir = false;
2863 char * passDebugWorkDir = null;
2864 bool openAsText = false;
2865 DynamicString passArgs { };
2868 for(c = 1; c<app.argc; c++)
2872 char * arg = app.argv[c];
2873 char * buf = new char[strlen(arg)*2+1];
2875 passArgs.concat(" ");
2877 passArgs.concat(buf);
2880 else if(debugWorkDir)
2882 passDebugWorkDir = CopyString(app.argv[c]);
2883 StripQuotes(passDebugWorkDir, passDebugWorkDir);
2884 debugWorkDir = false;
2886 else if(!strcmp(app.argv[c], "-t"))
2888 else if(!strcmp(app.argv[c], "-no-parsing"))
2889 ide.noParsing = true;
2890 else if(!strcmp(app.argv[c], "-debug-start"))
2892 else if(!strcmp(app.argv[c], "-debug-work-dir"))
2893 debugWorkDir = true;
2894 else if(!strcmp(app.argv[c], "-@"))
2898 char fullPath[MAX_LOCATION];
2899 char parentPath[MAX_LOCATION];
2900 char ext[MAX_EXTENSION];
2902 FileAttribs dirAttribs;
2903 GetWorkingDir(fullPath, MAX_LOCATION);
2904 PathCat(fullPath, app.argv[c]);
2905 StripLastDirectory(fullPath, parentPath);
2906 GetExtension(app.argv[c], ext);
2907 isProject = !openAsText && !strcmpi(ext, "epj");
2909 if(isProject && c > (debugStart ? 2 : 1)) continue;
2911 // Create directory for projects (only)
2912 if(((dirAttribs = FileExists(parentPath)) && dirAttribs.isDirectory) || isProject)
2914 if(isProject && !FileExists(fullPath))
2916 char name[MAX_LOCATION];
2917 NewProjectDialog newProjectDialog;
2921 projectView.visible = false;
2922 if(!projectView.Destroy(0))
2926 newProjectDialog = { master = this };
2928 strcpy(name, app.argv[c]);
2929 StripExtension(name);
2930 GetLastDirectory(name, name);
2931 newProjectDialog.projectName.contents = name;
2932 newProjectDialog.projectName.NotifyModified(newProjectDialog, newProjectDialog.projectName);
2933 newProjectDialog.locationEditBox.path = parentPath;
2934 newProjectDialog.NotifyModifiedLocation(newProjectDialog.locationEditBox);
2936 incref newProjectDialog;
2937 newProjectDialog.Modal();
2940 ideSettings.AddRecentProject(projectView.fileName);
2941 ide.UpdateRecentMenus();
2942 settingsContainer.Save();
2944 delete newProjectDialog;
2945 // Open only one project
2949 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, openAsText ? "txt" : null, yes, normal, false);
2951 else if(strstr(fullPath, "http://") == fullPath)
2952 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, openAsText ? "txt" : null, yes, normal, false);
2955 if(passThrough && projectView && projectView.project && workspace)
2956 workspace.commandLineArgs = passArgs;
2957 if(passDebugWorkDir && projectView && projectView.project && workspace)
2959 workspace.debugDir = passDebugWorkDir;
2960 delete passDebugWorkDir;
2963 ;//MenuDebugStart(debugStartResumeItem, 0); // <-- how TODO this without getting into the app.Wait lock
2965 UpdateToolBarActiveConfigs(false);
2966 UpdateToolBarActiveCompilers();
2973 // IS THIS NEEDED? WASN'T HERE BEFORE... Crashes on getting node's projectView otherwise
2976 projectView.visible = false;
2977 projectView.Destroy(0);
2980 #ifdef GDB_DEBUG_GUI
2981 gdbDialog.Destroy(0);
2986 void SetPath(bool projectsDirs, CompilerConfig compiler, ProjectConfig config, int bitDepth)
2990 char * oldPaths[128];
2991 String oldList = new char[maxPathLen];
2992 Array<String> newExePaths { };
2993 //Map<String, bool> exePathExists { };
2995 #if defined(__unix__) || defined(__APPLE__)
2996 Array<String> newLibPaths { };
2997 Map<String, bool> libPathExists { };
3002 for(prj : workspace.projects)
3004 DirExpression targetDirExp;
3006 // SKIP FIRST PROJECT...
3007 if(prj == workspace.projects.firstIterator.data) continue;
3009 // NOTE: Right now the additional project config dir will be
3010 // obtained when the debugger is started, so toggling it
3011 // while building will change which library gets used.
3012 // To go with the initial state, e.g. when F5 was pressed,
3013 // we nould need to keep a list of all project's active
3014 // config upon startup.
3015 targetDirExp = prj.GetTargetDir(compiler, prj.config, bitDepth);
3017 /*if(prj.config.targetType == sharedLibrary && prj.config.debug)
3021 for(cfg = prj.configurations.first; cfg; cfg = cfg.next)
3022 if(cfg.targetType == sharedLibrary && cfg.debug && !strcmpi(cfg.name, "Debug"))
3026 for(cfg = prj.configurations.first; cfg; cfg = cfg.next)
3027 if(cfg.targetType == sharedLibrary && cfg.debug)
3031 if(targetDirExp.dir)
3033 char buffer[MAX_LOCATION];
3034 #if defined(__WIN32__)
3035 Array<String> paths = newExePaths;
3037 Array<String> paths = newLibPaths;
3039 GetSystemPathBuffer(buffer, prj.topNode.path);
3040 PathCat(buffer, targetDirExp.dir);
3043 if(!fstrcmp(p, buffer))
3050 paths.Add(CopyString(buffer));
3052 delete targetDirExp;
3056 for(item : compiler.executableDirs)
3059 for(p : newExePaths)
3061 if(!fstrcmp(p, item))
3068 newExePaths.Add(CopySystemPath(item));
3071 GetEnvironment("PATH", oldList, maxPathLen);
3073 printf("Old value of PATH: %s\n", oldList);
3075 count = TokenizeWith(oldList, sizeof(oldPaths) / sizeof(char *), oldPaths, pathListSep, false);
3076 for(c = 0; c < count; c++)
3079 for(p : newExePaths)
3081 if(!fstrcmp(p, oldPaths[c]))
3088 newExePaths.Add(CopySystemPath(oldPaths[c]));
3092 for(path : newExePaths)
3093 len += strlen(path) + 1;
3094 newList = new char[len + 1];
3096 for(path : newExePaths)
3098 strcat(newList, path);
3099 strcat(newList, pathListSep);
3101 newList[len - 1] = '\0';
3102 SetEnvironment("PATH", newList);
3104 printf("New value of PATH: %s\n", newList);
3111 #if defined(__unix__) || defined(__APPLE__)
3113 for(item : compiler.libraryDirs)
3115 if(!libPathExists[item]) // fstrcmp should be used
3117 String s = CopyString(item);
3119 libPathExists[s] = true;
3123 #if defined(__APPLE__)
3124 GetEnvironment("DYLD_LIBRARY_PATH", oldList, maxPathLen);
3126 GetEnvironment("LD_LIBRARY_PATH", oldList, maxPathLen);
3129 printf("Old value of [DY]LD_LIBRARY_PATH: %s\n", oldList);
3131 count = TokenizeWith(oldList, sizeof(oldPaths) / sizeof(char *), oldPaths, pathListSep, false);
3132 for(c = 0; c < count; c++)
3134 if(!libPathExists[oldPaths[c]]) // fstrcmp should be used
3136 String s = CopyString(oldPaths[c]);
3138 libPathExists[s] = true;
3143 for(path : newLibPaths)
3144 len += strlen(path) + 1;
3145 newList = new char[len + 1];
3147 for(path : newLibPaths)
3149 strcat(newList, path);
3150 strcat(newList, pathListSep);
3152 newList[len - 1] = '\0';
3153 #if defined(__APPLE__)
3154 SetEnvironment("DYLD_LIBRARY_PATH", newList);
3156 SetEnvironment("LD_LIBRARY_PATH", newList);
3159 printf("New value of [DY]LD_LIBRARY_PATH: %s\n", newList);
3165 delete libPathExists;
3168 if(compiler.distccEnabled && compiler.distccHosts)
3169 SetEnvironment("DISTCC_HOSTS", compiler.distccHosts);
3174 void DestroyTemporaryProjectDir()
3176 if(tmpPrjDir && tmpPrjDir[0])
3178 if(FileExists(tmpPrjDir).isDirectory)
3179 DestroyDir(tmpPrjDir);
3180 property::tmpPrjDir = null;
3186 // Graphics Driver Menu
3190 app.currentSkin.selectionColor = selectionColor;
3191 app.currentSkin.selectionText = selectionText;
3195 driverItems = new MenuItem[app.numDrivers];
3196 for(c = 0; c < app.numDrivers; c++)
3198 driverItems[c] = MenuItem { driversMenu, app.drivers[c], NotifySelect = NotifySelectDisplayDriver };
3199 driverItems[c].id = c;
3200 driverItems[c].isRadio = true;
3203 driverItems = new MenuItem[2];
3204 #if defined(__unix__)
3205 driverItems[0] = MenuItem { driversMenu, "X", NotifySelect = NotifySelectDisplayDriver };
3206 driverItems[0].id = 0;
3207 driverItems[0].isRadio = true;
3209 driverItems[0] = MenuItem { driversMenu, "GDI", NotifySelect = NotifySelectDisplayDriver };
3210 driverItems[0].id = 0;
3211 driverItems[0].isRadio = true;
3213 driverItems[1] = MenuItem { driversMenu, "OpenGL", NotifySelect = NotifySelectDisplayDriver };
3214 driverItems[1].id = 1;
3215 driverItems[1].isRadio = true;
3217 /* skinItems = new MenuItem[app.numSkins];
3218 for(c = 0; c < app.numSkins; c++)
3220 skinItems[c] = MenuItem {skinsMenu, app.skins[c], NotifySelect = NotifySelectDisplaySkin };
3221 skinItems[c].id = c;
3222 skinItems[c].isRadio = true;
3225 ideFileDialog.master = this;
3226 ideProjectFileDialog.master = this;
3228 //SetDriverAndSkin();
3232 void UpdateRecentMenus()
3235 Menu fileMenu = menu.FindMenu($"File");
3236 Menu recentFiles = fileMenu.FindMenu($"Recent Files");
3237 Menu recentProjects = fileMenu.FindMenu($"Recent Projects");
3238 char * itemPath = new char[MAX_LOCATION];
3239 char * itemName = new char[MAX_LOCATION+4];
3242 recentFiles.Clear();
3245 for(recent : ideSettings.recentFiles)
3247 strncpy(itemPath, recent, MAX_LOCATION); itemPath[MAX_LOCATION-1] = '\0';
3248 MakeSystemPath(itemPath);
3249 snprintf(itemName, MAX_LOCATION+4, "%d %s", 1 + c, itemPath); itemName[MAX_LOCATION+4-1] = '\0';
3250 recentFiles.AddDynamic(MenuItem { copyText = true, text = itemName, (Key)k1 + c, id = c, NotifySelect = ide.FileRecentFile }, ide, true);
3254 recentProjects.Clear();
3256 for(recent : ideSettings.recentProjects)
3258 strncpy(itemPath, recent, MAX_LOCATION); itemPath[MAX_LOCATION-1] = '\0';
3259 MakeSystemPath(itemPath);
3260 snprintf(itemName, MAX_LOCATION+4, "%d %s", 1 + c, itemPath); itemName[MAX_LOCATION+4-1] = '\0';
3261 recentProjects.AddDynamic(MenuItem { copyText = true, text = itemName, (Key)k1 + c, id = c, NotifySelect = ide.FileRecentProject }, ide, true);
3277 void DestroyDir(char * path)
3279 RecursiveDeleteFolderFSI fsi { };
3284 #if defined(__WIN32__)
3285 define sdkDirName = "Ecere SDK";
3287 define sdkDirName = "ecere";
3290 void FindAndShellOpenInstalledFolder(char * name)
3292 char * p = new char[MAX_LOCATION];
3293 char * v = new char[maxPathLen];
3296 Array<String> paths { };
3298 strncpy(p, settingsContainer.moduleLocation, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3299 StripLastDirectory(p, p);
3301 paths.Add(CopyString(p));
3302 #if defined(__WIN32__)
3303 GetEnvironment("ECERE_SDK_SRC", v, maxPathLen);
3306 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3307 PathCat(p, name); paths.Add(CopyString(p));
3309 GetEnvironment("AppData", v, maxPathLen);
3312 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3313 PathCat(p, sdkDirName); PathCat(p, name); paths.Add(CopyString(p));
3315 GetEnvironment("ProgramFiles", 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(x86)", 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("SystemDrive", v, maxPathLen);
3330 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3331 PathCat(p, "Program Files"); PathCat(p, sdkDirName); PathCat(p, name); paths.Add(CopyString(p));
3334 GetEnvironment("XDG_DATA_DIRS", v, maxPathLen);
3335 numTokens = TokenizeWith(v, sizeof(tokens) / sizeof(byte *), tokens, ":", false);
3336 for(c=0; c<numTokens; c++)
3338 strncpy(p, tokens[c], MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3339 PathCat(p, sdkDirName); PathCat(p, name); paths.Add(CopyString(p));
3344 strncpy(p, path, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3345 if(FileExists(p).isDirectory)
3357 void FindAndShellOpenInstalledFile(char * subdir, char * name)
3359 char * p = new char[MAX_LOCATION];
3360 char * v = new char[maxPathLen];
3363 Array<String> paths { };
3365 strncpy(p, settingsContainer.moduleLocation, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3366 paths.Add(CopyString(p));
3367 StripLastDirectory(p, p);
3369 paths.Add(CopyString(p));
3370 #if defined(__WIN32__)
3371 GetEnvironment("ECERE_SDK_SRC", v, maxPathLen);
3374 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3375 PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3377 GetEnvironment("AppData", 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("ProgramFiles", 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(x86)", 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("SystemDrive", v, maxPathLen);
3398 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3399 PathCat(p, "Program Files"); PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3402 GetEnvironment("XDG_DATA_DIRS", v, maxPathLen);
3403 numTokens = TokenizeWith(v, sizeof(tokens) / sizeof(byte *), tokens, ":", false);
3404 for(c=0; c<numTokens; c++)
3406 strncpy(p, tokens[c], MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3407 PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3412 strncpy(p, path, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3414 if(FileExists(p).isFile)
3426 class RecursiveDeleteFolderFSI : NormalFileSystemIterator
3428 bool preserveRootFolder;
3430 void OutFolder(char * folderPath, bool isRoot)
3432 if(!(preserveRootFolder && isRoot))
3433 RemoveDir(folderPath);
3436 bool OnFile(char * filePath)
3438 DeleteFile(filePath);
3443 class IDEApp : GuiApplication
3445 //driver = "Win32Console";
3446 // driver = "OpenGL";
3450 TempFile includeFile { };
3454 SetLoggingMode(stdOut, null);
3455 //SetLoggingMode(debug, null);
3457 settingsContainer.Load();
3458 #if defined(__unix__) || defined(__APPLE__)
3459 app.driver = (ideSettings.displayDriver && !strcmp(ideSettings.displayDriver, "OpenGL")) ? ideSettings.displayDriver : "X";
3461 app.driver = (ideSettings.displayDriver && !strcmp(ideSettings.displayDriver, "OpenGL")) ? ideSettings.displayDriver : "GDI";
3463 ide.driverItems[ideSettings.displayDriver && !strcmp(ideSettings.displayDriver,"OpenGL")].checked = true;
3467 desktop.text = titleECEREIDE;
3470 for(c = 1; c<app.argc; c++)
3472 char fullPath[MAX_LOCATION];
3473 GetWorkingDir(fullPath, MAX_LOCATION);
3474 PathCat(fullPath, app.argv[c]);
3475 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, null, yes, normal, false);
3479 if(!LoadIncludeFile())
3480 PrintLn("error: unable to load :crossplatform.mk file inside ide binary.");
3485 bool LoadIncludeFile()
3487 bool result = false;
3488 File include = FileOpen(":crossplatform.mk", read);
3491 File f = includeFile;
3494 for(; !include.Eof(); )
3497 int count = include.Read(buffer, 1, 4096);
3498 f.Write(buffer, 1, count);
3508 IDEMainFrame ideMainFrame { };
3510 define app = ((IDEApp)__thisModule);
3512 define titleECEREIDE = $"ECERE IDE (Debug)";
3514 define titleECEREIDE = $"ECERE IDE";