diff --git a/newton/main.js b/newton/main.js index cd2ce4d..b0f262f 100644 --- a/newton/main.js +++ b/newton/main.js @@ -65,6 +65,8 @@ const loadProcessSignalHandlers = () => { } const loadHandlers = () => { + ipcMain.handle('quit', (eve) => app.quit()); + ipcMain.handle('toggleFullScreen', (eve) => { window.setFullScreen(!window.isFullScreen()); }); ipcMain.handle('getLspConfigData', (eve) => newton.fs.getLspConfigData()); ipcMain.handle('getFileContents', (eve, path) => newton.fs.getFileContents(path)); ipcMain.handle('openFiles', (eve, startPath) => newton.fs.openFiles(startPath)); @@ -109,4 +111,3 @@ app.on('window-all-closed', () => { app.quit() }; }); - diff --git a/newton/preload.js b/newton/preload.js index 8940c92..f1c0764 100644 --- a/newton/preload.js +++ b/newton/preload.js @@ -9,6 +9,8 @@ contextBridge.exposeInMainWorld('electron', { contextBridge.exposeInMainWorld('main', { onMenuActions: (callback) => ipcRenderer.on('menu-actions', (_event, action) => callback(action)), + quit: () => ipcRenderer.invoke("quit"), + toggleFullScreen: () => ipcRenderer.invoke("toggleFullScreen"), }); contextBridge.exposeInMainWorld('fs', { diff --git a/src/app/common/configs/keybindings.config.ts b/src/app/common/configs/keybindings.config.ts index 2ca8a05..6c33f78 100644 --- a/src/app/common/configs/keybindings.config.ts +++ b/src/app/common/configs/keybindings.config.ts @@ -1,5 +1,13 @@ export const Keybindings: Array<{}> = [ { + name: "quit", + bindKey: {win: "Ctrl-q", mac: "Ctrl-q"}, + readOnly: false + }, { + name: "toggleFullScreen", + bindKey: {win: "F11", mac: "F11"}, + readOnly: false + }, { name: "showSettingsMenu", bindKey: {win: "Ctrl-Shift-m", mac: "Ctrl-Shift-m"}, readOnly: false diff --git a/src/app/editor/newton-editor/newton-editor.base.ts b/src/app/editor/newton-editor/newton-editor.base.ts index eaa9445..db4c92c 100644 --- a/src/app/editor/newton-editor/newton-editor.base.ts +++ b/src/app/editor/newton-editor/newton-editor.base.ts @@ -54,6 +54,14 @@ export class NewtonEditorBase { this.editor.session.destroy(); } + protected quit() { + window.main.quit(); + } + + protected toggleFullScreen() { + window.main.toggleFullScreen(); + } + protected openFiles() { let startDir = ""; if (this.activeFile) { diff --git a/src/polyfills.ts b/src/polyfills.ts index d04f1e9..e32ca37 100644 --- a/src/polyfills.ts +++ b/src/polyfills.ts @@ -20,6 +20,8 @@ declare global { }, main: { onMenuActions: (arg0: any) => Promise, + quit: any, + toggleFullScreen: any, }, fs: { getLspConfigData: () => Promise,