Revert "Merge pull request #4166 from Tyriar/event_with_emitter"

This reverts commit d22f7c9edd, reversing
changes made to 1f8e6f0952.
This commit is contained in:
Daniel Imms
2022-10-06 09:48:54 -07:00
parent 5f1651ffbc
commit 4d97729010
34 changed files with 329 additions and 283 deletions
+33 -22
View File
@@ -37,7 +37,7 @@ import { ITheme, IMarker, IDisposable, ILinkProvider, IDecorationOptions, IDecor
import { DomRenderer } from 'browser/renderer/dom/DomRenderer';
import { KeyboardResultType, CoreMouseEventType, CoreMouseButton, CoreMouseAction, ITerminalOptions, ScrollSource, IColorEvent, ColorIndex, ColorRequestType } from 'common/Types';
import { evaluateKeyboardEvent } from 'common/input/Keyboard';
import { EventEmitter, IEvent, forwardEvent, initEvent } from 'common/EventEmitter';
import { EventEmitter, IEvent, forwardEvent } from 'common/EventEmitter';
import { DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine';
import { ColorManager } from 'browser/ColorManager';
import { RenderService } from 'browser/services/RenderService';
@@ -122,16 +122,27 @@ export class Terminal extends CoreTerminal implements ITerminal {
private _colorManager: ColorManager | undefined;
private _theme: ITheme | undefined;
public readonly onCursorMove = initEvent<void>();
public readonly onKey = initEvent<{ key: string, domEvent: KeyboardEvent }>();
public readonly onRender = initEvent<{ start: number, end: number }>();
public readonly onSelectionChange = initEvent<void>();
public readonly onTitleChange = initEvent<string>();
public readonly onBell = initEvent<void>();
public readonly onFocus = initEvent<void>();
public readonly onBlur = initEvent<void>();
public readonly onA11yChar = initEvent<string>();
public readonly onA11yTab = initEvent<number>();
private readonly _onCursorMove = new EventEmitter<void>();
public readonly onCursorMove = this._onCursorMove.event;
private readonly _onKey = new EventEmitter<{ key: string, domEvent: KeyboardEvent }>();
public readonly onKey = this._onKey.event;
private readonly _onRender = new EventEmitter<{ start: number, end: number }>();
public readonly onRender = this._onRender.event;
private readonly _onSelectionChange = new EventEmitter<void>();
public readonly onSelectionChange = this._onSelectionChange.event;
private readonly _onTitleChange = new EventEmitter<string>();
public readonly onTitleChange = this._onTitleChange.event;
private readonly _onBell = new EventEmitter<void>();
public readonly onBell = this._onBell.event;
private readonly _onFocus = new EventEmitter<void>();
public readonly onFocus = this._onFocus.event;
private readonly _onBlur = new EventEmitter<void>();
public readonly onBlur = this._onBlur.event;
private readonly _onA11yCharEmitter = new EventEmitter<string>();
public readonly onA11yChar = this._onA11yCharEmitter.event;
private readonly _onA11yTabEmitter = new EventEmitter<number>();
public readonly onA11yTab = this._onA11yTabEmitter.event;
/**
* Creates a new `Terminal` object.
@@ -158,16 +169,16 @@ export class Terminal extends CoreTerminal implements ITerminal {
this._instantiationService.setService(IDecorationService, this._decorationService);
// Setup InputHandler listeners
this.register(this._inputHandler.onRequestBell(() => this.onBell.fire()));
this.register(this._inputHandler.onRequestBell(() => this._onBell.fire()));
this.register(this._inputHandler.onRequestRefreshRows((start, end) => this.refresh(start, end)));
this.register(this._inputHandler.onRequestSendFocus(() => this._reportFocus()));
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(forwardEvent(this._inputHandler.onCursorMove, this.onCursorMove));
this.register(forwardEvent(this._inputHandler.onTitleChange, this.onTitleChange));
this.register(forwardEvent(this._inputHandler.onA11yChar, this.onA11yChar));
this.register(forwardEvent(this._inputHandler.onA11yTab, this.onA11yTab));
this.register(forwardEvent(this._inputHandler.onCursorMove, this._onCursorMove));
this.register(forwardEvent(this._inputHandler.onTitleChange, this._onTitleChange));
this.register(forwardEvent(this._inputHandler.onA11yChar, this._onA11yCharEmitter));
this.register(forwardEvent(this._inputHandler.onA11yTab, this._onA11yTabEmitter));
// Setup listeners
this.register(this._bufferService.onResize(e => this._afterResize(e.cols, e.rows)));
@@ -315,7 +326,7 @@ export class Terminal extends CoreTerminal implements ITerminal {
this.updateCursorStyle(ev);
this.element!.classList.add('focus');
this._showCursor();
this.onFocus.fire();
this._onFocus.fire();
}
/**
@@ -338,7 +349,7 @@ export class Terminal extends CoreTerminal implements ITerminal {
this.coreService.triggerDataEvent(C0.ESC + '[O');
}
this.element!.classList.remove('focus');
this.onBlur.fire();
this._onBlur.fire();
}
private _syncTextArea(): void {
@@ -501,7 +512,7 @@ export class Terminal extends CoreTerminal implements ITerminal {
const renderer = this._createRenderer();
this._renderService = this.register(this._instantiationService.createInstance(RenderService, renderer, this.rows, this.screenElement));
this._instantiationService.setService(IRenderService, this._renderService);
this.register(this._renderService.onRenderedViewportChange(e => this.onRender.fire(e)));
this.register(this._renderService.onRenderedViewportChange(e => this._onRender.fire(e)));
this.onResize(e => this._renderService!.resize(e.cols, e.rows));
this._compositionView = document.createElement('div');
@@ -541,7 +552,7 @@ export class Terminal extends CoreTerminal implements ITerminal {
));
this._instantiationService.setService(ISelectionService, this._selectionService);
this.register(this._selectionService.onRequestScrollLines(e => this.scrollLines(e.amount, e.suppressScrollEvent)));
this.register(this._selectionService.onSelectionChange(() => this.onSelectionChange.fire()));
this.register(this._selectionService.onSelectionChange(() => this._onSelectionChange.fire()));
this.register(this._selectionService.onRequestRedraw(e => this._renderService!.onSelectionChanged(e.start, e.end, e.columnSelectMode)));
this.register(this._selectionService.onLinuxMouseSelection(text => {
// If there's a new selection, put it into the textarea, focus and select it
@@ -1090,7 +1101,7 @@ export class Terminal extends CoreTerminal implements ITerminal {
this.textarea!.value = '';
}
this.onKey.fire({ key: result.key, domEvent: event });
this._onKey.fire({ key: result.key, domEvent: event });
this._showCursor();
this.coreService.triggerDataEvent(result.key, true);
@@ -1173,7 +1184,7 @@ export class Terminal extends CoreTerminal implements ITerminal {
key = String.fromCharCode(key);
this.onKey.fire({ key, domEvent: ev });
this._onKey.fire({ key, domEvent: ev });
this._showCursor();
this.coreService.triggerDataEvent(key, true);