Oni: Persist window size from last session

Created on 15 May 2017  路  11Comments  路  Source: onivim/oni

I am able to maximize the windows by selecting "Maximize WIndows" from Command Palette but how can i set it default in the config file ?

enhancement

All 11 comments

Hi @HiCodin ,

Is the editor.fullScreenOnStart configuration property not working for you? I'm wondering if there has been a regression from the fix in #195

Also, did you build from source? Or download a release binary?

@extr0py ah I failed to properly specify my requirement. editor.fullScreenOnStart is working as intended. But What I meant for this request is that instead of choosing Maximize Window from the Command Palette every time I open Oni, is there a way to set it default or have Oni remembered the last opened window size ?

Ah thanks for the clarification, @HiCodin

Yes, I agree, having a way to persist some of this state (like window position) on close and then reopen would be very helpful. I'll keep this open to track that. We can start with just the window position & size. I also changed the title as well.

@extr0py Thanks ! is there anyway I can help you with ? Really liking this. :)

@HiCodin, if you're willing to implement this yourself and submit a Pull Request here are a couple pointers.

Implement it ourselves: https://github.com/electron/electron/issues/526
or
Use library: https://github.com/mawie81/electron-window-state (might be abandoned)

Note that we already have a config.js (look at Config.ts) which we could use to persist the size/position. Also, main.js (at the root of the project) is where the closed and window-all-closed events are handled, although our Config instance is only available from the Oni process main.js creates so you'd have to use events like 'rebuild-menu' to communicate with it. You can send events to Oni with mainWindow.webContents.send("<event name>", <args>) or send events to main.js with ipcRenderer.send("<event name>", <args>). Menu.js has examples of sending to Oni, browser/src/index.tsx has examples of sending to main.js. I'm guessing you'd want to send a reset-size event after the Config is done loading and send a save-size event during the close event.

@keforbes alright. I'll take a look at the things you mentioned. Thanks !

Great tips, @keforbes ! Thanks!

I was thinking about the config.js approach when I was looking at showing some notification UI for the language service providers - one challenge is that, with our current format (js), it might be difficult to write-back because it is unstructured.

  • Write-back to config.js - there'd be some interesting challenging issues here. It might be technically possible by parsing the AST and dropping in new config values, but I think this would be very difficult to get correct in general.
  • Use a separate json file (ie, like persisted.json) to store these persisted values. We could add an API like setPersistedValue("editor.windowDimensions")/getPersistedValue("editor.windowDimensions").
  • Use the localStorage API . This provides a convenient way to read/write to a key value dictionary, but would only be available in the BrowserWindow process. Otherwise, it'd be similiar to the above.

With regard to the editor.fullScreenOnStart option. It makes Oni "true" full screen instead of just maximized whereas I just really wanted it maximized.

Unless we really want to keep track of the dimensions from the last window opened we can close this issue.

@bryphe After option for maximization for Oni was merged, would we really want to keep track of the dimensions of the last window opened?

If not, this issue could be closed since @HiCodin's problem actually was maximization (same as mine).

@badosu , sounds good. I was thinking about having some potential configuration options persist, but we have #571 tracking that anyway. And as you mentioned this has a setting so isn't as pressing anymore. I'll go ahead and close it out, thanks for checking in!

Was this page helpful?
0 / 5 - 0 ratings