* Try to clean up terminal stuff set by doors @ exit

This commit is contained in:
Bryan Ashby 2016-06-20 21:38:43 -06:00
parent 97c2e7adc0
commit 8c06325e63
2 changed files with 18 additions and 6 deletions

View File

@ -2,7 +2,6 @@
'use strict'; 'use strict';
const events = require('events'); const events = require('events');
const _ = require('lodash'); const _ = require('lodash');
const pty = require('ptyw.js'); const pty = require('ptyw.js');
const decode = require('iconv-lite').decode; const decode = require('iconv-lite').decode;
@ -80,6 +79,10 @@ function Door(client, exeInfo) {
return cb(null); return cb(null);
} }
}; };
this.doorExited = function() {
self.emit('finished');
};
} }
require('util').inherits(Door, events.EventEmitter); require('util').inherits(Door, events.EventEmitter);
@ -90,7 +93,7 @@ Door.prototype.run = function() {
this.prepareSocketIoServer( (err, sockServer) => { this.prepareSocketIoServer( (err, sockServer) => {
if(err) { if(err) {
this.client.log.warn( { error : err.toString() }, 'Failed executing door'); this.client.log.warn( { error : err.toString() }, 'Failed executing door');
return self.emit('finished'); return self.doorExited();
} }
// Expand arg strings, e.g. {dropFile} -> DOOR32.SYS // Expand arg strings, e.g. {dropFile} -> DOOR32.SYS
@ -140,7 +143,7 @@ Door.prototype.run = function() {
door.removeAllListeners(); door.removeAllListeners();
self.emit('finished'); return self.doorExited();
}); });
}); });
}; };

View File

@ -11,7 +11,6 @@ let async = require('async');
let assert = require('assert'); let assert = require('assert');
let paths = require('path'); let paths = require('path');
let _ = require('lodash'); let _ = require('lodash');
let net = require('net');
let mkdirs = require('fs-extra').mkdirs; let mkdirs = require('fs-extra').mkdirs;
// :TODO: This should really be a system module... needs a little work to allow for such // :TODO: This should really be a system module... needs a little work to allow for such
@ -20,8 +19,6 @@ exports.getModule = AbracadabraModule;
let activeDoorNodeInstances = {}; let activeDoorNodeInstances = {};
let doorInstances = {}; // name -> { count : <instCount>, { <nodeNum> : <inst> } }
exports.moduleInfo = { exports.moduleInfo = {
name : 'Abracadabra', name : 'Abracadabra',
desc : 'External BBS Door Module', desc : 'External BBS Door Module',
@ -166,6 +163,18 @@ function AbracadabraModule(options) {
const doorInstance = new door.Door(self.client, exeInfo); const doorInstance = new door.Door(self.client, exeInfo);
doorInstance.once('finished', () => { doorInstance.once('finished', () => {
//
// Try to clean up various settings such as scroll regions that may
// have been set within the door
//
self.client.term.rawWrite(
ansi.normal() +
ansi.goto(self.client.term.termHeight, self.client.term.termWidth) +
ansi.setScrollRegion() +
ansi.goto(self.client.term.termHeight, 0) +
'\r\n\r\n'
);
self.prevMenu(); self.prevMenu();
}); });