Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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 addons/xterm-addon-attach/typings/xterm-addon-attach.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @license MIT
*/

import { Terminal, ILinkMatcherOptions, ITerminalAddon } from 'xterm';
import { Terminal, ITerminalAddon } from 'xterm';

declare module 'xterm-addon-attach' {
export interface IAttachOptions {
Expand Down
24 changes: 5 additions & 19 deletions addons/xterm-addon-web-links/src/WebLinksAddon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @license MIT
*/

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

const protocolClause = '(https?:\\/\\/)';
Expand Down Expand Up @@ -41,37 +41,23 @@ function handleLink(event: MouseEvent, uri: string): void {
}

export class WebLinksAddon implements ITerminalAddon {
private _linkMatcherId: number | undefined;
private _terminal: Terminal | undefined;
private _linkProvider: IDisposable | undefined;

constructor(
private _handler: (event: MouseEvent, uri: string) => void = handleLink,
private _options: ILinkMatcherOptions | ILinkProviderOptions = {},
private _useLinkProvider: boolean = false
private _options: ILinkProviderOptions = {}
) {
}

public activate(terminal: Terminal): void {
this._terminal = terminal;

if (this._useLinkProvider && 'registerLinkProvider' in this._terminal) {
const options = this._options as ILinkProviderOptions;
const regex = options.urlRegex || strictUrlRegex;
this._linkProvider = this._terminal.registerLinkProvider(new WebLinkProvider(this._terminal, regex, this._handler, options));
} else {
// TODO: This should be removed eventually
const options = this._options as ILinkMatcherOptions;
options.matchIndex = 1;
this._linkMatcherId = (this._terminal as Terminal).registerLinkMatcher(strictUrlRegex, this._handler, options);
}
const options = this._options as ILinkProviderOptions;
const regex = options.urlRegex || strictUrlRegex;
this._linkProvider = this._terminal.registerLinkProvider(new WebLinkProvider(this._terminal, regex, this._handler, options));
}

public dispose(): void {
if (this._linkMatcherId !== undefined && this._terminal !== undefined) {
this._terminal.deregisterLinkMatcher(this._linkMatcherId);
}

this._linkProvider?.dispose();
}
}
12 changes: 4 additions & 8 deletions addons/xterm-addon-web-links/typings/xterm-addon-web-links.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/


import { Terminal, ILinkMatcherOptions, ITerminalAddon, IViewportRange } from 'xterm';
import { Terminal, ITerminalAddon, IViewportRange } from 'xterm';

declare module 'xterm-addon-web-links' {
/**
Expand All @@ -14,13 +14,9 @@ declare module 'xterm-addon-web-links' {
/**
* Creates a new web links addon.
* @param handler The callback when the link is called.
* @param options Options for the link matcher.
* @param useLinkProvider Whether to use the new link provider API to create
* the links. This is an option because use of both link matcher (old) and
* link provider (new) may cause issues. Link provider will eventually be
* the default and only option.
* @param options Options for the link provider.
*/
constructor(handler?: (event: MouseEvent, uri: string) => void, options?: ILinkMatcherOptions | ILinkProviderOptions, useLinkProvider?: boolean);
constructor(handler?: (event: MouseEvent, uri: string) => void, options?: ILinkProviderOptions);

/**
* Activates the addon
Expand Down Expand Up @@ -50,7 +46,7 @@ declare module 'xterm-addon-web-links' {
*/
leave?(event: MouseEvent, text: string): void;

/**
/**
* A callback to use instead of the default one.
*/
urlRegex?: RegExp;
Expand Down
2 changes: 0 additions & 2 deletions addons/xterm-addon-webgl/src/renderLayer/LinkRenderLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ export class LinkRenderLayer extends BaseRenderLayer {

constructor(container: HTMLElement, zIndex: number, colors: IColorSet, terminal: ITerminal) {
super(container, 'link', zIndex, true, colors);
terminal.linkifier.onShowLinkUnderline(e => this._onShowLinkUnderline(e));
terminal.linkifier.onHideLinkUnderline(e => this._onHideLinkUnderline(e));

terminal.linkifier2.onShowLinkUnderline(e => this._onShowLinkUnderline(e));
terminal.linkifier2.onHideLinkUnderline(e => this._onHideLinkUnderline(e));
Expand Down
244 changes: 0 additions & 244 deletions src/browser/Linkifier.test.ts

This file was deleted.

Loading