Adopt onSpecificOptionChange

This commit is contained in:
Daniel Imms
2022-10-09 07:46:10 -07:00
parent cad9c4164c
commit 415100e8b8
8 changed files with 18 additions and 53 deletions
+2 -5
View File
@@ -265,8 +265,6 @@ export class Terminal extends CoreTerminal implements ITerminal {
} }
protected _updateOptions(key: string): void { protected _updateOptions(key: string): void {
super._updateOptions(key);
// TODO: These listeners should be owned by individual components // TODO: These listeners should be owned by individual components
switch (key) { switch (key) {
case 'fontFamily': case 'fontFamily':
@@ -307,7 +305,6 @@ export class Terminal extends CoreTerminal implements ITerminal {
this._accessibilityManager = undefined; this._accessibilityManager = undefined;
} }
break; break;
case 'tabStopWidth': this.buffers.setupTabStops(); break;
} }
} }
@@ -584,8 +581,8 @@ export class Terminal extends CoreTerminal implements ITerminal {
if (this.options.overviewRulerWidth) { if (this.options.overviewRulerWidth) {
this._overviewRulerRenderer = this.register(this._instantiationService.createInstance(OverviewRulerRenderer, this._viewportElement, this.screenElement)); this._overviewRulerRenderer = this.register(this._instantiationService.createInstance(OverviewRulerRenderer, this._viewportElement, this.screenElement));
} }
this.optionsService.onOptionChange(() => { this.optionsService.onSpecificOptionChange('overviewRulerWidth', value => {
if (!this._overviewRulerRenderer && this.options.overviewRulerWidth && this._viewportElement && this.screenElement) { if (!this._overviewRulerRenderer && value && this._viewportElement && this.screenElement) {
this._overviewRulerRenderer = this.register(this._instantiationService.createInstance(OverviewRulerRenderer, this._viewportElement, this.screenElement)); this._overviewRulerRenderer = this.register(this._instantiationService.createInstance(OverviewRulerRenderer, this._viewportElement, this.screenElement));
} }
}); });
@@ -110,15 +110,9 @@ export class OverviewRulerRenderer extends Disposable {
} }
})); }));
// overview ruler width changed // overview ruler width changed
this.register(this._optionsService.onOptionChange(o => { this.register(this._optionsService.onSpecificOptionChange('overviewRulerWidth', () => this._queueRefresh(true)));
if (o === 'overviewRulerWidth') {
this._queueRefresh(true);
}
}));
// device pixel ratio changed // device pixel ratio changed
this.register(addDisposableDomListener(this._coreBrowseService.window, 'resize', () => { this.register(addDisposableDomListener(this._coreBrowseService.window, 'resize', () => this._queueRefresh(true)));
this._queueRefresh(true);
}));
// set the canvas dimensions // set the canvas dimensions
this._queueRefresh(true); this._queueRefresh(true);
} }
+2 -10
View File
@@ -111,16 +111,8 @@ export class ThemeService extends Disposable implements IThemeService {
this._updateRestoreColors(); this._updateRestoreColors();
this._setTheme(this._optionsService.rawOptions.theme); this._setTheme(this._optionsService.rawOptions.theme);
this.register(this._optionsService.onOptionChange(key => { this.register(this._optionsService.onSpecificOptionChange('minimumContrastRatio', () => this._contrastCache.clear()));
switch (key) { this.register(this._optionsService.onSpecificOptionChange('theme', () => this._setTheme(this._optionsService.rawOptions.theme)));
case 'minimumContrastRatio':
this._contrastCache.clear();
break;
case 'theme':
this._setTheme(this._optionsService.rawOptions.theme);
break;
}
}));
} }
/** /**
+7 -15
View File
@@ -130,7 +130,7 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
this.register(forwardEvent(this.coreService.onData, this._onData)); this.register(forwardEvent(this.coreService.onData, this._onData));
this.register(forwardEvent(this.coreService.onBinary, this._onBinary)); this.register(forwardEvent(this.coreService.onBinary, this._onBinary));
this.register(this.coreService.onUserInput(() => this._writeBuffer.handleUserInput())); this.register(this.coreService.onUserInput(() => this._writeBuffer.handleUserInput()));
this.register(this.optionsService.onOptionChange(key => this._updateOptions(key))); this.register(this.optionsService.onSpecificOptionChange('windowsMode', e => this._handleWindowsModeOptionChange(e)));
this.register(this._bufferService.onScroll(event => { this.register(this._bufferService.onScroll(event => {
this._onScroll.fire({ position: this._bufferService.buffer.ydisp, source: ScrollSource.TERMINAL }); this._onScroll.fire({ position: this._bufferService.buffer.ydisp, source: ScrollSource.TERMINAL });
this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop, this._bufferService.buffer.scrollBottom); this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop, this._bufferService.buffer.scrollBottom);
@@ -261,20 +261,12 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
this.coreMouseService.reset(); this.coreMouseService.reset();
} }
protected _updateOptions(key: keyof ITerminalOptions): void { private _handleWindowsModeOptionChange(value: boolean | undefined): void {
// TODO: These listeners should be owned by individual components if (value) {
switch (key) { this._enableWindowsMode();
case 'scrollback': } else {
this.buffers.resize(this.cols, this.rows); this._windowsMode?.dispose();
break; this._windowsMode = undefined;
case 'windowsMode':
if (this.optionsService.rawOptions.windowsMode) {
this._enableWindowsMode();
} else {
this._windowsMode?.dispose();
this._windowsMode = undefined;
}
break;
} }
} }
+3
View File
@@ -32,6 +32,8 @@ export class BufferSet extends Disposable implements IBufferSet {
) { ) {
super(); super();
this.reset(); this.reset();
this.register(this._optionsService.onSpecificOptionChange('scrollback', () => this.resize(this._bufferService.cols, this._bufferService.rows)));
this.register(this._optionsService.onSpecificOptionChange('tabStopWidth', () => this.setupTabStops()));
} }
public reset(): void { public reset(): void {
@@ -119,6 +121,7 @@ export class BufferSet extends Disposable implements IBufferSet {
public resize(newCols: number, newRows: number): void { public resize(newCols: number, newRows: number): void {
this._normal.resize(newCols, newRows); this._normal.resize(newCols, newRows);
this._alt.resize(newCols, newRows); this._alt.resize(newCols, newRows);
this.setupTabStops(newCols);
} }
/** /**
+1 -1
View File
@@ -43,7 +43,7 @@ export class BufferService extends Disposable implements IBufferService {
this.cols = cols; this.cols = cols;
this.rows = rows; this.rows = rows;
this.buffers.resize(cols, rows); this.buffers.resize(cols, rows);
this.buffers.setupTabStops(this.cols); // TODO: This doesn't fire when scrollback changes - add a resize event to BufferSet and forward event
this._onResize.fire({ cols, rows }); this._onResize.fire({ cols, rows });
} }
+1 -5
View File
@@ -40,11 +40,7 @@ export class LogService extends Disposable implements ILogService {
) { ) {
super(); super();
this._updateLogLevel(); this._updateLogLevel();
this.register(this._optionsService.onOptionChange(key => { this.register(this._optionsService.onSpecificOptionChange('logLevel', () => this._updateLogLevel()));
if (key === 'logLevel') {
this._updateLogLevel();
}
}));
} }
private _updateLogLevel(): void { private _updateLogLevel(): void {
-9
View File
@@ -78,15 +78,6 @@ export class Terminal extends CoreTerminal {
return this.buffers.active; return this.buffers.active;
} }
protected _updateOptions(key: string): void {
super._updateOptions(key);
// TODO: These listeners should be owned by individual components
switch (key) {
case 'tabStopWidth': this.buffers.setupTabStops(); break;
}
}
// TODO: Support paste here? // TODO: Support paste here?
public get markers(): IMarker[] { public get markers(): IMarker[] {