Skip to content

Commit a04e410

Browse files
authored
feat: add option to enable zoom with ctrl + scroll (#19127)
This PR adds a new global setting `scrollToZoom` that allows users to enable font zooming with scrolling. When disabled, **this setting prevents accidental font size changes** that can occur when users scroll while holding the Ctrl key. Note: after disabling this setting, users may still change font size using `Ctrl+` and `Ctrl-` keyboard shortcuts. Other Ctrl+Scroll functionality (like transparency adjustments) remains unaffected. ## Validation Steps Performed - Verified the setting can be toggled in the Settings UI (Interaction tab) - Confirmed that when disabled, holding Ctrl and scrolling no longer changes font size - Validated that the setting persists across terminal restarts --- Note: I used the existing `FocusFollowMouse` setting as a reference for implementing this. Closes #11710 Closes #3793 Closes #11906 Closes #3990
1 parent 7b84162 commit a04e410

12 files changed

Lines changed: 24 additions & 1 deletion

File tree

doc/cascadia/profiles.schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2376,6 +2376,11 @@
23762376
"description": "When set to true, the terminal will focus the pane on mouse hover.",
23772377
"type": "boolean"
23782378
},
2379+
"experimental.scrollToZoom": {
2380+
"default": true,
2381+
"description": "When set to true, holding the Ctrl key while scrolling will increase or decrease the terminal font size.",
2382+
"type": "boolean"
2383+
},
23792384
"compatibility.allowHeadless": {
23802385
"default": false,
23812386
"description": "When set to true, Windows Terminal will run in the background. This allows globalSummon and quakeMode actions to work even when no windows are open.",

src/cascadia/TerminalControl/ControlInteractivity.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
519519
{
520520
_mouseTransparencyHandler(delta);
521521
}
522-
else if (ctrlPressed)
522+
else if (ctrlPressed && _core->Settings().ScrollToZoom())
523523
{
524524
_mouseZoomHandler(delta);
525525
}

src/cascadia/TerminalControl/IControlSettings.idl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ namespace Microsoft.Terminal.Control
6060
Boolean CopyOnSelect { get; };
6161
Microsoft.Terminal.Control.CopyFormat CopyFormatting { get; };
6262
Boolean FocusFollowMouse { get; };
63+
Boolean ScrollToZoom { get; };
6364

6465
String Commandline { get; };
6566
String StartingDirectory { get; };

src/cascadia/TerminalSettingsEditor/Interaction.xaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@
8383
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
8484
</local:SettingContainer>
8585

86+
<!-- Enable Font Size Changes with Scrolling -->
87+
<local:SettingContainer x:Uid="Globals_ScrollToZoom">
88+
<ToggleSwitch IsOn="{x:Bind ViewModel.ScrollToZoom, Mode=TwoWay}"
89+
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
90+
</local:SettingContainer>
91+
8692
<!-- Detect URLs -->
8793
<local:SettingContainer x:Uid="Globals_DetectURLs">
8894
<ToggleSwitch IsOn="{x:Bind ViewModel.DetectURLs, Mode=TwoWay}"

src/cascadia/TerminalSettingsEditor/InteractionViewModel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
2525
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, TrimPaste);
2626
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, SnapToGridOnResize);
2727
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, FocusFollowMouse);
28+
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, ScrollToZoom);
2829
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, DetectURLs);
2930
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, SearchWebDefaultQueryUrl);
3031
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, WordDelimiters);

src/cascadia/TerminalSettingsEditor/InteractionViewModel.idl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ namespace Microsoft.Terminal.Settings.Editor
2222
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, TrimPaste);
2323
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, SnapToGridOnResize);
2424
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, FocusFollowMouse);
25+
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, ScrollToZoom);
2526
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, DetectURLs);
2627
PERMANENT_OBSERVABLE_PROJECTED_SETTING(String, SearchWebDefaultQueryUrl);
2728
PERMANENT_OBSERVABLE_PROJECTED_SETTING(String, WordDelimiters);

src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1736,6 +1736,10 @@
17361736
<value>Automatically focus pane on mouse hover</value>
17371737
<comment>Header for a control to toggle the "focus follow mouse" setting. When enabled, hovering over a pane puts it in focus.</comment>
17381738
</data>
1739+
<data name="Globals_ScrollToZoom.Header" xml:space="preserve">
1740+
<value>Adjust terminal font size by scrolling while holding the Ctrl key</value>
1741+
<comment>Header for a control to toggle font size changes with scrolling. When enabled, holding the Ctrl key while scrolling will increase or decrease the terminal font size.</comment>
1742+
</data>
17391743
<data name="Globals_DisableAnimationsReversed.Header" xml:space="preserve">
17401744
<value>Pane animations</value>
17411745
<comment>Header for a control to toggle animations on panes. "Enabled" value enables the animations.</comment>

src/cascadia/TerminalSettingsModel/GlobalAppSettings.idl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ namespace Microsoft.Terminal.Settings.Model
9090
INHERITABLE_SETTING(Boolean, DisableAnimations);
9191
INHERITABLE_SETTING(String, StartupActions);
9292
INHERITABLE_SETTING(Boolean, FocusFollowMouse);
93+
INHERITABLE_SETTING(Boolean, ScrollToZoom);
9394
INHERITABLE_SETTING(WindowingMode, WindowingBehavior);
9495
INHERITABLE_SETTING(Boolean, TrimBlockSelection);
9596
INHERITABLE_SETTING(Boolean, DetectURLs);

src/cascadia/TerminalSettingsModel/MTSMSettings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Author(s):
2424
X(hstring, WordDelimiters, "wordDelimiters", DEFAULT_WORD_DELIMITERS) \
2525
X(bool, CopyOnSelect, "copyOnSelect", false) \
2626
X(bool, FocusFollowMouse, "focusFollowMouse", false) \
27+
X(bool, ScrollToZoom, "experimental.scrollToZoom", true) \
2728
X(winrt::Microsoft::Terminal::Control::GraphicsAPI, GraphicsAPI, "rendering.graphicsAPI") \
2829
X(bool, DisablePartialInvalidation, "rendering.disablePartialInvalidation", false) \
2930
X(bool, SoftwareRendering, "rendering.software", false) \

src/cascadia/TerminalSettingsModel/TerminalSettings.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
367367
_CopyOnSelect = globalSettings.CopyOnSelect();
368368
_CopyFormatting = globalSettings.CopyFormatting();
369369
_FocusFollowMouse = globalSettings.FocusFollowMouse();
370+
_ScrollToZoom = globalSettings.ScrollToZoom();
370371
_GraphicsAPI = globalSettings.GraphicsAPI();
371372
_DisablePartialInvalidation = globalSettings.DisablePartialInvalidation();
372373
_SoftwareRendering = globalSettings.SoftwareRendering();

0 commit comments

Comments
 (0)