Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose EditorZoom (used by ctrl + mouse wheel) in api #196

Closed
samelhusseini opened this issue Sep 19, 2016 · 5 comments
Closed

Expose EditorZoom (used by ctrl + mouse wheel) in api #196

samelhusseini opened this issue Sep 19, 2016 · 5 comments
Assignees
Milestone

Comments

@samelhusseini
Copy link

Version 0.6.1 of the editor allows us to Ctrl+MouseScroll to zoom in/out.
Is there a way to programmatically zoom in the editor, so as to bind the keys (CtrlCmd + NUMPAD_ADD) with the editor zoom action?

Also, is there a way to get the current zoom level, so we can store it between sessions?

monaco-editor npm version: 0.6.1
Browser: Chrome
OS: Windows

@samelhusseini samelhusseini changed the title Is there a way to programmatically zoom in the editor? Is there a way to programmatically zoom the editor? Sep 19, 2016
@alexdima
Copy link
Member

ctrl + mouse scroll simply updates the fontSize option (leaving the lineHeight unconfigured, which means lineHeight will be computed based off fontSize). So you can simply call editor.updateOptions({ fontSize: newFontSize }) independent of ctrl + mouse scroll.

@alexdima alexdima added this to the Backlog milestone Sep 20, 2016
@alexdima alexdima self-assigned this Sep 20, 2016
@samelhusseini
Copy link
Author

Great! Would onDidLayoutChange be the best handler to store the font size when it is updated by a ctrl+scroll zoom in/out ?

@samelhusseini
Copy link
Author

I think there might be a bug here. If I zoom in using Ctrl+Scroll it updates the fontSize but does not reset the zoomLevel when I'm done, so if I then call updateOptions with a specific font size, it is multiplied by the zoomLevel in computeInternalOptions:
var editorZoomLevelMultiplier = 1 + (exports.EditorZoom.getZoomLevel() * 0.1);

Is there some way to reset the zoom level, that could be a possible workaround.

@alexdima
Copy link
Member

I'm sorry, at this time, there's no API exposed to EditorZoom.

@alexdima alexdima changed the title Is there a way to programmatically zoom the editor? Expose EditorZoom (used by ctrl + mouse wheel) in api Jun 7, 2017
@alexdima alexdima added editor-api feature-request Request for new features or functionality and removed question labels Jun 7, 2017
@martin-pabst
Copy link

@samelhusseini:
You can call
editor.trigger('keyboard', 'editor.action.fontZoomOut', {});
or
editor.trigger('keyboard', 'editor.action.fontZoomIn', {});
to programmatically zoom out/zoom in the editor.

@alexdima alexdima added question and removed feature-request Request for new features or functionality labels Dec 10, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants