Move onSpecificOptionChange adoption

This commit is contained in:
Daniel Imms
2022-10-09 08:07:43 -07:00
parent 415100e8b8
commit 49a0904857
4 changed files with 16 additions and 15 deletions
+13 -13
View File
@@ -264,6 +264,17 @@ export class Terminal extends CoreTerminal implements ITerminal {
}
}
private _handleScreenReaderModeOptionChange(value: boolean): void {
if (value) {
if (!this._accessibilityManager && this._renderService) {
this._accessibilityManager = new AccessibilityManager(this, this._renderService);
}
} else {
this._accessibilityManager?.dispose();
this._accessibilityManager = undefined;
}
}
protected _updateOptions(key: string): void {
// TODO: These listeners should be owned by individual components
switch (key) {
@@ -285,6 +296,7 @@ export class Terminal extends CoreTerminal implements ITerminal {
case 'fontWeight':
case 'fontWeightBold':
case 'minimumContrastRatio':
// TODO: move to render service
// When the font changes the size of the cells may change which requires a renderer clear
if (this._renderService) {
this._renderService.clear();
@@ -292,19 +304,6 @@ export class Terminal extends CoreTerminal implements ITerminal {
this.refresh(0, this.rows - 1);
}
break;
case 'scrollback':
this.viewport?.syncScrollArea();
break;
case 'screenReaderMode':
if (this.optionsService.rawOptions.screenReaderMode) {
if (!this._accessibilityManager && this._renderService) {
this._accessibilityManager = new AccessibilityManager(this, this._renderService);
}
} else {
this._accessibilityManager?.dispose();
this._accessibilityManager = undefined;
}
break;
}
}
@@ -577,6 +576,7 @@ export class Terminal extends CoreTerminal implements ITerminal {
// ensure the correct order of the dprchange event
this._accessibilityManager = new AccessibilityManager(this, this._renderService);
}
this.register(this.optionsService.onSpecificOptionChange('screenReaderMode', e => this._handleScreenReaderModeOptionChange(e)));
if (this.options.overviewRulerWidth) {
this._overviewRulerRenderer = this.register(this._instantiationService.createInstance(OverviewRulerRenderer, this._viewportElement, this.screenElement));
+1
View File
@@ -75,6 +75,7 @@ export class Viewport extends Disposable implements IViewport {
this._handleThemeChange(themeService.colors);
this.register(themeService.onChangeColors(e => this._handleThemeChange(e)));
this.register(this._optionsService.onSpecificOptionChange('scrollback', () => this.syncScrollArea()));
// Perform this async to ensure the ICharSizeService is ready.
setTimeout(() => this.syncScrollArea(), 0);
+1 -1
View File
@@ -261,7 +261,7 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
this.coreMouseService.reset();
}
private _handleWindowsModeOptionChange(value: boolean | undefined): void {
private _handleWindowsModeOptionChange(value: boolean): void {
if (value) {
this._enableWindowsMode();
} else {
+1 -1
View File
@@ -200,7 +200,7 @@ export interface IOptionsService {
* preferred over {@link onOptionChange} when only a single option is being listened to.
*/
// eslint-disable-next-line @typescript-eslint/naming-convention
onSpecificOptionChange<T extends keyof ITerminalOptions>(key: T, listener: (arg1: ITerminalOptions[T]) => any): IDisposable;
onSpecificOptionChange<T extends keyof ITerminalOptions>(key: T, listener: (arg1: Required<ITerminalOptions>[T]) => any): IDisposable;
}
export type FontWeight = 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | number;