Here we ensure that the editor is in a valid state, and cleanup Default buffers
| 429 | |
| 430 | // Here we ensure that the editor is in a valid state, and cleanup Default buffers |
| 431 | void ZepEditor::UpdateWindowState() { |
| 432 | // If there is no active tab window, and we have one, set it. |
| 433 | if (!m_pActiveTabWindow) { |
| 434 | if (!m_tabWindows.empty()) { |
| 435 | SetCurrentTabWindow(m_tabWindows.back()); |
| 436 | } |
| 437 | } |
| 438 | |
| 439 | // If the tab window doesn't contain an active window, and there is one, set it |
| 440 | if (m_pActiveTabWindow && !m_pActiveTabWindow->GetActiveWindow()) { |
| 441 | if (!m_pActiveTabWindow->GetWindows().empty()) { |
| 442 | m_pActiveTabWindow->SetActiveWindow(m_pActiveTabWindow->GetWindows().back()); |
| 443 | m_bRegionsChanged = true; |
| 444 | } |
| 445 | } |
| 446 | |
| 447 | // Clean up any default buffers |
| 448 | std::vector<ZepBuffer*> victims; |
| 449 | for (auto& buffer : m_buffers) { |
| 450 | if (!buffer->HasFileFlags(FileFlags::DefaultBuffer) || buffer->HasFileFlags(FileFlags::Dirty)) { |
| 451 | continue; |
| 452 | } |
| 453 | |
| 454 | auto windows = FindBufferWindows(buffer.get()); |
| 455 | if (windows.empty()) { |
| 456 | victims.push_back(buffer.get()); |
| 457 | } |
| 458 | } |
| 459 | |
| 460 | for (auto& victim : victims) { |
| 461 | RemoveBuffer(victim); |
| 462 | } |
| 463 | |
| 464 | // If the display says we need a layout update, force it on all the windows |
| 465 | if (GetDisplay().LayoutDirty()) { |
| 466 | for (auto& tabWindow : GetTabWindows()) { |
| 467 | for (auto& window : tabWindow->GetWindows()) { |
| 468 | window->DirtyLayout(); |
| 469 | } |
| 470 | } |
| 471 | GetDisplay().SetLayoutDirty(false); |
| 472 | } |
| 473 | } |
| 474 | |
| 475 | void ZepEditor::ResetCursorTimer() { |
| 476 | timer_restart(m_cursorTimer); |
nothing calls this directly
no test coverage detected