Support setting color in TerminalOptions/ExtensionTerminalOptions (#128856)
This commit is contained in:
parent
93886fd7f9
commit
ad5970666d
7 changed files with 26 additions and 4 deletions
16
src/vs/vscode.proposed.d.ts
vendored
16
src/vs/vscode.proposed.d.ts
vendored
|
@ -878,6 +878,22 @@ declare module 'vscode' {
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
//#region Terminal color support https://github.com/microsoft/vscode/issues/128228
|
||||||
|
export interface TerminalOptions {
|
||||||
|
/**
|
||||||
|
* Supports all ThemeColor keys, terminal.ansi* is recommended for contrast/consistency
|
||||||
|
*/
|
||||||
|
color?: ThemeColor;
|
||||||
|
}
|
||||||
|
export interface ExtensionTerminalOptions {
|
||||||
|
/**
|
||||||
|
* Supports all ThemeColor keys, terminal.ansi* is recommended for contrast/consistency
|
||||||
|
*/
|
||||||
|
color?: ThemeColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
//#endregion
|
||||||
|
|
||||||
// eslint-disable-next-line vscode-dts-region-comments
|
// eslint-disable-next-line vscode-dts-region-comments
|
||||||
//#region @jrieken -> exclusive document filters
|
//#region @jrieken -> exclusive document filters
|
||||||
|
|
||||||
|
|
|
@ -130,6 +130,7 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
|
||||||
args: launchConfig.shellArgs,
|
args: launchConfig.shellArgs,
|
||||||
cwd: typeof launchConfig.cwd === 'string' ? launchConfig.cwd : URI.revive(launchConfig.cwd),
|
cwd: typeof launchConfig.cwd === 'string' ? launchConfig.cwd : URI.revive(launchConfig.cwd),
|
||||||
icon: launchConfig.icon,
|
icon: launchConfig.icon,
|
||||||
|
color: launchConfig.color,
|
||||||
initialText: launchConfig.initialText,
|
initialText: launchConfig.initialText,
|
||||||
waitOnExit: launchConfig.waitOnExit,
|
waitOnExit: launchConfig.waitOnExit,
|
||||||
ignoreConfigurationCwd: true,
|
ignoreConfigurationCwd: true,
|
||||||
|
|
|
@ -639,6 +639,9 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
|
||||||
},
|
},
|
||||||
createTerminal(nameOrOptions?: vscode.TerminalOptions | vscode.ExtensionTerminalOptions | string, shellPath?: string, shellArgs?: string[] | string): vscode.Terminal {
|
createTerminal(nameOrOptions?: vscode.TerminalOptions | vscode.ExtensionTerminalOptions | string, shellPath?: string, shellArgs?: string[] | string): vscode.Terminal {
|
||||||
if (typeof nameOrOptions === 'object') {
|
if (typeof nameOrOptions === 'object') {
|
||||||
|
if (nameOrOptions.color) {
|
||||||
|
checkProposedApiEnabled(extension);
|
||||||
|
}
|
||||||
if ('pty' in nameOrOptions) {
|
if ('pty' in nameOrOptions) {
|
||||||
return extHostTerminalService.createExtensionTerminal(nameOrOptions);
|
return extHostTerminalService.createExtensionTerminal(nameOrOptions);
|
||||||
}
|
}
|
||||||
|
|
|
@ -471,6 +471,7 @@ export interface TerminalLaunchConfig {
|
||||||
cwd?: string | UriComponents;
|
cwd?: string | UriComponents;
|
||||||
env?: ITerminalEnvironment;
|
env?: ITerminalEnvironment;
|
||||||
icon?: URI | { light: URI; dark: URI } | ThemeIcon;
|
icon?: URI | { light: URI; dark: URI } | ThemeIcon;
|
||||||
|
color?: string;
|
||||||
initialText?: string;
|
initialText?: string;
|
||||||
waitOnExit?: boolean;
|
waitOnExit?: boolean;
|
||||||
strictEnv?: boolean;
|
strictEnv?: boolean;
|
||||||
|
|
|
@ -10,7 +10,7 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation'
|
||||||
import { URI } from 'vs/base/common/uri';
|
import { URI } from 'vs/base/common/uri';
|
||||||
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
|
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
|
||||||
import { IDisposable, DisposableStore, Disposable } from 'vs/base/common/lifecycle';
|
import { IDisposable, DisposableStore, Disposable } from 'vs/base/common/lifecycle';
|
||||||
import { Disposable as VSCodeDisposable, EnvironmentVariableMutatorType, ThemeColor } from './extHostTypes';
|
import { Disposable as VSCodeDisposable, EnvironmentVariableMutatorType } from './extHostTypes';
|
||||||
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||||
import { localize } from 'vs/nls';
|
import { localize } from 'vs/nls';
|
||||||
import { NotSupportedError } from 'vs/base/common/errors';
|
import { NotSupportedError } from 'vs/base/common/errors';
|
||||||
|
@ -20,7 +20,7 @@ import { generateUuid } from 'vs/base/common/uuid';
|
||||||
import { ISerializableEnvironmentVariableCollection } from 'vs/workbench/contrib/terminal/common/environmentVariable';
|
import { ISerializableEnvironmentVariableCollection } from 'vs/workbench/contrib/terminal/common/environmentVariable';
|
||||||
import { ICreateContributedTerminalProfileOptions, IProcessReadyEvent, IShellLaunchConfigDto, ITerminalChildProcess, ITerminalDimensionsOverride, ITerminalLaunchError, ITerminalProfile, TerminalIcon, TerminalLocation, TerminalShellType } from 'vs/platform/terminal/common/terminal';
|
import { ICreateContributedTerminalProfileOptions, IProcessReadyEvent, IShellLaunchConfigDto, ITerminalChildProcess, ITerminalDimensionsOverride, ITerminalLaunchError, ITerminalProfile, TerminalIcon, TerminalLocation, TerminalShellType } from 'vs/platform/terminal/common/terminal';
|
||||||
import { TerminalDataBufferer } from 'vs/platform/terminal/common/terminalDataBuffering';
|
import { TerminalDataBufferer } from 'vs/platform/terminal/common/terminalDataBuffering';
|
||||||
import { ThemeIcon } from 'vs/platform/theme/common/themeService';
|
import { ThemeIcon, ThemeColor } from 'vs/platform/theme/common/themeService';
|
||||||
import { withNullAsUndefined } from 'vs/base/common/types';
|
import { withNullAsUndefined } from 'vs/base/common/types';
|
||||||
|
|
||||||
export interface IExtHostTerminalService extends ExtHostTerminalServiceShape, IDisposable {
|
export interface IExtHostTerminalService extends ExtHostTerminalServiceShape, IDisposable {
|
||||||
|
@ -135,6 +135,7 @@ export class ExtHostTerminal {
|
||||||
cwd: withNullAsUndefined(options.cwd),
|
cwd: withNullAsUndefined(options.cwd),
|
||||||
env: withNullAsUndefined(options.env),
|
env: withNullAsUndefined(options.env),
|
||||||
icon: withNullAsUndefined(asTerminalIcon(options.iconPath)),
|
icon: withNullAsUndefined(asTerminalIcon(options.iconPath)),
|
||||||
|
color: ThemeColor.isThemeColor(options.color) ? options.color.id : undefined,
|
||||||
initialText: withNullAsUndefined(options.message),
|
initialText: withNullAsUndefined(options.message),
|
||||||
strictEnv: withNullAsUndefined(options.strictEnv),
|
strictEnv: withNullAsUndefined(options.strictEnv),
|
||||||
hideFromUser: withNullAsUndefined(options.hideFromUser),
|
hideFromUser: withNullAsUndefined(options.hideFromUser),
|
||||||
|
|
|
@ -1200,7 +1200,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
|
||||||
this._onProcessExit(error);
|
this._onProcessExit(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!hadIcon && this.shellLaunchConfig.icon) {
|
if (!hadIcon && this.shellLaunchConfig.icon || this.shellLaunchConfig.color) {
|
||||||
this._onIconChanged.fire(this);
|
this._onIconChanged.fire(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,7 +124,7 @@ export abstract class BaseTerminalProfileResolverService implements ITerminalPro
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply the color
|
// Apply the color
|
||||||
shellLaunchConfig.color = resolvedProfile.color;
|
shellLaunchConfig.color = shellLaunchConfig.color || resolvedProfile.color;
|
||||||
|
|
||||||
// Resolve useShellEnvironment based on the setting if it's not set
|
// Resolve useShellEnvironment based on the setting if it's not set
|
||||||
if (shellLaunchConfig.useShellEnvironment === undefined) {
|
if (shellLaunchConfig.useShellEnvironment === undefined) {
|
||||||
|
|
Loading…
Reference in a new issue