From 43c39b525fcc3c62e35b18e0940ad43dbc8d50a2 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Tue, 21 Apr 2015 06:56:40 -0700 Subject: [PATCH] handle animating screenshots. ansi-viewer. --- example/ansi-viewer/index.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/example/ansi-viewer/index.js b/example/ansi-viewer/index.js index dd1ebd4..ead0328 100644 --- a/example/ansi-viewer/index.js +++ b/example/ansi-viewer/index.js @@ -25,6 +25,16 @@ var max = Object.keys(map).reduce(function(out, text) { return Math.max(out, text.length); }, 0) + 6; +// Animating ANSI art doesn't work for screenshots. +var ANIMATING = [ + 'bbs/void3', + 'holiday/xmasfwks', + 'unsorted/diver', + 'unsorted/mash-chp', + 'unsorted/ryans47', + 'unsorted/xmasfwks' +]; + var screen = blessed.screen({ smartCSR: true, dockBorders: true @@ -190,10 +200,14 @@ list.on('select', function(el, selected) { screen.render(); if (process.argv[2] === '--debug' || process.argv[2] === '--save') { - //var sgr = blessed.element.prototype.screenshot.call(art, - // 0 - art.ileft, art.width - art.iright, - // 0 - art.itop, art.height - art.ibottom); - var sgr = art.screenshot(); + // Animating art hangs terminal during screenshot as of right now. + if (~ANIMATING.indexOf(name)) { + var sgr = blessed.element.prototype.screenshot.call(art, + 0 - art.ileft, art.width - art.iright, + 0 - art.itop, art.height - art.ibottom); + } else { + var sgr = art.screenshot(); + } fs.writeFileSync(__dirname + '/' + filename + '.sgr', sgr); } });