Added support for a basic link parser

This commit is contained in:
Jon Bockhorst
2019-11-01 00:54:31 -05:00
parent d9f58c0dbb
commit 0c5962c538
15 changed files with 1283 additions and 105 deletions
+85
View File
@@ -539,6 +539,13 @@ declare module 'xterm' {
*/
deregisterLinkMatcher(matcherId: number): void;
/**
* (EXPERIMENTAL) Registers a link provider, allowing a custom parser to
* be used to match and handle links.
* @param linkProvider
*/
registerLinkProvider(linkProvider: ILinkProvider): IDisposable;
/**
* (EXPERIMENTAL) Registers a character joiner, allowing custom sequences of
* characters to be rendered as a single unit. This is useful in particular
@@ -887,6 +894,84 @@ declare module 'xterm' {
row: number;
}
/**
* A custom link provider
*/
interface ILinkProvider {
/**
* Provides a link a buffer position
* @param position
* @param callback
*/
provideLink(position: IBufferCellPosition, callback: (link: ILink | undefined) => void): void;
}
/**
* A link
*/
interface ILink {
/**
* The buffer range of the link
*/
range: IBufferRange;
/**
* The url of the link
*/
url: string;
/**
* The show tooltip callback
* @param event
* @param link
*/
showTooltip(event: MouseEvent, link: string): void;
/**
* The hide tooltip callback
* @param event
* @param link
*/
hideTooltip(event: MouseEvent, link: string): void;
/**
* Handles when the link is opened
* @param event
* @param link
*/
handle(event: MouseEvent, link: string): void;
}
/**
* A range in the buffer
*/
interface IBufferRange {
/**
* The start position of the range
*/
start: IBufferCellPosition;
/**
* The end position of the range
*/
end: IBufferCellPosition;
}
/**
* A position in the buffer
*/
interface IBufferCellPosition {
/**
* The x of the buffer position
*/
x: number;
/**
* The y of the buffer position
*/
y: number;
}
/**
* Represents a terminal buffer.
*/