xterm
[VSoRC/.git] / node_modules / xterm / src / browser / services / MouseService.ts
1 /**
2  * Copyright (c) 2017 The xterm.js authors. All rights reserved.
3  * @license MIT
4  */
5
6 import { ICharSizeService, IRenderService, IMouseService } from './Services';
7 import { getCoords, getRawByteCoords } from 'browser/input/Mouse';
8
9 export class MouseService implements IMouseService {
10   serviceBrand: any;
11
12   constructor(
13     @IRenderService private readonly _renderService: IRenderService,
14     @ICharSizeService private readonly _charSizeService: ICharSizeService
15   ) {
16   }
17
18   public getCoords(event: {clientX: number, clientY: number}, element: HTMLElement, colCount: number, rowCount: number, isSelection?: boolean): [number, number] | undefined {
19     return getCoords(
20       event,
21       element,
22       colCount,
23       rowCount,
24       this._charSizeService.hasValidSize,
25       this._renderService.dimensions.actualCellWidth,
26       this._renderService.dimensions.actualCellHeight,
27       isSelection
28     );
29   }
30
31   public getRawByteCoords(event: MouseEvent, element: HTMLElement, colCount: number, rowCount: number): { x: number, y: number } | undefined {
32     const coords = this.getCoords(event, element, colCount, rowCount);
33     return getRawByteCoords(coords);
34   }
35 }