Add lint rule to ensure on prefix is only for event emitters

Fixes #4183
This commit is contained in:
Daniel Imms
2022-10-08 10:57:31 -07:00
parent d8c31d7ad0
commit eecf52e949
29 changed files with 198 additions and 195 deletions
+5 -1
View File
@@ -96,7 +96,11 @@
{ "selector": "enumMember", "format": ["UPPER_CASE"] }, { "selector": "enumMember", "format": ["UPPER_CASE"] },
// memberLike - Allow enum-like objects to use UPPER_CASE // memberLike - Allow enum-like objects to use UPPER_CASE
{ "selector": "property", "modifiers": ["public"], "format": ["camelCase", "UPPER_CASE"] }, { "selector": "property", "modifiers": ["public"], "format": ["camelCase", "UPPER_CASE"] },
{ "selector": "method", "modifiers": ["public"], "format": ["camelCase", "UPPER_CASE"] }, // restrict on* naming for events only
{ "selector": "method", "modifiers": ["public"], "format": ["camelCase", "UPPER_CASE"], "custom": {
"regex": "^on[A-Z].+",
"match": false
} },
// typeLike // typeLike
{ "selector": "typeLike", "format": ["PascalCase"] }, { "selector": "typeLike", "format": ["PascalCase"] },
{ "selector": "interface", "format": ["PascalCase"], "prefix": ["I"] } { "selector": "interface", "format": ["PascalCase"], "prefix": ["I"] }
@@ -75,13 +75,13 @@ export abstract class BaseRenderLayer extends Disposable implements IRenderLayer
} }
} }
public onOptionsChanged(): void {} public handleOptionsChanged(): void {}
public onBlur(): void {} public handleBlur(): void {}
public onFocus(): void {} public handleFocus(): void {}
public onCursorMove(): void {} public handleCursorMove(): void {}
public onGridChanged(startRow: number, endRow: number): void {} public handleGridChanged(startRow: number, endRow: number): void {}
public onSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean = false): void { public handleSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean = false): void {
this._selectionModel.update(this._terminal, start, end, columnSelectMode); this._selectionModel.update(this._terminal, start, end, columnSelectMode);
} }
@@ -105,7 +105,7 @@ export abstract class BaseRenderLayer extends Disposable implements IRenderLayer
// Regenerate char atlas and force a full redraw // Regenerate char atlas and force a full redraw
this._refreshCharAtlas(this._colors); this._refreshCharAtlas(this._colors);
this.onGridChanged(0, this._bufferService.rows - 1); this.handleGridChanged(0, this._bufferService.rows - 1);
} }
/** /**
+2 -2
View File
@@ -45,11 +45,11 @@ export class CanvasAddon extends Disposable implements ITerminalAddon {
this._renderer = new CanvasRenderer(terminal, colors, screenElement, linkifier, bufferService, charSizeService, optionsService, characterJoinerService, coreService, coreBrowserService, decorationService); this._renderer = new CanvasRenderer(terminal, colors, screenElement, linkifier, bufferService, charSizeService, optionsService, characterJoinerService, coreService, coreBrowserService, decorationService);
this.register(forwardEvent(this._renderer.onChangeTextureAtlas, this._onChangeTextureAtlas)); this.register(forwardEvent(this._renderer.onChangeTextureAtlas, this._onChangeTextureAtlas));
renderService.setRenderer(this._renderer); renderService.setRenderer(this._renderer);
renderService.onResize(bufferService.cols, bufferService.rows); renderService.handleResize(bufferService.cols, bufferService.rows);
this.register(toDisposable(() => { this.register(toDisposable(() => {
renderService.setRenderer((this._terminal as any)._core._createRenderer()); renderService.setRenderer((this._terminal as any)._core._createRenderer());
renderService.onResize(terminal.cols, terminal.rows); renderService.handleResize(terminal.cols, terminal.rows);
this._renderer?.dispose(); this._renderer?.dispose();
this._renderer = undefined; this._renderer = undefined;
})); }));
+17 -17
View File
@@ -69,7 +69,7 @@ export class CanvasRenderer extends Disposable implements IRenderer {
this.register(observeDevicePixelDimensions(this._renderLayers[0].canvas, this._coreBrowserService.window, (w, h) => this._setCanvasDevicePixelDimensions(w, h))); this.register(observeDevicePixelDimensions(this._renderLayers[0].canvas, this._coreBrowserService.window, (w, h) => this._setCanvasDevicePixelDimensions(w, h)));
this.onOptionsChanged(); this.handleOptionsChanged();
this.register(toDisposable(() => { this.register(toDisposable(() => {
for (const l of this._renderLayers) { for (const l of this._renderLayers) {
@@ -83,12 +83,12 @@ export class CanvasRenderer extends Disposable implements IRenderer {
return this._renderLayers[0].cacheCanvas; return this._renderLayers[0].cacheCanvas;
} }
public onDevicePixelRatioChange(): void { public handleDevicePixelRatioChange(): void {
// If the device pixel ratio changed, the char atlas needs to be regenerated // If the device pixel ratio changed, the char atlas needs to be regenerated
// and the terminal needs to refreshed // and the terminal needs to refreshed
if (this._devicePixelRatio !== this._coreBrowserService.dpr) { if (this._devicePixelRatio !== this._coreBrowserService.dpr) {
this._devicePixelRatio = this._coreBrowserService.dpr; this._devicePixelRatio = this._coreBrowserService.dpr;
this.onResize(this._bufferService.cols, this._bufferService.rows); this.handleResize(this._bufferService.cols, this._bufferService.rows);
} }
} }
@@ -101,7 +101,7 @@ export class CanvasRenderer extends Disposable implements IRenderer {
} }
} }
public onResize(cols: number, rows: number): void { public handleResize(cols: number, rows: number): void {
// Update character and canvas dimensions // Update character and canvas dimensions
this._updateDimensions(); this._updateDimensions();
@@ -115,32 +115,32 @@ export class CanvasRenderer extends Disposable implements IRenderer {
this._screenElement.style.height = `${this.dimensions.canvasHeight}px`; this._screenElement.style.height = `${this.dimensions.canvasHeight}px`;
} }
public onCharSizeChanged(): void { public handleCharSizeChanged(): void {
this.onResize(this._bufferService.cols, this._bufferService.rows); this.handleResize(this._bufferService.cols, this._bufferService.rows);
} }
public onBlur(): void { public handleBlur(): void {
this._runOperation(l => l.onBlur()); this._runOperation(l => l.handleBlur());
} }
public onFocus(): void { public handleFocus(): void {
this._runOperation(l => l.onFocus()); this._runOperation(l => l.handleFocus());
} }
public onSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean = false): void { public handleSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean = false): void {
this._runOperation(l => l.onSelectionChanged(start, end, columnSelectMode)); this._runOperation(l => l.handleSelectionChanged(start, end, columnSelectMode));
// Selection foreground requires a full re-render // Selection foreground requires a full re-render
if (this._colors.selectionForeground) { if (this._colors.selectionForeground) {
this._onRequestRedraw.fire({ start: 0, end: this._bufferService.rows - 1 }); this._onRequestRedraw.fire({ start: 0, end: this._bufferService.rows - 1 });
} }
} }
public onCursorMove(): void { public handleCursorMove(): void {
this._runOperation(l => l.onCursorMove()); this._runOperation(l => l.handleCursorMove());
} }
public onOptionsChanged(): void { public handleOptionsChanged(): void {
this._runOperation(l => l.onOptionsChanged()); this._runOperation(l => l.handleOptionsChanged());
} }
public clear(): void { public clear(): void {
@@ -159,7 +159,7 @@ export class CanvasRenderer extends Disposable implements IRenderer {
*/ */
public renderRows(start: number, end: number): void { public renderRows(start: number, end: number): void {
for (const l of this._renderLayers) { for (const l of this._renderLayers) {
l.onGridChanged(start, end); l.handleGridChanged(start, end);
} }
} }
@@ -79,20 +79,20 @@ export class CursorRenderLayer extends BaseRenderLayer {
public reset(): void { public reset(): void {
this._clearCursor(); this._clearCursor();
this._cursorBlinkStateManager?.restartBlinkAnimation(); this._cursorBlinkStateManager?.restartBlinkAnimation();
this.onOptionsChanged(); this.handleOptionsChanged();
} }
public onBlur(): void { public handleBlur(): void {
this._cursorBlinkStateManager?.pause(); this._cursorBlinkStateManager?.pause();
this._onRequestRedraw.fire({ start: this._bufferService.buffer.y, end: this._bufferService.buffer.y }); this._onRequestRedraw.fire({ start: this._bufferService.buffer.y, end: this._bufferService.buffer.y });
} }
public onFocus(): void { public handleFocus(): void {
this._cursorBlinkStateManager?.resume(); this._cursorBlinkStateManager?.resume();
this._onRequestRedraw.fire({ start: this._bufferService.buffer.y, end: this._bufferService.buffer.y }); this._onRequestRedraw.fire({ start: this._bufferService.buffer.y, end: this._bufferService.buffer.y });
} }
public onOptionsChanged(): void { public handleOptionsChanged(): void {
if (this._optionsService.rawOptions.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, () => {
@@ -108,11 +108,11 @@ export class CursorRenderLayer extends BaseRenderLayer {
this._onRequestRedraw.fire({ start: this._bufferService.buffer.y, end: this._bufferService.buffer.y }); this._onRequestRedraw.fire({ start: this._bufferService.buffer.y, end: this._bufferService.buffer.y });
} }
public onCursorMove(): void { public handleCursorMove(): void {
this._cursorBlinkStateManager?.restartBlinkAnimation(); this._cursorBlinkStateManager?.restartBlinkAnimation();
} }
public onGridChanged(startRow: number, endRow: number): void { public handleGridChanged(startRow: number, endRow: number): void {
if (!this._cursorBlinkStateManager || this._cursorBlinkStateManager.isPaused) { if (!this._cursorBlinkStateManager || this._cursorBlinkStateManager.isPaused) {
this._render(false); this._render(false);
} else { } else {
@@ -59,18 +59,18 @@ export class SelectionRenderLayer extends BaseRenderLayer {
} }
} }
public onBlur(): void { public handleBlur(): void {
this.reset(); this.reset();
this._redrawSelection(this._selectionModel.selectionStart, this._selectionModel.selectionEnd, this._selectionModel.columnSelectMode); this._redrawSelection(this._selectionModel.selectionStart, this._selectionModel.selectionEnd, this._selectionModel.columnSelectMode);
} }
public onFocus(): void { public handleFocus(): void {
this.reset(); this.reset();
this._redrawSelection(this._selectionModel.selectionStart, this._selectionModel.selectionEnd, this._selectionModel.columnSelectMode); this._redrawSelection(this._selectionModel.selectionStart, this._selectionModel.selectionEnd, this._selectionModel.columnSelectMode);
} }
public onSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean): void { public handleSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean): void {
super.onSelectionChanged(start, end, columnSelectMode); super.handleSelectionChanged(start, end, columnSelectMode);
this._redrawSelection(start, end, columnSelectMode); this._redrawSelection(start, end, columnSelectMode);
} }
@@ -236,7 +236,7 @@ export class TextRenderLayer extends BaseRenderLayer {
this._forEachCell(firstRow, lastRow, (cell, x, y) => this._drawChars(cell, x, y)); this._forEachCell(firstRow, lastRow, (cell, x, y) => this._drawChars(cell, x, y));
} }
public onGridChanged(firstRow: number, lastRow: number): void { public handleGridChanged(firstRow: number, lastRow: number): void {
// Resize has not been called yet // Resize has not been called yet
if (this._state.cache.length === 0) { if (this._state.cache.length === 0) {
return; return;
@@ -251,7 +251,7 @@ export class TextRenderLayer extends BaseRenderLayer {
this._drawForeground(firstRow, lastRow); this._drawForeground(firstRow, lastRow);
} }
public onOptionsChanged(): void { public handleOptionsChanged(): void {
this._setTransparency(this._optionsService.rawOptions.allowTransparency); this._setTransparency(this._optionsService.rawOptions.allowTransparency);
} }
+14 -14
View File
@@ -42,14 +42,14 @@ export interface IRenderer extends IDisposable {
readonly onRequestRedraw: IEvent<IRequestRedrawEvent>; readonly onRequestRedraw: IEvent<IRequestRedrawEvent>;
setColors(colors: IColorSet): void; setColors(colors: IColorSet): void;
onDevicePixelRatioChange(): void; handleDevicePixelRatioChange(): void;
onResize(cols: number, rows: number): void; handleResize(cols: number, rows: number): void;
onCharSizeChanged(): void; handleCharSizeChanged(): void;
onBlur(): void; handleBlur(): void;
onFocus(): void; handleFocus(): void;
onSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean): void; handleSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean): void;
onCursorMove(): void; handleCursorMove(): void;
onOptionsChanged(): void; handleOptionsChanged(): void;
clear(): void; clear(): void;
renderRows(start: number, end: number): void; renderRows(start: number, end: number): void;
clearTextureAtlas?(): void; clearTextureAtlas?(): void;
@@ -62,22 +62,22 @@ export interface IRenderLayer extends IDisposable {
/** /**
* Called when the terminal loses focus. * Called when the terminal loses focus.
*/ */
onBlur(): void; handleBlur(): void;
/** /**
* * Called when the terminal gets focus. * * Called when the terminal gets focus.
*/ */
onFocus(): void; handleFocus(): void;
/** /**
* Called when the cursor is moved. * Called when the cursor is moved.
*/ */
onCursorMove(): void; handleCursorMove(): void;
/** /**
* Called when options change. * Called when options change.
*/ */
onOptionsChanged(): void; handleOptionsChanged(): void;
/** /**
* Called when the theme changes. * Called when the theme changes.
@@ -88,12 +88,12 @@ export interface IRenderLayer extends IDisposable {
* Called when the data in the grid has changed (or needs to be rendered * Called when the data in the grid has changed (or needs to be rendered
* again). * again).
*/ */
onGridChanged(startRow: number, endRow: number): void; handleGridChanged(startRow: number, endRow: number): void;
/** /**
* Calls when the selection changes. * Calls when the selection changes.
*/ */
onSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean): void; handleSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean): void;
/** /**
* Resize the render layer. * Resize the render layer.
@@ -167,7 +167,7 @@ export class GlyphRenderer extends Disposable {
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA); gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
// Set viewport // Set viewport
this.onResize(); this.handleResize();
} }
public beginFrame(): boolean { public beginFrame(): boolean {
@@ -263,7 +263,7 @@ export class GlyphRenderer extends Disposable {
} }
} }
public onResize(): void { public handleResize(): void {
const gl = this._gl; const gl = this._gl;
gl.viewport(0, 0, gl.canvas.width, gl.canvas.height); gl.viewport(0, 0, gl.canvas.width, gl.canvas.height);
this.clear(); this.clear();
@@ -151,7 +151,7 @@ export class RectangleRenderer extends Disposable {
gl.drawElementsInstanced(this._gl.TRIANGLES, 6, gl.UNSIGNED_BYTE, 0, this._vertices.count); gl.drawElementsInstanced(this._gl.TRIANGLES, 6, gl.UNSIGNED_BYTE, 0, this._vertices.count);
} }
public onResize(): void { public handleResize(): void {
this._updateViewportRectangle(); this._updateViewportRectangle();
} }
+1 -1
View File
@@ -51,7 +51,7 @@ export class WebglAddon extends Disposable implements ITerminalAddon {
this.register(toDisposable(() => { this.register(toDisposable(() => {
const renderService: IRenderService = (this._terminal as any)._core._renderService; const renderService: IRenderService = (this._terminal as any)._core._renderService;
renderService.setRenderer((this._terminal as any)._core._createRenderer()); renderService.setRenderer((this._terminal as any)._core._createRenderer());
renderService.onResize(terminal.cols, terminal.rows); renderService.handleResize(terminal.cols, terminal.rows);
})); }));
} }
+19 -19
View File
@@ -162,16 +162,16 @@ export class WebglRenderer extends Disposable implements IRenderer {
this._clearModel(true); this._clearModel(true);
} }
public onDevicePixelRatioChange(): void { public handleDevicePixelRatioChange(): void {
// If the device pixel ratio changed, the char atlas needs to be regenerated // If the device pixel ratio changed, the char atlas needs to be regenerated
// and the terminal needs to refreshed // and the terminal needs to refreshed
if (this._devicePixelRatio !== this._coreBrowserService.dpr) { if (this._devicePixelRatio !== this._coreBrowserService.dpr) {
this._devicePixelRatio = this._coreBrowserService.dpr; this._devicePixelRatio = this._coreBrowserService.dpr;
this.onResize(this._terminal.cols, this._terminal.rows); this.handleResize(this._terminal.cols, this._terminal.rows);
} }
} }
public onResize(cols: number, rows: number): void { public handleResize(cols: number, rows: number): void {
// Update character and canvas dimensions // Update character and canvas dimensions
this._updateDimensions(); this._updateDimensions();
@@ -193,9 +193,9 @@ export class WebglRenderer extends Disposable implements IRenderer {
this._core.screenElement!.style.height = `${this.dimensions.canvasHeight}px`; this._core.screenElement!.style.height = `${this.dimensions.canvasHeight}px`;
this._rectangleRenderer.setDimensions(this.dimensions); this._rectangleRenderer.setDimensions(this.dimensions);
this._rectangleRenderer.onResize(); this._rectangleRenderer.handleResize();
this._glyphRenderer.setDimensions(this.dimensions); this._glyphRenderer.setDimensions(this.dimensions);
this._glyphRenderer.onResize(); this._glyphRenderer.handleResize();
this._refreshCharAtlas(); this._refreshCharAtlas();
@@ -204,43 +204,43 @@ export class WebglRenderer extends Disposable implements IRenderer {
this._clearModel(false); this._clearModel(false);
} }
public onCharSizeChanged(): void { public handleCharSizeChanged(): void {
this.onResize(this._terminal.cols, this._terminal.rows); this.handleResize(this._terminal.cols, this._terminal.rows);
} }
public onBlur(): void { public handleBlur(): void {
for (const l of this._renderLayers) { for (const l of this._renderLayers) {
l.onBlur(this._terminal); l.handleBlur(this._terminal);
} }
// Request a redraw for active/inactive selection background // Request a redraw for active/inactive selection background
this._requestRedrawViewport(); this._requestRedrawViewport();
} }
public onFocus(): void { public handleFocus(): void {
for (const l of this._renderLayers) { for (const l of this._renderLayers) {
l.onFocus(this._terminal); l.handleFocus(this._terminal);
} }
// Request a redraw for active/inactive selection background // Request a redraw for active/inactive selection background
this._requestRedrawViewport(); this._requestRedrawViewport();
} }
public onSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean): void { public handleSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean): void {
for (const l of this._renderLayers) { for (const l of this._renderLayers) {
l.onSelectionChanged(this._terminal, start, end, columnSelectMode); l.handleSelectionChanged(this._terminal, start, end, columnSelectMode);
} }
this._model.selection.update(this._terminal, start, end, columnSelectMode); this._model.selection.update(this._terminal, start, end, columnSelectMode);
this._requestRedrawViewport(); this._requestRedrawViewport();
} }
public onCursorMove(): void { public handleCursorMove(): void {
for (const l of this._renderLayers) { for (const l of this._renderLayers) {
l.onCursorMove(this._terminal); l.handleCursorMove(this._terminal);
} }
} }
public onOptionsChanged(): void { public handleOptionsChanged(): void {
for (const l of this._renderLayers) { for (const l of this._renderLayers) {
l.onOptionsChanged(this._terminal); l.handleOptionsChanged(this._terminal);
} }
this._updateDimensions(); this._updateDimensions();
this._refreshCharAtlas(); this._refreshCharAtlas();
@@ -258,7 +258,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
this._glyphRenderer = this.register(new GlyphRenderer(this._terminal, this._gl, this.dimensions)); this._glyphRenderer = this.register(new GlyphRenderer(this._terminal, this._gl, this.dimensions));
// Update dimensions and acquire char atlas // Update dimensions and acquire char atlas
this.onCharSizeChanged(); this.handleCharSizeChanged();
} }
/** /**
@@ -328,7 +328,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
// Update render layers // Update render layers
for (const l of this._renderLayers) { for (const l of this._renderLayers) {
l.onGridChanged(this._terminal, start, end); l.handleGridChanged(this._terminal, start, end);
} }
// Tell renderer the frame is beginning // Tell renderer the frame is beginning
@@ -54,12 +54,12 @@ export abstract class BaseRenderLayer extends Disposable implements IRenderLayer
} }
} }
public onOptionsChanged(terminal: Terminal): void {} public handleOptionsChanged(terminal: Terminal): void {}
public onBlur(terminal: Terminal): void {} public handleBlur(terminal: Terminal): void {}
public onFocus(terminal: Terminal): void {} public handleFocus(terminal: Terminal): void {}
public onCursorMove(terminal: Terminal): void {} public handleCursorMove(terminal: Terminal): void {}
public onGridChanged(terminal: Terminal, startRow: number, endRow: number): void {} public handleGridChanged(terminal: Terminal, startRow: number, endRow: number): void {}
public onSelectionChanged(terminal: Terminal, start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean = false): void {} public handleSelectionChanged(terminal: Terminal, start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean = false): void {}
public setColors(terminal: Terminal, colorSet: IColorSet): void { public setColors(terminal: Terminal, colorSet: IColorSet): void {
this._refreshCharAtlas(terminal, colorSet); this._refreshCharAtlas(terminal, colorSet);
@@ -81,7 +81,7 @@ export abstract class BaseRenderLayer extends Disposable implements IRenderLayer
// Regenerate char atlas and force a full redraw // Regenerate char atlas and force a full redraw
this._refreshCharAtlas(terminal, this._colors); this._refreshCharAtlas(terminal, this._colors);
this.onGridChanged(terminal, 0, terminal.rows - 1); this.handleGridChanged(terminal, 0, terminal.rows - 1);
} }
/** /**
@@ -55,7 +55,7 @@ export class CursorRenderLayer extends BaseRenderLayer {
'block': this._renderBlockCursor.bind(this), 'block': this._renderBlockCursor.bind(this),
'underline': this._renderUnderlineCursor.bind(this) 'underline': this._renderUnderlineCursor.bind(this)
}; };
this.onOptionsChanged(terminal); this.handleOptionsChanged(terminal);
this.register(toDisposable(() => { this.register(toDisposable(() => {
this._cursorBlinkStateManager?.dispose(); this._cursorBlinkStateManager?.dispose();
this._cursorBlinkStateManager = undefined; this._cursorBlinkStateManager = undefined;
@@ -77,20 +77,20 @@ export class CursorRenderLayer extends BaseRenderLayer {
public reset(terminal: Terminal): void { public reset(terminal: Terminal): void {
this._clearCursor(); this._clearCursor();
this._cursorBlinkStateManager?.restartBlinkAnimation(terminal); this._cursorBlinkStateManager?.restartBlinkAnimation(terminal);
this.onOptionsChanged(terminal); this.handleOptionsChanged(terminal);
} }
public onBlur(terminal: Terminal): void { public handleBlur(terminal: Terminal): void {
this._cursorBlinkStateManager?.pause(); this._cursorBlinkStateManager?.pause();
this._onRequestRefreshRowsEvent.fire({ start: terminal.buffer.active.cursorY, end: terminal.buffer.active.cursorY }); this._onRequestRefreshRowsEvent.fire({ start: terminal.buffer.active.cursorY, end: terminal.buffer.active.cursorY });
} }
public onFocus(terminal: Terminal): void { public handleFocus(terminal: Terminal): void {
this._cursorBlinkStateManager?.resume(terminal); this._cursorBlinkStateManager?.resume(terminal);
this._onRequestRefreshRowsEvent.fire({ start: terminal.buffer.active.cursorY, end: terminal.buffer.active.cursorY }); this._onRequestRefreshRowsEvent.fire({ start: terminal.buffer.active.cursorY, end: terminal.buffer.active.cursorY });
} }
public onOptionsChanged(terminal: Terminal): void { public handleOptionsChanged(terminal: Terminal): void {
if (terminal.options.cursorBlink) { if (terminal.options.cursorBlink) {
if (!this._cursorBlinkStateManager) { if (!this._cursorBlinkStateManager) {
this._cursorBlinkStateManager = new CursorBlinkStateManager(() => { this._cursorBlinkStateManager = new CursorBlinkStateManager(() => {
@@ -106,11 +106,11 @@ export class CursorRenderLayer extends BaseRenderLayer {
this._onRequestRefreshRowsEvent.fire({ start: terminal.buffer.active.cursorY, end: terminal.buffer.active.cursorY }); this._onRequestRefreshRowsEvent.fire({ start: terminal.buffer.active.cursorY, end: terminal.buffer.active.cursorY });
} }
public onCursorMove(terminal: Terminal): void { public handleCursorMove(terminal: Terminal): void {
this._cursorBlinkStateManager?.restartBlinkAnimation(terminal); this._cursorBlinkStateManager?.restartBlinkAnimation(terminal);
} }
public onGridChanged(terminal: Terminal, startRow: number, endRow: number): void { public handleGridChanged(terminal: Terminal, startRow: number, endRow: number): void {
if (!this._cursorBlinkStateManager || this._cursorBlinkStateManager.isPaused) { if (!this._cursorBlinkStateManager || this._cursorBlinkStateManager.isPaused) {
this._render(terminal, false); this._render(terminal, false);
} else { } else {
@@ -11,22 +11,22 @@ export interface IRenderLayer extends IDisposable {
/** /**
* Called when the terminal loses focus. * Called when the terminal loses focus.
*/ */
onBlur(terminal: Terminal): void; handleBlur(terminal: Terminal): void;
/** /**
* * Called when the terminal gets focus. * * Called when the terminal gets focus.
*/ */
onFocus(terminal: Terminal): void; handleFocus(terminal: Terminal): void;
/** /**
* Called when the cursor is moved. * Called when the cursor is moved.
*/ */
onCursorMove(terminal: Terminal): void; handleCursorMove(terminal: Terminal): void;
/** /**
* Called when options change. * Called when options change.
*/ */
onOptionsChanged(terminal: Terminal): void; handleOptionsChanged(terminal: Terminal): void;
/** /**
* Called when the theme changes. * Called when the theme changes.
@@ -37,12 +37,12 @@ export interface IRenderLayer extends IDisposable {
* Called when the data in the grid has changed (or needs to be rendered * Called when the data in the grid has changed (or needs to be rendered
* again). * again).
*/ */
onGridChanged(terminal: Terminal, startRow: number, endRow: number): void; handleGridChanged(terminal: Terminal, startRow: number, endRow: number): void;
/** /**
* Calls when the selection changes. * Calls when the selection changes.
*/ */
onSelectionChanged(terminal: Terminal, start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean): void; handleSelectionChanged(terminal: Terminal, start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean): void;
/** /**
* Registers a handler to join characters to render as a group * Registers a handler to join characters to render as a group
+1 -1
View File
@@ -102,7 +102,7 @@ export class ColorManager implements IColorManager {
this._updateRestoreColors(); this._updateRestoreColors();
} }
public onOptionsChange(key: string, value: any): void { public handleOptionsChange(key: string, value: any): void {
switch (key) { switch (key) {
case 'minimumContrastRatio': case 'minimumContrastRatio':
this._contrastCache.clear(); this._contrastCache.clear();
+14 -14
View File
@@ -238,7 +238,7 @@ export class Terminal extends CoreTerminal implements ITerminal {
} }
} }
this._renderService?.setColors(this._colorManager.colors); this._renderService?.setColors(this._colorManager.colors);
this.viewport?.onThemeChange(this._colorManager.colors); this.viewport?.handleThemeChange(this._colorManager.colors);
} }
protected _setup(): void { protected _setup(): void {
@@ -289,7 +289,7 @@ export class Terminal extends CoreTerminal implements ITerminal {
// When the font changes the size of the cells may change which requires a renderer clear // When the font changes the size of the cells may change which requires a renderer clear
if (this._renderService) { if (this._renderService) {
this._renderService.clear(); this._renderService.clear();
this._renderService.onResize(this.cols, this.rows); this._renderService.handleResize(this.cols, this.rows);
this.refresh(0, this.rows - 1); this.refresh(0, this.rows - 1);
} }
break; break;
@@ -500,7 +500,7 @@ export class Terminal extends CoreTerminal implements ITerminal {
this._theme = this.options.theme || this._theme; this._theme = this.options.theme || this._theme;
this._colorManager = new ColorManager(); this._colorManager = new ColorManager();
this.register(this.optionsService.onOptionChange(e => this._colorManager!.onOptionsChange(e, this.optionsService.rawOptions[e]))); this.register(this.optionsService.onOptionChange(e => this._colorManager!.handleOptionsChange(e, this.optionsService.rawOptions[e])));
this._colorManager.setTheme(this._theme); this._colorManager.setTheme(this._theme);
this._characterJoinerService = this._instantiationService.createInstance(CharacterJoinerService); this._characterJoinerService = this._instantiationService.createInstance(CharacterJoinerService);
@@ -533,17 +533,17 @@ export class Terminal extends CoreTerminal implements ITerminal {
this._viewportScrollArea, this._viewportScrollArea,
this.element this.element
); );
this.viewport.onThemeChange(this._colorManager.colors); this.viewport.handleThemeChange(this._colorManager.colors);
this.register(this._inputHandler.onRequestSyncScrollBar(() => this.viewport!.syncScrollArea())); this.register(this._inputHandler.onRequestSyncScrollBar(() => this.viewport!.syncScrollArea()));
this.register(this.viewport); this.register(this.viewport);
this.register(this.onCursorMove(() => { this.register(this.onCursorMove(() => {
this._renderService!.onCursorMove(); this._renderService!.handleCursorMove();
this._syncTextArea(); this._syncTextArea();
})); }));
this.register(this.onResize(() => this._renderService!.onResize(this.cols, this.rows))); this.register(this.onResize(() => this._renderService!.handleResize(this.cols, this.rows)));
this.register(this.onBlur(() => this._renderService!.onBlur())); this.register(this.onBlur(() => this._renderService!.handleBlur()));
this.register(this.onFocus(() => this._renderService!.onFocus())); this.register(this.onFocus(() => this._renderService!.handleFocus()));
this.register(this._renderService.onDimensionsChange(() => this.viewport!.syncScrollArea())); this.register(this._renderService.onDimensionsChange(() => this.viewport!.syncScrollArea()));
this._selectionService = this.register(this._instantiationService.createInstance(SelectionService, this._selectionService = this.register(this._instantiationService.createInstance(SelectionService,
@@ -554,7 +554,7 @@ export class Terminal extends CoreTerminal implements ITerminal {
this._instantiationService.setService(ISelectionService, this._selectionService); this._instantiationService.setService(ISelectionService, this._selectionService);
this.register(this._selectionService.onRequestScrollLines(e => this.scrollLines(e.amount, e.suppressScrollEvent))); this.register(this._selectionService.onRequestScrollLines(e => this.scrollLines(e.amount, e.suppressScrollEvent)));
this.register(this._selectionService.onSelectionChange(() => this._onSelectionChange.fire())); this.register(this._selectionService.onSelectionChange(() => this._onSelectionChange.fire()));
this.register(this._selectionService.onRequestRedraw(e => this._renderService!.onSelectionChanged(e.start, e.end, e.columnSelectMode))); this.register(this._selectionService.onRequestRedraw(e => this._renderService!.handleSelectionChanged(e.start, e.end, e.columnSelectMode)));
this.register(this._selectionService.onLinuxMouseSelection(text => { this.register(this._selectionService.onLinuxMouseSelection(text => {
// If there's a new selection, put it into the textarea, focus and select it // If there's a new selection, put it into the textarea, focus and select it
// in order to register it as a selection on the OS. This event is fired // in order to register it as a selection on the OS. This event is fired
@@ -571,7 +571,7 @@ export class Terminal extends CoreTerminal implements ITerminal {
this.linkifier2.attachToDom(this.screenElement, this._mouseService, this._renderService); this.linkifier2.attachToDom(this.screenElement, this._mouseService, this._renderService);
this.register(this._instantiationService.createInstance(BufferDecorationRenderer, this.screenElement)); this.register(this._instantiationService.createInstance(BufferDecorationRenderer, this.screenElement));
this.register(addDisposableDomListener(this.element, 'mousedown', (e: MouseEvent) => this._selectionService!.onMouseDown(e))); this.register(addDisposableDomListener(this.element, 'mousedown', (e: MouseEvent) => this._selectionService!.handleMouseDown(e)));
// apply mouse event classes set by escape codes before terminal was attached // apply mouse event classes set by escape codes before terminal was attached
if (this.coreMouseService.areMouseEventsActive) { if (this.coreMouseService.areMouseEventsActive) {
@@ -621,7 +621,7 @@ export class Terminal extends CoreTerminal implements ITerminal {
this._theme = theme; this._theme = theme;
this._colorManager?.setTheme(theme); this._colorManager?.setTheme(theme);
this._renderService?.setColors(this._colorManager!.colors); this._renderService?.setColors(this._colorManager!.colors);
this.viewport?.onThemeChange(this._colorManager!.colors); this.viewport?.handleThemeChange(this._colorManager!.colors);
} }
/** /**
@@ -860,20 +860,20 @@ export class Terminal extends CoreTerminal implements ITerminal {
// normal viewport scrolling // normal viewport scrolling
// conditionally stop event, if the viewport still had rows to scroll within // conditionally stop event, if the viewport still had rows to scroll within
if (this.viewport!.onWheel(ev)) { if (this.viewport!.handleWheel(ev)) {
return this.cancel(ev); return this.cancel(ev);
} }
}, { passive: false })); }, { passive: false }));
this.register(addDisposableDomListener(el, 'touchstart', (ev: TouchEvent) => { this.register(addDisposableDomListener(el, 'touchstart', (ev: TouchEvent) => {
if (this.coreMouseService.areMouseEventsActive) return; if (this.coreMouseService.areMouseEventsActive) return;
this.viewport!.onTouchStart(ev); this.viewport!.handleTouchStart(ev);
return this.cancel(ev); return this.cancel(ev);
}, { passive: true })); }, { passive: true }));
this.register(addDisposableDomListener(el, 'touchmove', (ev: TouchEvent) => { this.register(addDisposableDomListener(el, 'touchmove', (ev: TouchEvent) => {
if (this.coreMouseService.areMouseEventsActive) return; if (this.coreMouseService.areMouseEventsActive) return;
if (!this.viewport!.onTouchMove(ev)) { if (!this.viewport!.handleTouchMove(ev)) {
return this.cancel(ev); return this.cancel(ev);
} }
}, { passive: false })); }, { passive: false }));
+20 -20
View File
@@ -285,14 +285,14 @@ export class MockRenderer implements IRenderer {
public registerDecoration(decorationOptions: IDecorationOptions): IDecoration { public registerDecoration(decorationOptions: IDecorationOptions): IDecoration {
throw new Error('Method not implemented.'); throw new Error('Method not implemented.');
} }
public onResize(cols: number, rows: number): void { } public handleResize(cols: number, rows: number): void { }
public onCharSizeChanged(): void { } public handleCharSizeChanged(): void { }
public onBlur(): void { } public handleBlur(): void { }
public onFocus(): void { } public handleFocus(): void { }
public onSelectionChanged(start: [number, number], end: [number, number]): void { } public handleSelectionChanged(start: [number, number], end: [number, number]): void { }
public onCursorMove(): void { } public handleCursorMove(): void { }
public onOptionsChanged(): void { } public handleOptionsChanged(): void { }
public onDevicePixelRatioChange(): void { } public handleDevicePixelRatioChange(): void { }
public clear(): void { } public clear(): void { }
public renderRows(start: number, end: number): void { } public renderRows(start: number, end: number): void { }
} }
@@ -302,16 +302,16 @@ export class MockViewport implements IViewport {
throw new Error('Method not implemented.'); throw new Error('Method not implemented.');
} }
public scrollBarWidth: number = 0; public scrollBarWidth: number = 0;
public onThemeChange(colors: IColorSet): void { public handleThemeChange(colors: IColorSet): void {
throw new Error('Method not implemented.'); throw new Error('Method not implemented.');
} }
public onWheel(ev: WheelEvent): boolean { public handleWheel(ev: WheelEvent): boolean {
throw new Error('Method not implemented.'); throw new Error('Method not implemented.');
} }
public onTouchStart(ev: TouchEvent): void { public handleTouchStart(ev: TouchEvent): void {
throw new Error('Method not implemented.'); throw new Error('Method not implemented.');
} }
public onTouchMove(ev: TouchEvent): boolean { public handleTouchMove(ev: TouchEvent): boolean {
throw new Error('Method not implemented.'); throw new Error('Method not implemented.');
} }
public syncScrollArea(): void { } public syncScrollArea(): void { }
@@ -410,25 +410,25 @@ export class MockRenderService implements IRenderService {
public setColors(colors: IColorSet): void { public setColors(colors: IColorSet): void {
throw new Error('Method not implemented.'); throw new Error('Method not implemented.');
} }
public onDevicePixelRatioChange(): void { public handleDevicePixelRatioChange(): void {
throw new Error('Method not implemented.'); throw new Error('Method not implemented.');
} }
public onResize(cols: number, rows: number): void { public handleResize(cols: number, rows: number): void {
throw new Error('Method not implemented.'); throw new Error('Method not implemented.');
} }
public onCharSizeChanged(): void { public handleCharSizeChanged(): void {
throw new Error('Method not implemented.'); throw new Error('Method not implemented.');
} }
public onBlur(): void { public handleBlur(): void {
throw new Error('Method not implemented.'); throw new Error('Method not implemented.');
} }
public onFocus(): void { public handleFocus(): void {
throw new Error('Method not implemented.'); throw new Error('Method not implemented.');
} }
public onSelectionChanged(start: [number, number], end: [number, number], columnSelectMode: boolean): void { public handleSelectionChanged(start: [number, number], end: [number, number], columnSelectMode: boolean): void {
throw new Error('Method not implemented.'); throw new Error('Method not implemented.');
} }
public onCursorMove(): void { public handleCursorMove(): void {
throw new Error('Method not implemented.'); throw new Error('Method not implemented.');
} }
public clear(): void { public clear(): void {
@@ -498,7 +498,7 @@ export class MockSelectionService implements ISelectionService {
public refresh(isLinuxMouseSelection?: boolean): void { public refresh(isLinuxMouseSelection?: boolean): void {
throw new Error('Method not implemented.'); throw new Error('Method not implemented.');
} }
public onMouseDown(event: MouseEvent): void { public handleMouseDown(event: MouseEvent): void {
throw new Error('Method not implemented.'); throw new Error('Method not implemented.');
} }
public isCellInSelection(x: number, y: number): boolean { public isCellInSelection(x: number, y: number): boolean {
+5 -5
View File
@@ -108,7 +108,7 @@ export interface IBrowser {
export interface IColorManager { export interface IColorManager {
colors: IColorSet; colors: IColorSet;
onOptionsChange(key: string, value: any): void; handleOptionsChange(key: string, value: any): void;
} }
export interface IColorSet { export interface IColorSet {
@@ -147,10 +147,10 @@ export interface IViewport extends IDisposable {
scrollBarWidth: number; scrollBarWidth: number;
syncScrollArea(immediate?: boolean): void; syncScrollArea(immediate?: boolean): void;
getLinesScrolled(ev: WheelEvent): number; getLinesScrolled(ev: WheelEvent): number;
onWheel(ev: WheelEvent): boolean; handleWheel(ev: WheelEvent): boolean;
onTouchStart(ev: TouchEvent): void; handleTouchStart(ev: TouchEvent): void;
onTouchMove(ev: TouchEvent): boolean; handleTouchMove(ev: TouchEvent): boolean;
onThemeChange(colors: IColorSet): void; handleThemeChange(colors: IColorSet): void;
} }
export interface ILinkifierEvent { export interface ILinkifierEvent {
+4 -4
View File
@@ -77,7 +77,7 @@ export class Viewport extends Disposable implements IViewport {
setTimeout(() => this.syncScrollArea(), 0); setTimeout(() => this.syncScrollArea(), 0);
} }
public onThemeChange(colors: IColorSet): void { public handleThemeChange(colors: IColorSet): void {
this._viewportElement.style.backgroundColor = colors.background.css; this._viewportElement.style.backgroundColor = colors.background.css;
} }
@@ -234,7 +234,7 @@ export class Viewport extends Disposable implements IViewport {
* `Viewport`. * `Viewport`.
* @param ev The mouse wheel event. * @param ev The mouse wheel event.
*/ */
public onWheel(ev: WheelEvent): boolean { public handleWheel(ev: WheelEvent): boolean {
const amount = this._getPixelsScrolled(ev); const amount = this._getPixelsScrolled(ev);
if (amount === 0) { if (amount === 0) {
return false; return false;
@@ -315,7 +315,7 @@ export class Viewport extends Disposable implements IViewport {
* Handles the touchstart event, recording the touch occurred. * Handles the touchstart event, recording the touch occurred.
* @param ev The touch event. * @param ev The touch event.
*/ */
public onTouchStart(ev: TouchEvent): void { public handleTouchStart(ev: TouchEvent): void {
this._lastTouchY = ev.touches[0].pageY; this._lastTouchY = ev.touches[0].pageY;
} }
@@ -323,7 +323,7 @@ export class Viewport extends Disposable implements IViewport {
* Handles the touchmove event, scrolling the viewport if the position shifted. * Handles the touchmove event, scrolling the viewport if the position shifted.
* @param ev The touch event. * @param ev The touch event.
*/ */
public onTouchMove(ev: TouchEvent): boolean { public handleTouchMove(ev: TouchEvent): boolean {
const deltaY = this._lastTouchY - ev.touches[0].pageY; const deltaY = this._lastTouchY - ev.touches[0].pageY;
this._lastTouchY = ev.touches[0].pageY; this._lastTouchY = ev.touches[0].pageY;
if (deltaY === 0) { if (deltaY === 0) {
+9 -9
View File
@@ -241,7 +241,7 @@ export class DomRenderer extends Disposable implements IRenderer {
this._themeStyleElement.textContent = styles; this._themeStyleElement.textContent = styles;
} }
public onDevicePixelRatioChange(): void { public handleDevicePixelRatioChange(): void {
this._updateDimensions(); this._updateDimensions();
} }
@@ -258,30 +258,30 @@ export class DomRenderer extends Disposable implements IRenderer {
} }
} }
public onResize(cols: number, rows: number): void { public handleResize(cols: number, rows: number): void {
this._refreshRowElements(cols, rows); this._refreshRowElements(cols, rows);
this._updateDimensions(); this._updateDimensions();
} }
public onCharSizeChanged(): void { public handleCharSizeChanged(): void {
this._updateDimensions(); this._updateDimensions();
} }
public onBlur(): void { public handleBlur(): void {
this._rowContainer.classList.remove(FOCUS_CLASS); this._rowContainer.classList.remove(FOCUS_CLASS);
} }
public onFocus(): void { public handleFocus(): void {
this._rowContainer.classList.add(FOCUS_CLASS); this._rowContainer.classList.add(FOCUS_CLASS);
} }
public onSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean): void { public handleSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean): void {
// Remove all selections // Remove all selections
while (this._selectionContainer.children.length) { while (this._selectionContainer.children.length) {
this._selectionContainer.removeChild(this._selectionContainer.children[0]); this._selectionContainer.removeChild(this._selectionContainer.children[0]);
} }
this._rowFactory.onSelectionChanged(start, end, columnSelectMode); this._rowFactory.handleSelectionChanged(start, end, columnSelectMode);
this.renderRows(0, this._bufferService.rows - 1); this.renderRows(0, this._bufferService.rows - 1);
// Selection does not exist // Selection does not exist
@@ -341,11 +341,11 @@ export class DomRenderer extends Disposable implements IRenderer {
return element; return element;
} }
public onCursorMove(): void { public handleCursorMove(): void {
// No-op, the cursor is drawn when rows are drawn // No-op, the cursor is drawn when rows are drawn
} }
public onOptionsChanged(): void { public handleOptionsChanged(): void {
// Force a refresh // Force a refresh
this._updateDimensions(); this._updateDimensions();
this._injectCss(); this._injectCss();
@@ -299,7 +299,7 @@ describe('DomRendererRowFactory', () => {
it('should force selected cells with content to be rendered above the background', () => { it('should force selected cells with content to be rendered above the background', () => {
lineData.setCell(0, CellData.fromCharData([DEFAULT_ATTR, 'a', 1, 'a'.charCodeAt(0)])); lineData.setCell(0, CellData.fromCharData([DEFAULT_ATTR, 'a', 1, 'a'.charCodeAt(0)]));
lineData.setCell(1, CellData.fromCharData([DEFAULT_ATTR, 'b', 1, 'b'.charCodeAt(0)])); lineData.setCell(1, CellData.fromCharData([DEFAULT_ATTR, 'b', 1, 'b'.charCodeAt(0)]));
rowFactory.onSelectionChanged([1, 0], [2, 0], false); rowFactory.handleSelectionChanged([1, 0], [2, 0], false);
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20); const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20);
assert.equal(getFragmentHtml(fragment), assert.equal(getFragmentHtml(fragment),
'<span>a</span><span class="xterm-decoration-top">b</span>' '<span>a</span><span class="xterm-decoration-top">b</span>'
@@ -307,7 +307,7 @@ describe('DomRendererRowFactory', () => {
}); });
it('should force whitespace cells to be rendered above the background', () => { it('should force whitespace cells to be rendered above the background', () => {
lineData.setCell(1, CellData.fromCharData([DEFAULT_ATTR, 'a', 1, 'a'.charCodeAt(0)])); lineData.setCell(1, CellData.fromCharData([DEFAULT_ATTR, 'a', 1, 'a'.charCodeAt(0)]));
rowFactory.onSelectionChanged([0, 0], [2, 0], false); rowFactory.handleSelectionChanged([0, 0], [2, 0], false);
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20); const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20);
assert.equal(getFragmentHtml(fragment), assert.equal(getFragmentHtml(fragment),
'<span class="xterm-decoration-top"> </span><span class="xterm-decoration-top">a</span>' '<span class="xterm-decoration-top"> </span><span class="xterm-decoration-top">a</span>'
@@ -48,7 +48,7 @@ export class DomRendererRowFactory {
this._colors = colors; this._colors = colors;
} }
public onSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean): void { public handleSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean): void {
this._selectionStart = start; this._selectionStart = start;
this._selectionEnd = end; this._selectionEnd = end;
this._columnSelectMode = columnSelectMode; this._columnSelectMode = columnSelectMode;
+8 -8
View File
@@ -62,14 +62,14 @@ export interface IRenderer extends IDisposable {
dispose(): void; dispose(): void;
setColors(colors: IColorSet): void; setColors(colors: IColorSet): void;
onDevicePixelRatioChange(): void; handleDevicePixelRatioChange(): void;
onResize(cols: number, rows: number): void; handleResize(cols: number, rows: number): void;
onCharSizeChanged(): void; handleCharSizeChanged(): void;
onBlur(): void; handleBlur(): void;
onFocus(): void; handleFocus(): void;
onSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean): void; handleSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean): void;
onCursorMove(): void; handleCursorMove(): void;
onOptionsChanged(): void; handleOptionsChanged(): void;
clear(): void; clear(): void;
renderRows(start: number, end: number): void; renderRows(start: number, end: number): void;
clearTextureAtlas?(): void; clearTextureAtlas?(): void;
+3 -3
View File
@@ -50,17 +50,17 @@ describe('SelectionModel', () => {
it('should trim a portion of the selection when a part of it is trimmed', () => { it('should trim a portion of the selection when a part of it is trimmed', () => {
model.selectionStart = [0, 0]; model.selectionStart = [0, 0];
model.selectionEnd = [10, 2]; model.selectionEnd = [10, 2];
model.onTrim(1); model.handleTrim(1);
assert.deepEqual(model.finalSelectionStart, [0, 0]); assert.deepEqual(model.finalSelectionStart, [0, 0]);
assert.deepEqual(model.finalSelectionEnd, [10, 1]); assert.deepEqual(model.finalSelectionEnd, [10, 1]);
model.onTrim(1); model.handleTrim(1);
assert.deepEqual(model.finalSelectionStart, [0, 0]); assert.deepEqual(model.finalSelectionStart, [0, 0]);
assert.deepEqual(model.finalSelectionEnd, [10, 0]); assert.deepEqual(model.finalSelectionEnd, [10, 0]);
}); });
it('should clear selection when it is trimmed in its entirety', () => { it('should clear selection when it is trimmed in its entirety', () => {
model.selectionStart = [0, 0]; model.selectionStart = [0, 0];
model.selectionEnd = [10, 0]; model.selectionEnd = [10, 0];
model.onTrim(1); model.handleTrim(1);
assert.deepEqual(model.finalSelectionStart, undefined); assert.deepEqual(model.finalSelectionStart, undefined);
assert.deepEqual(model.finalSelectionEnd, undefined); assert.deepEqual(model.finalSelectionEnd, undefined);
}); });
+1 -1
View File
@@ -120,7 +120,7 @@ export class SelectionModel {
* @param amount The amount the buffer is being trimmed. * @param amount The amount the buffer is being trimmed.
* @return Whether a refresh is necessary. * @return Whether a refresh is necessary.
*/ */
public onTrim(amount: number): boolean { public handleTrim(amount: number): boolean {
// Adjust the selection position based on the trimmed amount. // Adjust the selection position based on the trimmed amount.
if (this.selectionStart) { if (this.selectionStart) {
this.selectionStart[1] -= amount; this.selectionStart[1] -= amount;
+20 -20
View File
@@ -68,13 +68,13 @@ export class RenderService extends Disposable implements IRenderService {
this.register(this._renderDebouncer); this.register(this._renderDebouncer);
this._screenDprMonitor = new ScreenDprMonitor(coreBrowserService.window); this._screenDprMonitor = new ScreenDprMonitor(coreBrowserService.window);
this._screenDprMonitor.setListener(() => this.onDevicePixelRatioChange()); this._screenDprMonitor.setListener(() => this.handleDevicePixelRatioChange());
this.register(this._screenDprMonitor); this.register(this._screenDprMonitor);
this.register(bufferService.onResize(() => this._fullRefresh())); this.register(bufferService.onResize(() => this._fullRefresh()));
this.register(bufferService.buffers.onBufferActivate(() => this._renderer?.clear())); this.register(bufferService.buffers.onBufferActivate(() => this._renderer?.clear()));
this.register(optionsService.onOptionChange(() => this._handleOptionsChanged())); this.register(optionsService.onOptionChange(() => this._handleOptionsChanged()));
this.register(this._charSizeService.onCharSizeChange(() => this.onCharSizeChanged())); this.register(this._charSizeService.onCharSizeChange(() => this.handleCharSizeChanged()));
// Do a full refresh whenever any decoration is added or removed. This may not actually result // Do a full refresh whenever any decoration is added or removed. This may not actually result
// in changes but since decorations should be used sparingly or added/removed all in the same // in changes but since decorations should be used sparingly or added/removed all in the same
@@ -87,7 +87,7 @@ export class RenderService extends Disposable implements IRenderService {
// dprchange should handle this case, we need this as well for browsers that don't support the // dprchange should handle this case, we need this as well for browsers that don't support the
// matchMedia query. // matchMedia query.
this.register(addDisposableDomListener(coreBrowserService.window, 'resize', () => this.onDevicePixelRatioChange())); this.register(addDisposableDomListener(coreBrowserService.window, 'resize', () => this.handleDevicePixelRatioChange()));
// Detect whether IntersectionObserver is detected and enable renderer pause // Detect whether IntersectionObserver is detected and enable renderer pause
// and resume based on terminal visibility if so // and resume based on terminal visibility if so
@@ -132,7 +132,7 @@ export class RenderService extends Disposable implements IRenderService {
// Update selection if needed // Update selection if needed
if (this._needsSelectionRefresh) { if (this._needsSelectionRefresh) {
this._renderer.onSelectionChanged(this._selectionState.start, this._selectionState.end, this._selectionState.columnSelectMode); this._renderer.handleSelectionChanged(this._selectionState.start, this._selectionState.end, this._selectionState.columnSelectMode);
this._needsSelectionRefresh = false; this._needsSelectionRefresh = false;
} }
@@ -153,7 +153,7 @@ export class RenderService extends Disposable implements IRenderService {
if (!this._renderer) { if (!this._renderer) {
return; return;
} }
this._renderer.onOptionsChanged(); this._renderer.handleOptionsChanged();
this.refreshRows(0, this._rowCount - 1); this.refreshRows(0, this._rowCount - 1);
this._fireOnCanvasResize(); this._fireOnCanvasResize();
} }
@@ -212,7 +212,7 @@ export class RenderService extends Disposable implements IRenderService {
this._fullRefresh(); this._fullRefresh();
} }
public onDevicePixelRatioChange(): void { public handleDevicePixelRatioChange(): void {
// Force char size measurement as DomMeasureStrategy(getBoundingClientRect) is not stable // Force char size measurement as DomMeasureStrategy(getBoundingClientRect) is not stable
// when devicePixelRatio changes // when devicePixelRatio changes
this._charSizeService.measure(); this._charSizeService.measure();
@@ -220,44 +220,44 @@ export class RenderService extends Disposable implements IRenderService {
if (!this._renderer) { if (!this._renderer) {
return; return;
} }
this._renderer.onDevicePixelRatioChange(); this._renderer.handleDevicePixelRatioChange();
this.refreshRows(0, this._rowCount - 1); this.refreshRows(0, this._rowCount - 1);
} }
public onResize(cols: number, rows: number): void { public handleResize(cols: number, rows: number): void {
if (!this._renderer) { if (!this._renderer) {
return; return;
} }
if (this._isPaused) { if (this._isPaused) {
this._pausedResizeTask.set(() => this._renderer!.onResize(cols, rows)); this._pausedResizeTask.set(() => this._renderer!.handleResize(cols, rows));
} else { } else {
this._renderer.onResize(cols, rows); this._renderer.handleResize(cols, rows);
} }
this._fullRefresh(); this._fullRefresh();
} }
// TODO: Is this useful when we have onResize? // TODO: Is this useful when we have onResize?
public onCharSizeChanged(): void { public handleCharSizeChanged(): void {
this._renderer?.onCharSizeChanged(); this._renderer?.handleCharSizeChanged();
} }
public onBlur(): void { public handleBlur(): void {
this._renderer?.onBlur(); this._renderer?.handleBlur();
} }
public onFocus(): void { public handleFocus(): void {
this._renderer?.onFocus(); this._renderer?.handleFocus();
} }
public onSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean): void { public handleSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean): void {
this._selectionState.start = start; this._selectionState.start = start;
this._selectionState.end = end; this._selectionState.end = end;
this._selectionState.columnSelectMode = columnSelectMode; this._selectionState.columnSelectMode = columnSelectMode;
this._renderer?.onSelectionChanged(start, end, columnSelectMode); this._renderer?.handleSelectionChanged(start, end, columnSelectMode);
} }
public onCursorMove(): void { public handleCursorMove(): void {
this._renderer?.onCursorMove(); this._renderer?.handleCursorMove();
} }
public clear(): void { public clear(): void {
+2 -2
View File
@@ -376,7 +376,7 @@ export class SelectionService extends Disposable implements ISelectionService {
* @param amount The amount the buffer is being trimmed. * @param amount The amount the buffer is being trimmed.
*/ */
private _onTrim(amount: number): void { private _onTrim(amount: number): void {
const needsRefresh = this._model.onTrim(amount); const needsRefresh = this._model.handleTrim(amount);
if (needsRefresh) { if (needsRefresh) {
this.refresh(); this.refresh();
} }
@@ -438,7 +438,7 @@ export class SelectionService extends Disposable implements ISelectionService {
* Handles te mousedown event, setting up for a new selection. * Handles te mousedown event, setting up for a new selection.
* @param event The mousedown event. * @param event The mousedown event.
*/ */
public onMouseDown(event: MouseEvent): void { public handleMouseDown(event: MouseEvent): void {
this._mouseDownTimeStamp = event.timeStamp; this._mouseDownTimeStamp = event.timeStamp;
// If we have selection, we want the context menu on right click even if the // If we have selection, we want the context menu on right click even if the
// terminal is in mouse mode. // terminal is in mouse mode.
+8 -9
View File
@@ -74,14 +74,13 @@ export interface IRenderService extends IDisposable {
hasRenderer(): boolean; hasRenderer(): boolean;
setRenderer(renderer: IRenderer): void; setRenderer(renderer: IRenderer): void;
setColors(colors: IColorSet): void; setColors(colors: IColorSet): void;
onDevicePixelRatioChange(): void; handleDevicePixelRatioChange(): void;
onResize(cols: number, rows: number): void; handleResize(cols: number, rows: number): void;
// TODO: Is this useful when we have onResize? handleCharSizeChanged(): void;
onCharSizeChanged(): void; handleBlur(): void;
onBlur(): void; handleFocus(): void;
onFocus(): void; handleSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean): void;
onSelectionChanged(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean): void; handleCursorMove(): void;
onCursorMove(): void;
clear(): void; clear(): void;
} }
@@ -110,7 +109,7 @@ export interface ISelectionService {
shouldColumnSelect(event: KeyboardEvent | MouseEvent): boolean; shouldColumnSelect(event: KeyboardEvent | MouseEvent): boolean;
shouldForceSelection(event: MouseEvent): boolean; shouldForceSelection(event: MouseEvent): boolean;
refresh(isLinuxMouseSelection?: boolean): void; refresh(isLinuxMouseSelection?: boolean): void;
onMouseDown(event: MouseEvent): void; handleMouseDown(event: MouseEvent): void;
isCellInSelection(x: number, y: number): boolean; isCellInSelection(x: number, y: number): boolean;
} }