From da41cc8faa8e38fedf26e1c4c711bd00cef92482 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 21 Nov 2016 19:56:44 -0500 Subject: exporting escape codes --- js/matrix.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'js/matrix.js') diff --git a/js/matrix.js b/js/matrix.js index 1aeb929..dbc76c7 100644 --- a/js/matrix.js +++ b/js/matrix.js @@ -250,6 +250,23 @@ Matrix.prototype.ascii = function () { var txt = lines.join("\n") return txt } +Matrix.prototype.ansi = function (opts) { + var lines = this.aa.map(function(row, y){ + var last, line = "" + row.forEach(function(lex, x) { + if (lex.eqColor(last)) { + line += lex.sanitize() + } + else { + line += lex.ansi() + last = lex + } + }) + return line + }) + var txt = lines.filter(function(line){ return line.length > 0 }).join('\\e[0m\\n') + "\\e[0m" + return 'echo -e "' + txt + '"' +} Matrix.prototype.mirc = function (opts) { var cutoff = false var lines = this.aa.map(function(row, y){ -- cgit v1.2.3-70-g09d2