未验证 提交 1615443b 编写于 作者: S SteVen Batten 提交者: GitHub

Terminal in the Sidebar Fixes (#93440)

* split orientation fixes

* terminal now works across moves

* fix theming

* fixes #93415

* Update src/vs/workbench/contrib/terminal/browser/terminalInstance.ts
Co-Authored-By: NDaniel Imms <tyriar@tyriar.com>
Co-authored-by: NDaniel Imms <tyriar@tyriar.com>
上级 52df5961
......@@ -214,7 +214,11 @@ export abstract class Pane extends Disposable implements IView {
.event(() => this.setExpanded(true), null));
this._register(domEvent(this.header, 'click')
(() => this.setExpanded(!this.isExpanded()), null));
(e => {
if (!e.defaultPrevented) {
this.setExpanded(!this.isExpanded());
}
}, null));
this.body = append(this.element, $('.pane-body'));
this.renderBody(this.body);
......
......@@ -155,3 +155,8 @@
.xterm.xterm-cursor-pointer {
cursor: pointer!important;
}
/* Rotate icon when terminal is in the sidebar */
.monaco-workbench .part.sidebar .title-actions .terminal-action.codicon-split-horizontal {
transform: rotate(-90deg);
}
......@@ -23,7 +23,7 @@ import { INotificationService, IPromptChoice, Severity } from 'vs/platform/notif
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { activeContrastBorder, scrollbarSliderActiveBackground, scrollbarSliderBackground, scrollbarSliderHoverBackground } from 'vs/platform/theme/common/colorRegistry';
import { ICssStyleCollector, IColorTheme, IThemeService, registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import { PANEL_BACKGROUND } from 'vs/workbench/common/theme';
import { PANEL_BACKGROUND, SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme';
import { TerminalWidgetManager } from 'vs/workbench/contrib/terminal/browser/terminalWidgetManager';
import { IShellLaunchConfig, ITerminalDimensions, ITerminalProcessManager, KEYBINDING_CONTEXT_TERMINAL_TEXT_SELECTED, NEVER_MEASURE_RENDER_TIME_STORAGE_KEY, ProcessState, TERMINAL_VIEW_ID, IWindowsShellHelper, SHELL_PATH_INVALID_EXIT_CODE, SHELL_PATH_DIRECTORY_EXIT_CODE, SHELL_CWD_INVALID_EXIT_CODE, KEYBINDING_CONTEXT_TERMINAL_A11Y_TREE_FOCUS, INavigationMode, TitleEventSource, TERMINAL_COMMAND_ID, LEGACY_CONSOLE_MODE_EXIT_CODE } from 'vs/workbench/contrib/terminal/common/terminal';
import { ansiColorIdentifiers, TERMINAL_BACKGROUND_COLOR, TERMINAL_CURSOR_BACKGROUND_COLOR, TERMINAL_CURSOR_FOREGROUND_COLOR, TERMINAL_FOREGROUND_COLOR, TERMINAL_SELECTION_BACKGROUND_COLOR } from 'vs/workbench/contrib/terminal/common/terminalColorRegistry';
......@@ -40,7 +40,7 @@ import { NavigationModeAddon } from 'vs/workbench/contrib/terminal/browser/addon
import { XTermCore } from 'vs/workbench/contrib/terminal/browser/xterm-private';
import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
import { IOpenerService } from 'vs/platform/opener/common/opener';
import { IViewsService } from 'vs/workbench/common/views';
import { IViewsService, IViewDescriptorService, ViewContainerLocation } from 'vs/workbench/common/views';
// How long in milliseconds should an average frame take to render for a notification to appear
// which suggests the fallback DOM-based renderer
......@@ -292,6 +292,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
@ILogService private readonly _logService: ILogService,
@IStorageService private readonly _storageService: IStorageService,
@IAccessibilityService private readonly _accessibilityService: IAccessibilityService,
@IViewDescriptorService private readonly _viewDescriptorService: IViewDescriptorService,
@IOpenerService private readonly _openerService: IOpenerService
) {
super();
......@@ -534,6 +535,11 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
this._commandTrackerAddon = new CommandTrackerAddon();
this._xterm.loadAddon(this._commandTrackerAddon);
this._register(this._themeService.onDidColorThemeChange(theme => this._updateTheme(xterm, theme)));
this._register(this._viewDescriptorService.onDidChangeLocation(({ views }) => {
if (views.some(v => v.id === TERMINAL_VIEW_ID)) {
this._updateTheme(xterm);
}
}));
return xterm;
}
......@@ -1453,8 +1459,9 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
theme = this._themeService.getColorTheme();
}
const location = this._viewDescriptorService.getViewLocation(TERMINAL_VIEW_ID)!;
const foregroundColor = theme.getColor(TERMINAL_FOREGROUND_COLOR);
const backgroundColor = theme.getColor(TERMINAL_BACKGROUND_COLOR) || theme.getColor(PANEL_BACKGROUND);
const backgroundColor = theme.getColor(TERMINAL_BACKGROUND_COLOR) || (location === ViewContainerLocation.Sidebar ? theme.getColor(SIDE_BAR_BACKGROUND) : theme.getColor(PANEL_BACKGROUND));
const cursorColor = theme.getColor(TERMINAL_CURSOR_FOREGROUND_COLOR) || foregroundColor;
const cursorAccentColor = theme.getColor(TERMINAL_CURSOR_BACKGROUND_COLOR) || backgroundColor;
const selectionColor = theme.getColor(TERMINAL_SELECTION_BACKGROUND_COLOR);
......
......@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as aria from 'vs/base/browser/ui/aria/aria';
import * as nls from 'vs/nls';
import { IShellLaunchConfig, ITerminalConfigHelper } from 'vs/workbench/contrib/terminal/common/terminal';
import { IShellLaunchConfig, ITerminalConfigHelper, TERMINAL_VIEW_ID } from 'vs/workbench/contrib/terminal/common/terminal';
import { IContextKey } from 'vs/platform/contextkey/common/contextkey';
import { Event, Emitter } from 'vs/base/common/event';
import { IDisposable, Disposable, DisposableStore } from 'vs/base/common/lifecycle';
......@@ -12,6 +12,7 @@ import { SplitView, Orientation, IView, Sizing } from 'vs/base/browser/ui/splitv
import { IWorkbenchLayoutService, Parts, Position } from 'vs/workbench/services/layout/browser/layoutService';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ITerminalInstance, Direction, ITerminalTab, ITerminalService } from 'vs/workbench/contrib/terminal/browser/terminal';
import { ViewContainerLocation, IViewDescriptorService } from 'vs/workbench/common/views';
const SPLIT_PANE_MIN_SIZE = 120;
......@@ -215,6 +216,7 @@ export class TerminalTab extends Disposable implements ITerminalTab {
private _splitPaneContainer: SplitPaneContainer | undefined;
private _tabElement: HTMLElement | undefined;
private _panelPosition: Position = Position.BOTTOM;
private _terminalLocation: ViewContainerLocation = ViewContainerLocation.Panel;
private _activeInstanceIndex: number;
......@@ -232,6 +234,7 @@ export class TerminalTab extends Disposable implements ITerminalTab {
shellLaunchConfigOrInstance: IShellLaunchConfig | ITerminalInstance,
@ITerminalService private readonly _terminalService: ITerminalService,
@IWorkbenchLayoutService private readonly _layoutService: IWorkbenchLayoutService,
@IViewDescriptorService private readonly _viewDescriptorService: IViewDescriptorService,
@IInstantiationService private readonly _instantiationService: IInstantiationService
) {
super();
......@@ -340,12 +343,18 @@ export class TerminalTab extends Disposable implements ITerminalTab {
public attachToElement(element: HTMLElement): void {
this._container = element;
this._tabElement = document.createElement('div');
this._tabElement.classList.add('terminal-tab');
// If we already have a tab element, we can reparent it
if (!this._tabElement) {
this._tabElement = document.createElement('div');
this._tabElement.classList.add('terminal-tab');
}
this._container.appendChild(this._tabElement);
if (!this._splitPaneContainer) {
this._panelPosition = this._layoutService.getPanelPosition();
const orientation = this._panelPosition === Position.BOTTOM ? Orientation.HORIZONTAL : Orientation.VERTICAL;
this._terminalLocation = this._viewDescriptorService.getViewLocation(TERMINAL_VIEW_ID)!;
const orientation = this._terminalLocation === ViewContainerLocation.Panel && this._panelPosition === Position.BOTTOM ? Orientation.HORIZONTAL : Orientation.VERTICAL;
const newLocal = this._instantiationService.createInstance(SplitPaneContainer, this._tabElement, orientation);
this._splitPaneContainer = newLocal;
this.terminalInstances.forEach(instance => this._splitPaneContainer!.split(instance));
......@@ -394,11 +403,14 @@ export class TerminalTab extends Disposable implements ITerminalTab {
if (this._splitPaneContainer) {
// Check if the panel position changed and rotate panes if so
const newPanelPosition = this._layoutService.getPanelPosition();
const panelPositionChanged = newPanelPosition !== this._panelPosition;
if (panelPositionChanged) {
const newOrientation = newPanelPosition === Position.BOTTOM ? Orientation.HORIZONTAL : Orientation.VERTICAL;
const newTerminalLocation = this._viewDescriptorService.getViewLocation(TERMINAL_VIEW_ID)!;
const terminalPositionChanged = newPanelPosition !== this._panelPosition || newTerminalLocation !== this._terminalLocation;
if (terminalPositionChanged) {
const newOrientation = newTerminalLocation === ViewContainerLocation.Panel && newPanelPosition === Position.BOTTOM ? Orientation.HORIZONTAL : Orientation.VERTICAL;
this._splitPaneContainer.setOrientation(newOrientation);
this._panelPosition = newPanelPosition;
this._terminalLocation = newTerminalLocation;
}
this._splitPaneContainer.layout(width, height);
......
......@@ -29,6 +29,7 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IViewDescriptorService } from 'vs/workbench/common/views';
import { IOpenerService } from 'vs/platform/opener/common/opener';
import { PANEL_BACKGROUND, SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme';
const FIND_FOCUS_CLASS = 'find-focused';
......@@ -326,8 +327,11 @@ export class TerminalViewPane extends ViewPane {
}
registerThemingParticipant((theme: IColorTheme, collector: ICssStyleCollector) => {
const backgroundColor = theme.getColor(TERMINAL_BACKGROUND_COLOR);
collector.addRule(`.monaco-workbench .pane-body.integrated-terminal .terminal-outer-container { background-color: ${backgroundColor ? backgroundColor.toString() : ''}; }`);
const panelBackgroundColor = theme.getColor(TERMINAL_BACKGROUND_COLOR) || theme.getColor(PANEL_BACKGROUND);
collector.addRule(`.monaco-workbench .part.panel .pane-body.integrated-terminal .terminal-outer-container { background-color: ${panelBackgroundColor ? panelBackgroundColor.toString() : ''}; }`);
const sidebarBackgroundColor = theme.getColor(TERMINAL_BACKGROUND_COLOR) || theme.getColor(SIDE_BAR_BACKGROUND);
collector.addRule(`.monaco-workbench .part.sidebar .pane-body.integrated-terminal .terminal-outer-container { background-color: ${sidebarBackgroundColor ? sidebarBackgroundColor.toString() : ''}; }`);
const borderColor = theme.getColor(TERMINAL_BORDER_COLOR);
if (borderColor) {
......
......@@ -6,7 +6,7 @@
import * as nls from 'vs/nls';
import { registerColor, ColorIdentifier, ColorDefaults } from 'vs/platform/theme/common/colorRegistry';
import { PANEL_BORDER, PANEL_BACKGROUND } from 'vs/workbench/common/theme';
import { PANEL_BORDER } from 'vs/workbench/common/theme';
/**
* The color identifiers for the terminal's ansi colors. The index in the array corresponds to the index
......@@ -14,11 +14,7 @@ import { PANEL_BORDER, PANEL_BACKGROUND } from 'vs/workbench/common/theme';
*/
export const ansiColorIdentifiers: ColorIdentifier[] = [];
export const TERMINAL_BACKGROUND_COLOR = registerColor('terminal.background', {
dark: PANEL_BACKGROUND,
light: PANEL_BACKGROUND,
hc: PANEL_BACKGROUND
}, nls.localize('terminal.background', 'The background color of the terminal, this allows coloring the terminal differently to the panel.'));
export const TERMINAL_BACKGROUND_COLOR = registerColor('terminal.background', null, nls.localize('terminal.background', 'The background color of the terminal, this allows coloring the terminal differently to the panel.'));
export const TERMINAL_FOREGROUND_COLOR = registerColor('terminal.foreground', {
light: '#333333',
dark: '#CCCCCC',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册