* Update to encode()/decode() direct calls for iconv-lite

* Overrite font (to not use!) when showing pause prompts - they should use the current set by menu/art
This commit is contained in:
Bryan Ashby 2015-11-01 13:32:52 -07:00
parent ba4f407c90
commit 46088a9f02
5 changed files with 22 additions and 15 deletions

View File

@ -53,8 +53,8 @@ git clone https://github.com/NuSkooler/enigma-bbs.git
``` ```
**Create a Config** **Create a Config**
Create new *~/.enigma-bbs/config.hjson* file. Example:
```hjson ```hjson
/* ~/.enigma-bbs/config.hjson */
general: { general: {
boardName: Super Awesome BBS boardName: Super Awesome BBS
} }

View File

@ -244,7 +244,7 @@ function setSyncTERMFont(name, fontPage) {
assert(p1 >= 0 && p1 <= 3); assert(p1 >= 0 && p1 <= 3);
var p2 = SYNCTERM_FONT_AND_ENCODING_TABLE[name]; var p2 = SYNCTERM_FONT_AND_ENCODING_TABLE.indexOf(name);
if(_.isNumber(p2)) { if(_.isNumber(p2)) {
return ESC_CSI + p1 + ';' + p2 + ' D'; return ESC_CSI + p1 + ';' + p2 + ' D';
} }

View File

@ -35,7 +35,9 @@ var SUPPORTED_ART_TYPES = {
'.asc' : { name : 'ASCII', defaultEncoding : 'cp437', eof : 0x1a }, '.asc' : { name : 'ASCII', defaultEncoding : 'cp437', eof : 0x1a },
'.pcb' : { name : 'PCBoard', defaultEncoding : 'cp437', eof : 0x1a }, '.pcb' : { name : 'PCBoard', defaultEncoding : 'cp437', eof : 0x1a },
'.bbs' : { name : 'Wildcat', defaultEncoding : 'cp437', eof : 0x1a }, '.bbs' : { name : 'Wildcat', defaultEncoding : 'cp437', eof : 0x1a },
'.txt' : { name : 'Text', defaultEncoding : 'cp437', eof : 0x1a }, // :TODO: think about this more...
'.amiga' : { name : 'Amiga', defaultEncoding : 'amiga', eof : 0x1a },
'.txt' : { name : 'Amiga Text', defaultEncoding : 'cp437', eof : 0x1a },
// :TODO: extentions for wwiv, renegade, celerity, syncronet, ... // :TODO: extentions for wwiv, renegade, celerity, syncronet, ...
// :TODO: extension for atari // :TODO: extension for atari
// :TODO: extension for topaz ansi/ascii. // :TODO: extension for topaz ansi/ascii.
@ -79,7 +81,7 @@ function readSAUCE(data, cb) {
return; return;
} }
var ver = vars.version.toString('cp437'); var ver = iconv.decode(vars.version, 'cp437');
if('00' !== ver) { if('00' !== ver) {
cb(new Error('Unsupported SAUCE version: ' + ver)); cb(new Error('Unsupported SAUCE version: ' + ver));
@ -87,12 +89,12 @@ function readSAUCE(data, cb) {
} }
var sauce = { var sauce = {
id : vars.id.toString('cp437'), id : iconv.decode(vars.id, 'cp437'),
version : vars.version.toString('cp437'), version : iconv.decode(vars.version, 'cp437').trim(),
title : vars.title.toString('cp437').trim(), title : iconv.decode(vars.title, 'cp437').trim(),
author : vars.author.toString('cp437').trim(), author : iconv.decode(vars.author, 'cp437').trim(),
group : vars.group.toString('cp437').trim(), group : iconv.decode(vars.group, 'cp437').trim(),
date : vars.date.toString('cp437').trim(), date : iconv.decode(vars.date, 'cp437').trim(),
fileSize : vars.fileSize, fileSize : vars.fileSize,
dataType : vars.dataType, dataType : vars.dataType,
fileType : vars.fileType, fileType : vars.fileType,
@ -182,7 +184,7 @@ function parseCharacterSAUCE(sauce) {
while(i < sauce.tinfos.length && sauce.tinfos[i] !== 0x00) { while(i < sauce.tinfos.length && sauce.tinfos[i] !== 0x00) {
++i; ++i;
} }
var fontName = sauce.tinfos.slice(0, i).toString('cp437'); var fontName = iconv.decode(sauce.tinfos.slice(0, i), 'cp437');
if(fontName.length > 0) { if(fontName.length > 0) {
result.fontName = fontName; result.fontName = fontName;
} }
@ -525,7 +527,6 @@ function display(options, cb) {
// :TODO: If options.font, set the font via ANSI // :TODO: If options.font, set the font via ANSI
// ...this should come from sauce, be passed in, or defaulted // ...this should come from sauce, be passed in, or defaulted
var ansiFont = ''; var ansiFont = '';
if(options.font) { if(options.font) {
// :TODO: how to set to ignore SAUCE? // :TODO: how to set to ignore SAUCE?

View File

@ -10,7 +10,7 @@ var iconv = require('iconv-lite');
var assert = require('assert'); var assert = require('assert');
var _ = require('lodash'); var _ = require('lodash');
iconv.extendNodeEncodings(); //iconv.extendNodeEncodings();
exports.ClientTerminal = ClientTerminal; exports.ClientTerminal = ClientTerminal;

View File

@ -280,16 +280,22 @@ function displayThemedPause(options, cb) {
promptConfig = promptJson.prompts.pause; promptConfig = promptJson.prompts.pause;
callback(_.isObject(promptConfig) ? null : new Error('Invalid prompt config block!')); callback(_.isObject(promptConfig) ? null : new Error('Invalid prompt config block!'));
} else { } else {
callback(new Error('Missing standard \'pause\' prompt')) callback(new Error('Missing standard \'pause\' prompt'));
} }
} }
}); });
}, },
function displayPausePrompt(callback) { function displayPausePrompt(callback) {
//
// Override .font so it doesn't change from current setting
//
var dispOptions = promptConfig.options;
dispOptions.font = 'not_really_a_font!';
displayThemedAsset( displayThemedAsset(
promptConfig.art, promptConfig.art,
options.client, options.client,
promptConfig.options, dispOptions,
function displayed(err, artData) { function displayed(err, artData) {
artInfo = artData; artInfo = artData;
callback(err); callback(err);