@@ -3,6 +3,8 @@ const { contextBridge, ipcRenderer } = require('electron')
33const path = require ( 'path' )
44
55const MicroPython = require ( 'micropython.js' )
6+ const { emit, platform } = require ( 'process' )
7+ // const { platform } = requireprocess.platform
68const board = new MicroPython ( )
79board . chunk_size = 192
810board . chunk_sleep = 200
@@ -155,12 +157,31 @@ const Window = {
155157 setWindowSize : ( minWidth , minHeight ) => {
156158 ipcRenderer . invoke ( 'set-window-size' , minWidth , minHeight )
157159 } ,
160+ anyShortcut : ( callback , key ) => {
161+ ipcRenderer . on ( 'shortcut-cmd' , ( event , k ) => {
162+ // Get the active element
163+ const activeElement = document . activeElement ;
164+ // Check if the active element is the terminal
165+ const isTerminalFocused = activeElement . classList . contains ( 'xterm-helper-textarea' ) ;
166+ // Only trigger callback if terminal is not focused AND we're in editor view
167+ if ( ! isTerminalFocused ) {
168+ console . log ( 'shortcut-cmd-r executed' )
169+ callback ( k ) ;
170+ }
171+ } )
172+ } ,
173+
174+
158175 beforeClose : ( callback ) => ipcRenderer . on ( 'check-before-close' , callback ) ,
159176 confirmClose : ( ) => ipcRenderer . invoke ( 'confirm-close' ) ,
160177 isPackaged : ( ) => ipcRenderer . invoke ( 'is-packaged' ) ,
161- openDialog : ( opt ) => ipcRenderer . invoke ( 'open-dialog' , opt )
162- }
178+ openDialog : ( opt ) => ipcRenderer . invoke ( 'open-dialog' , opt ) ,
163179
180+ getOS : ( ) => platform ,
181+ isWindows : ( ) => platform === 'win32' ,
182+ isMac : ( ) => platform === 'darwin' ,
183+ isLinux : ( ) => platform === 'linux'
184+ }
164185
165186contextBridge . exposeInMainWorld ( 'BridgeSerial' , Serial )
166187contextBridge . exposeInMainWorld ( 'BridgeDisk' , Disk )
0 commit comments