Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the viewport-relative cursor pos for CCore.CursorPosition #13785

Merged
merged 1 commit into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cascadia/TerminalControl/ControlCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1602,7 +1602,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
}

auto lock = _terminal->LockForReading();
return _terminal->GetCursorPosition().to_core_point();
return _terminal->GetViewportRelativeCursorPosition().to_core_point();
}

// This one's really pushing the boundary of what counts as "encapsulation".
Expand Down
9 changes: 9 additions & 0 deletions src/cascadia/TerminalCore/Terminal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1638,3 +1638,12 @@ til::color Terminal::GetColorForMark(const Microsoft::Console::VirtualTerminal::
}
}
}

// Method Description:
// - Returns the position of the cursor relative to the active viewport
til::point Terminal::GetViewportRelativeCursorPosition() const noexcept
{
const auto absoluteCursorPosition{ GetCursorPosition() };
const auto viewport{ _GetMutableViewport() };
return absoluteCursorPosition - viewport.Origin();
}
2 changes: 2 additions & 0 deletions src/cascadia/TerminalCore/Terminal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ class Microsoft::Terminal::Core::Terminal final :
bool IsXtermBracketedPasteModeEnabled() const;
std::wstring_view GetWorkingDirectory();

til::point GetViewportRelativeCursorPosition() const noexcept;

// Write comes from the PTY and goes to our parser to be stored in the output buffer
void Write(std::wstring_view stringView);

Expand Down