bool PolycodeIDEApp::quitApp() { quittingApp = true; while(editorManager->getCurrentEditor()) { PolycodeEditor *editor = editorManager->getCurrentEditor(); if(editor->hasChanges()) { OSFileEntry entry(editor->getFilePath(), OSFileEntry::TYPE_FILE); frame->yesNoCancelPopup->setCaption("The file \""+entry.name+"\" has unsaved changes. Save before quitting?"); frame->yesNoCancelPopup->action = "closeQuitFile"; frame->showModal(frame->yesNoCancelPopup); return false; } else { if(editor->getEditorHolder()) { editor->getEditorHolder()->setEditor(NULL); } editorManager->destroyEditor(editor); if(editorManager->openEditors.size() > 0) { editorManager->setCurrentEditor(editorManager->openEditors[0]); frame->getActiveProjectFrame()->getActiveTab()->showEditor(editorManager->openEditors[0]); } else{ editorManager->setCurrentEditor(NULL); } } } return true; }
PolycodeEditor *PolycodeEditorManager::getEditorForPath(String path) { for(int i=0; i < openEditors.size();i++) { PolycodeEditor *editor = openEditors[i]; if(editor->getFilePath() == path) return editor; } return NULL; }
void PolycodeIDEApp::closeFile() { // this will save the file if it has changes and/or close it (in closeFiles()) PolycodeEditor *editor = editorManager->getCurrentEditor(); if (editor) { std::vector<PolycodeEditor*> editorToSave; editorToSave.push_back(editor); OSFileEntry entry(editor->getFilePath(), OSFileEntry::TYPE_FILE); closeFiles(editorToSave, "'"+entry.name+"' has unsaved changes. Save?"); } }