How to use the termcolors.export function in termcolors

To help you get started, we’ve selected a few termcolors examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github stayradiated / terminal.sexy / js / lib.js View on Github external
},{"bluebird":"EjIH/G","lodash":"K2RcUv"}],15:[function(require,module,exports){
var _ = require('lodash');

var termcolors = require('termcolors');
var tiny = require('tinytinycolor');

var template = ".foreground-alt{color:{{=c.alt}} !important;}\n.background-alt{background:{{=c.alt}} !important;}\n.foreground-bg{color:{{=c.background}} !important;}\n.background-bg{background:{{=c.background}} !important;}\n.foreground-fg{color:{{=c.foreground}} !important;}\n.background-fg{background:{{=c.foreground}} !important;}\n.foreground-0{color:{{=c[0]}} !important;}\n.background-0{background:{{=c[0]}} !important;}\n.foreground-1{color:{{=c[1]}} !important;}\n.background-1{background:{{=c[1]}} !important;}\n.foreground-2{color:{{=c[2]}} !important;}\n.background-2{background:{{=c[2]}} !important;}\n.foreground-3{color:{{=c[3]}} !important;}\n.background-3{background:{{=c[3]}} !important;}\n.foreground-4{color:{{=c[4]}} !important;}\n.background-4{background:{{=c[4]}} !important;}\n.foreground-5{color:{{=c[5]}} !important;}\n.background-5{background:{{=c[5]}} !important;}\n.foreground-6{color:{{=c[6]}} !important;}\n.background-6{background:{{=c[6]}} !important;}\n.foreground-7{color:{{=c[7]}} !important;}\n.background-7{background:{{=c[7]}} !important;}\n.foreground-8{color:{{=c[8]}} !important;}\n.background-8{background:{{=c[8]}} !important;}\n.foreground-9{color:{{=c[9]}} !important;}\n.background-9{background:{{=c[9]}} !important;}\n.foreground-10{color:{{=c[10]}} !important;}\n.background-10{background:{{=c[10]}} !important;}\n.foreground-11{color:{{=c[11]}} !important;}\n.background-11{background:{{=c[11]}} !important;}\n.foreground-12{color:{{=c[12]}} !important;}\n.background-12{background:{{=c[12]}} !important;}\n.foreground-13{color:{{=c[13]}} !important;}\n.background-13{background:{{=c[13]}} !important;}\n.foreground-14{color:{{=c[14]}} !important;}\n.background-14{background:{{=c[14]}} !important;}\n.foreground-15{color:{{=c[15]}} !important;}\n.background-15{background:{{=c[15]}} !important;}\n\n.window {\n  color: {{=c.foreground}} !important;\n  background: {{=c[0]}} !important;\n}\n\n.window .title {\n  color: {{=c.foreground}} !important;\n}\n\n.window .content {\n  background: {{=c.background}} !important;\n}\n";

module.exports = {
  export: termcolors.export(template, function (colors) {
    hex = _.mapValues(colors, function (color) {
      return color.toHexString();
    });

    var contrast = colors.background.toHsl().l > 0.5 ? 'darken' : 'lighten';
    hex.alt = tiny[contrast](colors.background, 7).toHexString();

    return hex;
  })
};

},{"lodash":"K2RcUv","termcolors":"39CK3B","tinytinycolor":"2EHlwd"}],16:[function(require,module,exports){
(function (Buffer){
github stayradiated / terminal.sexy / lib / formats / json.js View on Github external
'use strict';

var _ = require('lodash');
var fs = require('fs');
var termcolors = require('termcolors');

var template = fs.readFileSync(__dirname + '/json.dot', 'utf8');

module.exports = {
  export: termcolors.export(template, _.partialRight(_.mapValues, function (color) {
    return color.toHex();
  }))
};
github stayradiated / terminal.sexy / lib / formats / css.js View on Github external
var templates = {};

while ((match = regex.exec(cssTemplate)) !== null) {
  var len = match[0].length;
  var id = match[1];
  var index = match.index;
  matches.push([id, index, index + len]);
}

for (var i = 0, len = matches.length; i < len; i += 1) {
  match = matches[i];
  id = match[0];
  nextMatch = matches[i+1];
  nextMatch = nextMatch ? nextMatch[1] : cssTemplate.length;
  template = cssTemplate.substring(match[2], nextMatch);
  templates[id] = termcolors.export(template, templateFn[id]);
}

module.exports = {
  export: function (id, data) {
    return templates[id](data);
  }
};

termcolors

Convert color schemes to multiple terminal configs

MIT
Latest version published 3 years ago

Package Health Score

52 / 100
Full package analysis