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)
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 OnGotoLine(char * line)
492 stackLvl = atoi(line);
493 ide.debugger.GoToStackFrameLine(stackLvl, true);
496 void OnSelectFrame(int lineNumber)
498 ide.debugger.SelectFrame(lineNumber);
501 void OnToggleBreakpoint()
503 Debugger debugger = ide.debugger;
504 if(debugger.activeFrame && debugger.activeFrame.absoluteFile)
506 int line = debugger.activeFrame.line;
507 char name[MAX_LOCATION];
509 // TOFIX: Improve on this, don't use only filename, make a function
510 GetLastDirectory(debugger.activeFrame.absoluteFile, name);
511 if(ide && ide.workspace)
513 for(p : ide.workspace.projects)
515 if(p.topNode.Find(name, false))
523 for(p : ide.workspace.projects)
525 if(IsPathInsideOf(debugger.activeFrame.absoluteFile, p.topNode.path))
533 debugger.ToggleBreakpoint(debugger.activeFrame.absoluteFile, line, prj);
536 CodeEditor codeEditor = (CodeEditor)ide.FindWindow(debugger.activeFrame.absoluteFile);
537 if(codeEditor) { codeEditor.Update(null); Activate(); }
542 bool OnKeyDown(Key key, unichar ch)
546 case escape: ide.ShowCodeEditor(); break;
551 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
554 ide.RepositionWindows(false);
558 bool OnClose(bool parentClosing)
562 ide.RepositionWindows(false);
563 return parentClosing;
566 void OnRedraw(Surface surface)
568 Debugger debugger = ide.debugger;
569 Frame activeFrame = debugger.activeFrame;
573 int lineCursor, lineTopFrame, activeThread, hitThread;
574 int lineH, scrollY, boxH;
576 Breakpoint bp = null;
579 scrollY = editBox.scroll.y;
580 displaySystem.FontExtent(editBox.font.font, " ", 1, null, &lineH);
581 activeThread = debugger.activeThread;
582 hitThread = debugger.hitThread;
583 debugger.GetCallStackCursorLine(&error, &lineCursor, &lineTopFrame);
585 // TODO: improve bp drawing... it should be visible even if it's not on the activeFrame
586 if(activeFrame.absoluteFile)
588 for(i : ide.workspace.breakpoints; i.type == user)
590 if(i.absoluteFilePath && i.absoluteFilePath[0] &&
591 !fstrcmp(i.absoluteFilePath, activeFrame.absoluteFile) &&
592 activeFrame.line == i.line)
600 DrawLineMarginIcon(surface,
601 /*(lineCursor == 1 || lineTopFrame == 1) ? */ide.bmpBpHalf/* : ide.bmpBp*/,
602 lineCursor /*1*/, lineH, scrollY, boxH);
604 if(activeThread && activeThread == hitThread && debugger.bpHit && debugger.bpHit.type == user)
605 DrawLineMarginIcon(surface,
606 (lineCursor == 1 || lineTopFrame == 1) ? ide.bmpBpHalf : ide.bmpBp,
607 1, lineH, scrollY, boxH);
609 DrawLineMarginIcon(surface, error ? ide.bmpCursorError : ide.bmpCursor, lineCursor, lineH, scrollY, boxH);
610 if(bp && lineCursor == 1) //activeThread && activeThread == hitThread && debugger.bpHit && debugger.bpHit.type == user)
611 bmp = error ? ide.bmpTopFrameHalfError : ide.bmpTopFrameHalf;
613 bmp = error ? ide.bmpTopFrameError : ide.bmpTopFrame;
614 DrawLineMarginIcon(surface, bmp, lineTopFrame, lineH, scrollY, boxH);
616 if(editBox.horzScroll && editBox.horzScroll.visible)
618 surface.SetBackground(control);
619 surface.Area(0, editBox.clientSize.h, 20 - 1, clientSize.h - 1);
624 WatchesView watchesView { parent = this };
625 ThreadsView threadsView
627 parent = this, font = { panelFont.faceName, panelFont.size };
629 bool OnKeyDown(Key key, unichar ch)
633 case escape: ide.ShowCodeEditor(); break;
638 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
641 ide.RepositionWindows(false);
645 bool OnClose(bool parentClosing)
649 ide.RepositionWindows(false);
650 return parentClosing;
653 void OnSelectThread(int threadId)
656 ide.debugger.SelectThread(threadId);
659 bool OnGetThreadsInfo(int * activeThread, int * hitThread, int * signalThread)
662 Debugger debugger = ide.debugger;
663 *activeThread = debugger.activeThread;
664 *hitThread = debugger.hitThread;
665 *signalThread = debugger.signalThread;
670 BreakpointsView breakpointsView { parent = this };
672 ToolBox toolBox { parent = this };
673 Sheet sheet { parent = this };
676 property char * tmpPrjDir { set { delete tmpPrjDir; if(value) tmpPrjDir = CopyString(value); } get { return tmpPrjDir; } };
678 Menu fileMenu { menu, $"File", f, hasMargin = true };
681 fileMenu, $"New", n, ctrlN;
682 bitmap = { ":actions/docNew.png" };
683 bool NotifySelect(MenuItem selection, Modifiers mods)
685 Window document = (Window)NewCodeEditor(this, normal, false);
686 document.NotifySaved = DocumentSaved;
690 MenuItem fileOpenItem
692 fileMenu, $"Open...", o, ctrlO;
693 bitmap = { ":actions/docOpen.png" };
694 bool NotifySelect(MenuItem selection, Modifiers mods)
696 if(!projectView && ideSettings.ideFileDialogLocation)
697 ideFileDialog.currentDirectory = ideSettings.ideFileDialogLocation;
700 if(ideFileDialog.Modal() == ok)
702 bool gotWhatWeWant = false;
704 int numSelections = ideFileDialog.numSelections;
705 char ** multiFilePaths = ideFileDialog.multiFilePaths;
707 for(c = 0; c < numSelections; c++)
709 if(OpenFile(multiFilePaths[c], normal, true, fileTypes[ideFileDialog.fileType].typeExtension, no, normal))
710 gotWhatWeWant = true;
713 MessageBox { type = yesNo, master = this, text = $"Error opening file",
714 contents = $"Open a different file?" }.Modal() == no)
716 if(!projectView && gotWhatWeWant)
717 ChangeFileDialogsDirectory(ideFileDialog.currentDirectory, true);
727 MenuItem fileCloseItem { fileMenu, $"Close", c, ctrlF4, NotifySelect = MenuFileClose };
728 MenuDivider { fileMenu };
729 MenuItem fileSaveItem
731 fileMenu, $"Save", s, ctrlS, bitmap = { ":actions/docSave.png" };
733 // For the toolbar button; clients can still override that for the menu item
734 bool Window::NotifySelect(MenuItem selection, Modifiers mods)
736 Window w = activeClient;
738 w.MenuFileSave(null, 0);
742 MenuItem fileSaveAsItem { fileMenu, $"Save As...", a };
743 MenuItem fileSaveAllItem { fileMenu, $"Save All", l, NotifySelect = MenuFileSaveAll, bitmap = { ":actions/docSaveAll.png" } };
744 MenuDivider { fileMenu };
747 fileMenu, $"Find In Files...", f, Key { f, ctrl = true , shift = true };
748 bool NotifySelect(MenuItem selection, Modifiers mods)
750 findInFilesDialog.replaceMode = false;
751 findInFilesDialog.Show();
755 MenuItem replaceInFiles
757 fileMenu, $"Replace In Files...", e, Key { r, ctrl = true , shift = true };
758 bool NotifySelect(MenuItem selection, Modifiers mods)
760 findInFilesDialog.replaceMode = true;
761 findInFilesDialog.Show();
765 MenuDivider { fileMenu };
766 MenuItem globalSettingsItem
768 fileMenu, $"Global Settings...", g;
769 bool NotifySelect(MenuItem selection, Modifiers mods)
771 globalSettingsDialog.master = this;
772 if(ide.workspace && ide.workspace.compiler)
773 globalSettingsDialog.workspaceActiveCompiler = ide.workspace.compiler;
774 else if(ideSettings.defaultCompiler)
775 globalSettingsDialog.workspaceActiveCompiler = ideSettings.defaultCompiler;
776 globalSettingsDialog.Modal();
780 MenuDivider { fileMenu };
781 Menu recentFiles { fileMenu, $"Recent Files", r };
782 Menu recentProjects { fileMenu, $"Recent Projects", p };
783 MenuDivider { fileMenu };
786 fileMenu, $"Exit", x, altF4, NotifySelect = MenuFileExit;
788 bool NotifySelect(MenuItem selection, Modifiers mods)
790 ideMainFrame.Destroy(0);
795 bool FileRecentFile(MenuItem selection, Modifiers mods)
798 for(file : ideSettings.recentFiles)
800 if(id == selection.id)
804 char * command = PrintString("ide ", file);
809 OpenFile(file, normal, true, null, no, normal);
817 bool FileRecentProject(MenuItem selection, Modifiers mods)
820 for(file : ideSettings.recentProjects)
822 if(id == selection.id)
826 char * command = PrintString("ide ", file);
831 OpenFile(file, normal, true, null, no, normal);
839 MenuPlacement editMenu { menu, $"Edit", e };
841 Menu projectMenu { menu, $"Menu"."Project", p, hasMargin = true };
842 MenuItem projectNewItem
844 projectMenu, $"New...", n, Key { n, true, true };
845 bitmap = { ":actions/projNew.png" };
846 bool NotifySelect(MenuItem selection, Modifiers mods)
848 if(!DontTerminateDebugSession($"New Project"))
849 if(MenuWindowCloseAll(null, 0))
851 NewProjectDialog newProjectDialog;
855 projectView.visible = false;
856 if(!projectView.Destroy(0))
860 newProjectDialog = { master = this };
861 newProjectDialog.Modal();
864 ideSettings.AddRecentProject(projectView.fileName);
865 ide.UpdateRecentMenus();
866 settingsContainer.Save();
872 MenuItem projectOpenItem
874 projectMenu, $"Open...", o, Key { o, true, true };
875 bitmap = { ":actions/projOpen.png" };
876 bool NotifySelect(MenuItem selection, Modifiers mods)
878 if(ideSettings.ideProjectFileDialogLocation)
879 ideProjectFileDialog.currentDirectory = ideSettings.ideProjectFileDialogLocation;
881 ideProjectFileDialog.text = openProjectFileDialogTitle;
882 if(ideProjectFileDialog.Modal() == ok)
884 OpenFile(ideProjectFileDialog.filePath, normal, true, projectTypes[ideProjectFileDialog.fileType].typeExtension, no, normal);
885 //ChangeProjectFileDialogDirectory(ideProjectFileDialog.currentDirectory);
890 MenuItem projectQuickItem
892 projectMenu, $"Quick...", q, f7, disabled = true;
893 bool NotifySelect(MenuItem selection, Modifiers mods)
896 QuickProjectDialog { this }.Modal();
900 MenuItem projectAddItem
902 projectMenu, $"Add project to workspace...", a, Key { a, true, true };
903 bitmap = { ":actions/projAdd.png" };
905 bool NotifySelect(MenuItem selection, Modifiers mods)
907 if(ideSettings.ideProjectFileDialogLocation)
908 ideProjectFileDialog.currentDirectory = ideSettings.ideProjectFileDialogLocation;
910 ideProjectFileDialog.text = addProjectFileDialogTitle;
913 if(ideProjectFileDialog.Modal() == ok)
915 if(OpenFile(ideProjectFileDialog.filePath, normal, true, projectTypes[ideProjectFileDialog.fileType].typeExtension, no, add))
917 if(MessageBox { type = yesNo, master = this, text = $"Error opening project file",
918 contents = $"Add a different project?" }.Modal() == no)
929 MenuItem projectCloseItem
931 projectMenu, $"Close", c, disabled = true;
932 bool NotifySelect(MenuItem selection, Modifiers mods)
936 if(!ide.DontTerminateDebugSession($"Project Close"))
938 if(findInFilesDialog)
939 findInFilesDialog.SearchStop();
940 projectView.visible = false;
941 if(projectView.Destroy(0))
942 MenuWindowCloseAll(null, 0);
944 char workingDir[MAX_LOCATION];
945 GetWorkingDir(workingDir, MAX_LOCATION);
946 findInFilesDialog.currentDirectory = workingDir;
947 ideMainFrame.text = titleECEREIDE;
955 MenuDivider { projectMenu };
956 MenuItem projectSettingsItem
958 projectMenu, $"Settings...", s, altF7, disabled = true;
959 bool NotifySelect(MenuItem selection, Modifiers mods)
961 projectView.MenuSettings(projectView.active ? selection : null, mods);
965 MenuDivider { projectMenu };
966 MenuItem projectBrowseFolderItem
968 projectMenu, $"Browse Project Folder", p, disabled = true;
969 bool NotifySelect(MenuItem selection, Modifiers mods)
972 projectView.MenuBrowseFolder(null, mods);
976 MenuDivider { projectMenu };
977 MenuItem projectRunItem
979 projectMenu, $"Run", r, ctrlF5, disabled = true;
980 bitmap = { ":actions/run.png" };
981 bool NotifySelect(MenuItem selection, Modifiers mods)
984 projectView.Run(null, mods);
988 MenuItem projectBuildItem
990 projectMenu, $"Build", b, f7, disabled = true;
991 bitmap = { ":actions/build.png" };
992 bool NotifySelect(MenuItem selection, Modifiers mods)
996 if(projectView.buildInProgress == none)
997 projectView.ProjectBuild(projectView.active ? selection : null, mods);
999 projectView.stopBuild = true;
1004 MenuItem projectLinkItem
1006 projectMenu, $"Relink", l, disabled = true;
1007 bitmap = { ":actions/relink.png" };
1008 bool NotifySelect(MenuItem selection, Modifiers mods)
1011 projectView.ProjectLink(projectView.active ? selection : null, mods);
1015 MenuItem projectRebuildItem
1017 projectMenu, $"Rebuild", d, shiftF7, disabled = true;
1018 bitmap = { ":actions/rebuild.png" };
1019 bool NotifySelect(MenuItem selection, Modifiers mods)
1022 projectView.ProjectRebuild(projectView.active ? selection : null, mods);
1026 MenuItem projectCleanItem
1028 projectMenu, $"Clean", e, disabled = true;
1029 bitmap = { ":actions/clean.png" };
1030 bool NotifySelect(MenuItem selection, Modifiers mods)
1035 projectView.ProjectClean(projectView.active ? selection : null, mods);
1040 MenuItem projectRealCleanItem
1042 projectMenu, $"Real Clean", disabled = true;
1043 bitmap = { ":actions/clean.png" };
1044 bool NotifySelect(MenuItem selection, Modifiers mods)
1049 projectView.ProjectRealClean(projectView.active ? selection : null, mods);
1054 MenuItem projectRegenerateItem
1056 projectMenu, $"Regenerate Makefile", m, disabled = true;
1057 bitmap = { ":actions/regMakefile.png" };
1058 bool NotifySelect(MenuItem selection, Modifiers mods)
1061 projectView.ProjectRegenerate(projectView.active ? selection : null, mods);
1065 MenuItem projectCompileItem;
1066 Menu debugMenu { menu, $"Debug", d, hasMargin = true };
1067 MenuItem debugStartResumeItem
1069 debugMenu, $"Start", s, f5, disabled = true;
1070 bitmap = { ":actions/debug.png" };
1071 NotifySelect = MenuDebugStart;
1073 bool MenuDebugStart(MenuItem selection, Modifiers mods)
1077 debugStartResumeItem.disabled = true; // a very rare exception to calling AdjustDebugMenus
1078 if(!projectView.DebugStart())
1079 debugStartResumeItem.disabled = false; // same exception
1083 bool MenuDebugResume(MenuItem selection, Modifiers mods)
1086 projectView.DebugResume();
1089 MenuItem debugRestartItem
1091 debugMenu, $"Restart", r, Key { f5, ctrl = true, shift = true }, disabled = true;
1092 bitmap = { ":actions/restart.png" };
1093 bool NotifySelect(MenuItem selection, Modifiers mods)
1096 projectView.DebugRestart();
1100 MenuItem debugBreakItem
1102 debugMenu, $"Break", b, Key { pauseBreak, ctrl = true }, disabled = true;
1103 bitmap = { ":actions/pause.png" };
1104 bool NotifySelect(MenuItem selection, Modifiers mods)
1106 if(projectView && projectView.buildInProgress != none)
1109 projectView.DebugBreak();
1113 MenuItem debugStopItem
1115 debugMenu, $"Stop", p, shiftF5, disabled = true;
1116 bitmap = { ":actions/stopDebug.png" };
1117 bool NotifySelect(MenuItem selection, Modifiers mods)
1120 projectView.DebugStop();
1124 MenuDivider { debugMenu };
1125 MenuItem debugStepIntoItem
1127 debugMenu, $"Step Into", i, f11, disabled = true;
1128 bitmap = { ":actions/stepInto.png" };
1129 bool NotifySelect(MenuItem selection, Modifiers mods)
1132 projectView.DebugStepInto();
1136 MenuItem debugStepOverItem
1138 debugMenu, $"Step Over", v, f10, disabled = true;
1139 bitmap = { ":actions/stepOver.png" };
1140 bool NotifySelect(MenuItem selection, Modifiers mods)
1143 projectView.DebugStepOver(false);
1147 MenuItem debugStepOutItem
1149 debugMenu, $"Step Out", o, shiftF11, disabled = true;
1150 bitmap = { ":actions/stepOut.png" };
1151 bool NotifySelect(MenuItem selection, Modifiers mods)
1154 projectView.DebugStepOut(false);
1158 MenuPlacement debugRunToCursorItem { debugMenu, $"Run To Cursor", c };
1159 MenuItem debugSkipStepOverItem
1161 debugMenu, $"Step Over Skipping Breakpoints", e, shiftF10, disabled = true;
1162 bool NotifySelect(MenuItem selection, Modifiers mods)
1165 projectView.DebugStepOver(true);
1169 MenuItem debugSkipStepOutItem
1171 debugMenu, $"Step Out Skipping Breakpoints", t, Key { f11, ctrl = true, shift = true }, disabled = true;
1172 bitmap = { ":actions/skipBreaks.png" };
1173 bool NotifySelect(MenuItem selection, Modifiers mods)
1176 projectView.DebugStepOut(true);
1180 MenuPlacement debugSkipRunToCursorItem { debugMenu, $"Run To Cursor Skipping Breakpoints", u };
1181 //MenuDivider { debugMenu };
1182 //MenuPlacement debugToggleBreakpoint { debugMenu, "Toggle Breakpoint", t };
1183 MenuPlacement imageMenu { menu, $"Image", i };
1184 Menu viewMenu { menu, $"View", v };
1185 MenuItem viewProjectItem
1187 viewMenu, $"Project View", j, alt0, disabled = true;
1188 bool NotifySelect(MenuItem selection, Modifiers mods)
1192 projectView.visible = true;
1193 projectView.Activate();
1198 MenuPlacement { viewMenu, $"View Designer" };
1199 MenuPlacement { viewMenu, $"View Code" };
1200 MenuPlacement { viewMenu, $"View Properties" };
1201 MenuPlacement { viewMenu, $"View Methods" };
1202 MenuItem viewDesignerItem
1204 viewMenu, $"View Designer", d, f8;
1205 bool NotifySelect(MenuItem selection, Modifiers mods)
1207 Window client = activeClient;
1208 Class dataType = client._class;
1209 if(!strcmp(dataType.name, "Designer"))
1211 client.visible = true;
1215 ((CodeEditor)client).ViewDesigner();
1219 MenuItem viewCodeItem
1221 viewMenu, $"View Code", c, f8;
1222 bool NotifySelect(MenuItem selection, Modifiers mods)
1224 Window client = activeClient;
1225 Class dataType = client._class;
1226 if(!strcmp(dataType.name, "Designer"))
1227 client = ((Designer)client).codeEditor;
1230 // Do this after so the caret isn't moved yet...
1231 client.visible = true;
1235 MenuItem viewPropertiesItem
1237 viewMenu, $"View Properties", p, f4;
1238 bool NotifySelect(MenuItem selection, Modifiers mods)
1240 sheet.visible = true;
1241 sheet.sheetSelected = properties;
1246 MenuItem viewMethodsItem
1248 viewMenu, $"View Methods", m, f4;
1249 bool NotifySelect(MenuItem selection, Modifiers mods)
1251 sheet.visible = true;
1252 sheet.sheetSelected = methods;
1257 MenuItem viewToolBoxItem
1259 viewMenu, $"View Toolbox", x, f12;
1260 bool NotifySelect(MenuItem selection, Modifiers mods)
1262 toolBox.visible = true;
1267 MenuItem viewOutputItem
1269 viewMenu, $"Output", o, alt2;
1270 bool NotifySelect(MenuItem selection, Modifiers mods)
1276 MenuItem viewWatchesItem
1278 viewMenu, $"Watches", w, alt3;
1279 bool NotifySelect(MenuItem selection, Modifiers mods)
1285 MenuItem viewThreadsItem
1287 viewMenu, $"Threads", t, alt4;
1288 bool NotifySelect(MenuItem selection, Modifiers mods)
1294 MenuItem viewBreakpointsItem
1296 viewMenu, $"Breakpoints", b, alt5;
1297 bool NotifySelect(MenuItem selection, Modifiers mods)
1299 breakpointsView.Show();
1303 MenuItem viewCallStackItem
1305 viewMenu, $"Call Stack", s, alt7;
1306 bool NotifySelect(MenuItem selection, Modifiers mods)
1308 callStackView.Show();
1312 MenuItem viewAllDebugViews
1314 viewMenu, $"All Debug Views", a, alt9;
1315 bool NotifySelect(MenuItem selection, Modifiers mods)
1320 callStackView.Show();
1321 breakpointsView.Show();
1325 #ifdef GDB_DEBUG_GUI
1326 MenuDivider { viewMenu };
1327 MenuItem viewGDBItem
1329 viewMenu, $"GDB Dialog", g, Key { f9, shift = true, ctrl = true };
1330 bool NotifySelect(MenuItem selection, Modifiers mods)
1337 MenuDivider { viewMenu };
1338 MenuItem viewColorPicker
1340 viewMenu, $"Color Picker...", c, Key { c, ctrl = true , shift = true };
1341 bool NotifySelect(MenuItem selection, Modifiers mods)
1343 ColorPicker colorPicker { master = this };
1344 colorPicker.Modal();
1348 MenuDivider { viewMenu };
1352 viewMenu, "Full Screen", f, checkable = true;
1354 bool NotifySelect(MenuItem selection, Modifiers mods)
1356 app.fullScreen ^= true;
1358 anchor = { 0, 0, 0, 0 };
1363 Menu driversMenu { viewMenu, $"Graphics Driver", v };
1364 //Menu skinsMenu { viewMenu, "GUI Skins", k };
1365 Menu windowMenu { menu, $"Window", w };
1366 MenuItem { windowMenu, $"Close All", l, NotifySelect = MenuWindowCloseAll };
1367 MenuDivider { windowMenu };
1368 MenuItem { windowMenu, $"Next", n, f6, NotifySelect = MenuWindowNext };
1369 MenuItem { windowMenu, $"Previous", p, shiftF6, NotifySelect = MenuWindowPrevious };
1370 MenuDivider { windowMenu };
1371 MenuItem { windowMenu, $"Cascade", c, NotifySelect = MenuWindowCascade };
1372 MenuItem { windowMenu, $"Tile Horizontally", h, NotifySelect = MenuWindowTileHorz };
1373 MenuItem { windowMenu, $"Tile Vertically", v, NotifySelect = MenuWindowTileVert };
1374 MenuItem { windowMenu, $"Arrange Icons", a, NotifySelect = MenuWindowArrangeIcons };
1375 MenuDivider { windowMenu };
1376 MenuItem { windowMenu, $"Windows...", w, NotifySelect = MenuWindowWindows };
1377 Menu helpMenu { menu, $"Help", h };
1380 helpMenu, $"API Reference", r, f1;
1381 bool NotifySelect(MenuItem selection, Modifiers mods)
1383 Execute("documentor");
1387 MenuDivider { helpMenu };
1390 helpMenu, $"About...", a;
1391 bool NotifySelect(MenuItem selection, Modifiers mods)
1393 AboutIDE { master = this }.Modal();
1398 property ToolBox toolBox
1400 get { return toolBox; }
1403 property Sheet sheet
1405 get { return sheet; }
1408 property Project project
1410 get { return projectView ? projectView.project : null; }
1413 property Workspace workspace
1415 get { return projectView ? projectView.workspace : null; }
1418 FindInFilesDialog findInFilesDialog
1421 filters = findInFilesFileFilters.array, sizeFilters = findInFilesFileFilters.count * sizeof(FileFilter);
1425 #ifdef GDB_DEBUG_GUI
1428 master = this, parent = this;
1429 anchor = { left = 100, top = 100, right = 100, bottom = 100 };
1431 void OnCommand(char * string)
1434 ide.debugger.SendGDBCommand(string);
1439 bool NotifySelectDisplayDriver(MenuItem selection, Modifiers mods)
1441 //app.driver = app.drivers[selection.id];
1442 #if defined(__unix__) || defined(__APPLE__)
1443 app.driver = selection.id ? "OpenGL" : "X";
1445 app.driver = selection.id ? "OpenGL" : "GDI";
1447 delete ideSettings.displayDriver;
1448 ideSettings.displayDriver = CopyString(selection.id ? "OpenGL" : "Default");
1450 settingsContainer.Save();
1451 //SetDriverAndSkin();
1455 bool NotifySelectDisplaySkin(MenuItem selection, Modifiers mods)
1457 app.skin = app.skins[selection.id];
1462 void SetDriverAndSkin()
1465 for(c = 0; c < app.numSkins; c++)
1466 if(!strcmp(app.skins[c], app.skin))
1468 skinItems[c].checked = true;
1471 for(c = 0; c < app.numDrivers; c++)
1472 if(!strcmp(app.drivers[c], app.driver))
1474 driverItems[c].checked = true;
1479 ProjectView CreateProjectView(Workspace workspace, char * fileName)
1481 Project project = workspace.projects.firstIterator.data;
1482 projectView = ProjectView
1485 fileName = fileName;
1487 void NotifyDestroyed(Window window, DialogResult result)
1490 text = titleECEREIDE;
1495 projectView.Create();
1496 RepositionWindows(false);
1498 // Leave it after Create to avoid flicker due to seeing IDE without a project view
1499 projectView.workspace = workspace;
1500 projectView.project = project;
1501 ideMainFrame.SetText("%s - %s", project.topNode.name, titleECEREIDE);
1505 ide.breakpointsView.LoadFromWorkspace();
1506 ide.watchesView.LoadFromWorkspace();
1508 findInFilesDialog.projectNodeField.userData = projectView;
1511 char fileName[MAX_LOCATION];
1512 strcpy(fileName, project.topNode.path);
1513 PathCat(fileName, project.topNode.name);
1518 bool GetDebugMenusDisabled()
1522 Project project = projectView.project;
1524 if(project.GetTargetType(project.config) == executable)
1531 void RepositionWindows(bool expand)
1536 bool inDebugMode = debugger.isActive;
1537 bool callStackVisible = expand ? false : callStackView.visible;
1538 bool threadsVisible = expand ? false : threadsView.visible;
1539 bool watchesVisible = expand ? false : watchesView.visible;
1540 bool breakpointsVisible = expand ? false : breakpointsView.visible;
1541 bool toolBoxVisible = toolBox.visible;
1542 bool outputVisible = expand ? false : outputView.visible;
1543 int topDistance = (callStackVisible || threadsVisible) ? 200 : 0;
1544 int bottomDistance = (outputVisible || watchesVisible || breakpointsVisible) ? 240 : 0;
1546 for(child = firstChild; child; child = child.next)
1548 if(child._class == class(CodeEditor) || child._class == class(Designer) ||
1549 child._class == class(Sheet) || child._class == class(ProjectView))
1551 Anchor anchor = child.anchor;
1552 anchor.top = topDistance;
1553 anchor.bottom = bottomDistance;
1554 if(child._class == class(CodeEditor) || child._class == class(Designer))
1556 anchor.right = toolBoxVisible ? 150 : 0;
1558 child.anchor = anchor;
1562 if(child._class == class(OutputView) || child._class == class(CallStackView) || child._class == class(ThreadsView) || child._class == class(WatchesView) ||
1563 child._class == class(BreakpointsView))
1564 child.visible = false;
1567 // If this is not here, the IDE is not updated when doing Debug/Break then Alt-4 to show call stack (IDE not updated)
1572 bool ShowCodeEditor()
1575 activeClient.Activate();
1576 else if(projectView)
1578 projectView.visible = true;
1579 projectView.Activate();
1583 sheet.visible = true;
1589 void DocumentSaved(Window document, char * fileName)
1591 ideSettings.AddRecentFile(fileName);
1592 ide.UpdateRecentMenus();
1593 ide.AdjustFileMenus();
1594 settingsContainer.Save();
1597 bool Window::OnFileModified(FileChange fileChange, char * param)
1600 sprintf(temp, $"The document %s was modified by another application.\n"
1601 "Would you like to reload it and lose your changes?", this.fileName);
1602 if(MessageBox { type = yesNo, master = this/*.parent*/,
1603 text = $"Document has been modified", contents = temp }.Modal() == yes)
1605 char * fileName = CopyString(this.fileName);
1606 WindowState state = this.state;
1607 Anchor anchor = this.anchor;
1608 Size size = this.size;
1610 this.modifiedDocument = false;
1612 this = ide.OpenFile(fileName, normal, true, null, no, normal);
1615 this.anchor = anchor;
1617 this.SetState(state, true, 0);
1625 void UpdateMakefiles()
1629 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
1630 for(prj : workspace.projects)
1631 projectView.ProjectUpdateMakefileForAllConfigs(prj);
1636 void UpdateCompilerConfigs(bool mute)
1638 UpdateToolBarActiveCompilers();
1641 bool silent = mute || (ide.projectView.buildInProgress == none ? false : true);
1642 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
1645 projectView.ShowOutputBuildLog(true);
1646 projectView.DisplayCompiler(compiler, false);
1648 for(prj : workspace.projects)
1649 projectView.ProjectPrepareCompiler(prj, compiler, silent);
1654 void UpdateToolBarActiveCompilers()
1656 toolBar.activeCompiler.Clear();
1657 for(compiler : ideSettings.compilerConfigs)
1659 DataRow row = toolBar.activeCompiler.AddString(compiler.name);
1660 if(workspace && workspace.compiler && !strcmp(compiler.name, workspace.compiler))
1661 toolBar.activeCompiler.currentRow = row;
1663 if(!toolBar.activeCompiler.currentRow && toolBar.activeCompiler.firstRow)
1664 toolBar.activeCompiler.SelectRow(toolBar.activeCompiler.firstRow);
1667 void UpdateToolBarActiveConfigs(bool selectionOnly)
1669 bool commonSelected = false;
1670 DataRow row = toolBar.activeConfig.currentRow;
1672 row = toolBar.activeConfig.FindRow(1);
1675 toolBar.activeConfig.Clear();
1676 row = toolBar.activeConfig.AddString("(Mixed)");
1681 char * configName = null;
1684 Map<String, int> configs { }; // TOIMP: just need sort but using map until containers have sort
1685 for(prj : workspace.projects)
1687 for(cfg : prj.configurations)
1690 configs[cfg.name] = 1;
1695 toolBar.activeConfig.AddString(&name);
1699 if(projectView && projectView.project)
1701 for(prj : workspace.projects)
1703 if(prj.config && prj.config.name)
1705 configName = prj.config.name;
1711 commonSelected = true;
1712 for(prj : workspace.projects)
1714 if(prj.config && (!prj.config.name || strcmp(prj.config.name, configName)))
1716 commonSelected = false;
1724 commonSelected = false;
1725 for(row = toolBar.activeConfig.firstRow; row; row = row.next)
1727 if(!strcmp(row.string, configName))
1729 toolBar.activeConfig.currentRow = row;
1730 commonSelected = true;
1737 toolBar.activeConfig.Sort(null, 0);
1739 toolBar.activeConfig.currentRow = row;
1744 bool unavailable = !project;
1746 projectAddItem.disabled = unavailable;
1747 toolBar.buttonAddProject.disabled = unavailable;
1749 projectSettingsItem.disabled = unavailable;
1751 projectBrowseFolderItem.disabled = unavailable;
1753 viewProjectItem.disabled = unavailable;
1755 toolBar.activeConfig.disabled = unavailable;
1756 toolBar.activeCompiler.disabled = unavailable;
1757 toolBar.activeBitDepth.disabled = unavailable;
1764 property bool hasOpenedCodeEditors
1769 for(w = firstChild; w; w = w.next)
1770 if(w._class == class(CodeEditor) &&
1771 w.isDocument && !w.closing && w.visible && w.created &&
1772 w.fileName && w.fileName[0])
1778 void AdjustFileMenus()
1780 bool unavailable = project != null || !hasOpenedCodeEditors; // are they supported source code (ec, c, cpp, etc) ?
1782 projectQuickItem.disabled = unavailable;
1785 void AdjustBuildMenus()
1787 bool unavailable = project && projectView.buildInProgress;
1789 projectNewItem.disabled = unavailable;
1790 toolBar.buttonNewProject.disabled = unavailable;
1791 projectOpenItem.disabled = unavailable;
1792 toolBar.buttonOpenProject.disabled = unavailable;
1794 unavailable = !project || projectView.buildInProgress;
1796 projectCloseItem.disabled = unavailable;
1797 // toolBar.buttonCloseProject.disabled = unavailable;
1799 projectRunItem.disabled = unavailable || project.GetTargetType(project.config) != executable;
1800 toolBar.buttonRun.disabled = unavailable || project.GetTargetType(project.config) != executable;
1802 projectBuildItem.disabled = false;
1803 projectBuildItem.text = unavailable ? $"Stop Build" : $"Build";
1804 projectBuildItem.accelerator = unavailable ? Key { pauseBreak, ctrl = true } : f7;
1806 projectLinkItem.disabled = unavailable;
1807 toolBar.buttonReLink.disabled = unavailable;
1808 projectRebuildItem.disabled = unavailable;
1809 toolBar.buttonRebuild.disabled = unavailable;
1810 projectCleanItem.disabled = unavailable;
1811 toolBar.buttonClean.disabled = unavailable;
1812 projectRealCleanItem.disabled = unavailable;
1813 // toolBar.buttonRealClean.disabled = unavailable;
1814 projectRegenerateItem.disabled = unavailable;
1815 toolBar.buttonRegenerateMakefile.disabled = unavailable;
1816 projectCompileItem.disabled = unavailable;
1818 AdjustPopupBuildMenus();
1821 void AdjustPopupBuildMenus()
1823 bool unavailable = !project || projectView.buildInProgress;
1825 if(projectView && projectView.popupMenu && projectView.popupMenu.menu && projectView.popupMenu.created)
1828 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectBuild, 0);
1831 menu.disabled = false;
1832 menu.text = unavailable ? $"Stop Build" : $"Build";
1833 menu.accelerator = unavailable ? Key { pauseBreak, ctrl = true } : f7;
1836 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectLink, 0); if(menu) menu.disabled = unavailable;
1837 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRebuild, 0); if(menu) menu.disabled = unavailable;
1838 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectClean, 0); if(menu) menu.disabled = unavailable;
1839 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRealClean, 0); if(menu) menu.disabled = unavailable;
1840 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRegenerate, 0); if(menu) menu.disabled = unavailable;
1841 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRemove, 0); if(menu) menu.disabled = unavailable;
1842 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileClean, 0); if(menu) menu.disabled = unavailable;
1843 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileCompile, 0); if(menu) menu.disabled = unavailable;
1844 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugPrecompile, 0); if(menu) menu.disabled = unavailable;
1845 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugCompile, 0); if(menu) menu.disabled = unavailable;
1846 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugGenerateSymbols, 0); if(menu) menu.disabled = unavailable;
1847 projectView.popupMenu.Update(null);
1851 void AdjustDebugMenus()
1853 bool unavailable = !project || project.GetTargetType(project.config) != executable ||
1854 projectView.buildInProgress == buildingMainProject;
1855 bool active = ide.debugger.isActive;
1856 bool executing = ide.debugger.state == running;
1857 //bool holding = ide.debugger.state == stopped;
1859 debugStartResumeItem.disabled = unavailable || executing;
1860 debugStartResumeItem.text = active ? $"Resume" : $"Start";
1861 debugStartResumeItem.NotifySelect = active ? MenuDebugResume : MenuDebugStart;
1864 toolBar.buttonDebugStartResume.disabled = unavailable || executing;
1865 toolBar.buttonDebugStartResume.toolTip = active ? $"Resume" : $"Start";
1868 debugBreakItem.disabled = unavailable || !executing;
1869 debugStopItem.disabled = unavailable || !active;
1870 debugRestartItem.disabled = unavailable || !active;
1873 toolBar.buttonDebugPause.disabled = unavailable || !executing;
1874 toolBar.buttonDebugStop.disabled = unavailable || !active;
1875 toolBar.buttonDebugRestart.disabled = unavailable || !active;
1878 debugStepIntoItem.disabled = unavailable || executing;
1879 debugStepOverItem.disabled = unavailable || executing;
1880 debugStepOutItem.disabled = unavailable || executing || !active;
1881 debugSkipStepOverItem.disabled = unavailable || executing;
1882 debugSkipStepOutItem.disabled = unavailable || executing || !active;
1885 toolBar.buttonDebugStepInto.disabled = unavailable || executing;
1886 toolBar.buttonDebugStepOver.disabled = unavailable || executing;
1887 toolBar.buttonDebugStepOut.disabled = unavailable || executing || !active;
1888 toolBar.buttonDebugSkipStepOver.disabled = unavailable || executing;
1889 // toolBar.buttonDebugSkipStepOutItem.disabled = unavailable || executing;
1891 if((Designer)GetActiveDesigner())
1893 CodeEditor codeEditor = ((Designer)GetActiveDesigner()).codeEditor;
1896 codeEditor.debugRunToCursor.disabled = unavailable || executing;
1897 codeEditor.debugSkipRunToCursor.disabled = unavailable || executing;
1902 void ChangeFileDialogsDirectory(char * directory, bool saveSettings)
1904 char tempString[MAX_LOCATION];
1905 strcpy(tempString, directory);
1906 if(saveSettings && !projectView)
1908 ideSettings.ideFileDialogLocation = directory;
1909 settingsContainer.Save();
1912 ideFileDialog.currentDirectory = tempString;
1913 codeEditorFileDialog.currentDirectory = tempString;
1914 codeEditorFormFileDialog.currentDirectory = tempString;
1917 void ChangeProjectFileDialogDirectory(char * directory)
1919 ideSettings.ideProjectFileDialogLocation = directory;
1920 settingsContainer.Save();
1923 Window FindWindow(char * filePath)
1925 Window document = null;
1927 // TOCHECK: Do we need to change slashes here?
1928 for(document = firstChild; document; document = document.next)
1930 char * fileName = document.fileName;
1931 if(document.isDocument && fileName && !fstrcmp(fileName, filePath))
1933 document.visible = true;
1934 document.Activate();
1941 bool DontTerminateDebugSession(char * title)
1943 if(debugger.isActive)
1945 if(MessageBox { type = yesNo, master = ide,
1946 contents = $"Do you want to terminate the debugging session in progress?",
1947 text = title }.Modal() == no)
1950 MessageBox msg { type = yesNo, master = ide,
1951 contents = "Do you want to terminate the debugging session in progress?",
1953 if(msg.Modal() == no)
1965 Window OpenFile(char * origFilePath, WindowState state, bool visible, char * type, OpenCreateIfFails createIfFails, OpenMethod openMethod)
1967 char extension[MAX_EXTENSION] = "";
1968 Window document = null;
1969 bool isProject = false;
1970 bool needFileModified = true;
1971 char winFilePath[MAX_LOCATION];
1972 char * filePath = strstr(origFilePath, "http://") == origFilePath ? strcpy(winFilePath, origFilePath) : GetSystemPathBuffer(winFilePath, origFilePath);
1976 GetExtension(filePath, extension);
1980 strcpy(extension, type);
1982 if(strcmp(extension, ProjectExtension))
1984 for(document = firstChild; document; document = document.next)
1986 char * fileName = document.fileName;
1987 if(document.isDocument && fileName && !fstrcmp(fileName, filePath) && document.created)
1989 document.visible = true;
1991 document.Activate();
1997 if(createIfFails == whatever)
1999 else if(!strcmp(extension, ProjectExtension) || !strcmp(extension, WorkspaceExtension))
2001 needFileModified = false;
2002 if(openMethod == normal)
2004 if(DontTerminateDebugSession($"Open Project"))
2007 if(MenuWindowCloseAll(null, 0))
2011 projectView.visible = false;
2012 projectView.Destroy(0);
2013 // Where did this come from? projectView = null;
2020 Workspace workspace = null;
2022 if(FileExists(filePath))
2024 if(!strcmp(extension, ProjectExtension))
2026 char workspaceFile[MAX_LOCATION];
2027 strcpy(workspaceFile, filePath);
2028 ChangeExtension(workspaceFile, WorkspaceExtension, workspaceFile);
2029 workspace = LoadWorkspace(workspaceFile, filePath);
2031 else if(!strcmp(extension, WorkspaceExtension))
2032 workspace = LoadWorkspace(filePath, null);
2035 //project = LoadProject(filePath, null);
2040 char absolutePath[MAX_LOCATION];
2041 CreateProjectView(workspace, filePath);
2042 document = projectView;
2044 workspace.DropInvalidBreakpoints();
2047 ide.projectView.ShowOutputBuildLog(true);
2049 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
2050 ide.projectView.DisplayCompiler(compiler, false);
2053 UpdateCompilerConfigs(false);
2056 char newWorkingDir[MAX_LOCATION];
2057 StripLastDirectory(filePath, newWorkingDir);
2058 ChangeFileDialogsDirectory(newWorkingDir, false);
2061 document.fileName = filePath;
2063 ideMainFrame.SetText("%s - %s", filePath, titleECEREIDE);
2065 // this crashes on starting ide with epj file, solution please?
2066 // app.UpdateDisplay();
2068 workspace.holdTracking = true;
2069 for(ofi : workspace.openedFiles)
2071 if(ofi.state != closed)
2073 Window file = OpenFile(ofi.path, normal, true, null, no, normal);
2076 char fileName[MAX_LOCATION];
2078 GetLastDirectory(ofi.path, fileName);
2079 node = projectView.project.topNode.Find(fileName, true);
2081 node.EnsureVisible();
2085 workspace.holdTracking = false;
2087 workspace.timer.Start();
2089 findInFilesDialog.mode = FindInFilesMode::project;
2090 findInFilesDialog.currentDirectory = ide.project.topNode.path;
2093 char location[MAX_LOCATION];
2094 StripLastDirectory(ide.project.topNode.path, location);
2095 ChangeProjectFileDialogDirectory(location);
2099 if(projectView.debugger)
2100 projectView.debugger.EvaluateWatches();
2107 if(MessageBox { type = yesNo, master = this, text = $"Error opening project", contents = $"Open a different project?" }.Modal() == yes)
2109 ideProjectFileDialog.text = openProjectFileDialogTitle;
2110 if(ideProjectFileDialog.Modal() == cancel)
2112 filePath = ideProjectFileDialog.filePath;
2113 GetExtension(filePath, extension);
2124 else if(openMethod == add)
2129 char slashFilePath[MAX_LOCATION];
2130 GetSlashPathBuffer(slashFilePath, filePath);
2131 for(p : workspace.projects)
2133 if(!fstrcmp(p.filePath, slashFilePath))
2141 MessageBox { type = ok, parent = parent, master = this, text = $"Same Project",
2142 contents = $"This project is already present in workspace." }.Modal();
2146 prj = LoadProject(filePath, null);
2149 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
2150 prj.StartMonitoring();
2151 workspace.projects.Add(prj);
2153 projectView.AddNode(prj.topNode, null);
2154 workspace.modified = true;
2156 findInFilesDialog.AddProjectItem(prj);
2157 projectView.ShowOutputBuildLog(true);
2158 projectView.DisplayCompiler(compiler, false);
2159 projectView.ProjectUpdateMakefileForAllConfigs(prj);
2163 char location[MAX_LOCATION];
2164 StripLastDirectory(prj.topNode.path, location);
2165 ChangeProjectFileDialogDirectory(location);
2168 // projectView is associated with the main project and not with the one just added but
2169 return projectView; // just to let the caller know something was opened
2177 else if(!strcmp(extension, "bmp") || !strcmp(extension, "pcx") ||
2178 !strcmp(extension, "jpg") || !strcmp(extension, "gif") ||
2179 !strcmp(extension, "jpeg") || !strcmp(extension, "png"))
2181 if(FileExists(filePath))
2182 document = PictureEdit { hasMaximize = true, hasMinimize = true, hasClose = true, borderStyle = sizable,
2183 hasVertScroll = true, hasHorzScroll = true, parent = this, state = state,
2184 visible = visible, bitmapFile = filePath, OnClose = PictureEditOnClose/*why?--GenericDocumentOnClose*/;
2187 MessageBox { type = ok, master = this, text = filePath, contents = $"File doesn't exist." }.Modal();
2190 else if(!strcmp(extension, "3ds"))
2192 if(FileExists(filePath))
2193 document = ModelView { hasMaximize = true, hasMinimize = true, hasClose = true, borderStyle = sizable,
2194 hasVertScroll = true, hasHorzScroll = true, parent = this, state = state,
2195 visible = visible, modelFile = filePath, OnClose = ModelViewOnClose/*why?--GenericDocumentOnClose*/
2199 MessageBox { type = ok, master = this, text = filePath, contents = $"File doesn't exist." }.Modal();
2202 else if(!strcmp(extension, "txt") || !strcmp(extension, "text") ||
2203 !strcmp(extension, "nfo") || !strcmp(extension, "info") ||
2204 !strcmp(extension, "htm") || !strcmp(extension, "html") ||
2205 !strcmp(extension, "css") || !strcmp(extension, "php") ||
2206 !strcmp(extension, "js"))
2208 CodeEditor editor { parent = this, state = state, visible = false };
2209 editor.updatingCode = true;
2210 if(editor.LoadFile(filePath))
2213 editor.visible = true;
2217 needFileModified = false;
2221 CodeEditor editor { parent = this, state = state, visible = false };
2222 if(editor.LoadFile(filePath))
2225 editor.visible = true;
2229 needFileModified = false;
2232 if(document && (document._class == class(PictureEdit) ||
2233 document._class == class(ModelView)))
2238 document.fileName = filePath;
2239 if(workspace && !workspace.holdTracking)
2240 workspace.UpdateOpenedFileInfo(filePath, opened);
2244 if(!document && createIfFails != no)
2246 if(createIfFails != yes && !needFileModified &&
2247 MessageBox { type = yesNo, master = this, text = filePath, contents = $"File doesn't exist. Create?" }.Modal() == yes)
2248 createIfFails = yes;
2249 if(createIfFails == yes || createIfFails == whatever)
2251 document = (Window)NewCodeEditor(this, state, true);
2253 document.fileName = filePath;
2259 if(projectView && document._class == class(CodeEditor) && workspace)
2261 int lineNumber, position;
2263 CodeEditor editor = (CodeEditor)document;
2264 editor.openedFileInfo = workspace.UpdateOpenedFileInfo(filePath, opened);
2265 editor.openedFileInfo.holdTracking = true;
2266 lineNumber = Max(editor.openedFileInfo.lineNumber - 1, 0);
2267 position = Max(editor.openedFileInfo.position - 1, 0);
2268 editor.editBox.GoToLineNum(lineNumber);
2269 editor.editBox.GoToPosition(editor.editBox.line, lineNumber, position);
2270 scroll.x = Max(editor.openedFileInfo.scroll.x, 0);
2271 scroll.y = Max(editor.openedFileInfo.scroll.y, 0);
2272 editor.editBox.scroll = scroll;
2273 editor.openedFileInfo.holdTracking = false;
2276 if(needFileModified)
2277 document.OnFileModified = OnFileModified;
2278 document.NotifySaved = DocumentSaved;
2281 ideSettings.AddRecentProject(document.fileName);
2283 ideSettings.AddRecentFile(document.fileName);
2284 ide.UpdateRecentMenus();
2285 ide.AdjustFileMenus();
2286 settingsContainer.Save();
2294 // TOCHECK: I can't use a generic one for both ModelView and PictureEdit both derived from Window
2295 /*bool Window::GenericDocumentOnClose(bool parentClosing)
2297 if(!parentClosing && ide.workspace)
2298 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2301 bool ModelView::ModelViewOnClose(bool parentClosing)
2303 if(!parentClosing && ide.workspace)
2304 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2307 bool PictureEdit::PictureEditOnClose(bool parentClosing)
2309 if(!parentClosing && ide.workspace)
2310 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2315 void OnUnloadGraphics(Window window)
2317 display.ClearMaterials();
2318 display.ClearTextures();
2319 display.ClearMeshes();
2323 bool OnActivate(bool active, Window swap, bool * goOnWithActivation, bool direct)
2325 caps.color = app.GetKeyState(capsState) ? black : Color { 128,128,128 };
2326 num.color = app.GetKeyState(numState) ? black : Color { 128,128,128 };
2330 bool OnKeyDown(Key key, unichar ch)
2335 projectView.Update(null);
2338 caps.color = app.GetKeyState(capsState) ? black : Color { 128,128,128 };
2341 num.color = app.GetKeyState(numState) ? black : Color { 128,128,128 };
2347 void GoToError(const char * line)
2350 projectView.GoToError(line);
2353 void CodeLocationParseAndGoTo(const char * text, Project project, const char * dir)
2356 char *colon = strchr(text, ':');
2357 char filePath[MAX_LOCATION];
2358 char completePath[MAX_LOCATION];
2359 int line = 0, col = 0;
2361 FileAttribs fileAttribs;
2363 if(colon && (colon[1] == '/' || colon[1] == '\\'))
2365 path = (colon - 1 > path) ? colon - 1 : path;
2366 colon = strstr(colon + 1, ":");
2368 while(isspace(*path)) path++;
2371 char * close = strchr(path, ')');
2375 strncpy(name, path+1, close - path - 1);
2376 name[close - path - 1] = '\0';
2377 for(p : ide.workspace.projects)
2379 if(!strcmp(p.name, name))
2389 prj = project ? project : (dir ? null : ide.project);
2392 strncpy(filePath, path, colon - path);
2393 filePath[colon - path] = '\0';
2394 line = atoi(colon + 1);
2395 colon = strstr(colon + 1, ":");
2397 col = atoi(colon + 1);
2399 else if(path - 1 >= text && *(path - 1) == '\"')
2401 colon = strchr(path, '\"');
2404 strncpy(filePath, path, colon - path);
2405 filePath[colon - path] = '\0';
2408 else if(path && !colon)
2410 strcpy(filePath, path);
2414 strcpy(completePath, prj.topNode.path);
2415 else if(dir && dir[0])
2416 strcpy(completePath, dir);
2418 completePath[0] = '\0';
2419 PathCat(completePath, filePath);
2421 fileAttribs = FileExists(completePath);
2422 if(fileAttribs.isFile)
2424 CodeEditor codeEditor = (CodeEditor)OpenFile(completePath, normal, true, "", no, normal);
2425 if(codeEditor && line)
2427 EditBox editBox = codeEditor.editBox;
2428 editBox.GoToLineNum(line - 1);
2429 editBox.GoToPosition(editBox.line, line - 1, col ? (col - 1) : 0);
2432 else if(fileAttribs.isDirectory)
2433 ShellOpen(completePath);
2436 void OnRedraw(Surface surface)
2438 Bitmap bitmap = back.bitmap;
2440 surface.Blit(bitmap, (clientSize.w - bitmap.width) / 2, (clientSize.h - bitmap.height) / 2, 0, 0, bitmap.width, bitmap.height);
2443 void SheetSelected(SheetType sheetSelected)
2445 if(activeChild == sheet)
2447 if(sheetSelected == methods)
2449 viewPropertiesItem.accelerator = f4;
2450 viewPropertiesItem.parent = viewMenu;
2451 viewMethodsItem.parent = null;
2455 viewMethodsItem.accelerator = f4;
2456 viewMethodsItem.parent = viewMenu;
2457 viewPropertiesItem.parent = null;
2462 viewMethodsItem.parent = viewMenu;
2463 viewPropertiesItem.parent = viewMenu;
2464 if(sheetSelected == methods)
2466 viewMethodsItem.accelerator = f4;
2467 viewPropertiesItem.accelerator = 0;
2471 viewMethodsItem.accelerator = 0;
2472 viewPropertiesItem.accelerator = f4;
2477 void OnActivateClient(Window client, Window previous)
2479 //if(!client || client != previous)
2482 if(!client || client != previous)
2485 dataType = previous._class;
2486 if(previous && !strcmp(dataType.name, "CodeEditor"))
2488 ((CodeEditor)previous).UpdateFormCode();
2490 else if(previous && !strcmp(dataType.name, "Designer"))
2492 ((Designer)previous).codeEditor.UpdateFormCode();
2497 dataType = client._class;
2498 if(client && !strcmp(dataType.name, "CodeEditor"))
2500 CodeEditor codeEditor = (CodeEditor)client;
2501 SetPrivateModule(codeEditor.privateModule);
2502 SetCurrentContext(codeEditor.globalContext);
2503 SetTopContext(codeEditor.globalContext);
2504 SetGlobalContext(codeEditor.globalContext);
2506 SetDefines(&codeEditor.defines);
2507 SetImports(&codeEditor.imports);
2509 SetActiveDesigner(codeEditor.designer);
2511 sheet.codeEditor = codeEditor;
2512 toolBox.codeEditor = codeEditor;
2514 viewDesignerItem.parent = viewMenu;
2515 if(activeChild != codeEditor)
2517 viewCodeItem.parent = viewMenu;
2518 viewDesignerItem.accelerator = 0;
2519 viewCodeItem.accelerator = f8;
2523 viewCodeItem.parent = null;
2524 viewDesignerItem.accelerator = f8;
2527 else if(client && !strcmp(dataType.name, "Designer"))
2529 CodeEditor codeEditor = ((Designer)client).codeEditor;
2532 SetPrivateModule(codeEditor.privateModule);
2533 SetCurrentContext(codeEditor.globalContext);
2534 SetTopContext(codeEditor.globalContext);
2535 SetGlobalContext(codeEditor.globalContext);
2536 SetDefines(&codeEditor.defines);
2537 SetImports(&codeEditor.imports);
2541 SetPrivateModule(null);
2542 SetCurrentContext(null);
2543 SetTopContext(null);
2544 SetGlobalContext(null);
2549 SetActiveDesigner((Designer)client);
2551 sheet.codeEditor = codeEditor;
2552 toolBox.codeEditor = codeEditor;
2554 viewCodeItem.parent = viewMenu;
2555 if(activeChild != client)
2557 viewDesignerItem.parent = viewMenu;
2558 viewDesignerItem.accelerator = f8;
2559 viewCodeItem.accelerator = 0;
2563 viewDesignerItem.parent = null;
2564 viewCodeItem.accelerator = f8;
2570 sheet.codeEditor = null;
2571 toolBox.codeEditor = null;
2572 SetActiveDesigner(null);
2574 viewDesignerItem.parent = null;
2575 viewCodeItem.parent = null;
2578 SheetSelected(sheet.sheetSelected);
2581 projectCompileItem = null;
2586 if(client && client._class == eSystem_FindClass(__thisModule, "CodeEditor")) // !strcmp(client._class.name, "CodeEditor")
2588 CodeEditor codeEditor = (CodeEditor)client;
2589 EditBox editBox = codeEditor.editBox;
2591 statusBar.AddField(pos);
2593 caps = { width = 40, text = $"CAPS", color = app.GetKeyState(capsState) ? black : Color { 128, 128, 128 } };
2594 statusBar.AddField(caps);
2596 ovr = { width = 30, text = $"OVR", color = editBox.overwrite ? black : Color { 128, 128, 128 } };
2597 statusBar.AddField(ovr);
2599 num = { width = 30, text = $"NUM", color = app.GetKeyState(numState) ? black : Color { 128, 128, 128 } };
2600 statusBar.AddField(num);
2602 //statusBar.text = "Ready";
2604 if(projectView && projectView.project)
2606 bool isCObject = false;
2607 ProjectNode node = projectView.GetNodeFromWindow(client, null, false);
2608 if(!node && (node = projectView.GetNodeFromWindow(client, null, true)))
2612 char nodeName[MAX_FILENAME];
2613 char name[MAX_FILENAME+96];
2615 ChangeExtension(node.name, "c", nodeName);
2616 sprintf(name, $"Compile %s", isCObject ? nodeName : node.name);
2617 projectCompileItem =
2619 copyText = true, text = name, c, ctrlF7, disabled = projectView.buildInProgress;
2621 bool NotifySelect(MenuItem selection, Modifiers mods)
2625 bool result = false;
2626 bool isCObject = false;
2627 ProjectNode node = null;
2628 for(p : ide.workspace.projects)
2630 node = projectView.GetNodeFromWindow(activeClient, p, false);
2633 if(!node && (node = projectView.GetNodeFromWindow(activeClient, null, true)))
2637 List<ProjectNode> nodes { };
2639 projectView.Compile(node.project, nodes, mods.ctrl && mods.shift, isCObject ? cObject : normal);
2644 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
2649 projectMenu.AddDynamic(projectCompileItem, ide, false);
2655 caps = ovr = num = null;
2660 bool OnClose(bool parentClosing)
2662 //return !projectView.buildInProgress;
2663 if(projectView && projectView.buildInProgress)
2665 if(DontTerminateDebugSession($"Close IDE"))
2667 if(findInFilesDialog)
2668 findInFilesDialog.SearchStop();
2671 workspace.timer.Stop();
2674 ideMainFrame.Destroy(0);
2681 bool passThrough = false;
2682 bool debugStart = false;
2683 bool debugWorkDir = false;
2684 char * passDebugWorkDir = null;
2685 bool openAsText = false;
2686 DynamicString passArgs { };
2687 for(c = 1; c<app.argc; c++)
2689 if(!strcmp(app.argv[c], "-debug-start"))
2691 else if(!strcmp(app.argv[c], "-debug-work-dir"))
2692 debugWorkDir = true;
2693 else if(!passThrough && !strcmp(app.argv[c], "-@"))
2695 else if(passThrough)
2697 passArgs.concat(" ");
2698 passArgs.concat(app.argv[c]);
2700 else if(debugWorkDir)
2702 passDebugWorkDir = CopyString(app.argv[c]);
2703 StripQuotes(passDebugWorkDir, passDebugWorkDir);
2704 debugWorkDir = false;
2708 char fullPath[MAX_LOCATION];
2709 char parentPath[MAX_LOCATION];
2710 char ext[MAX_EXTENSION];
2712 FileAttribs dirAttribs;
2713 GetWorkingDir(fullPath, MAX_LOCATION);
2714 PathCat(fullPath, app.argv[c]);
2715 StripLastDirectory(fullPath, parentPath);
2716 GetExtension(app.argv[c], ext);
2717 isProject = !strcmpi(ext, "epj");
2719 if(isProject && c > (debugStart ? 2 : 1)) continue;
2721 // Create directory for projects (only)
2722 if(((dirAttribs = FileExists(parentPath)) && dirAttribs.isDirectory) || isProject)
2724 if(isProject && !FileExists(fullPath))
2726 // The NewProject will handle directory creation
2727 /*if(!dirAttribs.isDirectory)
2729 MakeDir(parentPath);
2730 dirAttribs = FileExists(parentPath);
2732 if(dirAttribs.isDirectory)*/
2734 char name[MAX_LOCATION];
2735 NewProjectDialog newProjectDialog;
2739 projectView.visible = false;
2740 if(!projectView.Destroy(0))
2744 newProjectDialog = { master = this };
2746 strcpy(name, app.argv[c]);
2747 StripExtension(name);
2748 GetLastDirectory(name, name);
2749 newProjectDialog.projectName.contents = name;
2750 newProjectDialog.projectName.NotifyModified(newProjectDialog, newProjectDialog.projectName);
2751 newProjectDialog.locationEditBox.path = parentPath;
2752 newProjectDialog.NotifyModifiedLocation(newProjectDialog.locationEditBox);
2754 newProjectDialog.Modal();
2757 ideSettings.AddRecentProject(projectView.fileName);
2758 ide.UpdateRecentMenus();
2759 settingsContainer.Save();
2762 // Open only one project
2766 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, null, yes, normal);
2768 else if(strstr(fullPath, "http://") == fullPath)
2769 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, null, yes, normal);
2772 if(passThrough && projectView && projectView.project && workspace)
2774 char * fixSpacing = new char[Max(passArgs.size * 1.5, 32)];
2780 bool inQuote = false;
2781 for(c=0; c<passArgs.size; c++)
2784 if(inQuote && k != '\\' && l == ' ')
2786 fixSpacing[d++] = '\"';
2787 fixSpacing[d++] = ' ';
2790 else if(inQuote && l == '\0')
2792 fixSpacing[d++] = '\"';
2793 fixSpacing[d++] = '\0';
2796 else if(!inQuote && j != '\\' && k == ' ' && l != '-' && l != ' ')
2798 fixSpacing[d++] = '\"';
2799 fixSpacing[d++] = l;
2802 else if(k == '\\' && l == ' ')
2803 fixSpacing[d++] = ' ';
2804 else if(k == '\\' && l == '\\')
2805 fixSpacing[d++] = '\\';
2807 fixSpacing[d++] = l;
2811 fixSpacing[d] = '\0';
2813 workspace.commandLineArgs = fixSpacing;
2815 if(passDebugWorkDir)
2817 workspace.debugDir = passDebugWorkDir;
2818 delete passDebugWorkDir;
2821 ;//MenuDebugStart(debugStartResumeItem, 0); // <-- how TODO this without getting into the app.Wait lock
2823 UpdateToolBarActiveConfigs(false);
2824 UpdateToolBarActiveCompilers();
2831 // IS THIS NEEDED? WASN'T HERE BEFORE... Crashes on getting node's projectView otherwise
2834 projectView.visible = false;
2835 projectView.Destroy(0);
2838 #ifdef GDB_DEBUG_GUI
2839 gdbDialog.Destroy(0);
2844 void SetPath(bool projectsDirs, CompilerConfig compiler, ProjectConfig config, int bitDepth)
2848 char * oldPaths[128];
2849 String oldList = new char[maxPathLen];
2850 Array<String> newExePaths { };
2851 //Map<String, bool> exePathExists { };
2853 #if defined(__unix__) || defined(__APPLE__)
2854 Array<String> newLibPaths { };
2855 Map<String, bool> libPathExists { };
2860 for(prj : workspace.projects)
2862 DirExpression targetDirExp;
2864 // SKIP FIRST PROJECT...
2865 if(prj == workspace.projects.firstIterator.data) continue;
2867 // NOTE: Right now the additional project config dir will be
2868 // obtained when the debugger is started, so toggling it
2869 // while building will change which library gets used.
2870 // To go with the initial state, e.g. when F5 was pressed,
2871 // we nould need to keep a list of all project's active
2872 // config upon startup.
2873 targetDirExp = prj.GetTargetDir(compiler, prj.config, bitDepth);
2875 /*if(prj.config.targetType == sharedLibrary && prj.config.debug)
2879 for(cfg = prj.configurations.first; cfg; cfg = cfg.next)
2880 if(cfg.targetType == sharedLibrary && cfg.debug && !strcmpi(cfg.name, "Debug"))
2884 for(cfg = prj.configurations.first; cfg; cfg = cfg.next)
2885 if(cfg.targetType == sharedLibrary && cfg.debug)
2889 if(targetDirExp.dir)
2891 char buffer[MAX_LOCATION];
2892 #if defined(__WIN32__)
2893 Array<String> paths = newExePaths;
2895 Array<String> paths = newLibPaths;
2897 GetSystemPathBuffer(buffer, prj.topNode.path);
2898 PathCat(buffer, targetDirExp.dir);
2901 if(!fstrcmp(p, buffer))
2908 paths.Add(CopyString(buffer));
2910 delete targetDirExp;
2914 for(item : compiler.executableDirs)
2917 for(p : newExePaths)
2919 if(!fstrcmp(p, item))
2926 newExePaths.Add(CopySystemPath(item));
2929 GetEnvironment("PATH", oldList, maxPathLen);
2931 printf("Old value of PATH: %s\n", oldList);
2933 count = TokenizeWith(oldList, sizeof(oldPaths) / sizeof(char *), oldPaths, pathListSep, false);
2934 for(c = 0; c < count; c++)
2937 for(p : newExePaths)
2939 if(!fstrcmp(p, oldPaths[c]))
2946 newExePaths.Add(CopySystemPath(oldPaths[c]));
2950 for(path : newExePaths)
2951 len += strlen(path) + 1;
2952 newList = new char[len + 1];
2954 for(path : newExePaths)
2956 strcat(newList, path);
2957 strcat(newList, pathListSep);
2959 newList[len - 1] = '\0';
2960 SetEnvironment("PATH", newList);
2962 printf("New value of PATH: %s\n", newList);
2969 #if defined(__unix__) || defined(__APPLE__)
2971 for(item : compiler.libraryDirs)
2973 if(!libPathExists[item]) // fstrcmp should be used
2975 newLibPaths.Add(item);
2976 libPathExists[item] = true;
2980 #if defined(__APPLE__)
2981 GetEnvironment("DYLD_LIBRARY_PATH", oldList, maxPathLen);
2983 GetEnvironment("LD_LIBRARY_PATH", oldList, maxPathLen);
2986 printf("Old value of [DY]LD_LIBRARY_PATH: %s\n", oldList);
2988 count = TokenizeWith(oldList, sizeof(oldPaths) / sizeof(char *), oldPaths, pathListSep, false);
2989 for(c = 0; c < count; c++)
2991 if(!libPathExists[oldPaths[c]]) // fstrcmp should be used
2993 newLibPaths.Add(oldPaths[c]);
2994 libPathExists[oldPaths[c]] = true;
2999 for(path : newLibPaths)
3000 len += strlen(path) + 1;
3001 newList = new char[len + 1];
3003 for(path : newLibPaths)
3005 strcat(newList, path);
3006 strcat(newList, pathListSep);
3008 newList[len - 1] = '\0';
3009 #if defined(__APPLE__)
3010 SetEnvironment("DYLD_LIBRARY_PATH", newList);
3012 SetEnvironment("LD_LIBRARY_PATH", newList);
3015 printf("New value of [DY]LD_LIBRARY_PATH: %s\n", newList);
3020 delete libPathExists;
3023 if(compiler.distccEnabled && compiler.distccHosts)
3024 SetEnvironment("DISTCC_HOSTS", compiler.distccHosts);
3029 void DestroyTemporaryProjectDir()
3031 if(tmpPrjDir && tmpPrjDir[0])
3033 if(FileExists(tmpPrjDir).isDirectory)
3034 DestroyDir(tmpPrjDir);
3035 property::tmpPrjDir = null;
3041 // Graphics Driver Menu
3045 app.currentSkin.selectionColor = selectionColor;
3046 app.currentSkin.selectionText = selectionText;
3050 driverItems = new MenuItem[app.numDrivers];
3051 for(c = 0; c < app.numDrivers; c++)
3053 driverItems[c] = MenuItem { driversMenu, app.drivers[c], NotifySelect = NotifySelectDisplayDriver };
3054 driverItems[c].id = c;
3055 driverItems[c].isRadio = true;
3058 driverItems = new MenuItem[2];
3059 #if defined(__unix__)
3060 driverItems[0] = MenuItem { driversMenu, "X", NotifySelect = NotifySelectDisplayDriver };
3061 driverItems[0].id = 0;
3062 driverItems[0].isRadio = true;
3064 driverItems[0] = MenuItem { driversMenu, "GDI", NotifySelect = NotifySelectDisplayDriver };
3065 driverItems[0].id = 0;
3066 driverItems[0].isRadio = true;
3068 driverItems[1] = MenuItem { driversMenu, "OpenGL", NotifySelect = NotifySelectDisplayDriver };
3069 driverItems[1].id = 1;
3070 driverItems[1].isRadio = true;
3072 /* skinItems = new MenuItem[app.numSkins];
3073 for(c = 0; c < app.numSkins; c++)
3075 skinItems[c] = MenuItem {skinsMenu, app.skins[c], NotifySelect = NotifySelectDisplaySkin };
3076 skinItems[c].id = c;
3077 skinItems[c].isRadio = true;
3080 ideFileDialog.master = this;
3081 ideProjectFileDialog.master = this;
3083 //SetDriverAndSkin();
3087 void UpdateRecentMenus()
3090 Menu fileMenu = menu.FindMenu($"File");
3091 Menu recentFiles = fileMenu.FindMenu($"Recent Files");
3092 Menu recentProjects = fileMenu.FindMenu($"Recent Projects");
3093 char itemName[MAX_LOCATION + 4];
3096 recentFiles.Clear();
3099 for(recent : ideSettings.recentFiles)
3101 sprintf(itemName, "%d %s", 1 + c, recent);
3102 MakeSystemPath(itemName);
3103 recentFiles.AddDynamic(MenuItem { copyText = true, text = itemName, (Key)k1 + c, id = c, NotifySelect = ide.FileRecentFile }, ide, true);
3107 recentProjects.Clear();
3109 for(recent : ideSettings.recentProjects)
3111 sprintf(itemName, "%d %s", 1 + c, recent);
3112 MakeSystemPath(itemName);
3113 recentProjects.AddDynamic(MenuItem { copyText = true, text = itemName, (Key)k1 + c, id = c, NotifySelect = ide.FileRecentProject }, ide, true);
3126 void DestroyDir(char * path)
3128 RecursiveDeleteFolderFSI fsi { };
3133 class RecursiveDeleteFolderFSI : NormalFileSystemIterator
3135 bool preserveRootFolder;
3137 void OutFolder(char * folderPath, bool isRoot)
3139 if(!(preserveRootFolder && isRoot))
3140 RemoveDir(folderPath);
3143 bool OnFile(char * filePath)
3145 DeleteFile(filePath);
3150 class IDEApp : GuiApplication
3152 //driver = "Win32Console";
3153 // driver = "OpenGL";
3157 TempFile includeFile { };
3161 SetLoggingMode(stdOut, null);
3162 //SetLoggingMode(debug, null);
3164 settingsContainer.Load();
3165 #if defined(__unix__) || defined(__APPLE__)
3166 app.driver = (ideSettings.displayDriver && !strcmp(ideSettings.displayDriver, "OpenGL")) ? ideSettings.displayDriver : "X";
3168 app.driver = (ideSettings.displayDriver && !strcmp(ideSettings.displayDriver, "OpenGL")) ? ideSettings.displayDriver : "GDI";
3170 ide.driverItems[ideSettings.displayDriver && !strcmp(ideSettings.displayDriver,"OpenGL")].checked = true;
3174 desktop.text = titleECEREIDE;
3177 for(c = 1; c<app.argc; c++)
3179 char fullPath[MAX_LOCATION];
3180 GetWorkingDir(fullPath, MAX_LOCATION);
3181 PathCat(fullPath, app.argv[c]);
3182 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, null, yes, normal);
3186 if(!LoadIncludeFile())
3187 PrintLn("error: unable to load :crossplatform.mk file inside ide binary.");
3192 bool LoadIncludeFile()
3194 bool result = false;
3195 File include = FileOpen(":crossplatform.mk", read);
3198 File f = includeFile;
3201 for(; !include.Eof(); )
3204 int count = include.Read(buffer, 1, 4096);
3205 f.Write(buffer, 1, count);
3215 IDEMainFrame ideMainFrame { };
3217 define app = ((IDEApp)__thisModule);
3219 define titleECEREIDE = $"ECERE IDE (Debug)";
3221 define titleECEREIDE = $"ECERE IDE";