Skip to content

Commit

Permalink
Add some more comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
j4james committed Feb 3, 2024
1 parent 9630969 commit 117323f
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/terminal/adapter/PageManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,29 @@ Page PageManager::Get(const til::CoordType pageNumber) const
{
const auto requestedPageNumber = std::min(std::max(pageNumber, 1), MAX_PAGES);
auto [visibleBuffer, visibleViewport, isMainBuffer] = _api.GetBufferAndViewport();

// If we're not in the main buffer (either because an app has enabled the
// alternate buffer mode, or switched the conhost screen buffer), then VT
// paging doesn't apply, so we disregard the requested page number and just
// use the visible buffer (with a fixed page number of 1).
if (!isMainBuffer)
{
return { visibleBuffer, visibleViewport, 1 };
}
else if (requestedPageNumber == _visiblePageNumber)

// If the requested page number happens to be the visible page, then we
// can also just use the visible buffer as is.
if (requestedPageNumber == _visiblePageNumber)
{
return { visibleBuffer, visibleViewport, _visiblePageNumber };
}
else
{
const auto pageSize = visibleViewport.size();
auto& pageBuffer = _getBuffer(requestedPageNumber, pageSize);
return { pageBuffer, til::rect{ pageSize }, requestedPageNumber };
}

// Otherwise we're working with a background buffer, so we need to
// retrieve that from the buffer array, and resize it to match the
// active page size.
const auto pageSize = visibleViewport.size();
auto& pageBuffer = _getBuffer(requestedPageNumber, pageSize);
return { pageBuffer, til::rect{ pageSize }, requestedPageNumber };
}

Page PageManager::ActivePage() const
Expand Down

0 comments on commit 117323f

Please sign in to comment.