Expose terminal link matcher on ITerminalInstance

Part of #18454
This commit is contained in:
Daniel Imms
2017-02-14 19:29:50 -08:00
parent ff7254c6d6
commit f04798da0e
2 changed files with 26 additions and 0 deletions
@@ -179,6 +179,24 @@ export interface ITerminalInstance {
*/
dispose(): void;
/**
* Registers a link matcher, allowing custom link patterns to be matched and handled.
* @param regex The regular expression the search for, specifically this searches the
* textContent of the rows. You will want to use \s to match a space ' ' character for example.
* @param handler The callback when the link is called.
* @param matchIndex The index of the link from the regex.match(html) call. This defaults to 0
* (for regular expressions without capture groups).
* @return The ID of the new matcher, this can be used to deregister.
*/
registerLinkMatcher(regex: RegExp, handler: (url: string) => void, matchIndex?: number): number;
/**
* Deregisters a link matcher if it has been registered.
* @param matcherId The link matcher's ID (returned after register)
* @return Whether a link matcher was found and deregistered.
*/
deregisterLinkMatcher(matcherId: number): void;
/**
* Check if anything is selected in terminal.
*/
@@ -225,6 +225,14 @@ export class TerminalInstance implements ITerminalInstance {
this.updateConfig();
}
public registerLinkMatcher(regex: RegExp, handler: (url: string) => void, matchIndex?: number): number {
return this._xterm.registerLinkMatcher(regex, handler, matchIndex);
}
public deregisterLinkMatcher(linkMatcherId: number): void {
this._xterm.deregisterLinkMatcher(linkMatcherId);
}
public hasSelection(): boolean {
return !document.getSelection().isCollapsed;
}