Merge branch '0.0.9-alpha' of ssh://numinibsd/git/base/enigma-bbs into achivements-0.0.9-alpha

This commit is contained in:
Bryan Ashby 2019-01-12 23:00:27 -07:00
commit 90137819dd
4 changed files with 2312 additions and 2540 deletions

View File

@ -56,6 +56,74 @@ function ansiDiscoverHomePosition(client, cb) {
client.term.write(`${ansi.goHome()}${ansi.queryPos()}`); // go home, query pos client.term.write(`${ansi.goHome()}${ansi.queryPos()}`); // go home, query pos
} }
function ansiAttemptDetectUTF8(client, cb) {
//
// Trick to attempt and detect UTF-8. While there is a lot more than
// just UTF-8 and CP437, many those are the main concerns, when it comes
// terminals that for example tell us they are "xterm" but still want CP437.
//
// Try to detect UTF-8 by discovering the cursor position, writing some
// multi-byte UTF-8, and checking the position again. If the term is really
// UTF-8, we should get a proper position, otherwise we'll be further out.
//
// We currently only do this if the term hasn't already been ID'd as a
// "*nix" terminal -- that is, xterm, etc.
//
if(!client.term.isNixTerm()) {
return cb(null);
}
let posStage = 1;
let initialPosition;
let giveUpTimer;
const giveUp = () => {
client.removeListener('cursor position report', cprListener);
clearTimeout(giveUpTimer);
return cb(null);
};
const ASCIIPortion = ' Character encoding detection ';
const cprListener = (pos) => {
switch(posStage) {
case 1 :
posStage = 2;
initialPosition = pos;
clearTimeout(giveUpTimer);
giveUpTimer = setTimeout( () => {
return giveUp();
}, 2000);
client.once('cursor position report', cprListener);
client.term.rawWrite(`\u9760${ASCIIPortion}\u9760`); // Unicode skulls on each side
client.term.rawWrite(ansi.queryPos());
break;
case 2 :
{
clearTimeout(giveUpTimer);
const len = pos[1] - initialPosition[1];
if(!isNaN(len) && len >= ASCIIPortion.length + 6) { // CP437 displays 3 chars each Unicode skull
client.log.info('Terminal identified as UTF-8 but does not appear to be. Overriding to "ansi".');
client.setTermType('ansi');
}
}
return cb(null);
}
};
giveUpTimer = setTimeout( () => {
return giveUp();
}, 2000);
client.once('cursor position report', cprListener);
client.term.rawWrite(ansi.goHome() + ansi.queryPos());
}
function ansiQueryTermSizeIfNeeded(client, cb) { function ansiQueryTermSizeIfNeeded(client, cb) {
if(client.term.termHeight > 0 || client.term.termWidth > 0) { if(client.term.termHeight > 0 || client.term.termWidth > 0) {
return cb(null); return cb(null);
@ -164,7 +232,7 @@ function connectEntry(client, nextMenu) {
// We still don't have something good for term height/width. // We still don't have something good for term height/width.
// Default to DOS size 80x25. // Default to DOS size 80x25.
// //
// :TODO: Netrunner is currenting hitting this and it feels wrong. Why is NAWS/ENV/CPR all failing??? // :TODO: Netrunner is currently hitting this and it feels wrong. Why is NAWS/ENV/CPR all failing???
client.log.warn( { reason : err.message }, 'Failed to negotiate term size; Defaulting to 80x25!'); client.log.warn( { reason : err.message }, 'Failed to negotiate term size; Defaulting to 80x25!');
term.termHeight = 25; term.termHeight = 25;
@ -175,6 +243,9 @@ function connectEntry(client, nextMenu) {
return callback(null); return callback(null);
}); });
}, },
function checkUtf8IfNeeded(callback) {
return ansiAttemptDetectUTF8(client, callback);
}
], ],
() => { () => {
prepareTerminal(term); prepareTerminal(term);

2530
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -33,28 +33,28 @@
"hashids": "^1.1.1", "hashids": "^1.1.1",
"hjson": "^3.1.2", "hjson": "^3.1.2",
"iconv-lite": "^0.4.23", "iconv-lite": "^0.4.23",
"inquirer": "^6.0.0", "inquirer": "^6.2.1",
"later": "1.2.0", "later": "1.2.0",
"lodash": "^4.17.10", "lodash": "^4.17.10",
"lru-cache": "^5.1.1",
"mime-types": "^2.1.21", "mime-types": "^2.1.21",
"minimist": "1.2.x", "minimist": "1.2.x",
"moment": "^2.22.2", "moment": "^2.23.0",
"node-pty": "^0.7.4", "nntp-server": "^1.0.3",
"nodemailer": "^4.6.5", "node-pty": "^0.8.0",
"nodemailer": "^5.1.1",
"rlogin": "^1.0.0", "rlogin": "^1.0.0",
"sane": "^4.0.2", "sane": "^4.0.2",
"sanitize-filename": "^1.6.1", "sanitize-filename": "^1.6.1",
"sqlite3": "^4.0.4", "sqlite3": "^4.0.6",
"sqlite3-trans": "^1.2.1", "sqlite3-trans": "^1.2.1",
"ssh2": "^0.6.1", "ssh2": "^0.7.1",
"temptmp": "^1.1.0", "temptmp": "^1.1.0",
"uuid": "^3.2.1", "uuid": "^3.2.1",
"uuid-parse": "^1.0.0", "uuid-parse": "^1.0.0",
"ws": "^6.1.2", "ws": "^6.1.2",
"xxhash": "^0.2.4", "xxhash": "^0.2.4",
"yazl": "^2.5.0", "yazl": "^2.5.1"
"nntp-server": "^1.0.3",
"lru-cache" : "^5.1.1"
}, },
"devDependencies": {}, "devDependencies": {},
"engines": { "engines": {

2231
yarn.lock Normal file

File diff suppressed because it is too large Load Diff