This commit is contained in:
Daniel Imms
2017-05-21 11:57:24 -07:00
parent 4d32826891
commit c323e0ad4a
+18
View File
@@ -4,6 +4,14 @@
import { CharMeasure } from './CharMeasure';
/**
* Gets coordinates within the terminal for a particular mouse event. The result
* is returned as an array in the form [x, y] instead of an object as it's a
* little faster and this function is used in some low level code.
* @param event The mouse event.
* @param rowContainer The terminal's row container.
* @param charMeasure The char measure object used to determine character sizes.
*/
export function getCoords(event: MouseEvent, rowContainer: HTMLElement, charMeasure: CharMeasure): [number, number] {
// ignore browsers without pageX for now
if (event.pageX == null) {
@@ -29,6 +37,16 @@ export function getCoords(event: MouseEvent, rowContainer: HTMLElement, charMeas
return [x, y];
}
/**
* Gets coordinates within the terminal for a particular mouse event, wrapping
* them to the bounds of the terminal and adding 32 to both the x and y values
* as expected by xterm.
* @param event The mouse event.
* @param rowContainer The terminal's row container.
* @param charMeasure The char measure object used to determine character sizes.
* @param colCount The number of columns in the terminal.
* @param rowCount The number of rows in the terminal.
*/
export function getRawByteCoords(event: MouseEvent, rowContainer: HTMLElement, charMeasure: CharMeasure, colCount: number, rowCount: number): { x: number, y: number } {
const coords = getCoords(event, rowContainer, charMeasure);
let x = coords[0];