Create new event with emitter object to simplify code
This commit is contained in:
+11
-14
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import { ICircularList } from 'common/Types';
|
||||
import { EventEmitter, IEvent } from 'common/EventEmitter';
|
||||
import { initEvent } from 'common/EventEmitter';
|
||||
|
||||
export interface IInsertEvent {
|
||||
index: number;
|
||||
@@ -25,12 +25,9 @@ export class CircularList<T> implements ICircularList<T> {
|
||||
private _startIndex: number;
|
||||
private _length: number;
|
||||
|
||||
public readonly onDeleteEmitter = new EventEmitter<IDeleteEvent>();
|
||||
public readonly onDelete = this.onDeleteEmitter.event;
|
||||
public readonly onInsertEmitter = new EventEmitter<IInsertEvent>();
|
||||
public readonly onInsert = this.onInsertEmitter.event;
|
||||
public readonly onTrimEmitter = new EventEmitter<number>();
|
||||
public readonly onTrim = this.onTrimEmitter.event;
|
||||
public readonly onDelete = initEvent<IDeleteEvent>();
|
||||
public readonly onInsert = initEvent<IInsertEvent>();
|
||||
public readonly onTrim = initEvent<number>();
|
||||
|
||||
constructor(
|
||||
private _maxLength: number
|
||||
@@ -107,7 +104,7 @@ export class CircularList<T> implements ICircularList<T> {
|
||||
this._array[this._getCyclicIndex(this._length)] = value;
|
||||
if (this._length === this._maxLength) {
|
||||
this._startIndex = ++this._startIndex % this._maxLength;
|
||||
this.onTrimEmitter.fire(1);
|
||||
this.onTrim.fire(1);
|
||||
} else {
|
||||
this._length++;
|
||||
}
|
||||
@@ -123,7 +120,7 @@ export class CircularList<T> implements ICircularList<T> {
|
||||
throw new Error('Can only recycle when the buffer is full');
|
||||
}
|
||||
this._startIndex = ++this._startIndex % this._maxLength;
|
||||
this.onTrimEmitter.fire(1);
|
||||
this.onTrim.fire(1);
|
||||
return this._array[this._getCyclicIndex(this._length - 1)]!;
|
||||
}
|
||||
|
||||
@@ -158,7 +155,7 @@ export class CircularList<T> implements ICircularList<T> {
|
||||
this._array[this._getCyclicIndex(i)] = this._array[this._getCyclicIndex(i + deleteCount)];
|
||||
}
|
||||
this._length -= deleteCount;
|
||||
this.onDeleteEmitter.fire({ index: start, amount: deleteCount });
|
||||
this.onDelete.fire({ index: start, amount: deleteCount });
|
||||
}
|
||||
|
||||
// Add items
|
||||
@@ -169,7 +166,7 @@ export class CircularList<T> implements ICircularList<T> {
|
||||
this._array[this._getCyclicIndex(start + i)] = items[i];
|
||||
}
|
||||
if (items.length) {
|
||||
this.onInsertEmitter.fire({ index: start, amount: items.length });
|
||||
this.onInsert.fire({ index: start, amount: items.length });
|
||||
}
|
||||
|
||||
// Adjust length as needed
|
||||
@@ -177,7 +174,7 @@ export class CircularList<T> implements ICircularList<T> {
|
||||
const countToTrim = (this._length + items.length) - this._maxLength;
|
||||
this._startIndex += countToTrim;
|
||||
this._length = this._maxLength;
|
||||
this.onTrimEmitter.fire(countToTrim);
|
||||
this.onTrim.fire(countToTrim);
|
||||
} else {
|
||||
this._length += items.length;
|
||||
}
|
||||
@@ -193,7 +190,7 @@ export class CircularList<T> implements ICircularList<T> {
|
||||
}
|
||||
this._startIndex += count;
|
||||
this._length -= count;
|
||||
this.onTrimEmitter.fire(count);
|
||||
this.onTrim.fire(count);
|
||||
}
|
||||
|
||||
public shiftElements(start: number, count: number, offset: number): void {
|
||||
@@ -217,7 +214,7 @@ export class CircularList<T> implements ICircularList<T> {
|
||||
while (this._length > this._maxLength) {
|
||||
this._length--;
|
||||
this._startIndex++;
|
||||
this.onTrimEmitter.fire(1);
|
||||
this.onTrim.fire(1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
+11
-16
@@ -29,7 +29,7 @@ import { BufferService, MINIMUM_COLS, MINIMUM_ROWS } from 'common/services/Buffe
|
||||
import { OptionsService } from 'common/services/OptionsService';
|
||||
import { IDisposable, IAttributeData, ICoreTerminal, IScrollEvent, ScrollSource } from 'common/Types';
|
||||
import { CoreService } from 'common/services/CoreService';
|
||||
import { EventEmitter, IEvent, forwardEvent } from 'common/EventEmitter';
|
||||
import { EventEmitter, IEvent, forwardEvent, initEvent } from 'common/EventEmitter';
|
||||
import { CoreMouseService } from 'common/services/CoreMouseService';
|
||||
import { UnicodeService } from 'common/services/UnicodeService';
|
||||
import { CharsetService } from 'common/services/CharsetService';
|
||||
@@ -59,16 +59,11 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
|
||||
private _writeBuffer: WriteBuffer;
|
||||
private _windowsMode: IDisposable | undefined;
|
||||
|
||||
private readonly _onBinary = new EventEmitter<string>();
|
||||
public readonly onBinary = this._onBinary.event;
|
||||
private readonly _onData = new EventEmitter<string>();
|
||||
public readonly onData = this._onData.event;
|
||||
protected _onLineFeed = new EventEmitter<void>();
|
||||
public readonly onLineFeed = this._onLineFeed.event;
|
||||
private readonly _onResize = new EventEmitter<{ cols: number, rows: number }>();
|
||||
public readonly onResize = this._onResize.event;
|
||||
protected readonly _onWriteParsed = new EventEmitter<void>();
|
||||
public readonly onWriteParsed = this._onWriteParsed.event;
|
||||
public readonly onBinary = initEvent<string>();
|
||||
public readonly onData = initEvent<string>();
|
||||
public readonly onLineFeed = initEvent<void>();
|
||||
public readonly onResize = initEvent<{ cols: number, rows: number }>();
|
||||
public readonly onWriteParsed = initEvent<void>();
|
||||
|
||||
/**
|
||||
* Internally we track the source of the scroll but this is meaningless outside the library so
|
||||
@@ -122,13 +117,13 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
|
||||
|
||||
// Register input handler and handle/forward events
|
||||
this._inputHandler = new InputHandler(this._bufferService, this._charsetService, this.coreService, this._logService, this.optionsService, this._oscLinkService, this.coreMouseService, this.unicodeService);
|
||||
this.register(forwardEvent(this._inputHandler.onLineFeed, this._onLineFeed));
|
||||
this.register(forwardEvent(this._inputHandler.onLineFeed, this.onLineFeed));
|
||||
this.register(this._inputHandler);
|
||||
|
||||
// Setup listeners
|
||||
this.register(forwardEvent(this._bufferService.onResize, this._onResize));
|
||||
this.register(forwardEvent(this.coreService.onData, this._onData));
|
||||
this.register(forwardEvent(this.coreService.onBinary, this._onBinary));
|
||||
this.register(forwardEvent(this._bufferService.onResize, this.onResize));
|
||||
this.register(forwardEvent(this.coreService.onData, this.onData));
|
||||
this.register(forwardEvent(this.coreService.onBinary, this.onBinary));
|
||||
this.register(this.coreService.onUserInput(() => this._writeBuffer.handleUserInput()));
|
||||
this.register(this.optionsService.onOptionChange(key => this._updateOptions(key)));
|
||||
this.register(this._bufferService.onScroll(event => {
|
||||
@@ -142,7 +137,7 @@ export abstract class CoreTerminal extends Disposable implements ICoreTerminal {
|
||||
|
||||
// Setup WriteBuffer
|
||||
this._writeBuffer = new WriteBuffer((data, promiseResult) => this._inputHandler.parse(data, promiseResult));
|
||||
this.register(forwardEvent(this._writeBuffer.onWriteParsed, this._onWriteParsed));
|
||||
this.register(forwardEvent(this._writeBuffer.onWriteParsed, this.onWriteParsed));
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
|
||||
@@ -14,11 +14,13 @@ export interface IEvent<T, U = void> {
|
||||
}
|
||||
|
||||
export interface IEventEmitter<T, U = void> {
|
||||
event: IEvent<T, U>;
|
||||
fire(arg1: T, arg2: U): void;
|
||||
dispose(): void;
|
||||
}
|
||||
|
||||
export interface IEventWithEmitter<T, U = void> extends IEventEmitter<T, U>, IEvent<T, U> {
|
||||
}
|
||||
|
||||
export class EventEmitter<T, U = void> implements IEventEmitter<T, U> {
|
||||
private _listeners: IListener<T, U>[] = [];
|
||||
private _event?: IEvent<T, U>;
|
||||
@@ -64,6 +66,18 @@ export class EventEmitter<T, U = void> implements IEventEmitter<T, U> {
|
||||
}
|
||||
}
|
||||
|
||||
export function initEvent<T, U = void>(): IEventWithEmitter<T, U> {
|
||||
const emitter = new EventEmitter<T, U>();
|
||||
const event = emitter.event;
|
||||
Object.defineProperty(event, 'fire', {
|
||||
value: emitter.fire.bind(emitter)
|
||||
});
|
||||
Object.defineProperty(event, 'dispose', {
|
||||
value: emitter.dispose.bind(emitter)
|
||||
});
|
||||
return event as any;
|
||||
}
|
||||
|
||||
export function forwardEvent<T>(from: IEvent<T>, to: IEventEmitter<T>): IDisposable {
|
||||
return from(e => to.fire(e));
|
||||
}
|
||||
|
||||
+45
-58
@@ -11,7 +11,7 @@ import { EscapeSequenceParser } from 'common/parser/EscapeSequenceParser';
|
||||
import { Disposable } from 'common/Lifecycle';
|
||||
import { StringToUtf32, stringFromCodePoint, Utf8ToUtf32 } from 'common/input/TextDecoder';
|
||||
import { DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine';
|
||||
import { EventEmitter, IEvent } from 'common/EventEmitter';
|
||||
import { EventEmitter, IEvent, initEvent } from 'common/EventEmitter';
|
||||
import { IParsingState, IEscapeSequenceParser, IParams, IFunctionIdentifier } from 'common/parser/Types';
|
||||
import { NULL_CELL_CODE, NULL_CELL_WIDTH, Attributes, FgFlags, BgFlags, Content, UnderlineStyle } from 'common/buffer/Constants';
|
||||
import { CellData } from 'common/buffer/CellData';
|
||||
@@ -132,33 +132,20 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
|
||||
private _activeBuffer: IBuffer;
|
||||
|
||||
private readonly _onRequestBell = new EventEmitter<void>();
|
||||
public readonly onRequestBell = this._onRequestBell.event;
|
||||
private readonly _onRequestRefreshRows = new EventEmitter<number, number>();
|
||||
public readonly onRequestRefreshRows = this._onRequestRefreshRows.event;
|
||||
private readonly _onRequestReset = new EventEmitter<void>();
|
||||
public readonly onRequestReset = this._onRequestReset.event;
|
||||
private readonly _onRequestSendFocus = new EventEmitter<void>();
|
||||
public readonly onRequestSendFocus = this._onRequestSendFocus.event;
|
||||
private readonly _onRequestSyncScrollBar = new EventEmitter<void>();
|
||||
public readonly onRequestSyncScrollBar = this._onRequestSyncScrollBar.event;
|
||||
private readonly _onRequestWindowsOptionsReport = new EventEmitter<WindowsOptionsReportType>();
|
||||
public readonly onRequestWindowsOptionsReport = this._onRequestWindowsOptionsReport.event;
|
||||
public readonly onRequestBell = initEvent<void>();
|
||||
public readonly onRequestRefreshRows = initEvent<number, number>();
|
||||
public readonly onRequestReset = initEvent<void>();
|
||||
public readonly onRequestSendFocus = initEvent<void>();
|
||||
public readonly onRequestSyncScrollBar = initEvent<void>();
|
||||
public readonly onRequestWindowsOptionsReport = initEvent<WindowsOptionsReportType>();
|
||||
|
||||
private readonly _onA11yChar = new EventEmitter<string>();
|
||||
public readonly onA11yChar = this._onA11yChar.event;
|
||||
private readonly _onA11yTab = new EventEmitter<number>();
|
||||
public readonly onA11yTab = this._onA11yTab.event;
|
||||
private readonly _onCursorMove = new EventEmitter<void>();
|
||||
public readonly onCursorMove = this._onCursorMove.event;
|
||||
private readonly _onLineFeed = new EventEmitter<void>();
|
||||
public readonly onLineFeed = this._onLineFeed.event;
|
||||
private readonly _onScroll = new EventEmitter<number>();
|
||||
public readonly onScroll = this._onScroll.event;
|
||||
private readonly _onTitleChange = new EventEmitter<string>();
|
||||
public readonly onTitleChange = this._onTitleChange.event;
|
||||
private readonly _onColor = new EventEmitter<IColorEvent>();
|
||||
public readonly onColor = this._onColor.event;
|
||||
public readonly onA11yChar = initEvent<string>();
|
||||
public readonly onA11yTab = initEvent<number>();
|
||||
public readonly onCursorMove = initEvent<void>();
|
||||
public readonly onLineFeed = initEvent<void>();
|
||||
public readonly onScroll = initEvent<number>();
|
||||
public readonly onTitleChange = initEvent<string>();
|
||||
public readonly onColor = initEvent<IColorEvent>();
|
||||
|
||||
private _parseStack: IParseStack = {
|
||||
paused: false,
|
||||
@@ -492,11 +479,11 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
}
|
||||
|
||||
if (this._activeBuffer.x !== cursorStartX || this._activeBuffer.y !== cursorStartY) {
|
||||
this._onCursorMove.fire();
|
||||
this.onCursorMove.fire();
|
||||
}
|
||||
|
||||
// Refresh any dirty rows accumulated as part of parsing
|
||||
this._onRequestRefreshRows.fire(this._dirtyRowTracker.start, this._dirtyRowTracker.end);
|
||||
this.onRequestRefreshRows.fire(this._dirtyRowTracker.start, this._dirtyRowTracker.end);
|
||||
}
|
||||
|
||||
public print(data: Uint32Array, start: number, end: number): void {
|
||||
@@ -535,7 +522,7 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
}
|
||||
|
||||
if (screenReaderMode) {
|
||||
this._onA11yChar.fire(stringFromCodePoint(code));
|
||||
this.onA11yChar.fire(stringFromCodePoint(code));
|
||||
}
|
||||
if (this._currentLinkId !== undefined) {
|
||||
this._oscLinkService.addLineToLink(this._currentLinkId, this._activeBuffer.ybase + this._activeBuffer.y);
|
||||
@@ -687,7 +674,7 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
* and `ITerminalOptions.bellSound`.
|
||||
*/
|
||||
public bell(): boolean {
|
||||
this._onRequestBell.fire();
|
||||
this.onRequestBell.fire();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -719,7 +706,7 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
}
|
||||
this._dirtyRowTracker.markDirty(this._activeBuffer.y);
|
||||
|
||||
this._onLineFeed.fire();
|
||||
this.onLineFeed.fire();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -808,7 +795,7 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
const originalX = this._activeBuffer.x;
|
||||
this._activeBuffer.x = this._activeBuffer.nextStop();
|
||||
if (this._optionsService.rawOptions.screenReaderMode) {
|
||||
this._onA11yTab.fire(this._activeBuffer.x - originalX);
|
||||
this.onA11yTab.fire(this._activeBuffer.x - originalX);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1218,7 +1205,7 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
this._activeBuffer.ybase = Math.max(this._activeBuffer.ybase - scrollBackSize, 0);
|
||||
this._activeBuffer.ydisp = Math.max(this._activeBuffer.ydisp - scrollBackSize, 0);
|
||||
// Force a scroll event to refresh viewport
|
||||
this._onScroll.fire(0);
|
||||
this.onScroll.fire(0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1849,7 +1836,7 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
*/
|
||||
if (this._optionsService.rawOptions.windowOptions.setWinLines) {
|
||||
this._bufferService.resize(132, this._bufferService.rows);
|
||||
this._onRequestReset.fire();
|
||||
this.onRequestReset.fire();
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
@@ -1868,7 +1855,7 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
case 66:
|
||||
this._logService.debug('Serial port requested application keypad.');
|
||||
this._coreService.decPrivateModes.applicationKeypad = true;
|
||||
this._onRequestSyncScrollBar.fire();
|
||||
this.onRequestSyncScrollBar.fire();
|
||||
break;
|
||||
case 9: // X10 Mouse
|
||||
// no release, no motion, no wheel, no modifiers.
|
||||
@@ -1890,7 +1877,7 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
// focusin: ^[[I
|
||||
// focusout: ^[[O
|
||||
this._coreService.decPrivateModes.sendFocus = true;
|
||||
this._onRequestSendFocus.fire();
|
||||
this.onRequestSendFocus.fire();
|
||||
break;
|
||||
case 1005: // utf8 ext mode mouse - removed in #2507
|
||||
this._logService.debug('DECSET 1005 not supported (see #2507)');
|
||||
@@ -1917,8 +1904,8 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
case 1047: // alt screen buffer
|
||||
this._bufferService.buffers.activateAltBuffer(this._eraseAttrData());
|
||||
this._coreService.isCursorInitialized = true;
|
||||
this._onRequestRefreshRows.fire(0, this._bufferService.rows - 1);
|
||||
this._onRequestSyncScrollBar.fire();
|
||||
this.onRequestRefreshRows.fire(0, this._bufferService.rows - 1);
|
||||
this.onRequestSyncScrollBar.fire();
|
||||
break;
|
||||
case 2004: // bracketed paste mode (https://cirw.in/blog/bracketed-paste)
|
||||
this._coreService.decPrivateModes.bracketedPasteMode = true;
|
||||
@@ -2087,7 +2074,7 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
*/
|
||||
if (this._optionsService.rawOptions.windowOptions.setWinLines) {
|
||||
this._bufferService.resize(80, this._bufferService.rows);
|
||||
this._onRequestReset.fire();
|
||||
this.onRequestReset.fire();
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
@@ -2106,7 +2093,7 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
case 66:
|
||||
this._logService.debug('Switching back to normal keypad.');
|
||||
this._coreService.decPrivateModes.applicationKeypad = false;
|
||||
this._onRequestSyncScrollBar.fire();
|
||||
this.onRequestSyncScrollBar.fire();
|
||||
break;
|
||||
case 9: // X10 Mouse
|
||||
case 1000: // vt200 mouse
|
||||
@@ -2145,8 +2132,8 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
this.restoreCursor();
|
||||
}
|
||||
this._coreService.isCursorInitialized = true;
|
||||
this._onRequestRefreshRows.fire(0, this._bufferService.rows - 1);
|
||||
this._onRequestSyncScrollBar.fire();
|
||||
this.onRequestRefreshRows.fire(0, this._bufferService.rows - 1);
|
||||
this.onRequestSyncScrollBar.fire();
|
||||
break;
|
||||
case 2004: // bracketed paste mode (https://cirw.in/blog/bracketed-paste)
|
||||
this._coreService.decPrivateModes.bracketedPasteMode = false;
|
||||
@@ -2645,7 +2632,7 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
*/
|
||||
public softReset(params: IParams): boolean {
|
||||
this._coreService.isCursorHidden = false;
|
||||
this._onRequestSyncScrollBar.fire();
|
||||
this.onRequestSyncScrollBar.fire();
|
||||
this._activeBuffer.scrollTop = 0;
|
||||
this._activeBuffer.scrollBottom = this._bufferService.rows - 1;
|
||||
this._curAttrData = DEFAULT_ATTR_DATA.clone();
|
||||
@@ -2765,11 +2752,11 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
switch (params.params[0]) {
|
||||
case 14: // GetWinSizePixels, returns CSI 4 ; height ; width t
|
||||
if (second !== 2) {
|
||||
this._onRequestWindowsOptionsReport.fire(WindowsOptionsReportType.GET_WIN_SIZE_PIXELS);
|
||||
this.onRequestWindowsOptionsReport.fire(WindowsOptionsReportType.GET_WIN_SIZE_PIXELS);
|
||||
}
|
||||
break;
|
||||
case 16: // GetCellSizePixels, returns CSI 6 ; height ; width t
|
||||
this._onRequestWindowsOptionsReport.fire(WindowsOptionsReportType.GET_CELL_SIZE_PIXELS);
|
||||
this.onRequestWindowsOptionsReport.fire(WindowsOptionsReportType.GET_CELL_SIZE_PIXELS);
|
||||
break;
|
||||
case 18: // GetWinSizeChars, returns CSI 8 ; height ; width t
|
||||
if (this._bufferService) {
|
||||
@@ -2859,7 +2846,7 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
*/
|
||||
public setTitle(data: string): boolean {
|
||||
this._windowTitle = data;
|
||||
this._onTitleChange.fire(data);
|
||||
this.onTitleChange.fire(data);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2901,7 +2888,7 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
}
|
||||
}
|
||||
if (event.length) {
|
||||
this._onColor.fire(event);
|
||||
this.onColor.fire(event);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -2975,11 +2962,11 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
for (let i = 0; i < slots.length; ++i, ++offset) {
|
||||
if (offset >= this._specialColors.length) break;
|
||||
if (slots[i] === '?') {
|
||||
this._onColor.fire([{ type: ColorRequestType.REPORT, index: this._specialColors[offset] }]);
|
||||
this.onColor.fire([{ type: ColorRequestType.REPORT, index: this._specialColors[offset] }]);
|
||||
} else {
|
||||
const color = parseColor(slots[i]);
|
||||
if (color) {
|
||||
this._onColor.fire([{ type: ColorRequestType.SET, index: this._specialColors[offset], color }]);
|
||||
this.onColor.fire([{ type: ColorRequestType.SET, index: this._specialColors[offset], color }]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3040,7 +3027,7 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
*/
|
||||
public restoreIndexedColor(data: string): boolean {
|
||||
if (!data) {
|
||||
this._onColor.fire([{ type: ColorRequestType.RESTORE }]);
|
||||
this.onColor.fire([{ type: ColorRequestType.RESTORE }]);
|
||||
return true;
|
||||
}
|
||||
const event: IColorEvent = [];
|
||||
@@ -3054,7 +3041,7 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
}
|
||||
}
|
||||
if (event.length) {
|
||||
this._onColor.fire(event);
|
||||
this.onColor.fire(event);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -3065,7 +3052,7 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
* @vt: #Y OSC 110 "Restore default foreground color" "OSC 110 BEL" "Restore default foreground to themed color."
|
||||
*/
|
||||
public restoreFgColor(data: string): boolean {
|
||||
this._onColor.fire([{ type: ColorRequestType.RESTORE, index: ColorIndex.FOREGROUND }]);
|
||||
this.onColor.fire([{ type: ColorRequestType.RESTORE, index: ColorIndex.FOREGROUND }]);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3075,7 +3062,7 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
* @vt: #Y OSC 111 "Restore default background color" "OSC 111 BEL" "Restore default background to themed color."
|
||||
*/
|
||||
public restoreBgColor(data: string): boolean {
|
||||
this._onColor.fire([{ type: ColorRequestType.RESTORE, index: ColorIndex.BACKGROUND }]);
|
||||
this.onColor.fire([{ type: ColorRequestType.RESTORE, index: ColorIndex.BACKGROUND }]);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3085,7 +3072,7 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
* @vt: #Y OSC 112 "Restore default cursor color" "OSC 112 BEL" "Restore default cursor to themed color."
|
||||
*/
|
||||
public restoreCursorColor(data: string): boolean {
|
||||
this._onColor.fire([{ type: ColorRequestType.RESTORE, index: ColorIndex.CURSOR }]);
|
||||
this.onColor.fire([{ type: ColorRequestType.RESTORE, index: ColorIndex.CURSOR }]);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3112,7 +3099,7 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
public keypadApplicationMode(): boolean {
|
||||
this._logService.debug('Serial port requested application keypad.');
|
||||
this._coreService.decPrivateModes.applicationKeypad = true;
|
||||
this._onRequestSyncScrollBar.fire();
|
||||
this.onRequestSyncScrollBar.fire();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3124,7 +3111,7 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
public keypadNumericMode(): boolean {
|
||||
this._logService.debug('Switching back to normal keypad.');
|
||||
this._coreService.decPrivateModes.applicationKeypad = false;
|
||||
this._onRequestSyncScrollBar.fire();
|
||||
this.onRequestSyncScrollBar.fire();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3238,7 +3225,7 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
*/
|
||||
public fullReset(): boolean {
|
||||
this._parser.reset();
|
||||
this._onRequestReset.fire();
|
||||
this.onRequestReset.fire();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import { IBufferService, ICoreService, ILogService, IOptionsService, ITerminalOptions, ICoreMouseService, ICharsetService, IUnicodeService, IUnicodeVersionProvider, LogLevelEnum, IDecorationService, IInternalDecoration, IOscLinkService } from 'common/services/Services';
|
||||
import { IEvent, EventEmitter } from 'common/EventEmitter';
|
||||
import { IEvent, EventEmitter, initEvent } from 'common/EventEmitter';
|
||||
import { clone } from 'common/Clone';
|
||||
import { DEFAULT_OPTIONS } from 'common/services/OptionsService';
|
||||
import { IBufferSet, IBuffer } from 'common/buffer/Types';
|
||||
@@ -17,8 +17,8 @@ export class MockBufferService implements IBufferService {
|
||||
public serviceBrand: any;
|
||||
public get buffer(): IBuffer { return this.buffers.active; }
|
||||
public buffers: IBufferSet = {} as any;
|
||||
public onResize: IEvent<{ cols: number, rows: number }> = new EventEmitter<{ cols: number, rows: number }>().event;
|
||||
public onScroll: IEvent<number> = new EventEmitter<number>().event;
|
||||
public onResize: IEvent<{ cols: number, rows: number }> = initEvent<{ cols: number, rows: number }>();
|
||||
public onScroll: IEvent<number> = initEvent<number>();
|
||||
public isUserScrolling: boolean = false;
|
||||
constructor(
|
||||
public cols: number,
|
||||
@@ -60,7 +60,7 @@ export class MockCoreMouseService implements ICoreMouseService {
|
||||
public addProtocol(name: string): void { }
|
||||
public reset(): void { }
|
||||
public triggerMouseEvent(event: ICoreMouseEvent): boolean { return false; }
|
||||
public onProtocolChange: IEvent<CoreMouseEventType> = new EventEmitter<CoreMouseEventType>().event;
|
||||
public onProtocolChange: IEvent<CoreMouseEventType> = initEvent<CoreMouseEventType>();
|
||||
public explainEvents(events: CoreMouseEventType): { [event: string]: boolean } {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
@@ -92,9 +92,9 @@ export class MockCoreService implements ICoreService {
|
||||
sendFocus: false,
|
||||
wraparound: true
|
||||
};
|
||||
public onData: IEvent<string> = new EventEmitter<string>().event;
|
||||
public onUserInput: IEvent<void> = new EventEmitter<void>().event;
|
||||
public onBinary: IEvent<string> = new EventEmitter<string>().event;
|
||||
public onData: IEvent<string> = initEvent<string>();
|
||||
public onUserInput: IEvent<void> = initEvent<void>();
|
||||
public onBinary: IEvent<string> = initEvent<string>();
|
||||
public reset(): void { }
|
||||
public triggerDataEvent(data: string, wasUserInput?: boolean): void { }
|
||||
public triggerBinaryEvent(data: string): void { }
|
||||
@@ -113,7 +113,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: IEvent<string> = new EventEmitter<string>().event;
|
||||
public onOptionChange: IEvent<string> = initEvent<string>();
|
||||
constructor(testOptions?: Partial<ITerminalOptions>) {
|
||||
if (testOptions) {
|
||||
for (const key of Object.keys(testOptions)) {
|
||||
@@ -149,7 +149,7 @@ export class MockUnicodeService implements IUnicodeService {
|
||||
}
|
||||
public versions: string[] = [];
|
||||
public activeVersion: string = '';
|
||||
public onChange: IEvent<string> = new EventEmitter<string>().event;
|
||||
public onChange: IEvent<string> = initEvent<string>();
|
||||
public wcwidth = (codepoint: number): number => this._provider.wcwidth(codepoint);
|
||||
public getStringCellWidth(s: string): number {
|
||||
throw new Error('Method not implemented.');
|
||||
@@ -159,8 +159,8 @@ export class MockUnicodeService implements IUnicodeService {
|
||||
export class MockDecorationService implements IDecorationService {
|
||||
public serviceBrand: any;
|
||||
public get decorations(): IterableIterator<IInternalDecoration> { return [].values(); }
|
||||
public onDecorationRegistered = new EventEmitter<IInternalDecoration>().event;
|
||||
public onDecorationRemoved = new EventEmitter<IInternalDecoration>().event;
|
||||
public onDecorationRegistered = initEvent<IInternalDecoration>();
|
||||
public onDecorationRemoved = initEvent<IInternalDecoration>();
|
||||
public registerDecoration(decorationOptions: IDecorationOptions): IDecoration | undefined { return undefined; }
|
||||
public reset(): void { }
|
||||
public forEachDecorationAtCell(x: number, line: number, layer: 'bottom' | 'top' | undefined, callback: (decoration: IInternalDecoration) => void): void { }
|
||||
|
||||
Vendored
+4
-7
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import { IFunctionIdentifier, ITerminalOptions as IPublicTerminalOptions } from 'xterm';
|
||||
import { IEvent, IEventEmitter } from 'common/EventEmitter';
|
||||
import { IEvent, IEventEmitter, IEventWithEmitter } from 'common/EventEmitter';
|
||||
import { IDeleteEvent, IInsertEvent } from 'common/CircularList';
|
||||
import { IParams } from 'common/parser/Types';
|
||||
import { ICoreMouseService, ICoreService, IOptionsService, IUnicodeService } from 'common/services/Services';
|
||||
@@ -71,12 +71,9 @@ export interface ICircularList<T> {
|
||||
maxLength: number;
|
||||
isFull: boolean;
|
||||
|
||||
onDeleteEmitter: IEventEmitter<IDeleteEvent>;
|
||||
onDelete: IEvent<IDeleteEvent>;
|
||||
onInsertEmitter: IEventEmitter<IInsertEvent>;
|
||||
onInsert: IEvent<IInsertEvent>;
|
||||
onTrimEmitter: IEventEmitter<number>;
|
||||
onTrim: IEvent<number>;
|
||||
onDelete: IEventWithEmitter<IDeleteEvent>;
|
||||
onInsert: IEventWithEmitter<IInsertEvent>;
|
||||
onTrim: IEventWithEmitter<number>;
|
||||
|
||||
get(index: number): T | undefined;
|
||||
set(index: number, value: T): void;
|
||||
|
||||
@@ -1071,7 +1071,7 @@ describe('Buffer', () => {
|
||||
buffer.fillViewportRows();
|
||||
const marker = buffer.addMarker(buffer.lines.length - 1);
|
||||
assert.equal(marker.line, buffer.lines.length - 1);
|
||||
buffer.lines.onTrimEmitter.fire(1);
|
||||
buffer.lines.onTrim.fire(1);
|
||||
assert.equal(marker.line, buffer.lines.length - 2);
|
||||
});
|
||||
it('should dispose of a marker if it is trimmed off the buffer', () => {
|
||||
@@ -1081,7 +1081,7 @@ describe('Buffer', () => {
|
||||
const marker = buffer.addMarker(0);
|
||||
assert.equal(marker.isDisposed, false);
|
||||
assert.equal(buffer.markers.length, 1);
|
||||
buffer.lines.onTrimEmitter.fire(1);
|
||||
buffer.lines.onTrim.fire(1);
|
||||
assert.equal(marker.isDisposed, true);
|
||||
assert.equal(buffer.markers.length, 0);
|
||||
});
|
||||
@@ -1094,7 +1094,7 @@ describe('Buffer', () => {
|
||||
marker.onDispose(() => eventStack.push('disposed'));
|
||||
assert.equal(marker.isDisposed, false);
|
||||
assert.equal(buffer.markers.length, 1);
|
||||
buffer.lines.onTrimEmitter.fire(1);
|
||||
buffer.lines.onTrim.fire(1);
|
||||
assert.equal(marker.isDisposed, true);
|
||||
assert.equal(buffer.markers.length, 0);
|
||||
assert.deepEqual(eventStack, ['disposed']);
|
||||
|
||||
@@ -463,12 +463,12 @@ export class Buffer implements IBuffer {
|
||||
let insertCountEmitted = 0;
|
||||
for (let i = insertEvents.length - 1; i >= 0; i--) {
|
||||
insertEvents[i].index += insertCountEmitted;
|
||||
this.lines.onInsertEmitter.fire(insertEvents[i]);
|
||||
this.lines.onInsert.fire(insertEvents[i]);
|
||||
insertCountEmitted += insertEvents[i].amount;
|
||||
}
|
||||
const amountToTrim = Math.max(0, originalLinesLength + countToInsert - this.lines.maxLength);
|
||||
if (amountToTrim > 0) {
|
||||
this.lines.onTrimEmitter.fire(amountToTrim);
|
||||
this.lines.onTrim.fire(amountToTrim);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ export function reflowLargerCreateNewLayout(lines: CircularList<IBufferLine>, to
|
||||
const countToRemove = toRemove[++nextToRemoveIndex];
|
||||
|
||||
// Tell markers that there was a deletion
|
||||
lines.onDeleteEmitter.fire({
|
||||
lines.onDelete.fire({
|
||||
index: i - countRemovedSoFar,
|
||||
amount: countToRemove
|
||||
});
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import { IBuffer, IBufferSet } from 'common/buffer/Types';
|
||||
import { IAttributeData } from 'common/Types';
|
||||
import { Buffer } from 'common/buffer/Buffer';
|
||||
import { EventEmitter, IEvent } from 'common/EventEmitter';
|
||||
import { EventEmitter, IEvent, initEvent } from 'common/EventEmitter';
|
||||
import { IOptionsService, IBufferService } from 'common/services/Services';
|
||||
import { Disposable } from 'common/Lifecycle';
|
||||
|
||||
@@ -19,8 +19,7 @@ export class BufferSet extends Disposable implements IBufferSet {
|
||||
private _alt!: Buffer;
|
||||
private _activeBuffer!: Buffer;
|
||||
|
||||
private readonly _onBufferActivate = this.register(new EventEmitter<{activeBuffer: IBuffer, inactiveBuffer: IBuffer}>());
|
||||
public readonly onBufferActivate = this._onBufferActivate.event;
|
||||
public readonly onBufferActivate = this.register(initEvent<{activeBuffer: IBuffer, inactiveBuffer: IBuffer}>());
|
||||
|
||||
/**
|
||||
* Create a new BufferSet for the given terminal.
|
||||
@@ -42,7 +41,7 @@ export class BufferSet extends Disposable implements IBufferSet {
|
||||
// See http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-The-Alternate-Screen-Buffer
|
||||
this._alt = new Buffer(false, this._optionsService, this._bufferService);
|
||||
this._activeBuffer = this._normal;
|
||||
this._onBufferActivate.fire({
|
||||
this.onBufferActivate.fire({
|
||||
activeBuffer: this._normal,
|
||||
inactiveBuffer: this._alt
|
||||
});
|
||||
@@ -86,7 +85,7 @@ export class BufferSet extends Disposable implements IBufferSet {
|
||||
this._alt.clearAllMarkers();
|
||||
this._alt.clear();
|
||||
this._activeBuffer = this._normal;
|
||||
this._onBufferActivate.fire({
|
||||
this.onBufferActivate.fire({
|
||||
activeBuffer: this._normal,
|
||||
inactiveBuffer: this._alt
|
||||
});
|
||||
@@ -105,7 +104,7 @@ export class BufferSet extends Disposable implements IBufferSet {
|
||||
this._alt.x = this._normal.x;
|
||||
this._alt.y = this._normal.y;
|
||||
this._activeBuffer = this._alt;
|
||||
this._onBufferActivate.fire({
|
||||
this.onBufferActivate.fire({
|
||||
activeBuffer: this._alt,
|
||||
inactiveBuffer: this._normal
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { EventEmitter, IEvent } from 'common/EventEmitter';
|
||||
import { initEvent } from 'common/EventEmitter';
|
||||
import { Disposable } from 'common/Lifecycle';
|
||||
import { IMarker } from 'common/Types';
|
||||
|
||||
@@ -15,8 +15,7 @@ export class Marker extends Disposable implements IMarker {
|
||||
|
||||
public get id(): number { return this._id; }
|
||||
|
||||
private readonly _onDispose = new EventEmitter<void>();
|
||||
public readonly onDispose = this._onDispose.event;
|
||||
public readonly onDispose = initEvent<void>();
|
||||
|
||||
constructor(
|
||||
public line: number
|
||||
@@ -31,7 +30,7 @@ export class Marker extends Disposable implements IMarker {
|
||||
this.isDisposed = true;
|
||||
this.line = -1;
|
||||
// Emit before super.dispose such that dispose listeners get a change to react
|
||||
this._onDispose.fire();
|
||||
this.onDispose.fire();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { EventEmitter, IEvent } from 'common/EventEmitter';
|
||||
import { initEvent, EventEmitter, IEvent } from 'common/EventEmitter';
|
||||
|
||||
declare const setTimeout: (handler: () => void, timeout?: number) => void;
|
||||
|
||||
@@ -42,8 +42,7 @@ export class WriteBuffer {
|
||||
private _syncCalls = 0;
|
||||
private _didUserInput = false;
|
||||
|
||||
private readonly _onWriteParsed = new EventEmitter<void>();
|
||||
public readonly onWriteParsed = this._onWriteParsed.event;
|
||||
public readonly onWriteParsed = initEvent<void>();
|
||||
|
||||
constructor(private _action: (data: string | Uint8Array, promiseResult?: boolean) => void | Promise<boolean>) { }
|
||||
|
||||
@@ -237,6 +236,6 @@ export class WriteBuffer {
|
||||
this._pendingData = 0;
|
||||
this._bufferOffset = 0;
|
||||
}
|
||||
this._onWriteParsed.fire();
|
||||
this.onWriteParsed.fire();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,20 +5,19 @@
|
||||
|
||||
import { IBuffer as IBufferApi, IBufferNamespace as IBufferNamespaceApi } from 'xterm';
|
||||
import { BufferApiView } from 'common/public/BufferApiView';
|
||||
import { IEvent, EventEmitter } from 'common/EventEmitter';
|
||||
import { IEvent, EventEmitter, initEvent } from 'common/EventEmitter';
|
||||
import { ICoreTerminal } from 'common/Types';
|
||||
|
||||
export class BufferNamespaceApi implements IBufferNamespaceApi {
|
||||
private _normal: BufferApiView;
|
||||
private _alternate: BufferApiView;
|
||||
|
||||
private readonly _onBufferChange = new EventEmitter<IBufferApi>();
|
||||
public readonly onBufferChange = this._onBufferChange.event;
|
||||
public readonly onBufferChange = initEvent<IBufferApi>();
|
||||
|
||||
constructor(private _core: ICoreTerminal) {
|
||||
this._normal = new BufferApiView(this._core.buffers.normal, 'normal');
|
||||
this._alternate = new BufferApiView(this._core.buffers.alt, 'alternate');
|
||||
this._core.buffers.onBufferActivate(() => this._onBufferChange.fire(this.active));
|
||||
this._core.buffers.onBufferActivate(() => this.onBufferChange.fire(this.active));
|
||||
}
|
||||
public get active(): IBufferApi {
|
||||
if (this._core.buffers.active === this._core.buffers.normal) { return this.normal; }
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import { IBufferService, IOptionsService } from 'common/services/Services';
|
||||
import { BufferSet } from 'common/buffer/BufferSet';
|
||||
import { IBufferSet, IBuffer } from 'common/buffer/Types';
|
||||
import { EventEmitter, IEventEmitter, IEvent } from 'common/EventEmitter';
|
||||
import { EventEmitter, IEventEmitter, IEvent, initEvent } from 'common/EventEmitter';
|
||||
import { Disposable } from 'common/Lifecycle';
|
||||
import { IAttributeData, IBufferLine, ScrollSource } from 'common/Types';
|
||||
|
||||
@@ -22,10 +22,8 @@ export class BufferService extends Disposable implements IBufferService {
|
||||
/** Whether the user is scrolling (locks the scroll position) */
|
||||
public isUserScrolling: boolean = false;
|
||||
|
||||
private readonly _onResize = new EventEmitter<{ cols: number, rows: number }>();
|
||||
public readonly onResize = this._onResize.event;
|
||||
private readonly _onScroll = new EventEmitter<number>();
|
||||
public readonly onScroll = this._onScroll.event;
|
||||
public readonly onResize = initEvent<{ cols: number, rows: number }>();
|
||||
public readonly onScroll = initEvent<number>();
|
||||
|
||||
public get buffer(): IBuffer { return this.buffers.active; }
|
||||
|
||||
@@ -49,7 +47,7 @@ export class BufferService extends Disposable implements IBufferService {
|
||||
this.rows = rows;
|
||||
this.buffers.resize(cols, rows);
|
||||
this.buffers.setupTabStops(this.cols);
|
||||
this._onResize.fire({ cols, rows });
|
||||
this.onResize.fire({ cols, rows });
|
||||
}
|
||||
|
||||
public reset(): void {
|
||||
@@ -118,7 +116,7 @@ export class BufferService extends Disposable implements IBufferService {
|
||||
buffer.ydisp = buffer.ybase;
|
||||
}
|
||||
|
||||
this._onScroll.fire(buffer.ydisp);
|
||||
this.onScroll.fire(buffer.ydisp);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,7 +146,7 @@ export class BufferService extends Disposable implements IBufferService {
|
||||
}
|
||||
|
||||
if (!suppressScrollEvent) {
|
||||
this._onScroll.fire(buffer.ydisp);
|
||||
this.onScroll.fire(buffer.ydisp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* @license MIT
|
||||
*/
|
||||
import { IBufferService, ICoreService, ICoreMouseService } from 'common/services/Services';
|
||||
import { EventEmitter, IEvent } from 'common/EventEmitter';
|
||||
import { EventEmitter, IEvent, initEvent } from 'common/EventEmitter';
|
||||
import { ICoreMouseProtocol, ICoreMouseEvent, CoreMouseEncoding, CoreMouseEventType, CoreMouseButton, CoreMouseAction } from 'common/Types';
|
||||
|
||||
/**
|
||||
@@ -172,8 +172,7 @@ export class CoreMouseService implements ICoreMouseService {
|
||||
private _activeEncoding: string = '';
|
||||
private _lastEvent: ICoreMouseEvent | null = null;
|
||||
|
||||
private readonly _onProtocolChange = new EventEmitter<CoreMouseEventType>();
|
||||
public readonly onProtocolChange = this._onProtocolChange.event;
|
||||
public readonly onProtocolChange = initEvent<CoreMouseEventType>();
|
||||
|
||||
constructor(
|
||||
@IBufferService private readonly _bufferService: IBufferService,
|
||||
@@ -207,7 +206,7 @@ export class CoreMouseService implements ICoreMouseService {
|
||||
throw new Error(`unknown protocol "${name}"`);
|
||||
}
|
||||
this._activeProtocol = name;
|
||||
this._onProtocolChange.fire(this._protocols[name].events);
|
||||
this.onProtocolChange.fire(this._protocols[name].events);
|
||||
}
|
||||
|
||||
public get activeEncoding(): string {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import { ICoreService, ILogService, IOptionsService, IBufferService } from 'common/services/Services';
|
||||
import { EventEmitter, IEvent } from 'common/EventEmitter';
|
||||
import { EventEmitter, IEvent, initEvent } from 'common/EventEmitter';
|
||||
import { IDecPrivateModes, IModes } from 'common/Types';
|
||||
import { clone } from 'common/Clone';
|
||||
import { Disposable } from 'common/Lifecycle';
|
||||
@@ -34,12 +34,9 @@ export class CoreService extends Disposable implements ICoreService {
|
||||
// Circular dependency, this must be unset or memory will leak after Terminal.dispose
|
||||
private _scrollToBottom: (() => void) | undefined;
|
||||
|
||||
private readonly _onData = this.register(new EventEmitter<string>());
|
||||
public readonly onData = this._onData.event;
|
||||
private readonly _onUserInput = this.register(new EventEmitter<void>());
|
||||
public readonly onUserInput = this._onUserInput.event;
|
||||
private readonly _onBinary = this.register(new EventEmitter<string>());
|
||||
public readonly onBinary = this._onBinary.event;
|
||||
public readonly onData = this.register(initEvent<string>());
|
||||
public readonly onUserInput = this.register(initEvent<void>());
|
||||
public readonly onBinary = this.register(initEvent<string>());
|
||||
|
||||
constructor(
|
||||
// TODO: Move this into a service
|
||||
@@ -74,12 +71,12 @@ export class CoreService extends Disposable implements ICoreService {
|
||||
|
||||
// Fire onUserInput so listeners can react as well (eg. clear selection)
|
||||
if (wasUserInput) {
|
||||
this._onUserInput.fire();
|
||||
this.onUserInput.fire();
|
||||
}
|
||||
|
||||
// Fire onData API
|
||||
this._logService.debug(`sending data "${data}"`, () => data.split('').map(e => e.charCodeAt(0)));
|
||||
this._onData.fire(data);
|
||||
this.onData.fire(data);
|
||||
}
|
||||
|
||||
public triggerBinaryEvent(data: string): void {
|
||||
@@ -87,6 +84,6 @@ export class CoreService extends Disposable implements ICoreService {
|
||||
return;
|
||||
}
|
||||
this._logService.debug(`sending binary "${data}"`, () => data.split('').map(e => e.charCodeAt(0)));
|
||||
this._onBinary.fire(data);
|
||||
this.onBinary.fire(data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import { css } from 'common/Color';
|
||||
import { EventEmitter } from 'common/EventEmitter';
|
||||
import { EventEmitter, initEvent } from 'common/EventEmitter';
|
||||
import { Disposable } from 'common/Lifecycle';
|
||||
import { IDecorationService, IInternalDecoration } from 'common/services/Services';
|
||||
import { SortedList } from 'common/SortedList';
|
||||
@@ -25,10 +25,8 @@ export class DecorationService extends Disposable implements IDecorationService
|
||||
*/
|
||||
private readonly _decorations: SortedList<IInternalDecoration> = new SortedList(e => e?.marker.line);
|
||||
|
||||
private readonly _onDecorationRegistered = this.register(new EventEmitter<IInternalDecoration>());
|
||||
public readonly onDecorationRegistered = this._onDecorationRegistered.event;
|
||||
private readonly _onDecorationRemoved = this.register(new EventEmitter<IInternalDecoration>());
|
||||
public readonly onDecorationRemoved = this._onDecorationRemoved.event;
|
||||
public readonly onDecorationRegistered = this.register(initEvent<IInternalDecoration>());
|
||||
public readonly onDecorationRemoved = this.register(initEvent<IInternalDecoration>());
|
||||
|
||||
public get decorations(): IterableIterator<IInternalDecoration> { return this._decorations.values(); }
|
||||
|
||||
@@ -42,13 +40,13 @@ export class DecorationService extends Disposable implements IDecorationService
|
||||
decoration.onDispose(() => {
|
||||
if (decoration) {
|
||||
if (this._decorations.delete(decoration)) {
|
||||
this._onDecorationRemoved.fire(decoration);
|
||||
this.onDecorationRemoved.fire(decoration);
|
||||
}
|
||||
markerDispose.dispose();
|
||||
}
|
||||
});
|
||||
this._decorations.insert(decoration);
|
||||
this._onDecorationRegistered.fire(decoration);
|
||||
this.onDecorationRegistered.fire(decoration);
|
||||
}
|
||||
return decoration;
|
||||
}
|
||||
@@ -84,7 +82,7 @@ export class DecorationService extends Disposable implements IDecorationService
|
||||
|
||||
public dispose(): void {
|
||||
for (const d of this._decorations.values()) {
|
||||
this._onDecorationRemoved.fire(d);
|
||||
this.onDecorationRemoved.fire(d);
|
||||
}
|
||||
this.reset();
|
||||
}
|
||||
@@ -95,10 +93,8 @@ class Decoration extends Disposable implements IInternalDecoration {
|
||||
public element: HTMLElement | undefined;
|
||||
public isDisposed: boolean = false;
|
||||
|
||||
public readonly onRenderEmitter = this.register(new EventEmitter<HTMLElement>());
|
||||
public readonly onRender = this.onRenderEmitter.event;
|
||||
private readonly _onDispose = this.register(new EventEmitter<void>());
|
||||
public readonly onDispose = this._onDispose.event;
|
||||
public readonly onRender = this.register(initEvent<HTMLElement>());
|
||||
public readonly onDispose = this.register(initEvent<void>());
|
||||
|
||||
private _cachedBg: IColor | undefined | null = null;
|
||||
public get backgroundColorRGB(): IColor | undefined {
|
||||
@@ -139,7 +135,7 @@ class Decoration extends Disposable implements IInternalDecoration {
|
||||
return;
|
||||
}
|
||||
this._isDisposed = true;
|
||||
this._onDispose.fire();
|
||||
this.onDispose.fire();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
*/
|
||||
|
||||
import { IOptionsService, ITerminalOptions, FontWeight } from 'common/services/Services';
|
||||
import { EventEmitter, IEvent } from 'common/EventEmitter';
|
||||
import { isMac } from 'common/Platform';
|
||||
import { CursorStyle } from 'common/Types';
|
||||
import { initEvent } from 'common/EventEmitter';
|
||||
|
||||
export const DEFAULT_OPTIONS: Readonly<Required<ITerminalOptions>> = {
|
||||
cols: 80,
|
||||
@@ -57,8 +57,7 @@ export class OptionsService implements IOptionsService {
|
||||
public readonly rawOptions: Required<ITerminalOptions>;
|
||||
public options: Required<ITerminalOptions>;
|
||||
|
||||
private readonly _onOptionChange = new EventEmitter<string>();
|
||||
public readonly onOptionChange = this._onOptionChange.event;
|
||||
public readonly onOptionChange = initEvent<string>();
|
||||
|
||||
constructor(options: Partial<ITerminalOptions>) {
|
||||
// set the default value of each option
|
||||
@@ -97,7 +96,7 @@ export class OptionsService implements IOptionsService {
|
||||
// Don't fire an option change event if they didn't change
|
||||
if (this.rawOptions[propName] !== value) {
|
||||
this.rawOptions[propName] = value;
|
||||
this._onOptionChange.fire(propName);
|
||||
this.onOptionChange.fire(propName);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { IEvent, IEventEmitter } from 'common/EventEmitter';
|
||||
import { IEvent, IEventEmitter, IEventWithEmitter } from 'common/EventEmitter';
|
||||
import { IBuffer, IBufferSet } from 'common/buffer/Types';
|
||||
import { IDecPrivateModes, ICoreMouseEvent, CoreMouseEncoding, ICoreMouseProtocol, CoreMouseEventType, ICharset, IWindowOptions, IModes, IAttributeData, ScrollSource, IDisposable, IColor, CursorStyle, IOscLinkData } from 'common/Types';
|
||||
import { createDecorator } from 'common/services/ServiceRegistry';
|
||||
@@ -318,5 +318,5 @@ export interface IInternalDecoration extends IDecoration {
|
||||
readonly options: IDecorationOptions;
|
||||
readonly backgroundColorRGB: IColor | undefined;
|
||||
readonly foregroundColorRGB: IColor | undefined;
|
||||
readonly onRenderEmitter: IEventEmitter<HTMLElement>;
|
||||
readonly onRender: IEventWithEmitter<HTMLElement>;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* @license MIT
|
||||
*/
|
||||
import { IUnicodeService, IUnicodeVersionProvider } from 'common/services/Services';
|
||||
import { EventEmitter, IEvent } from 'common/EventEmitter';
|
||||
import { EventEmitter, IEvent, initEvent } from 'common/EventEmitter';
|
||||
import { UnicodeV6 } from 'common/input/UnicodeV6';
|
||||
|
||||
|
||||
@@ -14,8 +14,7 @@ export class UnicodeService implements IUnicodeService {
|
||||
private _active: string = '';
|
||||
private _activeProvider: IUnicodeVersionProvider;
|
||||
|
||||
private readonly _onChange = new EventEmitter<string>();
|
||||
public readonly onChange = this._onChange.event;
|
||||
public readonly onChange = initEvent<string>();
|
||||
|
||||
constructor() {
|
||||
const defaultProvider = new UnicodeV6();
|
||||
@@ -38,7 +37,7 @@ export class UnicodeService implements IUnicodeService {
|
||||
}
|
||||
this._active = version;
|
||||
this._activeProvider = this._providers[version];
|
||||
this._onChange.fire(version);
|
||||
this.onChange.fire(version);
|
||||
}
|
||||
|
||||
public register(provider: IUnicodeVersionProvider): void {
|
||||
|
||||
Reference in New Issue
Block a user