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; };
249 #ifdef IDE_SHOW_INSTALL_MENU_BUTTON
250 ToolButton buttonInstall { this, toolTip = $"Install", menuItemPtr = IDEItem(projectInstallItem), disabled = true; };
253 ToolSeparator separator4 { this };
257 ToolButton buttonDebugStartResume { this, toolTip = $"Start", menuItemPtr = IDEItem(debugStartResumeItem), disabled = true; };
259 ToolButton buttonDebugRestart { this, toolTip = $"Restart", menuItemPtr = IDEItem(debugRestartItem), disabled = true; };
261 ToolButton buttonDebugPause { this, toolTip = $"Break", menuItemPtr = IDEItem(debugBreakItem), disabled = true; };
263 ToolButton buttonDebugStop { this, toolTip = $"Stop", menuItemPtr = IDEItem(debugStopItem), disabled = true; };
265 //ToolButton buttonRun { this, toolTip = $"Run", menuItemPtr = IDEItem(projectRunItem) };
267 ToolButton buttonDebugStepInto { this, toolTip = $"Step Into", menuItemPtr = IDEItem(debugStepIntoItem), disabled = true; };
269 ToolButton buttonDebugStepOver { this, toolTip = $"Step Over", menuItemPtr = IDEItem(debugStepOverItem), disabled = true; };
271 ToolButton buttonDebugStepOut { this, toolTip = $"Step Out", menuItemPtr = IDEItem(debugStepOutItem), disabled = true; };
273 ToolButton buttonDebugSkipStepOver { this, toolTip = $"Step Over Skipping Breakpoints", menuItemPtr = IDEItem(debugSkipStepOverItem), disabled = true; };
275 ToolSeparator separator5 { this };
277 Window spacer5 { this, size = { 4 } };
281 this, toolTip = $"Active Configuration(s)", size = { 160 }, disabled = true;
282 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
285 ide.workspace.SelectActiveConfig(row.string);
290 Window spacer6 { this, size = { 4 } };
292 DropBox activeCompiler
294 this, toolTip = $"Active Compiler", size = { 160 }, disabled = true;
295 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
297 if(ide.workspace && ide.projectView && row && strcmp(row.string, ide.workspace.compiler))
299 bool silent = ide.projectView.buildInProgress == none ? false : true;
300 CompilerConfig compiler = ideSettings.GetCompilerConfig(row.string);
301 ide.workspace.compiler = row.string;
302 ide.projectView.ShowOutputBuildLog(!silent);
304 ide.projectView.DisplayCompiler(compiler, false);
305 for(prj : ide.workspace.projects)
306 ide.projectView.ProjectPrepareCompiler(prj, compiler, silent);
308 ide.workspace.Save();
314 DropBox activeBitDepth
316 this, toolTip = $"Active Bit Depth", size = { 60 }, disabled = true;
317 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
319 if(ide.workspace && ide.projectView && row)
321 bool silent = ide.projectView.buildInProgress == none ? false : true;
322 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
323 ide.workspace.bitDepth = (int)row.tag;
324 ide.projectView.ShowOutputBuildLog(!silent);
326 ide.projectView.DisplayCompiler(compiler, false);
327 for(prj : ide.workspace.projects)
328 ide.projectView.ProjectPrepareCompiler(prj, compiler, silent);
330 ide.workspace.Save();
336 Window spacer7 { this, size = { 4 } };
341 row = activeBitDepth.AddString("Auto");
343 activeBitDepth.AddString("32 bit").tag = 32;
344 activeBitDepth.AddString("64 bit").tag = 64;
345 activeBitDepth.currentRow = row;
350 class IDEMainFrame : Window
352 background = formColor;
353 borderStyle = sizable;
357 minClientSize = { 600, 300 };
359 icon = { ":icon.png" };
360 text = titleECEREIDE;
364 anchor = { top = 0, right = 0, bottom = 0 };
367 anchor = { left = 0, top = 0, right = 0, bottom = 0 };
374 isActiveClient = true;
376 direction = vertical;
377 background = formColor;
378 anchor = { left = 0, top = 0, right = 0, bottom = 0 };
386 ((IDEWorkSpace)master).toolBar = null;
389 IDEWorkSpace ideWorkSpace { stack, this, toolBar = toolBar };
392 define ide = ideMainFrame.ideWorkSpace;
394 class IDEWorkSpace : Window
396 background = Color { 85, 85, 85 };
399 hasVertScroll = true;
400 hasHorzScroll = true;
402 isActiveClient = true;
403 anchor = { left = 0, top = 0, right = 0, bottom = 0 };
407 MenuItem * driverItems, * skinItems;
408 StatusField pos { width = 150 };
409 StatusField ovr, caps, num;
411 BitmapResource back { ":ecereBack.jpg", window = this };
412 BitmapResource bmpBp { ":codeMarks/breakpoint.png", window = this };
413 BitmapResource bmpBpDisabled { ":codeMarks/breakpointDisabled.png", window = this };
414 BitmapResource bmpBpHalf { ":codeMarks/breakpointHalf.png", window = this };
415 BitmapResource bmpBpHalfDisabled { ":codeMarks/breakpointHalfDisabled.png", window = this };
416 BitmapResource bmpCursor { ":codeMarks/cursor.png", window = this };
417 BitmapResource bmpCursorError { ":codeMarks/cursorError.png", window = this };
418 BitmapResource bmpTopFrame { ":codeMarks/topFrame.png", window = this };
419 BitmapResource bmpTopFrameError { ":codeMarks/topFrameError.png", window = this };
420 BitmapResource bmpTopFrameHalf { ":codeMarks/topFrameHalf.png", window = this };
421 BitmapResource bmpTopFrameHalfError { ":codeMarks/topFrameHalfError.png", window = this };
423 Debugger debugger { };
425 ProjectView projectView;
427 OutputView outputView
431 void OnGotoError(char * line, bool noParsing)
433 ide.GoToError(line, noParsing);
436 void OnCodeLocationParseAndGoTo(char * line)
438 ide.CodeLocationParseAndGoTo(line, ide.findInFilesDialog.findProject, ide.findInFilesDialog.findDir);
441 bool OnKeyDown(Key key, unichar ch)
446 if(activeBox != findBox || !ide.findInFilesDialog || !ide.findInFilesDialog.SearchAbort())
447 ide.ShowCodeEditor();
451 OutputView::OnKeyDown(key, ch);
458 bool OnClose(bool parentClosing)
462 ide.RepositionWindows(false);
463 return parentClosing;
467 CallStackView callStackView
469 parent = this, font = { panelFont.faceName, panelFont.size };
471 void OnSelectFrame(int frameIndex)
473 ide.debugger.GoToStackFrameLine(frameIndex, true);
475 ide.debugger.SelectFrame(frameIndex);
478 void OnToggleBreakpoint()
480 Debugger debugger = ide.debugger;
481 if(debugger.activeFrame && debugger.activeFrame.absoluteFile)
483 int line = debugger.activeFrame.line;
484 char name[MAX_LOCATION];
486 // TOFIX: Improve on this, don't use only filename, make a function
487 GetLastDirectory(debugger.activeFrame.absoluteFile, name);
488 if(ide && ide.workspace)
490 for(p : ide.workspace.projects)
492 if(p.topNode.Find(name, false))
500 for(p : ide.workspace.projects)
502 if(IsPathInsideOf(debugger.activeFrame.absoluteFile, p.topNode.path))
510 debugger.ToggleBreakpoint(debugger.activeFrame.absoluteFile, line, prj);
513 CodeEditor codeEditor = (CodeEditor)ide.FindWindow(debugger.activeFrame.absoluteFile);
514 if(codeEditor) { codeEditor.Update(null); Activate(); }
519 bool OnKeyDown(Key key, unichar ch)
523 case escape: ide.ShowCodeEditor(); break;
528 bool OnClose(bool parentClosing)
532 ide.RepositionWindows(false);
533 return parentClosing;
536 void OnRedraw(Surface surface)
538 Debugger debugger = ide.debugger;
539 Frame activeFrame = debugger.activeFrame;
543 int lineCursor, lineTopFrame, activeThread, hitThread;
544 int lineH, scrollY, boxH;
546 Breakpoint bp = null;
549 scrollY = editBox.scroll.y;
550 displaySystem.FontExtent(editBox.font.font, " ", 1, null, &lineH);
551 activeThread = debugger.activeThread;
552 hitThread = debugger.hitThread;
553 debugger.GetCallStackCursorLine(&error, &lineCursor, &lineTopFrame);
555 // TODO: improve bp drawing... it should be visible even if it's not on the activeFrame
556 if(activeFrame.absoluteFile)
558 for(i : ide.workspace.breakpoints; i.type == user)
560 if(i.absoluteFilePath && i.absoluteFilePath[0] &&
561 !fstrcmp(i.absoluteFilePath, activeFrame.absoluteFile) &&
562 activeFrame.line == i.line)
570 DrawLineMarginIcon(surface,
571 /*(lineCursor == 1 || lineTopFrame == 1) ? */ide.bmpBpHalf/* : ide.bmpBp*/,
572 lineCursor /*1*/, lineH, scrollY, boxH);
574 if(activeThread && activeThread == hitThread && debugger.bpHit && debugger.bpHit.type == user)
575 DrawLineMarginIcon(surface,
576 (lineCursor == 1 || lineTopFrame == 1) ? ide.bmpBpHalf : ide.bmpBp,
577 1, lineH, scrollY, boxH);
579 DrawLineMarginIcon(surface, error ? ide.bmpCursorError : ide.bmpCursor, lineCursor, lineH, scrollY, boxH);
580 if(bp && lineCursor == 1) //activeThread && activeThread == hitThread && debugger.bpHit && debugger.bpHit.type == user)
581 bmp = error ? ide.bmpTopFrameHalfError : ide.bmpTopFrameHalf;
583 bmp = error ? ide.bmpTopFrameError : ide.bmpTopFrame;
584 DrawLineMarginIcon(surface, bmp, lineTopFrame, lineH, scrollY, boxH);
586 if(editBox.horzScroll && editBox.horzScroll.visible)
588 surface.SetBackground(control);
589 surface.Area(0, editBox.clientSize.h, 20 - 1, clientSize.h - 1);
594 WatchesView watchesView { parent = this };
595 ThreadsView threadsView
597 parent = this, font = { panelFont.faceName, panelFont.size };
599 bool OnKeyDown(Key key, unichar ch)
603 case escape: ide.ShowCodeEditor(); break;
608 bool OnClose(bool parentClosing)
612 ide.RepositionWindows(false);
613 return parentClosing;
616 void OnSelectThread(int threadId)
619 ide.debugger.SelectThread(threadId);
622 bool OnGetThreadsInfo(int * activeThread, int * hitThread, int * signalThread)
625 Debugger debugger = ide.debugger;
626 *activeThread = debugger.activeThread;
627 *hitThread = debugger.hitThread;
628 *signalThread = debugger.signalThread;
633 BreakpointsView breakpointsView { parent = this };
635 ToolBox toolBox { parent = this };
636 Sheet sheet { parent = this };
639 property char * tmpPrjDir { set { delete tmpPrjDir; if(value) tmpPrjDir = CopyString(value); } get { return tmpPrjDir; } };
641 Menu fileMenu { menu, $"File", f, hasMargin = true };
644 fileMenu, $"New", n, ctrlN;
645 bitmap = { ":actions/docNew.png" };
646 bool NotifySelect(MenuItem selection, Modifiers mods)
648 Window document = (Window)NewCodeEditor(this, normal, false);
649 document.NotifySaved = DocumentSaved;
653 MenuItem fileOpenItem
655 fileMenu, $"Open...", o, ctrlO;
656 bitmap = { ":actions/docOpen.png" };
657 bool NotifySelect(MenuItem selection, Modifiers mods)
659 if(!projectView && ideSettings.ideFileDialogLocation)
660 ideFileDialog.currentDirectory = ideSettings.ideFileDialogLocation;
663 if(ideFileDialog.Modal() == ok)
665 bool gotWhatWeWant = false;
667 int numSelections = ideFileDialog.numSelections;
668 char ** multiFilePaths = ideFileDialog.multiFilePaths;
670 for(c = 0; c < numSelections; c++)
672 if(OpenFile(multiFilePaths[c], normal, true, fileTypes[ideFileDialog.fileType].typeExtension, no, normal, mods.ctrl && mods.shift))
673 gotWhatWeWant = true;
676 MessageBox { type = yesNo, master = this, text = $"Error opening file",
677 contents = $"Open a different file?" }.Modal() == no)
679 if(!projectView && gotWhatWeWant)
680 ChangeFileDialogsDirectory(ideFileDialog.currentDirectory, true);
681 ide.RepositionWindows(false);
691 MenuItem fileCloseItem { fileMenu, $"Close", c, ctrlF4, NotifySelect = MenuFileClose };
692 MenuDivider { fileMenu };
693 MenuItem fileSaveItem
695 fileMenu, $"Save", s, ctrlS, bitmap = { ":actions/docSave.png" };
697 // For the toolbar button; clients can still override that for the menu item
698 bool Window::NotifySelect(MenuItem selection, Modifiers mods)
700 Window w = activeClient;
702 w.MenuFileSave(null, 0);
706 MenuItem fileSaveAsItem { fileMenu, $"Save As...", a };
707 MenuItem fileSaveAllItem { fileMenu, $"Save All", l, NotifySelect = MenuFileSaveAll, bitmap = { ":actions/docSaveAll.png" } };
708 MenuDivider { fileMenu };
711 fileMenu, $"Find In Files...", f, Key { f, ctrl = true , shift = true };
712 bool NotifySelect(MenuItem selection, Modifiers mods)
714 findInFilesDialog.replaceMode = false;
715 findInFilesDialog.Show();
719 MenuItem replaceInFiles
721 fileMenu, $"Replace In Files...", e, Key { r, ctrl = true , shift = true };
722 bool NotifySelect(MenuItem selection, Modifiers mods)
724 findInFilesDialog.replaceMode = true;
725 findInFilesDialog.Show();
729 MenuDivider { fileMenu };
730 MenuItem globalSettingsItem
732 fileMenu, $"Global Settings...", g;
733 bool NotifySelect(MenuItem selection, Modifiers mods)
735 globalSettingsDialog.master = this;
736 if(ide.workspace && ide.workspace.compiler)
737 globalSettingsDialog.workspaceActiveCompiler = ide.workspace.compiler;
738 else if(ideSettings.defaultCompiler)
739 globalSettingsDialog.workspaceActiveCompiler = ideSettings.defaultCompiler;
740 globalSettingsDialog.Modal();
744 MenuDivider { fileMenu };
745 Menu recentFiles { fileMenu, $"Recent Files", r };
746 Menu recentProjects { fileMenu, $"Recent Projects", p };
747 MenuDivider { fileMenu };
750 fileMenu, $"Exit", x, altF4;
752 bool NotifySelect(MenuItem selection, Modifiers mods)
754 ideMainFrame.Destroy(0);
759 bool FileRecentFile(MenuItem selection, Modifiers mods)
762 for(file : ideSettings.recentFiles)
764 if(id == selection.id)
767 char extension[MAX_EXTENSION] = "";
768 GetExtension(file, extension);
769 isProjectFile = (!strcmpi(extension, "epj") || !strcmpi(extension, "ews"));
772 char * command = PrintString("ide ", isProjectFile ? "-t " : "", file);
778 OpenFile(file, normal, true, isProjectFile ? "txt" : null, no, normal, mods.ctrl && mods.shift);
779 ide.RepositionWindows(false);
788 bool FileRecentProject(MenuItem selection, Modifiers mods)
791 for(file : ideSettings.recentProjects)
793 if(id == selection.id)
797 char * command = PrintString("ide ", file);
802 OpenFile(file, normal, true, null, no, normal, mods.ctrl && mods.shift);
810 MenuPlacement editMenu { menu, $"Edit", e };
812 Menu projectMenu { menu, $"Menu"."Project", p, hasMargin = true };
813 MenuItem projectNewItem
815 projectMenu, $"New...", n, Key { n, true, true };
816 bitmap = { ":actions/projNew.png" };
817 bool NotifySelect(MenuItem selection, Modifiers mods)
819 if(!DontTerminateDebugSession($"New Project"))
822 NewProjectDialog newProjectDialog { master = this };
823 incref newProjectDialog;
824 result = newProjectDialog.Modal();
829 newProjectDialog.CreateNewProject();
832 ideSettings.AddRecentProject(projectView.fileName);
833 ide.UpdateRecentMenus();
834 settingsContainer.Save();
838 delete newProjectDialog;
843 MenuItem projectOpenItem
845 projectMenu, $"Open...", o, Key { o, true, true };
846 bitmap = { ":actions/projOpen.png" };
847 bool NotifySelect(MenuItem selection, Modifiers mods)
849 if(ideSettings.ideProjectFileDialogLocation)
850 ideProjectFileDialog.currentDirectory = ideSettings.ideProjectFileDialogLocation;
852 ideProjectFileDialog.text = openProjectFileDialogTitle;
853 if(ideProjectFileDialog.Modal() == ok)
855 OpenFile(ideProjectFileDialog.filePath, normal, true, projectTypes[ideProjectFileDialog.fileType].typeExtension, no, normal, mods.ctrl && mods.shift);
856 //ChangeProjectFileDialogDirectory(ideProjectFileDialog.currentDirectory);
861 MenuItem projectQuickItem
863 projectMenu, $"Quick...", q, f7, disabled = true;
864 bool NotifySelect(MenuItem selection, Modifiers mods)
867 QuickProjectDialog { this }.Modal();
871 MenuItem projectAddItem
873 projectMenu, $"Add project to workspace...", a, Key { a, true, true };
874 bitmap = { ":actions/projAdd.png" };
876 bool NotifySelect(MenuItem selection, Modifiers mods)
878 if(ideSettings.ideProjectFileDialogLocation)
879 ideProjectFileDialog.currentDirectory = ideSettings.ideProjectFileDialogLocation;
881 ideProjectFileDialog.text = addProjectFileDialogTitle;
884 if(ideProjectFileDialog.Modal() == ok)
886 if(OpenFile(ideProjectFileDialog.filePath, normal, true, projectTypes[ideProjectFileDialog.fileType].typeExtension, no, add, mods.ctrl && mods.shift))
888 if(MessageBox { type = yesNo, master = this, text = $"Error opening project file",
889 contents = $"Add a different project?" }.Modal() == no)
900 MenuItem projectCloseItem
902 projectMenu, $"Close", c, disabled = true;
903 bool NotifySelect(MenuItem selection, Modifiers mods)
907 if(!ide.DontTerminateDebugSession($"Project Close"))
913 MenuDivider { projectMenu };
914 MenuItem projectSettingsItem
916 projectMenu, $"Settings...", s, altF7, disabled = true;
917 bool NotifySelect(MenuItem selection, Modifiers mods)
919 projectView.MenuSettings(projectView.active ? selection : null, mods);
923 MenuDivider { projectMenu };
924 MenuItem projectBrowseFolderItem
926 projectMenu, $"Browse Project Folder", p, disabled = true;
927 bool NotifySelect(MenuItem selection, Modifiers mods)
930 projectView.MenuBrowseFolder(null, mods);
934 MenuDivider { projectMenu };
935 MenuItem projectRunItem
937 projectMenu, $"Run", r, ctrlF5, disabled = true;
938 bitmap = { ":actions/run.png" };
939 bool NotifySelect(MenuItem selection, Modifiers mods)
942 projectView.Run(null, mods);
946 MenuItem projectBuildItem
948 projectMenu, $"Build", b, f7, disabled = true;
949 bitmap = { ":actions/build.png" };
950 bool NotifySelect(MenuItem selection, Modifiers mods)
954 if(projectView.buildInProgress == none)
955 projectView.ProjectBuild(projectView.active ? selection : null, mods);
957 projectView.stopBuild = true;
962 MenuItem projectLinkItem
964 projectMenu, $"Relink", l, disabled = true;
965 bitmap = { ":actions/relink.png" };
966 bool NotifySelect(MenuItem selection, Modifiers mods)
969 projectView.ProjectLink(projectView.active ? selection : null, mods);
973 MenuItem projectRebuildItem
975 projectMenu, $"Rebuild", d, shiftF7, disabled = true;
976 bitmap = { ":actions/rebuild.png" };
977 bool NotifySelect(MenuItem selection, Modifiers mods)
980 projectView.ProjectRebuild(projectView.active ? selection : null, mods);
984 MenuItem projectCleanTargetItem
986 projectMenu, $"Clean Target", g, disabled = true;
987 bitmap = { ":actions/clean.png" };
988 bool NotifySelect(MenuItem selection, Modifiers mods)
993 projectView.ProjectCleanTarget(projectView.active ? selection : null, mods);
998 MenuItem projectCleanItem
1000 projectMenu, $"Clean", e, disabled = true;
1001 bitmap = { ":actions/clean.png" };
1002 bool NotifySelect(MenuItem selection, Modifiers mods)
1007 projectView.ProjectClean(projectView.active ? selection : null, mods);
1012 MenuItem projectRealCleanItem
1014 projectMenu, $"Real Clean", disabled = true;
1015 bitmap = { ":actions/clean.png" };
1016 bool NotifySelect(MenuItem selection, Modifiers mods)
1021 projectView.ProjectRealClean(projectView.active ? selection : null, mods);
1026 MenuItem projectRegenerateItem
1028 projectMenu, $"Regenerate Makefile", m, disabled = true;
1029 bitmap = { ":actions/regMakefile.png" };
1030 bool NotifySelect(MenuItem selection, Modifiers mods)
1033 projectView.ProjectRegenerate(projectView.active ? selection : null, mods);
1037 MenuItem projectInstallItem
1039 #ifdef IDE_SHOW_INSTALL_MENU_BUTTON
1040 projectMenu, $"Install", t, disabled = true;
1042 bitmap = { ":status/software-update-available.png" };
1043 bool NotifySelect(MenuItem selection, Modifiers mods)
1046 projectView.ProjectInstall(projectView.active ? selection : null, mods);
1050 MenuItem projectCompileItem;
1051 Menu debugMenu { menu, $"Debug", d, hasMargin = true };
1052 MenuItem debugStartResumeItem
1054 debugMenu, $"Start", s, f5, disabled = true;
1055 bitmap = { ":actions/debug.png" };
1056 NotifySelect = MenuDebugStart;
1058 bool MenuDebugStart(MenuItem selection, Modifiers mods)
1062 debugStartResumeItem.disabled = true; // a very rare exception to calling AdjustDebugMenus
1063 if(!projectView.DebugStart())
1064 debugStartResumeItem.disabled = false; // same exception
1068 bool MenuDebugResume(MenuItem selection, Modifiers mods)
1071 projectView.DebugResume();
1074 MenuItem debugRestartItem
1076 debugMenu, $"Restart", r, Key { f5, ctrl = true, shift = true }, disabled = true;
1077 bitmap = { ":actions/restart.png" };
1078 bool NotifySelect(MenuItem selection, Modifiers mods)
1081 projectView.DebugRestart();
1085 MenuItem debugBreakItem
1087 debugMenu, $"Break", b, Key { pauseBreak, ctrl = true }, disabled = true;
1088 bitmap = { ":actions/pause.png" };
1089 bool NotifySelect(MenuItem selection, Modifiers mods)
1091 if(projectView && projectView.buildInProgress != none)
1094 projectView.DebugBreak();
1098 MenuItem debugStopItem
1100 debugMenu, $"Stop", p, shiftF5, disabled = true;
1101 bitmap = { ":actions/stopDebug.png" };
1102 bool NotifySelect(MenuItem selection, Modifiers mods)
1105 projectView.DebugStop();
1110 MenuDivider { debugMenu };
1111 MenuItem debugUseValgrindItem
1113 debugMenu, $"Use Valgrind", d, disabled = true, checkable = true;
1114 bool NotifySelect(MenuItem selection, Modifiers mods)
1118 ide.workspace.useValgrind = selection.checked;
1119 ide.workspace.Save();
1121 ide.AdjustValgrindMenus();
1125 Menu debugValgrindLeakCheckItem { debugMenu, $"Valgrind Leak Check", h };
1126 MenuItem debugValgrindNoLeakCheckItem { debugValgrindLeakCheckItem, $"No" , f, id = ValgrindLeakCheck::no , checkable = true, disabled = true; NotifySelect = ValgrindLCSelect; }
1127 MenuItem debugValgrindSummaryLeakCheckItem { debugValgrindLeakCheckItem, $"Summary", f, id = ValgrindLeakCheck::summary, checkable = true, disabled = true; NotifySelect = ValgrindLCSelect, checked = true; }
1128 MenuItem debugValgrindYesLeakCheckItem { debugValgrindLeakCheckItem, $"Yes" , f, id = ValgrindLeakCheck::yes , checkable = true, disabled = true; NotifySelect = ValgrindLCSelect; }
1129 MenuItem debugValgrindFullLeakCheckItem { debugValgrindLeakCheckItem, $"Full" , f, id = ValgrindLeakCheck::full , checkable = true, disabled = true; NotifySelect = ValgrindLCSelect; }
1130 bool ValgrindLCSelect(MenuItem selection, Modifiers mods)
1134 if(selection.checked)
1136 ValgrindLeakCheck vgLeakCheck = (ValgrindLeakCheck)selection.id;
1138 debugValgrindNoLeakCheckItem.checked = debugValgrindNoLeakCheckItem.id == vgLeakCheck;
1139 debugValgrindSummaryLeakCheckItem.checked = debugValgrindSummaryLeakCheckItem.id == vgLeakCheck;
1140 debugValgrindYesLeakCheckItem.checked = debugValgrindYesLeakCheckItem.id == vgLeakCheck;
1141 debugValgrindFullLeakCheckItem.checked = debugValgrindFullLeakCheckItem.id == vgLeakCheck;
1143 ide.workspace.vgLeakCheck = vgLeakCheck;
1144 ide.workspace.Save();
1147 selection.checked = true;
1151 Menu debugValgrindRedzoneSizeItem { debugMenu, $"Valgrind Redzone Size", z };
1152 MenuItem debugValgrindRS0Item { debugValgrindRedzoneSizeItem, $"0" , f, id = 0, checkable = true, disabled = true; NotifySelect = ValgrindRSSelect, checked = true; }
1153 MenuItem debugValgrindRS16Item { debugValgrindRedzoneSizeItem, $"16" , f, id = 16, checkable = true, disabled = true; NotifySelect = ValgrindRSSelect; }
1154 MenuItem debugValgrindRS32Item { debugValgrindRedzoneSizeItem, $"32" , f, id = 32, checkable = true, disabled = true; NotifySelect = ValgrindRSSelect; }
1155 MenuItem debugValgrindRS64Item { debugValgrindRedzoneSizeItem, $"64" , f, id = 64, checkable = true, disabled = true; NotifySelect = ValgrindRSSelect; }
1156 MenuItem debugValgrindRS128Item { debugValgrindRedzoneSizeItem, $"128", f, id = 128, checkable = true, disabled = true; NotifySelect = ValgrindRSSelect; }
1157 MenuItem debugValgrindRS256Item { debugValgrindRedzoneSizeItem, $"256", f, id = 256, checkable = true, disabled = true; NotifySelect = ValgrindRSSelect; }
1158 MenuItem debugValgrindRS512Item { debugValgrindRedzoneSizeItem, $"512", f, id = 512, checkable = true, disabled = true; NotifySelect = ValgrindRSSelect; }
1159 bool ValgrindRSSelect(MenuItem selection, Modifiers mods)
1163 if(selection.checked)
1165 int vgRedzoneSize = (int)selection.id;
1167 debugValgrindRS0Item.checked = debugValgrindRS0Item.id == vgRedzoneSize;
1168 debugValgrindRS16Item.checked = debugValgrindRS16Item.id == vgRedzoneSize;
1169 debugValgrindRS32Item.checked = debugValgrindRS32Item.id == vgRedzoneSize;
1170 debugValgrindRS64Item.checked = debugValgrindRS64Item.id == vgRedzoneSize;
1171 debugValgrindRS128Item.checked = debugValgrindRS128Item.id == vgRedzoneSize;
1172 debugValgrindRS256Item.checked = debugValgrindRS256Item.id == vgRedzoneSize;
1173 debugValgrindRS512Item.checked = debugValgrindRS512Item.id == vgRedzoneSize;
1175 ide.workspace.vgRedzoneSize = vgRedzoneSize;
1176 ide.workspace.Save();
1179 selection.checked = true;
1183 MenuItem debugValgrindTrackOriginsItem
1185 debugMenu, $"Valgrind Track Origins", k, checkable = true, disabled = true;
1186 bool NotifySelect(MenuItem selection, Modifiers mods)
1190 ide.workspace.vgTrackOrigins = selection.checked;
1191 ide.workspace.Save();
1197 MenuDivider { debugMenu };
1198 MenuItem debugStepIntoItem
1200 debugMenu, $"Step Into", i, f11, disabled = true;
1201 bitmap = { ":actions/stepInto.png" };
1202 bool NotifySelect(MenuItem selection, Modifiers mods)
1205 projectView.DebugStepInto();
1209 MenuItem debugStepOverItem
1211 debugMenu, $"Step Over", v, f10, disabled = true;
1212 bitmap = { ":actions/stepOver.png" };
1213 bool NotifySelect(MenuItem selection, Modifiers mods)
1216 projectView.DebugStepOver(false);
1220 MenuItem debugStepOutItem
1222 debugMenu, $"Step Out", o, shiftF11, disabled = true;
1223 bitmap = { ":actions/stepOut.png" };
1224 bool NotifySelect(MenuItem selection, Modifiers mods)
1227 projectView.DebugStepOut(false);
1231 MenuPlacement debugRunToCursorItem { debugMenu, $"Run To Cursor", c };
1232 MenuItem debugSkipStepOverItem
1234 debugMenu, $"Step Over Skipping Breakpoints", e, shiftF10, disabled = true;
1235 bool NotifySelect(MenuItem selection, Modifiers mods)
1238 projectView.DebugStepOver(true);
1242 MenuItem debugSkipStepOutItem
1244 debugMenu, $"Step Out Skipping Breakpoints", t, Key { f11, ctrl = true, shift = true }, disabled = true;
1245 bitmap = { ":actions/skipBreaks.png" };
1246 bool NotifySelect(MenuItem selection, Modifiers mods)
1249 projectView.DebugStepOut(true);
1253 MenuPlacement debugSkipRunToCursorItem { debugMenu, $"Run To Cursor Skipping Breakpoints", u };
1254 MenuPlacement debugSkipRunToCursorAtSameLevelItem { debugMenu, $"Run To Cursor At Same Level Skipping Breakpoints", l };
1255 //MenuDivider { debugMenu };
1256 //MenuPlacement debugToggleBreakpoint { debugMenu, "Toggle Breakpoint", t };
1257 MenuPlacement imageMenu { menu, $"Image", i };
1258 Menu viewMenu { menu, $"View", v };
1259 MenuItem viewProjectItem
1261 viewMenu, $"Project View", j, alt0, disabled = true;
1262 bool NotifySelect(MenuItem selection, Modifiers mods)
1266 projectView.visible = true;
1267 projectView.Activate();
1272 MenuPlacement { viewMenu, $"View Designer" };
1273 MenuPlacement { viewMenu, $"View Code" };
1274 MenuPlacement { viewMenu, $"View Properties" };
1275 MenuPlacement { viewMenu, $"View Methods" };
1276 MenuItem viewDesignerItem
1278 viewMenu, $"View Designer", d, f8;
1279 bool NotifySelect(MenuItem selection, Modifiers mods)
1281 Window client = activeClient;
1282 Class dataType = client._class;
1283 if(!strcmp(dataType.name, "Designer"))
1285 client.visible = true;
1289 ((CodeEditor)client).ViewDesigner();
1293 MenuItem viewCodeItem
1295 viewMenu, $"View Code", c, f8;
1296 bool NotifySelect(MenuItem selection, Modifiers mods)
1298 Window client = activeClient;
1299 Class dataType = client._class;
1300 if(!strcmp(dataType.name, "Designer"))
1301 client = ((Designer)client).codeEditor;
1304 // Do this after so the caret isn't moved yet...
1305 client.visible = true;
1309 MenuItem viewPropertiesItem
1311 viewMenu, $"View Properties", p, f4;
1312 bool NotifySelect(MenuItem selection, Modifiers mods)
1314 sheet.visible = true;
1315 sheet.sheetSelected = properties;
1320 MenuItem viewMethodsItem
1322 viewMenu, $"View Methods", m, f4;
1323 bool NotifySelect(MenuItem selection, Modifiers mods)
1325 sheet.visible = true;
1326 sheet.sheetSelected = methods;
1331 MenuItem viewToolBoxItem
1333 viewMenu, $"View Toolbox", x, f12;
1334 bool NotifySelect(MenuItem selection, Modifiers mods)
1336 toolBox.visible = true;
1341 MenuItem viewOutputItem
1343 viewMenu, $"Output", o, alt2;
1344 bool NotifySelect(MenuItem selection, Modifiers mods)
1350 MenuItem viewWatchesItem
1352 viewMenu, $"Watches", w, alt3;
1353 bool NotifySelect(MenuItem selection, Modifiers mods)
1359 MenuItem viewThreadsItem
1361 viewMenu, $"Threads", t, alt4;
1362 bool NotifySelect(MenuItem selection, Modifiers mods)
1368 MenuItem viewBreakpointsItem
1370 viewMenu, $"Breakpoints", b, alt5;
1371 bool NotifySelect(MenuItem selection, Modifiers mods)
1373 breakpointsView.Show();
1377 MenuItem viewCallStackItem
1379 viewMenu, $"Call Stack", s, alt7;
1380 bool NotifySelect(MenuItem selection, Modifiers mods)
1382 callStackView.Show();
1386 MenuItem viewAllDebugViews
1388 viewMenu, $"All Debug Views", a, alt9;
1389 bool NotifySelect(MenuItem selection, Modifiers mods)
1394 callStackView.Show();
1395 breakpointsView.Show();
1399 #ifdef GDB_DEBUG_GUI
1400 MenuDivider { viewMenu };
1401 MenuItem viewGDBItem
1403 viewMenu, $"GDB Dialog", g, Key { f9, shift = true, ctrl = true };
1404 bool NotifySelect(MenuItem selection, Modifiers mods)
1411 MenuDivider { viewMenu };
1412 MenuItem viewColorPicker
1414 viewMenu, $"Color Picker...", c, Key { c, ctrl = true , shift = true };
1415 bool NotifySelect(MenuItem selection, Modifiers mods)
1417 ColorPicker colorPicker { master = this };
1418 colorPicker.Modal();
1422 MenuDivider { viewMenu };
1426 viewMenu, "Full Screen", f, checkable = true;
1428 bool NotifySelect(MenuItem selection, Modifiers mods)
1430 app.fullScreen ^= true;
1432 anchor = { 0, 0, 0, 0 };
1437 Menu driversMenu { viewMenu, $"Graphics Driver", v };
1438 //Menu skinsMenu { viewMenu, "GUI Skins", k };
1439 Menu windowMenu { menu, $"Window", w };
1440 MenuItem { windowMenu, $"Close All", l, NotifySelect = MenuWindowCloseAll };
1441 MenuDivider { windowMenu };
1442 MenuItem { windowMenu, $"Next", n, f6, NotifySelect = MenuWindowNext };
1443 MenuItem { windowMenu, $"Previous", p, shiftF6, NotifySelect = MenuWindowPrevious };
1444 MenuDivider { windowMenu };
1445 MenuItem { windowMenu, $"Cascade", c, NotifySelect = MenuWindowCascade };
1446 MenuItem { windowMenu, $"Tile Horizontally", h, NotifySelect = MenuWindowTileHorz };
1447 MenuItem { windowMenu, $"Tile Vertically", v, NotifySelect = MenuWindowTileVert };
1448 MenuItem { windowMenu, $"Arrange Icons", a, NotifySelect = MenuWindowArrangeIcons };
1449 MenuDivider { windowMenu };
1450 MenuItem { windowMenu, $"Windows...", w, NotifySelect = MenuWindowWindows };
1451 Menu helpMenu { menu, $"Help", h };
1454 helpMenu, $"API Reference", r, f1;
1455 bool NotifySelect(MenuItem selection, Modifiers mods)
1457 char * p = new char[MAX_LOCATION];
1459 strncpy(p, settingsContainer.moduleLocation, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
1460 PathCat(p, "documentor");
1461 #if defined(__WIN32__)
1462 ChangeExtension(p, "exe", p);
1464 if(FileExists(p).isFile)
1467 Execute("documentor");
1472 MenuDivider { helpMenu };
1475 helpMenu, $"Ecere Tao of Programming [work in progress]", t;
1476 bool NotifySelect(MenuItem selection, Modifiers mods)
1478 FindAndShellOpenInstalledFile("doc", "Ecere Tao of Programming [work in progress].pdf");
1482 MenuDivider { helpMenu };
1485 helpMenu, $"Documentation Folder", d;
1486 bool NotifySelect(MenuItem selection, Modifiers mods)
1488 FindAndShellOpenInstalledFolder("doc");
1494 helpMenu, $"Samples Folder", s;
1495 bool NotifySelect(MenuItem selection, Modifiers mods)
1497 FindAndShellOpenInstalledFolder("samples");
1503 helpMenu, $"Extras Folder", x;
1504 bool NotifySelect(MenuItem selection, Modifiers mods)
1506 FindAndShellOpenInstalledFolder("extras");
1510 MenuDivider { helpMenu };
1513 helpMenu, $"Community Forums", f;
1514 bool NotifySelect(MenuItem selection, Modifiers mods)
1516 ShellOpen("http://ecere.com/forums");
1520 MenuDivider { helpMenu };
1523 helpMenu, $"About...", a;
1524 bool NotifySelect(MenuItem selection, Modifiers mods)
1526 AboutIDE { master = this }.Modal();
1531 property ToolBox toolBox
1533 get { return toolBox; }
1536 property Sheet sheet
1538 get { return sheet; }
1541 property Project project
1543 get { return projectView ? projectView.project : null; }
1546 property Workspace workspace
1548 get { return projectView ? projectView.workspace : null; }
1551 FindInFilesDialog findInFilesDialog
1554 filters = findInFilesFileFilters.array, sizeFilters = findInFilesFileFilters.count * sizeof(FileFilter);
1560 #ifdef GDB_DEBUG_GUI
1563 master = this, parent = this;
1564 //anchor = { left = 100, top = 100, right = 100, bottom = 100 };
1566 void OnCommand(char * string)
1569 ide.debugger.SendGDBCommand(string);
1574 bool NotifySelectDisplayDriver(MenuItem selection, Modifiers mods)
1576 //app.driver = app.drivers[selection.id];
1577 #if defined(__unix__) || defined(__APPLE__)
1578 app.driver = selection.id ? "OpenGL" : "X";
1580 app.driver = selection.id ? "OpenGL" : "GDI";
1582 delete ideSettings.displayDriver;
1583 ideSettings.displayDriver = CopyString(selection.id ? "OpenGL" : "Default");
1585 settingsContainer.Save();
1586 //SetDriverAndSkin();
1590 bool NotifySelectDisplaySkin(MenuItem selection, Modifiers mods)
1592 app.skin = app.skins[selection.id];
1597 void SetDriverAndSkin()
1600 for(c = 0; c < app.numSkins; c++)
1601 if(!strcmp(app.skins[c], app.skin))
1603 skinItems[c].checked = true;
1606 for(c = 0; c < app.numDrivers; c++)
1607 if(!strcmp(app.drivers[c], app.driver))
1609 driverItems[c].checked = true;
1614 ProjectView CreateProjectView(Workspace workspace, char * fileName)
1616 Project project = workspace.projects.firstIterator.data;
1617 projectView = ProjectView
1620 fileName = fileName;
1622 void NotifyDestroyed(Window window, DialogResult result)
1625 text = titleECEREIDE;
1630 projectView.Create();
1631 RepositionWindows(false);
1633 // Leave it after Create to avoid flicker due to seeing IDE without a project view
1634 projectView.workspace = workspace;
1635 projectView.project = project;
1636 ideMainFrame.SetText("%s - %s", project.topNode.name, titleECEREIDE);
1640 ide.breakpointsView.LoadFromWorkspace();
1641 ide.watchesView.LoadFromWorkspace();
1643 findInFilesDialog.projectNodeField.userData = projectView;
1646 char fileName[MAX_LOCATION];
1647 strcpy(fileName, project.topNode.path);
1648 PathCat(fileName, project.topNode.name);
1655 projectView.visible = false;
1656 if((!projectView || projectView.created == false || projectView.Destroy(0)) && MenuWindowCloseAll(null, 0))
1658 if(findInFilesDialog)
1660 char workingDir[MAX_LOCATION];
1661 GetWorkingDir(workingDir, MAX_LOCATION);
1662 findInFilesDialog.SearchStop();
1663 findInFilesDialog.currentDirectory = workingDir;
1665 ideMainFrame.text = titleECEREIDE;
1672 void RepositionWindows(bool expand)
1677 bool inDebugMode = debugger.isActive;
1678 bool callStackVisible = expand ? false : callStackView.visible;
1679 bool threadsVisible = expand ? false : threadsView.visible;
1680 bool watchesVisible = expand ? false : watchesView.visible;
1681 bool breakpointsVisible = expand ? false : breakpointsView.visible;
1682 bool toolBoxVisible = toolBox.visible;
1683 bool outputVisible = expand ? false : outputView.visible;
1684 int topDistance = (callStackVisible || threadsVisible) ? 200 : 0;
1685 int bottomDistance = (outputVisible || watchesVisible || breakpointsVisible) ? 240 : 0;
1687 for(child = firstChild; child; child = child.next)
1689 if(child._class == class(CodeEditor) || child._class == class(Designer) ||
1690 child._class == class(Sheet) || child._class == class(ProjectView))
1692 Anchor anchor = child.anchor;
1693 anchor.top = topDistance;
1694 anchor.bottom = bottomDistance;
1695 if(child._class == class(CodeEditor) || child._class == class(Designer))
1698 anchor.right = toolBoxVisible ? 150 : 0;
1700 child.anchor = anchor;
1704 if(child._class == class(OutputView) || child._class == class(CallStackView) || child._class == class(ThreadsView) || child._class == class(WatchesView) ||
1705 child._class == class(BreakpointsView))
1706 child.visible = false;
1709 // If this is not here, the IDE is not updated when doing Debug/Break then Alt-4 to show call stack (IDE not updated)
1714 bool ShowCodeEditor()
1717 activeClient.Activate();
1718 else if(projectView)
1720 projectView.visible = true;
1721 projectView.Activate();
1725 sheet.visible = true;
1731 void DocumentSaved(Window document, char * fileName)
1733 ideSettings.AddRecentFile(fileName);
1734 ide.UpdateRecentMenus();
1735 ide.AdjustFileMenus();
1736 settingsContainer.Save();
1739 bool Window::OnFileModified(FileChange fileChange, char * param)
1742 sprintf(temp, $"The document %s was modified by another application.\n"
1743 "Would you like to reload it and lose your changes?", this.fileName);
1744 if(MessageBox { type = yesNo, master = this/*.parent*/,
1745 text = $"Document has been modified", contents = temp }.Modal() == yes)
1747 bool noParsing = (this._class == class(CodeEditor) && ((CodeEditor)this).noParsing) ? true : false;
1748 char * fileName = CopyString(this.fileName);
1749 WindowState state = this.state;
1750 Anchor anchor = this.anchor;
1751 Size size = this.size;
1753 this.modifiedDocument = false;
1755 this = ide.OpenFile(fileName, normal, true, null, no, normal, noParsing);
1758 this.anchor = anchor;
1760 this.SetState(state, true, 0);
1768 void UpdateMakefiles()
1772 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
1773 for(prj : workspace.projects)
1774 projectView.ProjectUpdateMakefileForAllConfigs(prj);
1779 void UpdateCompilerConfigs(bool mute)
1781 UpdateToolBarActiveCompilers();
1784 bool silent = mute || (ide.projectView.buildInProgress == none ? false : true);
1785 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
1788 projectView.ShowOutputBuildLog(true);
1789 projectView.DisplayCompiler(compiler, false);
1791 for(prj : workspace.projects)
1792 projectView.ProjectPrepareCompiler(prj, compiler, silent);
1797 void UpdateToolBarActiveCompilers()
1799 toolBar.activeCompiler.Clear();
1800 for(compiler : ideSettings.compilerConfigs)
1802 DataRow row = toolBar.activeCompiler.AddString(compiler.name);
1803 if(workspace && workspace.compiler && !strcmp(compiler.name, workspace.compiler))
1804 toolBar.activeCompiler.currentRow = row;
1806 if(!toolBar.activeCompiler.currentRow && toolBar.activeCompiler.firstRow)
1807 toolBar.activeCompiler.SelectRow(toolBar.activeCompiler.firstRow);
1810 void UpdateToolBarActiveConfigs(bool selectionOnly)
1812 bool commonSelected = false;
1813 DataRow row = toolBar.activeConfig.currentRow;
1815 row = toolBar.activeConfig.FindRow(1);
1818 toolBar.activeConfig.Clear();
1819 row = toolBar.activeConfig.AddString($"(Mixed)");
1824 char * configName = null;
1827 Map<String, int> configs { }; // TOIMP: just need sort but using map until containers have sort
1828 for(prj : workspace.projects)
1830 for(cfg : prj.configurations)
1833 configs[cfg.name] = 1;
1838 toolBar.activeConfig.AddString(&name);
1842 if(projectView && projectView.project)
1844 for(prj : workspace.projects)
1846 if(prj.config && prj.config.name)
1848 configName = prj.config.name;
1854 commonSelected = true;
1855 for(prj : workspace.projects)
1857 if(prj.config && (!prj.config.name || strcmp(prj.config.name, configName)))
1859 commonSelected = false;
1867 commonSelected = false;
1868 for(row = toolBar.activeConfig.firstRow; row; row = row.next)
1870 if(!strcmp(row.string, configName))
1872 toolBar.activeConfig.currentRow = row;
1873 commonSelected = true;
1880 toolBar.activeConfig.Sort(null, 0);
1882 toolBar.activeConfig.currentRow = row;
1887 bool unavailable = !project;
1889 projectAddItem.disabled = unavailable;
1890 toolBar.buttonAddProject.disabled = unavailable;
1892 projectSettingsItem.disabled = unavailable;
1894 projectBrowseFolderItem.disabled = unavailable;
1896 viewProjectItem.disabled = unavailable;
1898 toolBar.activeConfig.disabled = unavailable;
1899 toolBar.activeCompiler.disabled = unavailable;
1900 toolBar.activeBitDepth.disabled = unavailable;
1903 debugUseValgrindItem.disabled = unavailable;
1904 AdjustValgrindMenus();
1913 void AdjustValgrindMenus()
1915 bool unavailable = !project || !debugUseValgrindItem.checked;
1916 debugValgrindNoLeakCheckItem.disabled = unavailable;
1917 debugValgrindSummaryLeakCheckItem.disabled = unavailable;
1918 debugValgrindYesLeakCheckItem.disabled = unavailable;
1919 debugValgrindFullLeakCheckItem.disabled = unavailable;
1921 debugValgrindTrackOriginsItem.disabled = unavailable;
1923 debugValgrindRS0Item.disabled = unavailable;
1924 debugValgrindRS16Item.disabled = unavailable;
1925 debugValgrindRS32Item.disabled = unavailable;
1926 debugValgrindRS64Item.disabled = unavailable;
1927 debugValgrindRS128Item.disabled = unavailable;
1928 debugValgrindRS256Item.disabled = unavailable;
1929 debugValgrindRS512Item.disabled = unavailable;
1933 property bool hasOpenedCodeEditors
1938 for(w = firstChild; w; w = w.next)
1939 if(w._class == class(CodeEditor) &&
1940 w.isDocument && !w.closing && w.visible && w.created &&
1941 w.fileName && w.fileName[0])
1947 void AdjustFileMenus()
1949 bool unavailable = project != null || !hasOpenedCodeEditors; // are they supported source code (ec, c, cpp, etc) ?
1951 projectQuickItem.disabled = unavailable;
1954 void AdjustBuildMenus()
1956 bool unavailable = project && projectView.buildInProgress;
1957 bool naForRun = unavailable || !project || project.GetTargetType(project.config) != executable;
1959 projectNewItem.disabled = unavailable;
1960 toolBar.buttonNewProject.disabled = unavailable;
1961 projectOpenItem.disabled = unavailable;
1962 toolBar.buttonOpenProject.disabled = unavailable;
1964 unavailable = !project || projectView.buildInProgress;
1966 projectCloseItem.disabled = unavailable;
1967 // toolBar.buttonCloseProject.disabled = unavailable;
1969 projectRunItem.disabled = naForRun;
1970 toolBar.buttonRun.disabled = naForRun;
1972 projectBuildItem.disabled = false;
1973 projectBuildItem.text = unavailable ? $"Stop Build" : $"Build";
1974 projectBuildItem.accelerator = unavailable ? Key { pauseBreak, ctrl = true } : f7;
1976 projectLinkItem.disabled = unavailable;
1977 toolBar.buttonReLink.disabled = unavailable;
1978 projectRebuildItem.disabled = unavailable;
1979 toolBar.buttonRebuild.disabled = unavailable;
1980 projectCleanItem.disabled = unavailable;
1981 toolBar.buttonClean.disabled = unavailable;
1982 projectCleanTargetItem.disabled = unavailable;
1983 projectRealCleanItem.disabled = unavailable;
1984 // toolBar.buttonRealClean.disabled = unavailable;
1985 projectRegenerateItem.disabled = unavailable;
1986 toolBar.buttonRegenerateMakefile.disabled = unavailable;
1987 #ifdef IDE_SHOW_INSTALL_MENU_BUTTON
1988 projectInstallItem.disabled = unavailable;
1989 toolBar.buttonInstall.disabled = unavailable;
1991 projectCompileItem.disabled = unavailable;
1993 AdjustPopupBuildMenus();
1996 void AdjustPopupBuildMenus()
1998 bool unavailable = !project || projectView.buildInProgress;
2000 if(projectView && projectView.popupMenu && projectView.popupMenu.menu && projectView.popupMenu.created)
2003 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectBuild, 0);
2006 menu.disabled = false;
2007 menu.text = unavailable ? $"Stop Build" : $"Build";
2008 menu.accelerator = unavailable ? Key { pauseBreak, ctrl = true } : f7;
2011 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectLink, 0); if(menu) menu.disabled = unavailable;
2012 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRebuild, 0); if(menu) menu.disabled = unavailable;
2013 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectCleanTarget, 0); if(menu) menu.disabled = unavailable;
2014 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectClean, 0); if(menu) menu.disabled = unavailable;
2015 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRealClean, 0); if(menu) menu.disabled = unavailable;
2016 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRegenerate, 0); if(menu) menu.disabled = unavailable;
2017 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectInstall, 0); if(menu) menu.disabled = unavailable;
2018 menu = projectView.popupMenu.menu.FindItem(ProjectView::ProjectRemove, 0); if(menu) menu.disabled = unavailable;
2019 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileClean, 0); if(menu) menu.disabled = unavailable;
2020 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileCompile, 0); if(menu) menu.disabled = unavailable;
2021 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugPrecompile, 0); if(menu) menu.disabled = unavailable;
2022 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugCompile, 0); if(menu) menu.disabled = unavailable;
2023 menu = projectView.popupMenu.menu.FindItem(ProjectView::FileDebugGenerateSymbols, 0); if(menu) menu.disabled = unavailable;
2024 projectView.popupMenu.Update(null);
2028 property bool areDebugMenusUnavailable { get {
2030 project.GetTargetType(project.config) != executable ||
2031 projectView.buildInProgress == buildingMainProject;
2034 property bool isBreakpointTogglingUnavailable { get {
2038 property bool isDebuggerExecuting { get {
2042 return ide.debugger.state == running;
2045 void AdjustDebugMenus()
2047 bool unavailable = areDebugMenusUnavailable;
2048 bool active = debugger.isActive;
2049 bool bpNoToggle = isBreakpointTogglingUnavailable;
2050 bool executing = isDebuggerExecuting;
2051 //bool holding = debugger.state == stopped;
2053 debugStartResumeItem.disabled = unavailable || executing;
2054 debugStartResumeItem.text = active ? $"Resume" : $"Start";
2055 debugStartResumeItem.NotifySelect = active ? MenuDebugResume : MenuDebugStart;
2058 toolBar.buttonDebugStartResume.disabled = unavailable || executing;
2059 toolBar.buttonDebugStartResume.toolTip = active ? $"Resume" : $"Start";
2062 debugBreakItem.disabled = unavailable || !executing;
2063 debugStopItem.disabled = unavailable || !active;
2064 debugRestartItem.disabled = unavailable || !active;
2067 toolBar.buttonDebugPause.disabled = unavailable || !executing;
2068 toolBar.buttonDebugStop.disabled = unavailable || !active;
2069 toolBar.buttonDebugRestart.disabled = unavailable || !active;
2072 debugStepIntoItem.disabled = unavailable || executing;
2073 debugStepOverItem.disabled = unavailable || executing;
2074 debugStepOutItem.disabled = unavailable || executing || !active;
2075 debugSkipStepOverItem.disabled = unavailable || executing;
2076 debugSkipStepOutItem.disabled = unavailable || executing || !active;
2079 toolBar.buttonDebugStepInto.disabled = unavailable || executing;
2080 toolBar.buttonDebugStepOver.disabled = unavailable || executing;
2081 toolBar.buttonDebugStepOut.disabled = unavailable || executing || !active;
2082 toolBar.buttonDebugSkipStepOver.disabled = unavailable || executing;
2083 // toolBar.buttonDebugSkipStepOutItem.disabled = unavailable || executing;
2085 if((Designer)GetActiveDesigner())
2087 CodeEditor codeEditor = ((Designer)GetActiveDesigner()).codeEditor;
2089 codeEditor.AdjustDebugMenus(unavailable, bpNoToggle, executing);
2093 void ChangeFileDialogsDirectory(char * directory, bool saveSettings)
2095 char tempString[MAX_LOCATION];
2096 strcpy(tempString, directory);
2097 if(saveSettings && !projectView)
2099 ideSettings.ideFileDialogLocation = directory;
2100 settingsContainer.Save();
2103 ideFileDialog.currentDirectory = tempString;
2104 codeEditorFileDialog.currentDirectory = tempString;
2105 codeEditorFormFileDialog.currentDirectory = tempString;
2108 void ChangeProjectFileDialogDirectory(char * directory)
2110 ideSettings.ideProjectFileDialogLocation = directory;
2111 settingsContainer.Save();
2114 Window FindWindow(char * filePath)
2116 Window document = null;
2118 // TOCHECK: Do we need to change slashes here?
2119 for(document = firstChild; document; document = document.next)
2121 char * fileName = document.fileName;
2122 if(document.isDocument && fileName && !fstrcmp(fileName, filePath))
2124 document.visible = true;
2125 document.Activate();
2132 bool DontTerminateDebugSession(char * title)
2134 if(debugger.isActive)
2136 if(MessageBox { type = yesNo, master = ide,
2137 contents = $"Do you want to terminate the debugging session in progress?",
2138 text = title }.Modal() == no)
2141 MessageBox msg { type = yesNo, master = ide,
2142 contents = "Do you want to terminate the debugging session in progress?",
2144 if(msg.Modal() == no)
2156 Window OpenFile(char * origFilePath, WindowState state, bool visible, char * type, OpenCreateIfFails createIfFails, OpenMethod openMethod, bool noParsing)
2158 char extension[MAX_EXTENSION] = "";
2159 Window document = null;
2160 bool isProject = false;
2161 bool needFileModified = true;
2162 char winFilePath[MAX_LOCATION];
2163 char * filePath = strstr(origFilePath, "http://") == origFilePath ? strcpy(winFilePath, origFilePath) : GetSystemPathBuffer(winFilePath, origFilePath);
2167 GetExtension(filePath, extension);
2171 strcpy(extension, type);
2173 if(strcmp(extension, ProjectExtension))
2175 for(document = firstChild; document; document = document.next)
2177 char * fileName = document.fileName;
2178 if(document.isDocument && fileName && !fstrcmp(fileName, filePath) && document.created)
2180 document.visible = true;
2182 document.Activate();
2188 if(createIfFails == whatever)
2190 else if(!strcmp(extension, ProjectExtension) || !strcmp(extension, WorkspaceExtension))
2192 needFileModified = false;
2193 if(openMethod == normal)
2195 if(DontTerminateDebugSession($"Open Project"))
2205 Workspace workspace = null;
2207 if(FileExists(filePath))
2209 if(!strcmp(extension, ProjectExtension))
2211 char workspaceFile[MAX_LOCATION];
2212 strcpy(workspaceFile, filePath);
2213 ChangeExtension(workspaceFile, WorkspaceExtension, workspaceFile);
2214 workspace = LoadWorkspace(workspaceFile, filePath);
2216 else if(!strcmp(extension, WorkspaceExtension))
2217 workspace = LoadWorkspace(filePath, null);
2220 //project = LoadProject(filePath, null);
2225 char absolutePath[MAX_LOCATION];
2226 CreateProjectView(workspace, filePath);
2227 document = projectView;
2229 workspace.DropInvalidBreakpoints();
2232 ide.projectView.ShowOutputBuildLog(true);
2234 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
2235 ide.projectView.DisplayCompiler(compiler, false);
2238 UpdateCompilerConfigs(false);
2241 char newWorkingDir[MAX_LOCATION];
2242 StripLastDirectory(filePath, newWorkingDir);
2243 ChangeFileDialogsDirectory(newWorkingDir, false);
2246 document.fileName = filePath;
2248 ideMainFrame.SetText("%s - %s", filePath, titleECEREIDE);
2250 // this crashes on starting ide with epj file, solution please?
2251 // app.UpdateDisplay();
2253 workspace.holdTracking = true;
2254 for(ofi : workspace.openedFiles)
2256 if(ofi.state != closed)
2258 Window file = OpenFile(ofi.path, normal, true, null, no, normal, noParsing);
2261 char fileName[MAX_LOCATION];
2263 GetLastDirectory(ofi.path, fileName);
2264 node = projectView.project.topNode.Find(fileName, true);
2266 node.EnsureVisible();
2270 ide.RepositionWindows(false);
2271 workspace.holdTracking = false;
2273 workspace.timer.Start();
2275 findInFilesDialog.mode = FindInFilesMode::project;
2276 findInFilesDialog.currentDirectory = ide.project.topNode.path;
2279 char location[MAX_LOCATION];
2280 StripLastDirectory(ide.project.topNode.path, location);
2281 ChangeProjectFileDialogDirectory(location);
2285 if(projectView.debugger)
2286 projectView.debugger.EvaluateWatches();
2293 if(MessageBox { type = yesNo, master = this, text = $"Error opening project", contents = $"Open a different project?" }.Modal() == yes)
2295 ideProjectFileDialog.text = openProjectFileDialogTitle;
2296 if(ideProjectFileDialog.Modal() == cancel)
2298 filePath = ideProjectFileDialog.filePath;
2299 GetExtension(filePath, extension);
2310 else if(openMethod == add)
2315 char slashFilePath[MAX_LOCATION];
2316 GetSlashPathBuffer(slashFilePath, filePath);
2317 for(p : workspace.projects)
2319 if(!fstrcmp(p.filePath, slashFilePath))
2327 MessageBox { type = ok, parent = parent, master = this, text = $"Same Project",
2328 contents = $"This project is already present in workspace." }.Modal();
2332 prj = LoadProject(filePath, null);
2335 char * activeConfigName = null;
2336 CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.compiler);
2337 prj.StartMonitoring();
2338 workspace.projects.Add(prj);
2339 if(toolBar.activeConfig.currentRow && toolBar.activeConfig.currentRow != toolBar.activeConfig.firstRow &&
2340 toolBar.activeConfig.currentRow.string && toolBar.activeConfig.currentRow.string[0])
2341 activeConfigName = toolBar.activeConfig.currentRow.string;
2342 if(activeConfigName)
2344 for(cfg : prj.configurations)
2346 if(cfg.name && !strcmp(cfg.name, activeConfigName))
2354 projectView.AddNode(prj.topNode, null);
2355 workspace.modified = true;
2357 findInFilesDialog.AddProjectItem(prj);
2358 projectView.ShowOutputBuildLog(true);
2359 projectView.DisplayCompiler(compiler, false);
2360 projectView.ProjectUpdateMakefileForAllConfigs(prj);
2364 char location[MAX_LOCATION];
2365 StripLastDirectory(prj.topNode.path, location);
2366 ChangeProjectFileDialogDirectory(location);
2369 // projectView is associated with the main project and not with the one just added but
2370 return projectView; // just to let the caller know something was opened
2378 else if(!strcmp(extension, "bmp") || !strcmp(extension, "pcx") ||
2379 !strcmp(extension, "jpg") || !strcmp(extension, "gif") ||
2380 !strcmp(extension, "jpeg") || !strcmp(extension, "png"))
2382 if(FileExists(filePath))
2383 document = PictureEdit { hasMaximize = true, hasMinimize = true, hasClose = true, borderStyle = sizable,
2384 hasVertScroll = true, hasHorzScroll = true, parent = this, state = state,
2385 visible = visible, bitmapFile = filePath, OnClose = PictureEditOnClose/*why?--GenericDocumentOnClose*/;
2388 MessageBox { type = ok, master = this, text = filePath, contents = $"File doesn't exist." }.Modal();
2391 else if(!strcmp(extension, "3ds"))
2393 if(FileExists(filePath))
2394 document = ModelView { hasMaximize = true, hasMinimize = true, hasClose = true, borderStyle = sizable,
2395 hasVertScroll = true, hasHorzScroll = true, parent = this, state = state,
2396 visible = visible, modelFile = filePath, OnClose = ModelViewOnClose/*why?--GenericDocumentOnClose*/
2400 MessageBox { type = ok, master = this, text = filePath, contents = $"File doesn't exist." }.Modal();
2403 else if(!strcmp(extension, "txt") || !strcmp(extension, "text") ||
2404 !strcmp(extension, "nfo") || !strcmp(extension, "info") ||
2405 !strcmp(extension, "htm") || !strcmp(extension, "html") ||
2406 !strcmp(extension, "css") || !strcmp(extension, "php") ||
2407 !strcmp(extension, "js"))
2409 CodeEditor editor { parent = this, state = state, visible = false, noParsing = noParsing };
2410 editor.updatingCode = true;
2411 if(editor.LoadFile(filePath))
2414 editor.visible = true;
2418 needFileModified = false;
2422 CodeEditor editor { parent = this, state = state, visible = false, noParsing = noParsing };
2423 if(editor.LoadFile(filePath))
2426 editor.visible = true;
2430 needFileModified = false;
2433 if(document && (document._class == class(PictureEdit) ||
2434 document._class == class(ModelView)))
2439 document.fileName = filePath;
2440 if(workspace && !workspace.holdTracking)
2441 workspace.UpdateOpenedFileInfo(filePath, opened);
2445 if(!document && createIfFails != no)
2447 if(createIfFails != yes && !needFileModified &&
2448 MessageBox { type = yesNo, master = this, text = filePath, contents = $"File doesn't exist. Create?" }.Modal() == yes)
2449 createIfFails = yes;
2450 if(createIfFails == yes || createIfFails == whatever)
2452 document = (Window)NewCodeEditor(this, state, true);
2454 document.fileName = filePath;
2460 if(projectView && document._class == class(CodeEditor) && workspace)
2462 int lineNumber, position;
2464 CodeEditor editor = (CodeEditor)document;
2465 editor.openedFileInfo = workspace.UpdateOpenedFileInfo(filePath, opened);
2466 editor.openedFileInfo.holdTracking = true;
2467 lineNumber = Max(editor.openedFileInfo.lineNumber - 1, 0);
2468 position = Max(editor.openedFileInfo.position - 1, 0);
2469 editor.editBox.GoToLineNum(lineNumber);
2470 editor.editBox.GoToPosition(editor.editBox.line, lineNumber, position);
2471 scroll.x = Max(editor.openedFileInfo.scroll.x, 0);
2472 scroll.y = Max(editor.openedFileInfo.scroll.y, 0);
2473 editor.editBox.scroll = scroll;
2474 editor.openedFileInfo.holdTracking = false;
2477 if(needFileModified)
2478 document.OnFileModified = OnFileModified;
2479 document.NotifySaved = DocumentSaved;
2482 ideSettings.AddRecentProject(document.fileName);
2484 ideSettings.AddRecentFile(document.fileName);
2485 ide.UpdateRecentMenus();
2486 ide.AdjustFileMenus();
2487 settingsContainer.Save();
2495 // TOCHECK: I can't use a generic one for both ModelView and PictureEdit both derived from Window
2496 /*bool Window::GenericDocumentOnClose(bool parentClosing)
2498 if(!parentClosing && ide.workspace)
2499 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2502 bool ModelView::ModelViewOnClose(bool parentClosing)
2504 if(!parentClosing && ide.workspace)
2505 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2508 bool PictureEdit::PictureEditOnClose(bool parentClosing)
2510 if(!parentClosing && ide.workspace)
2511 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
2516 void OnUnloadGraphics(Window window)
2518 display.ClearMaterials();
2519 display.ClearTextures();
2520 display.ClearMeshes();
2524 bool OnActivate(bool active, Window swap, bool * goOnWithActivation, bool direct)
2526 caps.color = app.GetKeyState(capsState) ? black : Color { 128,128,128 };
2527 num.color = app.GetKeyState(numState) ? black : Color { 128,128,128 };
2531 bool OnKeyDown(Key key, unichar ch)
2536 projectView.Update(null);
2539 caps.color = app.GetKeyState(capsState) ? black : Color { 128,128,128 };
2542 num.color = app.GetKeyState(numState) ? black : Color { 128,128,128 };
2548 void GoToError(const char * line, bool noParsing)
2551 projectView.GoToError(line, noParsing);
2554 void CodeLocationParseAndGoTo(const char * text, Project project, const char * dir)
2558 char *colon = strchr(text, ':');
2559 char filePath[MAX_LOCATION] = "";
2560 char completePath[MAX_LOCATION];
2561 int line = 0, col = 0;
2562 int len = strlen(text);
2564 FileAttribs fileAttribs;
2566 // support for valgrind output
2567 if((s = strstr(text, "==")) && (s = strstr(s+2, "==")) && (s = strstr(s+2, ":")) && (s = strstr(s+1, ":")))
2578 /*for(s=colon; *s; s++)
2587 //line = atoi(colon+1);
2589 // support for "Found n match(es) in "file/path";
2590 else if(path[len-1] == '\"' && strstr(path, $"Found %d match%s in \"%s\"%s\n\n"."Found") && strstr(path, $"match") && strstr(path, $"in") && (s = strstr(path, "\"")) && s != path+len-1)
2596 if(colon && (colon[1] == '/' || colon[1] == '\\'))
2598 path = (colon - 1 > path) ? colon - 1 : path;
2599 colon = strstr(colon + 1, ":");
2601 if(*path == '*' && (s = strchr(path+1, '*')))
2603 while(isspace(*path)) path++;
2607 char * close = strchr(path, ')');
2611 strncpy(name, path+1, close - path - 1);
2612 name[close - path - 1] = '\0';
2613 for(p : ide.workspace.projects)
2615 if(!strcmp(p.name, name))
2625 prj = project ? project : (dir ? null : ide.project);
2628 strncpy(filePath, path, colon - path);
2629 filePath[colon - path] = '\0';
2630 line = atoi(colon + 1);
2631 colon = strstr(colon + 1, ":");
2633 col = atoi(colon + 1);
2635 else if(path - 1 >= text && *(path - 1) == '\"')
2637 colon = strchr(path, '\"');
2640 strncpy(filePath, path, colon - path);
2641 filePath[colon - path] = '\0';
2644 else if(path && !colon)
2646 strcpy(filePath, path);
2652 strcpy(completePath, prj.topNode.path);
2653 else if(dir && dir[0])
2654 strcpy(completePath, dir);
2656 completePath[0] = '\0';
2657 PathCat(completePath, filePath);
2659 if((fileAttribs = FileExists(completePath)))
2660 CodeLocationGoTo(completePath, fileAttribs, line, col);
2661 else if(ide.workspace)
2664 for(p : ide.workspace.projects)
2666 strcpy(completePath, p.topNode.path);
2667 PathCat(completePath, filePath);
2668 if((fileAttribs = FileExists(completePath)).isFile)
2670 CodeLocationGoTo(completePath, fileAttribs, line, col);
2677 for(p : ide.workspace.projects)
2679 ProjectNode node = p.topNode.Find(filePath, false);
2682 node.GetFullFilePath(completePath);
2683 if((fileAttribs = FileExists(completePath)).isFile)
2685 CodeLocationGoTo(completePath, fileAttribs, line, col);
2695 void CodeLocationGoTo(const char * path, const FileAttribs fileAttribs, int line, int col)
2697 if(fileAttribs.isFile)
2699 char ext[MAX_EXTENSION];
2700 GetExtension(path, ext);
2701 if(!strcmp(ext, "mp3") || !strcmp(ext, "flac") || !strcmp(ext, "ogg") || !strcmp(ext, "avi") || !strcmp(ext, "mkv"))
2703 else if(!strcmp(ext, "a") || !strcmp(ext, "o") || !strcmp(ext, "lib") || !strcmp(ext, "dll") || !strcmp(ext, "exe"))
2705 char dirPath[MAX_LOCATION];
2706 StripLastDirectory(path, dirPath);
2711 CodeEditor codeEditor = (CodeEditor)OpenFile(path, normal, true, ext, no, normal, false);
2712 if(codeEditor && line)
2714 EditBox editBox = codeEditor.editBox;
2715 editBox.GoToLineNum(line - 1);
2716 editBox.GoToPosition(editBox.line, line - 1, col ? (col - 1) : 0);
2720 else if(fileAttribs.isDirectory)
2724 void OnRedraw(Surface surface)
2726 Bitmap bitmap = back.bitmap;
2728 surface.Blit(bitmap, (clientSize.w - bitmap.width) / 2, (clientSize.h - bitmap.height) / 2, 0, 0, bitmap.width, bitmap.height);
2731 void SheetSelected(SheetType sheetSelected)
2733 if(activeChild == sheet)
2735 if(sheetSelected == methods)
2737 viewPropertiesItem.accelerator = f4;
2738 viewPropertiesItem.parent = viewMenu;
2739 viewMethodsItem.parent = null;
2743 viewMethodsItem.accelerator = f4;
2744 viewMethodsItem.parent = viewMenu;
2745 viewPropertiesItem.parent = null;
2750 viewMethodsItem.parent = viewMenu;
2751 viewPropertiesItem.parent = viewMenu;
2752 if(sheetSelected == methods)
2754 viewMethodsItem.accelerator = f4;
2755 viewPropertiesItem.accelerator = 0;
2759 viewMethodsItem.accelerator = 0;
2760 viewPropertiesItem.accelerator = f4;
2765 void OnActivateClient(Window client, Window previous)
2767 //if(!client || client != previous)
2770 if(!client || client != previous)
2773 dataType = previous._class;
2774 if(previous && !strcmp(dataType.name, "CodeEditor"))
2776 ((CodeEditor)previous).UpdateFormCode();
2778 else if(previous && !strcmp(dataType.name, "Designer"))
2780 ((Designer)previous).codeEditor.UpdateFormCode();
2785 dataType = client._class;
2786 if(client && !strcmp(dataType.name, "CodeEditor"))
2788 CodeEditor codeEditor = (CodeEditor)client;
2789 SetPrivateModule(codeEditor.privateModule);
2790 SetCurrentContext(codeEditor.globalContext);
2791 SetTopContext(codeEditor.globalContext);
2792 SetGlobalContext(codeEditor.globalContext);
2794 SetDefines(&codeEditor.defines);
2795 SetImports(&codeEditor.imports);
2797 SetActiveDesigner(codeEditor.designer);
2799 sheet.codeEditor = codeEditor;
2800 toolBox.codeEditor = codeEditor;
2802 viewDesignerItem.parent = viewMenu;
2803 if(activeChild != codeEditor)
2805 viewCodeItem.parent = viewMenu;
2806 viewDesignerItem.accelerator = 0;
2807 viewCodeItem.accelerator = f8;
2811 viewCodeItem.parent = null;
2812 viewDesignerItem.accelerator = f8;
2815 else if(client && !strcmp(dataType.name, "Designer"))
2817 CodeEditor codeEditor = ((Designer)client).codeEditor;
2820 SetPrivateModule(codeEditor.privateModule);
2821 SetCurrentContext(codeEditor.globalContext);
2822 SetTopContext(codeEditor.globalContext);
2823 SetGlobalContext(codeEditor.globalContext);
2824 SetDefines(&codeEditor.defines);
2825 SetImports(&codeEditor.imports);
2829 SetPrivateModule(null);
2830 SetCurrentContext(null);
2831 SetTopContext(null);
2832 SetGlobalContext(null);
2837 SetActiveDesigner((Designer)client);
2839 sheet.codeEditor = codeEditor;
2840 toolBox.codeEditor = codeEditor;
2842 viewCodeItem.parent = viewMenu;
2843 if(activeChild != client)
2845 viewDesignerItem.parent = viewMenu;
2846 viewDesignerItem.accelerator = f8;
2847 viewCodeItem.accelerator = 0;
2851 viewDesignerItem.parent = null;
2852 viewCodeItem.accelerator = f8;
2858 sheet.codeEditor = null;
2859 toolBox.codeEditor = null;
2860 SetActiveDesigner(null);
2862 viewDesignerItem.parent = null;
2863 viewCodeItem.parent = null;
2866 SheetSelected(sheet.sheetSelected);
2869 projectCompileItem = null;
2874 if(client && client._class == eSystem_FindClass(__thisModule, "CodeEditor")) // !strcmp(client._class.name, "CodeEditor")
2876 CodeEditor codeEditor = (CodeEditor)client;
2877 EditBox editBox = codeEditor.editBox;
2879 statusBar.AddField(pos);
2881 caps = { width = 40, text = $"CAPS", color = app.GetKeyState(capsState) ? black : Color { 128, 128, 128 } };
2882 statusBar.AddField(caps);
2884 ovr = { width = 30, text = $"OVR", color = (editBox && editBox.overwrite) ? black : Color { 128, 128, 128 } };
2885 statusBar.AddField(ovr);
2887 num = { width = 30, text = $"NUM", color = app.GetKeyState(numState) ? black : Color { 128, 128, 128 } };
2888 statusBar.AddField(num);
2890 //statusBar.text = "Ready";
2892 if(projectView && projectView.project)
2894 bool isCObject = false;
2895 ProjectNode node = projectView.GetNodeFromWindow(client, null, false);
2896 if(!node && (node = projectView.GetNodeFromWindow(client, null, true)))
2900 char nodeName[MAX_FILENAME];
2901 char name[MAX_FILENAME+96];
2903 ChangeExtension(node.name, "c", nodeName);
2904 sprintf(name, $"Compile %s", isCObject ? nodeName : node.name);
2905 projectCompileItem =
2907 copyText = true, text = name, c, ctrlF7, disabled = projectView.buildInProgress;
2909 bool NotifySelect(MenuItem selection, Modifiers mods)
2913 bool result = false;
2914 bool isCObject = false;
2915 ProjectNode node = null;
2916 for(p : ide.workspace.projects)
2918 node = projectView.GetNodeFromWindow(activeClient, p, false);
2921 if(!node && (node = projectView.GetNodeFromWindow(activeClient, null, true)))
2925 List<ProjectNode> nodes { };
2927 projectView.Compile(node.project, nodes, mods.ctrl && mods.shift, isCObject ? cObject : normal);
2932 ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
2937 projectMenu.AddDynamic(projectCompileItem, ide, false);
2943 caps = ovr = num = null;
2948 bool OnClose(bool parentClosing)
2950 //return !projectView.buildInProgress;
2951 if(projectView && projectView.buildInProgress)
2953 if(DontTerminateDebugSession($"Close IDE"))
2955 if(findInFilesDialog)
2956 findInFilesDialog.SearchStop();
2959 workspace.timer.Stop();
2962 ideMainFrame.Destroy(0);
2969 bool passThrough = false;
2970 bool debugStart = false;
2971 bool debugWorkDir = false;
2972 char * passDebugWorkDir = null;
2973 bool openAsText = false;
2974 DynamicString passArgs { };
2977 for(c = 1; c<app.argc; c++)
2981 char * arg = app.argv[c];
2982 char * buf = new char[strlen(arg)*2+1];
2984 passArgs.concat(" ");
2986 passArgs.concat(buf);
2989 else if(debugWorkDir)
2991 passDebugWorkDir = CopyString(app.argv[c]);
2992 StripQuotes(passDebugWorkDir, passDebugWorkDir);
2993 debugWorkDir = false;
2995 else if(!strcmp(app.argv[c], "-t"))
2997 else if(!strcmp(app.argv[c], "-no-parsing"))
2998 ide.noParsing = true;
2999 else if(!strcmp(app.argv[c], "-debug-start"))
3001 else if(!strcmp(app.argv[c], "-debug-work-dir"))
3002 debugWorkDir = true;
3003 else if(!strcmp(app.argv[c], "-@"))
3007 char fullPath[MAX_LOCATION];
3008 char parentPath[MAX_LOCATION];
3009 char ext[MAX_EXTENSION];
3011 FileAttribs dirAttribs;
3012 GetWorkingDir(fullPath, MAX_LOCATION);
3013 PathCat(fullPath, app.argv[c]);
3014 StripLastDirectory(fullPath, parentPath);
3015 GetExtension(app.argv[c], ext);
3016 isProject = !openAsText && !strcmpi(ext, "epj");
3018 if(isProject && c > (debugStart ? 2 : 1)) continue;
3020 // Create directory for projects (only)
3021 if(((dirAttribs = FileExists(parentPath)) && dirAttribs.isDirectory) || isProject)
3023 if(isProject && !FileExists(fullPath))
3025 char name[MAX_LOCATION];
3026 NewProjectDialog newProjectDialog;
3030 projectView.visible = false;
3031 if(!projectView.Destroy(0))
3035 newProjectDialog = { master = this };
3037 strcpy(name, app.argv[c]);
3038 StripExtension(name);
3039 GetLastDirectory(name, name);
3040 newProjectDialog.projectName.contents = name;
3041 newProjectDialog.projectName.NotifyModified(newProjectDialog, newProjectDialog.projectName);
3042 newProjectDialog.locationEditBox.path = parentPath;
3043 newProjectDialog.NotifyModifiedLocation(newProjectDialog.locationEditBox);
3045 incref newProjectDialog;
3046 newProjectDialog.Modal();
3049 ideSettings.AddRecentProject(projectView.fileName);
3050 ide.UpdateRecentMenus();
3051 settingsContainer.Save();
3053 delete newProjectDialog;
3054 // Open only one project
3058 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, openAsText ? "txt" : null, yes, normal, false);
3060 else if(strstr(fullPath, "http://") == fullPath)
3061 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, openAsText ? "txt" : null, yes, normal, false);
3064 if(passThrough && projectView && projectView.project && workspace)
3065 workspace.commandLineArgs = passArgs;
3066 if(passDebugWorkDir && projectView && projectView.project && workspace)
3068 workspace.debugDir = passDebugWorkDir;
3069 delete passDebugWorkDir;
3072 ;//MenuDebugStart(debugStartResumeItem, 0); // <-- how TODO this without getting into the app.Wait lock
3074 UpdateToolBarActiveConfigs(false);
3075 UpdateToolBarActiveCompilers();
3082 // IS THIS NEEDED? WASN'T HERE BEFORE... Crashes on getting node's projectView otherwise
3085 projectView.visible = false;
3086 projectView.Destroy(0);
3089 #ifdef GDB_DEBUG_GUI
3090 gdbDialog.Destroy(0);
3095 void SetPath(bool projectsDirs, CompilerConfig compiler, ProjectConfig config, int bitDepth)
3099 char * oldPaths[128];
3100 String oldList = new char[maxPathLen];
3101 Array<String> newExePaths { };
3102 //Map<String, bool> exePathExists { };
3104 #if defined(__unix__) || defined(__APPLE__)
3105 Array<String> newLibPaths { };
3106 Map<String, bool> libPathExists { };
3111 for(prj : workspace.projects)
3113 DirExpression targetDirExp;
3115 // SKIP FIRST PROJECT...
3116 if(prj == workspace.projects.firstIterator.data) continue;
3118 // NOTE: Right now the additional project config dir will be
3119 // obtained when the debugger is started, so toggling it
3120 // while building will change which library gets used.
3121 // To go with the initial state, e.g. when F5 was pressed,
3122 // we nould need to keep a list of all project's active
3123 // config upon startup.
3124 targetDirExp = prj.GetTargetDir(compiler, prj.config, bitDepth);
3126 /*if(prj.config.targetType == sharedLibrary && prj.config.debug)
3130 for(cfg = prj.configurations.first; cfg; cfg = cfg.next)
3131 if(cfg.targetType == sharedLibrary && cfg.debug && !strcmpi(cfg.name, "Debug"))
3135 for(cfg = prj.configurations.first; cfg; cfg = cfg.next)
3136 if(cfg.targetType == sharedLibrary && cfg.debug)
3140 if(targetDirExp.dir)
3142 char buffer[MAX_LOCATION];
3143 #if defined(__WIN32__)
3144 Array<String> paths = newExePaths;
3146 Array<String> paths = newLibPaths;
3148 GetSystemPathBuffer(buffer, prj.topNode.path);
3149 PathCat(buffer, targetDirExp.dir);
3152 if(!fstrcmp(p, buffer))
3159 paths.Add(CopyString(buffer));
3161 delete targetDirExp;
3165 for(item : compiler.executableDirs)
3168 for(p : newExePaths)
3170 if(!fstrcmp(p, item))
3177 newExePaths.Add(CopySystemPath(item));
3180 GetEnvironment("PATH", oldList, maxPathLen);
3182 printf("Old value of PATH: %s\n", oldList);
3184 count = TokenizeWith(oldList, sizeof(oldPaths) / sizeof(char *), oldPaths, pathListSep, false);
3185 for(c = 0; c < count; c++)
3188 for(p : newExePaths)
3190 if(!fstrcmp(p, oldPaths[c]))
3197 newExePaths.Add(CopySystemPath(oldPaths[c]));
3201 for(path : newExePaths)
3202 len += strlen(path) + 1;
3203 newList = new char[len + 1];
3205 for(path : newExePaths)
3207 strcat(newList, path);
3208 strcat(newList, pathListSep);
3210 newList[len - 1] = '\0';
3211 SetEnvironment("PATH", newList);
3213 printf("New value of PATH: %s\n", newList);
3220 #if defined(__unix__) || defined(__APPLE__)
3222 for(item : compiler.libraryDirs)
3224 if(!libPathExists[item]) // fstrcmp should be used
3226 String s = CopyString(item);
3228 libPathExists[s] = true;
3232 #if defined(__APPLE__)
3233 GetEnvironment("DYLD_LIBRARY_PATH", oldList, maxPathLen);
3235 GetEnvironment("LD_LIBRARY_PATH", oldList, maxPathLen);
3238 printf("Old value of [DY]LD_LIBRARY_PATH: %s\n", oldList);
3240 count = TokenizeWith(oldList, sizeof(oldPaths) / sizeof(char *), oldPaths, pathListSep, false);
3241 for(c = 0; c < count; c++)
3243 if(!libPathExists[oldPaths[c]]) // fstrcmp should be used
3245 String s = CopyString(oldPaths[c]);
3247 libPathExists[s] = true;
3252 for(path : newLibPaths)
3253 len += strlen(path) + 1;
3254 newList = new char[len + 1];
3256 for(path : newLibPaths)
3258 strcat(newList, path);
3259 strcat(newList, pathListSep);
3261 newList[len - 1] = '\0';
3262 #if defined(__APPLE__)
3263 SetEnvironment("DYLD_LIBRARY_PATH", newList);
3265 SetEnvironment("LD_LIBRARY_PATH", newList);
3268 printf("New value of [DY]LD_LIBRARY_PATH: %s\n", newList);
3274 delete libPathExists;
3277 if(compiler.distccEnabled && compiler.distccHosts)
3278 SetEnvironment("DISTCC_HOSTS", compiler.distccHosts);
3283 void DestroyTemporaryProjectDir()
3285 if(tmpPrjDir && tmpPrjDir[0])
3287 if(FileExists(tmpPrjDir).isDirectory)
3288 DestroyDir(tmpPrjDir);
3289 property::tmpPrjDir = null;
3295 // Graphics Driver Menu
3299 app.currentSkin.selectionColor = selectionColor;
3300 app.currentSkin.selectionText = selectionText;
3304 driverItems = new MenuItem[app.numDrivers];
3305 for(c = 0; c < app.numDrivers; c++)
3307 driverItems[c] = MenuItem { driversMenu, app.drivers[c], NotifySelect = NotifySelectDisplayDriver };
3308 driverItems[c].id = c;
3309 driverItems[c].isRadio = true;
3312 driverItems = new MenuItem[2];
3313 #if defined(__unix__)
3314 driverItems[0] = MenuItem { driversMenu, "X", NotifySelect = NotifySelectDisplayDriver };
3315 driverItems[0].id = 0;
3316 driverItems[0].isRadio = true;
3318 driverItems[0] = MenuItem { driversMenu, "GDI", NotifySelect = NotifySelectDisplayDriver };
3319 driverItems[0].id = 0;
3320 driverItems[0].isRadio = true;
3322 driverItems[1] = MenuItem { driversMenu, "OpenGL", NotifySelect = NotifySelectDisplayDriver };
3323 driverItems[1].id = 1;
3324 driverItems[1].isRadio = true;
3326 /* skinItems = new MenuItem[app.numSkins];
3327 for(c = 0; c < app.numSkins; c++)
3329 skinItems[c] = MenuItem {skinsMenu, app.skins[c], NotifySelect = NotifySelectDisplaySkin };
3330 skinItems[c].id = c;
3331 skinItems[c].isRadio = true;
3334 ideFileDialog.master = this;
3335 ideProjectFileDialog.master = this;
3337 //SetDriverAndSkin();
3341 void UpdateRecentMenus()
3344 Menu fileMenu = menu.FindMenu($"File");
3345 Menu recentFiles = fileMenu.FindMenu($"Recent Files");
3346 Menu recentProjects = fileMenu.FindMenu($"Recent Projects");
3347 char * itemPath = new char[MAX_LOCATION];
3348 char * itemName = new char[MAX_LOCATION+4];
3351 recentFiles.Clear();
3354 for(recent : ideSettings.recentFiles)
3356 strncpy(itemPath, recent, MAX_LOCATION); itemPath[MAX_LOCATION-1] = '\0';
3357 MakeSystemPath(itemPath);
3358 snprintf(itemName, MAX_LOCATION+4, "%d %s", 1 + c, itemPath); itemName[MAX_LOCATION+4-1] = '\0';
3359 recentFiles.AddDynamic(MenuItem { copyText = true, text = itemName, (Key)k1 + c, id = c, NotifySelect = ide.FileRecentFile }, ide, true);
3363 recentProjects.Clear();
3365 for(recent : ideSettings.recentProjects)
3367 strncpy(itemPath, recent, MAX_LOCATION); itemPath[MAX_LOCATION-1] = '\0';
3368 MakeSystemPath(itemPath);
3369 snprintf(itemName, MAX_LOCATION+4, "%d %s", 1 + c, itemPath); itemName[MAX_LOCATION+4-1] = '\0';
3370 recentProjects.AddDynamic(MenuItem { copyText = true, text = itemName, (Key)k1 + c, id = c, NotifySelect = ide.FileRecentProject }, ide, true);
3386 void DestroyDir(char * path)
3388 RecursiveDeleteFolderFSI fsi { };
3393 #if defined(__WIN32__)
3394 define sdkDirName = "Ecere SDK";
3396 define sdkDirName = "ecere";
3399 void FindAndShellOpenInstalledFolder(char * name)
3401 char * p = new char[MAX_LOCATION];
3402 char * v = new char[maxPathLen];
3405 Array<String> paths { };
3407 strncpy(p, settingsContainer.moduleLocation, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3408 StripLastDirectory(p, p);
3410 paths.Add(CopyString(p));
3411 #if defined(__WIN32__)
3412 GetEnvironment("ECERE_SDK_SRC", v, maxPathLen);
3415 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3416 PathCat(p, name); paths.Add(CopyString(p));
3418 GetEnvironment("AppData", v, maxPathLen);
3421 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3422 PathCat(p, sdkDirName); PathCat(p, name); paths.Add(CopyString(p));
3424 GetEnvironment("ProgramFiles", v, maxPathLen);
3427 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3428 PathCat(p, sdkDirName); PathCat(p, name); paths.Add(CopyString(p));
3430 GetEnvironment("ProgramFiles(x86)", v, maxPathLen);
3433 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3434 PathCat(p, sdkDirName); PathCat(p, name); paths.Add(CopyString(p));
3436 GetEnvironment("SystemDrive", v, maxPathLen);
3439 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3440 PathCat(p, "Program Files"); PathCat(p, sdkDirName); PathCat(p, name); paths.Add(CopyString(p));
3443 GetEnvironment("XDG_DATA_DIRS", v, maxPathLen);
3444 numTokens = TokenizeWith(v, sizeof(tokens) / sizeof(byte *), tokens, ":", false);
3445 for(c=0; c<numTokens; c++)
3447 strncpy(p, tokens[c], MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3448 PathCat(p, sdkDirName); PathCat(p, name); paths.Add(CopyString(p));
3453 strncpy(p, path, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3454 if(FileExists(p).isDirectory)
3466 void FindAndShellOpenInstalledFile(char * subdir, char * name)
3468 char * p = new char[MAX_LOCATION];
3469 char * v = new char[maxPathLen];
3472 Array<String> paths { };
3474 strncpy(p, settingsContainer.moduleLocation, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3475 paths.Add(CopyString(p));
3476 StripLastDirectory(p, p);
3478 paths.Add(CopyString(p));
3479 #if defined(__WIN32__)
3480 GetEnvironment("ECERE_SDK_SRC", v, maxPathLen);
3483 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3484 PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3486 GetEnvironment("AppData", v, maxPathLen);
3489 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3490 PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3492 GetEnvironment("ProgramFiles", v, maxPathLen);
3495 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3496 PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3498 GetEnvironment("ProgramFiles(x86)", v, maxPathLen);
3501 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3502 PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3504 GetEnvironment("SystemDrive", v, maxPathLen);
3507 strncpy(p, v, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3508 PathCat(p, "Program Files"); PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3511 GetEnvironment("XDG_DATA_DIRS", v, maxPathLen);
3512 numTokens = TokenizeWith(v, sizeof(tokens) / sizeof(byte *), tokens, ":", false);
3513 for(c=0; c<numTokens; c++)
3515 strncpy(p, tokens[c], MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3516 PathCat(p, sdkDirName); PathCat(p, subdir); paths.Add(CopyString(p));
3521 strncpy(p, path, MAX_LOCATION); p[MAX_LOCATION-1] = '\0';
3523 if(FileExists(p).isFile)
3535 class RecursiveDeleteFolderFSI : NormalFileSystemIterator
3537 bool preserveRootFolder;
3539 void OutFolder(char * folderPath, bool isRoot)
3541 if(!(preserveRootFolder && isRoot))
3542 RemoveDir(folderPath);
3545 bool OnFile(char * filePath)
3547 DeleteFile(filePath);
3552 class IDEApp : GuiApplication
3554 //driver = "Win32Console";
3555 // driver = "OpenGL";
3559 TempFile includeFile { };
3563 char ext[MAX_EXTENSION];
3564 SetLoggingMode(stdOut, null);
3565 //SetLoggingMode(debug, null);
3567 settingsContainer.Load();
3568 if(argc > 1 && !strcmpi(GetExtension(argv[1], ext), "3ds"))
3570 app.driver = "OpenGL";
3571 ide.driverItems[1].checked = true;
3575 #if defined(__unix__) || defined(__APPLE__)
3576 app.driver = (ideSettings.displayDriver && !strcmp(ideSettings.displayDriver, "OpenGL")) ? ideSettings.displayDriver : "X";
3578 app.driver = (ideSettings.displayDriver && !strcmp(ideSettings.displayDriver, "OpenGL")) ? ideSettings.displayDriver : "GDI";
3580 ide.driverItems[ideSettings.displayDriver && !strcmp(ideSettings.displayDriver,"OpenGL")].checked = true;
3585 desktop.text = titleECEREIDE;
3588 for(c = 1; c<app.argc; c++)
3590 char fullPath[MAX_LOCATION];
3591 GetWorkingDir(fullPath, MAX_LOCATION);
3592 PathCat(fullPath, app.argv[c]);
3593 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, null, yes, normal, false);
3597 if(!LoadIncludeFile())
3598 PrintLn("error: unable to load :crossplatform.mk file inside ide binary.");
3603 bool LoadIncludeFile()
3605 bool result = false;
3606 File include = FileOpen(":crossplatform.mk", read);
3609 File f = includeFile;
3612 for(; !include.Eof(); )
3615 int count = include.Read(buffer, 1, 4096);
3616 f.Write(buffer, 1, count);
3626 IDEMainFrame ideMainFrame { };
3628 define app = ((IDEApp)__thisModule);
3630 define titleECEREIDE = $"ECERE IDE (Debug)";
3632 define titleECEREIDE = $"ECERE IDE";