Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mariano/838e517c8ce4308627fef9c85d9918da to your computer and use it in GitHub Desktop.
Save mariano/838e517c8ce4308627fef9c85d9918da to your computer and use it in GitHub Desktop.
Add profile setting `disableMouseWheelZoom` to disable zooming while hitting CTRL and using mouse wheel, performing a normal scroll if setting enabled
diff --git a/src/cascadia/TerminalApp/Profile.cpp b/src/cascadia/TerminalApp/Profile.cpp
index 7cd80a65..0c815b29 100644
--- a/src/cascadia/TerminalApp/Profile.cpp
+++ b/src/cascadia/TerminalApp/Profile.cpp
@@ -53,6 +53,8 @@ static constexpr std::string_view BackgroundImageAlignmentKey{ "backgroundImageA
static constexpr std::string_view RetroTerminalEffectKey{ "experimental.retroTerminalEffect" };
static constexpr std::string_view AntialiasingModeKey{ "antialiasingMode" };
+static constexpr std::string_view DisableMouseWheelZoomKey{ "disableMouseWheelZoom" };
+
Profile::Profile() :
Profile(std::nullopt)
{
@@ -93,7 +95,9 @@ Profile::Profile(const std::optional<GUID>& guid) :
_backgroundImageStretchMode{},
_backgroundImageAlignment{},
_retroTerminalEffect{},
- _antialiasingMode{ TextAntialiasingMode::Grayscale }
+ _antialiasingMode{ TextAntialiasingMode::Grayscale },
+
+ _disableMouseWheelZoom{false}
{
winrt::Windows::UI::Text::FontWeight weight;
weight.Weight = DEFAULT_FONT_WEIGHT;
@@ -229,6 +233,11 @@ TerminalSettings Profile::CreateTerminalSettings(const std::unordered_map<std::w
terminalSettings.RetroTerminalEffect(_retroTerminalEffect.value());
}
+ if (_disableMouseWheelZoom)
+ {
+ terminalSettings.DisableMouseWheelZoom(_disableMouseWheelZoom.value());
+ }
+
terminalSettings.AntialiasingMode(_antialiasingMode);
return terminalSettings;
@@ -404,6 +413,8 @@ void Profile::LayerJson(const Json::Value& json)
JsonUtils::GetValueForKey(json, BackgroundImageAlignmentKey, _backgroundImageAlignment);
JsonUtils::GetValueForKey(json, RetroTerminalEffectKey, _retroTerminalEffect);
JsonUtils::GetValueForKey(json, AntialiasingModeKey, _antialiasingMode);
+
+ JsonUtils::GetValueForKey(json, DisableMouseWheelZoomKey, _disableMouseWheelZoom);
}
void Profile::SetFontFace(std::wstring fontFace) noexcept
diff --git a/src/cascadia/TerminalApp/Profile.h b/src/cascadia/TerminalApp/Profile.h
index 17edad98..1f42e374 100644
--- a/src/cascadia/TerminalApp/Profile.h
+++ b/src/cascadia/TerminalApp/Profile.h
@@ -151,4 +151,6 @@ private:
friend class TerminalAppUnitTests::DynamicProfileTests;
std::optional<bool> _retroTerminalEffect;
+
+ std::optional<bool> _disableMouseWheelZoom;
};
diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp
index 8838eb5d..8fc2c123 100644
--- a/src/cascadia/TerminalControl/TermControl.cpp
+++ b/src/cascadia/TerminalControl/TermControl.cpp
@@ -1374,7 +1374,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
{
_MouseTransparencyHandler(delta);
}
- else if (ctrlPressed)
+ else if (ctrlPressed && !_settings.DisableMouseWheelZoom())
{
_MouseZoomHandler(delta);
}
diff --git a/src/cascadia/TerminalSettings/IControlSettings.idl b/src/cascadia/TerminalSettings/IControlSettings.idl
index 47484d99..654aebf7 100644
--- a/src/cascadia/TerminalSettings/IControlSettings.idl
+++ b/src/cascadia/TerminalSettings/IControlSettings.idl
@@ -58,5 +58,7 @@ namespace Microsoft.Terminal.Settings
Boolean RetroTerminalEffect;
Boolean ForceFullRepaintRendering;
Boolean SoftwareRendering;
+
+ Boolean DisableMouseWheelZoom;
};
}
diff --git a/src/cascadia/TerminalSettings/terminalsettings.h b/src/cascadia/TerminalSettings/terminalsettings.h
index 1bd1aad9..aad940db 100644
--- a/src/cascadia/TerminalSettings/terminalsettings.h
+++ b/src/cascadia/TerminalSettings/terminalsettings.h
@@ -95,6 +95,8 @@ namespace winrt::Microsoft::Terminal::Settings::implementation
GETSET_PROPERTY(bool, SoftwareRendering, false);
GETSET_PROPERTY(bool, ForceVTInput, false);
+ GETSET_PROPERTY(bool, DisableMouseWheelZoom, false);
+
#pragma warning(pop)
private:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment