Skip to content

Commit

Permalink
Merge pull request #3719 from LuckyGeck/addregex
Browse files Browse the repository at this point in the history
Expose urlRegex in the public .d.ts file.
  • Loading branch information
Tyriar authored Mar 30, 2022
2 parents 89af5b1 + bd3bd7f commit 4319df0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
3 changes: 2 additions & 1 deletion addons/xterm-addon-web-links/src/WebLinkProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@

import { ILinkProvider, ILink, Terminal, IViewportRange } from 'xterm';

interface ILinkProviderOptions {
export interface ILinkProviderOptions {
hover?(event: MouseEvent, text: string, location: IViewportRange): void;
leave?(event: MouseEvent, text: string): void;
urlRegex?: RegExp;
}

export class WebLinkProvider implements ILinkProvider {
Expand Down
10 changes: 2 additions & 8 deletions addons/xterm-addon-web-links/src/WebLinksAddon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* @license MIT
*/

import { Terminal, ILinkMatcherOptions, ITerminalAddon, IDisposable, IViewportRange } from 'xterm';
import { WebLinkProvider } from './WebLinkProvider';
import { Terminal, ILinkMatcherOptions, ITerminalAddon, IDisposable } from 'xterm';
import { ILinkProviderOptions, WebLinkProvider } from './WebLinkProvider';

const protocolClause = '(https?:\\/\\/)';
const domainCharacterSet = '[\\da-z\\.-]+';
Expand Down Expand Up @@ -40,12 +40,6 @@ function handleLink(event: MouseEvent, uri: string): void {
}
}

interface ILinkProviderOptions {
hover?(event: MouseEvent, text: string, location: IViewportRange): void;
leave?(event: MouseEvent, text: string): void;
urlRegex?: RegExp;
}

export class WebLinksAddon implements ITerminalAddon {
private _linkMatcherId: number | undefined;
private _terminal: Terminal | undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,10 @@ declare module 'xterm-addon-web-links' {
* happen even when tooltipCallback hasn't fired for the link yet.
*/
leave?(event: MouseEvent, text: string): void;

/**
* A callback to use instead of the default one.
*/
urlRegex?: RegExp;
}
}

0 comments on commit 4319df0

Please sign in to comment.