From c7a51c978ccc244d794e8ffccd64f156c47a1b19 Mon Sep 17 00:00:00 2001 From: sagarbhure-msft Date: Fri, 3 Apr 2026 20:30:09 +0530 Subject: [PATCH 1/4] Show terminal size overlay (COLSxROWS) during resize (#2833) Display a centered overlay showing columns x rows when the terminal control is resized. The overlay auto-hides after 750ms of inactivity. - Add ResizeOverlay Border element to TermControl.xaml - Add ViewWidth() to ControlCore (matches existing ViewHeight()) - Show overlay in _SwapChainSizeChanged using SafeDispatcherTimer - Use fmt::format for string formatting Closes #2833 --- src/cascadia/TerminalControl/ControlCore.cpp | 11 ++++++++++ src/cascadia/TerminalControl/ControlCore.h | 1 + src/cascadia/TerminalControl/TermControl.cpp | 20 +++++++++++++++++++ src/cascadia/TerminalControl/TermControl.h | 2 ++ src/cascadia/TerminalControl/TermControl.xaml | 18 +++++++++++++++++ 5 files changed, 52 insertions(+) diff --git a/src/cascadia/TerminalControl/ControlCore.cpp b/src/cascadia/TerminalControl/ControlCore.cpp index 7b9d05e5a3d..1890344f3f1 100644 --- a/src/cascadia/TerminalControl/ControlCore.cpp +++ b/src/cascadia/TerminalControl/ControlCore.cpp @@ -1580,6 +1580,17 @@ namespace winrt::Microsoft::Terminal::Control::implementation return _terminal->GetViewport().Height(); } + // Function Description: + // - Gets the width of the terminal in columns. This is just the + // width of the viewport. + // Return Value: + // - The width of the terminal in columns + int ControlCore::ViewWidth() const + { + const auto lock = _terminal->LockForReading(); + return _terminal->GetViewport().Width(); + } + // Function Description: // - Gets the height of the terminal in lines of text. This includes the // history AND the viewport. diff --git a/src/cascadia/TerminalControl/ControlCore.h b/src/cascadia/TerminalControl/ControlCore.h index e66d778f61e..858bef70535 100644 --- a/src/cascadia/TerminalControl/ControlCore.h +++ b/src/cascadia/TerminalControl/ControlCore.h @@ -172,6 +172,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation int ScrollOffset(); int ViewHeight() const; + int ViewWidth() const; int BufferHeight() const; bool HasSelection() const; diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index ced2d9e873f..012b27f91fb 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -2458,6 +2458,26 @@ namespace winrt::Microsoft::Terminal::Control::implementation { _automationPeer.UpdateControlBounds(); } + + // Show resize overlay with COLSxROWS + const auto coreImpl = winrt::get_self(_core); + const auto cols = coreImpl->ViewWidth(); + const auto rows = coreImpl->ViewHeight(); + if (cols > 0 && rows > 0) + { + ResizeOverlayText().Text(fmt::format(FMT_COMPILE(L"{} \u00D7 {}"), cols, rows)); + ResizeOverlay().Visibility(Visibility::Visible); + + _resizeOverlayTimer.Interval(std::chrono::milliseconds(750)); + _resizeOverlayTimer.Tick([weakThis = get_weak()](auto&&, auto&&) { + if (auto self = weakThis.get()) + { + self->ResizeOverlay().Visibility(Visibility::Collapsed); + self->_resizeOverlayTimer.Stop(); + } + }); + _resizeOverlayTimer.Start(); + } } // Method Description: diff --git a/src/cascadia/TerminalControl/TermControl.h b/src/cascadia/TerminalControl/TermControl.h index 767596e95a8..b27b56f64a6 100644 --- a/src/cascadia/TerminalControl/TermControl.h +++ b/src/cascadia/TerminalControl/TermControl.h @@ -316,6 +316,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation winrt::hstring _restorePath; bool _showMarksInScrollbar{ false }; + SafeDispatcherTimer _resizeOverlayTimer; + bool _isBackgroundLight{ false }; bool _detached{ false }; til::CoordType _searchScrollOffset = 0; diff --git a/src/cascadia/TerminalControl/TermControl.xaml b/src/cascadia/TerminalControl/TermControl.xaml index 6fa5e6aebbb..c14712091e2 100644 --- a/src/cascadia/TerminalControl/TermControl.xaml +++ b/src/cascadia/TerminalControl/TermControl.xaml @@ -1365,6 +1365,24 @@ + + + + + Date: Mon, 13 Apr 2026 22:33:04 +0530 Subject: [PATCH 2/4] Fix code formatting in TermControl.xaml Run Invoke-CodeFormat: reorder XAML attributes alphabetically and normalize comment spacing per project style. --- src/cascadia/TerminalControl/TermControl.xaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cascadia/TerminalControl/TermControl.xaml b/src/cascadia/TerminalControl/TermControl.xaml index c14712091e2..d5e89cd5920 100644 --- a/src/cascadia/TerminalControl/TermControl.xaml +++ b/src/cascadia/TerminalControl/TermControl.xaml @@ -1365,11 +1365,11 @@ - + Date: Mon, 13 Apr 2026 23:03:26 +0530 Subject: [PATCH 3/4] Fix spell-check: replace COLSxROWS with plain text in comments --- src/cascadia/TerminalControl/TermControl.cpp | 2 +- src/cascadia/TerminalControl/TermControl.xaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index 012b27f91fb..fbe76eef664 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -2459,7 +2459,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation _automationPeer.UpdateControlBounds(); } - // Show resize overlay with COLSxROWS + // Show resize overlay with columns x rows const auto coreImpl = winrt::get_self(_core); const auto cols = coreImpl->ViewWidth(); const auto rows = coreImpl->ViewHeight(); diff --git a/src/cascadia/TerminalControl/TermControl.xaml b/src/cascadia/TerminalControl/TermControl.xaml index d5e89cd5920..0d675816835 100644 --- a/src/cascadia/TerminalControl/TermControl.xaml +++ b/src/cascadia/TerminalControl/TermControl.xaml @@ -1365,7 +1365,7 @@ - + Date: Tue, 14 Apr 2026 09:20:10 +0530 Subject: [PATCH 4/4] Show overlay on font-size zoom, skip in Settings preview Show the resize overlay when Ctrl+Scroll changes font size and alters the grid dimensions. Extract overlay logic into _ShowResizeOverlay() helper called from both _SwapChainSizeChanged and _coreFontSizeChanged. Skip the overlay when the control is disabled (IsEnabled() == false), which is the case for the Settings page terminal preview. --- src/cascadia/TerminalControl/TermControl.cpp | 18 ++++++++++++++++++ src/cascadia/TerminalControl/TermControl.h | 1 + 2 files changed, 19 insertions(+) diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index fbe76eef664..a6097e74b9e 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -2460,6 +2460,21 @@ namespace winrt::Microsoft::Terminal::Control::implementation } // Show resize overlay with columns x rows + _ShowResizeOverlay(); + } + + // Method Description: + // - Shows a centered overlay with the current terminal dimensions (columns x rows). + // Used during window resize and font size changes. Skipped for disabled controls + // (e.g. the Settings preview terminal) to avoid visual noise. + void TermControl::_ShowResizeOverlay() + { + // Don't show the overlay in the Settings preview control + if (!IsEnabled()) + { + return; + } + const auto coreImpl = winrt::get_self(_core); const auto cols = coreImpl->ViewWidth(); const auto rows = coreImpl->ViewHeight(); @@ -3691,6 +3706,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation } _searchScrollOffset = _calculateSearchScrollOffset(); + + // Show resize overlay when font size change alters the grid dimensions + _ShowResizeOverlay(); } void TermControl::_coreRaisedNotice(const IInspectable& /*sender*/, diff --git a/src/cascadia/TerminalControl/TermControl.h b/src/cascadia/TerminalControl/TermControl.h index b27b56f64a6..143d454200a 100644 --- a/src/cascadia/TerminalControl/TermControl.h +++ b/src/cascadia/TerminalControl/TermControl.h @@ -317,6 +317,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation bool _showMarksInScrollbar{ false }; SafeDispatcherTimer _resizeOverlayTimer; + void _ShowResizeOverlay(); bool _isBackgroundLight{ false }; bool _detached{ false };