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
+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;
/**