├── README.md ├── index.js ├── index.html ├── package.json ├── main.js └── .gitignore /README.md: -------------------------------------------------------------------------------- 1 | # electron-local-terminal-prototype 2 | 3 | # Just a prototype... 4 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const ipc = require("electron").ipcRenderer; 2 | var term = new Terminal(); 3 | term.open(document.getElementById('terminal')); 4 | 5 | ipc.on("terminal.incomingData", (event, data) => { 6 | term.write(data); 7 | }); 8 | 9 | term.onData(e => { 10 | ipc.send("terminal.keystroke", e); 11 | }); -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | XTERM 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "shadowengineterminaltest", 3 | "version": "1.0.0", 4 | "description": "YES", 5 | "main": "main.js", 6 | "scripts": { 7 | "start": "electron .", 8 | "rebuild": "electron-rebuild" 9 | }, 10 | "author": "Vince Richter", 11 | "license": "MIT", 12 | "dependencies": { 13 | "electron-rebuild": "^1.11.0", 14 | "electron-tools": "^2.4.2", 15 | "node-pty": "^0.9.0", 16 | "xterm": "^4.8.1" 17 | }, 18 | "devDependencies": { 19 | "electron": "^9.2.0" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /main.js: -------------------------------------------------------------------------------- 1 | const {app, BrowserWindow, ipcMain} = require("electron"); 2 | const pty = require("node-pty"); 3 | const os = require("os"); 4 | var shell = os.platform() === "win32" ? "powershell.exe" : "bash"; 5 | 6 | let mainWindow; 7 | function createWindow() { 8 | mainWindow = new BrowserWindow({ 9 | height: 450, 10 | width: 800, 11 | webPreferences: { 12 | nodeIntegration: true 13 | } 14 | }); 15 | mainWindow.loadURL(`file://${__dirname}/index.html`); 16 | mainWindow.on("closed", function() { 17 | mainWindow = null; 18 | }); 19 | 20 | 21 | //ipcing 22 | 23 | var ptyProcess = pty.spawn(shell, [], { 24 | name: "xterm-color", 25 | cols: 80, 26 | rows: 30, 27 | cwd: process.env.HOME, 28 | env: process.env 29 | }); 30 | 31 | ptyProcess.on('data', function(data) { 32 | mainWindow.webContents.send("terminal.incomingData", data); 33 | console.log("Data sent"); 34 | }); 35 | ipcMain.on("terminal.keystroke", (event, key) => { 36 | ptyProcess.write(key); 37 | }); 38 | 39 | 40 | 41 | 42 | } 43 | 44 | app.on("ready", createWindow); 45 | 46 | app.on("window-all-closed", function() { 47 | if (process.platform !== "darwin") { 48 | app.quit(); 49 | } 50 | }); 51 | 52 | app.on("activate", function() { 53 | if (mainWindow === null) { 54 | createWindow(); 55 | } 56 | }); -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # Snowpack dependency directory (https://snowpack.dev/) 45 | web_modules/ 46 | 47 | # TypeScript cache 48 | *.tsbuildinfo 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Microbundle cache 57 | .rpt2_cache/ 58 | .rts2_cache_cjs/ 59 | .rts2_cache_es/ 60 | .rts2_cache_umd/ 61 | 62 | # Optional REPL history 63 | .node_repl_history 64 | 65 | # Output of 'npm pack' 66 | *.tgz 67 | 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | 71 | # dotenv environment variables file 72 | .env 73 | .env.test 74 | 75 | # parcel-bundler cache (https://parceljs.org/) 76 | .cache 77 | .parcel-cache 78 | 79 | # Next.js build output 80 | .next 81 | out 82 | 83 | # Nuxt.js build / generate output 84 | .nuxt 85 | dist 86 | 87 | # Gatsby files 88 | .cache/ 89 | # Comment in the public line in if your project uses Gatsby and not Next.js 90 | # https://nextjs.org/blog/next-9-1#public-directory-support 91 | # public 92 | 93 | # vuepress build output 94 | .vuepress/dist 95 | 96 | # Serverless directories 97 | .serverless/ 98 | 99 | # FuseBox cache 100 | .fusebox/ 101 | 102 | # DynamoDB Local files 103 | .dynamodb/ 104 | 105 | # TernJS port file 106 | .tern-port 107 | 108 | # Stores VSCode versions used for testing VSCode extensions 109 | .vscode-test 110 | 111 | # yarn v2 112 | .yarn/cache 113 | .yarn/unplugged 114 | .yarn/build-state.yml 115 | .yarn/install-state.gz 116 | .pnp.* --------------------------------------------------------------------------------