cronvel / terminal-kit

Terminal utilities for node.js
MIT License
3.08k stars 198 forks source link

ansi 256 colors doesnt work when using escape codes in content #196

Open valyrie97 opened 2 years ago

valyrie97 commented 2 years ago

ansi 256 seems to work fine when specified in attr, but not in content.

the empty object for attr fixes an additional related bug, whereby with not attr key, the text background is dim white, and foreground is bright white. (visually, maybe its ansi 256 codes, maybes its bright black bg and white fg, i cant tell, but its certainly not default text.)

With attr key

image

Without attr key

image

Reproducible test

import tk from 'terminal-kit';
const term = tk.terminal;
const Text = tk.Text;

const document = term.createDocument();

new Text({
  parent: document,
  content: `\x1b[38;5;242m\x1b[39;5;173mThis Should Be Orange With Grey Background But is Not.\x1b[0m`,
  contentHasMarkup: 'ansi',
  attr: {}
});

term.on('key', function (key: string) {
  if (key === 'CTRL_C') {
    term.grabInput(false);
    term.clear();
    process.exit();
  }
});