| 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(notify) |
| 8 { |
| 9 this._notify = notify; |
| 10 } |
| 11 |
| 12 Terminal.prototype = { |
| 13 init: function(params) |
| 14 { |
| 15 this._term = pty.spawn(process.platform === "win32" ? "cmd.exe" : "bash"
, [], { |
| 16 name: "xterm-color", |
| 17 cols: params.cols || 80, |
| 18 rows: params.rows || 24, |
| 19 cwd: process.env.PWD, |
| 20 env: process.env |
| 21 }); |
| 22 |
| 23 this._term.on("data", data => { |
| 24 if (this._notify) |
| 25 this._notify("data", { data: data }); |
| 26 }); |
| 27 return Promise.resolve({}); |
| 28 }, |
| 29 |
| 30 resize: function(params) |
| 31 { |
| 32 if (this._term) |
| 33 this._term.resize(params.cols, params.rows); |
| 34 return Promise.resolve({}); |
| 35 }, |
| 36 |
| 37 write: function(params) |
| 38 { |
| 39 this._term.write(params.data); |
| 40 return Promise.resolve({}); |
| 41 }, |
| 42 |
| 43 dispose: function(params) |
| 44 { |
| 45 this._notify = null; |
| 46 if (this._term) |
| 47 process.kill(this._term.pid); |
| 48 return Promise.resolve({}); |
| 49 }, |
| 50 } |
| 51 |
| 52 exports.Terminal = Terminal; |
| OLD | NEW |