fix test and replace options with rawOptions

This commit is contained in:
Simon Lamon
2022-01-08 08:20:50 +00:00
parent 65182176b9
commit 1dcc1d1baf
21 changed files with 84 additions and 79 deletions
+1 -1
View File
@@ -150,7 +150,7 @@ export class MouseZoneManager extends Disposable implements IMouseZoneManager {
} }
// Restart the tooltip timeout // Restart the tooltip timeout
this._tooltipTimeout = window.setTimeout(() => this._onTooltip(e), this._optionsService.options.linkTooltipHoverDuration); this._tooltipTimeout = window.setTimeout(() => this._onTooltip(e), this._optionsService.rawOptions.linkTooltipHoverDuration);
} }
private _onTooltip(e: MouseEvent): void { private _onTooltip(e: MouseEvent): void {
+5 -5
View File
@@ -260,7 +260,7 @@ export class Terminal extends CoreTerminal implements ITerminal {
this.viewport?.syncScrollArea(); this.viewport?.syncScrollArea();
break; break;
case 'screenReaderMode': case 'screenReaderMode':
if (this.optionsService.options.screenReaderMode) { if (this.optionsService.rawOptions.screenReaderMode) {
if (!this._accessibilityManager && this._renderService) { if (!this._accessibilityManager && this._renderService) {
this._accessibilityManager = new AccessibilityManager(this, this._renderService); this._accessibilityManager = new AccessibilityManager(this, this._renderService);
} }
@@ -271,7 +271,7 @@ export class Terminal extends CoreTerminal implements ITerminal {
break; break;
case 'tabStopWidth': this.buffers.setupTabStops(); break; case 'tabStopWidth': this.buffers.setupTabStops(); break;
case 'theme': case 'theme':
this._setTheme(this.optionsService.options.theme); this._setTheme(this.optionsService.rawOptions.theme);
break; break;
} }
} }
@@ -715,7 +715,7 @@ export class Terminal extends CoreTerminal implements ITerminal {
this.register(this.coreMouseService.onProtocolChange(events => { this.register(this.coreMouseService.onProtocolChange(events => {
// apply global changes on events // apply global changes on events
if (events) { if (events) {
if (this.optionsService.options.logLevel === 'debug') { if (this.optionsService.rawOptions.logLevel === 'debug') {
this._logService.debug('Binding to mouse events:', this.coreMouseService.explainEvents(events)); this._logService.debug('Binding to mouse events:', this.coreMouseService.explainEvents(events));
} }
this.element!.classList.add('enable-mouse-events'); this.element!.classList.add('enable-mouse-events');
@@ -1087,7 +1087,7 @@ export class Terminal extends CoreTerminal implements ITerminal {
// other listeners. When screen reader mode is enabled, this could cause issues if the event // other listeners. When screen reader mode is enabled, this could cause issues if the event
// is handled at a higher level, this is a compromise in order to echo keys to the screen // is handled at a higher level, this is a compromise in order to echo keys to the screen
// reader. // reader.
if (!this.optionsService.options.screenReaderMode) { if (!this.optionsService.rawOptions.screenReaderMode) {
return this.cancel(event, true); return this.cancel(event, true);
} }
@@ -1182,7 +1182,7 @@ export class Terminal extends CoreTerminal implements ITerminal {
protected _inputEvent(ev: InputEvent): boolean { protected _inputEvent(ev: InputEvent): boolean {
// Only support emoji IMEs when screen reader mode is disabled as the event must bubble up to // Only support emoji IMEs when screen reader mode is disabled as the event must bubble up to
// support reading out character input which can doubling up input characters // support reading out character input which can doubling up input characters
if (ev.data && ev.inputType === 'insertText' && !ev.composed && !this.optionsService.options.screenReaderMode) { if (ev.data && ev.inputType === 'insertText' && !ev.composed && !this.optionsService.rawOptions.screenReaderMode) {
if (this._keyPressHandled) { if (this._keyPressHandled) {
return false; return false;
} }
+5 -5
View File
@@ -110,7 +110,7 @@ export class Viewport extends Disposable implements IViewport {
} }
// Update scroll bar width // Update scroll bar width
if (this._optionsService.options.scrollback === 0) { if (this._optionsService.rawOptions.scrollback === 0) {
this.scrollBarWidth = 0; this.scrollBarWidth = 0;
} else { } else {
this.scrollBarWidth = (this._viewportElement.offsetWidth - this._scrollArea.offsetWidth) || FALLBACK_SCROLL_BAR_WIDTH; this.scrollBarWidth = (this._viewportElement.offsetWidth - this._scrollArea.offsetWidth) || FALLBACK_SCROLL_BAR_WIDTH;
@@ -153,7 +153,7 @@ export class Viewport extends Disposable implements IViewport {
} }
// If the scroll bar visibility changed // If the scroll bar visibility changed
if (this._lastHadScrollBar !== (this._optionsService.options.scrollback > 0)) { if (this._lastHadScrollBar !== (this._optionsService.rawOptions.scrollback > 0)) {
this._refresh(immediate); this._refresh(immediate);
} }
} }
@@ -259,15 +259,15 @@ export class Viewport extends Disposable implements IViewport {
} }
private _applyScrollModifier(amount: number, ev: WheelEvent): number { private _applyScrollModifier(amount: number, ev: WheelEvent): number {
const modifier = this._optionsService.options.fastScrollModifier; const modifier = this._optionsService.rawOptions.fastScrollModifier;
// Multiply the scroll speed when the modifier is down // Multiply the scroll speed when the modifier is down
if ((modifier === 'alt' && ev.altKey) || if ((modifier === 'alt' && ev.altKey) ||
(modifier === 'ctrl' && ev.ctrlKey) || (modifier === 'ctrl' && ev.ctrlKey) ||
(modifier === 'shift' && ev.shiftKey)) { (modifier === 'shift' && ev.shiftKey)) {
return amount * this._optionsService.options.fastScrollSensitivity * this._optionsService.options.scrollSensitivity; return amount * this._optionsService.rawOptions.fastScrollSensitivity * this._optionsService.rawOptions.scrollSensitivity;
} }
return amount * this._optionsService.options.scrollSensitivity; return amount * this._optionsService.rawOptions.scrollSensitivity;
} }
/** /**
+2 -2
View File
@@ -217,8 +217,8 @@ export class CompositionHelper {
this._compositionView.style.top = cursorTop + 'px'; this._compositionView.style.top = cursorTop + 'px';
this._compositionView.style.height = cellHeight + 'px'; this._compositionView.style.height = cellHeight + 'px';
this._compositionView.style.lineHeight = cellHeight + 'px'; this._compositionView.style.lineHeight = cellHeight + 'px';
this._compositionView.style.fontFamily = this._optionsService.options.fontFamily; this._compositionView.style.fontFamily = this._optionsService.rawOptions.fontFamily;
this._compositionView.style.fontSize = this._optionsService.options.fontSize + 'px'; this._compositionView.style.fontSize = this._optionsService.rawOptions.fontSize + 'px';
// Sync the textarea to the exact position of the composition view so the IME knows where the // Sync the textarea to the exact position of the composition view so the IME knows where the
// text is. // text is.
const compositionViewBounds = this._compositionView.getBoundingClientRect(); const compositionViewBounds = this._compositionView.getBoundingClientRect();
+2 -2
View File
@@ -30,7 +30,7 @@ export class Terminal implements ITerminalApi {
this._core = new TerminalCore(options); this._core = new TerminalCore(options);
this._addonManager = new AddonManager(); this._addonManager = new AddonManager();
this._publicOptions = {}; this._publicOptions = { ... this._core.options };
const getter = (propName: string): any => { const getter = (propName: string): any => {
return this._core.options[propName]; return this._core.options[propName];
}; };
@@ -58,7 +58,7 @@ export class Terminal implements ITerminalApi {
} }
private _checkProposedApi(): void { private _checkProposedApi(): void {
if (!this._core.optionsService.options.allowProposedApi) { if (!this._core.optionsService.rawOptions.allowProposedApi) {
throw new Error('You must set the allowProposedApi option to true to use proposed API'); throw new Error('You must set the allowProposedApi option to true to use proposed API');
} }
} }
+11 -11
View File
@@ -112,7 +112,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
if (this._scaledCharWidth <= 0 && this._scaledCharHeight <= 0) { if (this._scaledCharWidth <= 0 && this._scaledCharHeight <= 0) {
return; return;
} }
this._charAtlas = acquireCharAtlas(this._optionsService.options, this._rendererId, colorSet, this._scaledCharWidth, this._scaledCharHeight); this._charAtlas = acquireCharAtlas(this._optionsService.rawOptions, this._rendererId, colorSet, this._scaledCharWidth, this._scaledCharHeight);
this._charAtlas.warmUp(); this._charAtlas.warmUp();
} }
@@ -267,7 +267,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
// Draw custom characters if applicable // Draw custom characters if applicable
let drawSuccess = false; let drawSuccess = false;
if (this._optionsService.options.customGlyphs !== false) { if (this._optionsService.rawOptions.customGlyphs !== false) {
drawSuccess = tryDrawCustomChar(this._ctx, cell.getChars(), x * this._scaledCellWidth, y * this._scaledCellHeight, this._scaledCellWidth, this._scaledCellHeight); drawSuccess = tryDrawCustomChar(this._ctx, cell.getChars(), x * this._scaledCellWidth, y * this._scaledCellHeight, this._scaledCellWidth, this._scaledCellHeight);
} }
@@ -315,7 +315,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
fg = (cell.isFgDefault()) ? DEFAULT_COLOR : cell.getFgColor(); fg = (cell.isFgDefault()) ? DEFAULT_COLOR : cell.getFgColor();
} }
const drawInBrightColor = this._optionsService.options.drawBoldTextInBrightColors && cell.isBold() && fg < 8; const drawInBrightColor = this._optionsService.rawOptions.drawBoldTextInBrightColors && cell.isBold() && fg < 8;
fg += drawInBrightColor ? 8 : 0; fg += drawInBrightColor ? 8 : 0;
this._currentGlyphIdentifier.chars = cell.getChars() || WHITESPACE_CELL_CHAR; this._currentGlyphIdentifier.chars = cell.getChars() || WHITESPACE_CELL_CHAR;
@@ -356,7 +356,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
this._ctx.fillStyle = `rgb(${AttributeData.toColorRGB(cell.getBgColor()).join(',')})`; this._ctx.fillStyle = `rgb(${AttributeData.toColorRGB(cell.getBgColor()).join(',')})`;
} else { } else {
let bg = cell.getBgColor(); let bg = cell.getBgColor();
if (this._optionsService.options.drawBoldTextInBrightColors && cell.isBold() && bg < 8) { if (this._optionsService.rawOptions.drawBoldTextInBrightColors && cell.isBold() && bg < 8) {
bg += 8; bg += 8;
} }
this._ctx.fillStyle = this._colors.ansi[bg].css; this._ctx.fillStyle = this._colors.ansi[bg].css;
@@ -370,7 +370,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
this._ctx.fillStyle = `rgb(${AttributeData.toColorRGB(cell.getFgColor()).join(',')})`; this._ctx.fillStyle = `rgb(${AttributeData.toColorRGB(cell.getFgColor()).join(',')})`;
} else { } else {
let fg = cell.getFgColor(); let fg = cell.getFgColor();
if (this._optionsService.options.drawBoldTextInBrightColors && cell.isBold() && fg < 8) { if (this._optionsService.rawOptions.drawBoldTextInBrightColors && cell.isBold() && fg < 8) {
fg += 8; fg += 8;
} }
this._ctx.fillStyle = this._colors.ansi[fg].css; this._ctx.fillStyle = this._colors.ansi[fg].css;
@@ -386,7 +386,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
// Draw custom characters if applicable // Draw custom characters if applicable
let drawSuccess = false; let drawSuccess = false;
if (this._optionsService.options.customGlyphs !== false) { if (this._optionsService.rawOptions.customGlyphs !== false) {
drawSuccess = tryDrawCustomChar(this._ctx, cell.getChars(), x * this._scaledCellWidth, y * this._scaledCellHeight, this._scaledCellWidth, this._scaledCellHeight); drawSuccess = tryDrawCustomChar(this._ctx, cell.getChars(), x * this._scaledCellWidth, y * this._scaledCellHeight, this._scaledCellWidth, this._scaledCellHeight);
} }
@@ -421,14 +421,14 @@ export abstract class BaseRenderLayer implements IRenderLayer {
* @param isBold If we should use the bold fontWeight. * @param isBold If we should use the bold fontWeight.
*/ */
protected _getFont(isBold: boolean, isItalic: boolean): string { protected _getFont(isBold: boolean, isItalic: boolean): string {
const fontWeight = isBold ? this._optionsService.options.fontWeightBold : this._optionsService.options.fontWeight; const fontWeight = isBold ? this._optionsService.rawOptions.fontWeightBold : this._optionsService.rawOptions.fontWeight;
const fontStyle = isItalic ? 'italic' : ''; const fontStyle = isItalic ? 'italic' : '';
return `${fontStyle} ${fontWeight} ${this._optionsService.options.fontSize * window.devicePixelRatio}px ${this._optionsService.options.fontFamily}`; return `${fontStyle} ${fontWeight} ${this._optionsService.rawOptions.fontSize * window.devicePixelRatio}px ${this._optionsService.rawOptions.fontFamily}`;
} }
private _getContrastColor(cell: CellData): IColor | undefined { private _getContrastColor(cell: CellData): IColor | undefined {
if (this._optionsService.options.minimumContrastRatio === 1) { if (this._optionsService.rawOptions.minimumContrastRatio === 1) {
return undefined; return undefined;
} }
@@ -455,7 +455,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
const bgRgba = this._resolveBackgroundRgba(bgColorMode, bgColor, isInverse); const bgRgba = this._resolveBackgroundRgba(bgColorMode, bgColor, isInverse);
const fgRgba = this._resolveForegroundRgba(fgColorMode, fgColor, isInverse, isBold); const fgRgba = this._resolveForegroundRgba(fgColorMode, fgColor, isInverse, isBold);
const result = rgba.ensureContrastRatio(bgRgba, fgRgba, this._optionsService.options.minimumContrastRatio); const result = rgba.ensureContrastRatio(bgRgba, fgRgba, this._optionsService.rawOptions.minimumContrastRatio);
if (!result) { if (!result) {
this._colors.contrastCache.setColor(cell.bg, cell.fg, null); this._colors.contrastCache.setColor(cell.bg, cell.fg, null);
@@ -495,7 +495,7 @@ export abstract class BaseRenderLayer implements IRenderLayer {
switch (fgColorMode) { switch (fgColorMode) {
case Attributes.CM_P16: case Attributes.CM_P16:
case Attributes.CM_P256: case Attributes.CM_P256:
if (this._optionsService.options.drawBoldTextInBrightColors && bold && fgColor < 8) { if (this._optionsService.rawOptions.drawBoldTextInBrightColors && bold && fgColor < 8) {
fgColor += 8; fgColor += 8;
} }
return this._colors.ansi[fgColor].rgba; return this._colors.ansi[fgColor].rgba;
+6 -6
View File
@@ -94,7 +94,7 @@ export class CursorRenderLayer extends BaseRenderLayer {
} }
public onOptionsChanged(): void { public onOptionsChanged(): void {
if (this._optionsService.options.cursorBlink) { if (this._optionsService.rawOptions.cursorBlink) {
if (!this._cursorBlinkStateManager) { if (!this._cursorBlinkStateManager) {
this._cursorBlinkStateManager = new CursorBlinkStateManager(this._coreBrowserService.isFocused, () => { this._cursorBlinkStateManager = new CursorBlinkStateManager(this._coreBrowserService.isFocused, () => {
this._render(true); this._render(true);
@@ -148,7 +148,7 @@ export class CursorRenderLayer extends BaseRenderLayer {
this._clearCursor(); this._clearCursor();
this._ctx.save(); this._ctx.save();
this._ctx.fillStyle = this._colors.cursor.css; this._ctx.fillStyle = this._colors.cursor.css;
const cursorStyle = this._optionsService.options.cursorStyle; const cursorStyle = this._optionsService.rawOptions.cursorStyle;
if (cursorStyle && cursorStyle !== 'block') { if (cursorStyle && cursorStyle !== 'block') {
this._cursorRenderers[cursorStyle](cursorX, viewportRelativeCursorY, this._cell); this._cursorRenderers[cursorStyle](cursorX, viewportRelativeCursorY, this._cell);
} else { } else {
@@ -174,7 +174,7 @@ export class CursorRenderLayer extends BaseRenderLayer {
if (this._state.x === cursorX && if (this._state.x === cursorX &&
this._state.y === viewportRelativeCursorY && this._state.y === viewportRelativeCursorY &&
this._state.isFocused === this._coreBrowserService.isFocused && this._state.isFocused === this._coreBrowserService.isFocused &&
this._state.style === this._optionsService.options.cursorStyle && this._state.style === this._optionsService.rawOptions.cursorStyle &&
this._state.width === this._cell.getWidth()) { this._state.width === this._cell.getWidth()) {
return; return;
} }
@@ -182,13 +182,13 @@ export class CursorRenderLayer extends BaseRenderLayer {
} }
this._ctx.save(); this._ctx.save();
this._cursorRenderers[this._optionsService.options.cursorStyle || 'block'](cursorX, viewportRelativeCursorY, this._cell); this._cursorRenderers[this._optionsService.rawOptions.cursorStyle || 'block'](cursorX, viewportRelativeCursorY, this._cell);
this._ctx.restore(); this._ctx.restore();
this._state.x = cursorX; this._state.x = cursorX;
this._state.y = viewportRelativeCursorY; this._state.y = viewportRelativeCursorY;
this._state.isFocused = false; this._state.isFocused = false;
this._state.style = this._optionsService.options.cursorStyle; this._state.style = this._optionsService.rawOptions.cursorStyle;
this._state.width = this._cell.getWidth(); this._state.width = this._cell.getWidth();
} }
@@ -213,7 +213,7 @@ export class CursorRenderLayer extends BaseRenderLayer {
private _renderBarCursor(x: number, y: number, cell: ICellData): void { private _renderBarCursor(x: number, y: number, cell: ICellData): void {
this._ctx.save(); this._ctx.save();
this._ctx.fillStyle = this._colors.cursor.css; this._ctx.fillStyle = this._colors.cursor.css;
this._fillLeftLineAtCell(x, y, this._optionsService.options.cursorWidth); this._fillLeftLineAtCell(x, y, this._optionsService.rawOptions.cursorWidth);
this._ctx.restore(); this._ctx.restore();
} }
+5 -5
View File
@@ -39,7 +39,7 @@ export class Renderer extends Disposable implements IRenderer {
@IOptionsService private readonly _optionsService: IOptionsService @IOptionsService private readonly _optionsService: IOptionsService
) { ) {
super(); super();
const allowTransparency = this._optionsService.options.allowTransparency; const allowTransparency = this._optionsService.rawOptions.allowTransparency;
this._renderLayers = [ this._renderLayers = [
instantiationService.createInstance(TextRenderLayer, this._screenElement, 0, this._colors, allowTransparency, this._id), instantiationService.createInstance(TextRenderLayer, this._screenElement, 0, this._colors, allowTransparency, this._id),
instantiationService.createInstance(SelectionRenderLayer, this._screenElement, 1, this._colors, this._id), instantiationService.createInstance(SelectionRenderLayer, this._screenElement, 1, this._colors, this._id),
@@ -178,18 +178,18 @@ export class Renderer extends Disposable implements IRenderer {
// will be floored because since lineHeight can never be lower then 1, there // will be floored because since lineHeight can never be lower then 1, there
// is a guarentee that the scaled line height will always be larger than // is a guarentee that the scaled line height will always be larger than
// scaled char height. // scaled char height.
this.dimensions.scaledCellHeight = Math.floor(this.dimensions.scaledCharHeight * this._optionsService.options.lineHeight); this.dimensions.scaledCellHeight = Math.floor(this.dimensions.scaledCharHeight * this._optionsService.rawOptions.lineHeight);
// Calculate the y coordinate within a cell that text should draw from in // Calculate the y coordinate within a cell that text should draw from in
// order to draw in the center of a cell. // order to draw in the center of a cell.
this.dimensions.scaledCharTop = this._optionsService.options.lineHeight === 1 ? 0 : Math.round((this.dimensions.scaledCellHeight - this.dimensions.scaledCharHeight) / 2); this.dimensions.scaledCharTop = this._optionsService.rawOptions.lineHeight === 1 ? 0 : Math.round((this.dimensions.scaledCellHeight - this.dimensions.scaledCharHeight) / 2);
// Calculate the scaled cell width, taking the letterSpacing into account. // Calculate the scaled cell width, taking the letterSpacing into account.
this.dimensions.scaledCellWidth = this.dimensions.scaledCharWidth + Math.round(this._optionsService.options.letterSpacing); this.dimensions.scaledCellWidth = this.dimensions.scaledCharWidth + Math.round(this._optionsService.rawOptions.letterSpacing);
// Calculate the x coordinate with a cell that text should draw from in // Calculate the x coordinate with a cell that text should draw from in
// order to draw in the center of a cell. // order to draw in the center of a cell.
this.dimensions.scaledCharLeft = Math.floor(this._optionsService.options.letterSpacing / 2); this.dimensions.scaledCharLeft = Math.floor(this._optionsService.rawOptions.letterSpacing / 2);
// Recalculate the canvas dimensions; scaled* define the actual number of // Recalculate the canvas dimensions; scaled* define the actual number of
// pixel in the canvas // pixel in the canvas
+3 -3
View File
@@ -225,7 +225,7 @@ export class TextRenderLayer extends BaseRenderLayer {
this._ctx.fillStyle = `rgb(${AttributeData.toColorRGB(cell.getBgColor()).join(',')})`; this._ctx.fillStyle = `rgb(${AttributeData.toColorRGB(cell.getBgColor()).join(',')})`;
} else { } else {
let bg = cell.getBgColor(); let bg = cell.getBgColor();
if (this._optionsService.options.drawBoldTextInBrightColors && cell.isBold() && bg < 8) { if (this._optionsService.rawOptions.drawBoldTextInBrightColors && cell.isBold() && bg < 8) {
bg += 8; bg += 8;
} }
this._ctx.fillStyle = this._colors.ansi[bg].css; this._ctx.fillStyle = this._colors.ansi[bg].css;
@@ -237,7 +237,7 @@ export class TextRenderLayer extends BaseRenderLayer {
this._ctx.fillStyle = `rgb(${AttributeData.toColorRGB(cell.getFgColor()).join(',')})`; this._ctx.fillStyle = `rgb(${AttributeData.toColorRGB(cell.getFgColor()).join(',')})`;
} else { } else {
let fg = cell.getFgColor(); let fg = cell.getFgColor();
if (this._optionsService.options.drawBoldTextInBrightColors && cell.isBold() && fg < 8) { if (this._optionsService.rawOptions.drawBoldTextInBrightColors && cell.isBold() && fg < 8) {
fg += 8; fg += 8;
} }
this._ctx.fillStyle = this._colors.ansi[fg].css; this._ctx.fillStyle = this._colors.ansi[fg].css;
@@ -271,7 +271,7 @@ export class TextRenderLayer extends BaseRenderLayer {
} }
public onOptionsChanged(): void { public onOptionsChanged(): void {
this._setTransparency(this._optionsService.options.allowTransparency); this._setTransparency(this._optionsService.rawOptions.allowTransparency);
} }
/** /**
+9 -9
View File
@@ -107,8 +107,8 @@ export class DomRenderer extends Disposable implements IRenderer {
private _updateDimensions(): void { private _updateDimensions(): void {
this.dimensions.scaledCharWidth = this._charSizeService.width * window.devicePixelRatio; this.dimensions.scaledCharWidth = this._charSizeService.width * window.devicePixelRatio;
this.dimensions.scaledCharHeight = Math.ceil(this._charSizeService.height * window.devicePixelRatio); this.dimensions.scaledCharHeight = Math.ceil(this._charSizeService.height * window.devicePixelRatio);
this.dimensions.scaledCellWidth = this.dimensions.scaledCharWidth + Math.round(this._optionsService.options.letterSpacing); this.dimensions.scaledCellWidth = this.dimensions.scaledCharWidth + Math.round(this._optionsService.rawOptions.letterSpacing);
this.dimensions.scaledCellHeight = Math.floor(this.dimensions.scaledCharHeight * this._optionsService.options.lineHeight); this.dimensions.scaledCellHeight = Math.floor(this.dimensions.scaledCharHeight * this._optionsService.rawOptions.lineHeight);
this.dimensions.scaledCharLeft = 0; this.dimensions.scaledCharLeft = 0;
this.dimensions.scaledCharTop = 0; this.dimensions.scaledCharTop = 0;
this.dimensions.scaledCanvasWidth = this.dimensions.scaledCellWidth * this._bufferService.cols; this.dimensions.scaledCanvasWidth = this.dimensions.scaledCellWidth * this._bufferService.cols;
@@ -161,16 +161,16 @@ export class DomRenderer extends Disposable implements IRenderer {
let styles = let styles =
`${this._terminalSelector} .${ROW_CONTAINER_CLASS} {` + `${this._terminalSelector} .${ROW_CONTAINER_CLASS} {` +
` color: ${this._colors.foreground.css};` + ` color: ${this._colors.foreground.css};` +
` font-family: ${this._optionsService.options.fontFamily};` + ` font-family: ${this._optionsService.rawOptions.fontFamily};` +
` font-size: ${this._optionsService.options.fontSize}px;` + ` font-size: ${this._optionsService.rawOptions.fontSize}px;` +
`}`; `}`;
// Text styles // Text styles
styles += styles +=
`${this._terminalSelector} span:not(.${BOLD_CLASS}) {` + `${this._terminalSelector} span:not(.${BOLD_CLASS}) {` +
` font-weight: ${this._optionsService.options.fontWeight};` + ` font-weight: ${this._optionsService.rawOptions.fontWeight};` +
`}` + `}` +
`${this._terminalSelector} span.${BOLD_CLASS} {` + `${this._terminalSelector} span.${BOLD_CLASS} {` +
` font-weight: ${this._optionsService.options.fontWeightBold};` + ` font-weight: ${this._optionsService.rawOptions.fontWeightBold};` +
`}` + `}` +
`${this._terminalSelector} span.${ITALIC_CLASS} {` + `${this._terminalSelector} span.${ITALIC_CLASS} {` +
` font-style: italic;` + ` font-style: italic;` +
@@ -210,7 +210,7 @@ export class DomRenderer extends Disposable implements IRenderer {
` color: ${this._colors.cursorAccent.css};` + ` color: ${this._colors.cursorAccent.css};` +
`}` + `}` +
`${this._terminalSelector} .${ROW_CONTAINER_CLASS} .${CURSOR_CLASS}.${CURSOR_STYLE_BAR_CLASS} {` + `${this._terminalSelector} .${ROW_CONTAINER_CLASS} .${CURSOR_CLASS}.${CURSOR_STYLE_BAR_CLASS} {` +
` box-shadow: ${this._optionsService.options.cursorWidth}px 0 0 ${this._colors.cursor.css} inset;` + ` box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${this._colors.cursor.css} inset;` +
`}` + `}` +
`${this._terminalSelector} .${ROW_CONTAINER_CLASS} .${CURSOR_CLASS}.${CURSOR_STYLE_UNDERLINE_CLASS} {` + `${this._terminalSelector} .${ROW_CONTAINER_CLASS} .${CURSOR_CLASS}.${CURSOR_STYLE_UNDERLINE_CLASS} {` +
` box-shadow: 0 -1px 0 ${this._colors.cursor.css} inset;` + ` box-shadow: 0 -1px 0 ${this._colors.cursor.css} inset;` +
@@ -356,7 +356,7 @@ export class DomRenderer extends Disposable implements IRenderer {
public renderRows(start: number, end: number): void { public renderRows(start: number, end: number): void {
const cursorAbsoluteY = this._bufferService.buffer.ybase + this._bufferService.buffer.y; const cursorAbsoluteY = this._bufferService.buffer.ybase + this._bufferService.buffer.y;
const cursorX = Math.min(this._bufferService.buffer.x, this._bufferService.cols - 1); const cursorX = Math.min(this._bufferService.buffer.x, this._bufferService.cols - 1);
const cursorBlink = this._optionsService.options.cursorBlink; const cursorBlink = this._optionsService.rawOptions.cursorBlink;
for (let y = start; y <= end; y++) { for (let y = start; y <= end; y++) {
const rowElement = this._rowElements[y]; const rowElement = this._rowElements[y];
@@ -364,7 +364,7 @@ export class DomRenderer extends Disposable implements IRenderer {
const row = y + this._bufferService.buffer.ydisp; const row = y + this._bufferService.buffer.ydisp;
const lineData = this._bufferService.buffer.lines.get(row); const lineData = this._bufferService.buffer.lines.get(row);
const cursorStyle = this._optionsService.options.cursorStyle; const cursorStyle = this._optionsService.rawOptions.cursorStyle;
rowElement.appendChild(this._rowFactory.createRow(lineData!, row, row === cursorAbsoluteY, cursorStyle, cursorX, cursorBlink, this.dimensions.actualCellWidth, this._bufferService.cols)); rowElement.appendChild(this._rowFactory.createRow(lineData!, row, row === cursorAbsoluteY, cursorStyle, cursorX, cursorBlink, this.dimensions.actualCellWidth, this._bufferService.cols));
} }
} }
@@ -175,7 +175,7 @@ export class DomRendererRowFactory {
switch (fgColorMode) { switch (fgColorMode) {
case Attributes.CM_P16: case Attributes.CM_P16:
case Attributes.CM_P256: case Attributes.CM_P256:
if (cell.isBold() && fg < 8 && this._optionsService.options.drawBoldTextInBrightColors) { if (cell.isBold() && fg < 8 && this._optionsService.rawOptions.drawBoldTextInBrightColors) {
fg += 8; fg += 8;
} }
if (!this._applyMinimumContrast(charElement, this._colors.background, this._colors.ansi[fg])) { if (!this._applyMinimumContrast(charElement, this._colors.background, this._colors.ansi[fg])) {
@@ -225,7 +225,7 @@ export class DomRendererRowFactory {
} }
private _applyMinimumContrast(element: HTMLElement, bg: IColor, fg: IColor): boolean { private _applyMinimumContrast(element: HTMLElement, bg: IColor, fg: IColor): boolean {
if (this._optionsService.options.minimumContrastRatio === 1) { if (this._optionsService.rawOptions.minimumContrastRatio === 1) {
return false; return false;
} }
@@ -234,7 +234,7 @@ export class DomRendererRowFactory {
// Calculate and store in cache // Calculate and store in cache
if (adjustedColor === undefined) { if (adjustedColor === undefined) {
adjustedColor = color.ensureContrastRatio(bg, fg, this._optionsService.options.minimumContrastRatio); adjustedColor = color.ensureContrastRatio(bg, fg, this._optionsService.rawOptions.minimumContrastRatio);
this._colors.contrastCache.setColor(this._workCell.bg, this._workCell.fg, adjustedColor ?? null); this._colors.contrastCache.setColor(this._workCell.bg, this._workCell.fg, adjustedColor ?? null);
} }
+2 -2
View File
@@ -69,8 +69,8 @@ class DomMeasureStrategy implements IMeasureStrategy {
} }
public measure(): IReadonlyMeasureResult { public measure(): IReadonlyMeasureResult {
this._measureElement.style.fontFamily = this._optionsService.options.fontFamily; this._measureElement.style.fontFamily = this._optionsService.rawOptions.fontFamily;
this._measureElement.style.fontSize = `${this._optionsService.options.fontSize}px`; this._measureElement.style.fontSize = `${this._optionsService.rawOptions.fontSize}px`;
// Note that this triggers a synchronous layout // Note that this triggers a synchronous layout
const geometry = this._measureElement.getBoundingClientRect(); const geometry = this._measureElement.getBoundingClientRect();
+3 -3
View File
@@ -414,7 +414,7 @@ export class SelectionService extends Disposable implements ISelectionService {
*/ */
public shouldForceSelection(event: MouseEvent): boolean { public shouldForceSelection(event: MouseEvent): boolean {
if (Browser.isMac) { if (Browser.isMac) {
return event.altKey && this._optionsService.options.macOptionClickForcesSelection; return event.altKey && this._optionsService.rawOptions.macOptionClickForcesSelection;
} }
return event.shiftKey; return event.shiftKey;
@@ -567,7 +567,7 @@ export class SelectionService extends Disposable implements ISelectionService {
* @param event the mouse or keyboard event * @param event the mouse or keyboard event
*/ */
public shouldColumnSelect(event: KeyboardEvent | MouseEvent): boolean { public shouldColumnSelect(event: KeyboardEvent | MouseEvent): boolean {
return event.altKey && !(Browser.isMac && this._optionsService.options.macOptionClickForcesSelection); return event.altKey && !(Browser.isMac && this._optionsService.rawOptions.macOptionClickForcesSelection);
} }
/** /**
@@ -993,7 +993,7 @@ export class SelectionService extends Disposable implements ISelectionService {
if (cell.getWidth() === 0) { if (cell.getWidth() === 0) {
return false; return false;
} }
return this._optionsService.options.wordSeparator.indexOf(cell.getChars()) >= 0; return this._optionsService.rawOptions.wordSeparator.indexOf(cell.getChars()) >= 0;
} }
/** /**
+1 -1
View File
@@ -34,7 +34,7 @@ export class SoundService implements ISoundService {
return; return;
} }
const bellAudioSource = ctx.createBufferSource(); const bellAudioSource = ctx.createBufferSource();
ctx.decodeAudioData(this._base64ToArrayBuffer(this._removeMimeType(this._optionsService.options.bellSound)), (buffer) => { ctx.decodeAudioData(this._base64ToArrayBuffer(this._removeMimeType(this._optionsService.rawOptions.bellSound)), (buffer) => {
bellAudioSource.buffer = buffer; bellAudioSource.buffer = buffer;
bellAudioSource.connect(ctx.destination); bellAudioSource.connect(ctx.destination);
bellAudioSource.start(0); bellAudioSource.start(0);
+2 -2
View File
@@ -247,7 +247,7 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
} }
protected _setup(): void { protected _setup(): void {
if (this.optionsService.options.windowsMode) { if (this.optionsService.rawOptions.windowsMode) {
this._enableWindowsMode(); this._enableWindowsMode();
} }
} }
@@ -267,7 +267,7 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
this.buffers.resize(this.cols, this.rows); this.buffers.resize(this.cols, this.rows);
break; break;
case 'windowsMode': case 'windowsMode':
if (this.optionsService.options.windowsMode) { if (this.optionsService.rawOptions.windowsMode) {
this._enableWindowsMode(); this._enableWindowsMode();
} else { } else {
this._windowsMode?.dispose(); this._windowsMode?.dispose();
+10 -10
View File
@@ -176,8 +176,8 @@ class DECRQSS implements IDcsHandler {
break; break;
case ' q': // DECSCUSR case ' q': // DECSCUSR
const STYLES: { [key: string]: number } = { 'block': 2, 'underline': 4, 'bar': 6 }; const STYLES: { [key: string]: number } = { 'block': 2, 'underline': 4, 'bar': 6 };
let style = STYLES[this._optionsService.options.cursorStyle]; let style = STYLES[this._optionsService.rawOptions.cursorStyle];
style -= this._optionsService.options.cursorBlink ? 1 : 0; style -= this._optionsService.rawOptions.cursorBlink ? 1 : 0;
this._coreService.triggerDataEvent(`${C0.ESC}P1$r${style} q${C0.ESC}\\`); this._coreService.triggerDataEvent(`${C0.ESC}P1$r${style} q${C0.ESC}\\`);
break; break;
default: default:
@@ -589,7 +589,7 @@ export class InputHandler extends Disposable implements IInputHandler {
let code: number; let code: number;
let chWidth: number; let chWidth: number;
const charset = this._charsetService.charset; const charset = this._charsetService.charset;
const screenReaderMode = this._optionsService.options.screenReaderMode; const screenReaderMode = this._optionsService.rawOptions.screenReaderMode;
const cols = this._bufferService.cols; const cols = this._bufferService.cols;
const wraparoundMode = this._coreService.decPrivateModes.wraparound; const wraparoundMode = this._coreService.decPrivateModes.wraparound;
const insertMode = this._coreService.modes.insertMode; const insertMode = this._coreService.modes.insertMode;
@@ -731,7 +731,7 @@ export class InputHandler extends Disposable implements IInputHandler {
if (id.final === 't' && !id.prefix && !id.intermediates) { if (id.final === 't' && !id.prefix && !id.intermediates) {
// security: always check whether window option is allowed // security: always check whether window option is allowed
return this._parser.registerCsiHandler(id, params => { return this._parser.registerCsiHandler(id, params => {
if (!paramToWindowOption(params.params[0], this._optionsService.options.windowOptions)) { if (!paramToWindowOption(params.params[0], this._optionsService.rawOptions.windowOptions)) {
return true; return true;
} }
return callback(params); return callback(params);
@@ -786,7 +786,7 @@ export class InputHandler extends Disposable implements IInputHandler {
*/ */
public lineFeed(): boolean { public lineFeed(): boolean {
this._dirtyRowService.markDirty(this._activeBuffer.y); this._dirtyRowService.markDirty(this._activeBuffer.y);
if (this._optionsService.options.convertEol) { if (this._optionsService.rawOptions.convertEol) {
this._activeBuffer.x = 0; this._activeBuffer.x = 0;
} }
this._activeBuffer.y++; this._activeBuffer.y++;
@@ -890,7 +890,7 @@ export class InputHandler extends Disposable implements IInputHandler {
} }
const originalX = this._activeBuffer.x; const originalX = this._activeBuffer.x;
this._activeBuffer.x = this._activeBuffer.nextStop(); this._activeBuffer.x = this._activeBuffer.nextStop();
if (this._optionsService.options.screenReaderMode) { if (this._optionsService.rawOptions.screenReaderMode) {
this._onA11yTab.fire(this._activeBuffer.x - originalX); this._onA11yTab.fire(this._activeBuffer.x - originalX);
} }
return true; return true;
@@ -1749,7 +1749,7 @@ export class InputHandler extends Disposable implements IInputHandler {
* @param term The terminal name to evaluate * @param term The terminal name to evaluate
*/ */
private _is(term: string): boolean { private _is(term: string): boolean {
return (this._optionsService.options.termName + '').indexOf(term) === 0; return (this._optionsService.rawOptions.termName + '').indexOf(term) === 0;
} }
/** /**
@@ -1915,7 +1915,7 @@ export class InputHandler extends Disposable implements IInputHandler {
* This is only active if 'SetWinLines' (24) is enabled * This is only active if 'SetWinLines' (24) is enabled
* through `options.windowsOptions`. * through `options.windowsOptions`.
*/ */
if (this._optionsService.options.windowOptions.setWinLines) { if (this._optionsService.rawOptions.windowOptions.setWinLines) {
this._bufferService.resize(132, this._bufferService.rows); this._bufferService.resize(132, this._bufferService.rows);
this._onRequestReset.fire(); this._onRequestReset.fire();
} }
@@ -2149,7 +2149,7 @@ export class InputHandler extends Disposable implements IInputHandler {
* This is only active if 'SetWinLines' (24) is enabled * This is only active if 'SetWinLines' (24) is enabled
* through `options.windowsOptions`. * through `options.windowsOptions`.
*/ */
if (this._optionsService.options.windowOptions.setWinLines) { if (this._optionsService.rawOptions.windowOptions.setWinLines) {
this._bufferService.resize(80, this._bufferService.rows); this._bufferService.resize(80, this._bufferService.rows);
this._onRequestReset.fire(); this._onRequestReset.fire();
} }
@@ -2726,7 +2726,7 @@ export class InputHandler extends Disposable implements IInputHandler {
* Ps >= 24 not implemented * Ps >= 24 not implemented
*/ */
public windowOptions(params: IParams): boolean { public windowOptions(params: IParams): boolean {
if (!paramToWindowOption(params.params[0], this._optionsService.options.windowOptions)) { if (!paramToWindowOption(params.params[0], this._optionsService.rawOptions.windowOptions)) {
return true; return true;
} }
const second = (params.length > 1) ? params.params[1] : 0; const second = (params.length > 1) ? params.params[1] : 0;
+4 -4
View File
@@ -107,7 +107,7 @@ export class Buffer implements IBuffer {
return rows; return rows;
} }
const correctBufferLength = rows + this._optionsService.options.scrollback; const correctBufferLength = rows + this._optionsService.rawOptions.scrollback;
return correctBufferLength > MAX_BUFFER_SIZE ? MAX_BUFFER_SIZE : correctBufferLength; return correctBufferLength > MAX_BUFFER_SIZE ? MAX_BUFFER_SIZE : correctBufferLength;
} }
@@ -172,7 +172,7 @@ export class Buffer implements IBuffer {
if (this._rows < newRows) { if (this._rows < newRows) {
for (let y = this._rows; y < newRows; y++) { for (let y = this._rows; y < newRows; y++) {
if (this.lines.length < newRows + this.ybase) { if (this.lines.length < newRows + this.ybase) {
if (this._optionsService.options.windowsMode) { if (this._optionsService.rawOptions.windowsMode) {
// Just add the new missing rows on Windows as conpty reprints the screen with it's // Just add the new missing rows on Windows as conpty reprints the screen with it's
// view of the world. Once a line enters scrollback for conpty it remains there // view of the world. Once a line enters scrollback for conpty it remains there
this.lines.push(new BufferLine(newCols, nullCell)); this.lines.push(new BufferLine(newCols, nullCell));
@@ -252,7 +252,7 @@ export class Buffer implements IBuffer {
} }
private get _isReflowEnabled(): boolean { private get _isReflowEnabled(): boolean {
return this._hasScrollback && !this._optionsService.options.windowsMode; return this._hasScrollback && !this._optionsService.rawOptions.windowsMode;
} }
private _reflow(newCols: number, newRows: number): void { private _reflow(newCols: number, newRows: number): void {
@@ -550,7 +550,7 @@ export class Buffer implements IBuffer {
i = 0; i = 0;
} }
for (; i < this._cols; i += this._optionsService.options.tabStopWidth) { for (; i < this._cols; i += this._optionsService.rawOptions.tabStopWidth) {
this.tabs[i] = true; this.tabs[i] = true;
} }
} }
+2 -2
View File
@@ -36,8 +36,8 @@ export class BufferService extends Disposable implements IBufferService {
@IOptionsService private _optionsService: IOptionsService @IOptionsService private _optionsService: IOptionsService
) { ) {
super(); super();
this.cols = Math.max(_optionsService.options.cols || 0, MINIMUM_COLS); this.cols = Math.max(_optionsService.rawOptions.cols || 0, MINIMUM_COLS);
this.rows = Math.max(_optionsService.options.rows || 0, MINIMUM_ROWS); this.rows = Math.max(_optionsService.rawOptions.rows || 0, MINIMUM_ROWS);
this.buffers = new BufferSet(_optionsService, this); this.buffers = new BufferSet(_optionsService, this);
} }
+2 -2
View File
@@ -62,7 +62,7 @@ export class CoreService extends Disposable implements ICoreService {
public triggerDataEvent(data: string, wasUserInput: boolean = false): void { public triggerDataEvent(data: string, wasUserInput: boolean = false): void {
// Prevents all events to pty process if stdin is disabled // Prevents all events to pty process if stdin is disabled
if (this._optionsService.options.disableStdin) { if (this._optionsService.rawOptions.disableStdin) {
return; return;
} }
@@ -83,7 +83,7 @@ export class CoreService extends Disposable implements ICoreService {
} }
public triggerBinaryEvent(data: string): void { public triggerBinaryEvent(data: string): void {
if (this._optionsService.options.disableStdin) { if (this._optionsService.rawOptions.disableStdin) {
return; return;
} }
this._logService.debug(`sending binary "${data}"`, () => data.split('').map(e => e.charCodeAt(0))); this._logService.debug(`sending binary "${data}"`, () => data.split('').map(e => e.charCodeAt(0)));
+1 -1
View File
@@ -46,7 +46,7 @@ export class LogService implements ILogService {
} }
private _updateLogLevel(): void { private _updateLogLevel(): void {
this.logLevel = optionsKeyToLogLevel[this._optionsService.options.logLevel]; this.logLevel = optionsKeyToLogLevel[this._optionsService.rawOptions.logLevel];
} }
private _evalLazyOptionalParams(optionalParams: any[]): void { private _evalLazyOptionalParams(optionalParams: any[]): void {
+5
View File
@@ -188,6 +188,11 @@ export const IOptionsService = createDecorator<IOptionsService>('OptionsService'
export interface IOptionsService { export interface IOptionsService {
serviceBrand: undefined; serviceBrand: undefined;
/**
* Read only access to the raw options object, this is an internal-only fast path for accessing
* single options without any validation as we trust TypeScript to enforce correct usage
* internally.
*/
readonly rawOptions: Readonly<ITerminalOptions>; readonly rawOptions: Readonly<ITerminalOptions>;
readonly options: ITerminalOptions; readonly options: ITerminalOptions;