diff --git a/lib/program.js b/lib/program.js index 25c55cc..4ac1981 100644 --- a/lib/program.js +++ b/lib/program.js @@ -9,7 +9,8 @@ */ var EventEmitter = require('events').EventEmitter - , Tput = require('./tput'); + , Tput = require('./tput') + , colors = require('./colors'); /** * Program @@ -1554,7 +1555,9 @@ Program.prototype.text = function(text, attr) { Program.prototype._attr = function(param, val) { var self = this , param = param || 'normal' - , parts = param.split(/\s*[,;]\s*/); + , parts = param.split(/\s*[,;]\s*/) + , color + , m; if (parts.length > 1) { parts = parts.map(function(part) { @@ -1571,8 +1574,6 @@ Program.prototype._attr = function(param, val) { val = false; } - // tput: TODO - switch (param) { // attributes case 'normal': @@ -1754,9 +1755,13 @@ Program.prototype._attr = function(param, val) { default: // 256-color fg and bg - var m = /^(\d+) (fg|bg)$/.exec(param); + if (param[0] === '#') { + param = param.replace(/#(?:[0-9a-f]{3}){1,2}/i, colors.matchColor); + } + + m = /^(\d+) (fg|bg)$/.exec(param); if (m) { - var color = +m[1] - 1; + color = +m[1] - 1; if (val === false) { return this._attr('default ' + m[2]); diff --git a/lib/widget.js b/lib/widget.js index 69e1699..99e4859 100644 --- a/lib/widget.js +++ b/lib/widget.js @@ -4130,13 +4130,13 @@ function wrapContent(content, width, tags, state) { while (line[i] && line[i++] !== 'm'); } if (!line[i]) break; - //if (++total === width) { - if (++total > width) { + if (++total === width) { // Try to find a space to break on: if (line[i] !== ' ') { var j = i; while (j > i - 10 && j > 0 && line[j] !== ' ') j--; if (line[j] === ' ') i = j + 1; + else i++; } else { i++; }