Skip to content
Open
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
11 changes: 11 additions & 0 deletions src/cascadia/TerminalControl/ControlCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalControl/ControlCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation

int ScrollOffset();
int ViewHeight() const;
int ViewWidth() const;
int BufferHeight() const;

bool HasSelection() const;
Expand Down
38 changes: 38 additions & 0 deletions src/cascadia/TerminalControl/TermControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2458,6 +2458,41 @@ namespace winrt::Microsoft::Terminal::Control::implementation
{
_automationPeer.UpdateControlBounds();
}

// 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<ControlCore>(_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:
Expand Down Expand Up @@ -3671,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*/,
Expand Down
3 changes: 3 additions & 0 deletions src/cascadia/TerminalControl/TermControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
winrt::hstring _restorePath;
bool _showMarksInScrollbar{ false };

SafeDispatcherTimer _resizeOverlayTimer;
void _ShowResizeOverlay();

bool _isBackgroundLight{ false };
bool _detached{ false };
til::CoordType _searchScrollOffset = 0;
Expand Down
18 changes: 18 additions & 0 deletions src/cascadia/TerminalControl/TermControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -1365,6 +1365,24 @@

</Grid>

<!-- Resize overlay: shows columns x rows when terminal is resized -->
<Border x:Name="ResizeOverlay"
Padding="16,8,16,8"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="{ThemeResource SystemControlBackgroundAltHighBrush}"
BorderBrush="{ThemeResource SystemAccentColor}"
BorderThickness="1"
CornerRadius="{ThemeResource OverlayCornerRadius}"
IsHitTestVisible="False"
Visibility="Collapsed">
<TextBlock x:Name="ResizeOverlayText"
FontSize="18"
FontWeight="SemiBold"
Foreground="{ThemeResource SystemControlForegroundBaseHighBrush}"
TextAlignment="Center" />
</Border>

<Grid x:Name="RendererFailedNotice"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Expand Down
Loading