mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Merge pull request #2470 from jmbockhorst/linkPosition
Support link position in hover tooltip callback
This commit is contained in:
@@ -306,7 +306,9 @@ export class Linkifier implements ILinkifier {
|
||||
e => {
|
||||
this._onLinkTooltip.fire(this._createLinkHoverEvent(x1, y1, x2, y2, fg));
|
||||
if (matcher.hoverTooltipCallback) {
|
||||
matcher.hoverTooltipCallback(e, uri);
|
||||
// Note that IViewportRange use 1-based coordinates to align with escape sequences such
|
||||
// as CUP which use 1,1 as the default for row/col
|
||||
matcher.hoverTooltipCallback(e, uri, { start: { row: y1 + 1, col: x1 + 1 }, end: { row: y2 + 1, col: x2 } });
|
||||
}
|
||||
},
|
||||
() => {
|
||||
|
||||
Vendored
+13
-2
@@ -43,14 +43,25 @@ export interface IViewport extends IDisposable {
|
||||
onThemeChange(colors: IColorSet): void;
|
||||
}
|
||||
|
||||
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: IViewportRange) => void;
|
||||
export type LinkMatcherValidationCallback = (uri: string, callback: (isValid: boolean) => void) => void;
|
||||
|
||||
export interface ILinkMatcher {
|
||||
id: number;
|
||||
regex: RegExp;
|
||||
handler: LinkMatcherHandler;
|
||||
hoverTooltipCallback?: LinkMatcherHandler;
|
||||
hoverTooltipCallback?: LinkMatcherHoverTooltipCallback;
|
||||
hoverLeaveCallback?: () => void;
|
||||
matchIndex?: number;
|
||||
validationCallback?: LinkMatcherValidationCallback;
|
||||
@@ -96,7 +107,7 @@ export interface ILinkMatcherOptions {
|
||||
/**
|
||||
* A callback that fires when the mouse hovers over a link.
|
||||
*/
|
||||
tooltipCallback?: LinkMatcherHandler;
|
||||
tooltipCallback?: LinkMatcherHoverTooltipCallback;
|
||||
/**
|
||||
* A callback that fires when the mouse leaves a link that was hovered.
|
||||
*/
|
||||
|
||||
Vendored
+31
-1
@@ -279,7 +279,7 @@ declare module 'xterm' {
|
||||
/**
|
||||
* A callback that fires when the mouse hovers over a link for a moment.
|
||||
*/
|
||||
tooltipCallback?: (event: MouseEvent, uri: string) => 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
|
||||
@@ -852,6 +852,36 @@ declare module 'xterm' {
|
||||
endRow: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* An object representing a range within the viewport of the terminal.
|
||||
*/
|
||||
interface IViewportRange {
|
||||
/**
|
||||
* The start cell of the range.
|
||||
*/
|
||||
start: IViewportCellPosition;
|
||||
|
||||
/**
|
||||
* The end cell of the range.
|
||||
*/
|
||||
end: IViewportCellPosition;
|
||||
}
|
||||
|
||||
/**
|
||||
* An object representing a cell position within the viewport of the terminal.
|
||||
*/
|
||||
interface IViewportCellPosition {
|
||||
/**
|
||||
* The column of the cell. Note that this is 1-based; the first column is column 1.
|
||||
*/
|
||||
col: number;
|
||||
|
||||
/**
|
||||
* The row of the cell. Note that this is 1-based; the first row is row 1.
|
||||
*/
|
||||
row: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a terminal buffer.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user