void MainBook::RestoreSession(SessionEntry& session) { if(session.GetTabInfoArr().empty()) return; // nothing to restore CloseAll(false); size_t sel = session.GetSelectedTab(); const std::vector<TabInfo>& vTabInfoArr = session.GetTabInfoArr(); for(size_t i = 0; i < vTabInfoArr.size(); i++) { const TabInfo& ti = vTabInfoArr[i]; m_reloadingDoRaise = (i == vTabInfoArr.size() - 1); // Raise() when opening only the last editor LEditor* editor = OpenFile(ti.GetFileName()); if(!editor) { if(i < sel) { // have to adjust selected tab number because couldn't open tab sel--; } continue; } editor->SetFirstVisibleLine(ti.GetFirstVisibleLine()); editor->SetEnsureCaretIsVisible(editor->PositionFromLine(ti.GetCurrentLine())); editor->LoadMarkersFromArray(ti.GetBookmarks()); editor->LoadCollapsedFoldsFromArray(ti.GetCollapsedFolds()); } m_book->SetSelection(sel); }
void MainBook::RestoreSession(SessionEntry &session) { size_t sel = session.GetSelectedTab(); const std::vector<TabInfo> &vTabInfoArr = session.GetTabInfoArr(); for (size_t i = 0; i < vTabInfoArr.size(); i++) { const TabInfo &ti = vTabInfoArr[i]; m_reloadingDoRaise = (i == vTabInfoArr.size()-1); // Raise() when opening only the last editor LEditor *editor = OpenFile(ti.GetFileName()); if (!editor) { if (i < sel) { // have to adjust selected tab number because couldn't open tab sel--; } continue; } editor->ScrollToLine(ti.GetFirstVisibleLine()); editor->SetEnsureCaretIsVisible(editor->PositionFromLine(ti.GetCurrentLine())); editor->LoadMarkersFromArray(ti.GetBookmarks()); editor->LoadCollapsedFoldsFromArray(ti.GetCollapsedFolds()); } // We can't just use SelectPane() here. // Notebook::DoPageChangedEvent has posted events to us, // which have the effect of selecting back to page 0 // So post ourselves an event, so that it arrives after that one NotebookEvent event(wxEVT_COMMAND_BOOK_PAGE_CHANGED, GetId()); event.SetSelection(sel); m_book->GetEventHandler()->AddPendingEvent(event); }