nodejs / nodejs/node

Possible node interfering with console color?

Offen
#37,132 12 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

stdio
Vorherrschende Sprache
JavaScript
Sterne
122k
Forks
37.3k
Ø Merge
4 T. 2 Std.
Gemergte PRs (30 T.)
283

Beschreibung

There's a whole lot of things I don't understand here, so please let me apologize in advance for this ticket as a shambles.

Initially I was trying to work with a high quality console color library, and I was confounded because I had just switched to the modern Win10 console, with its 24 bit color support, and it wasn't 24 bit coloring. It's a big library by a big programmer, so I was surprised.

So I thought "it's just ansi codes, I'll do it myself," and tried to do it myself. Worked them out in console printf, looked good, node -e, and ... and ... wha?

image

The same string in the same console was working with printf and not with node -e console.log. The latter was getting downgraded to a different color range.

Okay, node must just not know it's 2-- wha?

image

So I tried using the FORCE_COLOR flag as a leader. No.

image

So I tried using it as an envvar. No.

image

So I switched to process.stdout. No.

image

And then I looked up my TERM setting. xterm-color-256. Initially I thought "aha!", except then I realized that's not the color you'd get from my testcase in a 6-cube.

Oh, dear. Am I in ... am I in 4-bit color in node, despite having a 24-bit terminal?

Wrote this to find out

const seq = n => new Array(n).fill(false).map( (_, i) => i );
const col = (r,g,b) => 16 + b + (g*6) + (r*36);

seq(6).map(b => {
  seq(6).map(g => {
    seq(6).map(r => process.stdout.write(`\x1b[38;5;${col(r,g,b)}m*`) );
  process.stdout.write(' '); });
process.stdout.write('\n'); });

Yep.

image

Gulp.

Am I missing something? It seems like my terminal is set up for 24 bit, and node is manually downsampling my terminal output for me despite FORCE_COLOR. It couldn't be doing that, could it? That wouldn't make any sense.

What exists between node and the console which could be doing this?

So I thought I'd be tricky and see if some other language on the machine would get it right, yeah?

Tried python. ... lol

image

So then, yes, there is something between the language and the console, which is capable of screwing ansi codes up.

How do I find what that something is for node, so that I can find what's misconfigured in it, please?

Thanks

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, das Verhalten mit node -e console.log, process.stdout, FORCE_COLOR und der bereitgestellten ANSI-Farbschleife in der modernen Windows-10-Konsole zu reproduzieren. Vergleiche die Ausgabe von Node mit printf und Python und ermittle anschließend, ob Node die ANSI-Sequenzen verändert oder eine externe Konsolenschicht dies tut; als erledigt gilt die Untersuchung, wenn die verantwortliche Komponente und Konfiguration identifiziert sind.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, node.js
Bereich
cli
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Ruhig
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.