Skip to content

Commit 35c991f

Browse files
authored
Merge pull request #10 from dieunity/default-directory
Default directory & formatting changes
2 parents 8afd047 + 17b56eb commit 35c991f

File tree

5 files changed

+22
-13
lines changed

5 files changed

+22
-13
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"concurrently": "^4.1.2",
2828
"cross-env": "^5.2.1",
2929
"dotenv": "^8.2.0",
30+
"electron": "11.4.3",
3031
"electron-is-dev": "^1.1.0",
3132
"fibers": "^5.0.0",
3233
"js-beautify": "^1.10.0",
@@ -83,7 +84,6 @@
8384
"@typescript-eslint/parser": "^2.33.0",
8485
"chai": "^4.3.4",
8586
"chai-as-promised": "^7.1.1",
86-
"electron": "11.4.3",
8787
"electron-builder": "^22.6.1",
8888
"electron-devtools-installer": "^3.0.0",
8989
"electron-rebuild": "^2.3.5",

public/electron.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,12 @@ function createWindow() {
4949
cwd: process.env.HOME,
5050
env: process.env,
5151
});
52+
// with ptyProcess, we want to send incoming data to the channel terminal.incData
5253
ptyProcess.on('data', (data) => {
53-
// process.stdout.write(data);
5454
mainWindow.webContents.send('terminal.incData', data);
5555
});
56+
// in the main process, at terminal.toTerm channel, when data is received,
57+
// main process will write to ptyProcess
5658
ipcMain.on('terminal.toTerm', function(event, data) {
5759
ptyProcess.write(data);
5860
})

src/components/EditorView/EditorView.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ const Editor = () => {
5656
<div>
5757
<div onClick={() => setWasSaved('')}>
5858
<MonacoEditor
59-
height='80vh'
60-
language='javascript'
61-
theme='light-dark'
59+
height="80vh"
60+
language="javascript"
61+
theme="light-dark"
6262
value={
6363
file
6464
? extensionChecker[fileType]

src/components/OpenFolder/OpenFolderButton.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
} from '../../context/actions/globalActions';
1616
import { GlobalContext } from '../../context/reducers/globalReducer';
1717

18+
const ipc = require('electron').ipcRenderer;
1819
const folderOpenIcon = require('../../assets/images/folder-open.png');
1920

2021
const { remote } = window.require('electron');
@@ -36,17 +37,19 @@ const OpenFolder = () => {
3637
],
3738
message: 'Please select your project folder',
3839
});
39-
console.log(directory)
4040
if (directory && directory.filePaths[0]) {
4141
let directoryPath = directory.filePaths[0];
42-
//replace backslashes for Windows OS
42+
// replace backslashes for Windows OS
4343
directoryPath = directoryPath.replace(/\\/g, '/');
4444
dispatchToGlobal(setProjectFilePath(directoryPath));
4545
dispatchToGlobal(createFileTree(generateFileTreeObject(directoryPath)));
4646
dispatchToGlobal(loadProject('load'));
4747
dispatchToGlobal(setTestCase(''));
4848
if (!isTestModalOpen) dispatchToGlobal(toggleModal());
4949
if (!isFileDirectoryOpen) dispatchToGlobal(toggleFileDirectory());
50+
51+
// Re-direct terminal directory to user selected directory
52+
ipc.send('terminal.toTerm', `cd ${directoryPath}\n`);
5053
}
5154
};
5255

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { useEffect } from 'react';
22
import { XTerm } from 'xterm-for-react';
3+
34
const { Terminal } = require('xterm');
45
const ipc = require('electron').ipcRenderer;
56

@@ -9,23 +10,26 @@ const term = new Terminal({
910
rows: 30,
1011
fontFamily: 'monospace',
1112
theme: {
12-
background: '#002a36'
13-
}
13+
background: '#002a36',
14+
},
1415
});
1516

1617
const TerminalGenerator = () => {
1718
useEffect(() => {
19+
// console.log(global.projectFilePath);
1820
term.open(document.getElementsByClassName('terminal')[0]);
19-
term.onData(e => {
21+
// when we have input events (e), we would send the data to the main processor
22+
term.onData((e) => {
2023
ipc.send('terminal.toTerm', e);
2124
});
25+
// when incoming Data comes back to the main process, this ipc renderer
26+
// will take it and writes it to xterm monitor
2227
ipc.on('terminal.incData', (event, data) => {
2328
term.write(data);
2429
});
2530
}, []);
2631

27-
28-
return <XTerm className='terminal' />
29-
}
32+
return <XTerm className='terminal' />;
33+
};
3034

3135
export default TerminalGenerator;

0 commit comments

Comments
 (0)