Merge branch 'master' into 1140
This commit is contained in:
@@ -136,12 +136,6 @@ export class MockOptionsService implements IOptionsService {
|
||||
this.options[key] = options[key];
|
||||
}
|
||||
}
|
||||
public setOption<T>(key: string, value: T): void {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
public getOption<T>(key: string): T {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
}
|
||||
|
||||
// defaults to V6 always to keep tests passing
|
||||
|
||||
@@ -17,16 +17,16 @@ describe('OptionsService', () => {
|
||||
});
|
||||
it('uses default value if invalid constructor option values passed for cols/rows', () => {
|
||||
const optionsService = new OptionsService({ cols: undefined, rows: undefined });
|
||||
assert.equal(optionsService.getOption('rows'), DEFAULT_OPTIONS.rows);
|
||||
assert.equal(optionsService.getOption('cols'), DEFAULT_OPTIONS.cols);
|
||||
assert.equal(optionsService.options.rows, DEFAULT_OPTIONS.rows);
|
||||
assert.equal(optionsService.options.cols, DEFAULT_OPTIONS.cols);
|
||||
});
|
||||
it('uses values from constructor option values if correctly passed', () => {
|
||||
const optionsService = new OptionsService({ cols: 80, rows: 25 });
|
||||
assert.equal(optionsService.getOption('rows'), 25);
|
||||
assert.equal(optionsService.getOption('cols'), 80);
|
||||
assert.equal(optionsService.options.rows, 25);
|
||||
assert.equal(optionsService.options.cols, 80);
|
||||
});
|
||||
it('uses default value if invalid constructor option value passed', () => {
|
||||
assert.equal(new OptionsService({ tabStopWidth: 0 }).getOption('tabStopWidth'), DEFAULT_OPTIONS.tabStopWidth);
|
||||
assert.equal(new OptionsService({ tabStopWidth: 0 }).options.tabStopWidth, DEFAULT_OPTIONS.tabStopWidth);
|
||||
});
|
||||
it('object.keys return the correct number of options', () => {
|
||||
const optionsService = new OptionsService({ cols: 80, rows: 25 });
|
||||
@@ -39,36 +39,36 @@ describe('OptionsService', () => {
|
||||
service = new OptionsService({});
|
||||
});
|
||||
it('applies valid fontWeight option values', () => {
|
||||
service.setOption('fontWeight', 'bold');
|
||||
assert.equal(service.getOption('fontWeight'), 'bold', '"bold" keyword value should be applied');
|
||||
service.options.fontWeight = 'bold';
|
||||
assert.equal(service.options.fontWeight, 'bold', '"bold" keyword value should be applied');
|
||||
|
||||
service.setOption('fontWeight', 'normal');
|
||||
assert.equal(service.getOption('fontWeight'), 'normal', '"normal" keyword value should be applied');
|
||||
service.options.fontWeight = 'normal';
|
||||
assert.equal(service.options.fontWeight, 'normal', '"normal" keyword value should be applied');
|
||||
|
||||
service.setOption('fontWeight', '600');
|
||||
assert.equal(service.getOption('fontWeight'), '600', 'String numeric values should be applied');
|
||||
service.options.fontWeight = '600';
|
||||
assert.equal(service.options.fontWeight, '600', 'String numeric values should be applied');
|
||||
|
||||
service.setOption('fontWeight', 350);
|
||||
assert.equal(service.getOption('fontWeight'), 350, 'Values between 1 and 1000 should be applied as is');
|
||||
service.options.fontWeight = 350;
|
||||
assert.equal(service.options.fontWeight, 350, 'Values between 1 and 1000 should be applied as is');
|
||||
|
||||
service.setOption('fontWeight', 1);
|
||||
assert.equal(service.getOption('fontWeight'), 1, 'Range should include minimum value: 1');
|
||||
service.options.fontWeight = 1;
|
||||
assert.equal(service.options.fontWeight, 1, 'Range should include minimum value: 1');
|
||||
|
||||
service.setOption('fontWeight', 1000);
|
||||
assert.equal(service.getOption('fontWeight'), 1000, 'Range should include maximum value: 1000');
|
||||
service.options.fontWeight = 1000;
|
||||
assert.equal(service.options.fontWeight, 1000, 'Range should include maximum value: 1000');
|
||||
});
|
||||
it('normalizes invalid fontWeight option values', () => {
|
||||
service.setOption('fontWeight', 350);
|
||||
assert.doesNotThrow(() => service.setOption('fontWeight', 10000), 'fontWeight should be normalized instead of throwing');
|
||||
assert.equal(service.getOption('fontWeight'), DEFAULT_OPTIONS.fontWeight, 'Values greater than 1000 should be reset to default');
|
||||
service.options.fontWeight = 350;
|
||||
assert.doesNotThrow(() => service.options.fontWeight = 10000), 'fontWeight should be normalized instead of throwing';
|
||||
assert.equal(service.options.fontWeight, DEFAULT_OPTIONS.fontWeight, 'Values greater than 1000 should be reset to default');
|
||||
|
||||
service.setOption('fontWeight', 350);
|
||||
service.setOption('fontWeight', -10);
|
||||
assert.equal(service.getOption('fontWeight'), DEFAULT_OPTIONS.fontWeight, 'Values less than 1 should be reset to default');
|
||||
service.options.fontWeight = 350;
|
||||
service.options.fontWeight = -10;
|
||||
assert.equal(service.options.fontWeight, DEFAULT_OPTIONS.fontWeight, 'Values less than 1 should be reset to default');
|
||||
|
||||
service.setOption('fontWeight', 350);
|
||||
service.setOption('fontWeight', 'bold700');
|
||||
assert.equal(service.getOption('fontWeight'), DEFAULT_OPTIONS.fontWeight, 'Wrong string literals should be reset to default');
|
||||
service.options.fontWeight = 350;
|
||||
service.options.fontWeight = 'bold700' as any;
|
||||
assert.equal(service.options.fontWeight, DEFAULT_OPTIONS.fontWeight, 'Wrong string literals should be reset to default');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -8,12 +8,6 @@ import { EventEmitter, IEvent } from 'common/EventEmitter';
|
||||
import { isMac } from 'common/Platform';
|
||||
import { CursorStyle } from 'common/Types';
|
||||
|
||||
// Source: https://freesound.org/people/altemark/sounds/45759/
|
||||
// This sound is released under the Creative Commons Attribution 3.0 Unported
|
||||
// (CC BY 3.0) license. It was created by 'altemark'. No modifications have been
|
||||
// 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_OPTIONS: Readonly<ITerminalOptions> = {
|
||||
cols: 80,
|
||||
rows: 24,
|
||||
@@ -21,8 +15,6 @@ export const DEFAULT_OPTIONS: Readonly<ITerminalOptions> = {
|
||||
cursorStyle: 'block',
|
||||
cursorWidth: 1,
|
||||
customGlyphs: true,
|
||||
bellSound: DEFAULT_BELL_SOUND,
|
||||
bellStyle: 'none',
|
||||
drawBoldTextInBrightColors: true,
|
||||
fastScrollModifier: 'alt',
|
||||
fastScrollSensitivity: 5,
|
||||
@@ -31,7 +23,6 @@ export const DEFAULT_OPTIONS: Readonly<ITerminalOptions> = {
|
||||
fontWeight: 'normal',
|
||||
fontWeightBold: 'bold',
|
||||
lineHeight: 1.0,
|
||||
linkTooltipHoverDuration: 500,
|
||||
letterSpacing: 0,
|
||||
logLevel: 'info',
|
||||
scrollback: 1000,
|
||||
@@ -42,12 +33,11 @@ export const DEFAULT_OPTIONS: Readonly<ITerminalOptions> = {
|
||||
macOptionClickForcesSelection: false,
|
||||
minimumContrastRatio: 1,
|
||||
disableStdin: false,
|
||||
allowProposedApi: true,
|
||||
allowProposedApi: false,
|
||||
allowTransparency: false,
|
||||
tabStopWidth: 8,
|
||||
theme: {},
|
||||
rightClickSelectsWord: isMac,
|
||||
rendererType: 'canvas',
|
||||
windowOptions: {},
|
||||
windowsMode: false,
|
||||
wordSeparator: ' ()[]{}\',"`',
|
||||
@@ -119,10 +109,6 @@ export class OptionsService implements IOptionsService {
|
||||
}
|
||||
}
|
||||
|
||||
public setOption(key: string, value: any): void {
|
||||
this.options[key] = value;
|
||||
}
|
||||
|
||||
private _sanitizeAndValidateOption(key: string, value: any): any {
|
||||
switch (key) {
|
||||
case 'cursorStyle':
|
||||
@@ -133,9 +119,7 @@ export class OptionsService implements IOptionsService {
|
||||
throw new Error(`"${value}" is not a valid value for ${key}`);
|
||||
}
|
||||
break;
|
||||
case 'bellStyle':
|
||||
case 'cursorStyle':
|
||||
case 'rendererType':
|
||||
case 'wordSeparator':
|
||||
if (!value) {
|
||||
value = DEFAULT_OPTIONS[key];
|
||||
@@ -181,10 +165,6 @@ export class OptionsService implements IOptionsService {
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public getOption(key: string): any {
|
||||
return this.options[key];
|
||||
}
|
||||
}
|
||||
|
||||
function isCursorStyle(value: unknown): value is CursorStyle {
|
||||
|
||||
@@ -198,22 +198,15 @@ export interface IOptionsService {
|
||||
readonly options: ITerminalOptions;
|
||||
|
||||
readonly onOptionChange: IEvent<string>;
|
||||
|
||||
setOption<T>(key: string, value: T): void;
|
||||
getOption<T>(key: string): T | undefined;
|
||||
}
|
||||
|
||||
export type FontWeight = 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | number;
|
||||
export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'off';
|
||||
|
||||
export type RendererType = 'dom' | 'canvas';
|
||||
|
||||
export interface ITerminalOptions {
|
||||
allowProposedApi: boolean;
|
||||
allowTransparency: boolean;
|
||||
altClickMovesCursor: boolean;
|
||||
bellSound: string;
|
||||
bellStyle: 'none' | 'sound' /* | 'visual' | 'both' */;
|
||||
cols: number;
|
||||
convertEol: boolean;
|
||||
cursorBlink: boolean;
|
||||
@@ -230,12 +223,10 @@ export interface ITerminalOptions {
|
||||
fontWeightBold: FontWeight;
|
||||
letterSpacing: number;
|
||||
lineHeight: number;
|
||||
linkTooltipHoverDuration: number;
|
||||
logLevel: LogLevel;
|
||||
macOptionIsMeta: boolean;
|
||||
macOptionClickForcesSelection: boolean;
|
||||
minimumContrastRatio: number;
|
||||
rendererType: RendererType;
|
||||
rightClickSelectsWord: boolean;
|
||||
rows: number;
|
||||
screenReaderMode: boolean;
|
||||
|
||||
Reference in New Issue
Block a user