Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/browser/Linkifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
matcher.hoverTooltipCallback(e, uri, { startRow: y1, startColumn: x1, endRow: y2, endColumn: x2 });
}
},
() => {
Expand Down
12 changes: 10 additions & 2 deletions src/browser/Types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,22 @@ export interface IViewport extends IDisposable {
onThemeChange(colors: IColorSet): void;
}

export interface ILinkLocation {
startColumn: number;
startRow: number;
endColumn: number;
endRow: number;
}

export type LinkMatcherHandler = (event: MouseEvent, uri: string) => void;
export type LinkMatcherHoverTooltipCallback = (event: MouseEvent, uri: string, position: ILinkLocation) => 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;
Expand Down Expand Up @@ -96,7 +104,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.
*/
Expand Down
27 changes: 26 additions & 1 deletion typings/xterm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => boolean | void;
tooltipCallback?: (event: MouseEvent, uri: string, location: ILinkLocation) => boolean | void;

/**
* A callback that fires when the mouse leaves a link. Note that this can
Expand Down Expand Up @@ -842,6 +842,31 @@ declare module 'xterm' {
endRow: number;
}

/**
* An object representing a link location within the terminal.
*/
interface ILinkLocation {
/**
* The start column of the link.
*/
startColumn: number;

/**
* The start row of the link.
*/
startRow: number;

/**
* The end column of the link.
*/
endColumn: number;

/**
* The end row of the link.
*/
endRow: number;
}
Comment thread
Tyriar marked this conversation as resolved.
Outdated

/**
* Represents a terminal buffer.
*/
Expand Down