* Start of work on re-write of SGR stuff related to MCI codes

This commit is contained in:
Bryan Ashby 2015-04-29 15:38:20 -06:00
parent 48be2f69be
commit 3f29e3dba4
10 changed files with 110 additions and 94 deletions

View file

@ -19,6 +19,7 @@ var _ = require('lodash');
exports.getFGColorValue = getFGColorValue;
exports.getBGColorValue = getBGColorValue;
exports.sgr = sgr;
exports.getSGRFromGraphicRendition = getSGRFromGraphicRendition;
exports.clearScreen = clearScreen;
exports.resetScreen = resetScreen;
exports.normal = normal;
@ -323,6 +324,21 @@ function sgr() {
return ESC_CSI + result + 'm';
}
//
// Converts a Graphic Rendition object used elsewhere
// to a ANSI SGR sequence
//
function getSGRFromGraphicRendition(graphicRendition) {
var sgrSeq = graphicRendition.styles.slice(0); // start out with styles
if(graphicRendition.fg) {
sgrSeq.push(graphicRendition.fg);
}
if(graphicRendition.bg) {
sgrSeq.push(graphicRendition.bg);
}
return sgr(sgrSeq);
}
///////////////////////////////////////////////////////////////////////////////
// Shortcuts for common functions
///////////////////////////////////////////////////////////////////////////////