@sussudio/platform
Version:
Internal APIs for VS Code's service injection the base services.
26 lines (25 loc) • 1.21 kB
JavaScript
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { getZoomLevel, setZoomFactor, setZoomLevel } from '@sussudio/base/browser/browser.mjs';
import { webFrame } from '@sussudio/base/parts/sandbox/electron-sandbox/globals.mjs';
import { zoomLevelToZoomFactor } from '../common/window.mjs';
/**
* Apply a zoom level to the window. Also sets it in our in-memory
* browser helper so that it can be accessed in non-electron layers.
*/
export function applyZoom(zoomLevel) {
webFrame.setZoomLevel(zoomLevel);
setZoomFactor(zoomLevelToZoomFactor(zoomLevel));
// Cannot be trusted because the webFrame might take some time
// until it really applies the new zoom level
// See https://github.com/microsoft/vscode/issues/26151
setZoomLevel(zoomLevel, false /* isTrusted */);
}
export function zoomIn() {
applyZoom(getZoomLevel() + 1);
}
export function zoomOut() {
applyZoom(getZoomLevel() - 1);
}