for(c : oldSettings.compilerConfigs)
data.compilerConfigs.Add(c.Copy());
- for(s : oldSettings.recentFiles) data.recentFiles.Add(CopyString(s));
- for(s : oldSettings.recentProjects) data.recentProjects.Add(CopyString(s));
+ for(s : oldSettings.recentFiles) data.recentFiles.Add(s);
+ for(s : oldSettings.recentProjects) data.recentProjects.Add(s);
data.docDir = oldSettings.docDir;
data.ideFileDialogLocation = oldSettings.ideFileDialogLocation;
{
public:
List<CompilerConfig> compilerConfigs { };
- Array<String> recentFiles { };
- Array<String> recentProjects { };
+ RecentPaths recentFiles { };
+ RecentPaths recentProjects { };
property const char * docDir
{
set { delete docDir; if(value && value[0]) docDir = CopyString(value); }
{
compilerConfigs.Free();
delete compilerConfigs;
- recentFiles.Free();
- delete recentFiles;
- recentProjects.Free();
- delete recentProjects;
+ if(recentProjects) { recentFiles.Free(); delete recentFiles; }
+ if(recentProjects) { recentProjects.Free(); delete recentProjects; }
delete docDir;
delete projectDefaultTargetDir;
}
}
}
- if(recentFiles && recentFiles.count)
- {
- int c;
- for(c = 0; c < recentFiles.count; c++)
- {
- if(recentFiles[c] && recentFiles[c][0])
- ChangeCh(recentFiles[c], from, to);
- }
- }
- if(recentProjects && recentProjects.count)
- {
- int c;
- for(c = 0; c < recentProjects.count; c++)
- {
- if(recentProjects[c] && recentProjects[c][0])
- ChangeCh(recentProjects[c], from, to);
- }
- }
+ recentFiles.changeChar(from, to);
+ recentProjects.changeChar(from, to);
if(docDir && docDir[0])
ChangeCh(docDir, from, to);
if(ideFileDialogLocation && ideFileDialogLocation[0])
}
return output;
}
+}
- void AddRecentFile(const char * fileName)
+class RecentPaths : Array<String>
+{
+ IteratorPointer Add(T value)
{
int c;
- char * filePath = CopyString(fileName);
+ char * filePath = (char *)value;
ChangeCh(filePath, '\\', '/');
- for(c = 0; c<recentFiles.count; c++)
+ for(c = 0; c < count; c++)
{
- if(recentFiles[c] && !fstrcmp(recentFiles[c], filePath))
+ if(this[c] && !fstrcmp(this[c], filePath))
{
- recentFiles.Delete((void *)&recentFiles[c]);
+ Delete((void *)&this[c]);
c--;
}
}
- while(recentFiles.count >= MaxRecent)
- recentFiles.Delete(recentFiles.GetLast());
- recentFiles.Insert(null, filePath);
- //UpdateRecentMenus(owner);
+ return Array::Add((T)filePath);
}
- void AddRecentProject(const char * projectName)
+ IteratorPointer addRecent(T value)
{
int c;
- char * filePath = CopyString(projectName);
+ char * filePath = (char *)value;
ChangeCh(filePath, '\\', '/');
- for(c = 0; c<recentProjects.count; c++)
+ for(c = 0; c < count; c++)
{
- if(recentProjects[c] && !fstrcmp(recentProjects[c], filePath))
+ if(this[c] && !fstrcmp(this[c], filePath))
{
- recentProjects.Delete((void *)&recentProjects[c]);
+ Delete((void *)&this[c]);
c--;
}
}
- while(recentProjects.count >= MaxRecent)
- recentProjects.Delete(recentProjects.GetLast());
- recentProjects.Insert(null, filePath);
- //UpdateRecentMenus(owner);
+ while(count >= MaxRecent)
+ Delete(GetLast());
+ return Insert(null, filePath);
+ }
+
+ void changeChar(char from, char to)
+ {
+ if(this && count)
+ {
+ int c;
+ for(c = 0; c < count; c++)
+ {
+ if(this[c] && this[c][0])
+ ChangeCh(this[c], from, to);
+ }
+ }
}
}
if(!parentClosing)
{
if(ide.workspace && fileName)
- ide.workspace.UpdateOpenedFileInfo(fileName, closed);
+ ide.workspace.UpdateOpenedFileInfo(fileName, closed, false);
if(inUseDebug && !debugClosing)
{
debugClosing = true;
{
ideSettings.compilerConfigs.Add(compiler.Copy());
}
-
compilerSettingsChanged = true;
}
}
};
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
{
bool FileRecentFile(MenuItem selection, Modifiers mods)
{
int id = 0;
- for(file : ideSettings.recentFiles)
+ RecentPaths recentFiles = workspace ? workspace.recentFiles : ideSettings.recentFiles;
+ for(file : recentFiles)
{
if(id == selection.id)
{
newProjectDialog.CreateNewProject();
if(projectView)
{
- ideSettings.AddRecentProject(projectView.fileName);
- ide.UpdateRecentMenus();
+ ideSettings.recentProjects.addRecent(CopyString(projectView.fileName));
+ ide.updateRecentProjectsMenu();
settingsContainer.Save();
}
}
ideMainFrame.SetText("%s - %s", project.topNode.name, titleECEREIDE);
AdjustMenus();
+ updateRecentMenus();
ide.breakpointsView.LoadFromWorkspace();
ide.watchesView.LoadFromWorkspace();
outputView.visible = false;
ideMainFrame.text = titleECEREIDE;
ide.AdjustMenus();
+ ide.updateRecentMenus();
return true;
}
return false;
void DocumentSaved(Window document, const char * fileName)
{
- ideSettings.AddRecentFile(fileName);
- ide.UpdateRecentMenus();
+ ideSettings.recentFiles.addRecent(CopyString(fileName));
+ ide.updateRecentFilesMenu();
ide.AdjustFileMenus();
settingsContainer.Save();
}
{
document.fileName = filePath;
if(workspace && !workspace.holdTracking)
- workspace.UpdateOpenedFileInfo(filePath, opened);
+ workspace.UpdateOpenedFileInfo(filePath, opened, true);
}
}
document.state = maximized;
if(isProject)
- ideSettings.AddRecentProject(document.fileName);
- else
- ideSettings.AddRecentFile(document.fileName);
- ide.UpdateRecentMenus();
+ ideSettings.recentProjects.addRecent(CopyString(document.fileName));
+ else if(!workspace)
+ ideSettings.recentFiles.addRecent(CopyString(document.fileName));
ide.AdjustFileMenus();
+ ide.updateRecentFilesMenu();
settingsContainer.Save();
return document;
/*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;
}
newProjectDialog.Modal();
if(projectView)
{
- ideSettings.AddRecentProject(projectView.fileName);
- ide.UpdateRecentMenus();
+ ideSettings.recentProjects.addRecent(CopyString(projectView.fileName));
+ ide.updateRecentMenus();
settingsContainer.Save();
}
delete newProjectDialog;
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 : ideSettings.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;
+ void updateRecentProjectsMenu()
+ {
+ int c = 0;
+ char * itemPath = new char[MAX_LOCATION];
+ char * itemName = new char[MAX_LOCATION+4];
+ recentProjectsMenu.Clear();
for(recent : ideSettings.recentProjects)
{
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;
}
#ifndef MAKEFILE_GENERATOR
IDESettings settings = (IDESettings)data;
globalSettingsDialog.ideSettings = settings;
- ide.UpdateRecentMenus();
+ ide.updateRecentMenus();
ide.UpdateCompilerConfigs(true);
#endif
}
property List<Breakpoint> breakpoints { set { breakpoints = value; } get { return breakpoints; } isset { return breakpoints && breakpoints.count; } }
property List<Watch> watches { set { watches = value; } get { return watches; } isset { return watches && watches.count; } }
property List<OpenedFileInfo> openedFiles { set { openedFiles = value; } get { return openedFiles; } isset { return openedFiles && openedFiles.count; } }
+ property RecentPaths recentFiles { set { recentFiles = value; } get { return recentFiles; } isset { return recentFiles && recentFiles.count; } }
bool useValgrind;
ValgrindLeakCheck vgLeakCheck;
List<Breakpoint> breakpoints;
List<Watch> watches;
List<OpenedFileInfo> openedFiles;
+ RecentPaths recentFiles;
char * workspaceFile;
char * workspaceDir;
return node;
}
- OpenedFileInfo UpdateOpenedFileInfo(const char * fileName, OpenedFileState state)
+ OpenedFileInfo UpdateOpenedFileInfo(const char * fileName, OpenedFileState state, bool fileOpen)
{
+ bool insert = false;
char absolutePath[MAX_LOCATION];
char relativePath[MAX_LOCATION];
OpenedFileInfo ofi;
GetSlashPathBuffer(absolutePath, fileName);
MakeRelativePath(relativePath, fileName);
ofi = FindOpenedFileInfo(relativePath, absolutePath);
+ if(fileOpen && ofi)
+ {
+ openedFiles.Remove(openedFiles.Find(ofi));
+ insert = true;
+ }
if(state)
{
if(!ofi)
{
ofi = OpenedFileInfo { path = CopyString(relativePath) };
- openedFiles.Add(ofi);
+ insert = true;
}
ofi.state = state;
ofi.modified = GetLocalTimeStamp();
if(!holdTracking)
modified = true;
}
+ if(insert)
+ openedFiles.Insert(null, ofi);
return ofi;
}
void RestorePreviouslyOpenedFileState(CodeEditor editor)
{
- if((editor.openedFileInfo = UpdateOpenedFileInfo(editor.fileName, opened)))
+ if((editor.openedFileInfo = UpdateOpenedFileInfo(editor.fileName, opened, true)))
editor.openedFileInfo.SetCodeEditorState(editor);
}
if(!breakpoints) breakpoints = { };
if(!watches) watches = { };
if(!openedFiles) openedFiles = { };
+ if(!recentFiles) recentFiles = { };
}
void Free()
if(breakpoints) { breakpoints.Free(); delete breakpoints; }
if(watches) { watches.Free(); delete watches; }
if(openedFiles) { openedFiles.Free(); delete openedFiles; }
+ if(recentFiles) { recentFiles.Free(); delete recentFiles; }
projects.Free();
}
SetSourceDirs(null);
Free();
}
-
}
Workspace LoadWorkspace(const char * filePath, const char * fromProjectFile)
if(workspace)
{
+ if(!workspace.recentFiles || !workspace.recentFiles.count)
+ {
+ int c;
+ if(!workspace.recentFiles) workspace.recentFiles = { };
+ if(workspace.openedFiles && workspace.openedFiles.count)
+ {
+ for(c = workspace.openedFiles.count - 1; c >= 0; c--)
+ {
+ char path[MAX_LOCATION];
+ strcpy(path, workspace.workspaceDir);
+ PathCatSlash(path, workspace.openedFiles[c].path);
+ workspace.recentFiles.addRecent(CopyString(path));
+ }
+ }
+ }
workspace.Init();
if(!workspace.projects.first)
{