Fix lint, split up namespace and interface

This commit is contained in:
Daniel Imms
2026-01-30 06:21:15 -08:00
parent b58bd452af
commit f80dbf3d03
19 changed files with 148 additions and 148 deletions
+3 -3
View File
@@ -7,7 +7,7 @@ import { FontWeight } from '@xterm/xterm';
import { IColorSet } from 'browser/Types';
import { ISelectionRenderModel } from 'browser/renderer/shared/Types';
import { CursorInactiveStyle, CursorStyle, type IDisposable } from 'common/Types';
import type { Event } from 'common/Event';
import type { IEvent } from 'common/Event';
export interface IRenderModel {
cells: Uint32Array;
@@ -58,8 +58,8 @@ export interface ICharAtlasConfig {
export interface ITextureAtlas extends IDisposable {
readonly pages: { canvas: HTMLCanvasElement, version: number }[];
onAddTextureAtlasCanvas: Event<HTMLCanvasElement>;
onRemoveTextureAtlasCanvas: Event<HTMLCanvasElement>;
onAddTextureAtlasCanvas: IEvent<HTMLCanvasElement>;
onRemoveTextureAtlasCanvas: IEvent<HTMLCanvasElement>;
/**
* Warm up the texture atlas, adding common glyphs to avoid slowing early frame.
+5 -5
View File
@@ -13,7 +13,7 @@ import { ICoreService, IDecorationService, ILogService, IOptionsService } from '
import { IWebGL2RenderingContext } from './Types';
import { WebglRenderer } from './WebglRenderer';
import { setTraceLogger } from 'common/services/LogService';
import { Emitter, Event } from 'common/Event';
import { Emitter, EventUtils } from 'common/Event';
export class WebglAddon extends Disposable implements ITerminalAddon , IWebglApi {
private _terminal?: Terminal;
@@ -85,10 +85,10 @@ export class WebglAddon extends Disposable implements ITerminalAddon , IWebglApi
this._customGlyphs,
this._preserveDrawingBuffer
));
this._register(Event.forward(this._renderer.onContextLoss, this._onContextLoss));
this._register(Event.forward(this._renderer.onChangeTextureAtlas, this._onChangeTextureAtlas));
this._register(Event.forward(this._renderer.onAddTextureAtlasCanvas, this._onAddTextureAtlasCanvas));
this._register(Event.forward(this._renderer.onRemoveTextureAtlasCanvas, this._onRemoveTextureAtlasCanvas));
this._register(EventUtils.forward(this._renderer.onContextLoss, this._onContextLoss));
this._register(EventUtils.forward(this._renderer.onChangeTextureAtlas, this._onChangeTextureAtlas));
this._register(EventUtils.forward(this._renderer.onAddTextureAtlasCanvas, this._onAddTextureAtlasCanvas));
this._register(EventUtils.forward(this._renderer.onRemoveTextureAtlasCanvas, this._onRemoveTextureAtlasCanvas));
renderService.setRenderer(this._renderer);
this._register(toDisposable(() => {
+3 -3
View File
@@ -22,7 +22,7 @@ import { COMBINED_CHAR_BIT_MASK, RENDER_MODEL_BG_OFFSET, RENDER_MODEL_EXT_OFFSET
import { IWebGL2RenderingContext, type ITextureAtlas } from './Types';
import { LinkRenderLayer } from './renderLayer/LinkRenderLayer';
import { IRenderLayer } from './renderLayer/Types';
import { Emitter, Event } from 'common/Event';
import { Emitter, EventUtils } from 'common/Event';
import { addDisposableListener } from 'vs/base/browser/dom';
import { combinedDisposable, Disposable, MutableDisposable, toDisposable } from 'common/Lifecycle';
import { createRenderDimensions } from 'browser/renderer/shared/RendererUtils';
@@ -290,8 +290,8 @@ export class WebglRenderer extends Disposable implements IRenderer {
if (this._charAtlas !== atlas) {
this._onChangeTextureAtlas.fire(atlas.pages[0].canvas);
this._charAtlasDisposable.value = combinedDisposable(
Event.forward(atlas.onAddTextureAtlasCanvas, this._onAddTextureAtlasCanvas),
Event.forward(atlas.onRemoveTextureAtlasCanvas, this._onRemoveTextureAtlasCanvas)
EventUtils.forward(atlas.onAddTextureAtlasCanvas, this._onAddTextureAtlasCanvas),
EventUtils.forward(atlas.onRemoveTextureAtlasCanvas, this._onRemoveTextureAtlasCanvas)
);
}
this._charAtlas = atlas;
+11 -11
View File
@@ -55,7 +55,7 @@ import { IDecorationService } from 'common/services/Services';
import { WindowsOptionsReportType } from '../common/InputHandler';
import { AccessibilityManager } from './AccessibilityManager';
import { Linkifier } from './Linkifier';
import { Emitter, Event } from 'common/Event';
import { Emitter, EventUtils, type IEvent } from 'common/Event';
import { addDisposableListener } from 'vs/base/browser/dom';
import { MutableDisposable, toDisposable } from 'common/Lifecycle';
@@ -135,15 +135,15 @@ export class CoreBrowserTerminal extends CoreTerminal implements ITerminal {
public readonly onBell = this._onBell.event;
private _onFocus = this._register(new Emitter<void>());
public get onFocus(): Event<void> { return this._onFocus.event; }
public get onFocus(): IEvent<void> { return this._onFocus.event; }
private _onBlur = this._register(new Emitter<void>());
public get onBlur(): Event<void> { return this._onBlur.event; }
public get onBlur(): IEvent<void> { return this._onBlur.event; }
private _onA11yCharEmitter = this._register(new Emitter<string>());
public get onA11yChar(): Event<string> { return this._onA11yCharEmitter.event; }
public get onA11yChar(): IEvent<string> { return this._onA11yCharEmitter.event; }
private _onA11yTabEmitter = this._register(new Emitter<number>());
public get onA11yTab(): Event<number> { return this._onA11yTabEmitter.event; }
public get onA11yTab(): IEvent<number> { return this._onA11yTabEmitter.event; }
private _onWillOpen = this._register(new Emitter<HTMLElement>());
public get onWillOpen(): Event<HTMLElement> { return this._onWillOpen.event; }
public get onWillOpen(): IEvent<HTMLElement> { return this._onWillOpen.event; }
private readonly _onDimensionsChange = this._register(new Emitter<IRenderDimensionsApi>());
public readonly onDimensionsChange = this._onDimensionsChange.event;
@@ -187,10 +187,10 @@ export class CoreBrowserTerminal extends CoreTerminal implements ITerminal {
this._register(this._inputHandler.onRequestReset(() => this.reset()));
this._register(this._inputHandler.onRequestWindowsOptionsReport(type => this._reportWindowsOptions(type)));
this._register(this._inputHandler.onColor((event) => this._handleColorEvent(event)));
this._register(Event.forward(this._inputHandler.onCursorMove, this._onCursorMove));
this._register(Event.forward(this._inputHandler.onTitleChange, this._onTitleChange));
this._register(Event.forward(this._inputHandler.onA11yChar, this._onA11yCharEmitter));
this._register(Event.forward(this._inputHandler.onA11yTab, this._onA11yTabEmitter));
this._register(EventUtils.forward(this._inputHandler.onCursorMove, this._onCursorMove));
this._register(EventUtils.forward(this._inputHandler.onTitleChange, this._onTitleChange));
this._register(EventUtils.forward(this._inputHandler.onA11yChar, this._onA11yCharEmitter));
this._register(EventUtils.forward(this._inputHandler.onA11yTab, this._onA11yTabEmitter));
// Setup listeners
this._register(this._bufferService.onResize(e => this._afterResize(e.cols, e.rows)));
@@ -566,7 +566,7 @@ export class CoreBrowserTerminal extends CoreTerminal implements ITerminal {
this.textarea!.focus();
this.textarea!.select();
}));
this._register(Event.any(
this._register(EventUtils.any(
this._onScroll.event,
this._inputHandler.onScroll
)(() => {
+27 -27
View File
@@ -18,7 +18,7 @@ import { AttributeData } from 'common/buffer/AttributeData';
import { ISelectionRedrawRequestEvent, ISelectionRequestScrollLinesEvent } from 'browser/selection/Types';
import { css } from 'common/Color';
import { createRenderDimensions } from 'browser/renderer/shared/RendererUtils';
import { Emitter, type Event } from 'common/Event';
import { Emitter, type IEvent } from 'common/Event';
export class TestTerminal extends CoreBrowserTerminal {
public get curAttrData(): IAttributeData { return (this as any)._inputHandler._curAttrData; }
@@ -30,24 +30,24 @@ export class TestTerminal extends CoreBrowserTerminal {
}
export class MockTerminal implements ITerminal {
public onBlur!: Event<void>;
public onFocus!: Event<void>;
public onA11yChar!: Event<string>;
public onWriteParsed!: Event<void>;
public onA11yTab!: Event<number>;
public onCursorMove!: Event<void>;
public onLineFeed!: Event<void>;
public onSelectionChange!: Event<void>;
public onData!: Event<string>;
public onBinary!: Event<string>;
public onTitleChange!: Event<string>;
public onBell!: Event<void>;
public onScroll!: Event<number>;
public onWillOpen!: Event<HTMLElement>;
public onKey!: Event<{ key: string, domEvent: KeyboardEvent }>;
public onRender!: Event<{ start: number, end: number }>;
public onResize!: Event<{ cols: number, rows: number }>;
public onDimensionsChange!: Event<IRenderDimensionsApi>;
public onBlur!: IEvent<void>;
public onFocus!: IEvent<void>;
public onA11yChar!: IEvent<string>;
public onWriteParsed!: IEvent<void>;
public onA11yTab!: IEvent<number>;
public onCursorMove!: IEvent<void>;
public onLineFeed!: IEvent<void>;
public onSelectionChange!: IEvent<void>;
public onData!: IEvent<string>;
public onBinary!: IEvent<string>;
public onTitleChange!: IEvent<string>;
public onBell!: IEvent<void>;
public onScroll!: IEvent<number>;
public onWillOpen!: IEvent<HTMLElement>;
public onKey!: IEvent<{ key: string, domEvent: KeyboardEvent }>;
public onRender!: IEvent<{ start: number, end: number }>;
public onResize!: IEvent<{ cols: number, rows: number }>;
public onDimensionsChange!: IEvent<IRenderDimensionsApi>;
public dimensions: IRenderDimensionsApi | undefined;
public markers!: IMarker[];
public linkifier: ILinkifier2 | undefined;
@@ -273,9 +273,9 @@ export class MockBuffer implements IBuffer {
}
export class MockRenderer implements IRenderer {
public onRequestRedraw!: Event<IRequestRedrawEvent>;
public onCanvasResize!: Event<{ width: number, height: number }>;
public onRender!: Event<{ start: number, end: number }>;
public onRequestRedraw!: IEvent<IRequestRedrawEvent>;
public onCanvasResize!: IEvent<{ width: number, height: number }>;
public onRender!: IEvent<{ start: number, end: number }>;
public dispose(): void {
throw new Error('Method not implemented.');
}
@@ -378,7 +378,7 @@ export class MockCoreBrowserService implements ICoreBrowserService {
export class MockCharSizeService implements ICharSizeService {
public serviceBrand: undefined;
public get hasValidSize(): boolean { return this.width > 0 && this.height > 0; }
public onCharSizeChange: Event<void> = new Emitter<void>().event;
public onCharSizeChange: IEvent<void> = new Emitter<void>().event;
constructor(public width: number, public height: number) {}
public measure(): void {}
}
@@ -396,10 +396,10 @@ export class MockMouseService implements IMouseService {
export class MockRenderService implements IRenderService {
public serviceBrand: undefined;
public onDimensionsChange: Event<IRenderDimensions> = new Emitter<IRenderDimensions>().event;
public onRenderedViewportChange: Event<{ start: number, end: number }> = new Emitter<{ start: number, end: number }>().event;
public onRender: Event<{ start: number, end: number }> = new Emitter<{ start: number, end: number }>().event;
public onRefreshRequest: Event<{ start: number, end: number}> = new Emitter<{ start: number, end: number }>().event;
public onDimensionsChange: IEvent<IRenderDimensions> = new Emitter<IRenderDimensions>().event;
public onRenderedViewportChange: IEvent<{ start: number, end: number }> = new Emitter<{ start: number, end: number }>().event;
public onRender: IEvent<{ start: number, end: number }> = new Emitter<{ start: number, end: number }>().event;
public onRefreshRequest: IEvent<{ start: number, end: number}> = new Emitter<{ start: number, end: number }>().event;
public dimensions: IRenderDimensions = createRenderDimensions();
public refreshRows(start: number, end: number): void {
throw new Error('Method not implemented.');
+10 -10
View File
@@ -7,7 +7,7 @@ import { CharData, IColor, ICoreTerminal, ITerminalOptions } from 'common/Types'
import { IBuffer } from 'common/buffer/Types';
import { IDisposable, IRenderDimensions as IRenderDimensionsApi, Terminal as ITerminalApi } from '@xterm/xterm';
import { channels, css } from 'common/Color';
import type { Event } from 'common/Event';
import type { IEvent } from 'common/Event';
/**
* A portion of the public API that are implemented identially internally and simply passed through.
@@ -23,12 +23,12 @@ export interface ITerminal extends InternalPassthroughApis, ICoreTerminal {
readonly dimensions: IRenderDimensionsApi | undefined;
onBlur: Event<void>;
onFocus: Event<void>;
onDimensionsChange: Event<IRenderDimensionsApi>;
onA11yChar: Event<string>;
onA11yTab: Event<number>;
onWillOpen: Event<HTMLElement>;
onBlur: IEvent<void>;
onFocus: IEvent<void>;
onDimensionsChange: IEvent<IRenderDimensionsApi>;
onA11yChar: IEvent<string>;
onA11yTab: IEvent<number>;
onWillOpen: IEvent<HTMLElement>;
cancel(ev: MouseEvent | WheelEvent | KeyboardEvent | InputEvent, force?: boolean): boolean | void;
}
@@ -101,7 +101,7 @@ export interface IPartialColorSet {
export interface IViewport extends IDisposable {
scrollBarWidth: number;
readonly onRequestScrollLines: Event<{ amount: number, suppressScrollEvent: boolean }>;
readonly onRequestScrollLines: IEvent<{ amount: number, suppressScrollEvent: boolean }>;
syncScrollArea(immediate?: boolean, force?: boolean): void;
getLinesScrolled(ev: WheelEvent): number;
getBufferElements(startLine: number, endLine?: number): { bufferElements: HTMLElement[], cursorElement?: HTMLElement };
@@ -131,8 +131,8 @@ export interface ILinkWithState {
}
export interface ILinkifier2 extends IDisposable {
onShowLinkUnderline: Event<ILinkifierEvent>;
onHideLinkUnderline: Event<ILinkifierEvent>;
onShowLinkUnderline: IEvent<ILinkifierEvent>;
onHideLinkUnderline: IEvent<ILinkifierEvent>;
readonly currentLink: ILinkWithState | undefined;
}
+3 -3
View File
@@ -11,7 +11,7 @@ import { CoreMouseEventType } from 'common/Types';
import { addDisposableListener, scheduleAtNextAnimationFrame } from 'vs/base/browser/dom';
import { SmoothScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement';
import type { ScrollableElementChangeOptions } from 'vs/base/browser/ui/scrollbar/scrollableElementOptions';
import { Emitter, Event } from 'common/Event';
import { Emitter, EventUtils } from 'common/Event';
import { Scrollable, ScrollbarVisibility, type ScrollEvent } from 'vs/base/common/scrollable';
import { Gesture, EventType as GestureEventType, type GestureEvent } from 'vs/base/browser/touch';
@@ -71,7 +71,7 @@ export class Viewport extends Disposable {
}));
this._scrollableElement.setScrollDimensions({ height: 0, scrollHeight: 0 });
this._register(Event.runAndSubscribe(themeService.onChangeColors, () => {
this._register(EventUtils.runAndSubscribe(themeService.onChangeColors, () => {
element.style.backgroundColor = themeService.colors.background.css;
this._scrollableElement.getDomNode().style.backgroundColor = themeService.colors.background.css;
}));
@@ -81,7 +81,7 @@ export class Viewport extends Disposable {
this._styleElement = coreBrowserService.mainDocument.createElement('style');
screenElement.appendChild(this._styleElement);
this._register(toDisposable(() => this._styleElement.remove()));
this._register(Event.runAndSubscribe(themeService.onChangeColors, () => {
this._register(EventUtils.runAndSubscribe(themeService.onChangeColors, () => {
this._styleElement.textContent = [
`.xterm .xterm-scrollable-element > .scrollbar > .slider {`,
` background: ${themeService.colors.scrollbarSliderBackground.css};`,
+14 -14
View File
@@ -13,7 +13,7 @@ import { BufferNamespaceApi } from 'common/public/BufferNamespaceApi';
import { ParserApi } from 'common/public/ParserApi';
import { UnicodeApi } from 'common/public/UnicodeApi';
import { IBufferNamespace as IBufferNamespaceApi, IDecoration, IDecorationOptions, IDisposable, ILinkProvider, ILocalizableStrings, IMarker, IModes, IParser, IRenderDimensions, ITerminalAddon, Terminal as ITerminalApi, ITerminalInitOnlyOptions, IUnicodeHandling } from '@xterm/xterm';
import type { Event } from 'common/Event';
import type { IEvent } from 'common/Event';
/**
* The set of options that only have an effect when set in the Terminal constructor.
@@ -68,19 +68,19 @@ export class Terminal extends Disposable implements ITerminalApi {
}
}
public get onBell(): Event<void> { return this._core.onBell; }
public get onBinary(): Event<string> { return this._core.onBinary; }
public get onCursorMove(): Event<void> { return this._core.onCursorMove; }
public get onData(): Event<string> { return this._core.onData; }
public get onKey(): Event<{ key: string, domEvent: KeyboardEvent }> { return this._core.onKey; }
public get onLineFeed(): Event<void> { return this._core.onLineFeed; }
public get onRender(): Event<{ start: number, end: number }> { return this._core.onRender; }
public get onResize(): Event<{ cols: number, rows: number }> { return this._core.onResize; }
public get onScroll(): Event<number> { return this._core.onScroll; }
public get onSelectionChange(): Event<void> { return this._core.onSelectionChange; }
public get onTitleChange(): Event<string> { return this._core.onTitleChange; }
public get onWriteParsed(): Event<void> { return this._core.onWriteParsed; }
public get onDimensionsChange(): Event<IRenderDimensions> { return this._core.onDimensionsChange; }
public get onBell(): IEvent<void> { return this._core.onBell; }
public get onBinary(): IEvent<string> { return this._core.onBinary; }
public get onCursorMove(): IEvent<void> { return this._core.onCursorMove; }
public get onData(): IEvent<string> { return this._core.onData; }
public get onKey(): IEvent<{ key: string, domEvent: KeyboardEvent }> { return this._core.onKey; }
public get onLineFeed(): IEvent<void> { return this._core.onLineFeed; }
public get onRender(): IEvent<{ start: number, end: number }> { return this._core.onRender; }
public get onResize(): IEvent<{ cols: number, rows: number }> { return this._core.onResize; }
public get onScroll(): IEvent<number> { return this._core.onScroll; }
public get onSelectionChange(): IEvent<void> { return this._core.onSelectionChange; }
public get onTitleChange(): IEvent<string> { return this._core.onTitleChange; }
public get onWriteParsed(): IEvent<void> { return this._core.onWriteParsed; }
public get onDimensionsChange(): IEvent<IRenderDimensions> { return this._core.onDimensionsChange; }
public get element(): HTMLElement | undefined { return this._core.element; }
public get parser(): IParser {
+2 -2
View File
@@ -6,7 +6,7 @@
import { Terminal } from '@xterm/xterm';
import { ITerminal } from 'browser/Types';
import { IDisposable } from 'common/Types';
import type { Event } from 'common/Event';
import type { IEvent } from 'common/Event';
export interface IDimensions {
width: number;
@@ -57,7 +57,7 @@ export interface IRenderer extends IDisposable {
* Fires when the renderer is requesting to be redrawn on the next animation
* frame but is _not_ a result of content changing (eg. selection changes).
*/
readonly onRequestRedraw: Event<IRequestRedrawEvent>;
readonly onRequestRedraw: IEvent<IRequestRedrawEvent>;
dispose(): void;
handleDevicePixelRatioChange(): void;
+2 -2
View File
@@ -4,7 +4,7 @@
*/
import { ICoreBrowserService } from './Services';
import { Emitter, Event } from 'common/Event';
import { Emitter, EventUtils } from 'common/Event';
import { addDisposableListener } from 'vs/base/browser/dom';
import { Disposable, MutableDisposable, toDisposable } from 'common/Lifecycle';
@@ -29,7 +29,7 @@ export class CoreBrowserService extends Disposable implements ICoreBrowserServic
// Monitor device pixel ratio
this._register(this.onWindowChange(w => this._screenDprMonitor.setWindow(w)));
this._register(Event.forward(this._screenDprMonitor.onDprChange, this._onDprChange));
this._register(EventUtils.forward(this._screenDprMonitor.onDprChange, this._onDprChange));
this._register(addDisposableListener(this._textarea, 'focus', () => this._isFocused = true));
this._register(addDisposableListener(this._textarea, 'blur', () => this._isFocused = false));
+13 -13
View File
@@ -8,7 +8,7 @@ import { IColorSet, ILink, ReadonlyColorSet } from 'browser/Types';
import { ISelectionRedrawRequestEvent as ISelectionRequestRedrawEvent, ISelectionRequestScrollLinesEvent } from 'browser/selection/Types';
import { createDecorator } from 'common/services/ServiceRegistry';
import { AllColorIndex, IDisposable, IKeyboardResult } from 'common/Types';
import type { Event } from 'common/Event';
import type { IEvent } from 'common/Event';
export const ICharSizeService = createDecorator<ICharSizeService>('CharSizeService');
export interface ICharSizeService {
@@ -18,7 +18,7 @@ export interface ICharSizeService {
readonly height: number;
readonly hasValidSize: boolean;
readonly onCharSizeChange: Event<void>;
readonly onCharSizeChange: IEvent<void>;
measure(): void;
}
@@ -29,8 +29,8 @@ export interface ICoreBrowserService {
readonly isFocused: boolean;
readonly onDprChange: Event<number>;
readonly onWindowChange: Event<Window & typeof globalThis>;
readonly onDprChange: IEvent<number>;
readonly onWindowChange: IEvent<Window & typeof globalThis>;
/**
* Gets or sets the parent window that the terminal is rendered into. DOM and rendering APIs (e.g.
@@ -61,17 +61,17 @@ export const IRenderService = createDecorator<IRenderService>('RenderService');
export interface IRenderService extends IDisposable {
serviceBrand: undefined;
onDimensionsChange: Event<IRenderDimensions>;
onDimensionsChange: IEvent<IRenderDimensions>;
/**
* Fires when buffer changes are rendered. This does not fire when only cursor
* or selections are rendered.
*/
onRenderedViewportChange: Event<{ start: number, end: number }>;
onRenderedViewportChange: IEvent<{ start: number, end: number }>;
/**
* Fires on render
*/
onRender: Event<{ start: number, end: number }>;
onRefreshRequest: Event<{ start: number, end: number }>;
onRender: IEvent<{ start: number, end: number }>;
onRefreshRequest: IEvent<{ start: number, end: number }>;
dimensions: IRenderDimensions;
@@ -101,10 +101,10 @@ export interface ISelectionService {
readonly selectionStart: [number, number] | undefined;
readonly selectionEnd: [number, number] | undefined;
readonly onLinuxMouseSelection: Event<string>;
readonly onRequestRedraw: Event<ISelectionRequestRedrawEvent>;
readonly onRequestScrollLines: Event<ISelectionRequestScrollLinesEvent>;
readonly onSelectionChange: Event<void>;
readonly onLinuxMouseSelection: IEvent<string>;
readonly onRequestRedraw: IEvent<ISelectionRequestRedrawEvent>;
readonly onRequestScrollLines: IEvent<ISelectionRequestScrollLinesEvent>;
readonly onSelectionChange: IEvent<void>;
disable(): void;
enable(): void;
@@ -136,7 +136,7 @@ export interface IThemeService {
readonly colors: ReadonlyColorSet;
readonly onChangeColors: Event<ReadonlyColorSet>;
readonly onChangeColors: IEvent<ReadonlyColorSet>;
restoreColor(slot?: AllColorIndex): void;
/**
+7 -7
View File
@@ -37,7 +37,7 @@ import { IBufferSet } from 'common/buffer/Types';
import { InputHandler } from 'common/InputHandler';
import { WriteBuffer } from 'common/input/WriteBuffer';
import { OscLinkService } from 'common/services/OscLinkService';
import { Emitter, Event } from 'common/Event';
import { Emitter, EventUtils, type IEvent } from 'common/Event';
import { Disposable, MutableDisposable, toDisposable } from 'common/Lifecycle';
// Only trigger this warning a single time per session
@@ -78,7 +78,7 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
*/
protected _onScrollApi?: Emitter<number>;
protected _onScroll = this._register(new Emitter<IScrollEvent>());
public get onScroll(): Event<number> {
public get onScroll(): IEvent<number> {
if (!this._onScrollApi) {
this._onScrollApi = this._register(new Emitter<number>());
this._onScroll.event(ev => {
@@ -125,12 +125,12 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
// Register input handler and handle/forward events
this._inputHandler = this._register(new InputHandler(this._bufferService, this._charsetService, this.coreService, this._logService, this.optionsService, this._oscLinkService, this.coreMouseService, this.unicodeService));
this._register(Event.forward(this._inputHandler.onLineFeed, this._onLineFeed));
this._register(EventUtils.forward(this._inputHandler.onLineFeed, this._onLineFeed));
// Setup listeners
this._register(Event.forward(this._bufferService.onResize, this._onResize));
this._register(Event.forward(this.coreService.onData, this._onData));
this._register(Event.forward(this.coreService.onBinary, this._onBinary));
this._register(EventUtils.forward(this._bufferService.onResize, this._onResize));
this._register(EventUtils.forward(this.coreService.onData, this._onData));
this._register(EventUtils.forward(this.coreService.onBinary, this._onBinary));
this._register(this.coreService.onRequestScrollToBottom(() => this.scrollToBottom(true)));
this._register(this.coreService.onUserInput(() => this._writeBuffer.handleUserInput()));
this._register(this.optionsService.onMultipleOptionChange(['windowsPty'], () => this._handleWindowsPtyOptionChange()));
@@ -140,7 +140,7 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
}));
// Setup WriteBuffer
this._writeBuffer = this._register(new WriteBuffer((data, promiseResult) => this._inputHandler.parse(data, promiseResult)));
this._register(Event.forward(this._writeBuffer.onWriteParsed, this._onWriteParsed));
this._register(EventUtils.forward(this._writeBuffer.onWriteParsed, this._onWriteParsed));
}
public write(data: string | Uint8Array, callback?: () => void): void {
+1 -1
View File
@@ -68,7 +68,7 @@ export class Emitter<T> {
}
}
export namespace Event {
export namespace EventUtils {
export function forward<T>(from: IEvent<T>, to: Emitter<T>): IDisposable {
return from(e => to.fire(e));
}
+10 -10
View File
@@ -12,14 +12,14 @@ import { BufferSet } from 'common/buffer/BufferSet';
import { IDecPrivateModes, ICoreMouseEvent, CoreMouseEventType, ICharset, IModes, IAttributeData, IOscLinkData, IDisposable } from 'common/Types';
import { UnicodeV6 } from 'common/input/UnicodeV6';
import { IDecorationOptions, IDecoration } from '@xterm/xterm';
import { Emitter, type Event } from 'common/Event';
import { Emitter, type IEvent } from 'common/Event';
export class MockBufferService implements IBufferService {
public serviceBrand: any;
public get buffer(): IBuffer { return this.buffers.active; }
public buffers: IBufferSet = {} as any;
public onResize: Event<IBufferResizeEvent> = new Emitter<IBufferResizeEvent>().event;
public onScroll: Event<number> = new Emitter<number>().event;
public onResize: IEvent<IBufferResizeEvent> = new Emitter<IBufferResizeEvent>().event;
public onScroll: IEvent<number> = new Emitter<number>().event;
private readonly _onScroll = new Emitter<number>();
public isUserScrolling: boolean = false;
constructor(
@@ -67,7 +67,7 @@ export class MockCoreMouseService implements ICoreMouseService {
public addProtocol(name: string): void { }
public reset(): void { }
public triggerMouseEvent(event: ICoreMouseEvent): boolean { return false; }
public onProtocolChange: Event<CoreMouseEventType> = new Emitter<CoreMouseEventType>().event;
public onProtocolChange: IEvent<CoreMouseEventType> = new Emitter<CoreMouseEventType>().event;
public explainEvents(events: CoreMouseEventType): { [event: string]: boolean } {
throw new Error('Method not implemented.');
}
@@ -122,10 +122,10 @@ export class MockCoreService implements ICoreService {
mainStack: [] as number[],
altStack: [] as number[]
};
public onData: Event<string> = new Emitter<string>().event;
public onUserInput: Event<void> = new Emitter<void>().event;
public onBinary: Event<string> = new Emitter<string>().event;
public onRequestScrollToBottom: Event<void> = new Emitter<void>().event;
public onData: IEvent<string> = new Emitter<string>().event;
public onUserInput: IEvent<void> = new Emitter<void>().event;
public onBinary: IEvent<string> = new Emitter<string>().event;
public onRequestScrollToBottom: IEvent<void> = new Emitter<void>().event;
public reset(): void { }
public triggerDataEvent(data: string, wasUserInput?: boolean): void { }
public triggerBinaryEvent(data: string): void { }
@@ -145,7 +145,7 @@ export class MockOptionsService implements IOptionsService {
public serviceBrand: any;
public readonly rawOptions: Required<ITerminalOptions> = clone(DEFAULT_OPTIONS);
public options: Required<ITerminalOptions> = this.rawOptions;
public onOptionChange: Event<keyof ITerminalOptions> = new Emitter<keyof ITerminalOptions>().event;
public onOptionChange: IEvent<keyof ITerminalOptions> = new Emitter<keyof ITerminalOptions>().event;
constructor(testOptions?: Partial<ITerminalOptions>) {
if (testOptions) {
for (const key of Object.keys(testOptions)) {
@@ -197,7 +197,7 @@ export class MockUnicodeService implements IUnicodeService {
}
public versions: string[] = [];
public activeVersion: string = '';
public onChange: Event<string> = new Emitter<string>().event;
public onChange: IEvent<string> = new Emitter<string>().event;
public wcwidth = (codepoint: number): UnicodeCharWidth => this._provider.wcwidth(codepoint);
public charProperties(codepoint: number, preceding: UnicodeCharProperties): UnicodeCharProperties {
let width = this.wcwidth(codepoint);
+6 -6
View File
@@ -9,7 +9,7 @@ import { IBufferSet } from 'common/buffer/Types';
import { IParams } from 'common/parser/Types';
import { ICoreMouseService, ICoreService, IOptionsService, IUnicodeService } from 'common/services/Services';
import { IFunctionIdentifier, ITerminalOptions as IPublicTerminalOptions } from '@xterm/xterm';
import type { Emitter, Event } from 'common/Event';
import type { Emitter, IEvent } from 'common/Event';
export interface ICoreTerminal {
coreMouseService: ICoreMouseService;
@@ -68,11 +68,11 @@ export interface ICircularList<T> {
isFull: boolean;
onDeleteEmitter: Emitter<IDeleteEvent>;
onDelete: Event<IDeleteEvent>;
onDelete: IEvent<IDeleteEvent>;
onInsertEmitter: Emitter<IInsertEvent>;
onInsert: Event<IInsertEvent>;
onInsert: IEvent<IInsertEvent>;
onTrimEmitter: Emitter<number>;
onTrim: Event<number>;
onTrim: IEvent<number>;
get(index: number): T | undefined;
set(index: number, value: T): void;
@@ -258,7 +258,7 @@ export interface IMarker extends IDisposable {
readonly id: number;
readonly isDisposed: boolean;
readonly line: number;
onDispose: Event<void>;
onDispose: IEvent<void>;
}
export interface IModes {
insertMode: boolean;
@@ -467,7 +467,7 @@ export type IColorEvent = (IColorReportRequest | IColorSetRequest | IColorRestor
* Calls the parser and handles actions generated by the parser.
*/
export interface IInputHandler {
onTitleChange: Event<string>;
onTitleChange: IEvent<string>;
parse(data: string | Uint8Array, promiseResult?: boolean): void | Promise<boolean>;
print(data: Uint32Array, start: number, end: number): void;
+2 -2
View File
@@ -4,7 +4,7 @@
*/
import { IAttributeData, ICircularList, IBufferLine, ICellData, IMarker, ICharset, IDisposable } from 'common/Types';
import type { Event } from 'common/Event';
import type { IEvent } from 'common/Event';
// BufferIndex denotes a position in the buffer: [rowIndex, colIndex]
export type BufferIndex = [number, number];
@@ -46,7 +46,7 @@ export interface IBufferSet extends IDisposable {
normal: IBuffer;
active: IBuffer;
onBufferActivate: Event<{ activeBuffer: IBuffer, inactiveBuffer: IBuffer }>;
onBufferActivate: IEvent<{ activeBuffer: IBuffer, inactiveBuffer: IBuffer }>;
activateNormalBuffer(): void;
activateAltBuffer(fillAttr?: IAttributeData): void;
+12 -12
View File
@@ -7,7 +7,7 @@ import { IDecoration, IDecorationOptions, ILinkHandler, ILogger, IWindowsPty, ty
import { CoreMouseEncoding, CoreMouseEventType, CursorInactiveStyle, CursorStyle, IAttributeData, ICharset, IColor, ICoreMouseEvent, ICoreMouseProtocol, IDecPrivateModes, IDisposable, IKittyKeyboardState, IModes, IOscLinkData, IWindowOptions } from 'common/Types';
import { IBuffer, IBufferSet } from 'common/buffer/Types';
import { createDecorator } from 'common/services/ServiceRegistry';
import type { Emitter, Event } from 'common/Event';
import type { Emitter, IEvent } from 'common/Event';
export const IBufferService = createDecorator<IBufferService>('BufferService');
export interface IBufferService {
@@ -18,8 +18,8 @@ export interface IBufferService {
readonly buffer: IBuffer;
readonly buffers: IBufferSet;
isUserScrolling: boolean;
onResize: Event<IBufferResizeEvent>;
onScroll: Event<number>;
onResize: IEvent<IBufferResizeEvent>;
onScroll: IEvent<number>;
scroll(eraseAttr: IAttributeData, isWrapped?: boolean): void;
scrollLines(disp: number, suppressScrollEvent?: boolean): void;
resize(cols: number, rows: number): void;
@@ -59,7 +59,7 @@ export interface ICoreMouseService {
/**
* Event to announce changes in mouse tracking.
*/
onProtocolChange: Event<CoreMouseEventType>;
onProtocolChange: IEvent<CoreMouseEventType>;
/**
* Human readable version of mouse events.
@@ -87,10 +87,10 @@ export interface ICoreService {
readonly decPrivateModes: IDecPrivateModes;
readonly kittyKeyboard: IKittyKeyboardState;
readonly onData: Event<string>;
readonly onUserInput: Event<void>;
readonly onBinary: Event<string>;
readonly onRequestScrollToBottom: Event<void>;
readonly onData: IEvent<string>;
readonly onUserInput: IEvent<void>;
readonly onBinary: IEvent<string>;
readonly onRequestScrollToBottom: IEvent<void>;
reset(): void;
@@ -201,7 +201,7 @@ export interface IOptionsService {
/**
* Adds an event listener for when any option changes.
*/
readonly onOptionChange: Event<keyof ITerminalOptions>;
readonly onOptionChange: IEvent<keyof ITerminalOptions>;
/**
* Adds an event listener for when a specific option changes, this is a convenience method that is
@@ -364,7 +364,7 @@ export interface IUnicodeService {
/** Currently active version. */
activeVersion: string;
/** Event triggered, when activate version changed. */
readonly onChange: Event<string>;
readonly onChange: IEvent<string>;
/**
* Unicode version dependent
@@ -389,8 +389,8 @@ export const IDecorationService = createDecorator<IDecorationService>('Decoratio
export interface IDecorationService extends IDisposable {
serviceBrand: undefined;
readonly decorations: IterableIterator<IInternalDecoration>;
readonly onDecorationRegistered: Event<IInternalDecoration>;
readonly onDecorationRemoved: Event<IInternalDecoration>;
readonly onDecorationRegistered: IEvent<IInternalDecoration>;
readonly onDecorationRemoved: IEvent<IInternalDecoration>;
registerDecoration(decorationOptions: IDecorationOptions): IDecoration | undefined;
reset(): void;
/**
+6 -6
View File
@@ -25,7 +25,7 @@ import { DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine';
import { IBuffer } from 'common/buffer/Types';
import { CoreTerminal } from 'common/CoreTerminal';
import { IMarker, ITerminalOptions } from 'common/Types';
import { Emitter, Event } from 'common/Event';
import { Emitter, EventUtils } from 'common/Event';
export class Terminal extends CoreTerminal {
private readonly _onBell = this._register(new Emitter<void>());
@@ -49,11 +49,11 @@ export class Terminal extends CoreTerminal {
// Setup InputHandler listeners
this._register(this._inputHandler.onRequestBell(() => this.bell()));
this._register(this._inputHandler.onRequestReset(() => this.reset()));
this._register(Event.forward(this._inputHandler.onCursorMove, this._onCursorMove));
this._register(Event.forward(this._inputHandler.onTitleChange, this._onTitleChange));
this._register(Event.forward(this._inputHandler.onA11yChar, this._onA11yCharEmitter));
this._register(Event.forward(this._inputHandler.onA11yTab, this._onA11yTabEmitter));
this._register(Event.forward(Event.map(this._inputHandler.onRequestRefreshRows, e => ({ start: e?.start ?? 0, end: e?.end ?? this.rows - 1 })), this._onRender));
this._register(EventUtils.forward(this._inputHandler.onCursorMove, this._onCursorMove));
this._register(EventUtils.forward(this._inputHandler.onTitleChange, this._onTitleChange));
this._register(EventUtils.forward(this._inputHandler.onA11yChar, this._onA11yCharEmitter));
this._register(EventUtils.forward(this._inputHandler.onA11yTab, this._onA11yTabEmitter));
this._register(EventUtils.forward(EventUtils.map(this._inputHandler.onRequestRefreshRows, e => ({ start: e?.start ?? 0, end: e?.end ?? this.rows - 1 })), this._onRender));
}
/**
+11 -11
View File
@@ -11,7 +11,7 @@ import { Terminal as TerminalCore } from 'headless/Terminal';
import { AddonManager } from 'common/public/AddonManager';
import { ITerminalOptions } from 'common/Types';
import { Disposable } from 'common/Lifecycle';
import type { Event } from 'common/Event';
import type { IEvent } from 'common/Event';
/**
* The set of options that only have an effect when set in the Terminal constructor.
*/
@@ -72,16 +72,16 @@ export class Terminal extends Disposable implements ITerminalApi {
}
}
public get onBell(): Event<void> { return this._core.onBell; }
public get onBinary(): Event<string> { return this._core.onBinary; }
public get onCursorMove(): Event<void> { return this._core.onCursorMove; }
public get onData(): Event<string> { return this._core.onData; }
public get onLineFeed(): Event<void> { return this._core.onLineFeed; }
public get onRender(): Event<{ start: number, end: number }> { return this._core.onRender; }
public get onResize(): Event<{ cols: number, rows: number }> { return this._core.onResize; }
public get onScroll(): Event<number> { return this._core.onScroll; }
public get onTitleChange(): Event<string> { return this._core.onTitleChange; }
public get onWriteParsed(): Event<void> { return this._core.onWriteParsed; }
public get onBell(): IEvent<void> { return this._core.onBell; }
public get onBinary(): IEvent<string> { return this._core.onBinary; }
public get onCursorMove(): IEvent<void> { return this._core.onCursorMove; }
public get onData(): IEvent<string> { return this._core.onData; }
public get onLineFeed(): IEvent<void> { return this._core.onLineFeed; }
public get onRender(): IEvent<{ start: number, end: number }> { return this._core.onRender; }
public get onResize(): IEvent<{ cols: number, rows: number }> { return this._core.onResize; }
public get onScroll(): IEvent<number> { return this._core.onScroll; }
public get onTitleChange(): IEvent<string> { return this._core.onTitleChange; }
public get onWriteParsed(): IEvent<void> { return this._core.onWriteParsed; }
public get parser(): IParser {
if (!this._parser) {