mirror of
https://github.com/microsoft/terminal.git
synced 2026-09-25 08:24:54 +00:00
Address feedback
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
// Return Value:
|
||||
// - constructed object
|
||||
ATTR_ROW::ATTR_ROW(const til::CoordType width, const TextAttribute attr) :
|
||||
_data(gsl::narrow<uint16_t>(width), attr) {}
|
||||
_data(gsl::narrow_cast<uint16_t>(width), attr) {}
|
||||
|
||||
// Routine Description:
|
||||
// - Sets all properties of the ATTR_ROW to default values
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
|
||||
// - phOutput: Receives the handle to the newly-created anonymous pipe for reading the output of the conpty.
|
||||
// - phPc: Receives a token value to identify this conpty
|
||||
#pragma warning(suppress : 26430) // This statement sufficiently checks the out parameters. Analyzer cannot find this.
|
||||
static HRESULT _CreatePseudoConsoleAndPipes(const til::size size, const DWORD dwFlags, HANDLE* phInput, HANDLE* phOutput, HPCON* phPC) noexcept
|
||||
static HRESULT _CreatePseudoConsoleAndPipes(const COORD size, const DWORD dwFlags, HANDLE* phInput, HANDLE* phOutput, HPCON* phPC) noexcept
|
||||
{
|
||||
RETURN_HR_IF(E_INVALIDARG, phPC == nullptr || phInput == nullptr || phOutput == nullptr);
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
|
||||
|
||||
RETURN_IF_WIN32_BOOL_FALSE(CreatePipe(&inPipePseudoConsoleSide, &inPipeOurSide, nullptr, 0));
|
||||
RETURN_IF_WIN32_BOOL_FALSE(CreatePipe(&outPipeOurSide, &outPipePseudoConsoleSide, nullptr, 0));
|
||||
RETURN_IF_FAILED(ConptyCreatePseudoConsole(til::unwrap_coord_size(size), inPipePseudoConsoleSide.get(), outPipePseudoConsoleSide.get(), dwFlags, phPC));
|
||||
RETURN_IF_FAILED(ConptyCreatePseudoConsole(size, inPipePseudoConsoleSide.get(), outPipePseudoConsoleSide.get(), dwFlags, phPC));
|
||||
*phInput = inPipeOurSide.release();
|
||||
*phOutput = outPipeOurSide.release();
|
||||
return S_OK;
|
||||
@@ -226,8 +226,8 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
|
||||
const winrt::hstring& startingDirectory,
|
||||
const winrt::hstring& startingTitle,
|
||||
const Windows::Foundation::Collections::IMapView<hstring, hstring>& environment,
|
||||
til::CoordType rows,
|
||||
til::CoordType columns,
|
||||
uint32_t rows,
|
||||
uint32_t columns,
|
||||
const winrt::guid& guid)
|
||||
{
|
||||
Windows::Foundation::Collections::ValueSet vs{};
|
||||
@@ -235,8 +235,8 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
|
||||
vs.Insert(L"commandline", Windows::Foundation::PropertyValue::CreateString(cmdline));
|
||||
vs.Insert(L"startingDirectory", Windows::Foundation::PropertyValue::CreateString(startingDirectory));
|
||||
vs.Insert(L"startingTitle", Windows::Foundation::PropertyValue::CreateString(startingTitle));
|
||||
vs.Insert(L"initialRows", Windows::Foundation::PropertyValue::CreateUInt32(gsl::narrow<uint32_t>(rows)));
|
||||
vs.Insert(L"initialCols", Windows::Foundation::PropertyValue::CreateUInt32(gsl::narrow<uint32_t>(columns)));
|
||||
vs.Insert(L"initialRows", Windows::Foundation::PropertyValue::CreateUInt32(rows));
|
||||
vs.Insert(L"initialCols", Windows::Foundation::PropertyValue::CreateUInt32(columns));
|
||||
vs.Insert(L"guid", Windows::Foundation::PropertyValue::CreateGuid(guid));
|
||||
|
||||
if (environment)
|
||||
@@ -262,8 +262,8 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
|
||||
_commandline = winrt::unbox_value_or<winrt::hstring>(settings.TryLookup(L"commandline").try_as<Windows::Foundation::IPropertyValue>(), _commandline);
|
||||
_startingDirectory = winrt::unbox_value_or<winrt::hstring>(settings.TryLookup(L"startingDirectory").try_as<Windows::Foundation::IPropertyValue>(), _startingDirectory);
|
||||
_startingTitle = winrt::unbox_value_or<winrt::hstring>(settings.TryLookup(L"startingTitle").try_as<Windows::Foundation::IPropertyValue>(), _startingTitle);
|
||||
_initialRows = gsl::narrow<til::CoordType>(winrt::unbox_value_or<uint32_t>(settings.TryLookup(L"initialRows").try_as<Windows::Foundation::IPropertyValue>(), _initialRows));
|
||||
_initialCols = gsl::narrow<til::CoordType>(winrt::unbox_value_or<uint32_t>(settings.TryLookup(L"initialCols").try_as<Windows::Foundation::IPropertyValue>(), _initialCols));
|
||||
_initialRows = winrt::unbox_value_or<uint32_t>(settings.TryLookup(L"initialRows").try_as<Windows::Foundation::IPropertyValue>(), _initialRows);
|
||||
_initialCols = winrt::unbox_value_or<uint32_t>(settings.TryLookup(L"initialCols").try_as<Windows::Foundation::IPropertyValue>(), _initialCols);
|
||||
_guid = winrt::unbox_value_or<winrt::guid>(settings.TryLookup(L"guid").try_as<Windows::Foundation::IPropertyValue>(), _guid);
|
||||
_environment = settings.TryLookup(L"environment").try_as<Windows::Foundation::Collections::ValueSet>();
|
||||
if constexpr (Feature_VtPassthroughMode::IsEnabled())
|
||||
@@ -293,7 +293,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
|
||||
{
|
||||
_transitionToState(ConnectionState::Connecting);
|
||||
|
||||
const til::size dimensions{ _initialCols, _initialRows };
|
||||
const til::size dimensions{ gsl::narrow<til::CoordType>(_initialCols), gsl::narrow<til::CoordType>(_initialRows) };
|
||||
|
||||
// If we do not have pipes already, then this is a fresh connection... not an inbound one that is a received
|
||||
// handoff from an already-started PTY process.
|
||||
@@ -309,7 +309,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
|
||||
}
|
||||
}
|
||||
|
||||
THROW_IF_FAILED(_CreatePseudoConsoleAndPipes(dimensions, flags, &_inPipe, &_outPipe, &_hPC));
|
||||
THROW_IF_FAILED(_CreatePseudoConsoleAndPipes(til::unwrap_coord_size(dimensions), flags, &_inPipe, &_outPipe, &_hPC));
|
||||
|
||||
if (_initialParentHwnd != 0)
|
||||
{
|
||||
@@ -474,7 +474,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
|
||||
LOG_IF_WIN32_BOOL_FALSE(WriteFile(_inPipe.get(), str.c_str(), (DWORD)str.length(), nullptr, nullptr));
|
||||
}
|
||||
|
||||
void ConptyConnection::Resize(til::CoordType rows, til::CoordType columns)
|
||||
void ConptyConnection::Resize(uint32_t rows, uint32_t columns)
|
||||
{
|
||||
// If we haven't started connecting at all, it's still fair to update
|
||||
// the initial rows and columns before we set things up.
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
|
||||
|
||||
void Start();
|
||||
void WriteInput(const hstring& data);
|
||||
void Resize(til::CoordType rows, til::CoordType columns);
|
||||
void Resize(uint32_t rows, uint32_t columns);
|
||||
void Close() noexcept;
|
||||
void ClearBuffer();
|
||||
|
||||
@@ -53,8 +53,8 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
|
||||
const winrt::hstring& startingDirectory,
|
||||
const winrt::hstring& startingTitle,
|
||||
const Windows::Foundation::Collections::IMapView<hstring, hstring>& environment,
|
||||
til::CoordType rows,
|
||||
til::CoordType columns,
|
||||
uint32_t rows,
|
||||
uint32_t columns,
|
||||
const winrt::guid& guid);
|
||||
|
||||
WINRT_CALLBACK(TerminalOutput, TerminalOutputHandler);
|
||||
|
||||
@@ -837,8 +837,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
// - <none>
|
||||
void ControlCore::_refreshSizeUnderLock()
|
||||
{
|
||||
auto cx = static_cast<til::CoordType>(_panelWidth * _compositionScale);
|
||||
auto cy = static_cast<til::CoordType>(_panelHeight * _compositionScale);
|
||||
auto cx = gsl::narrow_cast<til::CoordType>(_panelWidth * _compositionScale);
|
||||
auto cy = gsl::narrow_cast<til::CoordType>(_panelHeight * _compositionScale);
|
||||
|
||||
// Don't actually resize so small that a single character wouldn't fit
|
||||
// in either dimension. The buffer really doesn't like being size 0.
|
||||
|
||||
@@ -446,10 +446,10 @@ til::rect NonClientIslandWindow::_GetDragAreaRect() const noexcept
|
||||
};
|
||||
const auto clientDragBarRect = transform.TransformBounds(logicalDragBarRect);
|
||||
return {
|
||||
static_cast<til::CoordType>(clientDragBarRect.X * scale),
|
||||
static_cast<til::CoordType>(clientDragBarRect.Y * scale),
|
||||
static_cast<til::CoordType>((clientDragBarRect.Width + clientDragBarRect.X) * scale),
|
||||
static_cast<til::CoordType>((clientDragBarRect.Height + clientDragBarRect.Y) * scale),
|
||||
gsl::narrow_cast<til::CoordType>(clientDragBarRect.X * scale),
|
||||
gsl::narrow_cast<til::CoordType>(clientDragBarRect.Y * scale),
|
||||
gsl::narrow_cast<til::CoordType>((clientDragBarRect.Width + clientDragBarRect.X) * scale),
|
||||
gsl::narrow_cast<til::CoordType>((clientDragBarRect.Height + clientDragBarRect.Y) * scale),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -194,6 +194,15 @@ static void _releaseNotifier() noexcept
|
||||
_comServerExitEvent.SetEvent();
|
||||
}
|
||||
|
||||
// This method has the same behavior as gsl::narrow<T>, but instead of throwing an
|
||||
// exception on narrowing failure it'll return false. On success it returns true.
|
||||
template<typename T, typename U>
|
||||
constexpr bool narrow_maybe(U u, T& out) noexcept
|
||||
{
|
||||
out = gsl::narrow_cast<T>(u);
|
||||
return static_cast<U>(out) == u && (std::is_signed_v<T> == std::is_signed_v<U> || (out < T{}) == (u < U{}));
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
// - Main entry point for EXE version of console launching.
|
||||
// This can be used as a debugging/diagnostics tool as well as a method of testing the console without
|
||||
|
||||
@@ -564,7 +564,7 @@ til::size Settings::GetScreenBufferSize() const
|
||||
}
|
||||
void Settings::SetScreenBufferSize(const til::size dwScreenBufferSize)
|
||||
{
|
||||
_dwScreenBufferSize = til::unwrap_coord_size(dwScreenBufferSize);
|
||||
LOG_IF_FAILED(til::unwrap_coord_size_hr(dwScreenBufferSize, _dwScreenBufferSize));
|
||||
}
|
||||
|
||||
til::size Settings::GetWindowSize() const
|
||||
@@ -573,7 +573,7 @@ til::size Settings::GetWindowSize() const
|
||||
}
|
||||
void Settings::SetWindowSize(const til::size dwWindowSize)
|
||||
{
|
||||
_dwWindowSize = til::unwrap_coord_size(dwWindowSize);
|
||||
LOG_IF_FAILED(til::unwrap_coord_size_hr(dwWindowSize, _dwWindowSize));
|
||||
}
|
||||
|
||||
bool Settings::IsWindowSizePixelsValid() const
|
||||
@@ -586,7 +586,7 @@ til::size Settings::GetWindowSizePixels() const
|
||||
}
|
||||
void Settings::SetWindowSizePixels(const til::size dwWindowSizePixels)
|
||||
{
|
||||
_dwWindowSizePixels = til::unwrap_coord_size(dwWindowSizePixels);
|
||||
LOG_IF_FAILED(til::unwrap_coord_size_hr(dwWindowSizePixels, _dwWindowSizePixels));
|
||||
}
|
||||
|
||||
til::size Settings::GetWindowOrigin() const
|
||||
@@ -595,7 +595,7 @@ til::size Settings::GetWindowOrigin() const
|
||||
}
|
||||
void Settings::SetWindowOrigin(const til::size dwWindowOrigin)
|
||||
{
|
||||
_dwWindowOrigin = til::unwrap_coord_size(dwWindowOrigin);
|
||||
LOG_IF_FAILED(til::unwrap_coord_size_hr(dwWindowOrigin, _dwWindowOrigin));
|
||||
}
|
||||
|
||||
DWORD Settings::GetFont() const
|
||||
@@ -613,7 +613,7 @@ til::size Settings::GetFontSize() const
|
||||
}
|
||||
void Settings::SetFontSize(const til::size dwFontSize)
|
||||
{
|
||||
_dwFontSize = til::unwrap_coord_size(dwFontSize);
|
||||
LOG_IF_FAILED(til::unwrap_coord_size_hr(dwFontSize, _dwFontSize));
|
||||
}
|
||||
|
||||
UINT Settings::GetFontFamily() const
|
||||
|
||||
@@ -77,4 +77,13 @@ namespace til
|
||||
static constexpr details::flooring_t flooring; // positives become less positive, negatives become more negative
|
||||
static constexpr details::rounding_t rounding; // it's rounding, from math class
|
||||
}
|
||||
|
||||
// This method has the same behavior as gsl::narrow<T>, but instead of throwing an
|
||||
// exception on narrowing failure it'll return false. On success it returns true.
|
||||
template<typename T, typename U>
|
||||
constexpr bool narrow_maybe(U u, T& out) noexcept
|
||||
{
|
||||
out = gsl::narrow_cast<T>(u);
|
||||
return static_cast<U>(out) == u && (std::is_signed_v<T> == std::is_signed_v<U> || (out < T{}) == (u < U{}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,18 +245,31 @@ namespace til // Terminal Implementation Library. Also: "Today I Learned"
|
||||
}
|
||||
};
|
||||
|
||||
constexpr point wrap_coord(const COORD rect) noexcept
|
||||
constexpr point wrap_coord(const COORD pt) noexcept
|
||||
{
|
||||
return { rect.X, rect.Y };
|
||||
return { pt.X, pt.Y };
|
||||
}
|
||||
|
||||
constexpr COORD unwrap_coord(const point rect)
|
||||
constexpr COORD unwrap_coord(const point pt)
|
||||
{
|
||||
return {
|
||||
gsl::narrow<short>(rect.X),
|
||||
gsl::narrow<short>(rect.Y),
|
||||
gsl::narrow<short>(pt.x),
|
||||
gsl::narrow<short>(pt.y),
|
||||
};
|
||||
}
|
||||
|
||||
constexpr HRESULT unwrap_coord_hr(const point pt, COORD& out) noexcept
|
||||
{
|
||||
short x;
|
||||
short y;
|
||||
if (narrow_maybe(pt.x, x) && narrow_maybe(pt.y, y))
|
||||
{
|
||||
out.X = x;
|
||||
out.Y = y;
|
||||
return S_OK;
|
||||
}
|
||||
return HRESULT_FROM_WIN32(ERROR_UNHANDLED_EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __WEX_COMMON_H__
|
||||
|
||||
@@ -70,6 +70,23 @@ namespace til // Terminal Implementation Library. Also: "Today I Learned"
|
||||
};
|
||||
}
|
||||
|
||||
constexpr HRESULT unwrap_small_rect_hr(const inclusive_rect& rect, SMALL_RECT& out) noexcept
|
||||
{
|
||||
short l;
|
||||
short t;
|
||||
short r;
|
||||
short b;
|
||||
if (narrow_maybe(rect.left, l) && narrow_maybe(rect.top, t) && narrow_maybe(rect.right, r) && narrow_maybe(rect.bottom, b))
|
||||
{
|
||||
out.Left = l;
|
||||
out.Top = t;
|
||||
out.Right = r;
|
||||
out.Bottom = b;
|
||||
return S_OK;
|
||||
}
|
||||
return HRESULT_FROM_WIN32(ERROR_UNHANDLED_EXCEPTION);
|
||||
}
|
||||
|
||||
namespace details
|
||||
{
|
||||
class _rectangle_const_iterator
|
||||
@@ -759,6 +776,23 @@ namespace til // Terminal Implementation Library. Also: "Today I Learned"
|
||||
gsl::narrow<short>(rect.bottom),
|
||||
};
|
||||
}
|
||||
|
||||
constexpr HRESULT unwrap_exclusive_small_rect_hr(const rect& rect, SMALL_RECT& out) noexcept
|
||||
{
|
||||
short l;
|
||||
short t;
|
||||
short r;
|
||||
short b;
|
||||
if (narrow_maybe(rect.left, l) && narrow_maybe(rect.top, t) && narrow_maybe(rect.right, r) && narrow_maybe(rect.bottom, b))
|
||||
{
|
||||
out.Left = l;
|
||||
out.Top = t;
|
||||
out.Right = r;
|
||||
out.Bottom = b;
|
||||
return S_OK;
|
||||
}
|
||||
return HRESULT_FROM_WIN32(ERROR_UNHANDLED_EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __WEX_COMMON_H__
|
||||
|
||||
@@ -192,18 +192,31 @@ namespace til // Terminal Implementation Library. Also: "Today I Learned"
|
||||
}
|
||||
};
|
||||
|
||||
constexpr size wrap_coord_size(const COORD rect) noexcept
|
||||
constexpr size wrap_coord_size(const COORD sz) noexcept
|
||||
{
|
||||
return { rect.X, rect.Y };
|
||||
return { sz.X, sz.Y };
|
||||
}
|
||||
|
||||
constexpr COORD unwrap_coord_size(const size rect)
|
||||
constexpr COORD unwrap_coord_size(const size sz)
|
||||
{
|
||||
return {
|
||||
gsl::narrow<short>(rect.width),
|
||||
gsl::narrow<short>(rect.height),
|
||||
gsl::narrow<short>(sz.width),
|
||||
gsl::narrow<short>(sz.height),
|
||||
};
|
||||
}
|
||||
|
||||
constexpr HRESULT unwrap_coord_size_hr(const size sz, COORD& out) noexcept
|
||||
{
|
||||
short x;
|
||||
short y;
|
||||
if (narrow_maybe(sz.width, x) && narrow_maybe(sz.height, y))
|
||||
{
|
||||
out.X = x;
|
||||
out.Y = y;
|
||||
return S_OK;
|
||||
}
|
||||
return HRESULT_FROM_WIN32(ERROR_UNHANDLED_EXCEPTION);
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef __WEX_COMMON_H__
|
||||
|
||||
@@ -300,8 +300,8 @@ void Menu::s_ShowPropertiesDialog(HWND const hwnd, BOOL const Defaults)
|
||||
{
|
||||
const auto& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
|
||||
const auto& ScreenInfo = gci.GetActiveOutputBuffer();
|
||||
pStateInfo->ScreenBufferSize = til::unwrap_coord_size(ScreenInfo.GetBufferSize().Dimensions());
|
||||
pStateInfo->WindowSize = til::unwrap_coord_size(ScreenInfo.GetViewport().Dimensions());
|
||||
LOG_IF_FAILED(til::unwrap_coord_size_hr(ScreenInfo.GetBufferSize().Dimensions(), pStateInfo->ScreenBufferSize));
|
||||
LOG_IF_FAILED(til::unwrap_coord_size_hr(ScreenInfo.GetViewport().Dimensions(), pStateInfo->WindowSize));
|
||||
|
||||
const auto rcWindow = ServiceLocator::LocateConsoleWindow<Window>()->GetWindowRect();
|
||||
pStateInfo->WindowPosX = rcWindow.left;
|
||||
@@ -309,7 +309,7 @@ void Menu::s_ShowPropertiesDialog(HWND const hwnd, BOOL const Defaults)
|
||||
|
||||
const auto& currentFont = ScreenInfo.GetCurrentFont();
|
||||
pStateInfo->FontFamily = currentFont.GetFamily();
|
||||
pStateInfo->FontSize = til::unwrap_coord_size(currentFont.GetUnscaledSize());
|
||||
LOG_IF_FAILED(til::unwrap_coord_size_hr(currentFont.GetUnscaledSize(), pStateInfo->FontSize));
|
||||
pStateInfo->FontWeight = currentFont.GetWeight();
|
||||
LOG_IF_FAILED(StringCchCopyW(pStateInfo->FaceName, ARRAYSIZE(pStateInfo->FaceName), currentFont.GetFaceName().data()));
|
||||
|
||||
|
||||
@@ -1188,8 +1188,6 @@ void Renderer::_PaintSelection(_In_ IRenderEngine* const pEngine)
|
||||
{
|
||||
for (auto& dirtyRect : dirtyAreas)
|
||||
{
|
||||
// Make a copy as `TrimToViewport` will manipulate it and
|
||||
// can destroy it for the next dirtyRect to test against.
|
||||
if (const auto rectCopy = rect & dirtyRect)
|
||||
{
|
||||
LOG_IF_FAILED(pEngine->PaintSelection(rectCopy));
|
||||
|
||||
@@ -60,7 +60,7 @@ HRESULT GdiEngine::InvalidateSelection(const std::vector<til::rect>& rectangles)
|
||||
// - Notifies us that the console has changed the character region specified.
|
||||
// - NOTE: This typically triggers on cursor or text buffer changes
|
||||
// Arguments:
|
||||
// - psrRegion - Character region (til::inclusive_rect) that has been changed
|
||||
// - psrRegion - Character region (til::rect) that has been changed
|
||||
// Return Value:
|
||||
// - S_OK, GDI related failure, or safemath failure.
|
||||
HRESULT GdiEngine::Invalidate(const til::rect* const psrRegion) noexcept
|
||||
|
||||
@@ -54,7 +54,7 @@ UiaEngine::UiaEngine(IUiaEventDispatcher* dispatcher) :
|
||||
// - Notifies us that the console has changed the character region specified.
|
||||
// - NOTE: This typically triggers on cursor or text buffer changes
|
||||
// Arguments:
|
||||
// - psrRegion - Character region (til::inclusive_rect) that has been changed
|
||||
// - psrRegion - Character region (til::rect) that has been changed
|
||||
// Return Value:
|
||||
// - S_OK, else an appropriate HRESULT for failing to allocate or write.
|
||||
[[nodiscard]] HRESULT UiaEngine::Invalidate(const til::rect* const /*psrRegion*/) noexcept
|
||||
|
||||
@@ -43,7 +43,7 @@ using namespace Microsoft::Console::Render;
|
||||
// - Notifies us that the console has changed the character region specified.
|
||||
// - NOTE: This typically triggers on cursor or text buffer changes
|
||||
// Arguments:
|
||||
// - psrRegion - Character region (til::inclusive_rect) that has been changed
|
||||
// - psrRegion - Character region (til::rect) that has been changed
|
||||
// Return Value:
|
||||
// - S_OK, else an appropriate HRESULT for failing to allocate or write.
|
||||
[[nodiscard]] HRESULT VtEngine::Invalidate(const til::rect* const psrRegion) noexcept
|
||||
|
||||
@@ -16,7 +16,7 @@ using namespace Microsoft::Console;
|
||||
using namespace Microsoft::Console::Render;
|
||||
using namespace Microsoft::Console::Types;
|
||||
|
||||
const til::point VtEngine::INVALID_COORDS = { -1, -1 };
|
||||
constexpr til::point VtEngine::INVALID_COORDS = { -1, -1 };
|
||||
|
||||
// Routine Description:
|
||||
// - Creates a new VT-based rendering engine
|
||||
|
||||
@@ -724,8 +724,7 @@
|
||||
|
||||
auto size = til::wrap_coord_size(a->Size);
|
||||
m->_pApiRoutines->GetLargestConsoleWindowSizeImpl(*pObj, size);
|
||||
a->Size = til::unwrap_coord_size(size);
|
||||
return S_OK;
|
||||
return til::unwrap_coord_size_hr(size, a->Size);
|
||||
}
|
||||
|
||||
[[nodiscard]] HRESULT ApiDispatchers::ServerScrollConsoleScreenBuffer(_Inout_ CONSOLE_API_MSG* const m,
|
||||
@@ -910,7 +909,7 @@
|
||||
// Backup originalRegion and set the written area to a 0 size rectangle in case of failures.
|
||||
const auto originalRegion = Microsoft::Console::Types::Viewport::FromInclusive(til::wrap_small_rect(a->CharRegion));
|
||||
auto writtenRegion = Microsoft::Console::Types::Viewport::FromDimensions(originalRegion.Origin(), { 0, 0 });
|
||||
a->CharRegion = til::unwrap_small_rect(writtenRegion.ToInclusive());
|
||||
RETURN_IF_FAILED(til::unwrap_small_rect_hr(writtenRegion.ToInclusive(), a->CharRegion));
|
||||
|
||||
// Get input parameter buffer
|
||||
PVOID pvBuffer;
|
||||
@@ -941,9 +940,7 @@
|
||||
}
|
||||
|
||||
// Update the written region if we were successful
|
||||
a->CharRegion = til::unwrap_small_rect(writtenRegion.ToInclusive());
|
||||
|
||||
return S_OK;
|
||||
return til::unwrap_small_rect_hr(writtenRegion.ToInclusive(), a->CharRegion);
|
||||
}
|
||||
|
||||
[[nodiscard]] HRESULT ApiDispatchers::ServerWriteConsoleOutputString(_Inout_ CONSOLE_API_MSG* const m,
|
||||
@@ -1043,7 +1040,7 @@
|
||||
// Backup data region passed and set it to a zero size region in case we exit early for failures.
|
||||
const auto originalRegion = Microsoft::Console::Types::Viewport::FromInclusive(til::wrap_small_rect(a->CharRegion));
|
||||
const auto zeroRegion = Microsoft::Console::Types::Viewport::FromDimensions(originalRegion.Origin(), { 0, 0 });
|
||||
a->CharRegion = til::unwrap_small_rect(zeroRegion.ToInclusive());
|
||||
RETURN_IF_FAILED(til::unwrap_small_rect_hr(zeroRegion.ToInclusive(), a->CharRegion));
|
||||
|
||||
PVOID pvBuffer;
|
||||
ULONG cbBuffer;
|
||||
@@ -1079,7 +1076,7 @@
|
||||
finalRegion));
|
||||
}
|
||||
|
||||
a->CharRegion = til::unwrap_small_rect(finalRegion.ToInclusive());
|
||||
RETURN_IF_FAILED(til::unwrap_small_rect_hr(finalRegion.ToInclusive(), a->CharRegion));
|
||||
|
||||
// We have to reply back with the entire buffer length. The client side in kernelbase will trim out
|
||||
// the correct region of the buffer for return to the original caller.
|
||||
@@ -1192,8 +1189,7 @@
|
||||
|
||||
auto size = til::wrap_coord_size(a->FontSize);
|
||||
const auto hr = m->_pApiRoutines->GetConsoleFontSizeImpl(*pObj, a->FontIndex, size);
|
||||
a->FontSize = til::unwrap_coord_size(size);
|
||||
return hr;
|
||||
return til::unwrap_coord_size_hr(size, a->FontSize);
|
||||
}
|
||||
|
||||
[[nodiscard]] HRESULT ApiDispatchers::ServerGetConsoleCurrentFont(_Inout_ CONSOLE_API_MSG* const m,
|
||||
@@ -1236,8 +1232,7 @@
|
||||
|
||||
auto size = til::wrap_coord_size(a->ScreenBufferDimensions);
|
||||
const auto hr = m->_pApiRoutines->SetConsoleDisplayModeImpl(*pObj, a->dwFlags, size);
|
||||
a->ScreenBufferDimensions = til::unwrap_coord_size(size);
|
||||
return hr;
|
||||
return til::unwrap_coord_size_hr(size, a->ScreenBufferDimensions);
|
||||
}
|
||||
|
||||
[[nodiscard]] HRESULT ApiDispatchers::ServerGetConsoleDisplayMode(_Inout_ CONSOLE_API_MSG* const m,
|
||||
|
||||
@@ -130,7 +130,7 @@ bool FontBuffer::SetAttributes(const DispatchTypes::DrcsCellMatrix cellMatrix,
|
||||
// 0 width is treated as unknown (we'll try and estimate the expected
|
||||
// width), and the height parameter can still give us the height.
|
||||
_sizeDeclaredAsMatrix = false;
|
||||
_declaredWidth = static_cast<til::CoordType>(cellMatrix);
|
||||
_declaredWidth = static_cast<VTInt>(cellMatrix);
|
||||
_declaredHeight = cellHeight.value_or(0);
|
||||
valid = (_declaredWidth <= MAX_WIDTH && _declaredHeight <= MAX_HEIGHT);
|
||||
break;
|
||||
@@ -227,9 +227,9 @@ til::size FontBuffer::GetCellSize() const noexcept
|
||||
return { _fullWidth, _fullHeight };
|
||||
}
|
||||
|
||||
til::CoordType FontBuffer::GetTextCenteringHint() const noexcept
|
||||
size_t FontBuffer::GetTextCenteringHint() const noexcept
|
||||
{
|
||||
return _textCenteringHint;
|
||||
return gsl::narrow_cast<size_t>(_textCenteringHint);
|
||||
}
|
||||
|
||||
VTID FontBuffer::GetDesignation() const noexcept
|
||||
@@ -309,7 +309,7 @@ void FontBuffer::_prepareNextCharacter()
|
||||
}
|
||||
}
|
||||
|
||||
void FontBuffer::_addSixelValue(const til::CoordType value) noexcept
|
||||
void FontBuffer::_addSixelValue(const VTInt value) noexcept
|
||||
{
|
||||
if (_currentChar < MAX_CHARS && _sixelColumn < _textWidth)
|
||||
{
|
||||
@@ -319,10 +319,10 @@ void FontBuffer::_addSixelValue(const til::CoordType value) noexcept
|
||||
const auto outputColumnBit = (0x8000 >> (_sixelColumn + _textOffset));
|
||||
auto outputIterator = _currentCharBuffer;
|
||||
auto inputValueMask = 1;
|
||||
for (til::CoordType i = 0; i < 6 && _sixelRow + i < _fullHeight; i++)
|
||||
for (VTInt i = 0; i < 6 && _sixelRow + i < _fullHeight; i++)
|
||||
{
|
||||
*outputIterator |= (value & inputValueMask) ? outputColumnBit : 0;
|
||||
outputIterator++;
|
||||
++outputIterator;
|
||||
inputValueMask <<= 1;
|
||||
}
|
||||
}
|
||||
@@ -350,7 +350,7 @@ void FontBuffer::_endOfCharacter()
|
||||
_prepareNextCharacter();
|
||||
}
|
||||
|
||||
std::tuple<til::CoordType, til::CoordType, til::CoordType> FontBuffer::_calculateDimensions() const
|
||||
std::tuple<VTInt, VTInt, VTInt> FontBuffer::_calculateDimensions() const
|
||||
{
|
||||
// If the size is declared as a matrix, this is most likely a VT2xx font,
|
||||
// typically with a cell size of 10x10. However, in 132-column mode, the
|
||||
@@ -398,7 +398,7 @@ std::tuple<til::CoordType, til::CoordType, til::CoordType> FontBuffer::_calculat
|
||||
// estimate the size from the used sixel values. If comparing a sixel-based
|
||||
// height, though, we need to round up the target cell height to account for
|
||||
// the fact that our used height will always be a multiple of six.
|
||||
const auto inRange = [=](const til::CoordType cellWidth, const til::CoordType cellHeight) {
|
||||
const auto inRange = [=](const VTInt cellWidth, const VTInt cellHeight) {
|
||||
const auto sixelHeight = (cellHeight + 5) / 6 * 6;
|
||||
const auto heightInRange = _declaredHeight ? _declaredHeight <= cellHeight : _usedHeight <= sixelHeight;
|
||||
const auto widthInRange = _declaredWidth ? _declaredWidth <= cellWidth : _usedWidth <= cellWidth;
|
||||
@@ -499,7 +499,7 @@ void FontBuffer::_packAndCenterBitPatterns() noexcept
|
||||
// that are required.
|
||||
for (size_t srcLine = 0, dstLine = 0; srcLine < _buffer.size(); srcLine++)
|
||||
{
|
||||
if (gsl::narrow_cast<til::CoordType>(srcLine % MAX_HEIGHT) < _fullHeight)
|
||||
if (gsl::narrow_cast<VTInt>(srcLine % MAX_HEIGHT) < _fullHeight)
|
||||
{
|
||||
auto characterScanline = til::at(_buffer, srcLine);
|
||||
characterScanline &= textClippingMask;
|
||||
@@ -515,7 +515,7 @@ void FontBuffer::_fillUnusedCharacters()
|
||||
// with an error glyph (a reverse question mark). This includes every
|
||||
// character prior to the start char, or after the last char.
|
||||
const auto errorPattern = _generateErrorGlyph();
|
||||
for (til::CoordType ch = 0; ch < MAX_CHARS; ch++)
|
||||
for (VTInt ch = 0; ch < MAX_CHARS; ch++)
|
||||
{
|
||||
if (ch < _startChar || ch > _lastChar)
|
||||
{
|
||||
|
||||
@@ -32,22 +32,22 @@ namespace Microsoft::Console::VirtualTerminal
|
||||
|
||||
gsl::span<const uint16_t> GetBitPattern() const noexcept;
|
||||
til::size GetCellSize() const noexcept;
|
||||
til::CoordType GetTextCenteringHint() const noexcept;
|
||||
size_t GetTextCenteringHint() const noexcept;
|
||||
VTID GetDesignation() const noexcept;
|
||||
|
||||
private:
|
||||
static constexpr til::CoordType MAX_WIDTH = 16;
|
||||
static constexpr til::CoordType MAX_HEIGHT = 32;
|
||||
static constexpr til::CoordType MAX_CHARS = 96;
|
||||
static constexpr VTInt MAX_WIDTH = 16;
|
||||
static constexpr VTInt MAX_HEIGHT = 32;
|
||||
static constexpr VTInt MAX_CHARS = 96;
|
||||
|
||||
void _buildCharsetId(const wchar_t ch);
|
||||
void _prepareCharacterBuffer();
|
||||
void _prepareNextCharacter();
|
||||
void _addSixelValue(const til::CoordType value) noexcept;
|
||||
void _addSixelValue(const VTInt value) noexcept;
|
||||
void _endOfSixelLine();
|
||||
void _endOfCharacter();
|
||||
|
||||
std::tuple<til::CoordType, til::CoordType, til::CoordType> _calculateDimensions() const;
|
||||
std::tuple<VTInt, VTInt, VTInt> _calculateDimensions() const;
|
||||
void _packAndCenterBitPatterns() noexcept;
|
||||
void _fillUnusedCharacters();
|
||||
std::array<uint16_t, MAX_HEIGHT> _generateErrorGlyph();
|
||||
@@ -57,22 +57,22 @@ namespace Microsoft::Console::VirtualTerminal
|
||||
VTInt _cellHeight;
|
||||
VTInt _pendingCellHeight;
|
||||
bool _sizeDeclaredAsMatrix;
|
||||
til::CoordType _declaredWidth;
|
||||
til::CoordType _declaredHeight;
|
||||
til::CoordType _usedWidth;
|
||||
til::CoordType _usedHeight;
|
||||
til::CoordType _fullWidth;
|
||||
til::CoordType _fullHeight;
|
||||
til::CoordType _textWidth;
|
||||
til::CoordType _textOffset;
|
||||
til::CoordType _textCenteringHint;
|
||||
VTInt _declaredWidth;
|
||||
VTInt _declaredHeight;
|
||||
VTInt _usedWidth;
|
||||
VTInt _usedHeight;
|
||||
VTInt _fullWidth;
|
||||
VTInt _fullHeight;
|
||||
VTInt _textWidth;
|
||||
VTInt _textOffset;
|
||||
size_t _textCenteringHint;
|
||||
|
||||
DispatchTypes::DrcsFontSet _fontSet;
|
||||
DispatchTypes::DrcsFontSet _pendingFontSet;
|
||||
DispatchTypes::DrcsFontUsage _fontUsage;
|
||||
DispatchTypes::DrcsFontUsage _pendingFontUsage;
|
||||
til::CoordType _linesPerPage;
|
||||
til::CoordType _columnsPerPage;
|
||||
VTInt _linesPerPage;
|
||||
VTInt _columnsPerPage;
|
||||
bool _isTextFont;
|
||||
|
||||
DispatchTypes::DrcsCharsetSize _charsetSize;
|
||||
@@ -81,15 +81,15 @@ namespace Microsoft::Console::VirtualTerminal
|
||||
VTID _pendingCharsetId{ 0 };
|
||||
bool _charsetIdInitialized;
|
||||
VTIDBuilder _charsetIdBuilder;
|
||||
til::CoordType _startChar;
|
||||
til::CoordType _lastChar;
|
||||
til::CoordType _currentChar;
|
||||
VTInt _startChar;
|
||||
VTInt _lastChar;
|
||||
VTInt _currentChar;
|
||||
|
||||
using buffer_type = std::array<uint16_t, MAX_HEIGHT * MAX_CHARS>;
|
||||
buffer_type _buffer;
|
||||
buffer_type::iterator _currentCharBuffer;
|
||||
bool _bufferCleared;
|
||||
til::CoordType _sixelColumn;
|
||||
til::CoordType _sixelRow;
|
||||
VTInt _sixelColumn;
|
||||
VTInt _sixelRow;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -735,7 +735,8 @@ bool InputStateMachineEngine::_WriteMouseEvent(const til::point uiPos, const DWO
|
||||
{
|
||||
INPUT_RECORD rgInput;
|
||||
rgInput.EventType = MOUSE_EVENT;
|
||||
rgInput.Event.MouseEvent.dwMousePosition = til::unwrap_coord(uiPos);
|
||||
rgInput.Event.MouseEvent.dwMousePosition.X = ::base::saturated_cast<short>(uiPos.x);
|
||||
rgInput.Event.MouseEvent.dwMousePosition.Y = ::base::saturated_cast<short>(uiPos.y);
|
||||
rgInput.Event.MouseEvent.dwButtonState = buttonState;
|
||||
rgInput.Event.MouseEvent.dwControlKeyState = controlKeyState;
|
||||
rgInput.Event.MouseEvent.dwEventFlags = eventFlags;
|
||||
|
||||
@@ -1779,10 +1779,10 @@ til::rect UiaTextRangeBase::_getTerminalRect() const
|
||||
}
|
||||
|
||||
return {
|
||||
static_cast<til::CoordType>(result.left),
|
||||
static_cast<til::CoordType>(result.top),
|
||||
static_cast<til::CoordType>(result.left + result.width),
|
||||
static_cast<til::CoordType>(result.top + result.height),
|
||||
gsl::narrow_cast<til::CoordType>(result.left),
|
||||
gsl::narrow_cast<til::CoordType>(result.top),
|
||||
gsl::narrow_cast<til::CoordType>(result.left + result.width),
|
||||
gsl::narrow_cast<til::CoordType>(result.top + result.height),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user