mirror of
https://github.com/microsoft/terminal.git
synced 2026-05-18 01:39:55 +00:00
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -172,6 +172,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
|
||||
int ScrollOffset();
|
||||
int ViewHeight() const;
|
||||
int ViewWidth() const;
|
||||
int BufferHeight() const;
|
||||
|
||||
bool HasSelection() const;
|
||||
|
||||
@@ -2456,6 +2456,46 @@ 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);
|
||||
|
||||
if (!_resizeOverlayTimer)
|
||||
{
|
||||
_resizeOverlayTimer.emplace();
|
||||
_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:
|
||||
|
||||
@@ -316,6 +316,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
winrt::hstring _restorePath;
|
||||
bool _showMarksInScrollbar{ false };
|
||||
|
||||
std::optional<SafeDispatcherTimer> _resizeOverlayTimer;
|
||||
void _ShowResizeOverlay();
|
||||
|
||||
bool _isBackgroundLight{ false };
|
||||
bool _detached{ false };
|
||||
til::CoordType _searchScrollOffset = 0;
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user