Permalink
Browse files

connection: allow user to pass in window settings

  • Loading branch information...
1 parent 43a20be commit cc7e289e5f1a696c16c82440bab9b10698d3b6e8 @mscdex mscdex committed Nov 11, 2012
Showing with 21 additions and 6 deletions.
  1. +2 −2 lib/Channel.js
  2. +19 −4 lib/Connection.js
View
@@ -180,12 +180,12 @@ Channel.prototype._sendTermSizeChg = function(cols, rows, width, height, go) {
return true;
};
-Channel.prototype._sendPtyReq = function(cols, rows, width, height, term, modes,
+Channel.prototype._sendPtyReq = function(rows, cols, height, width, term, modes,
cb, go) {
if (!this._conn._sock.writable)
return null;
else if (!go && this._conn._state !== 'authenticated') {
- this._enqueue(['_sendPtyReq', cols, rows, width, height, term, modes, cb]);
+ this._enqueue(['_sendPtyReq', rows, cols, height, width, term, modes, cb]);
return false;
}
// Note: CHANNEL_REQUEST does not consume window space
View
@@ -844,13 +844,28 @@ Connection.prototype.exec = function(cmd, env, cb) {
this._openChan(localChan);
};
-Connection.prototype.shell = function(cb) {
+Connection.prototype.shell = function(window, cb) {
// TODO: buffer the outgoing CHANNEL_OPEN message if doing key (re-)exchange
- var self = this;
- var localChan = this._nextChan();
+ var self = this,
+ localChan = this._nextChan(),
+ rows = 24, cols = 80, width = 640, height = 480, term = 'vt100';
this._channels.push(localChan);
+ if (typeof window === 'object') {
+ if (typeof window.rows === 'number')
+ rows = window.rows;
+ if (typeof window.cols === 'number')
+ cols = window.cols;
+ if (typeof window.width === 'number')
+ width = window.width;
+ if (typeof window.height === 'number')
+ height = window.height;
+ if (typeof window.term === 'number')
+ term = window.term;
+ } else if (typeof window === 'function')
+ cb = window;
+
this._parser.once('CHANNEL_OPEN_CONFIRMATION:' + localChan, function(info) {
self._parser.removeAllListeners('CHANNEL_OPEN_FAILURE:' + localChan);
var chaninfo = {
@@ -869,7 +884,7 @@ Connection.prototype.shell = function(cb) {
}
};
var chan = new Channel(chaninfo, self);
- chan._sendPtyReq(80, 24, 640, 480, 'vt100', null, function(err) {
+ chan._sendPtyReq(rows, cols, height, width, term, null, function(err) {
if (err)
cb(err);
else

0 comments on commit cc7e289

Please sign in to comment.