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"))
853 if(MenuWindowCloseAll(null, 0))
855 NewProjectDialog newProjectDialog;
859 projectView.visible = false;
860 if(!projectView.Destroy(0))
864 newProjectDialog = { master = this };
865 newProjectDialog.Modal();
868 ideSettings.AddRecentProject(projectView.fileName);
869 ide.UpdateRecentMenus();
870 settingsContainer.Save();
876 MenuItem projectOpenItem
878 projectMenu, $"Open...", o, Key { o, true, true };
879 bitmap = { ":actions/projOpen.png" };
880 bool NotifySelect(MenuItem selection, Modifiers mods)
882 if(ideSettings.ideProjectFileDialogLocation)
883 ideProjectFileDialog.currentDirectory = ideSettings.ideProjectFileDialogLocation;
885 ideProjectFileDialog.text = openProjectFileDialogTitle;
886 if(ideProjectFileDialog.Modal() == ok)
888 OpenFile(ideProjectFileDialog.filePath, normal, true, projectTypes[ideProjectFileDialog.fileType].typeExtension, no, normal, mods.ctrl && mods.shift);
889 //ChangeProjectFileDialogDirectory(ideProjectFileDialog.currentDirectory);
894 MenuItem projectQuickItem
896 projectMenu, $"Quick...", q, f7, disabled = true;
897 bool NotifySelect(MenuItem selection, Modifiers mods)
900 QuickProjectDialog { this }.Modal();
904 MenuItem projectAddItem
906 projectMenu, $"Add project to workspace...", a, Key { a, true, true };
907 bitmap = { ":actions/projAdd.png" };
909 bool NotifySelect(MenuItem selection, Modifiers mods)
911 if(ideSettings.ideProjectFileDialogLocation)
912 ideProjectFileDialog.currentDirectory = ideSettings.ideProjectFileDialogLocation;
914 ideProjectFileDialog.text = addProjectFileDialogTitle;
917 if(ideProjectFileDialog.Modal() == ok)
919 if(OpenFile(ideProjectFileDialog.filePath, normal, true, projectTypes[ideProjectFileDialog.fileType].typeExtension, no, add, mods.ctrl && mods.shift))
921 if(MessageBox { type = yesNo, master = this, text = $"Error opening project file",
922 contents = $"Add a different project?" }.Modal() == no)
933 MenuItem projectCloseItem
935 projectMenu, $"Close", c, disabled = true;
936 bool NotifySelect(MenuItem selection, Modifiers mods)
940 if(!ide.DontTerminateDebugSession($"Project Close"))
942 if(findInFilesDialog)
943 findInFilesDialog.SearchStop();
944 projectView.visible = false;
945 if(projectView.Destroy(0))
946 MenuWindowCloseAll(null, 0);
948 char workingDir[MAX_LOCATION];
949 GetWorkingDir(workingDir, MAX_LOCATION);
950 findInFilesDialog.currentDirectory = workingDir;
951 ideMainFrame.text = titleECEREIDE;
959 MenuDivider { projectMenu };
960 MenuItem projectSettingsItem
962 projectMenu, $"Settings...", s, altF7, disabled = true;
963 bool NotifySelect(MenuItem selection, Modifiers mods)
965 projectView.MenuSettings(projectView.active ? selection : null, mods);
969 MenuDivider { projectMenu };
970 MenuItem projectBrowseFolderItem
972 projectMenu, $"Browse Project Folder", p, disabled = true;
973 bool NotifySelect(MenuItem selection, Modifiers mods)
976 projectView.MenuBrowseFolder(null, mods);
980 MenuDivider { projectMenu };
981 MenuItem projectRunItem
983 projectMenu, $"Run", r, ctrlF5, disabled = true;
984 bitmap = { ":actions/run.png" };
985 bool NotifySelect(MenuItem selection, Modifiers mods)
988 projectView.Run(null, mods);
992 MenuItem projectBuildItem
994 projectMenu, $"Build", b, f7, disabled = true;
995 bitmap = { ":actions/build.png" };
996 bool NotifySelect(MenuItem selection, Modifiers mods)
1000 if(projectView.buildInProgress == none)
1001 projectView.ProjectBuild(projectView.active ? selection : null, mods);
1003 projectView.stopBuild = true;
1008 MenuItem projectLinkItem
1010 projectMenu, $"Relink", l, disabled = true;
1011 bitmap = { ":actions/relink.png" };
1012 bool NotifySelect(MenuItem selection, Modifiers mods)
1015 projectView.ProjectLink(projectView.active ? selection : null, mods);
1019 MenuItem projectRebuildItem
1021 projectMenu, $"Rebuild", d, shiftF7, disabled = true;
1022 bitmap = { ":actions/rebuild.png" };
1023 bool NotifySelect(MenuItem selection, Modifiers mods)
1026 projectView.ProjectRebuild(projectView.active ? selection : null, mods);
1030 MenuItem projectCleanTargetItem
1032 projectMenu, $"Clean Target", g, disabled = true;
1033 bitmap = { ":actions/clean.png" };
1034 bool NotifySelect(MenuItem selection, Modifiers mods)
1039 projectView.ProjectCleanTarget(projectView.active ? selection : null, mods);
1044 MenuItem projectCleanItem
1046 projectMenu, $"Clean", e, disabled = true;
1047 bitmap = { ":actions/clean.png" };
1048 bool NotifySelect(MenuItem selection, Modifiers mods)
1053 projectView.ProjectClean(projectView.active ? selection : null, mods);
1058 MenuItem projectRealCleanItem
1060 projectMenu, $"Real Clean", disabled = true;
1061 bitmap = { ":actions/clean.png" };
1062 bool NotifySelect(MenuItem selection, Modifiers mods)
1067 projectView.ProjectRealClean(projectView.active ? selection : null, mods);
1072 MenuItem projectRegenerateItem
1074 projectMenu, $"Regenerate Makefile", m, disabled = true;
1075 bitmap = { ":actions/regMakefile.png" };
1076 bool NotifySelect(MenuItem selection, Modifiers mods)
1079 projectView.ProjectRegenerate(projectView.active ? selection : null, mods);
1083 MenuItem projectCompileItem;
1084 Menu debugMenu { menu, $"Debug", d, hasMargin = true };
1085 MenuItem debugStartResumeItem
1087 debugMenu, $"Start", s, f5, disabled = true;
1088 bitmap = { ":actions/debug.png" };
1089 NotifySelect = MenuDebugStart;
1091 bool MenuDebugStart(MenuItem selection, Modifiers mods)
1095 debugStartResumeItem.disabled = true; // a very rare exception to calling AdjustDebugMenus
1096 if(!projectView.DebugStart())
1097 debugStartResumeItem.disabled = false; // same exception
1101 bool MenuDebugResume(MenuItem selection, Modifiers mods)
1104 projectView.DebugResume();
1107 MenuItem debugRestartItem
1109 debugMenu, $"Restart", r, Key { f5, ctrl = true, shift = true }, disabled = true;
1110 bitmap = { ":actions/restart.png" };
1111 bool NotifySelect(MenuItem selection, Modifiers mods)
1114 projectView.DebugRestart();
1118 MenuItem debugBreakItem
1120 debugMenu, $"Break", b, Key { pauseBreak, ctrl = true }, disabled = true;
1121 bitmap = { ":actions/pause.png" };
1122 bool NotifySelect(MenuItem selection, Modifiers mods)
1124 if(projectView && projectView.buildInProgress != none)
1127 projectView.DebugBreak();
1131 MenuItem debugStopItem
1133 debugMenu, $"Stop", p, shiftF5, disabled = true;
1134 bitmap = { ":actions/stopDebug.png" };
1135 bool NotifySelect(MenuItem selection, Modifiers mods)
1138 projectView.DebugStop();
1142 MenuDivider { debugMenu };
1143 MenuItem debugStepIntoItem
1145 debugMenu, $"Step Into", i, f11, disabled = true;
1146 bitmap = { ":actions/stepInto.png" };
1147 bool NotifySelect(MenuItem selection, Modifiers mods)
1150 projectView.DebugStepInto();
1154 MenuItem debugStepOverItem
1156 debugMenu, $"Step Over", v, f10, disabled = true;
1157 bitmap = { ":actions/stepOver.png" };
1158 bool NotifySelect(MenuItem selection, Modifiers mods)
1161 projectView.DebugStepOver(false);
1165 MenuItem debugStepOutItem
1167 debugMenu, $"Step Out", o, shiftF11, disabled = true;
1168 bitmap = { ":actions/stepOut.png" };
1169 bool NotifySelect(MenuItem selection, Modifiers mods)
1172 projectView.DebugStepOut(false);
1176 MenuPlacement debugRunToCursorItem { debugMenu, $"Run To Cursor", c };
1177 MenuItem debugSkipStepOverItem
1179 debugMenu, $"Step Over Skipping Breakpoints", e, shiftF10, disabled = true;
1180 bool NotifySelect(MenuItem selection, Modifiers mods)
1183 projectView.DebugStepOver(true);
1187 MenuItem debugSkipStepOutItem
1189 debugMenu, $"Step Out Skipping Breakpoints", t, Key { f11, ctrl = true, shift = true }, disabled = true;
1190 bitmap = { ":actions/skipBreaks.png" };
1191 bool NotifySelect(MenuItem selection, Modifiers mods)
1194 projectView.DebugStepOut(true);
1198 MenuPlacement debugSkipRunToCursorItem { debugMenu, $"Run To Cursor Skipping Breakpoints", u };
1199 //MenuDivider { debugMenu };
1200 //MenuPlacement debugToggleBreakpoint { debugMenu, "Toggle Breakpoint", t };
1201 MenuPlacement imageMenu { menu, $"Image", i };
1202 Menu viewMenu { menu, $"View", v };
1203 MenuItem viewProjectItem
1205 viewMenu, $"Project View", j, alt0, disabled = true;
1206 bool NotifySelect(MenuItem selection, Modifiers mods)
1210 projectView.visible = true;
1211 projectView.Activate();
1216 MenuPlacement { viewMenu, $"View Designer" };
1217 MenuPlacement { viewMenu, $"View Code" };
1218 MenuPlacement { viewMenu, $"View Properties" };
1219 MenuPlacement { viewMenu, $"View Methods" };
1220 MenuItem viewDesignerItem
1222 viewMenu, $"View Designer", d, f8;
1223 bool NotifySelect(MenuItem selection, Modifiers mods)
1225 Window client = activeClient;
1226 Class dataType = client._class;
1227 if(!strcmp(dataType.name, "Designer"))
1229 client.visible = true;
1233 ((CodeEditor)client).ViewDesigner();
1237 MenuItem viewCodeItem
1239 viewMenu, $"View Code", c, f8;
1240 bool NotifySelect(MenuItem selection, Modifiers mods)
1242 Window client = activeClient;
1243 Class dataType = client._class;
1244 if(!strcmp(dataType.name, "Designer"))
1245 client = ((Designer)client).codeEditor;
1248 // Do this after so the caret isn't moved yet...
1249 client.visible = true;
1253 MenuItem viewPropertiesItem
1255 viewMenu, $"View Properties", p, f4;
1256 bool NotifySelect(MenuItem selection, Modifiers mods)
1258 sheet.visible = true;
1259 sheet.sheetSelected = properties;
1264 MenuItem viewMethodsItem
1266 viewMenu, $"View Methods", m, f4;
1267 bool NotifySelect(MenuItem selection, Modifiers mods)
1269 sheet.visible = true;
1270 sheet.sheetSelected = methods;
1275 MenuItem viewToolBoxItem
1277 viewMenu, $"View Toolbox", x, f12;
1278 bool NotifySelect(MenuItem selection, Modifiers mods)
1280 toolBox.visible = true;
1285 MenuItem viewOutputItem
1287 viewMenu, $"Output", o, alt2;
1288 bool NotifySelect(MenuItem selection, Modifiers mods)
1294 MenuItem viewWatchesItem
1296 viewMenu, $"Watches", w, alt3;
1297 bool NotifySelect(MenuItem selection, Modifiers mods)
1303 MenuItem viewThreadsItem
1305 viewMenu, $"Threads", t, alt4;
1306 bool NotifySelect(MenuItem selection, Modifiers mods)
1312 MenuItem viewBreakpointsItem
1314 viewMenu, $"Breakpoints", b, alt5;
1315 bool NotifySelect(MenuItem selection, Modifiers mods)
1317 breakpointsView.Show();
1321 MenuItem viewCallStackItem
1323 viewMenu, $"Call Stack", s, alt7;
1324 bool NotifySelect(MenuItem selection, Modifiers mods)
1326 callStackView.Show();
1330 MenuItem viewAllDebugViews
1332 viewMenu, $"All Debug Views", a, alt9;
1333 bool NotifySelect(MenuItem selection, Modifiers mods)
1338 callStackView.Show();
1339 breakpointsView.Show();
1343 #ifdef GDB_DEBUG_GUI
1344 MenuDivider { viewMenu };
1345 MenuItem viewGDBItem
1347 viewMenu, $"GDB Dialog", g, Key { f9, shift = true, ctrl = true };
1348 bool NotifySelect(MenuItem selection, Modifiers mods)
1355 MenuDivider { viewMenu };
1356 MenuItem viewColorPicker
1358 viewMenu, $"Color Picker...", c, Key { c, ctrl = true , shift = true };
1359 bool NotifySelect(MenuItem selection, Modifiers mods)
1361 ColorPicker colorPicker { master = this };
1362 colorPicker.Modal();
1366 MenuDivider { viewMenu };
1370 viewMenu, "Full Screen", f, checkable = true;
1372 bool NotifySelect(MenuItem selection, Modifiers mods)
1374 app.fullScreen ^= true;
1376 anchor = { 0, 0, 0, 0 };
1381 Menu driversMenu { viewMenu, $"Graphics Driver", v };
1382 //Menu skinsMenu { viewMenu, "GUI Skins", k };
1383 Menu windowMenu { menu, $"Window", w };
1384 MenuItem { windowMenu, $"Close All", l, NotifySelect = MenuWindowCloseAll };
1385 MenuDivider { windowMenu };
1386 MenuItem { windowMenu, $"Next", n, f6, NotifySelect = MenuWindowNext };
1387 MenuItem { windowMenu, $"Previous", p, shiftF6, NotifySelect = MenuWindowPrevious };
1388 MenuDivider { windowMenu };
1389 MenuItem { windowMenu, $"Cascade", c, NotifySelect = MenuWindowCascade };
1390 MenuItem { windowMenu, $"Tile Horizontally", h, NotifySelect = MenuWindowTileHorz };
1391 MenuItem { windowMenu, $"Tile Vertically", v, NotifySelect = MenuWindowTileVert };
1392 MenuItem { windowMenu, $"Arrange Icons", a, NotifySelect = MenuWindowArrangeIcons };
1393 MenuDivider { windowMenu };
1394 MenuItem { windowMenu, $"Windows...", w, NotifySelect = MenuWindowWindows };
1395 Menu helpMenu { menu, $"Help", h };
1398 helpMenu, $"API Reference", r, f1;
1399 bool NotifySelect(MenuItem selection, Modifiers mods)
1401 char * p = new char[MAX_LOCATION];
1403 strncpy(p, settingsContainer.moduleLocation, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
1404 PathCat(p, "documentor");
1405 #if defined(__WIN32__)
1406 ChangeExtension(p, "exe", p);
1408 if(FileExists(p).isFile)
1411 Execute("documentor");
1416 MenuDivider { helpMenu };
1419 helpMenu, $"Ecere Tao of Programming [work in progress]", t;
1420 bool NotifySelect(MenuItem selection, Modifiers mods)
1422 FindAndShellOpenInstalledFile("doc", "Ecere Tao of Programming [work in progress].pdf");
1426 MenuDivider { helpMenu };
1429 helpMenu, $"Documentation Folder", d;
1430 bool NotifySelect(MenuItem selection, Modifiers mods)
1432 FindAndShellOpenInstalledFolder("doc");
1438 helpMenu, $"Samples Folder", s;
1439 bool NotifySelect(MenuItem selection, Modifiers mods)
1441 FindAndShellOpenInstalledFolder("samples");
1447 helpMenu, $"Extras Folder", x;
1448 bool NotifySelect(MenuItem selection, Modifiers mods)
1450 FindAndShellOpenInstalledFolder("extras");
1454 MenuDivider { helpMenu };
1457 helpMenu, $"Community Forums", f;
1458 bool NotifySelect(MenuItem selection, Modifiers mods)
1460 ShellOpen("http://ecere.com/forums");
1464 MenuDivider { helpMenu };
1467 helpMenu, $"About...", a;
1468 bool NotifySelect(MenuItem selection, Modifiers mods)
1470 AboutIDE { master = this }.Modal();
1475 property ToolBox toolBox
1477 get { return toolBox; }
1480 property Sheet sheet
1482 get { return sheet; }
1485 property Project project
1487 get { return projectView ? projectView.project : null; }
1490 property Workspace workspace
1492 get { return projectView ? projectView.workspace : null; }
1495 FindInFilesDialog findInFilesDialog
1498 filters = findInFilesFileFilters.array, sizeFilters = findInFilesFileFilters.count * sizeof(FileFilter);
1504 #ifdef GDB_DEBUG_GUI
1507 master = this, parent = this;
1508 anchor = { left = 100, top = 100, right = 100, bottom = 100 };
1510 void OnCommand(char * string)
1513 ide.debugger.SendGDBCommand(string);
1518 bool NotifySelectDisplayDriver(MenuItem selection, Modifiers mods)
1520 //app.driver = app.drivers[selection.id];
1521 #if defined(__unix__) || defined(__APPLE__)
1522 app.driver = selection.id ? "OpenGL" : "X";
1524 app.driver = selection.id ? "OpenGL" : "GDI";
1526 delete ideSettings.displayDriver;
1527 ideSettings.displayDriver = CopyString(selection.id ? "OpenGL" : "Default");
1529 settingsContainer.Save();
1530 //SetDriverAndSkin();
1534 bool NotifySelectDisplaySkin(MenuItem selection, Modifiers mods)
1536 app.skin = app.skins[selection.id];
1541 void SetDriverAndSkin()
1544 for(c = 0; c < app.numSkins; c++)
1545 if(!strcmp(app.skins[c], app.skin))
1547 skinItems[c].checked = true;
1550 for(c = 0; c < app.numDrivers; c++)
1551 if(!strcmp(app.drivers[c], app.driver))
1553 driverItems[c].checked = true;
1558 ProjectView CreateProjectView(Workspace workspace, char * fileName)
1560 Project project = workspace.projects.firstIterator.data;
1561 projectView = ProjectView
1564 fileName = fileName;
1566 void NotifyDestroyed(Window window, DialogResult result)
1569 text = titleECEREIDE;
1574 projectView.Create();
1575 RepositionWindows(false);
1577 // Leave it after Create to avoid flicker due to seeing IDE without a project view
1578 projectView.workspace = workspace;
1579 projectView.project = project;
1580 ideMainFrame.SetText("%s - %s", project.topNode.name, titleECEREIDE);
1584 ide.breakpointsView.LoadFromWorkspace();
1585 ide.watchesView.LoadFromWorkspace();
1587 findInFilesDialog.projectNodeField.userData = projectView;
1590 char fileName[MAX_LOCATION];
1591 strcpy(fileName, project.topNode.path);
1592 PathCat(fileName, project.topNode.name);
1597 void RepositionWindows(bool expand)
1602 bool inDebugMode = debugger.isActive;
1603 bool callStackVisible = expand ? false : callStackView.visible;
1604 bool threadsVisible = expand ? false : threadsView.visible;
1605 bool watchesVisible = expand ? false : watchesView.visible;
1606 bool breakpointsVisible = expand ? false : breakpointsView.visible;
1607 bool toolBoxVisible = toolBox.visible;
1608 bool outputVisible = expand ? false : outputView.visible;
1609 int topDistance = (callStackVisible || threadsVisible) ? 200 : 0;
1610 int bottomDistance = (outputVisible || watchesVisible || breakpointsVisible) ? 240 : 0;
1612 for(child = firstChild; child; child = child.next)
1614 if(child._class == class(CodeEditor) || child._class == class(Designer) ||
1615 child._class == class(Sheet) || child._class == class(ProjectView))
1617 Anchor anchor = child.anchor;
1618 anchor.top = topDistance;
1619 anchor.bottom = bottomDistance;
1620 if(child._class == class(CodeEditor) || child._class == class(Designer))
1622 anchor.right = toolBoxVisible ? 150 : 0;
1624 child.anchor = anchor;
1628 if(child._class == class(OutputView) || child._class == class(CallStackView) || child._class == class(ThreadsView) || child._class == class(WatchesView) ||
1629 child._class == class(BreakpointsView))
1630 child.visible = false;
1633 // If this is not here, the IDE is not updated when doing Debug/Break then Alt-4 to show call stack (IDE not updated)
1638 bool ShowCodeEditor()
1641 activeClient.Activate();
1642 else if(projectView)
1644 projectView.visible = true;
1645 projectView.Activate();
1649 sheet.visible = true;
1655 void DocumentSaved(Window document, char * fileName)
1657 ideSettings.AddRecentFile(fileName);
1658 ide.UpdateRecentMenus();
1659 ide.AdjustFileMenus();
1660 settingsContainer.Save();
1663 bool Window::OnFileModified(FileChange fileChange, char * param)
1666 sprintf(temp, $"The document %s was modified by another application.\n"
1667 "Would you like to reload it and lose your changes?", this.fileName);
1668 if(MessageBox { type = yesNo, master = this/*.parent*/,
1669 text = $"Document has been modified", contents = temp }.Modal() == yes)
1671 bool noParsing = (this._class == class(CodeEditor) && ((CodeEditor)this).noParsing) ? true : false;
1672 char * fileName = CopyString(this.fileName);
1673 WindowState state = this.state;
1674 Anchor anchor = this.anchor;
1675 Size size = this.size;
1677 this.modifiedDocument = false;
1679 this = ide.OpenFile(fileName, normal, true, null, no, normal, noParsing);
1682 this.anchor = anchor;
1684 this.SetState(state, true, 0);
1692 void UpdateMakefiles()
1696 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
1697 for(prj : workspace.projects)
1698 projectView.ProjectUpdateMakefileForAllConfigs(prj);
1703 void UpdateCompilerConfigs(bool mute)
1705 UpdateToolBarActiveCompilers();
1708 bool silent = mute || (ide.projectView.buildInProgress == none ? false : true);
1709 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
1712 projectView.ShowOutputBuildLog(true);
1713 projectView.DisplayCompiler(compiler, false);
1715 for(prj : workspace.projects)
1716 projectView.ProjectPrepareCompiler(prj, compiler, silent);
1721 void UpdateToolBarActiveCompilers()
1723 toolBar.activeCompiler.Clear();
1724 for(compiler : ideSettings.compilerConfigs)
1726 DataRow row = toolBar.activeCompiler.AddString(compiler.name);
1727 if(workspace && workspace.compiler && !strcmp(compiler.name, workspace.compiler))
1728 toolBar.activeCompiler.currentRow = row;
1730 if(!toolBar.activeCompiler.currentRow && toolBar.activeCompiler.firstRow)
1731 toolBar.activeCompiler.SelectRow(toolBar.activeCompiler.firstRow);
1734 void UpdateToolBarActiveConfigs(bool selectionOnly)
1736 bool commonSelected = false;
1737 DataRow row = toolBar.activeConfig.currentRow;
1739 row = toolBar.activeConfig.FindRow(1);
1742 toolBar.activeConfig.Clear();
1743 row = toolBar.activeConfig.AddString("(Mixed)");
1748 char * configName = null;
1751 Map<String, int> configs { }; // TOIMP: just need sort but using map until containers have sort
1752 for(prj : workspace.projects)
1754 for(cfg : prj.configurations)
1757 configs[cfg.name] = 1;
1762 toolBar.activeConfig.AddString(&name);
1766 if(projectView && projectView.project)
1768 for(prj : workspace.projects)
1770 if(prj.config && prj.config.name)
1772 configName = prj.config.name;
1778 commonSelected = true;
1779 for(prj : workspace.projects)
1781 if(prj.config && (!prj.config.name || strcmp(prj.config.name, configName)))
1783 commonSelected = false;
1791 commonSelected = false;
1792 for(row = toolBar.activeConfig.firstRow; row; row = row.next)
1794 if(!strcmp(row.string, configName))
1796 toolBar.activeConfig.currentRow = row;
1797 commonSelected = true;
1804 toolBar.activeConfig.Sort(null, 0);
1806 toolBar.activeConfig.currentRow = row;
1811 bool unavailable = !project;
1813 projectAddItem.disabled = unavailable;
1814 toolBar.buttonAddProject.disabled = unavailable;
1816 projectSettingsItem.disabled = unavailable;
1818 projectBrowseFolderItem.disabled = unavailable;
1820 viewProjectItem.disabled = unavailable;
1822 toolBar.activeConfig.disabled = unavailable;
1823 toolBar.activeCompiler.disabled = unavailable;
1824 toolBar.activeBitDepth.disabled = unavailable;
1831 property bool hasOpenedCodeEditors
1836 for(w = firstChild; w; w = w.next)
1837 if(w._class == class(CodeEditor) &&
1838 w.isDocument && !w.closing && w.visible && w.created &&
1839 w.fileName && w.fileName[0])
1845 void AdjustFileMenus()
1847 bool unavailable = project != null || !hasOpenedCodeEditors; // are they supported source code (ec, c, cpp, etc) ?
1849 projectQuickItem.disabled = unavailable;
1852 void AdjustBuildMenus()
1854 bool unavailable = project && projectView.buildInProgress;
1856 projectNewItem.disabled = unavailable;
1857 toolBar.buttonNewProject.disabled = unavailable;
1858 projectOpenItem.disabled = unavailable;
1859 toolBar.buttonOpenProject.disabled = unavailable;
1861 unavailable = !project || projectView.buildInProgress;
1863 projectCloseItem.disabled = unavailable;
1864 // toolBar.buttonCloseProject.disabled = unavailable;
1866 projectRunItem.disabled = unavailable || project.GetTargetType(project.config) != executable;
1867 toolBar.buttonRun.disabled = unavailable || project.GetTargetType(project.config) != executable;
1869 projectBuildItem.disabled = false;
1870 projectBuildItem.text = unavailable ? $"Stop Build" : $"Build";
1871 projectBuildItem.accelerator = unavailable ? Key { pauseBreak, ctrl = true } : f7;
1873 projectLinkItem.disabled = unavailable;
1874 toolBar.buttonReLink.disabled = unavailable;
1875 projectRebuildItem.disabled = unavailable;
1876 toolBar.buttonRebuild.disabled = unavailable;
1877 projectCleanItem.disabled = unavailable;
1878 toolBar.buttonClean.disabled = unavailable;
1879 projectCleanTargetItem.disabled = unavailable;
1880 projectRealCleanItem.disabled = unavailable;
1881 // toolBar.buttonRealClean.disabled = unavailable;
1882 projectRegenerateItem.disabled = unavailable;
1883 toolBar.buttonRegenerateMakefile.disabled = unavailable;
1884 projectCompileItem.disabled = unavailable;
1886 AdjustPopupBuildMenus();
1889 void AdjustPopupBuildMenus()
1891 bool unavailable = !project || projectView.buildInProgress;
1893 if(projectView && projectView.popupMenu && projectView.popupMenu.menu && projectView.popupMenu.created)
1896 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectBuild, 0);
1899 menu.disabled = false;
1900 menu.text = unavailable ? $"Stop Build" : $"Build";
1901 menu.accelerator = unavailable ? Key { pauseBreak, ctrl = true } : f7;
1904 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectLink, 0); if(menu) menu.disabled = unavailable;
1905 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRebuild, 0); if(menu) menu.disabled = unavailable;
1906 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectCleanTarget, 0); if(menu) menu.disabled = unavailable;
1907 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectClean, 0); if(menu) menu.disabled = unavailable;
1908 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRealClean, 0); if(menu) menu.disabled = unavailable;
1909 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRegenerate, 0); if(menu) menu.disabled = unavailable;
1910 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRemove, 0); if(menu) menu.disabled = unavailable;
1911 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileClean, 0); if(menu) menu.disabled = unavailable;
1912 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileCompile, 0); if(menu) menu.disabled = unavailable;
1913 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugPrecompile, 0); if(menu) menu.disabled = unavailable;
1914 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugCompile, 0); if(menu) menu.disabled = unavailable;
1915 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugGenerateSymbols, 0); if(menu) menu.disabled = unavailable;
1916 projectView.popupMenu.Update(null);
1920 property bool areDebugMenusUnavailable { get {
1922 project.GetTargetType(project.config) != executable ||
1923 projectView.buildInProgress == buildingMainProject;
1926 property bool isBreakpointTogglingUnavailable { get {
1930 property bool isDebuggerExecuting { get {
1934 return ide.debugger.state == running;
1937 void AdjustDebugMenus()
1939 bool unavailable = areDebugMenusUnavailable;
1940 bool active = debugger.isActive;
1941 bool bpNoToggle = isBreakpointTogglingUnavailable;
1942 bool executing = isDebuggerExecuting;
1943 //bool holding = debugger.state == stopped;
1945 debugStartResumeItem.disabled = unavailable || executing;
1946 debugStartResumeItem.text = active ? $"Resume" : $"Start";
1947 debugStartResumeItem.NotifySelect = active ? MenuDebugResume : MenuDebugStart;
1950 toolBar.buttonDebugStartResume.disabled = unavailable || executing;
1951 toolBar.buttonDebugStartResume.toolTip = active ? $"Resume" : $"Start";
1954 debugBreakItem.disabled = unavailable || !executing;
1955 debugStopItem.disabled = unavailable || !active;
1956 debugRestartItem.disabled = unavailable || !active;
1959 toolBar.buttonDebugPause.disabled = unavailable || !executing;
1960 toolBar.buttonDebugStop.disabled = unavailable || !active;
1961 toolBar.buttonDebugRestart.disabled = unavailable || !active;
1964 debugStepIntoItem.disabled = unavailable || executing;
1965 debugStepOverItem.disabled = unavailable || executing;
1966 debugStepOutItem.disabled = unavailable || executing || !active;
1967 debugSkipStepOverItem.disabled = unavailable || executing;
1968 debugSkipStepOutItem.disabled = unavailable || executing || !active;
1971 toolBar.buttonDebugStepInto.disabled = unavailable || executing;
1972 toolBar.buttonDebugStepOver.disabled = unavailable || executing;
1973 toolBar.buttonDebugStepOut.disabled = unavailable || executing || !active;
1974 toolBar.buttonDebugSkipStepOver.disabled = unavailable || executing;
1975 // toolBar.buttonDebugSkipStepOutItem.disabled = unavailable || executing;
1977 if((Designer)GetActiveDesigner())
1979 CodeEditor codeEditor = ((Designer)GetActiveDesigner()).codeEditor;
1981 codeEditor.AdjustDebugMenus(unavailable, bpNoToggle, executing);
1985 void ChangeFileDialogsDirectory(char * directory, bool saveSettings)
1987 char tempString[MAX_LOCATION];
1988 strcpy(tempString, directory);
1989 if(saveSettings && !projectView)
1991 ideSettings.ideFileDialogLocation = directory;
1992 settingsContainer.Save();
1995 ideFileDialog.currentDirectory = tempString;
1996 codeEditorFileDialog.currentDirectory = tempString;
1997 codeEditorFormFileDialog.currentDirectory = tempString;
2000 void ChangeProjectFileDialogDirectory(char * directory)
2002 ideSettings.ideProjectFileDialogLocation = directory;
2003 settingsContainer.Save();
2006 Window FindWindow(char * filePath)
2008 Window document = null;
2010 // TOCHECK: Do we need to change slashes here?
2011 for(document = firstChild; document; document = document.next)
2013 char * fileName = document.fileName;
2014 if(document.isDocument && fileName && !fstrcmp(fileName, filePath))
2016 document.visible = true;
2017 document.Activate();
2024 bool DontTerminateDebugSession(char * title)
2026 if(debugger.isActive)
2028 if(MessageBox { type = yesNo, master = ide,
2029 contents = $"Do you want to terminate the debugging session in progress?",
2030 text = title }.Modal() == no)
2033 MessageBox msg { type = yesNo, master = ide,
2034 contents = "Do you want to terminate the debugging session in progress?",
2036 if(msg.Modal() == no)
2048 Window OpenFile(char * origFilePath, WindowState state, bool visible, char * type, OpenCreateIfFails createIfFails, OpenMethod openMethod, bool noParsing)
2050 char extension[MAX_EXTENSION] = "";
2051 Window document = null;
2052 bool isProject = false;
2053 bool needFileModified = true;
2054 char winFilePath[MAX_LOCATION];
2055 char * filePath = strstr(origFilePath, "http://") == origFilePath ? strcpy(winFilePath, origFilePath) : GetSystemPathBuffer(winFilePath, origFilePath);
2059 GetExtension(filePath, extension);
2063 strcpy(extension, type);
2065 if(strcmp(extension, ProjectExtension))
2067 for(document = firstChild; document; document = document.next)
2069 char * fileName = document.fileName;
2070 if(document.isDocument && fileName && !fstrcmp(fileName, filePath) && document.created)
2072 document.visible = true;
2074 document.Activate();
2080 if(createIfFails == whatever)
2082 else if(!strcmp(extension, ProjectExtension) || !strcmp(extension, WorkspaceExtension))
2084 needFileModified = false;
2085 if(openMethod == normal)
2087 if(DontTerminateDebugSession($"Open Project"))
2090 if(MenuWindowCloseAll(null, 0))
2094 projectView.visible = false;
2095 projectView.Destroy(0);
2096 // Where did this come from? projectView = null;
2103 Workspace workspace = null;
2105 if(FileExists(filePath))
2107 if(!strcmp(extension, ProjectExtension))
2109 char workspaceFile[MAX_LOCATION];
2110 strcpy(workspaceFile, filePath);
2111 ChangeExtension(workspaceFile, WorkspaceExtension, workspaceFile);
2112 workspace = LoadWorkspace(workspaceFile, filePath);
2114 else if(!strcmp(extension, WorkspaceExtension))
2115 workspace = LoadWorkspace(filePath, null);
2118 //project = LoadProject(filePath, null);
2123 char absolutePath[MAX_LOCATION];
2124 CreateProjectView(workspace, filePath);
2125 document = projectView;
2127 workspace.DropInvalidBreakpoints();
2130 ide.projectView.ShowOutputBuildLog(true);
2132 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
2133 ide.projectView.DisplayCompiler(compiler, false);
2136 UpdateCompilerConfigs(false);
2139 char newWorkingDir[MAX_LOCATION];
2140 StripLastDirectory(filePath, newWorkingDir);
2141 ChangeFileDialogsDirectory(newWorkingDir, false);
2144 document.fileName = filePath;
2146 ideMainFrame.SetText("%s - %s", filePath, titleECEREIDE);
2148 // this crashes on starting ide with epj file, solution please?
2149 // app.UpdateDisplay();
2151 workspace.holdTracking = true;
2152 for(ofi : workspace.openedFiles)
2154 if(ofi.state != closed)
2156 Window file = OpenFile(ofi.path, normal, true, null, no, normal, noParsing);
2159 char fileName[MAX_LOCATION];
2161 GetLastDirectory(ofi.path, fileName);
2162 node = projectView.project.topNode.Find(fileName, true);
2164 node.EnsureVisible();
2168 workspace.holdTracking = false;
2170 workspace.timer.Start();
2172 findInFilesDialog.mode = FindInFilesMode::project;
2173 findInFilesDialog.currentDirectory = ide.project.topNode.path;
2176 char location[MAX_LOCATION];
2177 StripLastDirectory(ide.project.topNode.path, location);
2178 ChangeProjectFileDialogDirectory(location);
2182 if(projectView.debugger)
2183 projectView.debugger.EvaluateWatches();
2190 if(MessageBox { type = yesNo, master = this, text = $"Error opening project", contents = $"Open a different project?" }.Modal() == yes)
2192 ideProjectFileDialog.text = openProjectFileDialogTitle;
2193 if(ideProjectFileDialog.Modal() == cancel)
2195 filePath = ideProjectFileDialog.filePath;
2196 GetExtension(filePath, extension);
2207 else if(openMethod == add)
2212 char slashFilePath[MAX_LOCATION];
2213 GetSlashPathBuffer(slashFilePath, filePath);
2214 for(p : workspace.projects)
2216 if(!fstrcmp(p.filePath, slashFilePath))
2224 MessageBox { type = ok, parent = parent, master = this, text = $"Same Project",
2225 contents = $"This project is already present in workspace." }.Modal();
2229 prj = LoadProject(filePath, null);
2232 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
2233 prj.StartMonitoring();
2234 workspace.projects.Add(prj);
2236 projectView.AddNode(prj.topNode, null);
2237 workspace.modified = true;
2239 findInFilesDialog.AddProjectItem(prj);
2240 projectView.ShowOutputBuildLog(true);
2241 projectView.DisplayCompiler(compiler, false);
2242 projectView.ProjectUpdateMakefileForAllConfigs(prj);
2246 char location[MAX_LOCATION];
2247 StripLastDirectory(prj.topNode.path, location);
2248 ChangeProjectFileDialogDirectory(location);
2251 // projectView is associated with the main project and not with the one just added but
2252 return projectView; // just to let the caller know something was opened
2260 else if(!strcmp(extension, "bmp") || !strcmp(extension, "pcx") ||
2261 !strcmp(extension, "jpg") || !strcmp(extension, "gif") ||
2262 !strcmp(extension, "jpeg") || !strcmp(extension, "png"))
2264 if(FileExists(filePath))
2265 document = PictureEdit { hasMaximize = true, hasMinimize = true, hasClose = true, borderStyle = sizable,
2266 hasVertScroll = true, hasHorzScroll = true, parent = this, state = state,
2267 visible = visible, bitmapFile = filePath, OnClose = PictureEditOnClose/*why?--GenericDocumentOnClose*/;
2270 MessageBox { type = ok, master = this, text = filePath, contents = $"File doesn't exist." }.Modal();
2273 else if(!strcmp(extension, "3ds"))
2275 if(FileExists(filePath))
2276 document = ModelView { hasMaximize = true, hasMinimize = true, hasClose = true, borderStyle = sizable,
2277 hasVertScroll = true, hasHorzScroll = true, parent = this, state = state,
2278 visible = visible, modelFile = filePath, OnClose = ModelViewOnClose/*why?--GenericDocumentOnClose*/
2282 MessageBox { type = ok, master = this, text = filePath, contents = $"File doesn't exist." }.Modal();
2285 else if(!strcmp(extension, "txt") || !strcmp(extension, "text") ||
2286 !strcmp(extension, "nfo") || !strcmp(extension, "info") ||
2287 !strcmp(extension, "htm") || !strcmp(extension, "html") ||
2288 !strcmp(extension, "css") || !strcmp(extension, "php") ||
2289 !strcmp(extension, "js"))
2291 CodeEditor editor { parent = this, state = state, visible = false, noParsing = noParsing };
2292 editor.updatingCode = true;
2293 if(editor.LoadFile(filePath))
2296 editor.visible = true;
2300 needFileModified = false;
2304 CodeEditor editor { parent = this, state = state, visible = false, noParsing = noParsing };
2305 if(editor.LoadFile(filePath))
2308 editor.visible = true;
2312 needFileModified = false;
2315 if(document && (document._class == class(PictureEdit) ||
2316 document._class == class(ModelView)))
2321 document.fileName = filePath;
2322 if(workspace && !workspace.holdTracking)
2323 workspace.UpdateOpenedFileInfo(filePath, opened);
2327 if(!document && createIfFails != no)
2329 if(createIfFails != yes && !needFileModified &&
2330 MessageBox { type = yesNo, master = this, text = filePath, contents = $"File doesn't exist. Create?" }.Modal() == yes)
2331 createIfFails = yes;
2332 if(createIfFails == yes || createIfFails == whatever)
2334 document = (Window)NewCodeEditor(this, state, true);
2336 document.fileName = filePath;
2342 if(projectView && document._class == class(CodeEditor) && workspace)
2344 int lineNumber, position;
2346 CodeEditor editor = (CodeEditor)document;
2347 editor.openedFileInfo = workspace.UpdateOpenedFileInfo(filePath, opened);
2348 editor.openedFileInfo.holdTracking = true;
2349 lineNumber = Max(editor.openedFileInfo.lineNumber - 1, 0);
2350 position = Max(editor.openedFileInfo.position - 1, 0);
2351 editor.editBox.GoToLineNum(lineNumber);
2352 editor.editBox.GoToPosition(editor.editBox.line, lineNumber, position);
2353 scroll.x = Max(editor.openedFileInfo.scroll.x, 0);
2354 scroll.y = Max(editor.openedFileInfo.scroll.y, 0);
2355 editor.editBox.scroll = scroll;
2356 editor.openedFileInfo.holdTracking = false;
2359 if(needFileModified)
2360 document.OnFileModified = OnFileModified;
2361 document.NotifySaved = DocumentSaved;
2364 ideSettings.AddRecentProject(document.fileName);
2366 ideSettings.AddRecentFile(document.fileName);
2367 ide.UpdateRecentMenus();
2368 ide.AdjustFileMenus();
2369 settingsContainer.Save();
2377 // TOCHECK: I can't use a generic one for both ModelView and PictureEdit both derived from Window
2378 /*bool Window::GenericDocumentOnClose(bool parentClosing)
2380 if(!parentClosing && ide.workspace)
2381 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2384 bool ModelView::ModelViewOnClose(bool parentClosing)
2386 if(!parentClosing && ide.workspace)
2387 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2390 bool PictureEdit::PictureEditOnClose(bool parentClosing)
2392 if(!parentClosing && ide.workspace)
2393 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2398 void OnUnloadGraphics(Window window)
2400 display.ClearMaterials();
2401 display.ClearTextures();
2402 display.ClearMeshes();
2406 bool OnActivate(bool active, Window swap, bool * goOnWithActivation, bool direct)
2408 caps.color = app.GetKeyState(capsState) ? black : Color { 128,128,128 };
2409 num.color = app.GetKeyState(numState) ? black : Color { 128,128,128 };
2413 bool OnKeyDown(Key key, unichar ch)
2418 projectView.Update(null);
2421 caps.color = app.GetKeyState(capsState) ? black : Color { 128,128,128 };
2424 num.color = app.GetKeyState(numState) ? black : Color { 128,128,128 };
2430 void GoToError(const char * line, bool noParsing)
2433 projectView.GoToError(line, noParsing);
2436 void CodeLocationParseAndGoTo(const char * text, Project project, const char * dir)
2439 char *colon = strchr(text, ':');
2440 char filePath[MAX_LOCATION];
2441 char completePath[MAX_LOCATION];
2442 int line = 0, col = 0;
2444 FileAttribs fileAttribs;
2446 if(colon && (colon[1] == '/' || colon[1] == '\\'))
2448 path = (colon - 1 > path) ? colon - 1 : path;
2449 colon = strstr(colon + 1, ":");
2451 while(isspace(*path)) path++;
2454 char * close = strchr(path, ')');
2458 strncpy(name, path+1, close - path - 1);
2459 name[close - path - 1] = '\0';
2460 for(p : ide.workspace.projects)
2462 if(!strcmp(p.name, name))
2472 prj = project ? project : (dir ? null : ide.project);
2475 strncpy(filePath, path, colon - path);
2476 filePath[colon - path] = '\0';
2477 line = atoi(colon + 1);
2478 colon = strstr(colon + 1, ":");
2480 col = atoi(colon + 1);
2482 else if(path - 1 >= text && *(path - 1) == '\"')
2484 colon = strchr(path, '\"');
2487 strncpy(filePath, path, colon - path);
2488 filePath[colon - path] = '\0';
2491 else if(path && !colon)
2493 strcpy(filePath, path);
2497 strcpy(completePath, prj.topNode.path);
2498 else if(dir && dir[0])
2499 strcpy(completePath, dir);
2501 completePath[0] = '\0';
2502 PathCat(completePath, filePath);
2504 fileAttribs = FileExists(completePath);
2505 if(fileAttribs.isFile)
2507 CodeEditor codeEditor = (CodeEditor)OpenFile(completePath, normal, true, "", no, normal, false);
2508 if(codeEditor && line)
2510 EditBox editBox = codeEditor.editBox;
2511 editBox.GoToLineNum(line - 1);
2512 editBox.GoToPosition(editBox.line, line - 1, col ? (col - 1) : 0);
2515 else if(fileAttribs.isDirectory)
2516 ShellOpen(completePath);
2519 void OnRedraw(Surface surface)
2521 Bitmap bitmap = back.bitmap;
2523 surface.Blit(bitmap, (clientSize.w - bitmap.width) / 2, (clientSize.h - bitmap.height) / 2, 0, 0, bitmap.width, bitmap.height);
2526 void SheetSelected(SheetType sheetSelected)
2528 if(activeChild == sheet)
2530 if(sheetSelected == methods)
2532 viewPropertiesItem.accelerator = f4;
2533 viewPropertiesItem.parent = viewMenu;
2534 viewMethodsItem.parent = null;
2538 viewMethodsItem.accelerator = f4;
2539 viewMethodsItem.parent = viewMenu;
2540 viewPropertiesItem.parent = null;
2545 viewMethodsItem.parent = viewMenu;
2546 viewPropertiesItem.parent = viewMenu;
2547 if(sheetSelected == methods)
2549 viewMethodsItem.accelerator = f4;
2550 viewPropertiesItem.accelerator = 0;
2554 viewMethodsItem.accelerator = 0;
2555 viewPropertiesItem.accelerator = f4;
2560 void OnActivateClient(Window client, Window previous)
2562 //if(!client || client != previous)
2565 if(!client || client != previous)
2568 dataType = previous._class;
2569 if(previous && !strcmp(dataType.name, "CodeEditor"))
2571 ((CodeEditor)previous).UpdateFormCode();
2573 else if(previous && !strcmp(dataType.name, "Designer"))
2575 ((Designer)previous).codeEditor.UpdateFormCode();
2580 dataType = client._class;
2581 if(client && !strcmp(dataType.name, "CodeEditor"))
2583 CodeEditor codeEditor = (CodeEditor)client;
2584 SetPrivateModule(codeEditor.privateModule);
2585 SetCurrentContext(codeEditor.globalContext);
2586 SetTopContext(codeEditor.globalContext);
2587 SetGlobalContext(codeEditor.globalContext);
2589 SetDefines(&codeEditor.defines);
2590 SetImports(&codeEditor.imports);
2592 SetActiveDesigner(codeEditor.designer);
2594 sheet.codeEditor = codeEditor;
2595 toolBox.codeEditor = codeEditor;
2597 viewDesignerItem.parent = viewMenu;
2598 if(activeChild != codeEditor)
2600 viewCodeItem.parent = viewMenu;
2601 viewDesignerItem.accelerator = 0;
2602 viewCodeItem.accelerator = f8;
2606 viewCodeItem.parent = null;
2607 viewDesignerItem.accelerator = f8;
2610 else if(client && !strcmp(dataType.name, "Designer"))
2612 CodeEditor codeEditor = ((Designer)client).codeEditor;
2615 SetPrivateModule(codeEditor.privateModule);
2616 SetCurrentContext(codeEditor.globalContext);
2617 SetTopContext(codeEditor.globalContext);
2618 SetGlobalContext(codeEditor.globalContext);
2619 SetDefines(&codeEditor.defines);
2620 SetImports(&codeEditor.imports);
2624 SetPrivateModule(null);
2625 SetCurrentContext(null);
2626 SetTopContext(null);
2627 SetGlobalContext(null);
2632 SetActiveDesigner((Designer)client);
2634 sheet.codeEditor = codeEditor;
2635 toolBox.codeEditor = codeEditor;
2637 viewCodeItem.parent = viewMenu;
2638 if(activeChild != client)
2640 viewDesignerItem.parent = viewMenu;
2641 viewDesignerItem.accelerator = f8;
2642 viewCodeItem.accelerator = 0;
2646 viewDesignerItem.parent = null;
2647 viewCodeItem.accelerator = f8;
2653 sheet.codeEditor = null;
2654 toolBox.codeEditor = null;
2655 SetActiveDesigner(null);
2657 viewDesignerItem.parent = null;
2658 viewCodeItem.parent = null;
2661 SheetSelected(sheet.sheetSelected);
2664 projectCompileItem = null;
2669 if(client && client._class == eSystem_FindClass(__thisModule, "CodeEditor")) // !strcmp(client._class.name, "CodeEditor")
2671 CodeEditor codeEditor = (CodeEditor)client;
2672 EditBox editBox = codeEditor.editBox;
2674 statusBar.AddField(pos);
2676 caps = { width = 40, text = $"CAPS", color = app.GetKeyState(capsState) ? black : Color { 128, 128, 128 } };
2677 statusBar.AddField(caps);
2679 ovr = { width = 30, text = $"OVR", color = (editBox && editBox.overwrite) ? black : Color { 128, 128, 128 } };
2680 statusBar.AddField(ovr);
2682 num = { width = 30, text = $"NUM", color = app.GetKeyState(numState) ? black : Color { 128, 128, 128 } };
2683 statusBar.AddField(num);
2685 //statusBar.text = "Ready";
2687 if(projectView && projectView.project)
2689 bool isCObject = false;
2690 ProjectNode node = projectView.GetNodeFromWindow(client, null, false);
2691 if(!node && (node = projectView.GetNodeFromWindow(client, null, true)))
2695 char nodeName[MAX_FILENAME];
2696 char name[MAX_FILENAME+96];
2698 ChangeExtension(node.name, "c", nodeName);
2699 sprintf(name, $"Compile %s", isCObject ? nodeName : node.name);
2700 projectCompileItem =
2702 copyText = true, text = name, c, ctrlF7, disabled = projectView.buildInProgress;
2704 bool NotifySelect(MenuItem selection, Modifiers mods)
2708 bool result = false;
2709 bool isCObject = false;
2710 ProjectNode node = null;
2711 for(p : ide.workspace.projects)
2713 node = projectView.GetNodeFromWindow(activeClient, p, false);
2716 if(!node && (node = projectView.GetNodeFromWindow(activeClient, null, true)))
2720 List<ProjectNode> nodes { };
2722 projectView.Compile(node.project, nodes, mods.ctrl && mods.shift, isCObject ? cObject : normal);
2727 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
2732 projectMenu.AddDynamic(projectCompileItem, ide, false);
2738 caps = ovr = num = null;
2743 bool OnClose(bool parentClosing)
2745 //return !projectView.buildInProgress;
2746 if(projectView && projectView.buildInProgress)
2748 if(DontTerminateDebugSession($"Close IDE"))
2750 if(findInFilesDialog)
2751 findInFilesDialog.SearchStop();
2754 workspace.timer.Stop();
2757 ideMainFrame.Destroy(0);
2764 bool passThrough = false;
2765 bool debugStart = false;
2766 bool debugWorkDir = false;
2767 char * passDebugWorkDir = null;
2768 bool openAsText = false;
2769 DynamicString passArgs { };
2770 for(c = 1; c<app.argc; c++)
2772 if(!strcmp(app.argv[c], "-t"))
2774 else if(!strcmp(app.argv[c], "-no-parsing"))
2775 ide.noParsing = true;
2776 else if(!strcmp(app.argv[c], "-debug-start"))
2778 else if(!strcmp(app.argv[c], "-debug-work-dir"))
2779 debugWorkDir = true;
2780 else if(!passThrough && !strcmp(app.argv[c], "-@"))
2782 else if(passThrough)
2784 passArgs.concat(" ");
2785 passArgs.concat(app.argv[c]);
2787 else if(debugWorkDir)
2789 passDebugWorkDir = CopyString(app.argv[c]);
2790 StripQuotes(passDebugWorkDir, passDebugWorkDir);
2791 debugWorkDir = false;
2795 char fullPath[MAX_LOCATION];
2796 char parentPath[MAX_LOCATION];
2797 char ext[MAX_EXTENSION];
2799 FileAttribs dirAttribs;
2800 GetWorkingDir(fullPath, MAX_LOCATION);
2801 PathCat(fullPath, app.argv[c]);
2802 StripLastDirectory(fullPath, parentPath);
2803 GetExtension(app.argv[c], ext);
2804 isProject = !openAsText && !strcmpi(ext, "epj");
2806 if(isProject && c > (debugStart ? 2 : 1)) continue;
2808 // Create directory for projects (only)
2809 if(((dirAttribs = FileExists(parentPath)) && dirAttribs.isDirectory) || isProject)
2811 if(isProject && !FileExists(fullPath))
2813 // The NewProject will handle directory creation
2814 /*if(!dirAttribs.isDirectory)
2816 MakeDir(parentPath);
2817 dirAttribs = FileExists(parentPath);
2819 if(dirAttribs.isDirectory)*/
2821 char name[MAX_LOCATION];
2822 NewProjectDialog newProjectDialog;
2826 projectView.visible = false;
2827 if(!projectView.Destroy(0))
2831 newProjectDialog = { master = this };
2833 strcpy(name, app.argv[c]);
2834 StripExtension(name);
2835 GetLastDirectory(name, name);
2836 newProjectDialog.projectName.contents = name;
2837 newProjectDialog.projectName.NotifyModified(newProjectDialog, newProjectDialog.projectName);
2838 newProjectDialog.locationEditBox.path = parentPath;
2839 newProjectDialog.NotifyModifiedLocation(newProjectDialog.locationEditBox);
2841 newProjectDialog.Modal();
2844 ideSettings.AddRecentProject(projectView.fileName);
2845 ide.UpdateRecentMenus();
2846 settingsContainer.Save();
2849 // Open only one project
2853 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, openAsText ? "txt" : null, yes, normal, false);
2855 else if(strstr(fullPath, "http://") == fullPath)
2856 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, openAsText ? "txt" : null, yes, normal, false);
2859 if(passThrough && projectView && projectView.project && workspace)
2861 char * fixSpacing = new char[Max(passArgs.size * 1.5, 32)];
2867 bool inQuote = false;
2868 for(c=0; c<passArgs.size; c++)
2871 if(inQuote && k != '\\' && l == ' ')
2873 fixSpacing[d++] = '\"';
2874 fixSpacing[d++] = ' ';
2877 else if(inQuote && l == '\0')
2879 fixSpacing[d++] = '\"';
2880 fixSpacing[d++] = '\0';
2883 else if(!inQuote && j != '\\' && k == ' ' && l != '-' && l != ' ')
2885 fixSpacing[d++] = '\"';
2886 fixSpacing[d++] = l;
2889 else if(k == '\\' && l == ' ')
2890 fixSpacing[d++] = ' ';
2891 else if(k == '\\' && l == '\\')
2892 fixSpacing[d++] = '\\';
2894 fixSpacing[d++] = l;
2898 fixSpacing[d] = '\0';
2900 workspace.commandLineArgs = fixSpacing;
2902 if(passDebugWorkDir)
2904 workspace.debugDir = passDebugWorkDir;
2905 delete passDebugWorkDir;
2908 ;//MenuDebugStart(debugStartResumeItem, 0); // <-- how TODO this without getting into the app.Wait lock
2910 UpdateToolBarActiveConfigs(false);
2911 UpdateToolBarActiveCompilers();
2918 // IS THIS NEEDED? WASN'T HERE BEFORE... Crashes on getting node's projectView otherwise
2921 projectView.visible = false;
2922 projectView.Destroy(0);
2925 #ifdef GDB_DEBUG_GUI
2926 gdbDialog.Destroy(0);
2931 void SetPath(bool projectsDirs, CompilerConfig compiler, ProjectConfig config, int bitDepth)
2935 char * oldPaths[128];
2936 String oldList = new char[maxPathLen];
2937 Array<String> newExePaths { };
2938 //Map<String, bool> exePathExists { };
2940 #if defined(__unix__) || defined(__APPLE__)
2941 Array<String> newLibPaths { };
2942 Map<String, bool> libPathExists { };
2947 for(prj : workspace.projects)
2949 DirExpression targetDirExp;
2951 // SKIP FIRST PROJECT...
2952 if(prj == workspace.projects.firstIterator.data) continue;
2954 // NOTE: Right now the additional project config dir will be
2955 // obtained when the debugger is started, so toggling it
2956 // while building will change which library gets used.
2957 // To go with the initial state, e.g. when F5 was pressed,
2958 // we nould need to keep a list of all project's active
2959 // config upon startup.
2960 targetDirExp = prj.GetTargetDir(compiler, prj.config, bitDepth);
2962 /*if(prj.config.targetType == sharedLibrary && prj.config.debug)
2966 for(cfg = prj.configurations.first; cfg; cfg = cfg.next)
2967 if(cfg.targetType == sharedLibrary && cfg.debug && !strcmpi(cfg.name, "Debug"))
2971 for(cfg = prj.configurations.first; cfg; cfg = cfg.next)
2972 if(cfg.targetType == sharedLibrary && cfg.debug)
2976 if(targetDirExp.dir)
2978 char buffer[MAX_LOCATION];
2979 #if defined(__WIN32__)
2980 Array<String> paths = newExePaths;
2982 Array<String> paths = newLibPaths;
2984 GetSystemPathBuffer(buffer, prj.topNode.path);
2985 PathCat(buffer, targetDirExp.dir);
2988 if(!fstrcmp(p, buffer))
2995 paths.Add(CopyString(buffer));
2997 delete targetDirExp;
3001 for(item : compiler.executableDirs)
3004 for(p : newExePaths)
3006 if(!fstrcmp(p, item))
3013 newExePaths.Add(CopySystemPath(item));
3016 GetEnvironment("PATH", oldList, maxPathLen);
3018 printf("Old value of PATH: %s\n", oldList);
3020 count = TokenizeWith(oldList, sizeof(oldPaths) / sizeof(char *), oldPaths, pathListSep, false);
3021 for(c = 0; c < count; c++)
3024 for(p : newExePaths)
3026 if(!fstrcmp(p, oldPaths[c]))
3033 newExePaths.Add(CopySystemPath(oldPaths[c]));
3037 for(path : newExePaths)
3038 len += strlen(path) + 1;
3039 newList = new char[len + 1];
3041 for(path : newExePaths)
3043 strcat(newList, path);
3044 strcat(newList, pathListSep);
3046 newList[len - 1] = '\0';
3047 SetEnvironment("PATH", newList);
3049 printf("New value of PATH: %s\n", newList);
3056 #if defined(__unix__) || defined(__APPLE__)
3058 for(item : compiler.libraryDirs)
3060 if(!libPathExists[item]) // fstrcmp should be used
3062 newLibPaths.Add(item);
3063 libPathExists[item] = true;
3067 #if defined(__APPLE__)
3068 GetEnvironment("DYLD_LIBRARY_PATH", oldList, maxPathLen);
3070 GetEnvironment("LD_LIBRARY_PATH", oldList, maxPathLen);
3073 printf("Old value of [DY]LD_LIBRARY_PATH: %s\n", oldList);
3075 count = TokenizeWith(oldList, sizeof(oldPaths) / sizeof(char *), oldPaths, pathListSep, false);
3076 for(c = 0; c < count; c++)
3078 if(!libPathExists[oldPaths[c]]) // fstrcmp should be used
3080 newLibPaths.Add(oldPaths[c]);
3081 libPathExists[oldPaths[c]] = true;
3086 for(path : newLibPaths)
3087 len += strlen(path) + 1;
3088 newList = new char[len + 1];
3090 for(path : newLibPaths)
3092 strcat(newList, path);
3093 strcat(newList, pathListSep);
3095 newList[len - 1] = '\0';
3096 #if defined(__APPLE__)
3097 SetEnvironment("DYLD_LIBRARY_PATH", newList);
3099 SetEnvironment("LD_LIBRARY_PATH", newList);
3102 printf("New value of [DY]LD_LIBRARY_PATH: %s\n", newList);
3107 delete libPathExists;
3110 if(compiler.distccEnabled && compiler.distccHosts)
3111 SetEnvironment("DISTCC_HOSTS", compiler.distccHosts);
3116 void DestroyTemporaryProjectDir()
3118 if(tmpPrjDir && tmpPrjDir[0])
3120 if(FileExists(tmpPrjDir).isDirectory)
3121 DestroyDir(tmpPrjDir);
3122 property::tmpPrjDir = null;
3128 // Graphics Driver Menu
3132 app.currentSkin.selectionColor = selectionColor;
3133 app.currentSkin.selectionText = selectionText;
3137 driverItems = new MenuItem[app.numDrivers];
3138 for(c = 0; c < app.numDrivers; c++)
3140 driverItems[c] = MenuItem { driversMenu, app.drivers[c], NotifySelect = NotifySelectDisplayDriver };
3141 driverItems[c].id = c;
3142 driverItems[c].isRadio = true;
3145 driverItems = new MenuItem[2];
3146 #if defined(__unix__)
3147 driverItems[0] = MenuItem { driversMenu, "X", NotifySelect = NotifySelectDisplayDriver };
3148 driverItems[0].id = 0;
3149 driverItems[0].isRadio = true;
3151 driverItems[0] = MenuItem { driversMenu, "GDI", NotifySelect = NotifySelectDisplayDriver };
3152 driverItems[0].id = 0;
3153 driverItems[0].isRadio = true;
3155 driverItems[1] = MenuItem { driversMenu, "OpenGL", NotifySelect = NotifySelectDisplayDriver };
3156 driverItems[1].id = 1;
3157 driverItems[1].isRadio = true;
3159 /* skinItems = new MenuItem[app.numSkins];
3160 for(c = 0; c < app.numSkins; c++)
3162 skinItems[c] = MenuItem {skinsMenu, app.skins[c], NotifySelect = NotifySelectDisplaySkin };
3163 skinItems[c].id = c;
3164 skinItems[c].isRadio = true;
3167 ideFileDialog.master = this;
3168 ideProjectFileDialog.master = this;
3170 //SetDriverAndSkin();
3174 void UpdateRecentMenus()
3177 Menu fileMenu = menu.FindMenu($"File");
3178 Menu recentFiles = fileMenu.FindMenu($"Recent Files");
3179 Menu recentProjects = fileMenu.FindMenu($"Recent Projects");
3180 char * itemPath = new char[MAX_LOCATION];
3181 char * itemName = new char[MAX_LOCATION+4];
3184 recentFiles.Clear();
3187 for(recent : ideSettings.recentFiles)
3189 strncpy(itemPath, recent, MAX_LOCATION); itemPath[MAX_LOCATION-1] = '\0';
3190 MakeSystemPath(itemPath);
3191 snprintf(itemName, MAX_LOCATION+4, "%d %s", 1 + c, itemPath); itemName[MAX_LOCATION+4-1] = '\0';
3192 recentFiles.AddDynamic(MenuItem { copyText = true, text = itemName, (Key)k1 + c, id = c, NotifySelect = ide.FileRecentFile }, ide, true);
3196 recentProjects.Clear();
3198 for(recent : ideSettings.recentProjects)
3200 strncpy(itemPath, recent, MAX_LOCATION); itemPath[MAX_LOCATION-1] = '\0';
3201 MakeSystemPath(itemPath);
3202 snprintf(itemName, MAX_LOCATION+4, "%d %s", 1 + c, itemPath); itemName[MAX_LOCATION+4-1] = '\0';
3203 recentProjects.AddDynamic(MenuItem { copyText = true, text = itemName, (Key)k1 + c, id = c, NotifySelect = ide.FileRecentProject }, ide, true);
3219 void DestroyDir(char * path)
3221 RecursiveDeleteFolderFSI fsi { };
3226 #if defined(__WIN32__)
3227 define sdkDirName = "Ecere SDK";
3229 define sdkDirName = "ecere";
3232 void FindAndShellOpenInstalledFolder(char * name)
3234 char * p = new char[MAX_LOCATION];
3235 char * v = new char[maxPathLen];
3238 Array<String> paths { };
3240 strncpy(p, settingsContainer.moduleLocation, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3241 StripLastDirectory(p, p);
3243 paths.Add(CopyString(p));
3244 #if defined(__WIN32__)
3245 GetEnvironment("ECERE_SDK_SRC", v, maxPathLen);
3248 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3249 PathCat(p, name); paths.Add(CopyString(p));
3251 GetEnvironment("AppData", v, maxPathLen);
3254 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3255 PathCat(p, sdkDirName); PathCat(p, name); paths.Add(CopyString(p));
3257 GetEnvironment("ProgramFiles", v, maxPathLen);
3260 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3261 PathCat(p, sdkDirName); PathCat(p, name); paths.Add(CopyString(p));
3263 GetEnvironment("ProgramFiles(x86)", v, maxPathLen);
3266 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3267 PathCat(p, sdkDirName); PathCat(p, name); paths.Add(CopyString(p));
3269 GetEnvironment("SystemDrive", v, maxPathLen);
3272 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3273 PathCat(p, "Program Files"); PathCat(p, sdkDirName); PathCat(p, name); paths.Add(CopyString(p));
3276 GetEnvironment("XDG_DATA_DIRS", v, maxPathLen);
3277 numTokens = TokenizeWith(v, sizeof(tokens) / sizeof(byte *), tokens, ":", false);
3278 for(c=0; c<numTokens; c++)
3280 strncpy(p, tokens[c], MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3281 PathCat(p, sdkDirName); PathCat(p, name); paths.Add(CopyString(p));
3286 strncpy(p, path, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3287 if(FileExists(p).isDirectory)
3299 void FindAndShellOpenInstalledFile(char * subdir, char * name)
3301 char * p = new char[MAX_LOCATION];
3302 char * v = new char[maxPathLen];
3305 Array<String> paths { };
3307 strncpy(p, settingsContainer.moduleLocation, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3308 paths.Add(CopyString(p));
3309 StripLastDirectory(p, p);
3311 paths.Add(CopyString(p));
3312 #if defined(__WIN32__)
3313 GetEnvironment("ECERE_SDK_SRC", v, maxPathLen);
3316 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3317 PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3319 GetEnvironment("AppData", v, maxPathLen);
3322 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3323 PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3325 GetEnvironment("ProgramFiles", v, maxPathLen);
3328 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3329 PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3331 GetEnvironment("ProgramFiles(x86)", v, maxPathLen);
3334 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3335 PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3337 GetEnvironment("SystemDrive", v, maxPathLen);
3340 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3341 PathCat(p, "Program Files"); PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3344 GetEnvironment("XDG_DATA_DIRS", v, maxPathLen);
3345 numTokens = TokenizeWith(v, sizeof(tokens) / sizeof(byte *), tokens, ":", false);
3346 for(c=0; c<numTokens; c++)
3348 strncpy(p, tokens[c], MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3349 PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3354 strncpy(p, path, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3356 if(FileExists(p).isFile)
3368 class RecursiveDeleteFolderFSI : NormalFileSystemIterator
3370 bool preserveRootFolder;
3372 void OutFolder(char * folderPath, bool isRoot)
3374 if(!(preserveRootFolder && isRoot))
3375 RemoveDir(folderPath);
3378 bool OnFile(char * filePath)
3380 DeleteFile(filePath);
3385 class IDEApp : GuiApplication
3387 //driver = "Win32Console";
3388 // driver = "OpenGL";
3392 TempFile includeFile { };
3396 SetLoggingMode(stdOut, null);
3397 //SetLoggingMode(debug, null);
3399 settingsContainer.Load();
3400 #if defined(__unix__) || defined(__APPLE__)
3401 app.driver = (ideSettings.displayDriver && !strcmp(ideSettings.displayDriver, "OpenGL")) ? ideSettings.displayDriver : "X";
3403 app.driver = (ideSettings.displayDriver && !strcmp(ideSettings.displayDriver, "OpenGL")) ? ideSettings.displayDriver : "GDI";
3405 ide.driverItems[ideSettings.displayDriver && !strcmp(ideSettings.displayDriver,"OpenGL")].checked = true;
3409 desktop.text = titleECEREIDE;
3412 for(c = 1; c<app.argc; c++)
3414 char fullPath[MAX_LOCATION];
3415 GetWorkingDir(fullPath, MAX_LOCATION);
3416 PathCat(fullPath, app.argv[c]);
3417 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, null, yes, normal, false);
3421 if(!LoadIncludeFile())
3422 PrintLn("error: unable to load :crossplatform.mk file inside ide binary.");
3427 bool LoadIncludeFile()
3429 bool result = false;
3430 File include = FileOpen(":crossplatform.mk", read);
3433 File f = includeFile;
3436 for(; !include.Eof(); )
3439 int count = include.Read(buffer, 1, 4096);
3440 f.Write(buffer, 1, count);
3450 IDEMainFrame ideMainFrame { };
3452 define app = ((IDEApp)__thisModule);
3454 define titleECEREIDE = $"ECERE IDE (Debug)";
3456 define titleECEREIDE = $"ECERE IDE";