Skip to content

Commit

Permalink
9012-registerTerminalLinkProvider-stub: in order to facilitate vscode…
Browse files Browse the repository at this point in the history
…-java-debug extension added registerTerminalLinkProvider stub which is invoked upon extension activation

Signed-off-by: Dan Arad <dan.arad@sap.com>
  • Loading branch information
danarad05 authored and amiramw committed Feb 23, 2021
1 parent 2681e6e commit 31b0838
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/plugin-ext/src/plugin/plugin-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
Expand Down
69 changes: 69 additions & 0 deletions packages/plugin/src/theia.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T extends TerminalLink = TerminalLink> {
/**
* 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<T[]>;

/**
* Handle an activated terminal link.
* @param link The link to handle.
*/
handleTerminalLink(link: T): ProviderResult<void>;
}

/**
* 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.
*/
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 31b0838

Please sign in to comment.