Make InputHandler parseAnsiColorChange private
This commit is contained in:
@@ -1694,16 +1694,13 @@ describe('InputHandler', () => {
|
|||||||
});
|
});
|
||||||
describe('OSC', () => {
|
describe('OSC', () => {
|
||||||
it('should ignore incorrect Ansi color change data', () => {
|
it('should ignore incorrect Ansi color change data', () => {
|
||||||
assert.deepEqual(inputHandler.parseAnsiColorChange('17;rgb:1a/2b/3c'), {
|
// this is testing a private method
|
||||||
colorIndex: 17,
|
const parseAnsiColorChange = inputHandler["_parseAnsiColorChange"];
|
||||||
red: 0x1a,
|
|
||||||
green: 0x2b,
|
assert.isNull(parseAnsiColorChange('17;rgb:a/b/c'));
|
||||||
blue: 0x3c
|
assert.isNull(parseAnsiColorChange('17;rgb:#aabbcc'));
|
||||||
});
|
assert.isNull(parseAnsiColorChange('17;rgba:aa/bb/cc'));
|
||||||
assert.isNull(inputHandler.parseAnsiColorChange('17;rgb:a/b/c'));
|
assert.isNull(parseAnsiColorChange('rgb:aa/bb/cc'));
|
||||||
assert.isNull(inputHandler.parseAnsiColorChange('17;rgb:#aabbcc'));
|
|
||||||
assert.isNull(inputHandler.parseAnsiColorChange('17;rgba:aa/bb/cc'));
|
|
||||||
assert.isNull(inputHandler.parseAnsiColorChange('rgb:aa/bb/cc'));
|
|
||||||
});
|
});
|
||||||
it('should fire event on Ansi color change', (done) => {
|
it('should fire event on Ansi color change', (done) => {
|
||||||
inputHandler.onAnsiColorChange(e => {
|
inputHandler.onAnsiColorChange(e => {
|
||||||
|
|||||||
@@ -2714,9 +2714,7 @@ export class InputHandler extends Disposable implements IInputHandler {
|
|||||||
this._iconName = data;
|
this._iconName = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is really an internal method and not part of IInputHandler implementation.
|
private _parseAnsiColorChange(data: string): IAnsiColorChangeEvent | null {
|
||||||
// Making it public so that I can test it.
|
|
||||||
public parseAnsiColorChange(data: string): IAnsiColorChangeEvent | null {
|
|
||||||
// example data: 5;rgb:aa/bb/cc
|
// example data: 5;rgb:aa/bb/cc
|
||||||
const regex = /(\d+);rgb:([0-9a-fA-F]{2})\/([0-9a-fA-F]{2})\/([0-9a-fA-F]{2})/;
|
const regex = /(\d+);rgb:([0-9a-fA-F]{2})\/([0-9a-fA-F]{2})\/([0-9a-fA-F]{2})/;
|
||||||
const match = data.match(regex);
|
const match = data.match(regex);
|
||||||
@@ -2739,7 +2737,7 @@ export class InputHandler extends Disposable implements IInputHandler {
|
|||||||
* `c` is the color index between 0 and 255. `spec` color format is 'rgb:hh/hh/hh' where `h` are hexadecimal digits.
|
* `c` is the color index between 0 and 255. `spec` color format is 'rgb:hh/hh/hh' where `h` are hexadecimal digits.
|
||||||
*/
|
*/
|
||||||
public setAnsiColor(data: string): void {
|
public setAnsiColor(data: string): void {
|
||||||
const event = this.parseAnsiColorChange(data);
|
const event = this._parseAnsiColorChange(data);
|
||||||
if (event) {
|
if (event) {
|
||||||
this._onAnsiColorChange.fire(event);
|
this._onAnsiColorChange.fire(event);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user