Skip to content

Commit

Permalink
Rename EventEmitter2 to EventEmitter
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyriar committed Jun 9, 2019
1 parent 447fc4f commit 80ce33f
Show file tree
Hide file tree
Showing 21 changed files with 66 additions and 66 deletions.
10 changes: 5 additions & 5 deletions src/InputHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Disposable } from 'common/Lifecycle';
import { concat } from 'common/TypedArrayUtils';
import { StringToUtf32, stringFromCodePoint, utf32ToString, Utf8ToUtf32 } from 'common/input/TextDecoder';
import { CellData, Attributes, FgFlags, BgFlags, AttributeData, NULL_CELL_WIDTH, NULL_CELL_CODE, DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine';
import { EventEmitter2, IEvent } from 'common/EventEmitter2';
import { EventEmitter, IEvent } from 'common/EventEmitter';
import { IParsingState, IDcsHandler, IEscapeSequenceParser } from 'common/parser/Types';

/**
Expand Down Expand Up @@ -108,13 +108,13 @@ export class InputHandler extends Disposable implements IInputHandler {
private _utf8Decoder: Utf8ToUtf32 = new Utf8ToUtf32();
private _workCell: CellData = new CellData();

private _onCursorMove = new EventEmitter2<void>();
private _onCursorMove = new EventEmitter<void>();
public get onCursorMove(): IEvent<void> { return this._onCursorMove.event; }
private _onData = new EventEmitter2<string>();
private _onData = new EventEmitter<string>();
public get onData(): IEvent<string> { return this._onData.event; }
private _onLineFeed = new EventEmitter2<void>();
private _onLineFeed = new EventEmitter<void>();
public get onLineFeed(): IEvent<void> { return this._onLineFeed.event; }
private _onScroll = new EventEmitter2<number>();
private _onScroll = new EventEmitter<number>();
public get onScroll(): IEvent<number> { return this._onScroll.event; }

constructor(
Expand Down
8 changes: 4 additions & 4 deletions src/Linkifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ILinkifierEvent, ILinkMatcher, LinkMatcherHandler, ILinkMatcherOptions,
import { IBufferStringIteratorResult } from 'common/buffer/Types';
import { MouseZone } from './MouseZoneManager';
import { getStringCellWidth } from 'common/CharWidth';
import { EventEmitter2, IEvent } from 'common/EventEmitter2';
import { EventEmitter, IEvent } from 'common/EventEmitter';

/**
* The Linkifier applies links to rows shortly after they have been refreshed.
Expand All @@ -34,11 +34,11 @@ export class Linkifier implements ILinkifier {
private _nextLinkMatcherId = 0;
private _rowsToLinkify: { start: number, end: number };

private _onLinkHover = new EventEmitter2<ILinkifierEvent>();
private _onLinkHover = new EventEmitter<ILinkifierEvent>();
public get onLinkHover(): IEvent<ILinkifierEvent> { return this._onLinkHover.event; }
private _onLinkLeave = new EventEmitter2<ILinkifierEvent>();
private _onLinkLeave = new EventEmitter<ILinkifierEvent>();
public get onLinkLeave(): IEvent<ILinkifierEvent> { return this._onLinkLeave.event; }
private _onLinkTooltip = new EventEmitter2<ILinkifierEvent>();
private _onLinkTooltip = new EventEmitter<ILinkifierEvent>();
public get onLinkTooltip(): IEvent<ILinkifierEvent> { return this._onLinkTooltip.event; }

constructor(
Expand Down
8 changes: 4 additions & 4 deletions src/SelectionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { SelectionModel } from './SelectionModel';
import { AltClickHandler } from './handlers/AltClickHandler';
import { CellData } from 'common/buffer/BufferLine';
import { IDisposable } from 'xterm';
import { EventEmitter2, IEvent } from 'common/EventEmitter2';
import { EventEmitter, IEvent } from 'common/EventEmitter';
import { ICharSizeService } from 'browser/services/Services';
import { IBufferService } from 'common/services/Services';

Expand Down Expand Up @@ -110,11 +110,11 @@ export class SelectionManager implements ISelectionManager {

private _mouseDownTimeStamp: number;

private _onLinuxMouseSelection = new EventEmitter2<string>();
private _onLinuxMouseSelection = new EventEmitter<string>();
public get onLinuxMouseSelection(): IEvent<string> { return this._onLinuxMouseSelection.event; }
private _onRedrawRequest = new EventEmitter2<ISelectionRedrawRequestEvent>();
private _onRedrawRequest = new EventEmitter<ISelectionRedrawRequestEvent>();
public get onRedrawRequest(): IEvent<ISelectionRedrawRequestEvent> { return this._onRedrawRequest.event; }
private _onSelectionChange = new EventEmitter2<void>();
private _onSelectionChange = new EventEmitter<void>();
public get onSelectionChange(): IEvent<void> { return this._onSelectionChange.event; }

constructor(
Expand Down
28 changes: 14 additions & 14 deletions src/Terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import { removeTerminalFromCache } from './renderer/atlas/CharAtlasCache';
import { DomRenderer } from './renderer/dom/DomRenderer';
import { IKeyboardEvent, KeyboardResultType, ICharset, IBufferLine, IAttributeData } from 'common/Types';
import { evaluateKeyboardEvent } from 'common/input/Keyboard';
import { EventEmitter2, IEvent } from 'common/EventEmitter2';
import { EventEmitter, IEvent } from 'common/EventEmitter';
import { Attributes, DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine';
import { applyWindowsMode } from './WindowsMode';
import { ColorManager } from 'browser/ColorManager';
Expand Down Expand Up @@ -190,32 +190,32 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
public get cols(): number { return this._bufferService.cols; }
public get rows(): number { return this._bufferService.rows; }

private _onCursorMove = new EventEmitter2<void>();
private _onCursorMove = new EventEmitter<void>();
public get onCursorMove(): IEvent<void> { return this._onCursorMove.event; }
private _onData = new EventEmitter2<string>();
private _onData = new EventEmitter<string>();
public get onData(): IEvent<string> { return this._onData.event; }
private _onKey = new EventEmitter2<{ key: string, domEvent: KeyboardEvent }>();
private _onKey = new EventEmitter<{ key: string, domEvent: KeyboardEvent }>();
public get onKey(): IEvent<{ key: string, domEvent: KeyboardEvent }> { return this._onKey.event; }
private _onLineFeed = new EventEmitter2<void>();
private _onLineFeed = new EventEmitter<void>();
public get onLineFeed(): IEvent<void> { return this._onLineFeed.event; }
private _onRender = new EventEmitter2<{ start: number, end: number }>();
private _onRender = new EventEmitter<{ start: number, end: number }>();
public get onRender(): IEvent<{ start: number, end: number }> { return this._onRender.event; }
private _onResize = new EventEmitter2<{ cols: number, rows: number }>();
private _onResize = new EventEmitter<{ cols: number, rows: number }>();
public get onResize(): IEvent<{ cols: number, rows: number }> { return this._onResize.event; }
private _onScroll = new EventEmitter2<number>();
private _onScroll = new EventEmitter<number>();
public get onScroll(): IEvent<number> { return this._onScroll.event; }
private _onSelectionChange = new EventEmitter2<void>();
private _onSelectionChange = new EventEmitter<void>();
public get onSelectionChange(): IEvent<void> { return this._onSelectionChange.event; }
private _onTitleChange = new EventEmitter2<string>();
private _onTitleChange = new EventEmitter<string>();
public get onTitleChange(): IEvent<string> { return this._onTitleChange.event; }

private _onFocus = new EventEmitter2<void>();
private _onFocus = new EventEmitter<void>();
public get onFocus(): IEvent<void> { return this._onFocus.event; }
private _onBlur = new EventEmitter2<void>();
private _onBlur = new EventEmitter<void>();
public get onBlur(): IEvent<void> { return this._onBlur.event; }
public onA11yCharEmitter = new EventEmitter2<string>();
public onA11yCharEmitter = new EventEmitter<string>();
public get onA11yChar(): IEvent<string> { return this.onA11yCharEmitter.event; }
public onA11yTabEmitter = new EventEmitter2<number>();
public onA11yTabEmitter = new EventEmitter<number>();
public get onA11yTab(): IEvent<number> { return this.onA11yTabEmitter.event; }

/**
Expand Down
6 changes: 3 additions & 3 deletions src/TestUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Terminal } from './Terminal';
import { AttributeData } from 'common/buffer/BufferLine';
import { IColorManager, IColorSet, IMouseHelper } from 'browser/Types';
import { IOptionsService } from 'common/services/Services';
import { EventEmitter2 } from 'common/EventEmitter2';
import { EventEmitter } from 'common/EventEmitter';

export class TestTerminal extends Terminal {
writeSync(data: string): void {
Expand Down Expand Up @@ -186,8 +186,8 @@ export class MockTerminal implements ITerminal {
}

export class MockInputHandlingTerminal implements IInputHandlingTerminal {
onA11yCharEmitter: EventEmitter2<string>;
onA11yTabEmitter: EventEmitter2<number>;
onA11yCharEmitter: EventEmitter<string>;
onA11yTabEmitter: EventEmitter<number>;
element: HTMLElement;
options: ITerminalOptions = {};
cols: number;
Expand Down
6 changes: 3 additions & 3 deletions src/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { ITerminalOptions as IPublicTerminalOptions, IDisposable, IMarker, ISelectionPosition } from 'xterm';
import { ICharset, IAttributeData, CharData } from 'common/Types';
import { IEvent, EventEmitter2 } from 'common/EventEmitter2';
import { IEvent, EventEmitter } from 'common/EventEmitter';
import { IColorSet, IMouseHelper } from 'browser/Types';
import { IOptionsService } from 'common/services/Services';
import { IBuffer, IBufferSet } from 'common/buffer/Types';
Expand Down Expand Up @@ -54,8 +54,8 @@ export interface IInputHandlingTerminal {
viewport: IViewport;
selectionManager: ISelectionManager;

onA11yCharEmitter: EventEmitter2<string>;
onA11yTabEmitter: EventEmitter2<number>;
onA11yCharEmitter: EventEmitter<string>;
onA11yTabEmitter: EventEmitter<number>;

bell(): void;
focus(): void;
Expand Down
4 changes: 2 additions & 2 deletions src/browser/TestUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
* @license MIT
*/

import { IEvent, EventEmitter2 } from 'common/EventEmitter2';
import { IEvent, EventEmitter } from 'common/EventEmitter';
import { ICharSizeService } from 'browser/services/Services';

export class MockCharSizeService implements ICharSizeService {
get hasValidSize(): boolean { return this.width > 0 && this.height > 0; }
onCharSizeChange: IEvent<void> = new EventEmitter2<void>().event;
onCharSizeChange: IEvent<void> = new EventEmitter<void>().event;
constructor(public width: number, public height: number) {}
measure(): void {}
}
4 changes: 2 additions & 2 deletions src/browser/services/CharSizeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { IOptionsService } from 'common/services/Services';
import { IEvent, EventEmitter2 } from 'common/EventEmitter2';
import { IEvent, EventEmitter } from 'common/EventEmitter';
import { ICharSizeService } from 'browser/services/Services';

export class CharSizeService implements ICharSizeService {
Expand All @@ -14,7 +14,7 @@ export class CharSizeService implements ICharSizeService {

public get hasValidSize(): boolean { return this.width > 0 && this.height > 0; }

private _onCharSizeChange = new EventEmitter2<void>();
private _onCharSizeChange = new EventEmitter<void>();
public get onCharSizeChange(): IEvent<void> { return this._onCharSizeChange.event; }

constructor(
Expand Down
8 changes: 4 additions & 4 deletions src/browser/services/RenderService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { IRenderer, IRenderDimensions, CharacterJoinerHandler } from 'browser/renderer/Types';
import { RenderDebouncer } from 'browser/RenderDebouncer';
import { EventEmitter2, IEvent } from 'common/EventEmitter2';
import { EventEmitter, IEvent } from 'common/EventEmitter';
import { Disposable } from 'common/Lifecycle';
import { ScreenDprMonitor } from 'browser/ScreenDprMonitor';
import { addDisposableDomListener } from 'browser/Lifecycle';
Expand All @@ -22,11 +22,11 @@ export class RenderService extends Disposable implements IRenderService {
private _canvasWidth: number = 0;
private _canvasHeight: number = 0;

private _onDimensionsChange = new EventEmitter2<IRenderDimensions>();
private _onDimensionsChange = new EventEmitter<IRenderDimensions>();
public get onDimensionsChange(): IEvent<IRenderDimensions> { return this._onDimensionsChange.event; }
private _onRender = new EventEmitter2<{ start: number, end: number }>();
private _onRender = new EventEmitter<{ start: number, end: number }>();
public get onRender(): IEvent<{ start: number, end: number }> { return this._onRender.event; }
private _onRefreshRequest = new EventEmitter2<{ start: number, end: number }>();
private _onRefreshRequest = new EventEmitter<{ start: number, end: number }>();
public get onRefreshRequest(): IEvent<{ start: number, end: number }> { return this._onRefreshRequest.event; }

public get dimensions(): IRenderDimensions { return this._renderer.dimensions; }
Expand Down
2 changes: 1 addition & 1 deletion src/browser/services/Services.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @license MIT
*/

import { IEvent } from 'common/EventEmitter2';
import { IEvent } from 'common/EventEmitter';
import { IRenderDimensions, IRenderer, CharacterJoinerHandler } from 'browser/renderer/Types';
import { IColorSet } from 'browser/Types';

Expand Down
8 changes: 4 additions & 4 deletions src/common/CircularList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { ICircularList } from 'common/Types';
import { EventEmitter2, IEvent } from 'common/EventEmitter2';
import { EventEmitter, IEvent } from 'common/EventEmitter';

export interface IInsertEvent {
index: number;
Expand All @@ -25,11 +25,11 @@ export class CircularList<T> implements ICircularList<T> {
private _startIndex: number;
private _length: number;

public onDeleteEmitter = new EventEmitter2<IDeleteEvent>();
public onDeleteEmitter = new EventEmitter<IDeleteEvent>();
public get onDelete(): IEvent<IDeleteEvent> { return this.onDeleteEmitter.event; }
public onInsertEmitter = new EventEmitter2<IInsertEvent>();
public onInsertEmitter = new EventEmitter<IInsertEvent>();
public get onInsert(): IEvent<IInsertEvent> { return this.onInsertEmitter.event; }
public onTrimEmitter = new EventEmitter2<number>();
public onTrimEmitter = new EventEmitter<number>();
public get onTrim(): IEvent<number> { return this.onTrimEmitter.event; }

constructor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
*/

import { assert } from 'chai';
import { EventEmitter2 } from 'common/EventEmitter2';
import { EventEmitter } from 'common/EventEmitter';

describe('EventEmitter2', () => {
describe('EventEmitter', () => {
it('should fire listeners multiple times', () => {
const order: string[] = [];
const emitter = new EventEmitter2<number>();
const emitter = new EventEmitter<number>();
emitter.event(data => order.push(data + 'a'));
emitter.event(data => order.push(data + 'b'));
emitter.fire(1);
Expand All @@ -19,7 +19,7 @@ describe('EventEmitter2', () => {

it('should not fire listeners once disposed', () => {
const order: string[] = [];
const emitter = new EventEmitter2<number>();
const emitter = new EventEmitter<number>();
emitter.event(data => order.push(data + 'a'));
const disposeB = emitter.event(data => order.push(data + 'b'));
emitter.event(data => order.push(data + 'c'));
Expand Down
2 changes: 1 addition & 1 deletion src/common/EventEmitter2.ts → src/common/EventEmitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface IEvent<T> {
(listener: (e: T) => any): IDisposable;
}

export class EventEmitter2<T> {
export class EventEmitter<T> {
private _listeners: IListener<T>[] = [];
private _event?: IEvent<T>;

Expand Down
4 changes: 2 additions & 2 deletions src/common/TestUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { IBufferService, IOptionsService, ITerminalOptions, IPartialTerminalOptions } from 'common/services/Services';
import { IEvent, EventEmitter2 } from 'common/EventEmitter2';
import { IEvent, EventEmitter } from 'common/EventEmitter';
import { clone } from 'common/Clone';
import { DEFAULT_OPTIONS } from 'common/services/OptionsService';

Expand All @@ -21,7 +21,7 @@ export class MockBufferService implements IBufferService {

export class MockOptionsService implements IOptionsService {
options: ITerminalOptions = clone(DEFAULT_OPTIONS);
onOptionChange: IEvent<string> = new EventEmitter2<string>().event;
onOptionChange: IEvent<string> = new EventEmitter<string>().event;
constructor(testOptions: IPartialTerminalOptions) {
Object.keys(testOptions).forEach(key => this.options[key] = (<any>testOptions)[key]);
}
Expand Down
8 changes: 4 additions & 4 deletions src/common/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @license MIT
*/

import { IEvent, EventEmitter2 } from 'common/EventEmitter2';
import { IEvent, EventEmitter } from 'common/EventEmitter';
import { IDeleteEvent, IInsertEvent } from 'common/CircularList';

export const DEFAULT_COLOR = 256;
Expand Down Expand Up @@ -40,11 +40,11 @@ export interface ICircularList<T> {
maxLength: number;
isFull: boolean;

onDeleteEmitter: EventEmitter2<IDeleteEvent>;
onDeleteEmitter: EventEmitter<IDeleteEvent>;
onDelete: IEvent<IDeleteEvent>;
onInsertEmitter: EventEmitter2<IInsertEvent>;
onInsertEmitter: EventEmitter<IInsertEvent>;
onInsert: IEvent<IInsertEvent>;
onTrimEmitter: EventEmitter2<number>;
onTrimEmitter: EventEmitter<number>;
onTrim: IEvent<number>;

get(index: number): T | undefined;
Expand Down
4 changes: 2 additions & 2 deletions src/common/buffer/BufferSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { IBuffer, IBufferSet } from 'common/buffer/Types';
import { IAttributeData } from 'common/Types';
import { Buffer } from 'common/buffer/Buffer';
import { EventEmitter2, IEvent } from 'common/EventEmitter2';
import { EventEmitter, IEvent } from 'common/EventEmitter';
import { IOptionsService, IBufferService } from 'common/services/Services';

/**
Expand All @@ -19,7 +19,7 @@ export class BufferSet implements IBufferSet {
private _activeBuffer: Buffer;


private _onBufferActivate = new EventEmitter2<{activeBuffer: IBuffer, inactiveBuffer: IBuffer}>();
private _onBufferActivate = new EventEmitter<{activeBuffer: IBuffer, inactiveBuffer: IBuffer}>();
public get onBufferActivate(): IEvent<{activeBuffer: IBuffer, inactiveBuffer: IBuffer}> { return this._onBufferActivate.event; }

/**
Expand Down
4 changes: 2 additions & 2 deletions src/common/buffer/Marker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @license MIT
*/

import { EventEmitter2, IEvent } from 'common/EventEmitter2';
import { EventEmitter, IEvent } from 'common/EventEmitter';
import { Disposable } from 'common/Lifecycle';
import { IMarker } from 'common/Types';

Expand All @@ -15,7 +15,7 @@ export class Marker extends Disposable implements IMarker {

public get id(): number { return this._id; }

private _onDispose = new EventEmitter2<void>();
private _onDispose = new EventEmitter<void>();
public get onDispose(): IEvent<void> { return this._onDispose.event; }

constructor(
Expand Down
2 changes: 1 addition & 1 deletion src/common/buffer/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { IAttributeData, ICircularList, IBufferLine, ICellData } from 'common/Types';
import { IEvent } from 'common/EventEmitter2';
import { IEvent } from 'common/EventEmitter';

// BufferIndex denotes a position in the buffer: [rowIndex, colIndex]
export type BufferIndex = [number, number];
Expand Down
4 changes: 2 additions & 2 deletions src/common/services/OptionsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { IOptionsService, ITerminalOptions, IPartialTerminalOptions } from 'common/services/Services';
import { EventEmitter2, IEvent } from 'common/EventEmitter2';
import { EventEmitter, IEvent } from 'common/EventEmitter';
import { isMac } from 'common/Platform';
import { clone } from 'common/Clone';

Expand Down Expand Up @@ -57,7 +57,7 @@ const CONSTRUCTOR_ONLY_OPTIONS = ['cols', 'rows'];
export class OptionsService implements IOptionsService {
public options: ITerminalOptions;

private _onOptionChange = new EventEmitter2<string>();
private _onOptionChange = new EventEmitter<string>();
public get onOptionChange(): IEvent<string> { return this._onOptionChange.event; }

constructor(options: IPartialTerminalOptions) {
Expand Down
Loading

0 comments on commit 80ce33f

Please sign in to comment.