Rename SelectionManager to SelectionService

This commit is contained in:
Daniel Imms
2019-06-29 14:27:50 -07:00
parent 4d22d1d008
commit 7ee2219314
10 changed files with 560 additions and 560 deletions
+36 -36
View File
@@ -30,7 +30,7 @@ import { C0 } from 'common/data/EscapeSequences';
import { InputHandler } from './InputHandler';
import { Renderer } from './renderer/Renderer';
import { Linkifier } from './Linkifier';
import { SelectionManager } from './SelectionManager';
import { SelectionService } from './SelectionService';
import * as Browser from 'common/Platform';
import { addDisposableDomListener } from 'browser/Lifecycle';
import * as Strings from './browser/LocalizableStrings';
@@ -174,7 +174,7 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
private _inputHandler: InputHandler;
public soundManager: SoundManager;
public selectionManager: SelectionManager;
public selectionService: SelectionService;
public linkifier: ILinkifier;
public viewport: IViewport;
private _compositionHelper: ICompositionHelper;
@@ -301,14 +301,14 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
this._inputHandler.onLineFeed(() => this._onLineFeed.fire());
this.register(this._inputHandler);
this.selectionManager = this.selectionManager || null;
this.selectionService = this.selectionService || null;
this.linkifier = this.linkifier || new Linkifier(this);
this._mouseZoneManager = this._mouseZoneManager || null;
this.soundManager = this.soundManager || new SoundManager(this);
if (this.selectionManager) {
this.selectionManager.clearSelection();
this.selectionManager.initBuffersListeners();
if (this.selectionService) {
this.selectionService.clearSelection();
this.selectionService.initBuffersListeners();
}
if (this.options.windowsMode) {
@@ -479,7 +479,7 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
if (!this.hasSelection()) {
return;
}
copyHandler(event, this.selectionManager);
copyHandler(event, this.selectionService);
}));
const pasteHandlerWrapper = (event: ClipboardEvent) => pasteHandler(event, this.textarea, this.bracketedPasteMode, e => this._coreService.triggerDataEvent(e, true));
this.register(addDisposableDomListener(this.textarea, 'paste', pasteHandlerWrapper));
@@ -490,12 +490,12 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
// Firefox doesn't appear to fire the contextmenu event on right click
this.register(addDisposableDomListener(this.element, 'mousedown', (event: MouseEvent) => {
if (event.button === 2) {
rightClickHandler(event, this.textarea, this.screenElement, this.selectionManager, this.options.rightClickSelectsWord);
rightClickHandler(event, this.textarea, this.screenElement, this.selectionService, this.options.rightClickSelectsWord);
}
}));
} else {
this.register(addDisposableDomListener(this.element, 'contextmenu', (event: MouseEvent) => {
rightClickHandler(event, this.textarea, this.screenElement, this.selectionManager, this.options.rightClickSelectsWord);
rightClickHandler(event, this.textarea, this.screenElement, this.selectionService, this.options.rightClickSelectsWord);
}));
}
@@ -641,15 +641,15 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
this.register(this.onFocus(() => this._renderService.onFocus()));
this.register(this._renderService.onDimensionsChange(() => this.viewport.syncScrollArea()));
this.selectionManager = new SelectionManager(
this.selectionService = new SelectionService(
(amount: number, suppressEvent: boolean) => this.scrollLines(amount, suppressEvent),
this.element, this.screenElement, this._charSizeService, this._bufferService, this._coreService,
this._mouseService, this.optionsService
);
this.register(this.selectionManager.onSelectionChange(() => this._onSelectionChange.fire()));
this.register(addDisposableDomListener(this.element, 'mousedown', (e: MouseEvent) => this.selectionManager.onMouseDown(e)));
this.register(this.selectionManager.onRedrawRequest(e => this._renderService.onSelectionChanged(e.start, e.end, e.columnSelectMode)));
this.register(this.selectionManager.onLinuxMouseSelection(text => {
this.register(this.selectionService.onSelectionChange(() => this._onSelectionChange.fire()));
this.register(addDisposableDomListener(this.element, 'mousedown', (e: MouseEvent) => this.selectionService.onMouseDown(e)));
this.register(this.selectionService.onRedrawRequest(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
// in order to register it as a selection on the OS. This event is fired
// only on Linux to enable middle click to paste selection.
@@ -659,16 +659,16 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
}));
this.register(this.onScroll(() => {
this.viewport.syncScrollArea();
this.selectionManager.refresh();
this.selectionService.refresh();
}));
this.register(addDisposableDomListener(this._viewportElement, 'scroll', () => this.selectionManager.refresh()));
this.register(addDisposableDomListener(this._viewportElement, 'scroll', () => this.selectionService.refresh()));
// apply mouse event classes set by escape codes before terminal was attached
this.element.classList.toggle('enable-mouse-events', this.mouseEvents);
if (this.mouseEvents) {
this.selectionManager.disable();
this.selectionService.disable();
} else {
this.selectionManager.enable();
this.selectionService.enable();
}
if (this.options.screenReaderMode) {
@@ -946,7 +946,7 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
// Don't send the mouse button to the pty if mouse events are disabled or
// if the selection manager is having selection forced (ie. a modifier is
// held).
if (!this.mouseEvents || this.selectionManager.shouldForceSelection(ev)) {
if (!this.mouseEvents || this.selectionService.shouldForceSelection(ev)) {
return;
}
@@ -1077,7 +1077,7 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
* Change the cursor style for different selection modes
*/
public updateCursorStyle(ev: KeyboardEvent): void {
if (this.selectionManager && this.selectionManager.shouldColumnSelect(ev)) {
if (this.selectionService && this.selectionService.shouldColumnSelect(ev)) {
this.element.classList.add('column-select');
} else {
this.element.classList.remove('column-select');
@@ -1481,7 +1481,7 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
* Gets whether the terminal has an active selection.
*/
public hasSelection(): boolean {
return this.selectionManager ? this.selectionManager.hasSelection : false;
return this.selectionService ? this.selectionService.hasSelection : false;
}
/**
@@ -1491,7 +1491,7 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
* @param length The length of the selection.
*/
public select(column: number, row: number, length: number): void {
this.selectionManager.setSelection(column, row, length);
this.selectionService.setSelection(column, row, length);
}
/**
@@ -1499,19 +1499,19 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
* behavior outside of xterm.js.
*/
public getSelection(): string {
return this.selectionManager ? this.selectionManager.selectionText : '';
return this.selectionService ? this.selectionService.selectionText : '';
}
public getSelectionPosition(): ISelectionPosition | undefined {
if (!this.selectionManager.hasSelection) {
if (!this.selectionService.hasSelection) {
return undefined;
}
return {
startColumn: this.selectionManager.selectionStart[0],
startRow: this.selectionManager.selectionStart[1],
endColumn: this.selectionManager.selectionEnd[0],
endRow: this.selectionManager.selectionEnd[1]
startColumn: this.selectionService.selectionStart[0],
startRow: this.selectionService.selectionStart[1],
endColumn: this.selectionService.selectionEnd[0],
endRow: this.selectionService.selectionEnd[1]
};
}
@@ -1519,8 +1519,8 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
* Clears the current terminal selection.
*/
public clearSelection(): void {
if (this.selectionManager) {
this.selectionManager.clearSelection();
if (this.selectionService) {
this.selectionService.clearSelection();
}
}
@@ -1528,14 +1528,14 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
* Selects all text within the terminal.
*/
public selectAll(): void {
if (this.selectionManager) {
this.selectionManager.selectAll();
if (this.selectionService) {
this.selectionService.selectAll();
}
}
public selectLines(start: number, end: number): void {
if (this.selectionManager) {
this.selectionManager.selectLines(start, end);
if (this.selectionService) {
this.selectionService.selectLines(start, end);
}
}
@@ -1808,8 +1808,8 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp
// }
// // Clear the selection if the selection manager is available and has an active selection
// if (this.selectionManager && this.selectionManager.hasSelection) {
// this.selectionManager.clearSelection();
// if (this.selectionService && this.selectionService.hasSelection) {
// this.selectionService.clearSelection();
// }
// // Input is being sent to the terminal, the terminal should focus the prompt.