From 31b08380014bae783ccf602caf7bba15c0e64871 Mon Sep 17 00:00:00 2001 From: Dan Arad Date: Wed, 10 Feb 2021 10:13:07 +0200 Subject: [PATCH] 9012-registerTerminalLinkProvider-stub: in order to facilitate vscode-java-debug extension added registerTerminalLinkProvider stub which is invoked upon extension activation Signed-off-by: Dan Arad --- .../plugin-ext/src/plugin/plugin-context.ts | 3 + packages/plugin/src/theia.d.ts | 69 +++++++++++++++++++ 2 files changed, 72 insertions(+) diff --git a/packages/plugin-ext/src/plugin/plugin-context.ts b/packages/plugin-ext/src/plugin/plugin-context.ts index d5a4058acea6a..021bae34804e4 100644 --- a/packages/plugin-ext/src/plugin/plugin-context.ts +++ b/packages/plugin-ext/src/plugin/plugin-context.ts @@ -432,6 +432,9 @@ export function createAPIFactory( createInputBox(): theia.InputBox { return quickOpenExt.createInputBox(plugin); }, + registerTerminalLinkProvider(provider: theia.TerminalLinkProvider): void { + /* NOOP. To be implemented at later stage */ + }, get activeColorTheme(): theia.ColorTheme { return themingExt.activeColorTheme; }, diff --git a/packages/plugin/src/theia.d.ts b/packages/plugin/src/theia.d.ts index cfbccb85f6dfc..37908bf0f0b68 100644 --- a/packages/plugin/src/theia.d.ts +++ b/packages/plugin/src/theia.d.ts @@ -2871,6 +2871,67 @@ declare module '@theia/plugin' { setDimensions?(dimensions: TerminalDimensions): void; } + /** + * Provides information on a line in a terminal in order to provide links for it. + */ + export interface TerminalLinkContext { + /** + * This is the text from the unwrapped line in the terminal. + */ + line: string; + + /** + * The terminal the link belongs to. + */ + terminal: Terminal; + } + + /** + * A provider that enables detection and handling of links within terminals. + */ + export interface TerminalLinkProvider { + /** + * Provide terminal links for the given context. Note that this can be called multiple times + * even before previous calls resolve, make sure to not share global objects (eg. `RegExp`) + * that could have problems when asynchronous usage may overlap. + * @param context Information about what links are being provided for. + * @param token A cancellation token. + * @return A list of terminal links for the given line. + */ + provideTerminalLinks(context: TerminalLinkContext, token: CancellationToken): ProviderResult; + + /** + * Handle an activated terminal link. + * @param link The link to handle. + */ + handleTerminalLink(link: T): ProviderResult; + } + + /** + * A link on a terminal line. + */ + export interface TerminalLink { + /** + * The start index of the link on [TerminalLinkContext.line](#TerminalLinkContext.line]. + */ + startIndex: number; + + /** + * The length of the link on [TerminalLinkContext.line](#TerminalLinkContext.line] + */ + length: number; + + /** + * The tooltip text when you hover over this link. + * + * If a tooltip is provided, is will be displayed in a string that includes instructions on + * how to trigger the link, such as `{0} (ctrl + click)`. The specific instructions vary + * depending on OS, user settings, and localization. + */ + tooltip?: string; + } + + /** * A type of mutation that can be applied to an environment variable. */ @@ -3964,6 +4025,14 @@ declare module '@theia/plugin' { */ export function createInputBox(): InputBox; + + /** + * Register provider that enables the detection and handling of links within the terminal. + * @param provider The provider that provides the terminal links. + * @return Disposable that unregisters the provider. + */ + export function registerTerminalLinkProvider(provider: TerminalLinkProvider): void; + /** * The currently active color theme as configured in the settings. The active * theme can be changed via the `workbench.colorTheme` setting.