Merge branch 'master' into osc_colors
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
"appPort": 3000,
|
"appPort": 3000,
|
||||||
"extensions": [
|
"extensions": [
|
||||||
"dbaeumer.vscode-eslint",
|
"dbaeumer.vscode-eslint",
|
||||||
"editorconfig.editorconfig"
|
"editorconfig.editorconfig",
|
||||||
|
"hbenl.vscode-mocha-test-adapter"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-12
@@ -293,11 +293,11 @@ function initOptions(term: TerminalType): void {
|
|||||||
rendererType: ['dom', 'canvas'],
|
rendererType: ['dom', 'canvas'],
|
||||||
wordSeparator: null
|
wordSeparator: null
|
||||||
};
|
};
|
||||||
const options = Object.keys((<any>term)._core.options);
|
const options = Object.keys(term.options);
|
||||||
const booleanOptions = [];
|
const booleanOptions = [];
|
||||||
const numberOptions = [];
|
const numberOptions = [];
|
||||||
options.filter(o => blacklistedOptions.indexOf(o) === -1).forEach(o => {
|
options.filter(o => blacklistedOptions.indexOf(o) === -1).forEach(o => {
|
||||||
switch (typeof term.getOption(o)) {
|
switch (typeof term.options[o]) {
|
||||||
case 'boolean':
|
case 'boolean':
|
||||||
booleanOptions.push(o);
|
booleanOptions.push(o);
|
||||||
break;
|
break;
|
||||||
@@ -314,18 +314,18 @@ function initOptions(term: TerminalType): void {
|
|||||||
let html = '';
|
let html = '';
|
||||||
html += '<div class="option-group">';
|
html += '<div class="option-group">';
|
||||||
booleanOptions.forEach(o => {
|
booleanOptions.forEach(o => {
|
||||||
html += `<div class="option"><label><input id="opt-${o}" type="checkbox" ${term.getOption(o) ? 'checked' : ''}/> ${o}</label></div>`;
|
html += `<div class="option"><label><input id="opt-${o}" type="checkbox" ${term.options[o] ? 'checked' : ''}/> ${o}</label></div>`;
|
||||||
});
|
});
|
||||||
html += '</div><div class="option-group">';
|
html += '</div><div class="option-group">';
|
||||||
numberOptions.forEach(o => {
|
numberOptions.forEach(o => {
|
||||||
html += `<div class="option"><label>${o} <input id="opt-${o}" type="number" value="${term.getOption(o)}" step="${o === 'lineHeight' || o === 'scrollSensitivity' ? '0.1' : '1'}"/></label></div>`;
|
html += `<div class="option"><label>${o} <input id="opt-${o}" type="number" value="${term.options[o]}" step="${o === 'lineHeight' || o === 'scrollSensitivity' ? '0.1' : '1'}"/></label></div>`;
|
||||||
});
|
});
|
||||||
html += '</div><div class="option-group">';
|
html += '</div><div class="option-group">';
|
||||||
Object.keys(stringOptions).forEach(o => {
|
Object.keys(stringOptions).forEach(o => {
|
||||||
if (stringOptions[o]) {
|
if (stringOptions[o]) {
|
||||||
html += `<div class="option"><label>${o} <select id="opt-${o}">${stringOptions[o].map(v => `<option ${term.getOption(o) === v ? 'selected' : ''}>${v}</option>`).join('')}</select></label></div>`;
|
html += `<div class="option"><label>${o} <select id="opt-${o}">${stringOptions[o].map(v => `<option ${term.options[o] === v ? 'selected' : ''}>${v}</option>`).join('')}</select></label></div>`;
|
||||||
} else {
|
} else {
|
||||||
html += `<div class="option"><label>${o} <input id="opt-${o}" type="text" value="${term.getOption(o)}"/></label></div>`;
|
html += `<div class="option"><label>${o} <input id="opt-${o}" type="text" value="${term.options[o]}"/></label></div>`;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
@@ -338,7 +338,7 @@ function initOptions(term: TerminalType): void {
|
|||||||
const input = <HTMLInputElement>document.getElementById(`opt-${o}`);
|
const input = <HTMLInputElement>document.getElementById(`opt-${o}`);
|
||||||
addDomListener(input, 'change', () => {
|
addDomListener(input, 'change', () => {
|
||||||
console.log('change', o, input.checked);
|
console.log('change', o, input.checked);
|
||||||
term.setOption(o, input.checked);
|
term.options[o] = input.checked;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
numberOptions.forEach(o => {
|
numberOptions.forEach(o => {
|
||||||
@@ -347,14 +347,17 @@ function initOptions(term: TerminalType): void {
|
|||||||
console.log('change', o, input.value);
|
console.log('change', o, input.value);
|
||||||
if (o === 'cols' || o === 'rows') {
|
if (o === 'cols' || o === 'rows') {
|
||||||
updateTerminalSize();
|
updateTerminalSize();
|
||||||
} else if (o === 'lineHeight' || o === 'scrollSensitivity') {
|
} else if (o === 'lineHeight') {
|
||||||
term.setOption(o, parseFloat(input.value));
|
term.options.lineHeight = parseFloat(input.value);
|
||||||
|
updateTerminalSize();
|
||||||
|
} else if (o === 'scrollSensitivity') {
|
||||||
|
term.options.scrollSensitivity = parseFloat(input.value);
|
||||||
updateTerminalSize();
|
updateTerminalSize();
|
||||||
} else if(o === 'scrollback') {
|
} else if(o === 'scrollback') {
|
||||||
term.setOption(o, parseInt(input.value));
|
term.options.scrollback = parseInt(input.value);
|
||||||
setTimeout(() => updateTerminalSize(), 5);
|
setTimeout(() => updateTerminalSize(), 5);
|
||||||
} else {
|
} else {
|
||||||
term.setOption(o, parseInt(input.value));
|
term.options[o] = parseInt(input.value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -362,7 +365,7 @@ function initOptions(term: TerminalType): void {
|
|||||||
const input = <HTMLInputElement>document.getElementById(`opt-${o}`);
|
const input = <HTMLInputElement>document.getElementById(`opt-${o}`);
|
||||||
addDomListener(input, 'change', () => {
|
addDomListener(input, 'change', () => {
|
||||||
console.log('change', o, input.value);
|
console.log('change', o, input.value);
|
||||||
term.setOption(o, input.value);
|
term.options[o] = input.value;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ export class Terminal extends CoreTerminal implements ITerminal {
|
|||||||
* @alias module:xterm/src/xterm
|
* @alias module:xterm/src/xterm
|
||||||
*/
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
options: ITerminalOptions = {}
|
options: Partial<ITerminalOptions> = {}
|
||||||
) {
|
) {
|
||||||
super(options);
|
super(options);
|
||||||
|
|
||||||
@@ -536,7 +536,8 @@ export class Terminal extends CoreTerminal implements ITerminal {
|
|||||||
this.viewport = this._instantiationService.createInstance(Viewport,
|
this.viewport = this._instantiationService.createInstance(Viewport,
|
||||||
(amount: number) => this.scrollLines(amount, true, ScrollSource.VIEWPORT),
|
(amount: number) => this.scrollLines(amount, true, ScrollSource.VIEWPORT),
|
||||||
this._viewportElement,
|
this._viewportElement,
|
||||||
this._viewportScrollArea
|
this._viewportScrollArea,
|
||||||
|
this.element
|
||||||
);
|
);
|
||||||
this.viewport.onThemeChange(this._colorManager.colors);
|
this.viewport.onThemeChange(this._colorManager.colors);
|
||||||
this.register(this._inputHandler.onRequestSyncScrollBar(() => this.viewport!.syncScrollArea()));
|
this.register(this._inputHandler.onRequestSyncScrollBar(() => this.viewport!.syncScrollArea()));
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ export class Viewport extends Disposable implements IViewport {
|
|||||||
private readonly _scrollLines: (amount: number) => void,
|
private readonly _scrollLines: (amount: number) => void,
|
||||||
private readonly _viewportElement: HTMLElement,
|
private readonly _viewportElement: HTMLElement,
|
||||||
private readonly _scrollArea: HTMLElement,
|
private readonly _scrollArea: HTMLElement,
|
||||||
|
private readonly _element: HTMLElement,
|
||||||
@IBufferService private readonly _bufferService: IBufferService,
|
@IBufferService private readonly _bufferService: IBufferService,
|
||||||
@IOptionsService private readonly _optionsService: IOptionsService,
|
@IOptionsService private readonly _optionsService: IOptionsService,
|
||||||
@ICharSizeService private readonly _charSizeService: ICharSizeService,
|
@ICharSizeService private readonly _charSizeService: ICharSizeService,
|
||||||
@@ -116,7 +117,9 @@ export class Viewport extends Disposable implements IViewport {
|
|||||||
}
|
}
|
||||||
this._lastHadScrollBar = this.scrollBarWidth > 0;
|
this._lastHadScrollBar = this.scrollBarWidth > 0;
|
||||||
|
|
||||||
this._viewportElement.style.width = (this._renderService.dimensions.actualCellWidth * (this._bufferService.cols) + this.scrollBarWidth).toString() + 'px';
|
const elementStyle = window.getComputedStyle(this._element);
|
||||||
|
const elementPadding = parseInt(elementStyle.paddingLeft) + parseInt(elementStyle.paddingRight);
|
||||||
|
this._viewportElement.style.width = (this._renderService.dimensions.actualCellWidth * (this._bufferService.cols) + this.scrollBarWidth + (this._lastHadScrollBar ? elementPadding : 0)).toString() + 'px';
|
||||||
this._refreshAnimationFrame = null;
|
this._refreshAnimationFrame = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -89,6 +89,9 @@ export class Terminal implements ITerminalApi {
|
|||||||
wraparoundMode: m.wraparound
|
wraparoundMode: m.wraparound
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
public get options(): ITerminalOptions {
|
||||||
|
return this._core.options;
|
||||||
|
}
|
||||||
public blur(): void {
|
public blur(): void {
|
||||||
this._core.blur();
|
this._core.blur();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,9 +86,10 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
|
|||||||
public get cols(): number { return this._bufferService.cols; }
|
public get cols(): number { return this._bufferService.cols; }
|
||||||
public get rows(): number { return this._bufferService.rows; }
|
public get rows(): number { return this._bufferService.rows; }
|
||||||
public get buffers(): IBufferSet { return this._bufferService.buffers; }
|
public get buffers(): IBufferSet { return this._bufferService.buffers; }
|
||||||
|
public get options(): ITerminalOptions { return this.optionsService.publicOptions; }
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
options: ITerminalOptions
|
options: Partial<ITerminalOptions>
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
* @license MIT
|
* @license MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { IBufferService, ICoreService, ILogService, IOptionsService, ITerminalOptions, IPartialTerminalOptions, IDirtyRowService, ICoreMouseService, ICharsetService, IUnicodeService, IUnicodeVersionProvider, LogLevelEnum } from 'common/services/Services';
|
import { IBufferService, ICoreService, ILogService, IOptionsService, ITerminalOptions, IDirtyRowService, ICoreMouseService, ICharsetService, IUnicodeService, IUnicodeVersionProvider, LogLevelEnum } from 'common/services/Services';
|
||||||
import { IEvent, EventEmitter } from 'common/EventEmitter';
|
import { IEvent, EventEmitter } from 'common/EventEmitter';
|
||||||
import { clone } from 'common/Clone';
|
import { clone } from 'common/Clone';
|
||||||
import { DEFAULT_OPTIONS } from 'common/services/OptionsService';
|
import { DEFAULT_OPTIONS } from 'common/services/OptionsService';
|
||||||
@@ -121,11 +121,13 @@ export class MockLogService implements ILogService {
|
|||||||
export class MockOptionsService implements IOptionsService {
|
export class MockOptionsService implements IOptionsService {
|
||||||
public serviceBrand: any;
|
public serviceBrand: any;
|
||||||
public options: ITerminalOptions = clone(DEFAULT_OPTIONS);
|
public options: ITerminalOptions = clone(DEFAULT_OPTIONS);
|
||||||
|
public publicOptions: ITerminalOptions = clone(DEFAULT_OPTIONS);
|
||||||
public onOptionChange: IEvent<string> = new EventEmitter<string>().event;
|
public onOptionChange: IEvent<string> = new EventEmitter<string>().event;
|
||||||
constructor(testOptions?: IPartialTerminalOptions) {
|
constructor(testOptions?: Partial<ITerminalOptions>) {
|
||||||
if (testOptions) {
|
if (testOptions) {
|
||||||
for (const key of Object.keys(testOptions)) {
|
for (const key of Object.keys(testOptions)) {
|
||||||
this.options[key] = (testOptions as any)[key];
|
this.options[key] = testOptions[key];
|
||||||
|
this.publicOptions[key] = testOptions[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+1
@@ -16,6 +16,7 @@ export interface ICoreTerminal {
|
|||||||
optionsService: IOptionsService;
|
optionsService: IOptionsService;
|
||||||
unicodeService: IUnicodeService;
|
unicodeService: IUnicodeService;
|
||||||
buffers: IBufferSet;
|
buffers: IBufferSet;
|
||||||
|
options: ITerminalOptions;
|
||||||
registerCsiHandler(id: IFunctionIdentifier, callback: (params: IParams) => boolean | Promise<boolean>): IDisposable;
|
registerCsiHandler(id: IFunctionIdentifier, callback: (params: IParams) => boolean | Promise<boolean>): IDisposable;
|
||||||
registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: IParams) => boolean | Promise<boolean>): IDisposable;
|
registerDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: IParams) => boolean | Promise<boolean>): IDisposable;
|
||||||
registerEscHandler(id: IFunctionIdentifier, callback: () => boolean | Promise<boolean>): IDisposable;
|
registerEscHandler(id: IFunctionIdentifier, callback: () => boolean | Promise<boolean>): IDisposable;
|
||||||
|
|||||||
@@ -3,10 +3,9 @@
|
|||||||
* @license MIT
|
* @license MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { IOptionsService, ITerminalOptions, IPartialTerminalOptions, FontWeight } from 'common/services/Services';
|
import { IOptionsService, ITerminalOptions, FontWeight } from 'common/services/Services';
|
||||||
import { EventEmitter, IEvent } from 'common/EventEmitter';
|
import { EventEmitter, IEvent } from 'common/EventEmitter';
|
||||||
import { isMac } from 'common/Platform';
|
import { isMac } from 'common/Platform';
|
||||||
import { clone } from 'common/Clone';
|
|
||||||
|
|
||||||
// Source: https://freesound.org/people/altemark/sounds/45759/
|
// Source: https://freesound.org/people/altemark/sounds/45759/
|
||||||
// This sound is released under the Creative Commons Attribution 3.0 Unported
|
// This sound is released under the Creative Commons Attribution 3.0 Unported
|
||||||
@@ -14,15 +13,14 @@ import { clone } from 'common/Clone';
|
|||||||
// made, apart from the conversion to base64.
|
// made, apart from the conversion to base64.
|
||||||
export const DEFAULT_BELL_SOUND = 'data:audio/mp3;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4LjMyLjEwNAAAAAAAAAAAAAAA//tQxAADB8AhSmxhIIEVCSiJrDCQBTcu3UrAIwUdkRgQbFAZC1CQEwTJ9mjRvBA4UOLD8nKVOWfh+UlK3z/177OXrfOdKl7pyn3Xf//WreyTRUoAWgBgkOAGbZHBgG1OF6zM82DWbZaUmMBptgQhGjsyYqc9ae9XFz280948NMBWInljyzsNRFLPWdnZGWrddDsjK1unuSrVN9jJsK8KuQtQCtMBjCEtImISdNKJOopIpBFpNSMbIHCSRpRR5iakjTiyzLhchUUBwCgyKiweBv/7UsQbg8isVNoMPMjAAAA0gAAABEVFGmgqK////9bP/6XCykxBTUUzLjEwMKqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq';
|
export const DEFAULT_BELL_SOUND = 'data:audio/mp3;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4LjMyLjEwNAAAAAAAAAAAAAAA//tQxAADB8AhSmxhIIEVCSiJrDCQBTcu3UrAIwUdkRgQbFAZC1CQEwTJ9mjRvBA4UOLD8nKVOWfh+UlK3z/177OXrfOdKl7pyn3Xf//WreyTRUoAWgBgkOAGbZHBgG1OF6zM82DWbZaUmMBptgQhGjsyYqc9ae9XFz280948NMBWInljyzsNRFLPWdnZGWrddDsjK1unuSrVN9jJsK8KuQtQCtMBjCEtImISdNKJOopIpBFpNSMbIHCSRpRR5iakjTiyzLhchUUBwCgyKiweBv/7UsQbg8isVNoMPMjAAAA0gAAABEVFGmgqK////9bP/6XCykxBTUUzLjEwMKqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq';
|
||||||
|
|
||||||
// TODO: Freeze?
|
export const DEFAULT_OPTIONS: Readonly<ITerminalOptions> = {
|
||||||
export const DEFAULT_OPTIONS: ITerminalOptions = Object.freeze({
|
|
||||||
cols: 80,
|
cols: 80,
|
||||||
rows: 24,
|
rows: 24,
|
||||||
cursorBlink: false,
|
cursorBlink: false,
|
||||||
cursorStyle: 'block',
|
cursorStyle: 'block',
|
||||||
cursorWidth: 1,
|
cursorWidth: 1,
|
||||||
customGlyphs: true,
|
customGlyphs: true,
|
||||||
bellSound: DEFAULT_BELL_SOUND,
|
bellSound: DEFAULT_BELL_SOUND,
|
||||||
bellStyle: 'none',
|
bellStyle: 'none',
|
||||||
drawBoldTextInBrightColors: true,
|
drawBoldTextInBrightColors: true,
|
||||||
fastScrollModifier: 'alt',
|
fastScrollModifier: 'alt',
|
||||||
@@ -55,7 +53,7 @@ export const DEFAULT_OPTIONS: ITerminalOptions = Object.freeze({
|
|||||||
convertEol: false,
|
convertEol: false,
|
||||||
termName: 'xterm',
|
termName: 'xterm',
|
||||||
cancelEvents: false
|
cancelEvents: false
|
||||||
});
|
};
|
||||||
|
|
||||||
const FONT_WEIGHT_OPTIONS: Extract<FontWeight, string>[] = ['normal', 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900'];
|
const FONT_WEIGHT_OPTIONS: Extract<FontWeight, string>[] = ['normal', 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900'];
|
||||||
|
|
||||||
@@ -67,45 +65,68 @@ const CONSTRUCTOR_ONLY_OPTIONS = ['cols', 'rows'];
|
|||||||
export class OptionsService implements IOptionsService {
|
export class OptionsService implements IOptionsService {
|
||||||
public serviceBrand: any;
|
public serviceBrand: any;
|
||||||
|
|
||||||
|
private _options: ITerminalOptions;
|
||||||
public options: ITerminalOptions;
|
public options: ITerminalOptions;
|
||||||
|
public publicOptions: ITerminalOptions;
|
||||||
|
|
||||||
private _onOptionChange = new EventEmitter<string>();
|
private _onOptionChange = new EventEmitter<string>();
|
||||||
public get onOptionChange(): IEvent<string> { return this._onOptionChange.event; }
|
public get onOptionChange(): IEvent<string> { return this._onOptionChange.event; }
|
||||||
|
|
||||||
constructor(options: IPartialTerminalOptions) {
|
constructor(options: Partial<ITerminalOptions>) {
|
||||||
this.options = clone(DEFAULT_OPTIONS);
|
// set the default value of each option
|
||||||
for (const k of Object.keys(options)) {
|
this._options = { ...DEFAULT_OPTIONS };
|
||||||
if (k in this.options) {
|
for (const key in options) {
|
||||||
|
if (key in this._options) {
|
||||||
try {
|
try {
|
||||||
const newValue = options[k as keyof IPartialTerminalOptions] as any;
|
const newValue = options[key];
|
||||||
this.options[k] = this._sanitizeAndValidateOption(k, newValue);
|
this._options[key] = this._sanitizeAndValidateOption(key, newValue);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set up getters and setters for each option
|
||||||
|
this.options = this._setupOptions(this._options, false);
|
||||||
|
this.publicOptions = this._setupOptions(this._options, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private _setupOptions(options: ITerminalOptions, isPublic: boolean): ITerminalOptions {
|
||||||
|
const copiedOptions = { ... options };
|
||||||
|
for (const propName in copiedOptions) {
|
||||||
|
Object.defineProperty(copiedOptions, propName, {
|
||||||
|
get: () => {
|
||||||
|
if (!(propName in DEFAULT_OPTIONS)) {
|
||||||
|
throw new Error(`No option with key "${propName}"`);
|
||||||
|
}
|
||||||
|
return this._options[propName];
|
||||||
|
},
|
||||||
|
set: (value: any) => {
|
||||||
|
if (!(propName in DEFAULT_OPTIONS)) {
|
||||||
|
throw new Error(`No option with key "${propName}"`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Throw an error if any constructor only option is modified
|
||||||
|
// from terminal.options
|
||||||
|
// Modifications from anywhere else are allowed
|
||||||
|
if (isPublic && CONSTRUCTOR_ONLY_OPTIONS.includes(propName)) {
|
||||||
|
throw new Error(`Option "${propName}" can only be set in the constructor`);
|
||||||
|
}
|
||||||
|
|
||||||
|
value = this._sanitizeAndValidateOption(propName, value);
|
||||||
|
// Don't fire an option change event if they didn't change
|
||||||
|
if (this._options[propName] !== value) {
|
||||||
|
this._options[propName] = value;
|
||||||
|
this._onOptionChange.fire(propName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return copiedOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public setOption(key: string, value: any): void {
|
public setOption(key: string, value: any): void {
|
||||||
if (!(key in DEFAULT_OPTIONS)) {
|
this.publicOptions[key] = value;
|
||||||
throw new Error('No option with key "' + key + '"');
|
|
||||||
}
|
|
||||||
if (CONSTRUCTOR_ONLY_OPTIONS.includes(key)) {
|
|
||||||
throw new Error(`Option "${key}" can only be set in the constructor`);
|
|
||||||
}
|
|
||||||
if (this.options[key] === value) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
value = this._sanitizeAndValidateOption(key, value);
|
|
||||||
|
|
||||||
// Don't fire an option change event if they didn't change
|
|
||||||
if (this.options[key] === value) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.options[key] = value;
|
|
||||||
this._onOptionChange.fire(key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private _sanitizeAndValidateOption(key: string, value: any): any {
|
private _sanitizeAndValidateOption(key: string, value: any): any {
|
||||||
@@ -160,9 +181,6 @@ export class OptionsService implements IOptionsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getOption(key: string): any {
|
public getOption(key: string): any {
|
||||||
if (!(key in DEFAULT_OPTIONS)) {
|
return this.publicOptions[key];
|
||||||
throw new Error(`No option with key "${key}"`);
|
|
||||||
}
|
|
||||||
return this.options[key];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -181,6 +181,7 @@ export interface IOptionsService {
|
|||||||
serviceBrand: undefined;
|
serviceBrand: undefined;
|
||||||
|
|
||||||
readonly options: ITerminalOptions;
|
readonly options: ITerminalOptions;
|
||||||
|
readonly publicOptions: ITerminalOptions;
|
||||||
|
|
||||||
readonly onOptionChange: IEvent<string>;
|
readonly onOptionChange: IEvent<string>;
|
||||||
|
|
||||||
@@ -199,41 +200,6 @@ export enum LogLevelEnum {
|
|||||||
}
|
}
|
||||||
export type RendererType = 'dom' | 'canvas';
|
export type RendererType = 'dom' | 'canvas';
|
||||||
|
|
||||||
export interface IPartialTerminalOptions {
|
|
||||||
altClickMovesCursor?: boolean;
|
|
||||||
allowTransparency?: boolean;
|
|
||||||
bellSound?: string;
|
|
||||||
bellStyle?: 'none' | 'sound' /* | 'visual' | 'both' */;
|
|
||||||
cols?: number;
|
|
||||||
cursorBlink?: boolean;
|
|
||||||
cursorStyle?: 'block' | 'underline' | 'bar';
|
|
||||||
cursorWidth?: number;
|
|
||||||
disableStdin?: boolean;
|
|
||||||
drawBoldTextInBrightColors?: boolean;
|
|
||||||
fastScrollModifier?: 'alt' | 'ctrl' | 'shift';
|
|
||||||
fastScrollSensitivity?: number;
|
|
||||||
fontSize?: number;
|
|
||||||
fontFamily?: string;
|
|
||||||
fontWeight?: FontWeight;
|
|
||||||
fontWeightBold?: FontWeight;
|
|
||||||
letterSpacing?: number;
|
|
||||||
lineHeight?: number;
|
|
||||||
logLevel?: LogLevel;
|
|
||||||
macOptionIsMeta?: boolean;
|
|
||||||
macOptionClickForcesSelection?: boolean;
|
|
||||||
rendererType?: RendererType;
|
|
||||||
rightClickSelectsWord?: boolean;
|
|
||||||
rows?: number;
|
|
||||||
screenReaderMode?: boolean;
|
|
||||||
scrollback?: number;
|
|
||||||
scrollSensitivity?: number;
|
|
||||||
tabStopWidth?: number;
|
|
||||||
theme?: ITheme;
|
|
||||||
windowsMode?: boolean;
|
|
||||||
wordSeparator?: string;
|
|
||||||
windowOptions?: IWindowOptions;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ITerminalOptions {
|
export interface ITerminalOptions {
|
||||||
allowProposedApi: boolean;
|
allowProposedApi: boolean;
|
||||||
allowTransparency: boolean;
|
allowTransparency: boolean;
|
||||||
|
|||||||
Vendored
+28
-8
@@ -635,6 +635,11 @@ declare module 'xterm' {
|
|||||||
*/
|
*/
|
||||||
readonly modes: IModes;
|
readonly modes: IModes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the terminal options
|
||||||
|
*/
|
||||||
|
readonly options: ITerminalOptions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Natural language strings that can be localized.
|
* Natural language strings that can be localized.
|
||||||
*/
|
*/
|
||||||
@@ -964,26 +969,31 @@ declare module 'xterm' {
|
|||||||
/**
|
/**
|
||||||
* Retrieves an option's value from the terminal.
|
* Retrieves an option's value from the terminal.
|
||||||
* @param key The option key.
|
* @param key The option key.
|
||||||
|
* @deprecated Use `options` instead.
|
||||||
*/
|
*/
|
||||||
getOption(key: 'bellSound' | 'bellStyle' | 'cursorStyle' | 'fontFamily' | 'logLevel' | 'rendererType' | 'termName' | 'wordSeparator'): string;
|
getOption(key: 'bellSound' | 'bellStyle' | 'cursorStyle' | 'fontFamily' | 'logLevel' | 'rendererType' | 'termName' | 'wordSeparator'): string;
|
||||||
/**
|
/**
|
||||||
* Retrieves an option's value from the terminal.
|
* Retrieves an option's value from the terminal.
|
||||||
* @param key The option key.
|
* @param key The option key.
|
||||||
|
* @deprecated Use `options` instead.
|
||||||
*/
|
*/
|
||||||
getOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell' | 'windowsMode'): boolean;
|
getOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell' | 'windowsMode'): boolean;
|
||||||
/**
|
/**
|
||||||
* Retrieves an option's value from the terminal.
|
* Retrieves an option's value from the terminal.
|
||||||
* @param key The option key.
|
* @param key The option key.
|
||||||
|
* @deprecated Use `options` instead.
|
||||||
*/
|
*/
|
||||||
getOption(key: 'cols' | 'fontSize' | 'letterSpacing' | 'lineHeight' | 'rows' | 'tabStopWidth' | 'scrollback'): number;
|
getOption(key: 'cols' | 'fontSize' | 'letterSpacing' | 'lineHeight' | 'rows' | 'tabStopWidth' | 'scrollback'): number;
|
||||||
/**
|
/**
|
||||||
* Retrieves an option's value from the terminal.
|
* Retrieves an option's value from the terminal.
|
||||||
* @param key The option key.
|
* @param key The option key.
|
||||||
|
* @deprecated Use `options` instead.
|
||||||
*/
|
*/
|
||||||
getOption(key: 'fontWeight' | 'fontWeightBold'): FontWeight;
|
getOption(key: 'fontWeight' | 'fontWeightBold'): FontWeight;
|
||||||
/**
|
/**
|
||||||
* Retrieves an option's value from the terminal.
|
* Retrieves an option's value from the terminal.
|
||||||
* @param key The option key.
|
* @param key The option key.
|
||||||
|
* @deprecated Use `options` instead.
|
||||||
*/
|
*/
|
||||||
getOption(key: string): any;
|
getOption(key: string): any;
|
||||||
|
|
||||||
@@ -991,60 +1001,70 @@ declare module 'xterm' {
|
|||||||
* Sets an option on the terminal.
|
* Sets an option on the terminal.
|
||||||
* @param key The option key.
|
* @param key The option key.
|
||||||
* @param value The option value.
|
* @param value The option value.
|
||||||
|
* @deprecated Use `options` instead.
|
||||||
*/
|
*/
|
||||||
setOption(key: 'fontFamily' | 'termName' | 'bellSound' | 'wordSeparator', value: string): void;
|
setOption(key: 'fontFamily' | 'termName' | 'bellSound' | 'wordSeparator', value: string): void;
|
||||||
/**
|
/**
|
||||||
* Sets an option on the terminal.
|
* Sets an option on the terminal.
|
||||||
* @param key The option key.
|
* @param key The option key.
|
||||||
* @param value The option value.
|
* @param value The option value.
|
||||||
*/
|
* @deprecated Use `options` instead.
|
||||||
|
*/
|
||||||
setOption(key: 'fontWeight' | 'fontWeightBold', value: null | 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | number): void;
|
setOption(key: 'fontWeight' | 'fontWeightBold', value: null | 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | number): void;
|
||||||
/**
|
/**
|
||||||
* Sets an option on the terminal.
|
* Sets an option on the terminal.
|
||||||
* @param key The option key.
|
* @param key The option key.
|
||||||
* @param value The option value.
|
* @param value The option value.
|
||||||
*/
|
* @deprecated Use `options` instead.
|
||||||
|
*/
|
||||||
setOption(key: 'logLevel', value: LogLevel): void;
|
setOption(key: 'logLevel', value: LogLevel): void;
|
||||||
/**
|
/**
|
||||||
* Sets an option on the terminal.
|
* Sets an option on the terminal.
|
||||||
* @param key The option key.
|
* @param key The option key.
|
||||||
* @param value The option value.
|
* @param value The option value.
|
||||||
|
* @deprecated Use `options` instead.
|
||||||
*/
|
*/
|
||||||
setOption(key: 'bellStyle', value: null | 'none' | 'visual' | 'sound' | 'both'): void;
|
setOption(key: 'bellStyle', value: null | 'none' | 'visual' | 'sound' | 'both'): void;
|
||||||
/**
|
/**
|
||||||
* Sets an option on the terminal.
|
* Sets an option on the terminal.
|
||||||
* @param key The option key.
|
* @param key The option key.
|
||||||
* @param value The option value.
|
* @param value The option value.
|
||||||
|
* @deprecated Use `options` instead.
|
||||||
*/
|
*/
|
||||||
setOption(key: 'cursorStyle', value: null | 'block' | 'underline' | 'bar'): void;
|
setOption(key: 'cursorStyle', value: null | 'block' | 'underline' | 'bar'): void;
|
||||||
/**
|
/**
|
||||||
* Sets an option on the terminal.
|
* Sets an option on the terminal.
|
||||||
* @param key The option key.
|
* @param key The option key.
|
||||||
* @param value The option value.
|
* @param value The option value.
|
||||||
|
* @deprecated Use `options` instead.
|
||||||
*/
|
*/
|
||||||
setOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'popOnBell' | 'rightClickSelectsWord' | 'visualBell' | 'windowsMode', value: boolean): void;
|
setOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'popOnBell' | 'rightClickSelectsWord' | 'visualBell' | 'windowsMode', value: boolean): void;
|
||||||
/**
|
/**
|
||||||
* Sets an option on the terminal.
|
* Sets an option on the terminal.
|
||||||
* @param key The option key.
|
* @param key The option key.
|
||||||
* @param value The option value.
|
* @param value The option value.
|
||||||
|
* @deprecated Use `options` instead.
|
||||||
*/
|
*/
|
||||||
setOption(key: 'fontSize' | 'letterSpacing' | 'lineHeight' | 'tabStopWidth' | 'scrollback', value: number): void;
|
setOption(key: 'fontSize' | 'letterSpacing' | 'lineHeight' | 'tabStopWidth' | 'scrollback', value: number): void;
|
||||||
/**
|
/**
|
||||||
* Sets an option on the terminal.
|
* Sets an option on the terminal.
|
||||||
* @param key The option key.
|
* @param key The option key.
|
||||||
* @param value The option value.
|
* @param value The option value.
|
||||||
|
* @deprecated Use `options` instead.
|
||||||
*/
|
*/
|
||||||
setOption(key: 'theme', value: ITheme): void;
|
setOption(key: 'theme', value: ITheme): void;
|
||||||
/**
|
/**
|
||||||
* Sets an option on the terminal.
|
* Sets an option on the terminal.
|
||||||
* @param key The option key.
|
* @param key The option key.
|
||||||
* @param value The option value.
|
* @param value The option value.
|
||||||
|
* @deprecated Use `options` instead.
|
||||||
*/
|
*/
|
||||||
setOption(key: 'cols' | 'rows', value: number): void;
|
setOption(key: 'cols' | 'rows', value: number): void;
|
||||||
/**
|
/**
|
||||||
* Sets an option on the terminal.
|
* Sets an option on the terminal.
|
||||||
* @param key The option key.
|
* @param key The option key.
|
||||||
* @param value The option value.
|
* @param value The option value.
|
||||||
|
* @deprecated Use `options` instead.
|
||||||
*/
|
*/
|
||||||
setOption(key: string, value: any): void;
|
setOption(key: string, value: any): void;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user