@@ -45,7 +45,6 @@ let browser;
45
45
//app.on is a start of the main process that controls the lifecycle events
46
46
//Fires once when app is ready..
47
47
app . on ( 'ready' , ( ) => {
48
- createApplicationMenu ( ) ;
49
48
createWindow ( ) ;
50
49
} ) ;
51
50
@@ -133,14 +132,12 @@ const createWindow = (exports.createWindow = () => {
133
132
// let watcher;
134
133
135
134
//show window by calling the listener once
136
- newWindow . once ( 'ready-to-show' , ( ) => {
135
+ newWindow . on ( 'ready-to-show' , ( ) => {
137
136
newWindow . show ( ) ;
138
137
} ) ;
139
-
140
138
newWindow . on ( 'focus' , createApplicationMenu ) ;
141
139
142
140
//save changes dialog modal message
143
-
144
141
newWindow . on ( 'close' , ( event ) => {
145
142
if ( newWindow . isDocumentEdited ( ) ) {
146
143
event . preventDefault ( ) ;
@@ -161,56 +158,58 @@ const createWindow = (exports.createWindow = () => {
161
158
newWindow . on ( 'closed' , ( ) => {
162
159
windows . delete ( newWindow ) ;
163
160
createApplicationMenu ( ) ;
164
- // ptyProcess = null;
165
161
newWindow = null ;
166
162
} ) ;
163
+ windows . add ( newWindow ) ;
167
164
168
- var shell = os . platform ( ) === 'win32' ? 'powershell.exe' : 'zsh' ;
165
+ } ) ;
169
166
170
- // this spawns the terminal window space
171
- var ptyProcess = pty . spawn ( shell , [ ] , {
172
- name : 'xterm-color' ,
173
- cols : 80 ,
174
- rows : 24 ,
175
- cwd : process . env . HOME ,
176
- // cwd: cwdFilePath,
177
- env : process . env ,
178
- } ) ;
167
+ /*
168
+ * Below code (shell and ptyProcess) was previously inside createWindow fxn but
169
+ * was causing issues w/ re-activation. Moving it outside of the fxn below
170
+ * allows re-activation app but still not perfect implementation
171
+ */
172
+ const shell = os . platform ( ) === 'win32' ? 'powershell.exe' : 'zsh' ;
173
+ // this spawns the terminal window space
174
+ const ptyProcess = pty . spawn ( shell , [ ] , {
175
+ name : 'xterm-color' ,
176
+ cols : 80 ,
177
+ rows : 24 ,
178
+ cwd : process . env . HOME ,
179
+ // cwd: cwdFilePath,
180
+ env : process . env ,
181
+ } ) ;
179
182
180
- //2022-ST-AJ sends to renderer cwd for it to display on prompt
181
- // ipcMain.on('cwd', (event, data) => {
182
- // event.reply('cwdreply', process.env.PWD);
183
- // });
183
+ //2022-ST-AJ sends to renderer cwd for it to display on prompt
184
+ // ipcMain.on('cwd', (event, data) => {
185
+ // event.reply('cwdreply', process.env.PWD);
186
+ // });
184
187
185
- // add ipc listen for open folder and reassign ptyProcess.cwd to actual cwd
186
- ipcMain . on ( 'openFolder' , ( event , data ) => {
187
- ptyProcess . cwd = cwdFilePath [ 0 ] ;
188
- } ) ;
189
-
190
- //2022-ST-AJ node-pty listens to data and send whatever it receives back to xterm to render
191
- ptyProcess . onData ( ( data ) => {
192
- newWindow . webContents . send ( 'terminal-incData' , data ) ;
193
- } ) ;
188
+ // add ipc listen for open folder and reassign ptyProcess.cwd to actual cwd
189
+ ipcMain . on ( 'openFolder' , ( event , data ) => {
190
+ ptyProcess . cwd = cwdFilePath [ 0 ] ;
191
+ } ) ;
194
192
195
- //2022-ST-AJ ipcMain listens on data passed from xterm to write to shell
196
- ipcMain . on ( 'terminal-into' , ( event , data ) => {
197
- ptyProcess . write ( data ) ;
198
- } ) ;
193
+ //2022-ST-AJ node-pty listens to data and send whatever it receives back to xterm to render
194
+ ptyProcess . onData ( ( data ) => {
195
+ newWindow . webContents . send ( 'terminal-incData' , data ) ;
196
+ } ) ;
199
197
200
- //2022-ST-AJ ipcMain listens to resizing event from renderer and calls resize on node-pty to align size between node-pty and xterm. They need to align otherwise there are wierd bugs everywhere.
201
- ipcMain . on ( 'terminal-resize' , ( event , size ) => {
202
- const cols = size . cols ;
203
- const rows = size . rows ;
204
- ptyProcess . resize ( cols , rows ) ;
205
- } ) ;
198
+ //2022-ST-AJ ipcMain listens on data passed from xterm to write to shell
199
+ ipcMain . on ( 'terminal-into' , ( event , data ) => {
200
+ ptyProcess . write ( data ) ;
201
+ } ) ;
206
202
207
- require ( 'electron-reload' ) ( __dirname , {
208
- electron : path . join ( __dirname , '../node_modules' , '.bin' , 'electron' ) ,
209
- awaitWriteFinish : true ,
210
- } ) ;
203
+ //2022-ST-AJ ipcMain listens to resizing event from renderer and calls resize on node-pty to align size between node-pty and xterm. They need to align otherwise there are wierd bugs everywhere.
204
+ ipcMain . on ( 'terminal-resize' , ( event , size ) => {
205
+ const cols = size . cols ;
206
+ const rows = size . rows ;
207
+ ptyProcess . resize ( cols , rows ) ;
208
+ } ) ;
211
209
212
- windows . add ( newWindow ) ;
213
- // return newWindow;
210
+ require ( 'electron-reload' ) ( __dirname , {
211
+ electron : path . join ( __dirname , '../node_modules' , '.bin' , 'electron' ) ,
212
+ awaitWriteFinish : true ,
214
213
} ) ;
215
214
216
215
/*
@@ -328,7 +327,7 @@ ipcMain.handle('decreaseFontSize', decreaseFontSize);
328
327
329
328
ipcMain . handle ( 'createProjectFromUser' , createProjectFromUser ) ;
330
329
331
- ipcMain . on ( 'openDebugAppWindow' , ( event , localhostToUse ) => {
330
+ ipcMain . on ( 'openDebugAppWindow' , ( event , localhostToUse ) => {
332
331
if ( localhostToUse . length === 4 || localhostToUse . length === 5 ) openBrowserWindow ( localhostToUse ) ;
333
332
} ) ;
334
333
0 commit comments