Add rudimenatary and not fully working support of OSC 4

This commit is contained in:
Slawek Zachcial
2020-11-03 18:36:28 +01:00
parent 02e4db4c82
commit 5c7644adc0
3 changed files with 35 additions and 0 deletions
+17
View File
@@ -53,6 +53,7 @@ import { Linkifier2 } from 'browser/Linkifier2';
import { CoreBrowserService } from 'browser/services/CoreBrowserService';
import { CoreTerminal } from 'common/CoreTerminal';
import { ITerminalOptions as IInitializedTerminalOptions } from 'common/services/Services';
import { css } from 'browser/Color';
// Let it work inside Node.js for automated testing purposes.
const document: Document = (typeof window !== 'undefined') ? window.document : null as any;
@@ -150,6 +151,7 @@ export class Terminal extends CoreTerminal implements ITerminal {
this.register(this._inputHandler.onRequestWindowsOptionsReport(type => this._reportWindowsOptions(type)));
this.register(forwardEvent(this._inputHandler.onCursorMove, this._onCursorMove));
this.register(forwardEvent(this._inputHandler.onTitleChange, this._onTitleChange));
this.register(this._inputHandler.onAnsiColorChange((index, color) => this.changeAnsiColor(index, color)));
this.register(forwardEvent(this._inputHandler.onA11yChar, this._onA11yCharEmitter));
this.register(forwardEvent(this._inputHandler.onA11yTab, this._onA11yTabEmitter));
@@ -157,6 +159,21 @@ export class Terminal extends CoreTerminal implements ITerminal {
this.register(this._bufferService.onResize(e => this._afterResize(e.cols, e.rows)));
}
private changeAnsiColor(colorIndex: number, colorValue: string): void {
// colorValue = rgb:xx/yy/zz
const r = colorValue.substring(4, 6);
const g = colorValue.substring(7, 9);
const b = colorValue.substring(10, 12);
const color = `#${r}${g}${b}`;
//TODO: remove debug
console.log(`Change ANSI color[${colorIndex}]=${colorValue} (${color})`);
this._colorManager!.colors.ansi[colorIndex] = css.toColor(color);
this._renderService?.setColors(this._colorManager!.colors);
this.viewport?.onThemeChange(this._colorManager!.colors);
}
public dispose(): void {
if (this._isDisposed) {
return;