Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

16 colors used, even with $TERM = xterm-256color #49

Open
cdaringe opened this issue Jun 22, 2020 · 1 comment · May be fixed by cdaringe/neo-blessed#1 or #50
Open

16 colors used, even with $TERM = xterm-256color #49

cdaringe opened this issue Jun 22, 2020 · 1 comment · May be fixed by cdaringe/neo-blessed#1 or #50

Comments

@cdaringe
Copy link

cdaringe commented Jun 22, 2020

Problem

I am trying to render a known valid color, e.g. DarkOrange3: "#d75f00", but blessed doesn't honor it.

example:

{#d75f00-fg}hello{/}

gets reduced internally to 1 fg by Program::_attr. 166 is the correct color index, not 1

It seems that during color selection, when parsing my hex color, I end up getting dropped into this block:

var ldiff = Infinity,
li = -1,
i = 0,
c,
r2,
g2,
b2,
diff;
for (; i < exports.vcolors.length; i++) {
c = exports.vcolors[i];
r2 = c[0];
g2 = c[1];
b2 = c[2];
diff = colorDistance(r1, g1, b1, r2, g2, b2);
if (diff === 0) {
li = i;
break;
}
if (diff < ldiff) {
ldiff = diff;
li = i;
}
}
exports._cache[hash] = li;
return exports._cache[hash];

of which exports.vcolors is an array of only eight (8) items.

one of two things is likely incorrect:

  • vcolors is not properly hydrated with the correct set of values
  • the _cache is not hydrated with the correct set of values

any assistance would be great!

thanks!

@cdaringe
Copy link
Author

so on init of blessed, the _cache is hydrated with 8-color mode values by simple means of exporting an iife of ccolors. see exports.ccolors = (function() { ... }(). now, anytime someone calls .match, you are immediately reduced to that small cache. further, because .match references a mutatable export, vcolors is internally is also attached a reduced color reference. there is almost certainly a more robust and less mutable (read: confusing) way to do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant