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

[1.14] Use the viewport-rel. cursor pos for CursorPosition #13786

Merged
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 @@ -1419,7 +1419,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
}

auto lock = _terminal->LockForReading();
return til::point{ _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 @@ -1462,3 +1462,12 @@ void Terminal::_updateUrlDetection()
ClearPatternTree();
}
}

// Method Description:
// - Returns the position of the cursor relative to the active viewport
til::point Terminal::GetViewportRelativeCursorPosition() const noexcept
{
const til::point absoluteCursorPosition{ GetCursorPosition() };
const auto viewport{ _GetMutableViewport() };
return absoluteCursorPosition - til::point{ 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