2 public import static "ecere"
3 public import static "ec"
9 import "GlobalSettingsDialog"
10 import "NewProjectDialog"
11 import "FindInFilesDialog"
18 import "ProjectConfig"
20 import "NodeProperties"
21 import "ProjectSettings"
33 import "BreakpointsView"
34 import "CallStackView"
45 import "FileSystemIterator"
47 #if defined(__WIN32__)
48 define pathListSep = ";";
50 define pathListSep = ":";
53 define maxPathLen = 65 * MAX_LOCATION;
55 class PathBackup : struct
62 oldPath = new char[maxPathLen];
63 oldLDPath = new char[maxPathLen];
65 GetEnvironment("PATH", oldPath, maxPathLen);
66 #if defined(__APPLE__)
67 GetEnvironment("DYLD_LIBRARY_PATH", oldLDPath, maxPathLen);
69 GetEnvironment("LD_LIBRARY_PATH", oldLDPath, maxPathLen);
75 SetEnvironment("PATH", oldPath);
76 #if defined(__APPLE__)
77 SetEnvironment("DYLD_LIBRARY_PATH", oldLDPath);
79 SetEnvironment("LD_LIBRARY_PATH", oldLDPath);
86 enum OpenCreateIfFails { no, yes, something, whatever };
87 enum OpenMethod { normal, add };
89 static Array<FileFilter> fileFilters
91 { $"C/C++/eC Files (*.ec, *.eh, *.c, *.cpp, *.cc, *.cxx, *.h, *.hpp, *.hh, *.hxx)", "ec, eh, c, cpp, cc, cxx, h, hpp, hh, hxx" },
92 { $"Header Files for eC/C/C++ (*.eh, *.h, *.hpp, *.hh, *.hxx)", "eh, h, hpp, hh, hxx" },
93 { $"C/C++/eC Source Files (*.ec, *.c, *.cpp, *.cc, *.cxx)", "ec, c, cpp, cc, cxx" },
94 { $"Text files (*.txt, *.text, *.nfo, *.info)", "txt, text, nfo, info" },
95 { $"Web files (*.html, *.htm, *.xhtml, *.css, *.php, *.js, *.jsi, *.rb, *.xml)", "html, htm, xhtml, css, php, js, jsi, rb, xml" },
96 { $"Image Files (*.jpg, *.jpeg, *.bmp, *.pcx, *.png, *.gif)", "jpg, jpeg, bmp, pcx, png, gif" },
97 { $"3D Studio Model Files (*.3ds)", "3ds" },
98 { $"All files", null }
101 static Array<FileType> fileTypes
103 { $"Based on extension", null },
106 { $"3D Studio Model", "3ds" }
109 static Array<FileFilter> projectFilters
111 { $"Project Files (*.epj)", ProjectExtension }
114 static Array<FileType> projectTypes
116 { $"Project File", ProjectExtension }
119 static Array<FileFilter> findInFilesFileFilters
121 { $"eC Files (*.ec, *.eh)", "ec, eh" },
122 { $"C/C++/eC Files (*.ec, *.eh, *.c, *.cpp, *.cc, *.cxx, *.h, *.hpp, *.hh, *.hxx)", "ec, eh, c, cpp, cc, cxx, h, hpp, hh, hxx" },
123 { $"Header Files for eC/C/C++ (*.eh, *.h, *.hpp, *.hh, *.hxx)", "eh, h, hpp, hh, hxx" },
124 { $"C/C++/eC Source Files (*.ec, *.c, *.cpp, *.cc, *.cxx)", "ec, c, cpp, cc, cxx" },
125 { $"Text files (*.txt)", "txt" },
126 { $"All files", null }
129 FileDialog ideFileDialog
131 type = multiOpen, text = $"Open";
132 types = fileTypes.array, sizeTypes = fileTypes.count * sizeof(FileType), filters = fileFilters.array, sizeFilters = fileFilters.count * sizeof(FileFilter);
135 define openProjectFileDialogTitle = $"Open Project";
136 define addProjectFileDialogTitle = $"Open Additional Project";
137 FileDialog ideProjectFileDialog
140 types = projectTypes.array, sizeTypes = projectTypes.count * sizeof(FileType), filters = projectFilters.array, sizeFilters = projectFilters.count * sizeof(FileFilter);
143 GlobalSettingsDialog globalSettingsDialog
145 ideSettings = ideSettings;
146 settingsContainer = settingsContainer;
148 void OnGlobalSettingChange(GlobalSettingsChange globalSettingsChange)
150 switch(globalSettingsChange)
155 for(child = ide.firstChild; child; child = child.next)
157 if(child._class == class(CodeEditor))
159 CodeEditor codeEditor = (CodeEditor) child;
160 codeEditor.editBox.freeCaret = ideSettings.useFreeCaret;
161 // codeEditor.editBox.lineNumbers = ideSettings.showLineNumbers;
162 codeEditor.editBox.caretFollowsScrolling = ideSettings.caretFollowsScrolling;
163 codeEditor.OnPostCreate(); // Update editBox margin size
170 case compilerSettings:
172 ide.UpdateCompilerConfigs(true);
179 void DrawLineMarginIcon(Surface surface, BitmapResource resource, int line, int lineH, int scrollY, int boxH)
184 lineY = (line - 1) * lineH;
185 if(lineY + lineH > scrollY && lineY + lineH < scrollY + boxH)
187 Bitmap bitmap = resource.bitmap;
189 surface.Blit(bitmap, 0, lineY - scrollY + (lineH - bitmap.height) / 2 + 1, 0, 0, bitmap.width, bitmap.height);
194 #define IDEItem(x) (&((IDEWorkSpace)0).x)
196 class IDEToolbar : ToolBar
200 ToolButton buttonNewFile { this, toolTip = $"New file", menuItemPtr = IDEItem(fileNewItem) };
202 ToolButton buttonOpenFile { this, toolTip = $"Open file", menuItemPtr = IDEItem(fileOpenItem) };
204 // ToolButton buttonCloseFile { this, toolTip = $"Close file", menuItemPtr = IDEItem(fileCloseItem) };
206 ToolButton buttonSaveFile { this, toolTip = $"Save file", menuItemPtr = IDEItem(fileSaveItem) };
208 ToolButton buttonSaveAllFile { this, toolTip = $"Save all", menuItemPtr = IDEItem(fileSaveAllItem) };
210 ToolSeparator separator1 { this };
219 // ToolSeparator separator2 { this };
221 /* Project options */
223 ToolButton buttonNewProject { this, toolTip = $"New project", menuItemPtr = IDEItem(projectNewItem) };
225 ToolButton buttonOpenProject { this, toolTip = $"Open project", menuItemPtr = IDEItem(projectOpenItem) };
226 // Add project to workspace
227 ToolButton buttonAddProject { this, toolTip = $"Add project to workspace", menuItemPtr = IDEItem(projectAddItem), disabled = true; };
229 // ToolButton buttonCloseProject { this, toolTip = $"Close project", menuItemPtr = IDEItem(projectCloseItem), disabled = true; };
231 ToolSeparator separator3 { this };
233 /* Build/Execution options */
235 ToolButton buttonBuild { this, toolTip = $"Build project", menuItemPtr = IDEItem(projectBuildItem), disabled = true; };
237 ToolButton buttonReLink { this, toolTip = $"Relink project", menuItemPtr = IDEItem(projectLinkItem), disabled = true; };
239 ToolButton buttonRebuild { this, toolTip = $"Rebuild project", menuItemPtr = IDEItem(projectRebuildItem), disabled = true; };
241 ToolButton buttonClean { this, toolTip = $"Clean project", menuItemPtr = IDEItem(projectCleanItem), disabled = true; };
243 // ToolButton buttonRealClean { this, toolTip = $"Real clean project", menuItemPtr = IDEItem(projectRealCleanItem), disabled = true; };
244 // Regenerate Makefile
245 ToolButton buttonRegenerateMakefile { this, toolTip = $"Regenerate Makefile", menuItemPtr = IDEItem(projectRegenerateItem), disabled = true; };
246 // Compile actual file
248 ToolButton buttonRun { this, toolTip = $"Run", menuItemPtr = IDEItem(projectRunItem), disabled = true; };
250 ToolSeparator separator4 { this };
254 ToolButton buttonDebugStartResume { this, toolTip = $"Start", menuItemPtr = IDEItem(debugStartResumeItem), disabled = true; };
256 ToolButton buttonDebugRestart { this, toolTip = $"Restart", menuItemPtr = IDEItem(debugRestartItem), disabled = true; };
258 ToolButton buttonDebugPause { this, toolTip = $"Break", menuItemPtr = IDEItem(debugBreakItem), disabled = true; };
260 ToolButton buttonDebugStop { this, toolTip = $"Stop", menuItemPtr = IDEItem(debugStopItem), disabled = true; };
262 //ToolButton buttonRun { this, toolTip = $"Run", menuItemPtr = IDEItem(projectRunItem) };
264 ToolButton buttonDebugStepInto { this, toolTip = $"Step Into", menuItemPtr = IDEItem(debugStepIntoItem), disabled = true; };
266 ToolButton buttonDebugStepOver { this, toolTip = $"Step Over", menuItemPtr = IDEItem(debugStepOverItem), disabled = true; };
268 ToolButton buttonDebugStepOut { this, toolTip = $"Step Out", menuItemPtr = IDEItem(debugStepOutItem), disabled = true; };
270 ToolButton buttonDebugSkipStepOver { this, toolTip = $"Step Over Skipping Breakpoints", menuItemPtr = IDEItem(debugSkipStepOverItem), disabled = true; };
272 ToolSeparator separator5 { this };
274 Window spacer5 { this, size = { 4 } };
278 this, toolTip = $"Active Configuration(s)", size = { 160 }, disabled = true;
279 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
283 for(prj : ide.workspace.projects)
285 for(cfg : prj.configurations)
287 if(cfg.name && !strcmp(cfg.name, row.string))
294 ide.UpdateToolBarActiveConfigs(true);
295 ide.projectView.Update(null);
301 Window spacer6 { this, size = { 4 } };
303 DropBox activeCompiler
305 this, toolTip = $"Active Compiler", size = { 160 }, disabled = true;
306 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
308 if(ide.workspace && ide.projectView && row && strcmp(row.string, ide.workspace.compiler))
310 bool silent = ide.projectView.buildInProgress == none ? false : true;
311 CompilerConfig compiler = ideSettings.GetCompilerConfig(row.string);
312 ide.workspace.compiler = row.string;
313 ide.projectView.ShowOutputBuildLog(!silent);
315 ide.projectView.DisplayCompiler(compiler, false);
316 for(prj : ide.workspace.projects)
317 ide.projectView.ProjectPrepareCompiler(prj, compiler, silent);
319 ide.workspace.Save();
325 DropBox activeBitDepth
327 this, toolTip = $"Active Bit Depth", size = { 60 }, disabled = true;
328 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
330 if(ide.workspace && ide.projectView && row)
332 bool silent = ide.projectView.buildInProgress == none ? false : true;
333 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
334 ide.workspace.bitDepth = (int)row.tag;
335 ide.projectView.ShowOutputBuildLog(!silent);
337 ide.projectView.DisplayCompiler(compiler, false);
338 for(prj : ide.workspace.projects)
339 ide.projectView.ProjectPrepareCompiler(prj, compiler, silent);
341 ide.workspace.Save();
347 Window spacer7 { this, size = { 4 } };
352 row = activeBitDepth.AddString("Auto");
354 activeBitDepth.AddString("32 bit").tag = 32;
355 activeBitDepth.AddString("64 bit").tag = 64;
356 activeBitDepth.currentRow = row;
361 class IDEMainFrame : Window
363 background = formColor;
364 borderStyle = sizable;
368 minClientSize = { 600, 300 };
370 icon = { ":icon.png" };
371 text = titleECEREIDE;
375 anchor = { top = 0, right = 0, bottom = 0 };
378 anchor = { left = 0, top = 0, right = 0, bottom = 0 };
385 isActiveClient = true;
387 direction = vertical;
388 background = formColor;
389 anchor = { left = 0, top = 0, right = 0, bottom = 0 };
397 ((IDEWorkSpace)master).toolBar = null;
400 IDEWorkSpace ideWorkSpace { stack, this, toolBar = toolBar };
403 define ide = ideMainFrame.ideWorkSpace;
405 class IDEWorkSpace : Window
407 background = Color { 85, 85, 85 };
410 hasVertScroll = true;
411 hasHorzScroll = true;
413 isActiveClient = true;
414 anchor = { left = 0, top = 0, right = 0, bottom = 0 };
418 MenuItem * driverItems, * skinItems;
419 StatusField pos { width = 150 };
420 StatusField ovr, caps, num;
422 BitmapResource back { ":ecereBack.jpg", window = this };
423 BitmapResource bmpBp { ":codeMarks/breakpoint.png", window = this };
424 BitmapResource bmpBpDisabled { ":codeMarks/breakpointDisabled.png", window = this };
425 BitmapResource bmpBpHalf { ":codeMarks/breakpointHalf.png", window = this };
426 BitmapResource bmpBpHalfDisabled { ":codeMarks/breakpointHalfDisabled.png", window = this };
427 BitmapResource bmpCursor { ":codeMarks/cursor.png", window = this };
428 BitmapResource bmpCursorError { ":codeMarks/cursorError.png", window = this };
429 BitmapResource bmpTopFrame { ":codeMarks/topFrame.png", window = this };
430 BitmapResource bmpTopFrameError { ":codeMarks/topFrameError.png", window = this };
431 BitmapResource bmpTopFrameHalf { ":codeMarks/topFrameHalf.png", window = this };
432 BitmapResource bmpTopFrameHalfError { ":codeMarks/topFrameHalfError.png", window = this };
434 Debugger debugger { };
436 ProjectView projectView;
438 OutputView outputView
442 void OnGotoError(char * line, bool noParsing)
444 ide.GoToError(line, noParsing);
447 void OnCodeLocationParseAndGoTo(char * line)
449 ide.CodeLocationParseAndGoTo(line, ide.findInFilesDialog.findProject, ide.findInFilesDialog.findDir);
452 bool OnKeyDown(Key key, unichar ch)
457 if(activeBox != findBox || !ide.findInFilesDialog || !ide.findInFilesDialog.SearchAbort())
458 ide.ShowCodeEditor();
462 OutputView::OnKeyDown(key, ch);
469 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
472 ide.RepositionWindows(false);
476 bool OnClose(bool parentClosing)
480 ide.RepositionWindows(false);
481 return parentClosing;
485 CallStackView callStackView
487 parent = this, font = { panelFont.faceName, panelFont.size };
489 void 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, mods.ctrl && mods.shift))
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)
803 char extension[MAX_EXTENSION] = "";
804 GetExtension(file, extension);
805 isProjectFile = (!strcmpi(extension, "epj") || !strcmpi(extension, "ews"));
808 char * command = PrintString("ide ", isProjectFile ? "-t " : "", file);
813 OpenFile(file, normal, true, isProjectFile ? "txt" : null, no, normal, mods.ctrl && mods.shift);
821 bool FileRecentProject(MenuItem selection, Modifiers mods)
824 for(file : ideSettings.recentProjects)
826 if(id == selection.id)
830 char * command = PrintString("ide ", file);
835 OpenFile(file, normal, true, null, no, normal, mods.ctrl && mods.shift);
843 MenuPlacement editMenu { menu, $"Edit", e };
845 Menu projectMenu { menu, $"Menu"."Project", p, hasMargin = true };
846 MenuItem projectNewItem
848 projectMenu, $"New...", n, Key { n, true, true };
849 bitmap = { ":actions/projNew.png" };
850 bool NotifySelect(MenuItem selection, Modifiers mods)
852 if(!DontTerminateDebugSession($"New Project"))
855 NewProjectDialog newProjectDialog { master = this };
856 result = newProjectDialog.Modal();
861 newProjectDialog.CreateNewProject();
864 ideSettings.AddRecentProject(projectView.fileName);
865 ide.UpdateRecentMenus();
866 settingsContainer.Save();
874 MenuItem projectOpenItem
876 projectMenu, $"Open...", o, Key { o, true, true };
877 bitmap = { ":actions/projOpen.png" };
878 bool NotifySelect(MenuItem selection, Modifiers mods)
880 if(ideSettings.ideProjectFileDialogLocation)
881 ideProjectFileDialog.currentDirectory = ideSettings.ideProjectFileDialogLocation;
883 ideProjectFileDialog.text = openProjectFileDialogTitle;
884 if(ideProjectFileDialog.Modal() == ok)
886 OpenFile(ideProjectFileDialog.filePath, normal, true, projectTypes[ideProjectFileDialog.fileType].typeExtension, no, normal, mods.ctrl && mods.shift);
887 //ChangeProjectFileDialogDirectory(ideProjectFileDialog.currentDirectory);
892 MenuItem projectQuickItem
894 projectMenu, $"Quick...", q, f7, disabled = true;
895 bool NotifySelect(MenuItem selection, Modifiers mods)
898 QuickProjectDialog { this }.Modal();
902 MenuItem projectAddItem
904 projectMenu, $"Add project to workspace...", a, Key { a, true, true };
905 bitmap = { ":actions/projAdd.png" };
907 bool NotifySelect(MenuItem selection, Modifiers mods)
909 if(ideSettings.ideProjectFileDialogLocation)
910 ideProjectFileDialog.currentDirectory = ideSettings.ideProjectFileDialogLocation;
912 ideProjectFileDialog.text = addProjectFileDialogTitle;
915 if(ideProjectFileDialog.Modal() == ok)
917 if(OpenFile(ideProjectFileDialog.filePath, normal, true, projectTypes[ideProjectFileDialog.fileType].typeExtension, no, add, mods.ctrl && mods.shift))
919 if(MessageBox { type = yesNo, master = this, text = $"Error opening project file",
920 contents = $"Add a different project?" }.Modal() == no)
931 MenuItem projectCloseItem
933 projectMenu, $"Close", c, disabled = true;
934 bool NotifySelect(MenuItem selection, Modifiers mods)
938 if(!ide.DontTerminateDebugSession($"Project Close"))
944 MenuDivider { projectMenu };
945 MenuItem projectSettingsItem
947 projectMenu, $"Settings...", s, altF7, disabled = true;
948 bool NotifySelect(MenuItem selection, Modifiers mods)
950 projectView.MenuSettings(projectView.active ? selection : null, mods);
954 MenuDivider { projectMenu };
955 MenuItem projectBrowseFolderItem
957 projectMenu, $"Browse Project Folder", p, disabled = true;
958 bool NotifySelect(MenuItem selection, Modifiers mods)
961 projectView.MenuBrowseFolder(null, mods);
965 MenuDivider { projectMenu };
966 MenuItem projectRunItem
968 projectMenu, $"Run", r, ctrlF5, disabled = true;
969 bitmap = { ":actions/run.png" };
970 bool NotifySelect(MenuItem selection, Modifiers mods)
973 projectView.Run(null, mods);
977 MenuItem projectBuildItem
979 projectMenu, $"Build", b, f7, disabled = true;
980 bitmap = { ":actions/build.png" };
981 bool NotifySelect(MenuItem selection, Modifiers mods)
985 if(projectView.buildInProgress == none)
986 projectView.ProjectBuild(projectView.active ? selection : null, mods);
988 projectView.stopBuild = true;
993 MenuItem projectLinkItem
995 projectMenu, $"Relink", l, disabled = true;
996 bitmap = { ":actions/relink.png" };
997 bool NotifySelect(MenuItem selection, Modifiers mods)
1000 projectView.ProjectLink(projectView.active ? selection : null, mods);
1004 MenuItem projectRebuildItem
1006 projectMenu, $"Rebuild", d, shiftF7, disabled = true;
1007 bitmap = { ":actions/rebuild.png" };
1008 bool NotifySelect(MenuItem selection, Modifiers mods)
1011 projectView.ProjectRebuild(projectView.active ? selection : null, mods);
1015 MenuItem projectCleanTargetItem
1017 projectMenu, $"Clean Target", g, disabled = true;
1018 bitmap = { ":actions/clean.png" };
1019 bool NotifySelect(MenuItem selection, Modifiers mods)
1024 projectView.ProjectCleanTarget(projectView.active ? selection : null, mods);
1029 MenuItem projectCleanItem
1031 projectMenu, $"Clean", e, disabled = true;
1032 bitmap = { ":actions/clean.png" };
1033 bool NotifySelect(MenuItem selection, Modifiers mods)
1038 projectView.ProjectClean(projectView.active ? selection : null, mods);
1043 MenuItem projectRealCleanItem
1045 projectMenu, $"Real Clean", disabled = true;
1046 bitmap = { ":actions/clean.png" };
1047 bool NotifySelect(MenuItem selection, Modifiers mods)
1052 projectView.ProjectRealClean(projectView.active ? selection : null, mods);
1057 MenuItem projectRegenerateItem
1059 projectMenu, $"Regenerate Makefile", m, disabled = true;
1060 bitmap = { ":actions/regMakefile.png" };
1061 bool NotifySelect(MenuItem selection, Modifiers mods)
1064 projectView.ProjectRegenerate(projectView.active ? selection : null, mods);
1068 MenuItem projectCompileItem;
1069 Menu debugMenu { menu, $"Debug", d, hasMargin = true };
1070 MenuItem debugStartResumeItem
1072 debugMenu, $"Start", s, f5, disabled = true;
1073 bitmap = { ":actions/debug.png" };
1074 NotifySelect = MenuDebugStart;
1076 bool MenuDebugStart(MenuItem selection, Modifiers mods)
1080 debugStartResumeItem.disabled = true; // a very rare exception to calling AdjustDebugMenus
1081 if(!projectView.DebugStart())
1082 debugStartResumeItem.disabled = false; // same exception
1086 bool MenuDebugResume(MenuItem selection, Modifiers mods)
1089 projectView.DebugResume();
1092 MenuItem debugRestartItem
1094 debugMenu, $"Restart", r, Key { f5, ctrl = true, shift = true }, disabled = true;
1095 bitmap = { ":actions/restart.png" };
1096 bool NotifySelect(MenuItem selection, Modifiers mods)
1099 projectView.DebugRestart();
1103 MenuItem debugBreakItem
1105 debugMenu, $"Break", b, Key { pauseBreak, ctrl = true }, disabled = true;
1106 bitmap = { ":actions/pause.png" };
1107 bool NotifySelect(MenuItem selection, Modifiers mods)
1109 if(projectView && projectView.buildInProgress != none)
1112 projectView.DebugBreak();
1116 MenuItem debugStopItem
1118 debugMenu, $"Stop", p, shiftF5, disabled = true;
1119 bitmap = { ":actions/stopDebug.png" };
1120 bool NotifySelect(MenuItem selection, Modifiers mods)
1123 projectView.DebugStop();
1127 MenuDivider { debugMenu };
1128 MenuItem debugStepIntoItem
1130 debugMenu, $"Step Into", i, f11, disabled = true;
1131 bitmap = { ":actions/stepInto.png" };
1132 bool NotifySelect(MenuItem selection, Modifiers mods)
1135 projectView.DebugStepInto();
1139 MenuItem debugStepOverItem
1141 debugMenu, $"Step Over", v, f10, disabled = true;
1142 bitmap = { ":actions/stepOver.png" };
1143 bool NotifySelect(MenuItem selection, Modifiers mods)
1146 projectView.DebugStepOver(false);
1150 MenuItem debugStepOutItem
1152 debugMenu, $"Step Out", o, shiftF11, disabled = true;
1153 bitmap = { ":actions/stepOut.png" };
1154 bool NotifySelect(MenuItem selection, Modifiers mods)
1157 projectView.DebugStepOut(false);
1161 MenuPlacement debugRunToCursorItem { debugMenu, $"Run To Cursor", c };
1162 MenuItem debugSkipStepOverItem
1164 debugMenu, $"Step Over Skipping Breakpoints", e, shiftF10, disabled = true;
1165 bool NotifySelect(MenuItem selection, Modifiers mods)
1168 projectView.DebugStepOver(true);
1172 MenuItem debugSkipStepOutItem
1174 debugMenu, $"Step Out Skipping Breakpoints", t, Key { f11, ctrl = true, shift = true }, disabled = true;
1175 bitmap = { ":actions/skipBreaks.png" };
1176 bool NotifySelect(MenuItem selection, Modifiers mods)
1179 projectView.DebugStepOut(true);
1183 MenuPlacement debugSkipRunToCursorItem { debugMenu, $"Run To Cursor Skipping Breakpoints", u };
1184 MenuPlacement debugSkipRunToCursorAtSameLevelItem { debugMenu, $"Run To Cursor At Same Level Skipping Breakpoints", s };
1185 //MenuDivider { debugMenu };
1186 //MenuPlacement debugToggleBreakpoint { debugMenu, "Toggle Breakpoint", t };
1187 MenuPlacement imageMenu { menu, $"Image", i };
1188 Menu viewMenu { menu, $"View", v };
1189 MenuItem viewProjectItem
1191 viewMenu, $"Project View", j, alt0, disabled = true;
1192 bool NotifySelect(MenuItem selection, Modifiers mods)
1196 projectView.visible = true;
1197 projectView.Activate();
1202 MenuPlacement { viewMenu, $"View Designer" };
1203 MenuPlacement { viewMenu, $"View Code" };
1204 MenuPlacement { viewMenu, $"View Properties" };
1205 MenuPlacement { viewMenu, $"View Methods" };
1206 MenuItem viewDesignerItem
1208 viewMenu, $"View Designer", d, f8;
1209 bool NotifySelect(MenuItem selection, Modifiers mods)
1211 Window client = activeClient;
1212 Class dataType = client._class;
1213 if(!strcmp(dataType.name, "Designer"))
1215 client.visible = true;
1219 ((CodeEditor)client).ViewDesigner();
1223 MenuItem viewCodeItem
1225 viewMenu, $"View Code", c, f8;
1226 bool NotifySelect(MenuItem selection, Modifiers mods)
1228 Window client = activeClient;
1229 Class dataType = client._class;
1230 if(!strcmp(dataType.name, "Designer"))
1231 client = ((Designer)client).codeEditor;
1234 // Do this after so the caret isn't moved yet...
1235 client.visible = true;
1239 MenuItem viewPropertiesItem
1241 viewMenu, $"View Properties", p, f4;
1242 bool NotifySelect(MenuItem selection, Modifiers mods)
1244 sheet.visible = true;
1245 sheet.sheetSelected = properties;
1250 MenuItem viewMethodsItem
1252 viewMenu, $"View Methods", m, f4;
1253 bool NotifySelect(MenuItem selection, Modifiers mods)
1255 sheet.visible = true;
1256 sheet.sheetSelected = methods;
1261 MenuItem viewToolBoxItem
1263 viewMenu, $"View Toolbox", x, f12;
1264 bool NotifySelect(MenuItem selection, Modifiers mods)
1266 toolBox.visible = true;
1271 MenuItem viewOutputItem
1273 viewMenu, $"Output", o, alt2;
1274 bool NotifySelect(MenuItem selection, Modifiers mods)
1280 MenuItem viewWatchesItem
1282 viewMenu, $"Watches", w, alt3;
1283 bool NotifySelect(MenuItem selection, Modifiers mods)
1289 MenuItem viewThreadsItem
1291 viewMenu, $"Threads", t, alt4;
1292 bool NotifySelect(MenuItem selection, Modifiers mods)
1298 MenuItem viewBreakpointsItem
1300 viewMenu, $"Breakpoints", b, alt5;
1301 bool NotifySelect(MenuItem selection, Modifiers mods)
1303 breakpointsView.Show();
1307 MenuItem viewCallStackItem
1309 viewMenu, $"Call Stack", s, alt7;
1310 bool NotifySelect(MenuItem selection, Modifiers mods)
1312 callStackView.Show();
1316 MenuItem viewAllDebugViews
1318 viewMenu, $"All Debug Views", a, alt9;
1319 bool NotifySelect(MenuItem selection, Modifiers mods)
1324 callStackView.Show();
1325 breakpointsView.Show();
1329 #ifdef GDB_DEBUG_GUI
1330 MenuDivider { viewMenu };
1331 MenuItem viewGDBItem
1333 viewMenu, $"GDB Dialog", g, Key { f9, shift = true, ctrl = true };
1334 bool NotifySelect(MenuItem selection, Modifiers mods)
1341 MenuDivider { viewMenu };
1342 MenuItem viewColorPicker
1344 viewMenu, $"Color Picker...", c, Key { c, ctrl = true , shift = true };
1345 bool NotifySelect(MenuItem selection, Modifiers mods)
1347 ColorPicker colorPicker { master = this };
1348 colorPicker.Modal();
1352 MenuDivider { viewMenu };
1356 viewMenu, "Full Screen", f, checkable = true;
1358 bool NotifySelect(MenuItem selection, Modifiers mods)
1360 app.fullScreen ^= true;
1362 anchor = { 0, 0, 0, 0 };
1367 Menu driversMenu { viewMenu, $"Graphics Driver", v };
1368 //Menu skinsMenu { viewMenu, "GUI Skins", k };
1369 Menu windowMenu { menu, $"Window", w };
1370 MenuItem { windowMenu, $"Close All", l, NotifySelect = MenuWindowCloseAll };
1371 MenuDivider { windowMenu };
1372 MenuItem { windowMenu, $"Next", n, f6, NotifySelect = MenuWindowNext };
1373 MenuItem { windowMenu, $"Previous", p, shiftF6, NotifySelect = MenuWindowPrevious };
1374 MenuDivider { windowMenu };
1375 MenuItem { windowMenu, $"Cascade", c, NotifySelect = MenuWindowCascade };
1376 MenuItem { windowMenu, $"Tile Horizontally", h, NotifySelect = MenuWindowTileHorz };
1377 MenuItem { windowMenu, $"Tile Vertically", v, NotifySelect = MenuWindowTileVert };
1378 MenuItem { windowMenu, $"Arrange Icons", a, NotifySelect = MenuWindowArrangeIcons };
1379 MenuDivider { windowMenu };
1380 MenuItem { windowMenu, $"Windows...", w, NotifySelect = MenuWindowWindows };
1381 Menu helpMenu { menu, $"Help", h };
1384 helpMenu, $"API Reference", r, f1;
1385 bool NotifySelect(MenuItem selection, Modifiers mods)
1387 char * p = new char[MAX_LOCATION];
1389 strncpy(p, settingsContainer.moduleLocation, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
1390 PathCat(p, "documentor");
1391 #if defined(__WIN32__)
1392 ChangeExtension(p, "exe", p);
1394 if(FileExists(p).isFile)
1397 Execute("documentor");
1402 MenuDivider { helpMenu };
1405 helpMenu, $"Ecere Tao of Programming [work in progress]", t;
1406 bool NotifySelect(MenuItem selection, Modifiers mods)
1408 FindAndShellOpenInstalledFile("doc", "Ecere Tao of Programming [work in progress].pdf");
1412 MenuDivider { helpMenu };
1415 helpMenu, $"Documentation Folder", d;
1416 bool NotifySelect(MenuItem selection, Modifiers mods)
1418 FindAndShellOpenInstalledFolder("doc");
1424 helpMenu, $"Samples Folder", s;
1425 bool NotifySelect(MenuItem selection, Modifiers mods)
1427 FindAndShellOpenInstalledFolder("samples");
1433 helpMenu, $"Extras Folder", x;
1434 bool NotifySelect(MenuItem selection, Modifiers mods)
1436 FindAndShellOpenInstalledFolder("extras");
1440 MenuDivider { helpMenu };
1443 helpMenu, $"Community Forums", f;
1444 bool NotifySelect(MenuItem selection, Modifiers mods)
1446 ShellOpen("http://ecere.com/forums");
1450 MenuDivider { helpMenu };
1453 helpMenu, $"About...", a;
1454 bool NotifySelect(MenuItem selection, Modifiers mods)
1456 AboutIDE { master = this }.Modal();
1461 property ToolBox toolBox
1463 get { return toolBox; }
1466 property Sheet sheet
1468 get { return sheet; }
1471 property Project project
1473 get { return projectView ? projectView.project : null; }
1476 property Workspace workspace
1478 get { return projectView ? projectView.workspace : null; }
1481 FindInFilesDialog findInFilesDialog
1484 filters = findInFilesFileFilters.array, sizeFilters = findInFilesFileFilters.count * sizeof(FileFilter);
1490 #ifdef GDB_DEBUG_GUI
1493 master = this, parent = this;
1494 anchor = { left = 100, top = 100, right = 100, bottom = 100 };
1496 void OnCommand(char * string)
1499 ide.debugger.SendGDBCommand(string);
1504 bool NotifySelectDisplayDriver(MenuItem selection, Modifiers mods)
1506 //app.driver = app.drivers[selection.id];
1507 #if defined(__unix__) || defined(__APPLE__)
1508 app.driver = selection.id ? "OpenGL" : "X";
1510 app.driver = selection.id ? "OpenGL" : "GDI";
1512 delete ideSettings.displayDriver;
1513 ideSettings.displayDriver = CopyString(selection.id ? "OpenGL" : "Default");
1515 settingsContainer.Save();
1516 //SetDriverAndSkin();
1520 bool NotifySelectDisplaySkin(MenuItem selection, Modifiers mods)
1522 app.skin = app.skins[selection.id];
1527 void SetDriverAndSkin()
1530 for(c = 0; c < app.numSkins; c++)
1531 if(!strcmp(app.skins[c], app.skin))
1533 skinItems[c].checked = true;
1536 for(c = 0; c < app.numDrivers; c++)
1537 if(!strcmp(app.drivers[c], app.driver))
1539 driverItems[c].checked = true;
1544 ProjectView CreateProjectView(Workspace workspace, char * fileName)
1546 Project project = workspace.projects.firstIterator.data;
1547 projectView = ProjectView
1550 fileName = fileName;
1552 void NotifyDestroyed(Window window, DialogResult result)
1555 text = titleECEREIDE;
1560 projectView.Create();
1561 RepositionWindows(false);
1563 // Leave it after Create to avoid flicker due to seeing IDE without a project view
1564 projectView.workspace = workspace;
1565 projectView.project = project;
1566 ideMainFrame.SetText("%s - %s", project.topNode.name, titleECEREIDE);
1570 ide.breakpointsView.LoadFromWorkspace();
1571 ide.watchesView.LoadFromWorkspace();
1573 findInFilesDialog.projectNodeField.userData = projectView;
1576 char fileName[MAX_LOCATION];
1577 strcpy(fileName, project.topNode.path);
1578 PathCat(fileName, project.topNode.name);
1585 projectView.visible = false;
1586 if((!projectView || projectView.created == false || projectView.Destroy(0)) && MenuWindowCloseAll(null, 0))
1588 if(findInFilesDialog)
1590 char workingDir[MAX_LOCATION];
1591 GetWorkingDir(workingDir, MAX_LOCATION);
1592 findInFilesDialog.SearchStop();
1593 findInFilesDialog.currentDirectory = workingDir;
1595 ideMainFrame.text = titleECEREIDE;
1602 void RepositionWindows(bool expand)
1607 bool inDebugMode = debugger.isActive;
1608 bool callStackVisible = expand ? false : callStackView.visible;
1609 bool threadsVisible = expand ? false : threadsView.visible;
1610 bool watchesVisible = expand ? false : watchesView.visible;
1611 bool breakpointsVisible = expand ? false : breakpointsView.visible;
1612 bool toolBoxVisible = toolBox.visible;
1613 bool outputVisible = expand ? false : outputView.visible;
1614 int topDistance = (callStackVisible || threadsVisible) ? 200 : 0;
1615 int bottomDistance = (outputVisible || watchesVisible || breakpointsVisible) ? 240 : 0;
1617 for(child = firstChild; child; child = child.next)
1619 if(child._class == class(CodeEditor) || child._class == class(Designer) ||
1620 child._class == class(Sheet) || child._class == class(ProjectView))
1622 Anchor anchor = child.anchor;
1623 anchor.top = topDistance;
1624 anchor.bottom = bottomDistance;
1625 if(child._class == class(CodeEditor) || child._class == class(Designer))
1627 anchor.right = toolBoxVisible ? 150 : 0;
1629 child.anchor = anchor;
1633 if(child._class == class(OutputView) || child._class == class(CallStackView) || child._class == class(ThreadsView) || child._class == class(WatchesView) ||
1634 child._class == class(BreakpointsView))
1635 child.visible = false;
1638 // If this is not here, the IDE is not updated when doing Debug/Break then Alt-4 to show call stack (IDE not updated)
1643 bool ShowCodeEditor()
1646 activeClient.Activate();
1647 else if(projectView)
1649 projectView.visible = true;
1650 projectView.Activate();
1654 sheet.visible = true;
1660 void DocumentSaved(Window document, char * fileName)
1662 ideSettings.AddRecentFile(fileName);
1663 ide.UpdateRecentMenus();
1664 ide.AdjustFileMenus();
1665 settingsContainer.Save();
1668 bool Window::OnFileModified(FileChange fileChange, char * param)
1671 sprintf(temp, $"The document %s was modified by another application.\n"
1672 "Would you like to reload it and lose your changes?", this.fileName);
1673 if(MessageBox { type = yesNo, master = this/*.parent*/,
1674 text = $"Document has been modified", contents = temp }.Modal() == yes)
1676 bool noParsing = (this._class == class(CodeEditor) && ((CodeEditor)this).noParsing) ? true : false;
1677 char * fileName = CopyString(this.fileName);
1678 WindowState state = this.state;
1679 Anchor anchor = this.anchor;
1680 Size size = this.size;
1682 this.modifiedDocument = false;
1684 this = ide.OpenFile(fileName, normal, true, null, no, normal, noParsing);
1687 this.anchor = anchor;
1689 this.SetState(state, true, 0);
1697 void UpdateMakefiles()
1701 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
1702 for(prj : workspace.projects)
1703 projectView.ProjectUpdateMakefileForAllConfigs(prj);
1708 void UpdateCompilerConfigs(bool mute)
1710 UpdateToolBarActiveCompilers();
1713 bool silent = mute || (ide.projectView.buildInProgress == none ? false : true);
1714 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
1717 projectView.ShowOutputBuildLog(true);
1718 projectView.DisplayCompiler(compiler, false);
1720 for(prj : workspace.projects)
1721 projectView.ProjectPrepareCompiler(prj, compiler, silent);
1726 void UpdateToolBarActiveCompilers()
1728 toolBar.activeCompiler.Clear();
1729 for(compiler : ideSettings.compilerConfigs)
1731 DataRow row = toolBar.activeCompiler.AddString(compiler.name);
1732 if(workspace && workspace.compiler && !strcmp(compiler.name, workspace.compiler))
1733 toolBar.activeCompiler.currentRow = row;
1735 if(!toolBar.activeCompiler.currentRow && toolBar.activeCompiler.firstRow)
1736 toolBar.activeCompiler.SelectRow(toolBar.activeCompiler.firstRow);
1739 void UpdateToolBarActiveConfigs(bool selectionOnly)
1741 bool commonSelected = false;
1742 DataRow row = toolBar.activeConfig.currentRow;
1744 row = toolBar.activeConfig.FindRow(1);
1747 toolBar.activeConfig.Clear();
1748 row = toolBar.activeConfig.AddString($"(Mixed)");
1753 char * configName = null;
1756 Map<String, int> configs { }; // TOIMP: just need sort but using map until containers have sort
1757 for(prj : workspace.projects)
1759 for(cfg : prj.configurations)
1762 configs[cfg.name] = 1;
1767 toolBar.activeConfig.AddString(&name);
1771 if(projectView && projectView.project)
1773 for(prj : workspace.projects)
1775 if(prj.config && prj.config.name)
1777 configName = prj.config.name;
1783 commonSelected = true;
1784 for(prj : workspace.projects)
1786 if(prj.config && (!prj.config.name || strcmp(prj.config.name, configName)))
1788 commonSelected = false;
1796 commonSelected = false;
1797 for(row = toolBar.activeConfig.firstRow; row; row = row.next)
1799 if(!strcmp(row.string, configName))
1801 toolBar.activeConfig.currentRow = row;
1802 commonSelected = true;
1809 toolBar.activeConfig.Sort(null, 0);
1811 toolBar.activeConfig.currentRow = row;
1816 bool unavailable = !project;
1818 projectAddItem.disabled = unavailable;
1819 toolBar.buttonAddProject.disabled = unavailable;
1821 projectSettingsItem.disabled = unavailable;
1823 projectBrowseFolderItem.disabled = unavailable;
1825 viewProjectItem.disabled = unavailable;
1827 toolBar.activeConfig.disabled = unavailable;
1828 toolBar.activeCompiler.disabled = unavailable;
1829 toolBar.activeBitDepth.disabled = unavailable;
1836 property bool hasOpenedCodeEditors
1841 for(w = firstChild; w; w = w.next)
1842 if(w._class == class(CodeEditor) &&
1843 w.isDocument && !w.closing && w.visible && w.created &&
1844 w.fileName && w.fileName[0])
1850 void AdjustFileMenus()
1852 bool unavailable = project != null || !hasOpenedCodeEditors; // are they supported source code (ec, c, cpp, etc) ?
1854 projectQuickItem.disabled = unavailable;
1857 void AdjustBuildMenus()
1859 bool unavailable = project && projectView.buildInProgress;
1861 projectNewItem.disabled = unavailable;
1862 toolBar.buttonNewProject.disabled = unavailable;
1863 projectOpenItem.disabled = unavailable;
1864 toolBar.buttonOpenProject.disabled = unavailable;
1866 unavailable = !project || projectView.buildInProgress;
1868 projectCloseItem.disabled = unavailable;
1869 // toolBar.buttonCloseProject.disabled = unavailable;
1871 projectRunItem.disabled = unavailable || project.GetTargetType(project.config) != executable;
1872 toolBar.buttonRun.disabled = unavailable || project.GetTargetType(project.config) != executable;
1874 projectBuildItem.disabled = false;
1875 projectBuildItem.text = unavailable ? $"Stop Build" : $"Build";
1876 projectBuildItem.accelerator = unavailable ? Key { pauseBreak, ctrl = true } : f7;
1878 projectLinkItem.disabled = unavailable;
1879 toolBar.buttonReLink.disabled = unavailable;
1880 projectRebuildItem.disabled = unavailable;
1881 toolBar.buttonRebuild.disabled = unavailable;
1882 projectCleanItem.disabled = unavailable;
1883 toolBar.buttonClean.disabled = unavailable;
1884 projectCleanTargetItem.disabled = unavailable;
1885 projectRealCleanItem.disabled = unavailable;
1886 // toolBar.buttonRealClean.disabled = unavailable;
1887 projectRegenerateItem.disabled = unavailable;
1888 toolBar.buttonRegenerateMakefile.disabled = unavailable;
1889 projectCompileItem.disabled = unavailable;
1891 AdjustPopupBuildMenus();
1894 void AdjustPopupBuildMenus()
1896 bool unavailable = !project || projectView.buildInProgress;
1898 if(projectView && projectView.popupMenu && projectView.popupMenu.menu && projectView.popupMenu.created)
1901 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectBuild, 0);
1904 menu.disabled = false;
1905 menu.text = unavailable ? $"Stop Build" : $"Build";
1906 menu.accelerator = unavailable ? Key { pauseBreak, ctrl = true } : f7;
1909 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectLink, 0); if(menu) menu.disabled = unavailable;
1910 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRebuild, 0); if(menu) menu.disabled = unavailable;
1911 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectCleanTarget, 0); if(menu) menu.disabled = unavailable;
1912 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectClean, 0); if(menu) menu.disabled = unavailable;
1913 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRealClean, 0); if(menu) menu.disabled = unavailable;
1914 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRegenerate, 0); if(menu) menu.disabled = unavailable;
1915 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRemove, 0); if(menu) menu.disabled = unavailable;
1916 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileClean, 0); if(menu) menu.disabled = unavailable;
1917 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileCompile, 0); if(menu) menu.disabled = unavailable;
1918 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugPrecompile, 0); if(menu) menu.disabled = unavailable;
1919 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugCompile, 0); if(menu) menu.disabled = unavailable;
1920 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugGenerateSymbols, 0); if(menu) menu.disabled = unavailable;
1921 projectView.popupMenu.Update(null);
1925 property bool areDebugMenusUnavailable { get {
1927 project.GetTargetType(project.config) != executable ||
1928 projectView.buildInProgress == buildingMainProject;
1931 property bool isBreakpointTogglingUnavailable { get {
1935 property bool isDebuggerExecuting { get {
1939 return ide.debugger.state == running;
1942 void AdjustDebugMenus()
1944 bool unavailable = areDebugMenusUnavailable;
1945 bool active = debugger.isActive;
1946 bool bpNoToggle = isBreakpointTogglingUnavailable;
1947 bool executing = isDebuggerExecuting;
1948 //bool holding = debugger.state == stopped;
1950 debugStartResumeItem.disabled = unavailable || executing;
1951 debugStartResumeItem.text = active ? $"Resume" : $"Start";
1952 debugStartResumeItem.NotifySelect = active ? MenuDebugResume : MenuDebugStart;
1955 toolBar.buttonDebugStartResume.disabled = unavailable || executing;
1956 toolBar.buttonDebugStartResume.toolTip = active ? $"Resume" : $"Start";
1959 debugBreakItem.disabled = unavailable || !executing;
1960 debugStopItem.disabled = unavailable || !active;
1961 debugRestartItem.disabled = unavailable || !active;
1964 toolBar.buttonDebugPause.disabled = unavailable || !executing;
1965 toolBar.buttonDebugStop.disabled = unavailable || !active;
1966 toolBar.buttonDebugRestart.disabled = unavailable || !active;
1969 debugStepIntoItem.disabled = unavailable || executing;
1970 debugStepOverItem.disabled = unavailable || executing;
1971 debugStepOutItem.disabled = unavailable || executing || !active;
1972 debugSkipStepOverItem.disabled = unavailable || executing;
1973 debugSkipStepOutItem.disabled = unavailable || executing || !active;
1976 toolBar.buttonDebugStepInto.disabled = unavailable || executing;
1977 toolBar.buttonDebugStepOver.disabled = unavailable || executing;
1978 toolBar.buttonDebugStepOut.disabled = unavailable || executing || !active;
1979 toolBar.buttonDebugSkipStepOver.disabled = unavailable || executing;
1980 // toolBar.buttonDebugSkipStepOutItem.disabled = unavailable || executing;
1982 if((Designer)GetActiveDesigner())
1984 CodeEditor codeEditor = ((Designer)GetActiveDesigner()).codeEditor;
1986 codeEditor.AdjustDebugMenus(unavailable, bpNoToggle, executing);
1990 void ChangeFileDialogsDirectory(char * directory, bool saveSettings)
1992 char tempString[MAX_LOCATION];
1993 strcpy(tempString, directory);
1994 if(saveSettings && !projectView)
1996 ideSettings.ideFileDialogLocation = directory;
1997 settingsContainer.Save();
2000 ideFileDialog.currentDirectory = tempString;
2001 codeEditorFileDialog.currentDirectory = tempString;
2002 codeEditorFormFileDialog.currentDirectory = tempString;
2005 void ChangeProjectFileDialogDirectory(char * directory)
2007 ideSettings.ideProjectFileDialogLocation = directory;
2008 settingsContainer.Save();
2011 Window FindWindow(char * filePath)
2013 Window document = null;
2015 // TOCHECK: Do we need to change slashes here?
2016 for(document = firstChild; document; document = document.next)
2018 char * fileName = document.fileName;
2019 if(document.isDocument && fileName && !fstrcmp(fileName, filePath))
2021 document.visible = true;
2022 document.Activate();
2029 bool DontTerminateDebugSession(char * title)
2031 if(debugger.isActive)
2033 if(MessageBox { type = yesNo, master = ide,
2034 contents = $"Do you want to terminate the debugging session in progress?",
2035 text = title }.Modal() == no)
2038 MessageBox msg { type = yesNo, master = ide,
2039 contents = "Do you want to terminate the debugging session in progress?",
2041 if(msg.Modal() == no)
2053 Window OpenFile(char * origFilePath, WindowState state, bool visible, char * type, OpenCreateIfFails createIfFails, OpenMethod openMethod, bool noParsing)
2055 char extension[MAX_EXTENSION] = "";
2056 Window document = null;
2057 bool isProject = false;
2058 bool needFileModified = true;
2059 char winFilePath[MAX_LOCATION];
2060 char * filePath = strstr(origFilePath, "http://") == origFilePath ? strcpy(winFilePath, origFilePath) : GetSystemPathBuffer(winFilePath, origFilePath);
2064 GetExtension(filePath, extension);
2068 strcpy(extension, type);
2070 if(strcmp(extension, ProjectExtension))
2072 for(document = firstChild; document; document = document.next)
2074 char * fileName = document.fileName;
2075 if(document.isDocument && fileName && !fstrcmp(fileName, filePath) && document.created)
2077 document.visible = true;
2079 document.Activate();
2085 if(createIfFails == whatever)
2087 else if(!strcmp(extension, ProjectExtension) || !strcmp(extension, WorkspaceExtension))
2089 needFileModified = false;
2090 if(openMethod == normal)
2092 if(DontTerminateDebugSession($"Open Project"))
2102 Workspace workspace = null;
2104 if(FileExists(filePath))
2106 if(!strcmp(extension, ProjectExtension))
2108 char workspaceFile[MAX_LOCATION];
2109 strcpy(workspaceFile, filePath);
2110 ChangeExtension(workspaceFile, WorkspaceExtension, workspaceFile);
2111 workspace = LoadWorkspace(workspaceFile, filePath);
2113 else if(!strcmp(extension, WorkspaceExtension))
2114 workspace = LoadWorkspace(filePath, null);
2117 //project = LoadProject(filePath, null);
2122 char absolutePath[MAX_LOCATION];
2123 CreateProjectView(workspace, filePath);
2124 document = projectView;
2126 workspace.DropInvalidBreakpoints();
2129 ide.projectView.ShowOutputBuildLog(true);
2131 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
2132 ide.projectView.DisplayCompiler(compiler, false);
2135 UpdateCompilerConfigs(false);
2138 char newWorkingDir[MAX_LOCATION];
2139 StripLastDirectory(filePath, newWorkingDir);
2140 ChangeFileDialogsDirectory(newWorkingDir, false);
2143 document.fileName = filePath;
2145 ideMainFrame.SetText("%s - %s", filePath, titleECEREIDE);
2147 // this crashes on starting ide with epj file, solution please?
2148 // app.UpdateDisplay();
2150 workspace.holdTracking = true;
2151 for(ofi : workspace.openedFiles)
2153 if(ofi.state != closed)
2155 Window file = OpenFile(ofi.path, normal, true, null, no, normal, noParsing);
2158 char fileName[MAX_LOCATION];
2160 GetLastDirectory(ofi.path, fileName);
2161 node = projectView.project.topNode.Find(fileName, true);
2163 node.EnsureVisible();
2167 workspace.holdTracking = false;
2169 workspace.timer.Start();
2171 findInFilesDialog.mode = FindInFilesMode::project;
2172 findInFilesDialog.currentDirectory = ide.project.topNode.path;
2175 char location[MAX_LOCATION];
2176 StripLastDirectory(ide.project.topNode.path, location);
2177 ChangeProjectFileDialogDirectory(location);
2181 if(projectView.debugger)
2182 projectView.debugger.EvaluateWatches();
2189 if(MessageBox { type = yesNo, master = this, text = $"Error opening project", contents = $"Open a different project?" }.Modal() == yes)
2191 ideProjectFileDialog.text = openProjectFileDialogTitle;
2192 if(ideProjectFileDialog.Modal() == cancel)
2194 filePath = ideProjectFileDialog.filePath;
2195 GetExtension(filePath, extension);
2206 else if(openMethod == add)
2211 char slashFilePath[MAX_LOCATION];
2212 GetSlashPathBuffer(slashFilePath, filePath);
2213 for(p : workspace.projects)
2215 if(!fstrcmp(p.filePath, slashFilePath))
2223 MessageBox { type = ok, parent = parent, master = this, text = $"Same Project",
2224 contents = $"This project is already present in workspace." }.Modal();
2228 prj = LoadProject(filePath, null);
2231 char * activeConfigName = null;
2232 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
2233 prj.StartMonitoring();
2234 workspace.projects.Add(prj);
2235 if(toolBar.activeConfig.currentRow && toolBar.activeConfig.currentRow != toolBar.activeConfig.firstRow &&
2236 toolBar.activeConfig.currentRow.string && toolBar.activeConfig.currentRow.string[0])
2237 activeConfigName = toolBar.activeConfig.currentRow.string;
2238 if(activeConfigName)
2240 for(cfg : prj.configurations)
2242 if(cfg.name && !strcmp(cfg.name, activeConfigName))
2250 projectView.AddNode(prj.topNode, null);
2251 workspace.modified = true;
2253 findInFilesDialog.AddProjectItem(prj);
2254 projectView.ShowOutputBuildLog(true);
2255 projectView.DisplayCompiler(compiler, false);
2256 projectView.ProjectUpdateMakefileForAllConfigs(prj);
2260 char location[MAX_LOCATION];
2261 StripLastDirectory(prj.topNode.path, location);
2262 ChangeProjectFileDialogDirectory(location);
2265 // projectView is associated with the main project and not with the one just added but
2266 return projectView; // just to let the caller know something was opened
2274 else if(!strcmp(extension, "bmp") || !strcmp(extension, "pcx") ||
2275 !strcmp(extension, "jpg") || !strcmp(extension, "gif") ||
2276 !strcmp(extension, "jpeg") || !strcmp(extension, "png"))
2278 if(FileExists(filePath))
2279 document = PictureEdit { hasMaximize = true, hasMinimize = true, hasClose = true, borderStyle = sizable,
2280 hasVertScroll = true, hasHorzScroll = true, parent = this, state = state,
2281 visible = visible, bitmapFile = filePath, OnClose = PictureEditOnClose/*why?--GenericDocumentOnClose*/;
2284 MessageBox { type = ok, master = this, text = filePath, contents = $"File doesn't exist." }.Modal();
2287 else if(!strcmp(extension, "3ds"))
2289 if(FileExists(filePath))
2290 document = ModelView { hasMaximize = true, hasMinimize = true, hasClose = true, borderStyle = sizable,
2291 hasVertScroll = true, hasHorzScroll = true, parent = this, state = state,
2292 visible = visible, modelFile = filePath, OnClose = ModelViewOnClose/*why?--GenericDocumentOnClose*/
2296 MessageBox { type = ok, master = this, text = filePath, contents = $"File doesn't exist." }.Modal();
2299 else if(!strcmp(extension, "txt") || !strcmp(extension, "text") ||
2300 !strcmp(extension, "nfo") || !strcmp(extension, "info") ||
2301 !strcmp(extension, "htm") || !strcmp(extension, "html") ||
2302 !strcmp(extension, "css") || !strcmp(extension, "php") ||
2303 !strcmp(extension, "js"))
2305 CodeEditor editor { parent = this, state = state, visible = false, noParsing = noParsing };
2306 editor.updatingCode = true;
2307 if(editor.LoadFile(filePath))
2310 editor.visible = true;
2314 needFileModified = false;
2318 CodeEditor editor { parent = this, state = state, visible = false, noParsing = noParsing };
2319 if(editor.LoadFile(filePath))
2322 editor.visible = true;
2326 needFileModified = false;
2329 if(document && (document._class == class(PictureEdit) ||
2330 document._class == class(ModelView)))
2335 document.fileName = filePath;
2336 if(workspace && !workspace.holdTracking)
2337 workspace.UpdateOpenedFileInfo(filePath, opened);
2341 if(!document && createIfFails != no)
2343 if(createIfFails != yes && !needFileModified &&
2344 MessageBox { type = yesNo, master = this, text = filePath, contents = $"File doesn't exist. Create?" }.Modal() == yes)
2345 createIfFails = yes;
2346 if(createIfFails == yes || createIfFails == whatever)
2348 document = (Window)NewCodeEditor(this, state, true);
2350 document.fileName = filePath;
2356 if(projectView && document._class == class(CodeEditor) && workspace)
2358 int lineNumber, position;
2360 CodeEditor editor = (CodeEditor)document;
2361 editor.openedFileInfo = workspace.UpdateOpenedFileInfo(filePath, opened);
2362 editor.openedFileInfo.holdTracking = true;
2363 lineNumber = Max(editor.openedFileInfo.lineNumber - 1, 0);
2364 position = Max(editor.openedFileInfo.position - 1, 0);
2365 editor.editBox.GoToLineNum(lineNumber);
2366 editor.editBox.GoToPosition(editor.editBox.line, lineNumber, position);
2367 scroll.x = Max(editor.openedFileInfo.scroll.x, 0);
2368 scroll.y = Max(editor.openedFileInfo.scroll.y, 0);
2369 editor.editBox.scroll = scroll;
2370 editor.openedFileInfo.holdTracking = false;
2373 if(needFileModified)
2374 document.OnFileModified = OnFileModified;
2375 document.NotifySaved = DocumentSaved;
2378 ideSettings.AddRecentProject(document.fileName);
2380 ideSettings.AddRecentFile(document.fileName);
2381 ide.UpdateRecentMenus();
2382 ide.AdjustFileMenus();
2383 settingsContainer.Save();
2391 // TOCHECK: I can't use a generic one for both ModelView and PictureEdit both derived from Window
2392 /*bool Window::GenericDocumentOnClose(bool parentClosing)
2394 if(!parentClosing && ide.workspace)
2395 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2398 bool ModelView::ModelViewOnClose(bool parentClosing)
2400 if(!parentClosing && ide.workspace)
2401 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2404 bool PictureEdit::PictureEditOnClose(bool parentClosing)
2406 if(!parentClosing && ide.workspace)
2407 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2412 void OnUnloadGraphics(Window window)
2414 display.ClearMaterials();
2415 display.ClearTextures();
2416 display.ClearMeshes();
2420 bool OnActivate(bool active, Window swap, bool * goOnWithActivation, bool direct)
2422 caps.color = app.GetKeyState(capsState) ? black : Color { 128,128,128 };
2423 num.color = app.GetKeyState(numState) ? black : Color { 128,128,128 };
2427 bool OnKeyDown(Key key, unichar ch)
2432 projectView.Update(null);
2435 caps.color = app.GetKeyState(capsState) ? black : Color { 128,128,128 };
2438 num.color = app.GetKeyState(numState) ? black : Color { 128,128,128 };
2444 void GoToError(const char * line, bool noParsing)
2447 projectView.GoToError(line, noParsing);
2450 void CodeLocationParseAndGoTo(const char * text, Project project, const char * dir)
2453 char *colon = strchr(text, ':');
2454 char filePath[MAX_LOCATION] = "";
2455 char completePath[MAX_LOCATION];
2456 int line = 0, col = 0;
2458 FileAttribs fileAttribs;
2460 if(colon && (colon[1] == '/' || colon[1] == '\\'))
2462 path = (colon - 1 > path) ? colon - 1 : path;
2463 colon = strstr(colon + 1, ":");
2465 while(isspace(*path)) path++;
2468 char * close = strchr(path, ')');
2472 strncpy(name, path+1, close - path - 1);
2473 name[close - path - 1] = '\0';
2474 for(p : ide.workspace.projects)
2476 if(!strcmp(p.name, name))
2486 prj = project ? project : (dir ? null : ide.project);
2489 strncpy(filePath, path, colon - path);
2490 filePath[colon - path] = '\0';
2491 line = atoi(colon + 1);
2492 colon = strstr(colon + 1, ":");
2494 col = atoi(colon + 1);
2496 else if(path - 1 >= text && *(path - 1) == '\"')
2498 colon = strchr(path, '\"');
2501 strncpy(filePath, path, colon - path);
2502 filePath[colon - path] = '\0';
2505 else if(path && !colon)
2507 strcpy(filePath, path);
2513 strcpy(completePath, prj.topNode.path);
2514 else if(dir && dir[0])
2515 strcpy(completePath, dir);
2517 completePath[0] = '\0';
2518 PathCat(completePath, filePath);
2520 if((fileAttribs = FileExists(completePath)))
2521 CodeLocationGoTo(completePath, fileAttribs, line, col);
2524 for(p : ide.workspace.projects)
2526 strcpy(completePath, p.topNode.path);
2527 PathCat(completePath, filePath);
2528 if((fileAttribs = FileExists(completePath)))
2530 CodeLocationGoTo(completePath, fileAttribs, line, col);
2538 void CodeLocationGoTo(const char * path, const FileAttribs fileAttribs, int line, int col)
2540 if(fileAttribs.isFile)
2542 CodeEditor codeEditor = (CodeEditor)OpenFile(path, normal, true, "", no, normal, false);
2543 if(codeEditor && line)
2545 char ext[MAX_EXTENSION];
2546 GetExtension(path, ext);
2547 if(!strcmp(ext, "mp3") || !strcmp(ext, "flac") || !strcmp(ext, "ogg") || !strcmp(ext, "avi") || !strcmp(ext, "mkv"))
2549 else if(!strcmp(ext, "a") || !strcmp(ext, "o") || !strcmp(ext, "lib") || !strcmp(ext, "dll") || !strcmp(ext, "exe"))
2551 char dirPath[MAX_LOCATION];
2552 StripLastDirectory(path, dirPath);
2557 CodeEditor codeEditor = (CodeEditor)OpenFile(path, normal, true, "", no, normal, false);
2558 if(codeEditor && line)
2560 EditBox editBox = codeEditor.editBox;
2561 editBox.GoToLineNum(line - 1);
2562 editBox.GoToPosition(editBox.line, line - 1, col ? (col - 1) : 0);
2566 else if(fileAttribs.isDirectory)
2571 void OnRedraw(Surface surface)
2573 Bitmap bitmap = back.bitmap;
2575 surface.Blit(bitmap, (clientSize.w - bitmap.width) / 2, (clientSize.h - bitmap.height) / 2, 0, 0, bitmap.width, bitmap.height);
2578 void SheetSelected(SheetType sheetSelected)
2580 if(activeChild == sheet)
2582 if(sheetSelected == methods)
2584 viewPropertiesItem.accelerator = f4;
2585 viewPropertiesItem.parent = viewMenu;
2586 viewMethodsItem.parent = null;
2590 viewMethodsItem.accelerator = f4;
2591 viewMethodsItem.parent = viewMenu;
2592 viewPropertiesItem.parent = null;
2597 viewMethodsItem.parent = viewMenu;
2598 viewPropertiesItem.parent = viewMenu;
2599 if(sheetSelected == methods)
2601 viewMethodsItem.accelerator = f4;
2602 viewPropertiesItem.accelerator = 0;
2606 viewMethodsItem.accelerator = 0;
2607 viewPropertiesItem.accelerator = f4;
2612 void OnActivateClient(Window client, Window previous)
2614 //if(!client || client != previous)
2617 if(!client || client != previous)
2620 dataType = previous._class;
2621 if(previous && !strcmp(dataType.name, "CodeEditor"))
2623 ((CodeEditor)previous).UpdateFormCode();
2625 else if(previous && !strcmp(dataType.name, "Designer"))
2627 ((Designer)previous).codeEditor.UpdateFormCode();
2632 dataType = client._class;
2633 if(client && !strcmp(dataType.name, "CodeEditor"))
2635 CodeEditor codeEditor = (CodeEditor)client;
2636 SetPrivateModule(codeEditor.privateModule);
2637 SetCurrentContext(codeEditor.globalContext);
2638 SetTopContext(codeEditor.globalContext);
2639 SetGlobalContext(codeEditor.globalContext);
2641 SetDefines(&codeEditor.defines);
2642 SetImports(&codeEditor.imports);
2644 SetActiveDesigner(codeEditor.designer);
2646 sheet.codeEditor = codeEditor;
2647 toolBox.codeEditor = codeEditor;
2649 viewDesignerItem.parent = viewMenu;
2650 if(activeChild != codeEditor)
2652 viewCodeItem.parent = viewMenu;
2653 viewDesignerItem.accelerator = 0;
2654 viewCodeItem.accelerator = f8;
2658 viewCodeItem.parent = null;
2659 viewDesignerItem.accelerator = f8;
2662 else if(client && !strcmp(dataType.name, "Designer"))
2664 CodeEditor codeEditor = ((Designer)client).codeEditor;
2667 SetPrivateModule(codeEditor.privateModule);
2668 SetCurrentContext(codeEditor.globalContext);
2669 SetTopContext(codeEditor.globalContext);
2670 SetGlobalContext(codeEditor.globalContext);
2671 SetDefines(&codeEditor.defines);
2672 SetImports(&codeEditor.imports);
2676 SetPrivateModule(null);
2677 SetCurrentContext(null);
2678 SetTopContext(null);
2679 SetGlobalContext(null);
2684 SetActiveDesigner((Designer)client);
2686 sheet.codeEditor = codeEditor;
2687 toolBox.codeEditor = codeEditor;
2689 viewCodeItem.parent = viewMenu;
2690 if(activeChild != client)
2692 viewDesignerItem.parent = viewMenu;
2693 viewDesignerItem.accelerator = f8;
2694 viewCodeItem.accelerator = 0;
2698 viewDesignerItem.parent = null;
2699 viewCodeItem.accelerator = f8;
2705 sheet.codeEditor = null;
2706 toolBox.codeEditor = null;
2707 SetActiveDesigner(null);
2709 viewDesignerItem.parent = null;
2710 viewCodeItem.parent = null;
2713 SheetSelected(sheet.sheetSelected);
2716 projectCompileItem = null;
2721 if(client && client._class == eSystem_FindClass(__thisModule, "CodeEditor")) // !strcmp(client._class.name, "CodeEditor")
2723 CodeEditor codeEditor = (CodeEditor)client;
2724 EditBox editBox = codeEditor.editBox;
2726 statusBar.AddField(pos);
2728 caps = { width = 40, text = $"CAPS", color = app.GetKeyState(capsState) ? black : Color { 128, 128, 128 } };
2729 statusBar.AddField(caps);
2731 ovr = { width = 30, text = $"OVR", color = (editBox && editBox.overwrite) ? black : Color { 128, 128, 128 } };
2732 statusBar.AddField(ovr);
2734 num = { width = 30, text = $"NUM", color = app.GetKeyState(numState) ? black : Color { 128, 128, 128 } };
2735 statusBar.AddField(num);
2737 //statusBar.text = "Ready";
2739 if(projectView && projectView.project)
2741 bool isCObject = false;
2742 ProjectNode node = projectView.GetNodeFromWindow(client, null, false);
2743 if(!node && (node = projectView.GetNodeFromWindow(client, null, true)))
2747 char nodeName[MAX_FILENAME];
2748 char name[MAX_FILENAME+96];
2750 ChangeExtension(node.name, "c", nodeName);
2751 sprintf(name, $"Compile %s", isCObject ? nodeName : node.name);
2752 projectCompileItem =
2754 copyText = true, text = name, c, ctrlF7, disabled = projectView.buildInProgress;
2756 bool NotifySelect(MenuItem selection, Modifiers mods)
2760 bool result = false;
2761 bool isCObject = false;
2762 ProjectNode node = null;
2763 for(p : ide.workspace.projects)
2765 node = projectView.GetNodeFromWindow(activeClient, p, false);
2768 if(!node && (node = projectView.GetNodeFromWindow(activeClient, null, true)))
2772 List<ProjectNode> nodes { };
2774 projectView.Compile(node.project, nodes, mods.ctrl && mods.shift, isCObject ? cObject : normal);
2779 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
2784 projectMenu.AddDynamic(projectCompileItem, ide, false);
2790 caps = ovr = num = null;
2795 bool OnClose(bool parentClosing)
2797 //return !projectView.buildInProgress;
2798 if(projectView && projectView.buildInProgress)
2800 if(DontTerminateDebugSession($"Close IDE"))
2802 if(findInFilesDialog)
2803 findInFilesDialog.SearchStop();
2806 workspace.timer.Stop();
2809 ideMainFrame.Destroy(0);
2816 bool passThrough = false;
2817 bool debugStart = false;
2818 bool debugWorkDir = false;
2819 char * passDebugWorkDir = null;
2820 bool openAsText = false;
2821 DynamicString passArgs { };
2824 for(c = 1; c<app.argc; c++)
2826 if(!strcmp(app.argv[c], "-t"))
2828 else if(!strcmp(app.argv[c], "-no-parsing"))
2829 ide.noParsing = true;
2830 else if(!strcmp(app.argv[c], "-debug-start"))
2832 else if(!strcmp(app.argv[c], "-debug-work-dir"))
2833 debugWorkDir = true;
2834 else if(!passThrough && !strcmp(app.argv[c], "-@"))
2836 else if(passThrough)
2839 passArgs.concat(" ");
2840 passArgs.concat(app.argv[c]);
2842 else if(debugWorkDir)
2844 passDebugWorkDir = CopyString(app.argv[c]);
2845 StripQuotes(passDebugWorkDir, passDebugWorkDir);
2846 debugWorkDir = false;
2850 char fullPath[MAX_LOCATION];
2851 char parentPath[MAX_LOCATION];
2852 char ext[MAX_EXTENSION];
2854 FileAttribs dirAttribs;
2855 GetWorkingDir(fullPath, MAX_LOCATION);
2856 PathCat(fullPath, app.argv[c]);
2857 StripLastDirectory(fullPath, parentPath);
2858 GetExtension(app.argv[c], ext);
2859 isProject = !openAsText && !strcmpi(ext, "epj");
2861 if(isProject && c > (debugStart ? 2 : 1)) continue;
2863 // Create directory for projects (only)
2864 if(((dirAttribs = FileExists(parentPath)) && dirAttribs.isDirectory) || isProject)
2866 if(isProject && !FileExists(fullPath))
2868 char name[MAX_LOCATION];
2869 NewProjectDialog newProjectDialog;
2873 projectView.visible = false;
2874 if(!projectView.Destroy(0))
2878 newProjectDialog = { master = this };
2880 strcpy(name, app.argv[c]);
2881 StripExtension(name);
2882 GetLastDirectory(name, name);
2883 newProjectDialog.projectName.contents = name;
2884 newProjectDialog.projectName.NotifyModified(newProjectDialog, newProjectDialog.projectName);
2885 newProjectDialog.locationEditBox.path = parentPath;
2886 newProjectDialog.NotifyModifiedLocation(newProjectDialog.locationEditBox);
2888 incref newProjectDialog;
2889 newProjectDialog.Modal();
2892 ideSettings.AddRecentProject(projectView.fileName);
2893 ide.UpdateRecentMenus();
2894 settingsContainer.Save();
2896 delete newProjectDialog;
2897 // Open only one project
2901 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, openAsText ? "txt" : null, yes, normal, false);
2903 else if(strstr(fullPath, "http://") == fullPath)
2904 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, openAsText ? "txt" : null, yes, normal, false);
2907 if(passThrough && projectView && projectView.project && workspace)
2909 char * fixSpacing = new char[Max(passArgs.size * 1.5, 32)];
2915 bool inQuote = false;
2916 for(c=0; c<passArgs.size; c++)
2919 if(inQuote && k != '\\' && l == ' ')
2921 fixSpacing[d++] = '\"';
2922 fixSpacing[d++] = ' ';
2925 else if(inQuote && l == '\0')
2927 fixSpacing[d++] = '\"';
2928 fixSpacing[d++] = '\0';
2931 else if(!inQuote && j != '\\' && k == ' ' && l != '-' && l != ' ')
2933 fixSpacing[d++] = '\"';
2934 fixSpacing[d++] = l;
2937 else if(k == '\\' && l == ' ')
2938 fixSpacing[d++] = ' ';
2939 else if(k == '\\' && l == '\\')
2940 fixSpacing[d++] = '\\';
2942 fixSpacing[d++] = l;
2946 fixSpacing[d] = '\0';
2948 workspace.commandLineArgs = fixSpacing;
2950 if(passDebugWorkDir)
2952 workspace.debugDir = passDebugWorkDir;
2953 delete passDebugWorkDir;
2956 ;//MenuDebugStart(debugStartResumeItem, 0); // <-- how TODO this without getting into the app.Wait lock
2958 UpdateToolBarActiveConfigs(false);
2959 UpdateToolBarActiveCompilers();
2966 // IS THIS NEEDED? WASN'T HERE BEFORE... Crashes on getting node's projectView otherwise
2969 projectView.visible = false;
2970 projectView.Destroy(0);
2973 #ifdef GDB_DEBUG_GUI
2974 gdbDialog.Destroy(0);
2979 void SetPath(bool projectsDirs, CompilerConfig compiler, ProjectConfig config, int bitDepth)
2983 char * oldPaths[128];
2984 String oldList = new char[maxPathLen];
2985 Array<String> newExePaths { };
2986 //Map<String, bool> exePathExists { };
2988 #if defined(__unix__) || defined(__APPLE__)
2989 Array<String> newLibPaths { };
2990 Map<String, bool> libPathExists { };
2995 for(prj : workspace.projects)
2997 DirExpression targetDirExp;
2999 // SKIP FIRST PROJECT...
3000 if(prj == workspace.projects.firstIterator.data) continue;
3002 // NOTE: Right now the additional project config dir will be
3003 // obtained when the debugger is started, so toggling it
3004 // while building will change which library gets used.
3005 // To go with the initial state, e.g. when F5 was pressed,
3006 // we nould need to keep a list of all project's active
3007 // config upon startup.
3008 targetDirExp = prj.GetTargetDir(compiler, prj.config, bitDepth);
3010 /*if(prj.config.targetType == sharedLibrary && prj.config.debug)
3014 for(cfg = prj.configurations.first; cfg; cfg = cfg.next)
3015 if(cfg.targetType == sharedLibrary && cfg.debug && !strcmpi(cfg.name, "Debug"))
3019 for(cfg = prj.configurations.first; cfg; cfg = cfg.next)
3020 if(cfg.targetType == sharedLibrary && cfg.debug)
3024 if(targetDirExp.dir)
3026 char buffer[MAX_LOCATION];
3027 #if defined(__WIN32__)
3028 Array<String> paths = newExePaths;
3030 Array<String> paths = newLibPaths;
3032 GetSystemPathBuffer(buffer, prj.topNode.path);
3033 PathCat(buffer, targetDirExp.dir);
3036 if(!fstrcmp(p, buffer))
3043 paths.Add(CopyString(buffer));
3045 delete targetDirExp;
3049 for(item : compiler.executableDirs)
3052 for(p : newExePaths)
3054 if(!fstrcmp(p, item))
3061 newExePaths.Add(CopySystemPath(item));
3064 GetEnvironment("PATH", oldList, maxPathLen);
3066 printf("Old value of PATH: %s\n", oldList);
3068 count = TokenizeWith(oldList, sizeof(oldPaths) / sizeof(char *), oldPaths, pathListSep, false);
3069 for(c = 0; c < count; c++)
3072 for(p : newExePaths)
3074 if(!fstrcmp(p, oldPaths[c]))
3081 newExePaths.Add(CopySystemPath(oldPaths[c]));
3085 for(path : newExePaths)
3086 len += strlen(path) + 1;
3087 newList = new char[len + 1];
3089 for(path : newExePaths)
3091 strcat(newList, path);
3092 strcat(newList, pathListSep);
3094 newList[len - 1] = '\0';
3095 SetEnvironment("PATH", newList);
3097 printf("New value of PATH: %s\n", newList);
3104 #if defined(__unix__) || defined(__APPLE__)
3106 for(item : compiler.libraryDirs)
3108 if(!libPathExists[item]) // fstrcmp should be used
3110 newLibPaths.Add(item);
3111 libPathExists[item] = true;
3115 #if defined(__APPLE__)
3116 GetEnvironment("DYLD_LIBRARY_PATH", oldList, maxPathLen);
3118 GetEnvironment("LD_LIBRARY_PATH", oldList, maxPathLen);
3121 printf("Old value of [DY]LD_LIBRARY_PATH: %s\n", oldList);
3123 count = TokenizeWith(oldList, sizeof(oldPaths) / sizeof(char *), oldPaths, pathListSep, false);
3124 for(c = 0; c < count; c++)
3126 if(!libPathExists[oldPaths[c]]) // fstrcmp should be used
3128 newLibPaths.Add(oldPaths[c]);
3129 libPathExists[oldPaths[c]] = true;
3134 for(path : newLibPaths)
3135 len += strlen(path) + 1;
3136 newList = new char[len + 1];
3138 for(path : newLibPaths)
3140 strcat(newList, path);
3141 strcat(newList, pathListSep);
3143 newList[len - 1] = '\0';
3144 #if defined(__APPLE__)
3145 SetEnvironment("DYLD_LIBRARY_PATH", newList);
3147 SetEnvironment("LD_LIBRARY_PATH", newList);
3150 printf("New value of [DY]LD_LIBRARY_PATH: %s\n", newList);
3155 delete libPathExists;
3158 if(compiler.distccEnabled && compiler.distccHosts)
3159 SetEnvironment("DISTCC_HOSTS", compiler.distccHosts);
3164 void DestroyTemporaryProjectDir()
3166 if(tmpPrjDir && tmpPrjDir[0])
3168 if(FileExists(tmpPrjDir).isDirectory)
3169 DestroyDir(tmpPrjDir);
3170 property::tmpPrjDir = null;
3176 // Graphics Driver Menu
3180 app.currentSkin.selectionColor = selectionColor;
3181 app.currentSkin.selectionText = selectionText;
3185 driverItems = new MenuItem[app.numDrivers];
3186 for(c = 0; c < app.numDrivers; c++)
3188 driverItems[c] = MenuItem { driversMenu, app.drivers[c], NotifySelect = NotifySelectDisplayDriver };
3189 driverItems[c].id = c;
3190 driverItems[c].isRadio = true;
3193 driverItems = new MenuItem[2];
3194 #if defined(__unix__)
3195 driverItems[0] = MenuItem { driversMenu, "X", NotifySelect = NotifySelectDisplayDriver };
3196 driverItems[0].id = 0;
3197 driverItems[0].isRadio = true;
3199 driverItems[0] = MenuItem { driversMenu, "GDI", NotifySelect = NotifySelectDisplayDriver };
3200 driverItems[0].id = 0;
3201 driverItems[0].isRadio = true;
3203 driverItems[1] = MenuItem { driversMenu, "OpenGL", NotifySelect = NotifySelectDisplayDriver };
3204 driverItems[1].id = 1;
3205 driverItems[1].isRadio = true;
3207 /* skinItems = new MenuItem[app.numSkins];
3208 for(c = 0; c < app.numSkins; c++)
3210 skinItems[c] = MenuItem {skinsMenu, app.skins[c], NotifySelect = NotifySelectDisplaySkin };
3211 skinItems[c].id = c;
3212 skinItems[c].isRadio = true;
3215 ideFileDialog.master = this;
3216 ideProjectFileDialog.master = this;
3218 //SetDriverAndSkin();
3222 void UpdateRecentMenus()
3225 Menu fileMenu = menu.FindMenu($"File");
3226 Menu recentFiles = fileMenu.FindMenu($"Recent Files");
3227 Menu recentProjects = fileMenu.FindMenu($"Recent Projects");
3228 char * itemPath = new char[MAX_LOCATION];
3229 char * itemName = new char[MAX_LOCATION+4];
3232 recentFiles.Clear();
3235 for(recent : ideSettings.recentFiles)
3237 strncpy(itemPath, recent, MAX_LOCATION); itemPath[MAX_LOCATION-1] = '\0';
3238 MakeSystemPath(itemPath);
3239 snprintf(itemName, MAX_LOCATION+4, "%d %s", 1 + c, itemPath); itemName[MAX_LOCATION+4-1] = '\0';
3240 recentFiles.AddDynamic(MenuItem { copyText = true, text = itemName, (Key)k1 + c, id = c, NotifySelect = ide.FileRecentFile }, ide, true);
3244 recentProjects.Clear();
3246 for(recent : ideSettings.recentProjects)
3248 strncpy(itemPath, recent, MAX_LOCATION); itemPath[MAX_LOCATION-1] = '\0';
3249 MakeSystemPath(itemPath);
3250 snprintf(itemName, MAX_LOCATION+4, "%d %s", 1 + c, itemPath); itemName[MAX_LOCATION+4-1] = '\0';
3251 recentProjects.AddDynamic(MenuItem { copyText = true, text = itemName, (Key)k1 + c, id = c, NotifySelect = ide.FileRecentProject }, ide, true);
3267 void DestroyDir(char * path)
3269 RecursiveDeleteFolderFSI fsi { };
3274 #if defined(__WIN32__)
3275 define sdkDirName = "Ecere SDK";
3277 define sdkDirName = "ecere";
3280 void FindAndShellOpenInstalledFolder(char * name)
3282 char * p = new char[MAX_LOCATION];
3283 char * v = new char[maxPathLen];
3286 Array<String> paths { };
3288 strncpy(p, settingsContainer.moduleLocation, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3289 StripLastDirectory(p, p);
3291 paths.Add(CopyString(p));
3292 #if defined(__WIN32__)
3293 GetEnvironment("ECERE_SDK_SRC", v, maxPathLen);
3296 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3297 PathCat(p, name); paths.Add(CopyString(p));
3299 GetEnvironment("AppData", v, maxPathLen);
3302 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3303 PathCat(p, sdkDirName); PathCat(p, name); paths.Add(CopyString(p));
3305 GetEnvironment("ProgramFiles", v, maxPathLen);
3308 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3309 PathCat(p, sdkDirName); PathCat(p, name); paths.Add(CopyString(p));
3311 GetEnvironment("ProgramFiles(x86)", v, maxPathLen);
3314 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3315 PathCat(p, sdkDirName); PathCat(p, name); paths.Add(CopyString(p));
3317 GetEnvironment("SystemDrive", v, maxPathLen);
3320 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3321 PathCat(p, "Program Files"); PathCat(p, sdkDirName); PathCat(p, name); paths.Add(CopyString(p));
3324 GetEnvironment("XDG_DATA_DIRS", v, maxPathLen);
3325 numTokens = TokenizeWith(v, sizeof(tokens) / sizeof(byte *), tokens, ":", false);
3326 for(c=0; c<numTokens; c++)
3328 strncpy(p, tokens[c], MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3329 PathCat(p, sdkDirName); PathCat(p, name); paths.Add(CopyString(p));
3334 strncpy(p, path, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3335 if(FileExists(p).isDirectory)
3347 void FindAndShellOpenInstalledFile(char * subdir, char * name)
3349 char * p = new char[MAX_LOCATION];
3350 char * v = new char[maxPathLen];
3353 Array<String> paths { };
3355 strncpy(p, settingsContainer.moduleLocation, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3356 paths.Add(CopyString(p));
3357 StripLastDirectory(p, p);
3359 paths.Add(CopyString(p));
3360 #if defined(__WIN32__)
3361 GetEnvironment("ECERE_SDK_SRC", v, maxPathLen);
3364 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3365 PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3367 GetEnvironment("AppData", v, maxPathLen);
3370 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3371 PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3373 GetEnvironment("ProgramFiles", v, maxPathLen);
3376 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3377 PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3379 GetEnvironment("ProgramFiles(x86)", v, maxPathLen);
3382 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3383 PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3385 GetEnvironment("SystemDrive", v, maxPathLen);
3388 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3389 PathCat(p, "Program Files"); PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3392 GetEnvironment("XDG_DATA_DIRS", v, maxPathLen);
3393 numTokens = TokenizeWith(v, sizeof(tokens) / sizeof(byte *), tokens, ":", false);
3394 for(c=0; c<numTokens; c++)
3396 strncpy(p, tokens[c], MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3397 PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3402 strncpy(p, path, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3404 if(FileExists(p).isFile)
3416 class RecursiveDeleteFolderFSI : NormalFileSystemIterator
3418 bool preserveRootFolder;
3420 void OutFolder(char * folderPath, bool isRoot)
3422 if(!(preserveRootFolder && isRoot))
3423 RemoveDir(folderPath);
3426 bool OnFile(char * filePath)
3428 DeleteFile(filePath);
3433 class IDEApp : GuiApplication
3435 //driver = "Win32Console";
3436 // driver = "OpenGL";
3440 TempFile includeFile { };
3444 SetLoggingMode(stdOut, null);
3445 //SetLoggingMode(debug, null);
3447 settingsContainer.Load();
3448 #if defined(__unix__) || defined(__APPLE__)
3449 app.driver = (ideSettings.displayDriver && !strcmp(ideSettings.displayDriver, "OpenGL")) ? ideSettings.displayDriver : "X";
3451 app.driver = (ideSettings.displayDriver && !strcmp(ideSettings.displayDriver, "OpenGL")) ? ideSettings.displayDriver : "GDI";
3453 ide.driverItems[ideSettings.displayDriver && !strcmp(ideSettings.displayDriver,"OpenGL")].checked = true;
3457 desktop.text = titleECEREIDE;
3460 for(c = 1; c<app.argc; c++)
3462 char fullPath[MAX_LOCATION];
3463 GetWorkingDir(fullPath, MAX_LOCATION);
3464 PathCat(fullPath, app.argv[c]);
3465 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, null, yes, normal, false);
3469 if(!LoadIncludeFile())
3470 PrintLn("error: unable to load :crossplatform.mk file inside ide binary.");
3475 bool LoadIncludeFile()
3477 bool result = false;
3478 File include = FileOpen(":crossplatform.mk", read);
3481 File f = includeFile;
3484 for(; !include.Eof(); )
3487 int count = include.Read(buffer, 1, 4096);
3488 f.Write(buffer, 1, count);
3498 IDEMainFrame ideMainFrame { };
3500 define app = ((IDEApp)__thisModule);
3502 define titleECEREIDE = $"ECERE IDE (Debug)";
3504 define titleECEREIDE = $"ECERE IDE";