未验证 提交 a3d61cb0 编写于 作者: D Daniel Imms

Add change icon/configure terminal action

Fixes #121467
上级 0b9c11a4
......@@ -576,4 +576,14 @@ export interface ITerminalInstance {
* Triggers a quick pick to rename this terminal.
*/
rename(): Promise<void>;
/**
* Triggers a quick pick to rename this terminal.
*/
changeIcon(): Promise<void>;
/**
* Allows the user to configure this terminal.
*/
configure(): Promise<void>;
}
......@@ -616,6 +616,34 @@ export function registerTerminalActions() {
}
}
});
registerAction2(class extends Action2 {
constructor() {
super({
id: TERMINAL_COMMAND_ID.CONFIGURE_ACTIVE,
title: { value: localize('workbench.action.terminal.configureActive', "Configure Active Terminal"), original: 'Configure Active Terminal' },
f1: true,
category,
precondition: KEYBINDING_CONTEXT_TERMINAL_PROCESS_SUPPORTED
});
}
async run(accessor: ServicesAccessor) {
return accessor.get(ITerminalService).getActiveInstance()?.configure();
}
});
registerAction2(class extends Action2 {
constructor() {
super({
id: TERMINAL_COMMAND_ID.CHANGE_ICON,
title: { value: localize('workbench.action.terminal.changeIcon', "Change Icon"), original: 'Change Icon' },
f1: true,
category,
precondition: KEYBINDING_CONTEXT_TERMINAL_PROCESS_SUPPORTED
});
}
async run(accessor: ServicesAccessor) {
return accessor.get(ITerminalService).getActiveInstance()?.changeIcon();
}
});
registerAction2(class extends Action2 {
constructor() {
super({
......
......@@ -52,7 +52,7 @@ import { formatMessageForTerminal } from 'vs/workbench/contrib/terminal/common/t
import { AutoOpenBarrier } from 'vs/base/common/async';
import { Codicon, iconRegistry } from 'vs/base/common/codicons';
import { ITerminalStatusList, TerminalStatus, TerminalStatusList } from 'vs/workbench/contrib/terminal/browser/terminalStatusList';
import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
import { IQuickInputService, IQuickPickItem } from 'vs/platform/quickinput/common/quickInput';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { isMacintosh, isWindows, OperatingSystem, OS } from 'vs/base/common/platform';
......@@ -1744,6 +1744,33 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
this.setTitle(name, TitleEventSource.Api);
}
}
public async changeIcon() {
const items: IQuickPickItem[] = [];
for (const icon of iconRegistry.all) {
items.push({ label: `$(${icon.id})`, description: `${icon.id}` });
}
const result = await this._quickInputService.pick(items, {
title: nls.localize('changeTerminalIcon', "Change Icon"),
matchOnDescription: true
});
if (result) {
this.shellLaunchConfig.icon = result.description;
this._onTitleChanged.fire(this);
}
}
public async configure(): Promise<void> {
const changeIcon: IQuickPickItem = { label: nls.localize('changeIconTerminal', 'Change Icon') };
const rename: IQuickPickItem = { label: nls.localize('renameTerminal', 'Rename') };
const result = await this._quickInputService.pick([changeIcon, rename], {
title: nls.localize('configureTerminalTitle', "Configure Terminal")
});
switch (result) {
case changeIcon: return this.changeIcon();
case rename: return this.rename();
}
}
}
registerThemingParticipant((theme: IColorTheme, collector: ICssStyleCollector) => {
......
......@@ -222,12 +222,12 @@ class TerminalTabsRenderer implements ITreeRenderer<ITerminalInstance, never, IT
}
fillActionBar(instance: ITerminalInstance, template: ITerminalTabEntryTemplate): void {
const rename = new Action(TERMINAL_COMMAND_ID.RENAME, localize('terminal.rename', "Rename"), ThemeIcon.asClassName(Codicon.tag), true, () => instance.rename());
const configure = new Action(TERMINAL_COMMAND_ID.CONFIGURE_ACTIVE, localize('terminal.configure', "Configure"), ThemeIcon.asClassName(Codicon.gear), true, () => instance.configure());
const split = new Action(TERMINAL_COMMAND_ID.SPLIT, localize('terminal.split', "Split"), ThemeIcon.asClassName(Codicon.splitHorizontal), true, async () => this._terminalService.splitInstance(instance));
const kill = new Action(TERMINAL_COMMAND_ID.KILL, localize('terminal.kill', "Kill"), ThemeIcon.asClassName(Codicon.trashcan), true, async () => instance.dispose(true));
// TODO: Cache these in a way that will use the correct instance
template.actionBar.clear();
template.actionBar.push(rename, { icon: true, label: false });
template.actionBar.push(configure, { icon: true, label: false });
template.actionBar.push(split, { icon: true, label: false });
template.actionBar.push(kill, { icon: true, label: false });
}
......
......@@ -453,6 +453,8 @@ export const enum TERMINAL_COMMAND_ID {
SCROLL_TO_TOP = 'workbench.action.terminal.scrollToTop',
CLEAR = 'workbench.action.terminal.clear',
CLEAR_SELECTION = 'workbench.action.terminal.clearSelection',
CONFIGURE_ACTIVE = 'workbench.action.terminal.configureActive',
CHANGE_ICON = 'workbench.action.terminal.changeIcon',
RENAME = 'workbench.action.terminal.rename',
RENAME_WITH_ARG = 'workbench.action.terminal.renameWithArg',
FIND_FOCUS = 'workbench.action.terminal.focusFind',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册