mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Adopt in SelectionManager
This commit is contained in:
@@ -4,13 +4,12 @@
|
||||
*/
|
||||
|
||||
import { assert } from 'chai';
|
||||
import { CharMeasure } from './CharMeasure';
|
||||
import { SelectionManager, SelectionMode } from './SelectionManager';
|
||||
import { SelectionModel } from './SelectionModel';
|
||||
import { BufferSet } from './BufferSet';
|
||||
import { ITerminal, IBuffer } from './Types';
|
||||
import { IBufferLine } from 'core/Types';
|
||||
import { MockTerminal } from './TestUtils.test';
|
||||
import { MockTerminal, MockCharSizeService } from './TestUtils.test';
|
||||
import { BufferLine, CellData } from 'core/buffer/BufferLine';
|
||||
|
||||
class TestMockTerminal extends MockTerminal {
|
||||
@@ -19,10 +18,9 @@ class TestMockTerminal extends MockTerminal {
|
||||
|
||||
class TestSelectionManager extends SelectionManager {
|
||||
constructor(
|
||||
terminal: ITerminal,
|
||||
charMeasure: CharMeasure
|
||||
terminal: ITerminal
|
||||
) {
|
||||
super(terminal, charMeasure);
|
||||
super(terminal, new MockCharSizeService(10, 10));
|
||||
}
|
||||
|
||||
public get model(): SelectionModel { return this._model; }
|
||||
@@ -52,7 +50,7 @@ describe('SelectionManager', () => {
|
||||
terminal.buffers = new BufferSet(terminal);
|
||||
terminal.buffer = terminal.buffers.active;
|
||||
buffer = terminal.buffer;
|
||||
selectionManager = new TestSelectionManager(terminal, null);
|
||||
selectionManager = new TestSelectionManager(terminal);
|
||||
});
|
||||
|
||||
function stringToRow(text: string): IBufferLine {
|
||||
|
||||
@@ -7,12 +7,12 @@ import { ITerminal, ISelectionManager, IBuffer, ISelectionRedrawRequestEvent } f
|
||||
import { IBufferLine } from 'core/Types';
|
||||
import { MouseHelper } from './MouseHelper';
|
||||
import * as Browser from 'common/Platform';
|
||||
import { CharMeasure } from './CharMeasure';
|
||||
import { SelectionModel } from './SelectionModel';
|
||||
import { AltClickHandler } from './handlers/AltClickHandler';
|
||||
import { CellData } from 'core/buffer/BufferLine';
|
||||
import { IDisposable } from 'xterm';
|
||||
import { EventEmitter2, IEvent } from 'common/EventEmitter2';
|
||||
import { ICharSizeService } from 'ui/services/Services';
|
||||
|
||||
/**
|
||||
* The number of pixels the mouse needs to be above or below the viewport in
|
||||
@@ -117,7 +117,7 @@ export class SelectionManager implements ISelectionManager {
|
||||
|
||||
constructor(
|
||||
private _terminal: ITerminal,
|
||||
private _charMeasure: CharMeasure
|
||||
private _charSizeService: ICharSizeService
|
||||
) {
|
||||
this._initListeners();
|
||||
this.enable();
|
||||
@@ -375,7 +375,7 @@ export class SelectionManager implements ISelectionManager {
|
||||
*/
|
||||
private _getMouseEventScrollAmount(event: MouseEvent): number {
|
||||
let offset = MouseHelper.getCoordsRelativeToElement(event, this._terminal.screenElement)[1];
|
||||
const terminalHeight = this._terminal.rows * Math.ceil(this._charMeasure.height * this._terminal.options.lineHeight);
|
||||
const terminalHeight = this._terminal.rows * Math.ceil(this._charSizeService.height * this._terminal.options.lineHeight);
|
||||
if (offset >= 0 && offset <= terminalHeight) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
+1
-1
@@ -646,7 +646,7 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
|
||||
this.register(this.charMeasure.onCharSizeChanged(() => this._renderCoordinator.onCharSizeChanged()));
|
||||
this.register(this._renderCoordinator.onDimensionsChange(() => this.viewport.syncScrollArea()));
|
||||
|
||||
this.selectionManager = new SelectionManager(this, this.charMeasure);
|
||||
this.selectionManager = new SelectionManager(this, this._charSizeService);
|
||||
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._renderCoordinator.onSelectionChanged(e.start, e.end, e.columnSelectMode)));
|
||||
|
||||
Reference in New Issue
Block a user