Oni: Add `window.zoomLevel` setting + default key bindings

Created on 31 Oct 2017  路  1Comment  路  Source: onivim/oni

An issue that was mentioned frequently in #837 is that it isn't easy currently to toggle zoom settings.

It'd be great to have an easy way to set this up. A few things we could add to make this easy:

  • A window.zoomLevel setting - this would use the setZoomFactor setting available on the WebContents object.
  • A window.zoom.increase (bound to <C-=> by default and window.zoom.decrease command bound to <C--> command.

Another issue is that it isn't easy today to programmatically set configuration values, outside of the initial read. I'd also propose adding the following items to the API surface:

Oni.configuration.setValue(propertyName: string, value: string, persist?: boolean)

This would allow for late-setting of properties, for example: Oni.configuration.setValue("window.zoomLevel", 2.0).

The most interesting property is the persist flag, which, if set, would be stored to localStorage (or a persisted file), so that it could persist between sessions. Use cases for this would be storing things like window size, open folder, etc. It's not straightforward to write-back to our configuration file as-is (since it is js and not json) - but we still want to be able to persist some of these settings.

The downside to persisting values outside of config.js is that it isn't transparent to the user what values are set, and this could be confusing and a source of issues - it'd be nice to be able to see/edit those as well.

enhancement

Most helpful comment

Also FYI @CrossR and @TalAmuyal - if you want a quick way to adjust the zoom factor while this is pending, you can add these in the activate section of your config.js:

const activate = (oni) => {
...
// Set zoom factor to 2 when Control+= is pressed
oni.input.bind("<C-=>", () => require("electron").remote.getCurrentWindow().webContents.setZoomFactor(2))

// Set zoom factor to 1 when Control+- is pressed
oni.input.bind("<C-->", () => require("electron").remote.getCurrentWindow().webContents.setZoomFactor(1))
...
}

Luckily Electron has an API for this already - we really just need to plumb it through (and think about the persistence model for our configuration settings).

>All comments

Also FYI @CrossR and @TalAmuyal - if you want a quick way to adjust the zoom factor while this is pending, you can add these in the activate section of your config.js:

const activate = (oni) => {
...
// Set zoom factor to 2 when Control+= is pressed
oni.input.bind("<C-=>", () => require("electron").remote.getCurrentWindow().webContents.setZoomFactor(2))

// Set zoom factor to 1 when Control+- is pressed
oni.input.bind("<C-->", () => require("electron").remote.getCurrentWindow().webContents.setZoomFactor(1))
...
}

Luckily Electron has an API for this already - we really just need to plumb it through (and think about the persistence model for our configuration settings).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TalAmuyal picture TalAmuyal  路  3Comments

bryphe picture bryphe  路  3Comments

Siilwyn picture Siilwyn  路  3Comments

akinsho picture akinsho  路  3Comments

timeyyy picture timeyyy  路  3Comments