2 public import static "ecere"
3 public import static "ec"
9 import "GlobalSettingsDialog"
10 import "NewProjectDialog"
11 import "FindInFilesDialog"
12 import "ActiveCompilerDialog"
19 import "ProjectActiveConfig"
20 import "ProjectConfig"
22 import "NodeProperties"
23 import "ProjectSettings"
35 import "BreakpointsView"
36 import "CallStackView"
47 import "FileSystemIterator"
49 #if defined(__WIN32__)
50 define pathListSep = ";";
52 define pathListSep = ":";
55 enum OpenCreateIfFails { no, yes, something, whatever };
56 enum OpenMethod { normal, add };
58 static FileFilter fileFilters[] =
61 "C/C++/eC Files (*.ec, *.eh, *.c, *.cpp, *.cc, *.cxx, *.h, *.hpp, *.hh, *.hxx)",
62 "ec, eh, c, cpp, cc, cxx, h, hpp, hh, hxx"
65 "Header Files for eC/C/C++ (*.eh, *.h, *.hpp, *.hh, *.hxx)",
69 "C/C++/eC Source Files (*.ec, *.c, *.cpp, *.cc, *.cxx)",
73 "Text files (*.txt, *.text, *.nfo, *.info)",
74 "txt, text, nfo, info"
77 "Web files (*.html, *.htm, *.xhtml, *.css, *.php, *.js, *.jsi, *.rb, *.xml)",
78 "html, htm, xhtml, css, php, js, jsi, rb, xml"
81 "Image Files (*.jpg, *.jpeg, *.bmp, *.pcx, *.png, *.gif)",
82 "jpg, jpeg, bmp, pcx, png, gif"
85 "3D Studio Model Files (*.3ds)",
91 static FileType fileTypes[] =
93 { "Based on extension", null },
96 { "3D Studio Model", "3ds" }
99 static FileFilter projectFilters[] =
102 "Project Files (*.epj)",
107 static FileType projectTypes[] =
109 { "Project File", ProjectExtension },
112 static FileFilter findInFilesFileFilters[] =
115 "eC Files (*.ec, *.eh)",
119 "C/C++/eC Files (*.ec, *.eh, *.c, *.cpp, *.cc, *.cxx, *.h, *.hpp, *.hh, *.hxx)",
120 "ec, eh, c, cpp, cc, cxx, h, hpp, hh, hxx"
123 "Header Files for eC/C/C++ (*.eh, *.h, *.hpp, *.hh, *.hxx)",
124 "eh, h, hpp, hh, hxx"
127 "C/C++/eC Source Files (*.ec, *.c, *.cpp, *.cc, *.cxx)",
128 "ec, c, cpp, cc, cxx"
131 "Text files (*.txt)",
134 { "All files", null }
137 FileDialog ideFileDialog
139 type = multiOpen, text = "Open";
140 types = fileTypes, sizeTypes = sizeof(fileTypes), filters = fileFilters, sizeFilters = sizeof(fileFilters);
143 FileDialog ideProjectFileDialog
145 type = open, text = "Open Project";
146 types = projectTypes, sizeTypes = sizeof(projectTypes), filters = projectFilters, sizeFilters = sizeof(projectFilters);
149 GlobalSettingsDialog globalSettingsDialog
151 ideSettings = ideSettings;
152 settingsContainer = settingsContainer;
154 void OnGlobalSettingChange(GlobalSettingsChange globalSettingsChange)
156 switch(globalSettingsChange)
161 for(child = ide.firstChild; child; child = child.next)
163 if(child._class == class(CodeEditor))
165 CodeEditor codeEditor = (CodeEditor) child;
166 codeEditor.editBox.freeCaret = ideSettings.useFreeCaret;
167 // codeEditor.editBox.lineNumbers = ideSettings.showLineNumbers;
168 codeEditor.editBox.caretFollowsScrolling = ideSettings.caretFollowsScrolling;
169 codeEditor.OnPostCreate(); // Update editBox margin size
176 case compilerSettings:
178 ide.UpdateMakefiles();
185 void DrawLineMarginIcon(Surface surface, BitmapResource resource, int line, int lineH, int scrollY, int boxH)
190 lineY = (line - 1) * lineH;
191 if(lineY + lineH > scrollY && lineY + lineH < scrollY + boxH)
193 Bitmap bitmap = resource.bitmap;
195 surface.Blit(bitmap, 0, lineY - scrollY + (lineH - bitmap.height) / 2 + 1, 0, 0, bitmap.width, bitmap.height);
202 #if defined(__WIN32__)
203 // Native decorations on Windows works pretty well now! Let's get them going good on X and make it the default there as well.
204 nativeDecorations = true;
206 icon = { ":icon.png" };
207 text = titleECEREIDE;
208 background = Color { 85, 85, 85 };
209 borderStyle = sizable;
214 hasVertScroll = true;
215 hasHorzScroll = true;
221 anchor = { top = 0, right = 0, bottom = 0 };
224 anchor = { left = 0, top = 0, right = 0, bottom = 0 };
228 MenuItem * driverItems, * skinItems;
229 StatusField pos { width = 150 };
230 StatusField ovr, caps, num;
232 BitmapResource back { ":ecereBack.jpg", window = this };
233 BitmapResource bmpBp { ":codeMarks/breakpoint.png", window = this };
234 BitmapResource bmpBpDisabled { ":codeMarks/breakpointDisabled.png", window = this };
235 BitmapResource bmpBpHalf { ":codeMarks/breakpointHalf.png", window = this };
236 BitmapResource bmpBpHalfDisabled { ":codeMarks/breakpointHalfDisabled.png", window = this };
237 BitmapResource bmpCursor { ":codeMarks/cursor.png", window = this };
238 BitmapResource bmpCursorError { ":codeMarks/cursorError.png", window = this };
239 BitmapResource bmpTopFrame { ":codeMarks/topFrame.png", window = this };
240 BitmapResource bmpTopFrameError { ":codeMarks/topFrameError.png", window = this };
241 BitmapResource bmpTopFrameHalf { ":codeMarks/topFrameHalf.png", window = this };
242 BitmapResource bmpTopFrameHalfError { ":codeMarks/topFrameHalfError.png", window = this };
244 Debugger debugger { };
246 ProjectView projectView;
248 OutputView outputView
252 void OnGotoError(char * line)
257 void OnCodeLocationParseAndGoTo(char * line)
259 ide.CodeLocationParseAndGoTo(line, ide.findInFilesDialog.findProject, ide.findInFilesDialog.findDir);
262 bool OnKeyDown(Key key, unichar ch)
267 if(!ide.findInFilesDialog || !ide.findInFilesDialog.SearchAbort())
268 ide.ShowCodeEditor();
271 ide.projectView.stopBuild = true;
275 OutputView::OnKeyDown(key, ch);
282 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
285 ide.RepositionWindows(false);
289 bool OnClose(bool parentClosing)
293 ide.RepositionWindows(false);
294 return parentClosing;
298 CallStackView callStackView
300 parent = this, font = { panelFont.faceName, panelFont.size };
302 void OnGotoLine(char * line)
305 stackLvl = atoi(line);
306 ide.debugger.GoToStackFrameLine(stackLvl, true);
309 void OnSelectFrame(int lineNumber)
311 ide.debugger.SelectFrame(lineNumber);
314 void OnToggleBreakpoint()
316 Debugger debugger = ide.debugger;
317 if(debugger.activeFrame && debugger.activeFrame.absoluteFile)
319 int line = debugger.activeFrame.line;
320 char name[MAX_LOCATION];
322 // TOFIX: Improve on this, don't use only filename, make a function
323 GetLastDirectory(debugger.activeFrame.absoluteFile, name);
324 if(ide && ide.workspace)
326 for(p : ide.workspace.projects)
328 if(p.topNode.Find(name, false))
336 for(p : ide.workspace.projects)
338 if(eString_PathInsideOf(debugger.activeFrame.absoluteFile, p.topNode.path))
346 debugger.ToggleBreakpoint(debugger.activeFrame.absoluteFile, line, prj);
349 CodeEditor codeEditor = (CodeEditor)ide.FindWindow(debugger.activeFrame.absoluteFile);
350 if(codeEditor) { codeEditor.Update(null); Activate(); }
355 bool OnKeyDown(Key key, unichar ch)
359 case escape: ide.ShowCodeEditor(); break;
364 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
367 ide.RepositionWindows(false);
371 bool OnClose(bool parentClosing)
375 ide.RepositionWindows(false);
376 return parentClosing;
379 void OnRedraw(Surface surface)
382 int lineCursor, lineTopFrame, activeThread, hitThread;
383 int lineH, scrollY, boxH;
385 Breakpoint bp = null;
386 Debugger debugger = ide.debugger;
387 Frame activeFrame = debugger.activeFrame;
390 scrollY = editBox.scroll.y;
391 displaySystem.FontExtent(editBox.font.font, " ", 1, null, &lineH);
393 activeThread = debugger.activeThread;
394 hitThread = debugger.hitThread;
395 debugger.GetCallStackCursorLine(&error, &lineCursor, &lineTopFrame);
397 if(activeFrame && activeFrame.absoluteFile)
399 for(i : ide.workspace.breakpoints; i.type == user)
401 if(i.absoluteFilePath && i.absoluteFilePath[0] &&
402 !fstrcmp(i.absoluteFilePath, activeFrame.absoluteFile) &&
403 activeFrame.line == i.line)
412 DrawLineMarginIcon(surface,
413 /*(lineCursor == 1 || lineTopFrame == 1) ? */ide.bmpBpHalf/* : ide.bmpBp*/,
414 lineCursor /*1*/, lineH, scrollY, boxH);
417 if(activeThread && activeThread == hitThread && debugger.bpHit && debugger.bpHit.type == user)
418 DrawLineMarginIcon(surface,
419 (lineCursor == 1 || lineTopFrame == 1) ? ide.bmpBpHalf : ide.bmpBp,
420 1, lineH, scrollY, boxH);
422 DrawLineMarginIcon(surface, error ? ide.bmpCursorError : ide.bmpCursor, lineCursor, lineH, scrollY, boxH);
423 if(bp && lineCursor == 1) //activeThread && activeThread == hitThread && debugger.bpHit && debugger.bpHit.type == user)
424 bmp = error ? ide.bmpTopFrameHalfError : ide.bmpTopFrameHalf;
426 bmp = error ? ide.bmpTopFrameError : ide.bmpTopFrame;
427 DrawLineMarginIcon(surface, bmp, lineTopFrame, lineH, scrollY, boxH);
428 if(editBox.horzScroll && editBox.horzScroll.visible)
430 surface.SetBackground(control);
431 surface.Area(0, editBox.clientSize.h, 20 - 1, clientSize.h - 1);
436 WatchesView watchesView { parent = this };
437 ThreadsView threadsView
439 parent = this, font = { panelFont.faceName, panelFont.size };
441 bool OnKeyDown(Key key, unichar ch)
445 case escape: ide.ShowCodeEditor(); break;
450 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
453 ide.RepositionWindows(false);
457 bool OnClose(bool parentClosing)
461 ide.RepositionWindows(false);
462 return parentClosing;
465 void OnSelectThread(int threadId)
468 ide.debugger.SelectThread(threadId);
471 bool OnGetThreadsInfo(int * activeThread, int * hitThread, int * signalThread)
474 Debugger debugger = ide.debugger;
475 *activeThread = debugger.activeThread;
476 *hitThread = debugger.hitThread;
477 *signalThread = debugger.signalThread;
482 BreakpointsView breakpointsView { parent = this };
484 ToolBox toolBox { parent = this };
485 Sheet sheet { parent = this };
488 property char * tmpPrjDir { set { delete tmpPrjDir; if(value) tmpPrjDir = CopyString(value); } get { return tmpPrjDir; } };
490 Menu fileMenu { menu, "File", f };
493 fileMenu, "New", n, ctrlN;
494 bool NotifySelect(MenuItem selection, Modifiers mods)
496 Window document = (Window)NewCodeEditor(this, normal, false);
497 document.NotifySaved = DocumentSaved;
501 MenuItem fileOpenItem
503 fileMenu, "Open...", o, ctrlO;
504 bool NotifySelect(MenuItem selection, Modifiers mods)
506 if(!projectView && ideSettings.ideFileDialogLocation)
507 ideFileDialog.currentDirectory = ideSettings.ideFileDialogLocation;
510 if(ideFileDialog.Modal() == ok)
512 bool gotWhatWeWant = false;
514 int numSelections = ideFileDialog.numSelections;
515 char ** multiFilePaths = ideFileDialog.multiFilePaths;
517 for(c = 0; c < numSelections; c++)
519 if(OpenFile(multiFilePaths[c], normal, true, fileTypes[ideFileDialog.fileType].typeExtension, no, normal))
520 gotWhatWeWant = true;
523 MessageBox { type = yesNo, master = this, text = "Error opening file",
524 contents = "Open a different file?" }.Modal() == no)
526 if(!projectView && gotWhatWeWant)
527 ChangeFileDialogsDirectory(ideFileDialog.currentDirectory, true);
537 MenuItem fileCloseItem { fileMenu, "Close", c, ctrlF4, NotifySelect = MenuFileClose };
538 MenuDivider { fileMenu };
539 MenuItem fileSaveItem { fileMenu, "Save", s, ctrlS };
540 MenuItem fileSaveAsItem { fileMenu, "Save As...", a };
541 MenuItem fileSaveAllItem { fileMenu, "Save All", l, NotifySelect = MenuFileSaveAll };
542 MenuDivider { fileMenu };
545 fileMenu, "Find In Files...", f, Key { f, ctrl = true , shift = true };
546 bool NotifySelect(MenuItem selection, Modifiers mods)
548 findInFilesDialog.replaceMode = false;
549 findInFilesDialog.Show();
553 MenuItem replaceInFiles
555 fileMenu, "Replace In Files...", e, Key { r, ctrl = true , shift = true };
556 bool NotifySelect(MenuItem selection, Modifiers mods)
558 findInFilesDialog.replaceMode = true;
559 findInFilesDialog.Show();
563 MenuDivider { fileMenu };
564 MenuItem globalSettingsItem
566 fileMenu, "Global Settings...", g;
567 bool NotifySelect(MenuItem selection, Modifiers mods)
569 globalSettingsDialog.master = this;
570 if(ide.workspace && ide.workspace.compiler)
571 globalSettingsDialog.workspaceActiveCompiler = ide.workspace.compiler;
572 else if(ideSettings.defaultCompiler)
573 globalSettingsDialog.workspaceActiveCompiler = ideSettings.defaultCompiler;
574 globalSettingsDialog.Modal();
578 MenuDivider { fileMenu };
579 Menu recentFiles { fileMenu, "Recent Files", r };
580 Menu recentProjects { fileMenu, "Recent Projects", p };
581 MenuDivider { fileMenu };
582 MenuItem exitItem { fileMenu, "Exit", x, altF4, NotifySelect = MenuFileExit };
584 bool FileRecentFile(MenuItem selection, Modifiers mods)
587 for(file : ideSettings.recentFiles)
589 if(id == selection.id)
591 OpenFile(file, normal, true, null, no, normal);
599 bool FileRecentProject(MenuItem selection, Modifiers mods)
602 for(file : ideSettings.recentProjects)
604 if(id == selection.id)
606 OpenFile(file, normal, true, null, no, normal);
614 MenuPlacement editMenu { menu, "Edit", e };
616 Menu projectMenu { menu, "Project", p };
617 MenuItem projectNewItem
619 projectMenu, "New...", n, Key { n, true, true };
620 bool NotifySelect(MenuItem selection, Modifiers mods)
622 if(!DontTerminateDebugSession("New Project"))
623 if(MenuWindowCloseAll(null, 0))
625 NewProjectDialog newProjectDialog;
629 projectView.visible = false;
630 if(!projectView.Destroy(0))
634 newProjectDialog = { master = this };
635 newProjectDialog.Modal();
638 ideSettings.AddRecentProject(projectView.fileName);
639 ide.UpdateRecentMenus();
640 settingsContainer.Save();
646 MenuItem projectOpenItem
648 projectMenu, "Open...", o, Key { o, true, true };
649 bool NotifySelect(MenuItem selection, Modifiers mods)
651 if(ideSettings.ideProjectFileDialogLocation)
652 ideProjectFileDialog.currentDirectory = ideSettings.ideProjectFileDialogLocation;
654 if(ideProjectFileDialog.Modal() == ok)
656 OpenFile(ideProjectFileDialog.filePath, normal, true, projectTypes[ideProjectFileDialog.fileType].typeExtension, no, normal);
657 //ChangeProjectFileDialogDirectory(ideProjectFileDialog.currentDirectory);
662 MenuItem projectQuickItem
664 projectMenu, "Quick...", q, f7;
665 bool NotifySelect(MenuItem selection, Modifiers mods)
668 QuickProjectDialog{ this }.Modal();
672 MenuItem projectAddItem
674 projectMenu, "Add project to workspace...", a, Key { a, true, true };
676 bool NotifySelect(MenuItem selection, Modifiers mods)
678 if(ideSettings.ideProjectFileDialogLocation)
679 ideProjectFileDialog.currentDirectory = ideSettings.ideProjectFileDialogLocation;
683 if(ideProjectFileDialog.Modal() == ok)
685 if(OpenFile(ideProjectFileDialog.filePath, normal, true, projectTypes[ideProjectFileDialog.fileType].typeExtension, no, add))
687 if(MessageBox { type = yesNo, master = this, text = "Error opening project file",
688 contents = "Add a different project?" }.Modal() == no)
699 MenuItem projectCloseItem
701 projectMenu, "Close", c, disabled = true;
702 bool NotifySelect(MenuItem selection, Modifiers mods)
706 if(!ide.DontTerminateDebugSession("Project Close"))
708 if(findInFilesDialog)
709 findInFilesDialog.SearchStop();
710 projectView.visible = false;
711 if(projectView.Destroy(0))
712 MenuWindowCloseAll(null, 0);
714 char workingDir[MAX_LOCATION];
715 GetWorkingDir(workingDir, MAX_LOCATION);
716 findInFilesDialog.currentDirectory = workingDir;
723 MenuDivider { projectMenu };
724 MenuItem activeCompilerItem
726 projectMenu, "Active Compiler...", g, /*altF5, */disabled = true;
727 bool NotifySelect(MenuItem selection, Modifiers mods)
729 projectView.MenuCompiler(null, mods);
733 MenuItem projectActiveConfigItem
735 projectMenu, "Active Configuration...", g, altF5, disabled = true;
736 bool NotifySelect(MenuItem selection, Modifiers mods)
738 projectView.MenuConfig(projectView.active ? selection : null, mods);
742 MenuItem projectSettingsItem
744 projectMenu, "Settings...", s, altF7, disabled = true;
745 bool NotifySelect(MenuItem selection, Modifiers mods)
747 projectView.MenuSettings(projectView.active ? selection : null, mods);
751 MenuDivider { projectMenu };
752 MenuItem projectBrowseFolderItem
754 projectMenu, "Browse Project Folder", p, disabled = true;
755 bool NotifySelect(MenuItem selection, Modifiers mods)
758 projectView.MenuBrowseFolder(null, mods);
762 MenuDivider { projectMenu };
763 MenuItem projectRunItem
765 projectMenu, "Run", r, ctrlF5, disabled = true;
766 bool NotifySelect(MenuItem selection, Modifiers mods)
769 projectView.Run(null, mods);
773 MenuItem projectBuildItem
775 projectMenu, "Build", b, f7, disabled = true;
776 bool NotifySelect(MenuItem selection, Modifiers mods)
779 projectView.ProjectBuild(projectView.active ? selection : null, mods);
783 MenuItem projectLinkItem
785 projectMenu, "Relink", l, disabled = true;
786 bool NotifySelect(MenuItem selection, Modifiers mods)
789 projectView.ProjectLink(projectView.active ? selection : null, mods);
793 MenuItem projectRebuildItem
795 projectMenu, "Rebuild", d, shiftF7, disabled = true;
796 bool NotifySelect(MenuItem selection, Modifiers mods)
799 projectView.ProjectRebuild(projectView.active ? selection : null, mods);
803 MenuItem projectCleanItem
805 projectMenu, "Clean", e, disabled = true;
806 bool NotifySelect(MenuItem selection, Modifiers mods)
811 projectView.ProjectClean(projectView.active ? selection : null, mods);
816 MenuItem projectRegenerateItem
818 projectMenu, "Regenerate Makefile", m, disabled = true;
819 bool NotifySelect(MenuItem selection, Modifiers mods)
822 projectView.ProjectRegenerate(projectView.active ? selection : null, mods);
826 MenuItem projectCompileItem;
827 Menu debugMenu { menu, "Debug", d };
828 MenuItem debugStartResumeItem
830 debugMenu, "Start", s, f5, disabled = true;
831 NotifySelect = MenuDebugStart;
833 bool MenuDebugStart(MenuItem selection, Modifiers mods)
837 debugStartResumeItem.disabled = true; // a very rare exception to calling AdjustDebugMenus
838 if(!projectView.DebugStart())
839 debugStartResumeItem.disabled = false; // same exception
843 bool MenuDebugResume(MenuItem selection, Modifiers mods)
846 projectView.DebugResume();
849 MenuItem debugRestartItem
851 debugMenu, "Restart", r, Key { f5, ctrl = true, shift = true }, disabled = true;
852 bool NotifySelect(MenuItem selection, Modifiers mods)
855 projectView.DebugRestart();
859 MenuItem debugBreakItem
861 debugMenu, "Break", b, Key { pauseBreak, ctrl = true }, disabled = true;
862 bool NotifySelect(MenuItem selection, Modifiers mods)
865 projectView.DebugBreak();
869 MenuItem debugStopItem
871 debugMenu, "Stop", p, shiftF5, disabled = true;
872 bool NotifySelect(MenuItem selection, Modifiers mods)
875 projectView.DebugStop();
879 MenuDivider { debugMenu };
880 MenuItem debugStepIntoItem
882 debugMenu, "Step Into", i, f11, disabled = true;
883 bool NotifySelect(MenuItem selection, Modifiers mods)
886 projectView.DebugStepInto();
890 MenuItem debugStepOverItem
892 debugMenu, "Step Over", v, f10, disabled = true;
893 bool NotifySelect(MenuItem selection, Modifiers mods)
896 projectView.DebugStepOver(false);
900 MenuItem debugStepOutItem
902 debugMenu, "Step Out", o, shiftF11, disabled = true;
903 bool NotifySelect(MenuItem selection, Modifiers mods)
906 projectView.DebugStepOut(false);
910 MenuPlacement debugRunToCursorItem { debugMenu, "Run To Cursor", c };
911 MenuItem debugSkipStepOverItem
913 debugMenu, "Step Over Skipping Breakpoints", e, shiftF10, disabled = true;
914 bool NotifySelect(MenuItem selection, Modifiers mods)
917 projectView.DebugStepOver(true);
921 MenuItem debugSkipStepOutItem
923 debugMenu, "Step Out Skipping Breakpoints", t, Key { f11, ctrl = true, shift = true }, disabled = true;
924 bool NotifySelect(MenuItem selection, Modifiers mods)
927 projectView.DebugStepOut(true);
931 MenuPlacement debugSkipRunToCursorItem { debugMenu, "Run To Cursor Skipping Breakpoints", u };
932 //MenuDivider { debugMenu };
933 //MenuPlacement debugToggleBreakpoint { debugMenu, "Toggle Breakpoint", t };
934 MenuPlacement imageMenu { menu, "Image", i };
935 Menu viewMenu { menu, "View", v };
936 MenuItem viewProjectItem
938 viewMenu, "Project", j, alt0, disabled = true;
939 bool NotifySelect(MenuItem selection, Modifiers mods)
943 projectView.visible = true;
944 projectView.Activate();
949 MenuPlacement { viewMenu, "View Designer" };
950 MenuPlacement { viewMenu, "View Code" };
951 MenuPlacement { viewMenu, "View Properties" };
952 MenuPlacement { viewMenu, "View Methods" };
953 MenuItem viewDesignerItem
955 viewMenu, "View Designer", d, f8;
956 bool NotifySelect(MenuItem selection, Modifiers mods)
958 Window client = activeClient;
959 Class dataType = client._class;
960 if(!strcmp(dataType.name, "Designer"))
962 client.visible = true;
966 ((CodeEditor)client).ViewDesigner();
970 MenuItem viewCodeItem
972 viewMenu, "View Code", c, f8;
973 bool NotifySelect(MenuItem selection, Modifiers mods)
975 Window client = activeClient;
976 Class dataType = client._class;
977 if(!strcmp(dataType.name, "Designer"))
978 client = ((Designer)client).codeEditor;
981 // Do this after so the caret isn't moved yet...
982 client.visible = true;
986 MenuItem viewPropertiesItem
988 viewMenu, "View Properties", p, f4;
989 bool NotifySelect(MenuItem selection, Modifiers mods)
991 sheet.visible = true;
992 sheet.sheetSelected = properties;
997 MenuItem viewMethodsItem
999 viewMenu, "View Methods", m, f4;
1000 bool NotifySelect(MenuItem selection, Modifiers mods)
1002 sheet.visible = true;
1003 sheet.sheetSelected = methods;
1008 MenuItem viewToolBoxItem
1010 viewMenu, "View Toolbox", x, f12;
1011 bool NotifySelect(MenuItem selection, Modifiers mods)
1013 toolBox.visible = true;
1018 MenuItem viewOutputItem
1020 viewMenu, "Output", o, alt2;
1021 bool NotifySelect(MenuItem selection, Modifiers mods)
1027 MenuItem viewWatchesItem
1029 viewMenu, "Watches", w, alt3;
1030 bool NotifySelect(MenuItem selection, Modifiers mods)
1036 MenuItem viewThreadsItem
1038 viewMenu, "Threads", t, alt4;
1039 bool NotifySelect(MenuItem selection, Modifiers mods)
1045 MenuItem viewBreakpointsItem
1047 viewMenu, "Breakpoints", b, alt5;
1048 bool NotifySelect(MenuItem selection, Modifiers mods)
1050 breakpointsView.Show();
1054 MenuItem viewCallStackItem
1056 viewMenu, "Call Stack", s, alt7;
1057 bool NotifySelect(MenuItem selection, Modifiers mods)
1059 callStackView.Show();
1063 MenuItem viewAllDebugViews
1065 viewMenu, "All Debug Views", a, alt9;
1066 bool NotifySelect(MenuItem selection, Modifiers mods)
1071 callStackView.Show();
1072 breakpointsView.Show();
1076 #ifdef GDB_DEBUG_GUI
1077 MenuDivider { viewMenu };
1078 MenuItem viewGDBItem
1080 viewMenu, "GDB Dialog", g, Key { f9, shift = true, ctrl = true };
1081 bool NotifySelect(MenuItem selection, Modifiers mods)
1088 MenuDivider { viewMenu };
1089 MenuItem viewColorPicker
1091 viewMenu, "Color Picker...", c, Key { c, ctrl = true , shift = true };
1092 bool NotifySelect(MenuItem selection, Modifiers mods)
1094 ColorPicker colorPicker { master = this, parent = this, stayOnTop = true };
1095 colorPicker.Create();
1099 MenuDivider { viewMenu };
1103 viewMenu, "Full Screen", f, checkable = true;
1105 bool NotifySelect(MenuItem selection, Modifiers mods)
1107 app.fullScreen ^= true;
1109 anchor = { 0, 0, 0, 0 };
1114 Menu driversMenu { viewMenu, "Graphics Driver", v };
1115 //Menu skinsMenu { viewMenu, "GUI Skins", k };
1116 Menu windowMenu { menu, "Window", w };
1117 MenuItem { windowMenu, "Close All", l, NotifySelect = MenuWindowCloseAll };
1118 MenuDivider { windowMenu };
1119 MenuItem { windowMenu, "Next", n, f6, NotifySelect = MenuWindowNext };
1120 MenuItem { windowMenu, "Previous", p, shiftF6, NotifySelect = MenuWindowPrevious };
1121 MenuDivider { windowMenu };
1122 MenuItem { windowMenu, "Cascade", c, NotifySelect = MenuWindowCascade };
1123 MenuItem { windowMenu, "Tile Horizontally", h, NotifySelect = MenuWindowTileHorz };
1124 MenuItem { windowMenu, "Tile Vertically", v, NotifySelect = MenuWindowTileVert };
1125 MenuItem { windowMenu, "Arrange Icons", a, NotifySelect = MenuWindowArrangeIcons };
1126 MenuDivider { windowMenu };
1127 MenuItem { windowMenu, "Windows...", w, NotifySelect = MenuWindowWindows };
1128 Menu helpMenu { menu, "Help", h };
1131 helpMenu, "API Reference", r, f1;
1132 bool NotifySelect(MenuItem selection, Modifiers mods)
1134 Execute("documentor");
1138 MenuDivider { helpMenu };
1141 helpMenu, "About...", a;
1142 bool NotifySelect(MenuItem selection, Modifiers mods)
1144 AboutIDE { master = this }.Modal();
1149 property ToolBox toolBox
1151 get { return toolBox; }
1154 property Sheet sheet
1156 get { return sheet; }
1159 property Project project
1161 get { return projectView ? projectView.project : null; }
1164 property Workspace workspace
1166 get { return projectView ? projectView.workspace : null; }
1169 FindInFilesDialog findInFilesDialog
1171 master = this, parent = this;
1172 filters = findInFilesFileFilters, sizeFilters = sizeof(findInFilesFileFilters);
1176 #ifdef GDB_DEBUG_GUI
1179 master = this, parent = this;
1180 anchor = { left = 100, top = 100, right = 100, bottom = 100 };
1182 void OnCommand(char * string)
1185 ide.debugger.SendGDBCommand(string);
1190 bool NotifySelectDisplayDriver(MenuItem selection, Modifiers mods)
1192 //app.driver = app.drivers[selection.id];
1194 app.driver = selection.id ? "OpenGL" : "X";
1196 app.driver = selection.id ? "OpenGL" : "GDI";
1198 delete ideSettings.displayDriver;
1199 ideSettings.displayDriver = CopyString(selection.id ? "OpenGL" : "Default");
1201 settingsContainer.Save();
1202 //SetDriverAndSkin();
1206 bool NotifySelectDisplaySkin(MenuItem selection, Modifiers mods)
1208 app.skin = app.skins[selection.id];
1213 void SetDriverAndSkin()
1216 for(c = 0; c < app.numSkins; c++)
1217 if(!strcmp(app.skins[c], app.skin))
1219 skinItems[c].checked = true;
1222 for(c = 0; c < app.numDrivers; c++)
1223 if(!strcmp(app.drivers[c], app.driver))
1225 driverItems[c].checked = true;
1230 ProjectView CreateProjectView(Workspace workspace, char * fileName)
1232 Project project = workspace.projects.firstIterator.data;
1233 projectView = ProjectView
1236 fileName = fileName;
1238 void NotifyDestroyed(Window window, DialogResult result)
1241 text = titleECEREIDE;
1246 projectView.Create();
1247 RepositionWindows(false);
1249 // Leave it after Create to avoid flicker due to seeing IDE without a project view
1250 projectView.workspace = workspace;
1251 projectView.project = project;
1252 SetText("%s - %s", project.topNode.name, titleECEREIDE);
1256 ide.breakpointsView.LoadFromWorkspace();
1257 ide.watchesView.LoadFromWorkspace();
1260 char fileName[MAX_LOCATION];
1261 strcpy(fileName, project.topNode.path);
1262 PathCat(fileName, project.topNode.name);
1267 bool GetDebugMenusDisabled()
1271 Project project = projectView.project;
1273 if(project.targetType == executable)
1280 void RepositionWindows(bool expand)
1285 bool inDebugMode = debugger.isActive;
1286 bool callStackVisible = expand ? false : callStackView.visible;
1287 bool threadsVisible = expand ? false : threadsView.visible;
1288 bool watchesVisible = expand ? false : watchesView.visible;
1289 bool breakpointsVisible = expand ? false : breakpointsView.visible;
1290 bool toolBoxVisible = toolBox.visible;
1291 bool outputVisible = expand ? false : outputView.visible;
1292 int topDistance = (callStackVisible || threadsVisible) ? 200 : 0;
1293 int bottomDistance = (outputVisible || watchesVisible || breakpointsVisible) ? 240 : 0;
1295 for(child = firstChild; child; child = child.next)
1297 if(child._class == class(CodeEditor) || child._class == class(Designer) ||
1298 child._class == class(Sheet) || child._class == class(ProjectView))
1300 Anchor anchor = child.anchor;
1301 anchor.top = topDistance;
1302 anchor.bottom = bottomDistance;
1303 if(child._class == class(CodeEditor) || child._class == class(Designer))
1305 anchor.right = toolBoxVisible ? 150 : 0;
1307 child.anchor = anchor;
1311 if(child._class == class(OutputView) || child._class == class(CallStackView) || child._class == class(ThreadsView) || child._class == class(WatchesView) ||
1312 child._class == class(BreakpointsView))
1313 child.visible = false;
1316 // If this is not here, the IDE is not updated when doing Debug/Break then Alt-4 to show call stack (IDE not updated)
1321 bool ShowCodeEditor()
1324 activeClient.Activate();
1325 else if(projectView)
1327 projectView.visible = true;
1328 projectView.Activate();
1332 sheet.visible = true;
1338 bool ShouldStopBuild()
1340 return projectView.stopBuild;
1343 void DocumentSaved(Window document, char * fileName)
1345 ideSettings.AddRecentFile(fileName);
1346 ide.UpdateRecentMenus();
1347 settingsContainer.Save();
1350 bool Window::OnFileModified(FileChange fileChange, char * param)
1353 sprintf(temp, "The document %s was modified by another application.\n"
1354 "Would you like to reload it and lose your changes?", this.fileName);
1355 if(MessageBox { type = yesNo, master = this/*.parent*/,
1356 text = "Document has been modified", contents = temp }.Modal() == yes)
1358 char * fileName = CopyString(this.fileName);
1359 WindowState state = this.state;
1360 Anchor anchor = this.anchor;
1361 Size size = this.size;
1363 this.modifiedDocument = false;
1365 this = ide.OpenFile(fileName, normal, true, null, no, normal);
1368 this.anchor = anchor;
1370 this.SetState(state, true, 0);
1378 void UpdateMakefiles()
1382 for(prj : workspace.projects)
1384 bool first = prj == workspace.projects.firstIterator.data;
1385 projectView.ProjectUpdateMakefileForAllConfigs(prj, first, first);
1392 bool unavailable = !project;
1394 projectQuickItem.disabled = !unavailable;
1396 projectAddItem.disabled = unavailable;
1398 activeCompilerItem.disabled = unavailable;
1399 projectActiveConfigItem.disabled = unavailable;
1400 projectSettingsItem.disabled = unavailable;
1402 projectBrowseFolderItem.disabled = unavailable;
1404 viewProjectItem.disabled = unavailable;
1410 void AdjustBuildMenus()
1412 bool unavailable = project && projectView.buildInProgress;
1414 projectNewItem.disabled = unavailable;
1415 projectOpenItem.disabled = unavailable;
1417 unavailable = !project || projectView.buildInProgress;
1419 projectCloseItem.disabled = unavailable;
1421 projectRunItem.disabled = unavailable || project.targetType != executable;
1422 projectBuildItem.disabled = unavailable;
1423 projectLinkItem.disabled = unavailable;
1424 projectRebuildItem.disabled = unavailable;
1425 projectCleanItem.disabled = unavailable;
1426 projectRegenerateItem.disabled = unavailable;
1427 projectCompileItem.disabled = unavailable;
1430 void AdjustDebugMenus()
1432 bool unavailable = !project || project.targetType != executable ||
1433 projectView.buildInProgress == buildingMainProject;
1434 bool active = ide.debugger.isActive;
1435 bool executing = ide.debugger.state == running;
1436 //bool holding = ide.debugger.state == stopped;
1438 debugStartResumeItem.disabled = unavailable || executing;
1440 debugStartResumeItem.text = active ? "Resume" : "Start";
1441 debugStartResumeItem.NotifySelect = active ? MenuDebugResume : MenuDebugStart;
1443 debugBreakItem.disabled = unavailable || !executing;
1444 debugStopItem.disabled = unavailable || !active;
1445 debugRestartItem.disabled = unavailable || !active;
1447 debugStepIntoItem.disabled = unavailable || executing;
1448 debugStepOverItem.disabled = unavailable || executing;
1449 debugStepOutItem.disabled = unavailable || executing || !active;
1450 debugSkipStepOverItem.disabled = unavailable || executing;
1451 debugSkipStepOutItem.disabled = unavailable || executing || !active;
1453 if((Designer)GetActiveDesigner())
1455 CodeEditor codeEditor = ((Designer)GetActiveDesigner()).codeEditor;
1458 codeEditor.debugRunToCursor.disabled = unavailable || executing;
1459 codeEditor.debugSkipRunToCursor.disabled = unavailable || executing;
1464 void ChangeFileDialogsDirectory(char * directory, bool saveSettings)
1466 char tempString[MAX_LOCATION];
1467 strcpy(tempString, directory);
1468 if(saveSettings && !projectView)
1470 ideSettings.ideFileDialogLocation = directory;
1471 settingsContainer.Save();
1474 ideFileDialog.currentDirectory = tempString;
1475 codeEditorFileDialog.currentDirectory = tempString;
1476 codeEditorFormFileDialog.currentDirectory = tempString;
1479 void ChangeProjectFileDialogDirectory(char * directory)
1481 ideSettings.ideProjectFileDialogLocation = directory;
1482 settingsContainer.Save();
1485 Window FindWindow(char * filePath)
1487 Window document = null;
1489 // TOCHECK: Do we need to change slashes here?
1490 for(document = firstChild; document; document = document.next)
1492 char * fileName = document.fileName;
1493 if(document.isDocument && fileName && !fstrcmp(fileName, filePath))
1495 document.visible = true;
1496 document.Activate();
1503 bool DontTerminateDebugSession(char * title)
1505 if(debugger.isActive)
1507 if(MessageBox { type = yesNo, master = ide,
1508 contents = "Do you want to terminate the debugging session in progress?",
1509 text = title }.Modal() == no)
1512 MessageBox msg { type = yesNo, master = ide,
1513 contents = "Do you want to terminate the debugging session in progress?",
1515 if(msg.Modal() == no)
1527 Window OpenFile(char * origFilePath, WindowState state, bool visible, char * type, OpenCreateIfFails createIfFails, OpenMethod openMethod)
1529 char extension[MAX_EXTENSION] = "";
1530 Window document = null;
1531 bool isProject = false;
1532 bool needFileModified = true;
1533 char winFilePath[MAX_LOCATION];
1534 char * filePath = strstr(origFilePath, "http://") == origFilePath ? strcpy(winFilePath, origFilePath) : GetSystemPathBuffer(winFilePath, origFilePath);
1538 GetExtension(filePath, extension);
1542 strcpy(extension, type);
1544 if(strcmp(extension, ProjectExtension))
1546 for(document = firstChild; document; document = document.next)
1548 char * fileName = document.fileName;
1549 if(document.isDocument && fileName && !fstrcmp(fileName, filePath) && document.created)
1551 document.visible = true;
1552 document.Activate();
1558 if(createIfFails == whatever)
1560 else if(!strcmp(extension, ProjectExtension) || !strcmp(extension, WorkspaceExtension))
1562 if(openMethod == normal)
1564 if(DontTerminateDebugSession("Open Project"))
1567 if(MenuWindowCloseAll(null, 0))
1571 projectView.visible = false;
1572 projectView.Destroy(0);
1573 // Where did this come from? projectView = null;
1580 Workspace workspace = null;
1582 if(FileExists(filePath))
1584 if(!strcmp(extension, ProjectExtension))
1586 char workspaceFile[MAX_LOCATION];
1587 strcpy(workspaceFile, filePath);
1588 ChangeExtension(workspaceFile, WorkspaceExtension, workspaceFile);
1589 workspace = LoadWorkspace(workspaceFile, filePath);
1591 else if(!strcmp(extension, WorkspaceExtension))
1592 workspace = LoadWorkspace(filePath, null);
1595 //project = LoadProject(filePath);
1600 char absolutePath[MAX_LOCATION];
1601 CreateProjectView(workspace, filePath);
1602 document = projectView;
1604 workspace.DropInvalidBreakpoints();
1607 ide.projectView.ShowOutputBuildLog(true);
1608 ide.projectView.DisplayCompiler(false);
1611 char newWorkingDir[MAX_LOCATION];
1612 StripLastDirectory(filePath, newWorkingDir);
1613 ChangeFileDialogsDirectory(newWorkingDir, false);
1616 document.fileName = filePath;
1618 SetText("%s - %s", filePath, titleECEREIDE);
1620 // this crashes on starting ide with epj file, solution please?
1621 // app.UpdateDisplay();
1623 workspace.holdTracking = true;
1624 for(ofi : workspace.openedFiles)
1626 if(ofi.state != closed)
1628 Window file = OpenFile(ofi.path, normal, true, null, no, normal);
1631 char fileName[MAX_LOCATION];
1633 GetLastDirectory(ofi.path, fileName);
1634 node = projectView.project.topNode.Find(fileName, true);
1636 node.EnsureVisible();
1640 workspace.holdTracking = false;
1642 workspace.timer.Start();
1644 findInFilesDialog.mode = FindInFilesMode::project;
1645 findInFilesDialog.currentDirectory = ide.project.topNode.path;
1648 char location[MAX_LOCATION];
1649 StripLastDirectory(ide.project.topNode.path, location);
1650 ChangeProjectFileDialogDirectory(location);
1654 if(projectView.debugger)
1655 projectView.debugger.EvaluateWatches();
1662 if(MessageBox { type = yesNo, parent = this, text = "Error opening project", contents = "Open a different project?" }.Modal() == yes)
1664 if(ideProjectFileDialog.Modal() == cancel)
1666 filePath = ideProjectFileDialog.filePath;
1667 GetExtension(filePath, extension);
1678 else if(openMethod == add)
1683 char slashFilePath[MAX_LOCATION];
1684 GetSlashPathBuffer(slashFilePath, filePath);
1685 for(p : workspace.projects)
1687 if(!fstrcmp(p.filePath, slashFilePath))
1695 MessageBox { type = ok, parent = parent, master = this, text = "Same Project",
1696 contents = "This project is already present in workspace." }.Modal();
1700 prj = LoadProject(filePath);
1703 workspace.projects.Add(prj);
1705 projectView.AddNode(prj.topNode, null);
1706 workspace.modified = true;
1708 findInFilesDialog.AddProjectItem(prj);
1709 projectView.ProjectUpdateMakefileForAllConfigs(prj, true, true);
1710 // projectView is associated with the main project and not with the one just added but
1711 return projectView; // just to let the caller know something was opened
1719 else if(!strcmp(extension, "bmp") || !strcmp(extension, "pcx") ||
1720 !strcmp(extension, "jpg") || !strcmp(extension, "gif") ||
1721 !strcmp(extension, "jpeg") || !strcmp(extension, "png"))
1723 if(FileExists(filePath))
1724 document = PictureEdit { hasMaximize = true, hasMinimize = true, hasClose = true, borderStyle = sizable,
1725 hasVertScroll = true, hasHorzScroll = true, parent = this, state = state,
1726 visible = visible, bitmapFile = filePath, OnClose = PictureEditOnClose/*why?--GenericDocumentOnClose*/;
1729 MessageBox { type = ok, parent = this, text = filePath, contents = "File doesn't exist." }.Modal();
1732 else if(!strcmp(extension, "3ds"))
1734 if(FileExists(filePath))
1735 document = ModelView { hasMaximize = true, hasMinimize = true, hasClose = true, borderStyle = sizable,
1736 hasVertScroll = true, hasHorzScroll = true, parent = this, state = state,
1737 visible = visible, modelFile = filePath, OnClose = ModelViewOnClose/*why?--GenericDocumentOnClose*/
1741 MessageBox { type = ok, parent = this, text = filePath, contents = "File doesn't exist." }.Modal();
1744 else if(!strcmp(extension, "txt") || !strcmp(extension, "text") ||
1745 !strcmp(extension, "nfo") || !strcmp(extension, "info") ||
1746 !strcmp(extension, "htm") || !strcmp(extension, "html") ||
1747 !strcmp(extension, "css") || !strcmp(extension, "php") ||
1748 !strcmp(extension, "js"))
1750 CodeEditor editor { parent = this, state = state, visible = false };
1751 editor.updatingCode = true;
1752 if(editor.LoadFile(filePath))
1755 editor.visible = true;
1759 needFileModified = false;
1763 CodeEditor editor { parent = this, state = state, visible = false };
1764 if(editor.LoadFile(filePath))
1767 editor.visible = true;
1771 needFileModified = false;
1774 if(document && (document._class == class(PictureEdit) ||
1775 document._class == class(ModelView)))
1780 document.fileName = filePath;
1781 if(workspace && !workspace.holdTracking)
1782 workspace.UpdateOpenedFileInfo(filePath, opened);
1786 if(!document && createIfFails != no)
1788 if(createIfFails != yes && !needFileModified &&
1789 MessageBox { type = yesNo, parent = this, text = filePath, contents = "File doesn't exist. Create?" }.Modal() == yes)
1790 createIfFails = yes;
1791 if(createIfFails == yes || createIfFails == whatever)
1793 document = (Window)NewCodeEditor(this, state, true);
1795 document.fileName = filePath;
1801 if(projectView && document._class == class(CodeEditor) && workspace)
1803 int lineNumber, position;
1805 CodeEditor editor = (CodeEditor)document;
1806 editor.openedFileInfo = workspace.UpdateOpenedFileInfo(filePath, opened);
1807 editor.openedFileInfo.holdTracking = true;
1808 lineNumber = Max(editor.openedFileInfo.lineNumber - 1, 0);
1809 position = Max(editor.openedFileInfo.position - 1, 0);
1810 editor.editBox.GoToLineNum(lineNumber);
1811 editor.editBox.GoToPosition(editor.editBox.line, lineNumber, position);
1812 scroll.x = Max(editor.openedFileInfo.scroll.x, 0);
1813 scroll.y = Max(editor.openedFileInfo.scroll.y, 0);
1814 editor.editBox.scroll = scroll;
1815 editor.openedFileInfo.holdTracking = false;
1818 if(needFileModified)
1819 document.OnFileModified = OnFileModified;
1820 document.NotifySaved = DocumentSaved;
1823 ideSettings.AddRecentProject(document.fileName);
1825 ideSettings.AddRecentFile(document.fileName);
1826 ide.UpdateRecentMenus();
1827 settingsContainer.Save();
1835 // TOCHECK: I can't use a generic one for both ModelView and PictureEdit both derived from Window
1836 /*bool Window::GenericDocumentOnClose(bool parentClosing)
1838 if(!parentClosing && ide.workspace)
1839 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
1842 bool ModelView::ModelViewOnClose(bool parentClosing)
1844 if(!parentClosing && ide.workspace)
1845 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
1848 bool PictureEdit::PictureEditOnClose(bool parentClosing)
1850 if(!parentClosing && ide.workspace)
1851 ide.workspace.UpdateOpenedFileInfo(fileName, unknown);
1856 void OnUnloadGraphics(Window window)
1858 display.ClearMaterials();
1859 display.ClearTextures();
1860 display.ClearMeshes();
1864 bool OnActivate(bool active, Window swap, bool * goOnWithActivation, bool direct)
1866 caps.color = app.GetKeyState(capsState) ? black : Color { 128,128,128 };
1867 num.color = app.GetKeyState(numState) ? black : Color { 128,128,128 };
1871 bool OnKeyDown(Key key, unichar ch)
1876 projectView.Update(null);
1879 caps.color = app.GetKeyState(capsState) ? black : Color { 128,128,128 };
1882 num.color = app.GetKeyState(numState) ? black : Color { 128,128,128 };
1888 void GoToError(const char * line)
1891 projectView.GoToError(line);
1894 void CodeLocationParseAndGoTo(const char * text, Project project, const char * dir)
1897 char *colon = strchr(text, ':');
1898 char filePath[MAX_LOCATION];
1899 char completePath[MAX_LOCATION];
1900 int line = 0, col = 0;
1905 char * close = strchr(text, ')');
1909 strncpy(name, &text[4], close - text - 4);
1910 name[close - text - 4] = '\0';
1911 for(p : ide.workspace.projects)
1913 if(!strcmp(p.name, name))
1923 prj = project ? project : (dir ? null : ide.project);
1924 if(colon && (colon[1] == '/' || colon[1] == '\\'))
1926 path = (colon - 1 > path) ? colon - 1 : path;
1927 colon = strstr(colon + 1, ":");
1929 while(isspace(*path)) path++;
1932 strncpy(filePath, path, colon - path);
1933 filePath[colon - path] = '\0';
1934 line = atoi(colon + 1);
1935 colon = strstr(colon + 1, ":");
1937 col = atoi(colon + 1);
1939 else if(path - 1 >= path && *(path - 1) == '\"')
1941 colon = strchr(path, '\"');
1944 strncpy(filePath, path, colon - path);
1945 filePath[colon - path] = '\0';
1950 strcpy(completePath, prj.topNode.path);
1951 else if(dir && dir[0])
1952 strcpy(completePath, dir);
1954 completePath[0] = '\0';
1955 PathCat(completePath, filePath);
1957 if(FileExists(completePath).isFile)
1959 CodeEditor codeEditor = (CodeEditor)OpenFile(completePath, normal, true, "", no, normal);
1960 if(codeEditor && line)
1962 EditBox editBox = codeEditor.editBox;
1963 editBox.GoToLineNum(line - 1);
1964 editBox.GoToPosition(editBox.line, line - 1, col ? (col - 1) : 0);
1969 void OnRedraw(Surface surface)
1971 Bitmap bitmap = back.bitmap;
1973 surface.Blit(bitmap, (clientSize.w - bitmap.width) / 2, (clientSize.h - bitmap.height) / 2, 0, 0, bitmap.width, bitmap.height);
1976 void SheetSelected(SheetType sheetSelected)
1978 if(activeChild == sheet)
1980 if(sheetSelected == methods)
1982 viewPropertiesItem.accelerator = f4;
1983 viewPropertiesItem.parent = viewMenu;
1984 viewMethodsItem.parent = null;
1988 viewMethodsItem.accelerator = f4;
1989 viewMethodsItem.parent = viewMenu;
1990 viewPropertiesItem.parent = null;
1995 viewMethodsItem.parent = viewMenu;
1996 viewPropertiesItem.parent = viewMenu;
1997 if(sheetSelected == methods)
1999 viewMethodsItem.accelerator = f4;
2000 viewPropertiesItem.accelerator = 0;
2004 viewMethodsItem.accelerator = 0;
2005 viewPropertiesItem.accelerator = f4;
2010 void OnActivateClient(Window client, Window previous)
2012 //if(!client || client != previous)
2015 if(!client || client != previous)
2018 dataType = previous._class;
2019 if(previous && !strcmp(dataType.name, "CodeEditor"))
2021 ((CodeEditor)previous).UpdateFormCode();
2023 else if(previous && !strcmp(dataType.name, "Designer"))
2025 ((Designer)previous).codeEditor.UpdateFormCode();
2030 dataType = client._class;
2031 if(client && !strcmp(dataType.name, "CodeEditor"))
2033 CodeEditor codeEditor = (CodeEditor)client;
2034 SetPrivateModule(codeEditor.privateModule);
2035 SetCurrentContext(codeEditor.globalContext);
2036 SetTopContext(codeEditor.globalContext);
2037 SetGlobalContext(codeEditor.globalContext);
2039 SetDefines(&codeEditor.defines);
2040 SetImports(&codeEditor.imports);
2042 SetActiveDesigner(codeEditor.designer);
2044 sheet.codeEditor = codeEditor;
2045 toolBox.codeEditor = codeEditor;
2047 viewDesignerItem.parent = viewMenu;
2048 if(activeChild != codeEditor)
2050 viewCodeItem.parent = viewMenu;
2051 viewDesignerItem.accelerator = 0;
2052 viewCodeItem.accelerator = f8;
2056 viewCodeItem.parent = null;
2057 viewDesignerItem.accelerator = f8;
2060 else if(client && !strcmp(dataType.name, "Designer"))
2062 CodeEditor codeEditor = ((Designer)client).codeEditor;
2065 SetPrivateModule(codeEditor.privateModule);
2066 SetCurrentContext(codeEditor.globalContext);
2067 SetTopContext(codeEditor.globalContext);
2068 SetGlobalContext(codeEditor.globalContext);
2069 SetDefines(&codeEditor.defines);
2070 SetImports(&codeEditor.imports);
2074 SetPrivateModule(null);
2075 SetCurrentContext(null);
2076 SetTopContext(null);
2077 SetGlobalContext(null);
2082 SetActiveDesigner((Designer)client);
2084 sheet.codeEditor = codeEditor;
2085 toolBox.codeEditor = codeEditor;
2087 viewCodeItem.parent = viewMenu;
2088 if(activeChild != client)
2090 viewDesignerItem.parent = viewMenu;
2091 viewDesignerItem.accelerator = f8;
2092 viewCodeItem.accelerator = 0;
2096 viewDesignerItem.parent = null;
2097 viewCodeItem.accelerator = f8;
2103 sheet.codeEditor = null;
2104 toolBox.codeEditor = null;
2105 SetActiveDesigner(null);
2107 viewDesignerItem.parent = null;
2108 viewCodeItem.parent = null;
2111 SheetSelected(sheet.sheetSelected);
2114 projectCompileItem = null;
2119 if(client && client._class == eSystem_FindClass(__thisModule, "CodeEditor")) // !strcmp(client._class.name, "CodeEditor")
2121 CodeEditor codeEditor = (CodeEditor)client;
2122 EditBox editBox = codeEditor.editBox;
2124 statusBar.AddField(pos);
2126 caps = { width = 40, text = "CAPS", color = app.GetKeyState(capsState) ? black : Color { 128, 128, 128 } };
2127 statusBar.AddField(caps);
2129 ovr = { width = 30, text = "OVR", color = editBox.overwrite ? black : Color { 128, 128, 128 } };
2130 statusBar.AddField(ovr);
2132 num = { width = 30, text = "NUM", color = app.GetKeyState(numState) ? black : Color { 128, 128, 128 } };
2133 statusBar.AddField(num);
2135 //statusBar.text = "Ready";
2137 if(projectView && projectView.project)
2139 ProjectNode node = projectView.GetNodeFromWindow(client, null);
2143 sprintf(name, "Compile %s", node.name);
2144 projectCompileItem =
2146 copyText = true, text = name, c, ctrlF7, disabled = projectView.buildInProgress;
2148 bool NotifySelect(MenuItem selection, Modifiers mods)
2152 ProjectNode node = projectView.GetNodeFromWindow(activeClient, null);
2154 projectView.Compile(node);
2159 projectMenu.AddDynamic(projectCompileItem, null, false);
2165 caps = ovr = num = null;
2170 bool OnClose(bool parentClosing)
2172 //return !projectView.buildInProgress;
2173 if(projectView && projectView.buildInProgress)
2175 if(DontTerminateDebugSession("Close IDE"))
2177 if(findInFilesDialog)
2178 findInFilesDialog.SearchStop();
2181 workspace.timer.Stop();
2190 for(c = 1; c<app.argc; c++)
2192 char fullPath[MAX_LOCATION];
2193 GetWorkingDir(fullPath, MAX_LOCATION);
2194 PathCat(fullPath, app.argv[c]);
2195 if(FileExists(fullPath))
2196 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, null, yes, normal);
2203 // IS THIS NEEDED? WASN'T HERE BEFORE...
2206 projectView.visible = false;
2207 projectView.Destroy(0);
2210 #ifdef GDB_DEBUG_GUI
2211 gdbDialog.Destroy(0);
2216 void SetPath(bool projectsDirs)
2220 char * oldPaths[128];
2221 char oldList[MAX_LOCATION * 128];
2222 Array<String> newExePaths { };
2223 //Map<String, bool> exePathExists { };
2225 #if defined(__unix__) || defined(__APPLE__)
2226 Array<String> newLibPaths { };
2227 Map<String, bool> libPathExists { };
2229 CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
2233 for(prj : workspace.projects)
2235 DirExpression targetDirExp;
2237 // SKIP FIRST PROJECT...
2238 if(prj == workspace.projects.firstIterator.data) continue;
2240 targetDirExp = prj.targetDir;
2242 /*if(prj.config.targetType == sharedLibrary && prj.config.debug)
2246 for(cfg = prj.configurations.first; cfg; cfg = cfg.next)
2247 if(cfg.targetType == sharedLibrary && cfg.debug && !strcmpi(cfg.name, "Debug"))
2251 for(cfg = prj.configurations.first; cfg; cfg = cfg.next)
2252 if(cfg.targetType == sharedLibrary && cfg.debug)
2256 if(targetDirExp.dir)
2258 char buffer[MAX_LOCATION];
2259 #if defined(__WIN32__)
2260 Array<String> paths = newExePaths;
2262 Array<String> paths = newLibPaths;
2264 GetSystemPathBuffer(buffer, prj.topNode.path);
2265 PathCat(buffer, targetDirExp.dir);
2268 if(!fstrcmp(p, buffer))
2275 paths.Add(CopyString(buffer));
2277 delete targetDirExp;
2281 for(item : compiler.executableDirs)
2284 for(p : newExePaths)
2286 if(!fstrcmp(p, item))
2293 newExePaths.Add(CopySystemPath(item));
2296 GetEnvironment("PATH", oldList, sizeof(oldList));
2298 printf("Old value of PATH: %s\n", oldList);
2300 count = TokenizeWith(oldList, sizeof(oldPaths) / sizeof(char *), oldPaths, pathListSep, false);
2301 for(c = 0; c < count; c++)
2304 for(p : newExePaths)
2306 if(!fstrcmp(p, oldPaths[c]))
2313 newExePaths.Add(CopySystemPath(oldPaths[c]));
2317 for(path : newExePaths)
2318 len += strlen(path) + 1;
2319 newList = new char[len + 1];
2321 for(path : newExePaths)
2323 strcat(newList, path);
2324 strcat(newList, pathListSep);
2326 newList[len - 1] = '\0';
2327 SetEnvironment("PATH", newList);
2329 printf("New value of PATH: %s\n", newList);
2336 #if defined(__unix__) || defined(__APPLE__)
2338 for(item : compiler.libraryDirs)
2340 if(!libPathExists[item]) // fstrcmp should be used
2342 newLibPaths.Add(item);
2343 libPathExists[item] = true;
2347 #if defined(__APPLE__)
2348 GetEnvironment("DYLD_LIBRARY_PATH", oldList, sizeof(oldList));
2350 GetEnvironment("LD_LIBRARY_PATH", oldList, sizeof(oldList));
2353 printf("Old value of [DY]LD_LIBRARY_PATH: %s\n", oldList);
2355 count = TokenizeWith(oldList, sizeof(oldPaths) / sizeof(char *), oldPaths, pathListSep, false);
2356 for(c = 0; c < count; c++)
2358 if(!libPathExists[oldPaths[c]]) // fstrcmp should be used
2360 newLibPaths.Add(oldPaths[c]);
2361 libPathExists[oldPaths[c]] = true;
2366 for(path : newLibPaths)
2367 len += strlen(path) + 1;
2368 newList = new char[len + 1];
2370 for(path : newLibPaths)
2372 strcat(newList, path);
2373 strcat(newList, pathListSep);
2375 newList[len - 1] = '\0';
2376 #if defined(__APPLE__)
2377 SetEnvironment("DYLD_LIBRARY_PATH", newList);
2379 SetEnvironment("LD_LIBRARY_PATH", newList);
2382 printf("New value of [DY]LD_LIBRARY_PATH: %s\n", newList);
2387 delete libPathExists;
2392 void DestroyTemporaryProjectDir()
2394 if(tmpPrjDir && tmpPrjDir[0])
2396 if(FileExists(tmpPrjDir).isDirectory)
2397 DestroyDir(tmpPrjDir);
2398 property::tmpPrjDir = null;
2404 // Graphics Driver Menu
2408 app.currentSkin.selectionColor = selectionColor;
2409 app.currentSkin.selectionText = selectionText;
2413 driverItems = new MenuItem[app.numDrivers];
2414 for(c = 0; c < app.numDrivers; c++)
2416 driverItems[c] = MenuItem { driversMenu, app.drivers[c], NotifySelect = NotifySelectDisplayDriver };
2417 driverItems[c].id = c;
2418 driverItems[c].isRadio = true;
2421 driverItems = new MenuItem[2];
2422 #if defined(__unix__)
2423 driverItems[0] = MenuItem { driversMenu, "X", NotifySelect = NotifySelectDisplayDriver };
2424 driverItems[0].id = 0;
2425 driverItems[0].isRadio = true;
2427 driverItems[0] = MenuItem { driversMenu, "GDI", NotifySelect = NotifySelectDisplayDriver };
2428 driverItems[0].id = 0;
2429 driverItems[0].isRadio = true;
2431 driverItems[1] = MenuItem { driversMenu, "OpenGL", NotifySelect = NotifySelectDisplayDriver };
2432 driverItems[1].id = 1;
2433 driverItems[1].isRadio = true;
2435 /* skinItems = new MenuItem[app.numSkins];
2436 for(c = 0; c < app.numSkins; c++)
2438 skinItems[c] = MenuItem {skinsMenu, app.skins[c], NotifySelect = NotifySelectDisplaySkin };
2439 skinItems[c].id = c;
2440 skinItems[c].isRadio = true;
2443 ideFileDialog.master = this;
2444 ideProjectFileDialog.master = this;
2446 //SetDriverAndSkin();
2450 void UpdateRecentMenus()
2453 Menu fileMenu = menu.FindMenu("File");
2454 Menu recentFiles = fileMenu.FindMenu("Recent Files");
2455 Menu recentProjects = fileMenu.FindMenu("Recent Projects");
2456 char itemName[MAX_LOCATION + 4];
2459 recentFiles.Clear();
2462 for(recent : ideSettings.recentFiles)
2464 sprintf(itemName, "%d %s", 1 + c, recent);
2465 MakeSystemPath(itemName);
2466 recentFiles.AddDynamic(MenuItem { copyText = true, text = itemName, (Key)k1 + c, id = c, NotifySelect = ide.FileRecentFile }, null, true);
2470 recentProjects.Clear();
2472 for(recent : ideSettings.recentProjects)
2474 sprintf(itemName, "%d %s", 1 + c, recent);
2475 MakeSystemPath(itemName);
2476 recentProjects.AddDynamic(MenuItem { copyText = true, text = itemName, (Key)k1 + c, id = c, NotifySelect = ide.FileRecentProject }, null, true);
2488 void DestroyDir(char * path)
2490 RecursiveDeleteFolderFSI fsi { };
2495 class RecursiveDeleteFolderFSI : NormalFileSystemIterator
2497 bool preserveRootFolder;
2499 void OutFolder(char * folderPath, bool isRoot)
2501 if(!(preserveRootFolder && isRoot))
2502 RemoveDir(folderPath);
2505 bool OnFile(char * filePath)
2507 DeleteFile(filePath);
2512 class IDEApp : GuiApplication
2514 //driver = "Win32Console";
2515 // driver = "OpenGL";
2520 SetLoggingMode(stdOut, null);
2521 //SetLoggingMode(debug, null);
2523 settingsContainer.Load();
2524 #if defined(__unix__) || defined(__APPLE__)
2525 app.driver = (ideSettings.displayDriver && !strcmp(ideSettings.displayDriver, "OpenGL")) ? ideSettings.displayDriver : "X";
2527 app.driver = (ideSettings.displayDriver && !strcmp(ideSettings.displayDriver, "OpenGL")) ? ideSettings.displayDriver : "GDI";
2529 ide.driverItems[ideSettings.displayDriver && !strcmp(ideSettings.displayDriver,"OpenGL")].checked = true;
2533 desktop.text = titleECEREIDE;
2536 for(c = 1; c<app.argc; c++)
2538 char fullPath[MAX_LOCATION];
2539 GetWorkingDir(fullPath, MAX_LOCATION);
2540 PathCat(fullPath, app.argv[c]);
2541 ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, null, yes, normal);
2550 define app = ((IDEApp)__thisModule);
2552 define titleECEREIDE = "ECERE IDE (Debug)";
2554 define titleECEREIDE = "ECERE IDE";