From 08475eb4954c1fff67ea0ab79bb21cd798d7ddfd Mon Sep 17 00:00:00 2001 From: Jon Bockhorst Date: Thu, 17 Oct 2019 12:25:42 -0500 Subject: [PATCH] Update API to use IViewportRange and IViewportCellPosition --- src/browser/Linkifier.ts | 2 +- src/browser/Types.d.ts | 15 +++++++++------ typings/xterm.d.ts | 33 +++++++++++++++++++-------------- 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/src/browser/Linkifier.ts b/src/browser/Linkifier.ts index d17de1ca..0b51d43f 100644 --- a/src/browser/Linkifier.ts +++ b/src/browser/Linkifier.ts @@ -306,7 +306,7 @@ export class Linkifier implements ILinkifier { e => { this._onLinkTooltip.fire(this._createLinkHoverEvent(x1, y1, x2, y2, fg)); if (matcher.hoverTooltipCallback) { - matcher.hoverTooltipCallback(e, uri, { startRow: y1, startColumn: x1, endRow: y2, endColumn: x2 }); + matcher.hoverTooltipCallback(e, uri, { start: { row: y1, col: x1 }, end: { row: y2, col: x2 } }); } }, () => { diff --git a/src/browser/Types.d.ts b/src/browser/Types.d.ts index bd3d8722..2b9a4a9b 100644 --- a/src/browser/Types.d.ts +++ b/src/browser/Types.d.ts @@ -43,15 +43,18 @@ export interface IViewport extends IDisposable { onThemeChange(colors: IColorSet): void; } -export interface ILinkLocation { - startColumn: number; - startRow: number; - endColumn: number; - endRow: number; +export interface IViewportRange { + start: IViewportCellPosition; + end: IViewportCellPosition; +} + +export interface IViewportCellPosition { + col: number; + row: number; } export type LinkMatcherHandler = (event: MouseEvent, uri: string) => void; -export type LinkMatcherHoverTooltipCallback = (event: MouseEvent, uri: string, position: ILinkLocation) => void; +export type LinkMatcherHoverTooltipCallback = (event: MouseEvent, uri: string, position: IViewportRange) => void; export type LinkMatcherValidationCallback = (uri: string, callback: (isValid: boolean) => void) => void; export interface ILinkMatcher { diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index 2ea8706a..32dce910 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -269,7 +269,7 @@ declare module 'xterm' { /** * A callback that fires when the mouse hovers over a link for a moment. */ - tooltipCallback?: (event: MouseEvent, uri: string, location: ILinkLocation) => boolean | void; + tooltipCallback?: (event: MouseEvent, uri: string, location: IViewportRange) => boolean | void; /** * A callback that fires when the mouse leaves a link. Note that this can @@ -843,28 +843,33 @@ declare module 'xterm' { } /** - * An object representing a link location within the terminal. + * An object representing a range within the viewport of the terminal. */ - interface ILinkLocation { + interface IViewportRange { /** - * The start column of the link. + * The start cell of the range. */ - startColumn: number; + start: IViewportCellPosition; /** - * The start row of the link. + * The end cell of the range. */ - startRow: number; + end: IViewportCellPosition; + } + + /** + * An object representing a cell within the viewport of the terminal. + */ + interface IViewportCellPosition { + /** + * The column of the cell. + */ + col: number; /** - * The end column of the link. + * The row of the cell. */ - endColumn: number; - - /** - * The end row of the link. - */ - endRow: number; + row: number; } /**