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 bool ShouldStopBuild()
1591 return projectView.stopBuild;
1594 void DocumentSaved(Window document, char * fileName)
1596 ideSettings.AddRecentFile(fileName);
1597 ide.UpdateRecentMenus();
1598 ide.AdjustFileMenus();
1599 settingsContainer.Save();
1602 bool Window::OnFileModified(FileChange fileChange, char * param)
1605 sprintf(temp, $"The document %s was modified by another application.\n"
1606 "Would you like to reload it and lose your changes?", this.fileName);
1607 if(MessageBox { type = yesNo, master = this/*.parent*/,
1608 text = $"Document has been modified", contents = temp }.Modal() == yes)
1610 char * fileName = CopyString(this.fileName);
1611 WindowState state = this.state;
1612 Anchor anchor = this.anchor;
1613 Size size = this.size;
1615 this.modifiedDocument = false;
1617 this = ide.OpenFile(fileName, normal, true, null, no, normal);
1620 this.anchor = anchor;
1622 this.SetState(state, true, 0);
1630 void UpdateMakefiles()
1634 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
1635 for(prj : workspace.projects)
1636 projectView.ProjectUpdateMakefileForAllConfigs(prj);
1641 void UpdateCompilerConfigs(bool mute)
1643 UpdateToolBarActiveCompilers();
1646 bool silent = mute || (ide.projectView.buildInProgress == none ? false : true);
1647 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
1650 projectView.ShowOutputBuildLog(true);
1651 projectView.DisplayCompiler(compiler, false);
1653 for(prj : workspace.projects)
1654 projectView.ProjectPrepareCompiler(prj, compiler, silent);
1659 void UpdateToolBarActiveCompilers()
1661 toolBar.activeCompiler.Clear();
1662 for(compiler : ideSettings.compilerConfigs)
1664 DataRow row = toolBar.activeCompiler.AddString(compiler.name);
1665 if(workspace && workspace.compiler && !strcmp(compiler.name, workspace.compiler))
1666 toolBar.activeCompiler.currentRow = row;
1668 if(!toolBar.activeCompiler.currentRow && toolBar.activeCompiler.firstRow)
1669 toolBar.activeCompiler.SelectRow(toolBar.activeCompiler.firstRow);
1672 void UpdateToolBarActiveConfigs(bool selectionOnly)
1674 bool commonSelected = false;
1675 DataRow row = toolBar.activeConfig.currentRow;
1677 row = toolBar.activeConfig.FindRow(1);
1680 toolBar.activeConfig.Clear();
1681 row = toolBar.activeConfig.AddString("(Mixed)");
1686 char * configName = null;
1689 Map<String, int> configs { }; // TOIMP: just need sort but using map until containers have sort
1690 for(prj : workspace.projects)
1692 for(cfg : prj.configurations)
1695 configs[cfg.name] = 1;
1700 toolBar.activeConfig.AddString(&name);
1704 if(projectView && projectView.project)
1706 for(prj : workspace.projects)
1708 if(prj.config && prj.config.name)
1710 configName = prj.config.name;
1716 commonSelected = true;
1717 for(prj : workspace.projects)
1719 if(prj.config && (!prj.config.name || strcmp(prj.config.name, configName)))
1721 commonSelected = false;
1729 commonSelected = false;
1730 for(row = toolBar.activeConfig.firstRow; row; row = row.next)
1732 if(!strcmp(row.string, configName))
1734 toolBar.activeConfig.currentRow = row;
1735 commonSelected = true;
1742 toolBar.activeConfig.Sort(null, 0);
1744 toolBar.activeConfig.currentRow = row;
1749 bool unavailable = !project;
1751 projectAddItem.disabled = unavailable;
1752 toolBar.buttonAddProject.disabled = unavailable;
1754 projectSettingsItem.disabled = unavailable;
1756 projectBrowseFolderItem.disabled = unavailable;
1758 viewProjectItem.disabled = unavailable;
1760 toolBar.activeConfig.disabled = unavailable;
1761 toolBar.activeCompiler.disabled = unavailable;
1762 toolBar.activeBitDepth.disabled = unavailable;
1769 property bool hasOpenedCodeEditors
1774 for(w = firstChild; w; w = w.next)
1775 if(w._class == class(CodeEditor) &&
1776 w.isDocument && !w.closing && w.visible && w.created &&
1777 w.fileName && w.fileName[0])
1783 void AdjustFileMenus()
1785 bool unavailable = project != null || !hasOpenedCodeEditors; // are they supported source code (ec, c, cpp, etc) ?
1787 projectQuickItem.disabled = unavailable;
1790 void AdjustBuildMenus()
1792 bool unavailable = project && projectView.buildInProgress;
1794 projectNewItem.disabled = unavailable;
1795 toolBar.buttonNewProject.disabled = unavailable;
1796 projectOpenItem.disabled = unavailable;
1797 toolBar.buttonOpenProject.disabled = unavailable;
1799 unavailable = !project || projectView.buildInProgress;
1801 projectCloseItem.disabled = unavailable;
1802 // toolBar.buttonCloseProject.disabled = unavailable;
1804 projectRunItem.disabled = unavailable || project.GetTargetType(project.config) != executable;
1805 toolBar.buttonRun.disabled = unavailable || project.GetTargetType(project.config) != executable;
1807 projectBuildItem.disabled = false;
1808 projectBuildItem.text = unavailable ? $"Stop Build" : $"Build";
1809 projectBuildItem.accelerator = unavailable ? Key { pauseBreak, ctrl = true } : f7;
1811 projectLinkItem.disabled = unavailable;
1812 toolBar.buttonReLink.disabled = unavailable;
1813 projectRebuildItem.disabled = unavailable;
1814 toolBar.buttonRebuild.disabled = unavailable;
1815 projectCleanItem.disabled = unavailable;
1816 toolBar.buttonClean.disabled = unavailable;
1817 projectRealCleanItem.disabled = unavailable;
1818 // toolBar.buttonRealClean.disabled = unavailable;
1819 projectRegenerateItem.disabled = unavailable;
1820 toolBar.buttonRegenerateMakefile.disabled = unavailable;
1821 projectCompileItem.disabled = unavailable;
1823 AdjustPopupBuildMenus();
1826 void AdjustPopupBuildMenus()
1828 bool unavailable = !project || projectView.buildInProgress;
1830 if(projectView && projectView.popupMenu && projectView.popupMenu.menu && projectView.popupMenu.created)
1833 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectBuild, 0);
1836 menu.disabled = false;
1837 menu.text = unavailable ? $"Stop Build" : $"Build";
1838 menu.accelerator = unavailable ? Key { pauseBreak, ctrl = true } : f7;
1841 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectLink, 0); if(menu) menu.disabled = unavailable;
1842 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRebuild, 0); if(menu) menu.disabled = unavailable;
1843 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectClean, 0); if(menu) menu.disabled = unavailable;
1844 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRealClean, 0); if(menu) menu.disabled = unavailable;
1845 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRegenerate, 0); if(menu) menu.disabled = unavailable;
1846 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRemove, 0); if(menu) menu.disabled = unavailable;
1847 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileClean, 0); if(menu) menu.disabled = unavailable;
1848 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileCompile, 0); if(menu) menu.disabled = unavailable;
1849 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugPrecompile, 0); if(menu) menu.disabled = unavailable;
1850 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugCompile, 0); if(menu) menu.disabled = unavailable;
1851 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugGenerateSymbols, 0); if(menu) menu.disabled = unavailable;
1852 projectView.popupMenu.Update(null);
1856 void AdjustDebugMenus()
1858 bool unavailable = !project || project.GetTargetType(project.config) != executable ||
1859 projectView.buildInProgress == buildingMainProject;
1860 bool active = ide.debugger.isActive;
1861 bool executing = ide.debugger.state == running;
1862 //bool holding = ide.debugger.state == stopped;
1864 debugStartResumeItem.disabled = unavailable || executing;
1865 debugStartResumeItem.text = active ? $"Resume" : $"Start";
1866 debugStartResumeItem.NotifySelect = active ? MenuDebugResume : MenuDebugStart;
1869 toolBar.buttonDebugStartResume.disabled = unavailable || executing;
1870 toolBar.buttonDebugStartResume.toolTip = active ? $"Resume" : $"Start";
1873 debugBreakItem.disabled = unavailable || !executing;
1874 debugStopItem.disabled = unavailable || !active;
1875 debugRestartItem.disabled = unavailable || !active;
1878 toolBar.buttonDebugPause.disabled = unavailable || !executing;
1879 toolBar.buttonDebugStop.disabled = unavailable || !active;
1880 toolBar.buttonDebugRestart.disabled = unavailable || !active;
1883 debugStepIntoItem.disabled = unavailable || executing;
1884 debugStepOverItem.disabled = unavailable || executing;
1885 debugStepOutItem.disabled = unavailable || executing || !active;
1886 debugSkipStepOverItem.disabled = unavailable || executing;
1887 debugSkipStepOutItem.disabled = unavailable || executing || !active;
1890 toolBar.buttonDebugStepInto.disabled = unavailable || executing;
1891 toolBar.buttonDebugStepOver.disabled = unavailable || executing;
1892 toolBar.buttonDebugStepOut.disabled = unavailable || executing || !active;
1893 toolBar.buttonDebugSkipStepOver.disabled = unavailable || executing;
1894 // toolBar.buttonDebugSkipStepOutItem.disabled = unavailable || executing;
1896 if((Designer)GetActiveDesigner())
1898 CodeEditor codeEditor = ((Designer)GetActiveDesigner()).codeEditor;
1901 codeEditor.debugRunToCursor.disabled = unavailable || executing;
1902 codeEditor.debugSkipRunToCursor.disabled = unavailable || executing;
1907 void ChangeFileDialogsDirectory(char * directory, bool saveSettings)
1909 char tempString[MAX_LOCATION];
1910 strcpy(tempString, directory);
1911 if(saveSettings && !projectView)
1913 ideSettings.ideFileDialogLocation = directory;
1914 settingsContainer.Save();
1917 ideFileDialog.currentDirectory = tempString;
1918 codeEditorFileDialog.currentDirectory = tempString;
1919 codeEditorFormFileDialog.currentDirectory = tempString;
1922 void ChangeProjectFileDialogDirectory(char * directory)
1924 ideSettings.ideProjectFileDialogLocation = directory;
1925 settingsContainer.Save();
1928 Window FindWindow(char * filePath)
1930 Window document = null;
1932 // TOCHECK: Do we need to change slashes here?
1933 for(document = firstChild; document; document = document.next)
1935 char * fileName = document.fileName;
1936 if(document.isDocument && fileName && !fstrcmp(fileName, filePath))
1938 document.visible = true;
1939 document.Activate();
1946 bool DontTerminateDebugSession(char * title)
1948 if(debugger.isActive)
1950 if(MessageBox { type = yesNo, master = ide,
1951 contents = $"Do you want to terminate the debugging session in progress?",
1952 text = title }.Modal() == no)
1955 MessageBox msg { type = yesNo, master = ide,
1956 contents = "Do you want to terminate the debugging session in progress?",
1958 if(msg.Modal() == no)
1970 Window OpenFile(char * origFilePath, WindowState state, bool visible, char * type, OpenCreateIfFails createIfFails, OpenMethod openMethod)
1972 char extension[MAX_EXTENSION] = "";
1973 Window document = null;
1974 bool isProject = false;
1975 bool needFileModified = true;
1976 char winFilePath[MAX_LOCATION];
1977 char * filePath = strstr(origFilePath, "http://") == origFilePath ? strcpy(winFilePath, origFilePath) : GetSystemPathBuffer(winFilePath, origFilePath);
1981 GetExtension(filePath, extension);
1985 strcpy(extension, type);
1987 if(strcmp(extension, ProjectExtension))
1989 for(document = firstChild; document; document = document.next)
1991 char * fileName = document.fileName;
1992 if(document.isDocument && fileName && !fstrcmp(fileName, filePath) && document.created)
1994 document.visible = true;
1996 document.Activate();
2002 if(createIfFails == whatever)
2004 else if(!strcmp(extension, ProjectExtension) || !strcmp(extension, WorkspaceExtension))
2006 needFileModified = false;
2007 if(openMethod == normal)
2009 if(DontTerminateDebugSession($"Open Project"))
2012 if(MenuWindowCloseAll(null, 0))
2016 projectView.visible = false;
2017 projectView.Destroy(0);
2018 // Where did this come from? projectView = null;
2025 Workspace workspace = null;
2027 if(FileExists(filePath))
2029 if(!strcmp(extension, ProjectExtension))
2031 char workspaceFile[MAX_LOCATION];
2032 strcpy(workspaceFile, filePath);
2033 ChangeExtension(workspaceFile, WorkspaceExtension, workspaceFile);
2034 workspace = LoadWorkspace(workspaceFile, filePath);
2036 else if(!strcmp(extension, WorkspaceExtension))
2037 workspace = LoadWorkspace(filePath, null);
2040 //project = LoadProject(filePath, null);
2045 char absolutePath[MAX_LOCATION];
2046 CreateProjectView(workspace, filePath);
2047 document = projectView;
2049 workspace.DropInvalidBreakpoints();
2052 ide.projectView.ShowOutputBuildLog(true);
2054 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
2055 ide.projectView.DisplayCompiler(compiler, false);
2058 UpdateCompilerConfigs(false);
2061 char newWorkingDir[MAX_LOCATION];
2062 StripLastDirectory(filePath, newWorkingDir);
2063 ChangeFileDialogsDirectory(newWorkingDir, false);
2066 document.fileName = filePath;
2068 ideMainFrame.SetText("%s - %s", filePath, titleECEREIDE);
2070 // this crashes on starting ide with epj file, solution please?
2071 // app.UpdateDisplay();
2073 workspace.holdTracking = true;
2074 for(ofi : workspace.openedFiles)
2076 if(ofi.state != closed)
2078 Window file = OpenFile(ofi.path, normal, true, null, no, normal);
2081 char fileName[MAX_LOCATION];
2083 GetLastDirectory(ofi.path, fileName);
2084 node = projectView.project.topNode.Find(fileName, true);
2086 node.EnsureVisible();
2090 workspace.holdTracking = false;
2092 workspace.timer.Start();
2094 findInFilesDialog.mode = FindInFilesMode::project;
2095 findInFilesDialog.currentDirectory = ide.project.topNode.path;
2098 char location[MAX_LOCATION];
2099 StripLastDirectory(ide.project.topNode.path, location);
2100 ChangeProjectFileDialogDirectory(location);
2104 if(projectView.debugger)
2105 projectView.debugger.EvaluateWatches();
2112 if(MessageBox { type = yesNo, master = this, text = $"Error opening project", contents = $"Open a different project?" }.Modal() == yes)
2114 ideProjectFileDialog.text = openProjectFileDialogTitle;
2115 if(ideProjectFileDialog.Modal() == cancel)
2117 filePath = ideProjectFileDialog.filePath;
2118 GetExtension(filePath, extension);
2129 else if(openMethod == add)
2134 char slashFilePath[MAX_LOCATION];
2135 GetSlashPathBuffer(slashFilePath, filePath);
2136 for(p : workspace.projects)
2138 if(!fstrcmp(p.filePath, slashFilePath))
2146 MessageBox { type = ok, parent = parent, master = this, text = $"Same Project",
2147 contents = $"This project is already present in workspace." }.Modal();
2151 prj = LoadProject(filePath, null);
2154 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
2155 prj.StartMonitoring();
2156 workspace.projects.Add(prj);
2158 projectView.AddNode(prj.topNode, null);
2159 workspace.modified = true;
2161 findInFilesDialog.AddProjectItem(prj);
2162 projectView.ShowOutputBuildLog(true);
2163 projectView.DisplayCompiler(compiler, false);
2164 projectView.ProjectUpdateMakefileForAllConfigs(prj);
2168 char location[MAX_LOCATION];
2169 StripLastDirectory(prj.topNode.path, location);
2170 ChangeProjectFileDialogDirectory(location);
2173 // projectView is associated with the main project and not with the one just added but
2174 return projectView; // just to let the caller know something was opened
2182 else if(!strcmp(extension, "bmp") || !strcmp(extension, "pcx") ||
2183 !strcmp(extension, "jpg") || !strcmp(extension, "gif") ||
2184 !strcmp(extension, "jpeg") || !strcmp(extension, "png"))
2186 if(FileExists(filePath))
2187 document = PictureEdit { hasMaximize = true, hasMinimize = true, hasClose = true, borderStyle = sizable,
2188 hasVertScroll = true, hasHorzScroll = true, parent = this, state = state,
2189 visible = visible, bitmapFile = filePath, OnClose = PictureEditOnClose/*why?--GenericDocumentOnClose*/;
2192 MessageBox { type = ok, master = this, text = filePath, contents = $"File doesn't exist." }.Modal();
2195 else if(!strcmp(extension, "3ds"))
2197 if(FileExists(filePath))
2198 document = ModelView { hasMaximize = true, hasMinimize = true, hasClose = true, borderStyle = sizable,
2199 hasVertScroll = true, hasHorzScroll = true, parent = this, state = state,
2200 visible = visible, modelFile = filePath, OnClose = ModelViewOnClose/*why?--GenericDocumentOnClose*/
2204 MessageBox { type = ok, master = this, text = filePath, contents = $"File doesn't exist." }.Modal();
2207 else if(!strcmp(extension, "txt") || !strcmp(extension, "text") ||
2208 !strcmp(extension, "nfo") || !strcmp(extension, "info") ||
2209 !strcmp(extension, "htm") || !strcmp(extension, "html") ||
2210 !strcmp(extension, "css") || !strcmp(extension, "php") ||
2211 !strcmp(extension, "js"))
2213 CodeEditor editor { parent = this, state = state, visible = false };
2214 editor.updatingCode = true;
2215 if(editor.LoadFile(filePath))
2218 editor.visible = true;
2222 needFileModified = false;
2226 CodeEditor editor { parent = this, state = state, visible = false };
2227 if(editor.LoadFile(filePath))
2230 editor.visible = true;
2234 needFileModified = false;
2237 if(document && (document._class == class(PictureEdit) ||
2238 document._class == class(ModelView)))
2243 document.fileName = filePath;
2244 if(workspace && !workspace.holdTracking)
2245 workspace.UpdateOpenedFileInfo(filePath, opened);
2249 if(!document && createIfFails != no)
2251 if(createIfFails != yes && !needFileModified &&
2252 MessageBox { type = yesNo, master = this, text = filePath, contents = $"File doesn't exist. Create?" }.Modal() == yes)
2253 createIfFails = yes;
2254 if(createIfFails == yes || createIfFails == whatever)
2256 document = (Window)NewCodeEditor(this, state, true);
2258 document.fileName = filePath;
2264 if(projectView && document._class == class(CodeEditor) && workspace)
2266 int lineNumber, position;
2268 CodeEditor editor = (CodeEditor)document;
2269 editor.openedFileInfo = workspace.UpdateOpenedFileInfo(filePath, opened);
2270 editor.openedFileInfo.holdTracking = true;
2271 lineNumber = Max(editor.openedFileInfo.lineNumber - 1, 0);
2272 position = Max(editor.openedFileInfo.position - 1, 0);
2273 editor.editBox.GoToLineNum(lineNumber);
2274 editor.editBox.GoToPosition(editor.editBox.line, lineNumber, position);
2275 scroll.x = Max(editor.openedFileInfo.scroll.x, 0);
2276 scroll.y = Max(editor.openedFileInfo.scroll.y, 0);
2277 editor.editBox.scroll = scroll;
2278 editor.openedFileInfo.holdTracking = false;
2281 if(needFileModified)
2282 document.OnFileModified = OnFileModified;
2283 document.NotifySaved = DocumentSaved;
2286 ideSettings.AddRecentProject(document.fileName);
2288 ideSettings.AddRecentFile(document.fileName);
2289 ide.UpdateRecentMenus();
2290 ide.AdjustFileMenus();
2291 settingsContainer.Save();
2299 // TOCHECK: I can't use a generic one for both ModelView and PictureEdit both derived from Window
2300 /*bool Window::GenericDocumentOnClose(bool parentClosing)
2302 if(!parentClosing && ide.workspace)
2303 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2306 bool ModelView::ModelViewOnClose(bool parentClosing)
2308 if(!parentClosing && ide.workspace)
2309 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2312 bool PictureEdit::PictureEditOnClose(bool parentClosing)
2314 if(!parentClosing && ide.workspace)
2315 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2320 void OnUnloadGraphics(Window window)
2322 display.ClearMaterials();
2323 display.ClearTextures();
2324 display.ClearMeshes();
2328 bool OnActivate(bool active, Window swap, bool * goOnWithActivation, bool direct)
2330 caps.color = app.GetKeyState(capsState) ? black : Color { 128,128,128 };
2331 num.color = app.GetKeyState(numState) ? black : Color { 128,128,128 };
2335 bool OnKeyDown(Key key, unichar ch)
2340 projectView.Update(null);
2343 caps.color = app.GetKeyState(capsState) ? black : Color { 128,128,128 };
2346 num.color = app.GetKeyState(numState) ? black : Color { 128,128,128 };
2352 void GoToError(const char * line)
2355 projectView.GoToError(line);
2358 void CodeLocationParseAndGoTo(const char * text, Project project, const char * dir)
2361 char *colon = strchr(text, ':');
2362 char filePath[MAX_LOCATION];
2363 char completePath[MAX_LOCATION];
2364 int line = 0, col = 0;
2366 FileAttribs fileAttribs;
2368 if(colon && (colon[1] == '/' || colon[1] == '\\'))
2370 path = (colon - 1 > path) ? colon - 1 : path;
2371 colon = strstr(colon + 1, ":");
2373 while(isspace(*path)) path++;
2376 char * close = strchr(path, ')');
2380 strncpy(name, path+1, close - path - 1);
2381 name[close - path - 1] = '\0';
2382 for(p : ide.workspace.projects)
2384 if(!strcmp(p.name, name))
2394 prj = project ? project : (dir ? null : ide.project);
2397 strncpy(filePath, path, colon - path);
2398 filePath[colon - path] = '\0';
2399 line = atoi(colon + 1);
2400 colon = strstr(colon + 1, ":");
2402 col = atoi(colon + 1);
2404 else if(path - 1 >= text && *(path - 1) == '\"')
2406 colon = strchr(path, '\"');
2409 strncpy(filePath, path, colon - path);
2410 filePath[colon - path] = '\0';
2413 else if(path && !colon)
2415 strcpy(filePath, path);
2419 strcpy(completePath, prj.topNode.path);
2420 else if(dir && dir[0])
2421 strcpy(completePath, dir);
2423 completePath[0] = '\0';
2424 PathCat(completePath, filePath);
2426 fileAttribs = FileExists(completePath);
2427 if(fileAttribs.isFile)
2429 CodeEditor codeEditor = (CodeEditor)OpenFile(completePath, normal, true, "", no, normal);
2430 if(codeEditor && line)
2432 EditBox editBox = codeEditor.editBox;
2433 editBox.GoToLineNum(line - 1);
2434 editBox.GoToPosition(editBox.line, line - 1, col ? (col - 1) : 0);
2437 else if(fileAttribs.isDirectory)
2438 ShellOpen(completePath);
2441 void OnRedraw(Surface surface)
2443 Bitmap bitmap = back.bitmap;
2445 surface.Blit(bitmap, (clientSize.w - bitmap.width) / 2, (clientSize.h - bitmap.height) / 2, 0, 0, bitmap.width, bitmap.height);
2448 void SheetSelected(SheetType sheetSelected)
2450 if(activeChild == sheet)
2452 if(sheetSelected == methods)
2454 viewPropertiesItem.accelerator = f4;
2455 viewPropertiesItem.parent = viewMenu;
2456 viewMethodsItem.parent = null;
2460 viewMethodsItem.accelerator = f4;
2461 viewMethodsItem.parent = viewMenu;
2462 viewPropertiesItem.parent = null;
2467 viewMethodsItem.parent = viewMenu;
2468 viewPropertiesItem.parent = viewMenu;
2469 if(sheetSelected == methods)
2471 viewMethodsItem.accelerator = f4;
2472 viewPropertiesItem.accelerator = 0;
2476 viewMethodsItem.accelerator = 0;
2477 viewPropertiesItem.accelerator = f4;
2482 void OnActivateClient(Window client, Window previous)
2484 //if(!client || client != previous)
2487 if(!client || client != previous)
2490 dataType = previous._class;
2491 if(previous && !strcmp(dataType.name, "CodeEditor"))
2493 ((CodeEditor)previous).UpdateFormCode();
2495 else if(previous && !strcmp(dataType.name, "Designer"))
2497 ((Designer)previous).codeEditor.UpdateFormCode();
2502 dataType = client._class;
2503 if(client && !strcmp(dataType.name, "CodeEditor"))
2505 CodeEditor codeEditor = (CodeEditor)client;
2506 SetPrivateModule(codeEditor.privateModule);
2507 SetCurrentContext(codeEditor.globalContext);
2508 SetTopContext(codeEditor.globalContext);
2509 SetGlobalContext(codeEditor.globalContext);
2511 SetDefines(&codeEditor.defines);
2512 SetImports(&codeEditor.imports);
2514 SetActiveDesigner(codeEditor.designer);
2516 sheet.codeEditor = codeEditor;
2517 toolBox.codeEditor = codeEditor;
2519 viewDesignerItem.parent = viewMenu;
2520 if(activeChild != codeEditor)
2522 viewCodeItem.parent = viewMenu;
2523 viewDesignerItem.accelerator = 0;
2524 viewCodeItem.accelerator = f8;
2528 viewCodeItem.parent = null;
2529 viewDesignerItem.accelerator = f8;
2532 else if(client && !strcmp(dataType.name, "Designer"))
2534 CodeEditor codeEditor = ((Designer)client).codeEditor;
2537 SetPrivateModule(codeEditor.privateModule);
2538 SetCurrentContext(codeEditor.globalContext);
2539 SetTopContext(codeEditor.globalContext);
2540 SetGlobalContext(codeEditor.globalContext);
2541 SetDefines(&codeEditor.defines);
2542 SetImports(&codeEditor.imports);
2546 SetPrivateModule(null);
2547 SetCurrentContext(null);
2548 SetTopContext(null);
2549 SetGlobalContext(null);
2554 SetActiveDesigner((Designer)client);
2556 sheet.codeEditor = codeEditor;
2557 toolBox.codeEditor = codeEditor;
2559 viewCodeItem.parent = viewMenu;
2560 if(activeChild != client)
2562 viewDesignerItem.parent = viewMenu;
2563 viewDesignerItem.accelerator = f8;
2564 viewCodeItem.accelerator = 0;
2568 viewDesignerItem.parent = null;
2569 viewCodeItem.accelerator = f8;
2575 sheet.codeEditor = null;
2576 toolBox.codeEditor = null;
2577 SetActiveDesigner(null);
2579 viewDesignerItem.parent = null;
2580 viewCodeItem.parent = null;
2583 SheetSelected(sheet.sheetSelected);
2586 projectCompileItem = null;
2591 if(client && client._class == eSystem_FindClass(__thisModule, "CodeEditor")) // !strcmp(client._class.name, "CodeEditor")
2593 CodeEditor codeEditor = (CodeEditor)client;
2594 EditBox editBox = codeEditor.editBox;
2596 statusBar.AddField(pos);
2598 caps = { width = 40, text = $"CAPS", color = app.GetKeyState(capsState) ? black : Color { 128, 128, 128 } };
2599 statusBar.AddField(caps);
2601 ovr = { width = 30, text = $"OVR", color = editBox.overwrite ? black : Color { 128, 128, 128 } };
2602 statusBar.AddField(ovr);
2604 num = { width = 30, text = $"NUM", color = app.GetKeyState(numState) ? black : Color { 128, 128, 128 } };
2605 statusBar.AddField(num);
2607 //statusBar.text = "Ready";
2609 if(projectView && projectView.project)
2611 bool isCObject = false;
2612 ProjectNode node = projectView.GetNodeFromWindow(client, null, false);
2613 if(!node && (node = projectView.GetNodeFromWindow(client, null, true)))
2617 char nodeName[MAX_FILENAME];
2618 char name[MAX_FILENAME+96];
2620 ChangeExtension(node.name, "c", nodeName);
2621 sprintf(name, $"Compile %s", isCObject ? nodeName : node.name);
2622 projectCompileItem =
2624 copyText = true, text = name, c, ctrlF7, disabled = projectView.buildInProgress;
2626 bool NotifySelect(MenuItem selection, Modifiers mods)
2630 bool result = false;
2631 bool isCObject = false;
2632 ProjectNode node = null;
2633 for(p : ide.workspace.projects)
2635 node = projectView.GetNodeFromWindow(activeClient, p, false);
2638 if(!node && (node = projectView.GetNodeFromWindow(activeClient, null, true)))
2642 List<ProjectNode> nodes { };
2644 projectView.Compile(node.project, nodes, mods.ctrl && mods.shift, isCObject ? cObject : normal);
2649 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
2654 projectMenu.AddDynamic(projectCompileItem, ide, false);
2660 caps = ovr = num = null;
2665 bool OnClose(bool parentClosing)
2667 //return !projectView.buildInProgress;
2668 if(projectView && projectView.buildInProgress)
2670 if(DontTerminateDebugSession($"Close IDE"))
2672 if(findInFilesDialog)
2673 findInFilesDialog.SearchStop();
2676 workspace.timer.Stop();
2679 ideMainFrame.Destroy(0);
2686 bool passThrough = false;
2687 bool debugStart = false;
2688 bool debugWorkDir = false;
2689 char * passDebugWorkDir = null;
2690 bool openAsText = false;
2691 DynamicString passArgs { };
2692 for(c = 1; c<app.argc; c++)
2694 if(!strcmp(app.argv[c], "-debug-start"))
2696 else if(!strcmp(app.argv[c], "-debug-work-dir"))
2697 debugWorkDir = true;
2698 else if(!passThrough && !strcmp(app.argv[c], "-@"))
2700 else if(passThrough)
2702 passArgs.concat(" ");
2703 passArgs.concat(app.argv[c]);
2705 else if(debugWorkDir)
2707 passDebugWorkDir = CopyString(app.argv[c]);
2708 StripQuotes(passDebugWorkDir, passDebugWorkDir);
2709 debugWorkDir = false;
2713 char fullPath[MAX_LOCATION];
2714 char parentPath[MAX_LOCATION];
2715 char ext[MAX_EXTENSION];
2717 FileAttribs dirAttribs;
2718 GetWorkingDir(fullPath, MAX_LOCATION);
2719 PathCat(fullPath, app.argv[c]);
2720 StripLastDirectory(fullPath, parentPath);
2721 GetExtension(app.argv[c], ext);
2722 isProject = !strcmpi(ext, "epj");
2724 if(isProject && c > (debugStart ? 2 : 1)) continue;
2726 // Create directory for projects (only)
2727 if(((dirAttribs = FileExists(parentPath)) && dirAttribs.isDirectory) || isProject)
2729 if(isProject && !FileExists(fullPath))
2731 // The NewProject will handle directory creation
2732 /*if(!dirAttribs.isDirectory)
2734 MakeDir(parentPath);
2735 dirAttribs = FileExists(parentPath);
2737 if(dirAttribs.isDirectory)*/
2739 char name[MAX_LOCATION];
2740 NewProjectDialog newProjectDialog;
2744 projectView.visible = false;
2745 if(!projectView.Destroy(0))
2749 newProjectDialog = { master = this };
2751 strcpy(name, app.argv[c]);
2752 StripExtension(name);
2753 GetLastDirectory(name, name);
2754 newProjectDialog.projectName.contents = name;
2755 newProjectDialog.projectName.NotifyModified(newProjectDialog, newProjectDialog.projectName);
2756 newProjectDialog.locationEditBox.path = parentPath;
2757 newProjectDialog.NotifyModifiedLocation(newProjectDialog.locationEditBox);
2759 newProjectDialog.Modal();
2762 ideSettings.AddRecentProject(projectView.fileName);
2763 ide.UpdateRecentMenus();
2764 settingsContainer.Save();
2767 // Open only one project
2771 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, null, yes, normal);
2773 else if(strstr(fullPath, "http://") == fullPath)
2774 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, null, yes, normal);
2777 if(passThrough && projectView && projectView.project && workspace)
2779 char * fixSpacing = new char[Max(passArgs.size * 1.5, 32)];
2785 bool inQuote = false;
2786 for(c=0; c<passArgs.size; c++)
2789 if(inQuote && k != '\\' && l == ' ')
2791 fixSpacing[d++] = '\"';
2792 fixSpacing[d++] = ' ';
2795 else if(inQuote && l == '\0')
2797 fixSpacing[d++] = '\"';
2798 fixSpacing[d++] = '\0';
2801 else if(!inQuote && j != '\\' && k == ' ' && l != '-' && l != ' ')
2803 fixSpacing[d++] = '\"';
2804 fixSpacing[d++] = l;
2807 else if(k == '\\' && l == ' ')
2808 fixSpacing[d++] = ' ';
2809 else if(k == '\\' && l == '\\')
2810 fixSpacing[d++] = '\\';
2812 fixSpacing[d++] = l;
2816 fixSpacing[d] = '\0';
2818 workspace.commandLineArgs = fixSpacing;
2820 if(passDebugWorkDir)
2822 workspace.debugDir = passDebugWorkDir;
2823 delete passDebugWorkDir;
2826 ;//MenuDebugStart(debugStartResumeItem, 0); // <-- how TODO this without getting into the app.Wait lock
2828 UpdateToolBarActiveConfigs(false);
2829 UpdateToolBarActiveCompilers();
2836 // IS THIS NEEDED? WASN'T HERE BEFORE... Crashes on getting node's projectView otherwise
2839 projectView.visible = false;
2840 projectView.Destroy(0);
2843 #ifdef GDB_DEBUG_GUI
2844 gdbDialog.Destroy(0);
2849 void SetPath(bool projectsDirs, CompilerConfig compiler, ProjectConfig config, int bitDepth)
2853 char * oldPaths[128];
2854 String oldList = new char[maxPathLen];
2855 Array<String> newExePaths { };
2856 //Map<String, bool> exePathExists { };
2858 #if defined(__unix__) || defined(__APPLE__)
2859 Array<String> newLibPaths { };
2860 Map<String, bool> libPathExists { };
2865 for(prj : workspace.projects)
2867 DirExpression targetDirExp;
2869 // SKIP FIRST PROJECT...
2870 if(prj == workspace.projects.firstIterator.data) continue;
2872 // NOTE: Right now the additional project config dir will be
2873 // obtained when the debugger is started, so toggling it
2874 // while building will change which library gets used.
2875 // To go with the initial state, e.g. when F5 was pressed,
2876 // we nould need to keep a list of all project's active
2877 // config upon startup.
2878 targetDirExp = prj.GetTargetDir(compiler, prj.config, bitDepth);
2880 /*if(prj.config.targetType == sharedLibrary && prj.config.debug)
2884 for(cfg = prj.configurations.first; cfg; cfg = cfg.next)
2885 if(cfg.targetType == sharedLibrary && cfg.debug && !strcmpi(cfg.name, "Debug"))
2889 for(cfg = prj.configurations.first; cfg; cfg = cfg.next)
2890 if(cfg.targetType == sharedLibrary && cfg.debug)
2894 if(targetDirExp.dir)
2896 char buffer[MAX_LOCATION];
2897 #if defined(__WIN32__)
2898 Array<String> paths = newExePaths;
2900 Array<String> paths = newLibPaths;
2902 GetSystemPathBuffer(buffer, prj.topNode.path);
2903 PathCat(buffer, targetDirExp.dir);
2906 if(!fstrcmp(p, buffer))
2913 paths.Add(CopyString(buffer));
2915 delete targetDirExp;
2919 for(item : compiler.executableDirs)
2922 for(p : newExePaths)
2924 if(!fstrcmp(p, item))
2931 newExePaths.Add(CopySystemPath(item));
2934 GetEnvironment("PATH", oldList, maxPathLen);
2936 printf("Old value of PATH: %s\n", oldList);
2938 count = TokenizeWith(oldList, sizeof(oldPaths) / sizeof(char *), oldPaths, pathListSep, false);
2939 for(c = 0; c < count; c++)
2942 for(p : newExePaths)
2944 if(!fstrcmp(p, oldPaths[c]))
2951 newExePaths.Add(CopySystemPath(oldPaths[c]));
2955 for(path : newExePaths)
2956 len += strlen(path) + 1;
2957 newList = new char[len + 1];
2959 for(path : newExePaths)
2961 strcat(newList, path);
2962 strcat(newList, pathListSep);
2964 newList[len - 1] = '\0';
2965 SetEnvironment("PATH", newList);
2967 printf("New value of PATH: %s\n", newList);
2974 #if defined(__unix__) || defined(__APPLE__)
2976 for(item : compiler.libraryDirs)
2978 if(!libPathExists[item]) // fstrcmp should be used
2980 newLibPaths.Add(item);
2981 libPathExists[item] = true;
2985 #if defined(__APPLE__)
2986 GetEnvironment("DYLD_LIBRARY_PATH", oldList, maxPathLen);
2988 GetEnvironment("LD_LIBRARY_PATH", oldList, maxPathLen);
2991 printf("Old value of [DY]LD_LIBRARY_PATH: %s\n", oldList);
2993 count = TokenizeWith(oldList, sizeof(oldPaths) / sizeof(char *), oldPaths, pathListSep, false);
2994 for(c = 0; c < count; c++)
2996 if(!libPathExists[oldPaths[c]]) // fstrcmp should be used
2998 newLibPaths.Add(oldPaths[c]);
2999 libPathExists[oldPaths[c]] = true;
3004 for(path : newLibPaths)
3005 len += strlen(path) + 1;
3006 newList = new char[len + 1];
3008 for(path : newLibPaths)
3010 strcat(newList, path);
3011 strcat(newList, pathListSep);
3013 newList[len - 1] = '\0';
3014 #if defined(__APPLE__)
3015 SetEnvironment("DYLD_LIBRARY_PATH", newList);
3017 SetEnvironment("LD_LIBRARY_PATH", newList);
3020 printf("New value of [DY]LD_LIBRARY_PATH: %s\n", newList);
3025 delete libPathExists;
3028 if(compiler.distccEnabled && compiler.distccHosts)
3029 SetEnvironment("DISTCC_HOSTS", compiler.distccHosts);
3034 void DestroyTemporaryProjectDir()
3036 if(tmpPrjDir && tmpPrjDir[0])
3038 if(FileExists(tmpPrjDir).isDirectory)
3039 DestroyDir(tmpPrjDir);
3040 property::tmpPrjDir = null;
3046 // Graphics Driver Menu
3050 app.currentSkin.selectionColor = selectionColor;
3051 app.currentSkin.selectionText = selectionText;
3055 driverItems = new MenuItem[app.numDrivers];
3056 for(c = 0; c < app.numDrivers; c++)
3058 driverItems[c] = MenuItem { driversMenu, app.drivers[c], NotifySelect = NotifySelectDisplayDriver };
3059 driverItems[c].id = c;
3060 driverItems[c].isRadio = true;
3063 driverItems = new MenuItem[2];
3064 #if defined(__unix__)
3065 driverItems[0] = MenuItem { driversMenu, "X", NotifySelect = NotifySelectDisplayDriver };
3066 driverItems[0].id = 0;
3067 driverItems[0].isRadio = true;
3069 driverItems[0] = MenuItem { driversMenu, "GDI", NotifySelect = NotifySelectDisplayDriver };
3070 driverItems[0].id = 0;
3071 driverItems[0].isRadio = true;
3073 driverItems[1] = MenuItem { driversMenu, "OpenGL", NotifySelect = NotifySelectDisplayDriver };
3074 driverItems[1].id = 1;
3075 driverItems[1].isRadio = true;
3077 /* skinItems = new MenuItem[app.numSkins];
3078 for(c = 0; c < app.numSkins; c++)
3080 skinItems[c] = MenuItem {skinsMenu, app.skins[c], NotifySelect = NotifySelectDisplaySkin };
3081 skinItems[c].id = c;
3082 skinItems[c].isRadio = true;
3085 ideFileDialog.master = this;
3086 ideProjectFileDialog.master = this;
3088 //SetDriverAndSkin();
3092 void UpdateRecentMenus()
3095 Menu fileMenu = menu.FindMenu($"File");
3096 Menu recentFiles = fileMenu.FindMenu($"Recent Files");
3097 Menu recentProjects = fileMenu.FindMenu($"Recent Projects");
3098 char itemName[MAX_LOCATION + 4];
3101 recentFiles.Clear();
3104 for(recent : ideSettings.recentFiles)
3106 sprintf(itemName, "%d %s", 1 + c, recent);
3107 MakeSystemPath(itemName);
3108 recentFiles.AddDynamic(MenuItem { copyText = true, text = itemName, (Key)k1 + c, id = c, NotifySelect = ide.FileRecentFile }, ide, true);
3112 recentProjects.Clear();
3114 for(recent : ideSettings.recentProjects)
3116 sprintf(itemName, "%d %s", 1 + c, recent);
3117 MakeSystemPath(itemName);
3118 recentProjects.AddDynamic(MenuItem { copyText = true, text = itemName, (Key)k1 + c, id = c, NotifySelect = ide.FileRecentProject }, ide, true);
3131 void DestroyDir(char * path)
3133 RecursiveDeleteFolderFSI fsi { };
3138 class RecursiveDeleteFolderFSI : NormalFileSystemIterator
3140 bool preserveRootFolder;
3142 void OutFolder(char * folderPath, bool isRoot)
3144 if(!(preserveRootFolder && isRoot))
3145 RemoveDir(folderPath);
3148 bool OnFile(char * filePath)
3150 DeleteFile(filePath);
3155 class IDEApp : GuiApplication
3157 //driver = "Win32Console";
3158 // driver = "OpenGL";
3162 TempFile includeFile { };
3166 SetLoggingMode(stdOut, null);
3167 //SetLoggingMode(debug, null);
3169 settingsContainer.Load();
3170 #if defined(__unix__) || defined(__APPLE__)
3171 app.driver = (ideSettings.displayDriver && !strcmp(ideSettings.displayDriver, "OpenGL")) ? ideSettings.displayDriver : "X";
3173 app.driver = (ideSettings.displayDriver && !strcmp(ideSettings.displayDriver, "OpenGL")) ? ideSettings.displayDriver : "GDI";
3175 ide.driverItems[ideSettings.displayDriver && !strcmp(ideSettings.displayDriver,"OpenGL")].checked = true;
3179 desktop.text = titleECEREIDE;
3182 for(c = 1; c<app.argc; c++)
3184 char fullPath[MAX_LOCATION];
3185 GetWorkingDir(fullPath, MAX_LOCATION);
3186 PathCat(fullPath, app.argv[c]);
3187 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, null, yes, normal);
3191 if(!LoadIncludeFile())
3192 PrintLn("error: unable to load :crossplatform.mk file inside ide binary.");
3197 bool LoadIncludeFile()
3199 bool result = false;
3200 File include = FileOpen(":crossplatform.mk", read);
3203 File f = includeFile;
3206 for(; !include.Eof(); )
3209 int count = include.Read(buffer, 1, 4096);
3210 f.Write(buffer, 1, count);
3220 IDEMainFrame ideMainFrame { };
3222 define app = ((IDEApp)__thisModule);
3224 define titleECEREIDE = $"ECERE IDE (Debug)";
3226 define titleECEREIDE = $"ECERE IDE";