Skip to content

Commit

Permalink
Handle cursor and attribute access through Page object.
Browse files Browse the repository at this point in the history
  • Loading branch information
j4james committed Jan 28, 2024
1 parent 7e51367 commit c82ca50
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 95 deletions.
22 changes: 22 additions & 0 deletions src/terminal/adapter/PageManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,28 @@ til::CoordType Page::Number() const noexcept
return _number;
}

Cursor& Page::Cursor() const noexcept
{
return _buffer.GetCursor();
}

const TextAttribute& Page::Attributes() const noexcept
{
return _buffer.GetCurrentAttributes();
}

void Page::SetAttributes(const TextAttribute& attr, ITerminalApi* api) const
{
_buffer.SetCurrentAttributes(attr);
// If the api parameter was specified, we need to pass the new attributes
// through to the api. This occurs when there's a potentail for the colors
// to be changed, which may require some legacy remapping in conhost.
if (api)
{
api->SetTextAttributes(attr);
}
}

PageManager::PageManager(ITerminalApi& api, Renderer& renderer) noexcept :
_api{ api },
_renderer{ renderer }
Expand Down
3 changes: 3 additions & 0 deletions src/terminal/adapter/PageManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ namespace Microsoft::Console::VirtualTerminal
TextBuffer& Buffer() const noexcept;
til::rect Viewport() const noexcept;
til::CoordType Number() const noexcept;
Cursor& Cursor() const noexcept;
const TextAttribute& Attributes() const noexcept;
void SetAttributes(const TextAttribute& attr, ITerminalApi* api = nullptr) const;

private:
TextBuffer& _buffer;
Expand Down
Loading

0 comments on commit c82ca50

Please sign in to comment.