mirror of
https://github.com/embarklabs/neo-blessed.git
synced 2025-02-02 06:07:36 +00:00
cleanup new dump method.
This commit is contained in:
parent
b7e7a8264b
commit
33214ee924
@ -79,20 +79,11 @@ Program.prototype.__proto__ = EventEmitter.prototype;
|
||||
Program.prototype.dump = function(file) {
|
||||
var self = this
|
||||
, _write = this.output.write
|
||||
, decoder = new (require('string_decoder')).StringDecoder('utf8')
|
||||
, stringify = stringifyLess;
|
||||
, decoder = new (require('string_decoder')).StringDecoder('utf8');
|
||||
|
||||
this.logger = require('fs').createWriteStream(file);
|
||||
|
||||
function stringifyJson(data) {
|
||||
return JSON.stringify(caret(data))
|
||||
.replace(/\\u00([0-9a-f])/gi, '\\x$1')
|
||||
.slice(1, -1);
|
||||
}
|
||||
|
||||
function stringifyLess(data) {
|
||||
// Could wrap in: \x1b[7m\x1b[m
|
||||
// for inverse in `less -R`.
|
||||
function stringify(data) {
|
||||
return caret(data
|
||||
.replace(/\r/g, '\\r')
|
||||
.replace(/\n/g, '\\n')
|
||||
@ -109,14 +100,6 @@ Program.prototype.dump = function(file) {
|
||||
});
|
||||
}
|
||||
|
||||
function stringifyMinimal(data) {
|
||||
return data
|
||||
//.replace(/\x1b/g, '^[')
|
||||
.replace(/\r/g, '\\r')
|
||||
.replace(/\n/g, '\\n')
|
||||
.replace(/\t/g, '\\t');
|
||||
}
|
||||
|
||||
function caret(data) {
|
||||
return data.replace(/[\0\x80\x1b-\x1f\x7f\x01-\x1a]/g, function(ch) {
|
||||
switch (ch) {
|
||||
@ -144,8 +127,8 @@ Program.prototype.dump = function(file) {
|
||||
break;
|
||||
default:
|
||||
ch = ch.charCodeAt(0);
|
||||
// From ('A' - 64) to ('Z' - 64).
|
||||
if (ch >= 1 && ch <= 26) {
|
||||
//if (ch >= 'A'.charCodeAt(0) - 64 && ch <= 'Z'.charCodeAt(0) - 64) {
|
||||
ch = String.fromCharCode(ch + 64);
|
||||
} else {
|
||||
return String.fromCharCode(ch);
|
||||
|
Loading…
x
Reference in New Issue
Block a user