| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 var pty = require("pty.js"); |
| 6 |
| 7 function Terminal() { } |
| 8 |
| 9 Terminal.prototype = { |
| 10 setNotify: function(notify) |
| 11 { |
| 12 this._notify = notify; |
| 13 }, |
| 14 |
| 15 init: function(params) |
| 16 { |
| 17 this._term = pty.spawn(process.platform === "win32" ? "cmd.exe" : "bash"
, [], { |
| 18 name: "xterm-color", |
| 19 cols: params.cols || 80, |
| 20 rows: params.rows || 24, |
| 21 cwd: process.env.PWD, |
| 22 env: process.env |
| 23 }); |
| 24 |
| 25 this._term.on("data", data => { |
| 26 if (this._notify) |
| 27 this._notify("data", { data: data }); |
| 28 }); |
| 29 return Promise.resolve({}); |
| 30 }, |
| 31 |
| 32 resize: function(params) |
| 33 { |
| 34 this._term.resize(params.cols, params.rows); |
| 35 return Promise.resolve({}); |
| 36 }, |
| 37 |
| 38 write: function(params) |
| 39 { |
| 40 this._term.write(params.data); |
| 41 return Promise.resolve({}); |
| 42 }, |
| 43 |
| 44 dispose: function(params) |
| 45 { |
| 46 this._notify = null; |
| 47 if (this._term) |
| 48 process.kill(this._term.pid); |
| 49 return Promise.resolve({}); |
| 50 }, |
| 51 } |
| 52 |
| 53 exports.Terminal = Terminal; |
| OLD | NEW |