diff --git a/core/ansi_escape_parser.js b/core/ansi_escape_parser.js index 083bedde..69a118f2 100644 --- a/core/ansi_escape_parser.js +++ b/core/ansi_escape_parser.js @@ -288,6 +288,7 @@ function ANSIEscapeParser(options) { // :TODO: finish this system // * style is map of styleName -> boolean + // * change self.style -> self.styles // * Change all fg/bg/etc -> self.state.color { fg, bg, style{} } // * Change all refs to use this new system // * When passing color -> sgr, iterate enabled styles -> additional params diff --git a/core/ansi_term.js b/core/ansi_term.js index b4f20a77..5d5a5e15 100644 --- a/core/ansi_term.js +++ b/core/ansi_term.js @@ -323,6 +323,25 @@ function sgr() { return ESC_CSI + result + 'm'; } +function ansiFromColor(color) { + var sgrParams = []; + for(var k in color.styles) { + if(true === color.styles[k]) { + sgrParams.push(k); + } + } + + if(color.fg) { + sgrParams.push(color.fg); + } + + if(color.bg) { + sgrParams.push(color.bg); + } + + return sgr(sgrParams); +} + /////////////////////////////////////////////////////////////////////////////// // Shortcuts for common functions ///////////////////////////////////////////////////////////////////////////////