diff --git a/src/vs/workbench/parts/terminal/common/terminal.ts b/src/vs/workbench/parts/terminal/common/terminal.ts index a1b2069f566d..54cdb4900ed0 100644 --- a/src/vs/workbench/parts/terminal/common/terminal.ts +++ b/src/vs/workbench/parts/terminal/common/terminal.ts @@ -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. */ diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts index 177bd0777635..d462778e7e19 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts @@ -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; }