Make Terminal.selectionService private

This commit is contained in:
Daniel Imms
2019-06-29 18:50:54 -07:00
parent 3806f67fc0
commit 79d8f05528
3 changed files with 45 additions and 40 deletions
+13 -5
View File
@@ -9,7 +9,6 @@ import { C0, C1 } from 'common/data/EscapeSequences';
import { CHARSETS, DEFAULT_CHARSET } from 'common/data/Charsets';
import { wcwidth } from 'common/CharWidth';
import { EscapeSequenceParser } from 'common/parser/EscapeSequenceParser';
import { IDisposable } from 'xterm';
import { Disposable } from 'common/Lifecycle';
import { concat } from 'common/TypedArrayUtils';
import { StringToUtf32, stringFromCodePoint, utf32ToString, Utf8ToUtf32 } from 'common/input/TextDecoder';
@@ -20,6 +19,8 @@ import { NULL_CELL_CODE, NULL_CELL_WIDTH, Attributes, FgFlags, BgFlags } from 'c
import { CellData } from 'common/buffer/CellData';
import { AttributeData } from 'common/buffer/AttributeData';
import { ICoreService } from 'common/services/Services';
import { ISelectionService } from 'browser/services/Services';
import { IDisposable } from 'common/Types';
/**
* Map collect to glevel. Used in `selectCharset`.
@@ -112,6 +113,8 @@ export class InputHandler extends Disposable implements IInputHandler {
private _utf8Decoder: Utf8ToUtf32 = new Utf8ToUtf32();
private _workCell: CellData = new CellData();
private _selectionService: ISelectionService | undefined;
private _onCursorMove = new EventEmitter<void>();
public get onCursorMove(): IEvent<void> { return this._onCursorMove.event; }
private _onLineFeed = new EventEmitter<void>();
@@ -297,6 +300,11 @@ export class InputHandler extends Disposable implements IInputHandler {
this._terminal = null;
}
// TODO: When InputHandler moves into common, browser dependencies need to move out
public setBrowserServices(selectionService: ISelectionService): void {
this._selectionService = selectionService;
}
public parse(data: string): void {
// Ensure the terminal is not disposed
if (!this._terminal) {
@@ -1347,8 +1355,8 @@ export class InputHandler extends Disposable implements IInputHandler {
if (this._terminal.element) {
this._terminal.element.classList.add('enable-mouse-events');
}
if (this._terminal.selectionService) {
this._terminal.selectionService.disable();
if (this._selectionService) {
this._selectionService.disable();
}
this._terminal.log('Binding to mouse events.');
break;
@@ -1539,8 +1547,8 @@ export class InputHandler extends Disposable implements IInputHandler {
if (this._terminal.element) {
this._terminal.element.classList.remove('enable-mouse-events');
}
if (this._terminal.selectionService) {
this._terminal.selectionService.enable();
if (this._selectionService) {
this._selectionService.enable();
}
break;
case 1004: // send focusin/focusout events