X-Git-Url: http://ecere.com/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=ide%2Fsrc%2Fide.ec;h=51eda16c24851b1e8e01dc9ff9a56fdeb2ee6801;hb=0e83a12f7aece981cf49a45847e0821e325e3069;hp=2ad63ca007dccf9eeeebcbf85e65f4c66234bd54;hpb=f389f063fc91900ffa7941621e2927870f743849;p=sdk diff --git a/ide/src/ide.ec b/ide/src/ide.ec index 2ad63ca..51eda16 100644 --- a/ide/src/ide.ec +++ b/ide/src/ide.ec @@ -306,7 +306,7 @@ class IDEToolbar : ToolBar if(ide.workspace && ide.projectView && row && strcmp(row.string, ide.workspace.activeCompiler)) { bool silent = ide.projectView.buildInProgress == none ? false : true; - CompilerConfig compiler = ideSettings.GetCompilerConfig(row.string); + CompilerConfig compiler = ideConfig.compilers.GetCompilerConfig(row.string); ide.workspace.activeCompiler = row.string; ide.projectView.ShowOutputBuildLog(!silent); if(!silent) @@ -328,7 +328,7 @@ class IDEToolbar : ToolBar if(ide.workspace && ide.projectView && row) { bool silent = ide.projectView.buildInProgress == none ? false : true; - CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.activeCompiler); + CompilerConfig compiler = ideConfig.compilers.GetCompilerConfig(ide.workspace.activeCompiler); ide.workspace.bitDepth = (int)row.tag; ide.projectView.ShowOutputBuildLog(!silent); if(!silent) @@ -441,16 +441,18 @@ class IDEWorkSpace : Window void OnGotoError(const char * line, bool noParsing) { - CompilerConfig compiler = ide.workspace ? ideSettings.GetCompilerConfig(ide.workspace.activeCompiler) : null; + CompilerConfig compiler = ide.workspace ? ideConfig.compilers.GetCompilerConfig(ide.workspace.activeCompiler) : null; const char * objectFileExt = compiler ? compiler.objectFileExt : objectDefaultFileExt; ide.GoToError(line, noParsing, objectFileExt); + delete compiler; } void OnCodeLocationParseAndGoTo(const char * line) { - CompilerConfig compiler = ide.workspace ? ideSettings.GetCompilerConfig(ide.workspace.activeCompiler) : null; + CompilerConfig compiler = ide.workspace ? ideConfig.compilers.GetCompilerConfig(ide.workspace.activeCompiler) : null; const char * objectFileExt = compiler ? compiler.objectFileExt : objectDefaultFileExt; ide.CodeLocationParseAndGoTo(line, ide.findInFilesDialog.findProject, ide.findInFilesDialog.findDir, objectFileExt); + delete compiler; } bool OnKeyDown(Key key, unichar ch) @@ -724,6 +726,10 @@ class IDEWorkSpace : Window fileMenu, $"Global Settings...", g; bool NotifySelect(MenuItem selection, Modifiers mods) { + // Reload configs here until we setup a configs directory monitor + ideConfig.compilers.Free(); + ideConfig.compilers.read(); + globalSettingsDialog.master = this; if(ide.workspace && ide.workspace.activeCompiler) globalSettingsDialog.workspaceActiveCompiler = ide.workspace.activeCompiler; @@ -734,8 +740,8 @@ class IDEWorkSpace : Window } }; MenuDivider { fileMenu }; - Menu recentFiles { fileMenu, $"Recent Files", r }; - Menu recentProjects { fileMenu, $"Recent Projects", p }; + Menu recentFilesMenu { fileMenu, $"Recent Files", r }; + Menu recentProjectsMenu { fileMenu, $"Recent Projects", p }; MenuDivider { fileMenu }; MenuItem exitItem { @@ -751,7 +757,8 @@ class IDEWorkSpace : Window bool FileRecentFile(MenuItem selection, Modifiers mods) { int id = 0; - for(file : ideSettings.recentFiles) + RecentPaths recentFiles = workspace ? workspace.recentFiles : ideConfig.recentFiles; + for(file : recentFiles) { if(id == selection.id) { @@ -780,7 +787,7 @@ class IDEWorkSpace : Window bool FileRecentProject(MenuItem selection, Modifiers mods) { int id = 0; - for(file : ideSettings.recentProjects) + for(file : ideConfig.recentWorkspaces) { if(id == selection.id) { @@ -821,9 +828,8 @@ class IDEWorkSpace : Window newProjectDialog.CreateNewProject(); if(projectView) { - ideSettings.AddRecentProject(projectView.fileName); - ide.UpdateRecentMenus(); - settingsContainer.Save(); + ideConfig.recentWorkspaces.addRecent(projectView.fileName); + ide.updateRecentProjectsMenu(); } } } @@ -1723,6 +1729,7 @@ class IDEWorkSpace : Window ideMainFrame.SetText("%s - %s", project.topNode.name, titleECEREIDE); AdjustMenus(); + updateRecentMenus(); ide.breakpointsView.LoadFromWorkspace(); ide.watchesView.LoadFromWorkspace(); @@ -1754,6 +1761,7 @@ class IDEWorkSpace : Window outputView.visible = false; ideMainFrame.text = titleECEREIDE; ide.AdjustMenus(); + ide.updateRecentMenus(); return true; } return false; @@ -1820,10 +1828,9 @@ class IDEWorkSpace : Window void DocumentSaved(Window document, const char * fileName) { - ideSettings.AddRecentFile(fileName); - ide.UpdateRecentMenus(); + ideConfig.recentFiles.addRecent(fileName); + ide.updateRecentFilesMenu(); ide.AdjustFileMenus(); - settingsContainer.Save(); } bool Window::OnFileModified(FileChange fileChange, const char * param) @@ -1859,7 +1866,7 @@ class IDEWorkSpace : Window { if(workspace) { - CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.activeCompiler); + CompilerConfig compiler = ideConfig.compilers.GetCompilerConfig(workspace.activeCompiler); for(prj : workspace.projects) projectView.ProjectUpdateMakefileForAllConfigs(prj); delete compiler; @@ -1872,7 +1879,7 @@ class IDEWorkSpace : Window if(workspace) { bool silent = mute || (ide.projectView.buildInProgress == none ? false : true); - CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.activeCompiler); + CompilerConfig compiler = ideConfig.compilers.GetCompilerConfig(workspace.activeCompiler); if(!silent) { projectView.ShowOutputBuildLog(true); @@ -1887,7 +1894,7 @@ class IDEWorkSpace : Window void UpdateToolBarActiveCompilers() { toolBar.activeCompiler.Clear(); - for(compiler : ideSettings.compilerConfigs) + for(compiler : ideConfig.compilers) { DataRow row = toolBar.activeCompiler.AddString(compiler.name); if(workspace && workspace.activeCompiler && !strcmp(compiler.name, workspace.activeCompiler)) @@ -2329,7 +2336,7 @@ class IDEWorkSpace : Window ide.projectView.ShowOutputBuildLog(true); { - CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.activeCompiler); + CompilerConfig compiler = ideConfig.compilers.GetCompilerConfig(ide.workspace.activeCompiler); ide.projectView.DisplayCompiler(compiler, false); delete compiler; } @@ -2432,7 +2439,7 @@ class IDEWorkSpace : Window if(prj) { const char * activeConfigName = null; - CompilerConfig compiler = ideSettings.GetCompilerConfig(workspace.activeCompiler); + CompilerConfig compiler = ideConfig.compilers.GetCompilerConfig(workspace.activeCompiler); prj.StartMonitoring(); workspace.AddProject(prj, null); if(toolBar.activeConfig.currentRow && toolBar.activeConfig.currentRow != toolBar.activeConfig.firstRow && @@ -2537,7 +2544,7 @@ class IDEWorkSpace : Window { document.fileName = filePath; if(workspace && !workspace.holdTracking) - workspace.UpdateOpenedFileInfo(filePath, opened); + workspace.UpdateOpenedFileInfo(filePath, opened, true); } } @@ -2566,13 +2573,16 @@ class IDEWorkSpace : Window document.state = maximized; if(isProject) - ideSettings.AddRecentProject(document.fileName); + { + ideConfig.recentWorkspaces.addRecent(document.fileName); + ide.updateRecentProjectsMenu(); + } + else if(workspace) + workspace.recentFiles.addRecent(document.fileName); else - ideSettings.AddRecentFile(document.fileName); - ide.UpdateRecentMenus(); + ideConfig.recentFiles.addRecent(document.fileName); + ide.updateRecentFilesMenu(); ide.AdjustFileMenus(); - settingsContainer.Save(); - return document; } else @@ -2583,19 +2593,19 @@ class IDEWorkSpace : Window /*bool Window::GenericDocumentOnClose(bool parentClosing) { if(!parentClosing && ide.workspace) - ide.workspace.UpdateOpenedFileInfo(fileName, unknown); + ide.workspace.UpdateOpenedFileInfo(fileName, unknown, false); return true; }*/ bool ModelView::ModelViewOnClose(bool parentClosing) { if(!parentClosing && ide.workspace) - ide.workspace.UpdateOpenedFileInfo(fileName, unknown); + ide.workspace.UpdateOpenedFileInfo(fileName, unknown, false); return true; } bool PictureEdit::PictureEditOnClose(bool parentClosing) { if(!parentClosing && ide.workspace) - ide.workspace.UpdateOpenedFileInfo(fileName, unknown); + ide.workspace.UpdateOpenedFileInfo(fileName, unknown, false); return true; } @@ -2744,7 +2754,7 @@ class IDEWorkSpace : Window //line = atoi(colon+1); } // support for "Found n match(es) in "file/path"; - 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) + else if(len > 0 && 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) { path = s+1; } @@ -3166,9 +3176,8 @@ class IDEWorkSpace : Window newProjectDialog.Modal(); if(projectView) { - ideSettings.AddRecentProject(projectView.fileName); - ide.UpdateRecentMenus(); - settingsContainer.Save(); + ideConfig.recentWorkspaces.addRecent(projectView.fileName); + ide.updateRecentMenus(); } delete newProjectDialog; // Open only one project @@ -3459,38 +3468,46 @@ class IDEWorkSpace : Window return true; } - void UpdateRecentMenus() + void updateRecentMenus() { - int c; - Menu fileMenu = menu.FindMenu($"File"); - Menu recentFiles = fileMenu.FindMenu($"Recent Files"); - Menu recentProjects = fileMenu.FindMenu($"Recent Projects"); + updateRecentFilesMenu(); + updateRecentProjectsMenu(); + } + + void updateRecentFilesMenu() + { + int c = 0; char * itemPath = new char[MAX_LOCATION]; char * itemName = new char[MAX_LOCATION+4]; - - recentFiles.Clear(); - c = 0; - - for(recent : ideSettings.recentFiles) + Workspace ws = workspace; + RecentPaths recentFiles = ws ? ws.recentFiles : ideConfig.recentFiles; + recentFilesMenu.Clear(); + for(recent : recentFiles) { strncpy(itemPath, recent, MAX_LOCATION); itemPath[MAX_LOCATION-1] = '\0'; MakeSystemPath(itemPath); snprintf(itemName, MAX_LOCATION+4, "%d %s", 1 + c, itemPath); itemName[MAX_LOCATION+4-1] = '\0'; - recentFiles.AddDynamic(MenuItem { copyText = true, text = itemName, (Key)k1 + c, id = c, NotifySelect = ide.FileRecentFile }, ide, true); + recentFilesMenu.AddDynamic(MenuItem { copyText = true, text = itemName, (Key)k1 + c, id = c, NotifySelect = ide.FileRecentFile }, ide, true); c++; } + delete itemPath; + delete itemName; + } - recentProjects.Clear(); - c = 0; - for(recent : ideSettings.recentProjects) + void updateRecentProjectsMenu() + { + int c = 0; + char * itemPath = new char[MAX_LOCATION]; + char * itemName = new char[MAX_LOCATION+4]; + recentProjectsMenu.Clear(); + for(recent : ideConfig.recentWorkspaces) { strncpy(itemPath, recent, MAX_LOCATION); itemPath[MAX_LOCATION-1] = '\0'; MakeSystemPath(itemPath); snprintf(itemName, MAX_LOCATION+4, "%d %s", 1 + c, itemPath); itemName[MAX_LOCATION+4-1] = '\0'; - recentProjects.AddDynamic(MenuItem { copyText = true, text = itemName, (Key)k1 + c, id = c, NotifySelect = ide.FileRecentProject }, ide, true); + recentProjectsMenu.AddDynamic(MenuItem { copyText = true, text = itemName, (Key)k1 + c, id = c, NotifySelect = ide.FileRecentProject }, ide, true); c++; } - delete itemPath; delete itemName; } @@ -3655,6 +3672,10 @@ class IDEApp : GuiApplication } } + ideConfig.compilers.read(); + ideConfig.recentFiles.read(); + ideConfig.recentWorkspaces.read(); + // First count files arg to decide whether to maximize { bool passThrough = false, debugWorkDir = false; @@ -3717,6 +3738,8 @@ class IDEApp : GuiApplication } */ + globalSettingsDialog.settingsContainer = settingsContainer; + // Default to language specified by environment if no language selected if(!ideSettings.language) {