Implement OSC 4 for list of colors
This commit is contained in:
@@ -1693,16 +1693,15 @@ describe('InputHandler', () => {
|
||||
});
|
||||
});
|
||||
describe('OSC', () => {
|
||||
it('should parse correct Ansi color change data', () => {
|
||||
it('4: should parse correct Ansi color change data', () => {
|
||||
// this is testing a private method
|
||||
const parseAnsiColorChange = inputHandler['_parseAnsiColorChange'];
|
||||
const event = parseAnsiColorChange('19;rgb:a1/b2/c3');
|
||||
|
||||
assert.deepEqual(
|
||||
parseAnsiColorChange('19;rgb:a1/b2/c3'),
|
||||
{ colorIndex: 19, red: 0xa1, green: 0xb2, blue: 0xc3 }
|
||||
);
|
||||
assert.isNotNull(event);
|
||||
assert.deepEqual(event!.colors[0], { colorIndex: 19, red: 0xa1, green: 0xb2, blue: 0xc3 });
|
||||
}),
|
||||
it('should ignore incorrect Ansi color change data', () => {
|
||||
it('4: should ignore incorrect Ansi color change data', () => {
|
||||
// this is testing a private method
|
||||
const parseAnsiColorChange = inputHandler['_parseAnsiColorChange'];
|
||||
|
||||
@@ -1711,12 +1710,43 @@ describe('InputHandler', () => {
|
||||
assert.isNull(parseAnsiColorChange('17;rgba:aa/bb/cc'));
|
||||
assert.isNull(parseAnsiColorChange('rgb:aa/bb/cc'));
|
||||
});
|
||||
it('should fire event on Ansi color change', (done) => {
|
||||
it('4: should parse a list of Ansi color changes', () => {
|
||||
// this is testing a private method
|
||||
const parseAnsiColorChange = inputHandler['_parseAnsiColorChange'];
|
||||
const event = parseAnsiColorChange('19;rgb:a1/b2/c3;17;rgb:00/11/22;255;rgb:01/ef/2d');
|
||||
|
||||
assert.isNotNull(event);
|
||||
assert.equal(event!.colors.length, 3);
|
||||
assert.deepEqual(event!.colors[0], { colorIndex: 19, red: 0xa1, green: 0xb2, blue: 0xc3 });
|
||||
assert.deepEqual(event!.colors[1], { colorIndex: 17, red: 0x00, green: 0x11, blue: 0x22 });
|
||||
assert.deepEqual(event!.colors[2], { colorIndex: 255, red: 0x01, green: 0xef, blue: 0x2d });
|
||||
});
|
||||
it('4: should ignore incorrect colors in a list of Ansi color changes', () => {
|
||||
// this is testing a private method
|
||||
const parseAnsiColorChange = inputHandler['_parseAnsiColorChange'];
|
||||
const event = parseAnsiColorChange('19;rgb:a1/b2/c3;17;rgb:WR/ON/G;255;rgb:01/ef/2d');
|
||||
|
||||
assert.equal(event!.colors.length, 2);
|
||||
assert.deepEqual(event!.colors[0], { colorIndex: 19, red: 0xa1, green: 0xb2, blue: 0xc3 });
|
||||
assert.deepEqual(event!.colors[1], { colorIndex: 255, red: 0x01, green: 0xef, blue: 0x2d });
|
||||
});
|
||||
it('4: should be case insensitive when parsing Ansi color changes', () => {
|
||||
// this is testing a private method
|
||||
const parseAnsiColorChange = inputHandler['_parseAnsiColorChange'];
|
||||
const event = parseAnsiColorChange('19;rGb:A1/b2/C3');
|
||||
|
||||
assert.equal(event!.colors.length, 1);
|
||||
assert.deepEqual(event!.colors[0], { colorIndex: 19, red: 0xa1, green: 0xb2, blue: 0xc3 });
|
||||
});
|
||||
it('4: should fire event on Ansi color change', (done) => {
|
||||
inputHandler.onAnsiColorChange(e => {
|
||||
assert.deepEqual(e, { colorIndex: 17, red: 0x1a, green: 0x2b, blue: 0x3c });
|
||||
assert.isNotNull(e);
|
||||
assert.isNotNull(e!.colors);
|
||||
assert.deepEqual(e!.colors[0], { colorIndex: 17, red: 0x1a, green: 0x2b, blue: 0x3c });
|
||||
assert.deepEqual(e!.colors[1], { colorIndex: 12, red: 0x11, green: 0x22, blue: 0x33 });
|
||||
done();
|
||||
});
|
||||
inputHandler.parse('\x1b]4;17;rgb:1a/2b/3c\x1b\\');
|
||||
inputHandler.parse('\x1b]4;17;rgb:1a/2b/3c;12;rgb:11/22/33\x1b\\');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user