diff --git a/src/Store/CommandStoreConnector.re b/src/Store/CommandStoreConnector.re index 8f0643e7c6..6c9cf8e629 100644 --- a/src/Store/CommandStoreConnector.re +++ b/src/Store/CommandStoreConnector.re @@ -5,6 +5,13 @@ open Oni_Model.Actions; module KeyDisplayer = Oni_Components.KeyDisplayer; +module Constants = { + let zoomStep = 0.2; + let defaultZoomValue = 1.0; + let minZoomValue = 0.0; + let maxZoomValue = 2.8; +}; + let pathSymlinkEnabled = (~addingLink) => ( Revery.Environment.os == Revery.Environment.Mac @@ -265,6 +272,33 @@ let start = (getState, contributedCommands) => { }, ); + let zoomEffect = (state: State.t, getCalculatedZoomValue, _) => + Isolinear.Effect.createWithDispatch(~name="window.zoom", dispatch => { + let configuration = state.configuration; + let currentZoomValue = + Configuration.getValue(c => c.uiZoom, configuration); + + let calculatedZoomValue = getCalculatedZoomValue(currentZoomValue); + let newZoomValue = + Utility.IntEx.clamp( + calculatedZoomValue, + ~hi=Constants.maxZoomValue, + ~lo=Constants.minZoomValue, + ); + + if (newZoomValue != currentZoomValue) { + dispatch( + ConfigurationSet({ + ...configuration, + default: { + ...configuration.default, + uiZoom: newZoomValue, + }, + }), + ); + }; + }); + let commands = [ ("keyDisplayer.enable", _ => singleActionEffect(EnableKeyDisplayer)), ("keyDisplayer.disable", _ => singleActionEffect(DisableKeyDisplayer)), @@ -399,6 +433,18 @@ let start = (getState, contributedCommands) => { ); }, ), + ( + "workbench.action.zoomIn", + state => zoomEffect(state, zoom => zoom +. Constants.zoomStep), + ), + ( + "workbench.action.zoomOut", + state => zoomEffect(state, zoom => zoom -. Constants.zoomStep), + ), + ( + "workbench.action.zoomReset", + state => zoomEffect(state, _zoom => Constants.defaultZoomValue), + ), ]; let commandMap = diff --git a/src/Store/ConfigurationStoreConnector.re b/src/Store/ConfigurationStoreConnector.re index a392b83525..c8ce0c3ec2 100644 --- a/src/Store/ConfigurationStoreConnector.re +++ b/src/Store/ConfigurationStoreConnector.re @@ -131,8 +131,7 @@ let start = let vsync = ref(Revery.Vsync.Immediate); let synchronizeConfigurationEffect = configuration => Isolinear.Effect.create(~name="configuration.synchronize", () => { - let zoomValue = - max(1.0, Configuration.getValue(c => c.uiZoom, configuration)); + let zoomValue = Configuration.getValue(c => c.uiZoom, configuration); if (zoomValue != zoom^) { Log.infof(m => m("Setting zoom: %f", zoomValue)); setZoom(zoomValue); diff --git a/src/Store/KeyBindingsStoreConnector.re b/src/Store/KeyBindingsStoreConnector.re index cb2a702b6c..a7f279af41 100644 --- a/src/Store/KeyBindingsStoreConnector.re +++ b/src/Store/KeyBindingsStoreConnector.re @@ -259,6 +259,36 @@ let start = maybeKeyBindingsFilePath => { command: "workbench.action.previousEditor", condition: WhenExpr.Value(True), }, + { + key: "", + command: "workbench.action.zoomIn", + condition: WhenExpr.Value(True), + }, + { + key: "", + command: "workbench.action.zoomIn", + condition: WhenExpr.Value(True), + }, + { + key: "", + command: "workbench.action.zoomOut", + condition: WhenExpr.Value(True), + }, + { + key: "", + command: "workbench.action.zoomOut", + condition: WhenExpr.Value(True), + }, + { + key: "", + command: "workbench.action.zoomReset", + condition: WhenExpr.Value(True), + }, + { + key: "", + command: "workbench.action.zoomReset", + condition: WhenExpr.Value(True), + }, // TERMINAL // Binding to open normal mode {