From a57f4aadccc317078bf766fc5bdb7c7db2efd3a6 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Tue, 7 Jul 2015 21:36:25 -0600 Subject: [PATCH] * Trying to figure out environment issue... --- core/art.js | 1 - core/multi_line_edit_text_view.js | 1 + core/servers/telnet.js | 55 +++++++++++++++++++++---------- 3 files changed, 39 insertions(+), 18 deletions(-) diff --git a/core/art.js b/core/art.js index 8e7ec768..01737ffa 100644 --- a/core/art.js +++ b/core/art.js @@ -555,5 +555,4 @@ function display(options, cb) { parser.reset(options.art); parser.parse(); - //parser.parse(options.art); } \ No newline at end of file diff --git a/core/multi_line_edit_text_view.js b/core/multi_line_edit_text_view.js index 1ff90adb..5c2b0a32 100644 --- a/core/multi_line_edit_text_view.js +++ b/core/multi_line_edit_text_view.js @@ -103,6 +103,7 @@ function MultiLineEditTextView(options) { this.textLines = []; this.topVisibleIndex = 0; + this.mode = options.mode || 'edit'; // edit | preview // // cursorPos represents zero-based row, col positions diff --git a/core/servers/telnet.js b/core/servers/telnet.js index 3c161d8f..a6c7e4e1 100644 --- a/core/servers/telnet.js +++ b/core/servers/telnet.js @@ -428,6 +428,7 @@ function TelnetClient(input, output) { this.didReady = false; // have we emit the 'ready' event? this.input.on('data', function onData(b) { + console.log(b) bufs.push(b); var i; @@ -508,7 +509,7 @@ TelnetClient.prototype.handleWillCommand = function(evt) { // See RFC 1091 @ http://www.faqs.org/rfcs/rfc1091.html // this.requestTerminalType(); - } else if('environment variables' === evt.option) { + } else if('new environment' === evt.option) { // // See RFC 1572 @ http://www.faqs.org/rfcs/rfc1572.html // @@ -659,25 +660,45 @@ TelnetClient.prototype.requestTerminalType = function() { SB_COMMANDS.SEND, COMMANDS.IAC, COMMANDS.SE ]); - return this.output.write(buf); + this.output.write(buf); }; -var WANTED_ENVIRONMENT_VARIABLES = [ 'LINES', 'COLUMNS', 'TERM', 'TERM_PROGRAM' ]; +//var WANTED_ENVIRONMENT_VARIABLES = [ 'LINES', 'COLUMNS', 'TERM', 'TERM_PROGRAM' ]; +var WANTED_ENVIRONMENT_VAR_BUFS = [ + new Buffer( 'LINES' ), + new Buffer( 'COLUMNS' ), + new Buffer( 'TERM' ), + new Buffer( 'TERM_PROGRAM' ) +]; TelnetClient.prototype.requestEnvironmentVariables = function() { - var bufs = buffers(); - - bufs.push(new Buffer([ COMMANDS.IAC, COMMANDS.SB, OPTIONS.NEW_ENVIRONMENT, SB_COMMANDS.SEND ])); + return; + // :TODO: This is broken. I think we just need to wait for supress go-ahead/etc. before doing this? - for(var i = 0; i < WANTED_ENVIRONMENT_VARIABLES.length; ++i) { - //bufs.push(new Buffer( [ ENVIRONMENT_VARIABLES_COMMANDS.VAR ])); - bufs.push(new Buffer( [ NEW_ENVIRONMENT_COMMANDS.VAR ] )); - bufs.push(new Buffer(WANTED_ENVIRONMENT_VARIABLES[i])); // :TODO: encoding here?! UTF-8 will work, but shoudl be more explicit + var self = this; + + console.log('requesting environment...') + var bufs = buffers(); + bufs.push(new Buffer( [ + COMMANDS.IAC, + COMMANDS.SB, + OPTIONS.NEW_ENVIRONMENT, + SB_COMMANDS.SEND ] + )); + + for(var i = 0; i < WANTED_ENVIRONMENT_VAR_BUFS.length; ++i) { + bufs.push(new Buffer( [ NEW_ENVIRONMENT_COMMANDS.VAR ] ), WANTED_ENVIRONMENT_VAR_BUFS[i] ); } bufs.push(new Buffer([ COMMANDS.IAC, COMMANDS.SE ])); - return this.output.write(bufs.toBuffer()); + var out = bufs.toBuffer(); + console.log('out=') + console.log(out) + console.log('---') + + self.output.write(bufs.toBuffer()); + }; TelnetClient.prototype.banner = function() { @@ -714,19 +735,19 @@ Object.keys(OPTIONS).forEach(function(name) { buf[1] = this.command; buf[2] = code; return this.client.output.write(buf); - } + }; }); // Create do, dont, etc. methods on Client ['do', 'dont', 'will', 'wont'].forEach(function(command) { - function get() { + var get = function() { return new Command(command, this); - } + }; Object.defineProperty(TelnetClient.prototype, command, { - get : get, - enumerable : true, - configurable : true + get : get, + enumerable : true, + configurable : true }); });