* Minor JSON -> HJSON config cleanup

* Some logging in telnet server vs console.log()
* Calculate FSE footer position vs hard code it
This commit is contained in:
Bryan Ashby 2015-09-12 17:17:00 -06:00
parent e661b23eca
commit 05f666cf29
10 changed files with 126 additions and 109 deletions

View File

@ -184,19 +184,17 @@ function FullScreenEditorModule(options) {
[
function moveToFooterPosition(callback) {
//
// Calculate footer staring position
// Calculate footer starting position
//
// row = (header height + body height)
//
// Header: mciData.body.height
// Body : We must find this in the config / theme
//
// :TODO: don't hard code this -- allow footer height to be part of theme/etc.
self.client.term.rawWrite(ansi.goto(24, 1));
var footerRow = self.header.height + self.body.height;
self.client.term.rawWrite(ansi.goto(footerRow, 1));
callback(null);
},
function clearFooterArea(callback) {
if(options.clear) {
// footer up to 3 rows in height
self.client.term.rawWrite(ansi.reset() + ansi.deleteLine(3));
}
callback(null);
@ -316,6 +314,9 @@ function FullScreenEditorModule(options) {
{ font : self.menuConfig.font },
function displayed(err, artData) {
mciData[n] = artData;
self[n] = { height : artData.height };
next(err);
}
);
@ -327,7 +328,7 @@ function FullScreenEditorModule(options) {
self.setInitialFooterMode();
var footerName = self.getFooterName();
console.log(footerName)
self.redrawFooter( { footerName : footerName }, function artDisplayed(err, artData) {
mciData[footerName] = artData;
callback(err);
@ -369,8 +370,6 @@ function FullScreenEditorModule(options) {
menuLoadOpts.formId = self.getFormId('body');
menuLoadOpts.mciMap = mciData.body.mciMap;
console.log('creating body.l..')
self.addViewController(
'body',
new ViewController( { client : self.client, formId : menuLoadOpts.formId } )

View File

@ -13,6 +13,13 @@ var util = require('util');
var async = require('async');
var iconv = require('iconv-lite');
/*
:TODO: should probably be broken up
FTNPacket
FTNPacketImport: packet -> message(s)
FTNPacketExport: message(s) -> packet
*/
//
// References
// * http://ftsc.org/docs/fts-0001.016

View File

@ -26,7 +26,14 @@ function MCIViewFactory(client) {
}
MCIViewFactory.UserViewCodes = [
'TL', 'ET', 'ME', 'MT', 'PL', 'BT', 'VM', 'HM', 'SM', 'TM'
'TL', 'ET', 'ME', 'MT', 'PL', 'BT', 'VM', 'HM', 'SM', 'TM',
//
// XY is a special MCI code that allows finding positions
// and counts for key lookup, but does not explicitly
// represent a visible View on it's own
//
'XY',
];
MCIViewFactory.prototype.createFromMCI = function(mci) {
@ -189,8 +196,6 @@ MCIViewFactory.prototype.createFromMCI = function(mci) {
setOption(2, 'justify');
view = new TextView(options);
} else {
// :TODO: log this
}
break;
}

View File

@ -154,13 +154,19 @@ function MenuModule(options) {
this.nextMenu = function() {
if(!_.isObject(self.menuConfig.form) && !_.isString(self.menuConfig.prompt) &&
(_.isString(self.menuConfig.next) || _.isObject(self.menuConfig.next)))
!_.isUndefined(self.menuConfig.next))
{
/*
next : "spec"
'next' may be a simple asset, or a object with next.asset and
extrArgs
next: assetSpec
-or-
next: {
"asset" : "spec",
"extraArgs" : ...
asset: assetSpec
extraArgs: ...
}
*/
if(self.hasNextTimeout()) {

View File

@ -326,7 +326,8 @@ OPTION_IMPLS[OPTIONS.NEW_ENVIRONMENT] = function(bufs, i, event) {
event.type = vars.isOrInfo;
if(vars.newEnv === OPTIONS.NEW_ENVIRONMENT_DEP) {
Log.warn('Handling deprecated RFC 1408 NEW-ENVIRON');
// :TODO: bring all this into Telnet class
Log.log.warn('Handling deprecated RFC 1408 NEW-ENVIRON');
}
});
@ -488,7 +489,7 @@ function TelnetClient(input, output) {
});
this.input.on('error', function sockError(err) {
Log.debug(err); // :TODO: probably something better...
self.log.debug(err); // :TODO: probably something better...
self.emit('end');
});
}
@ -524,12 +525,12 @@ TelnetClient.prototype.handleWillCommand = function(evt) {
this.requestNewEnvironment();
} else {
// :TODO: temporary:
console.log('unhandled will ' + JSON.stringify(evt));
this.log.trace(evt, 'WILL');
}
};
TelnetClient.prototype.handleWontCommand = function(evt) {
console.log('wont ' + JSON.stringify(evt));
this.log.trace(evt, 'WONT');
};
TelnetClient.prototype.handleDoCommand = function(evt) {
@ -547,19 +548,19 @@ TelnetClient.prototype.handleDoCommand = function(evt) {
this.wont.encrypt();
} else {
// :TODO: temporary:
console.log('do ' + JSON.stringify(evt));
this.log.trace(evt, 'DO');
}
};
TelnetClient.prototype.handleDontCommand = function(evt) {
console.log('dont ' + JSON.stringify(evt));
this.log.trace(evt, 'dont');
};
TelnetClient.prototype.setTermType = function(ttype) {
this.term.env.TERM = ttype;
this.term.termType = ttype;
Log.debug( { termType : ttype }, 'Set terminal type');
this.log.debug( { termType : ttype }, 'Set terminal type');
};
TelnetClient.prototype.handleSbCommand = function(evt) {
@ -592,22 +593,22 @@ TelnetClient.prototype.handleSbCommand = function(evt) {
self.setTermType(evt.envVars[name]);
} else if('COLUMNS' === name && 0 === self.term.termWidth) {
self.term.termWidth = parseInt(evt.envVars[name]);
Log.debug({ termWidth : self.term.termWidth, source : 'NEW-ENVIRON'}, 'Window width updated');
self.log.debug({ termWidth : self.term.termWidth, source : 'NEW-ENVIRON'}, 'Window width updated');
} else if('ROWS' === name && 0 === self.term.termHeight) {
self.term.termHeight = parseInt(evt.envVars[name]);
Log.debug({ termHeight : self.term.termHeight, source : 'NEW-ENVIRON'}, 'Window height updated');
self.log.debug({ termHeight : self.term.termHeight, source : 'NEW-ENVIRON'}, 'Window height updated');
} else {
if(name in self.term.env) {
assert(
SB_COMMANDS.INFO === evt.type || SB_COMMANDS.IS === evt.type,
'Unexpected type: ' + evt.type);
Log.warn(
self.log.warn(
{ varName : name, value : evt.envVars[name], existingValue : self.term.env[name] },
'Environment variable already exists');
} else {
self.term.env[name] = evt.envVars[name];
Log.debug(
self.log.debug(
{ varName : name, value : evt.envVars[name] }, 'New environment variable');
}
}
@ -629,9 +630,9 @@ TelnetClient.prototype.handleSbCommand = function(evt) {
self.term.env.ROWS = evt.height;
}
Log.debug({ termWidth : evt.width , termHeight : evt.height, source : 'NAWS' }, 'Window size updated');
self.log.debug({ termWidth : evt.width , termHeight : evt.height, source : 'NAWS' }, 'Window size updated');
} else {
console.log('unhandled SB: ' + JSON.stringify(evt));
self.log(evt, 'SB');
}
};
@ -650,15 +651,17 @@ TelnetClient.prototype.handleMiscCommand = function(evt) {
//
if('ip' === evt.command) {
// Interrupt Process (IP)
Log.debug('Interrupt Process (IP) - Ending');
this.log.debug('Interrupt Process (IP) - Ending');
this.input.end();
} else if('ayt' === evt.command) {
this.output.write('\b');
Log.debug('Are You There (AYT) - Replied "\\b"');
this.log.debug('Are You There (AYT) - Replied "\\b"');
} else if(IGNORED_COMMANDS.indexOf(evt.commandCode)) {
Log.debug({ evt : evt }, 'Ignoring command');
this.log.debug({ evt : evt }, 'Ignoring command');
} else {
Log.warn({ evt : evt }, 'Unknown command');
this.log.warn({ evt : evt }, 'Unknown command');
}
};
@ -683,7 +686,7 @@ var WANTED_ENVIRONMENT_VAR_BUFS = [
TelnetClient.prototype.requestNewEnvironment = function() {
if(this.subNegotiationState.newEnvironRequested) {
Log.debug('New environment already requested');
this.log.debug('New environment already requested');
return;
}

View File

@ -50,47 +50,50 @@
}
}
*/
"menus" : {
"connected" : {
"art" : "CONNECT",
"next" : "matrix",
"options" : {
"nextTimeout" : 1500
menus: {
connected: {
art: CONNECT
next: matrix
options: {
nextTimeout: 1500
}
},
"matrix" : {
"art" : "matrix",
"form" : {
"0" : { // :TODO: Make form "0" the default if missing (e.g. optional)... not sure how with current structure though
"VM" : {
"mci" : {
"VM1" : {
"submit" : true,
"focus" : true,
}
matrix: {
art: matrix
form: {
0: { // :TODO: Make form "0" the default if missing (e.g. optional)... not sure how with current structure though
VM: {
mci: {
VM1: {
submit: true
focus: true
// :TODO: need a good way to localize these ... Standard Orig->Lookup seems good.
"items" : [ "Login", "Apply", "Log Off" ]//,
items: [ "Login", "Apply", "Log Off" ]
}
},
"submit" : {
"*" : [
}
submit: {
*: [
{
"value" : { "1" : 0 },
"action" : "@menu:login2"
value: { 1: 0 }
action: @menu:login2
},
{
"value" : { "1" : 1 },
"action" : "@menu:apply"
value: { 1: 1 },
action: @menu:apply
},
{
"value" : { "1" : 2 },
"action" : "@menu:logoff"
value: { 1: 2 },
action: @menu:logoff
}
]
}
}
}
}
},
}
"login" : {
"prompt" : "userLoginCredentials",
"fallback" : "matrix",
@ -110,7 +113,8 @@
"login2" : {
"art" : "USRCRED",
"fallback" : "matrix",
"next" : "fullLoginSequenceLoginArt",
next: messageArea
//"next" : "fullLoginSequenceLoginArt",
"form" : {
"0" : {
"mci" : {
@ -431,7 +435,7 @@
art: {
header: MSGVHDR
// :TODO: fix these!!
body: demo_fse_netmail_body.ans
body: MSGBODY
footerEdit: demo_fse_netmail_footer_edit.ans
footerEditMenu: demo_fse_netmail_footer_edit_menu.ans
footerView: MSGVFTR
@ -464,29 +468,27 @@
}
},
"1" : {
"MT" : {
"mci" : {
"MT1" : {
"width" : 79,
"height" : 12,
"mode" : "preview"
}
},
"submit" : {
"*" : [
{
"value" : "message",
"action" : "@method:editModeEscPressed"
}
]
},
"actionKeys" : [
"mci" : {
"MT1" : {
"width" : 79,
"height" : 12,
"mode" : "preview"
}
},
"submit" : {
"*" : [
{
"keys" : [ "escape" ],
"viewId" : 1
"value" : "message",
"action" : "@method:editModeEscPressed"
}
]
}
},
"actionKeys" : [
{
"keys" : [ "escape" ],
"viewId" : 1
}
]
},
"2" : {
"TLTL" : {
@ -559,7 +561,7 @@
config: {
art: {
header: MSGEHDR
body: demo_fse_netmail_body.ans
body: MSGBODY
footerEditor: MSGEFTR
footerEditorMenu: MSGEMFT
footerView: demo_fse_netmail_footer_view.ans
@ -601,29 +603,24 @@
}
},
"1" : {
"MT" : {
"mci" : {
"MT1" : {
"width" : 79,
"height" : 17,
"argName" : "message"
}
},
"submit" : {
"*" : [
{
"value" : "message",
"action" : "@method:editModeEscPressed"
}
]
},
"actionKeys" : [
{
"keys" : [ "escape" ],
"viewId" : 1
}
]
"mci" : {
MT1: {
width: 79
height: 12
argName: message
mode: edit
}
}
submit: {
*: [ { "value": "message", "action": "@method:editModeEscPressed" } ]
},
"actionKeys" : [
{
"keys" : [ "escape" ],
"viewId" : 1
}
]
},
"2" : {
"TLTL" : {
@ -718,9 +715,9 @@
////////////////////////////////////////////////////////////////////////
// Mods
////////////////////////////////////////////////////////////////////////
"idleLogoff" : {
"art" : "IDLELOG",
"action" : "@systemMethod:logoff"
idleLogoff: {
art: IDLELOG
next: @systemMethod:logoff
},
////////////////////////////////////////////////////////////////////////
// Mods

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.