Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing: use a real terminal in test Test Results view #184963

Merged
merged 12 commits into from
Jun 16, 2023
8 changes: 8 additions & 0 deletions src/vs/platform/terminal/common/capabilities/capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ export interface ITerminalCapabilityStore {
get<T extends TerminalCapability>(capability: T): ITerminalCapabilityImplMap[T] | undefined;
}

export const emptyTerminalCapabilityStore: ITerminalCapabilityStore = {
items: [][Symbol.iterator](),
onDidAddCapability: Event.None,
onDidRemoveCapability: Event.None,
has: () => false,
get: () => undefined
};

/**
* Maps capability types to their implementation, enabling strongly typed fetching of
* implementations.
Expand Down
33 changes: 11 additions & 22 deletions src/vs/workbench/contrib/terminal/browser/media/scrollbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,43 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

.monaco-workbench .editor-instance .xterm-viewport,
.monaco-workbench .pane-body.integrated-terminal .xterm-viewport {
.xterm-viewport {
connor4312 marked this conversation as resolved.
Show resolved Hide resolved
/* Use the hack presented in https://stackoverflow.com/a/38748186/1156119 to get opacity transitions working on the scrollbar */
-webkit-background-clip: text;
background-clip: text;
-webkit-text-fill-color: transparent;
transition: background-color 800ms linear;
}

.monaco-workbench .editor-instance .xterm-viewport,
.monaco-workbench .pane-body.integrated-terminal .xterm-viewport {
.xterm-viewport {
scrollbar-width: thin;
}

.monaco-workbench .editor-instance .xterm-viewport::-webkit-scrollbar,
.monaco-workbench .pane-body.integrated-terminal .xterm-viewport::-webkit-scrollbar {
.xterm-viewport::-webkit-scrollbar {
width: 10px;
}

.monaco-workbench .editor-instance .xterm-viewport::-webkit-scrollbar-track,
.monaco-workbench .pane-body.integrated-terminal .xterm-viewport::-webkit-scrollbar-track {
.xterm-viewport::-webkit-scrollbar-track {
opacity: 0;
}

.monaco-workbench .editor-instance .xterm-viewport::-webkit-scrollbar-thumb,
.monaco-workbench .pane-body.integrated-terminal .xterm-viewport::-webkit-scrollbar-thumb {
.xterm-viewport::-webkit-scrollbar-thumb {
min-height: 20px;
background-color: inherit;
}

.monaco-workbench .editor-instance .force-scrollbar .xterm .xterm-viewport,
.monaco-workbench .pane-body.integrated-terminal .force-scrollbar .xterm .xterm-viewport,
.monaco-workbench .editor-instance .xterm.focus .xterm-viewport,
.monaco-workbench .pane-body.integrated-terminal .xterm.focus .xterm-viewport,
.monaco-workbench .editor-instance .xterm:focus .xterm-viewport,
.monaco-workbench .pane-body.integrated-terminal .xterm:focus .xterm-viewport,
.monaco-workbench .editor-instance .xterm:hover .xterm-viewport,
.monaco-workbench .pane-body.integrated-terminal .xterm:hover .xterm-viewport {
.force-scrollbar .xterm .xterm-viewport,
.xterm.focus .xterm-viewport,
.xterm:focus .xterm-viewport,
.xterm:hover .xterm-viewport {
transition: opacity 100ms linear;
cursor: default;
}

.monaco-workbench .editor-instance .xterm .xterm-viewport::-webkit-scrollbar-thumb:hover,
.monaco-workbench .pane-body.integrated-terminal .xterm .xterm-viewport::-webkit-scrollbar-thumb:hover {
.xterm .xterm-viewport::-webkit-scrollbar-thumb:hover {
transition: opacity 0ms linear;
}

.monaco-workbench .editor-instance .xterm .xterm-viewport::-webkit-scrollbar-thumb:window-inactive,
.monaco-workbench .pane-body.integrated-terminal .xterm .xterm-viewport::-webkit-scrollbar-thumb:window-inactive {
.xterm .xterm-viewport::-webkit-scrollbar-thumb:window-inactive {
background-color: inherit;
}
26 changes: 9 additions & 17 deletions src/vs/workbench/contrib/terminal/browser/media/terminal.css
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@
top: 0;
}

.monaco-workbench .pane-body.integrated-terminal .xterm .xterm-helper-textarea:focus {
.monaco-workbench .xterm .xterm-helper-textarea:focus {
connor4312 marked this conversation as resolved.
Show resolved Hide resolved
/* Override the general vscode style applies `opacity:1!important` to textareas */
opacity: 0 !important;
}
Expand Down Expand Up @@ -522,34 +522,26 @@
background-color: var(--vscode-terminal-hoverHighlightBackground);
}

.monaco-workbench .editor-instance .force-scrollbar .xterm .xterm-viewport,
.monaco-workbench .pane-body.integrated-terminal .force-scrollbar .xterm .xterm-viewport,
.monaco-workbench .editor-instance .xterm.focus .xterm-viewport,
.monaco-workbench .pane-body.integrated-terminal .xterm.focus .xterm-viewport,
.monaco-workbench .editor-instance .xterm:focus .xterm-viewport,
.monaco-workbench .pane-body.integrated-terminal .xterm:focus .xterm-viewport,
.monaco-workbench .editor-instance .xterm:hover .xterm-viewport,
.monaco-workbench .pane-body.integrated-terminal .xterm:hover .xterm-viewport {
.force-scrollbar .xterm .xterm-viewport,
.xterm.focus .xterm-viewport,
.xterm:focus .xterm-viewport,
.xterm:hover .xterm-viewport {
connor4312 marked this conversation as resolved.
Show resolved Hide resolved
background-color: var(--vscode-scrollbarSlider-background) !important;
}

.monaco-workbench .editor-instance .xterm-viewport,
.monaco-workbench .pane-body.integrated-terminal .xterm-viewport {
.xterm-viewport {
scrollbar-color: var(--vscode-scrollbarSlider-background) transparent;
}

.monaco-workbench .editor-instance .xterm .xterm-viewport::-webkit-scrollbar-thumb:hover,
.monaco-workbench .pane-body.integrated-terminal .xterm .xterm-viewport::-webkit-scrollbar-thumb:hover {
.xterm .xterm-viewport::-webkit-scrollbar-thumb:hover {
background-color: var(--vscode-scrollbarSlider-hoverBackground);
}

.monaco-workbench .editor-instance .xterm-viewport:hover,
.monaco-workbench .pane-body.integrated-terminal .xterm-viewport:hover {
.xterm-viewport:hover {
scrollbar-color: var(--vscode-scrollbarSlider-hoverBackground) transparent;
}

.monaco-workbench .editor-instance .xterm .xterm-viewport::-webkit-scrollbar-thumb:active,
.monaco-workbench .pane-body.integrated-terminal .xterm .xterm-viewport::-webkit-scrollbar-thumb:active {
.xterm .xterm-viewport::-webkit-scrollbar-thumb:active {
background-color: var(--vscode-scrollbarSlider-activeBackground);
}

Expand Down
65 changes: 59 additions & 6 deletions src/vs/workbench/contrib/terminal/browser/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,18 @@ export const enum TerminalConnectionState {
Connected
}

export interface IDetachedXTermOptions {
cols: number;
rows: number;
}

export interface ITerminalService extends ITerminalInstanceHost {
readonly _serviceBrand: undefined;

/** Gets all terminal instances, including editor and terminal view (group) instances. */
readonly instances: readonly ITerminalInstance[];
/** Gets detached terminal instances created via {@link createDetachedXterm}. */
readonly detachedInstances: Iterable<IXtermTerminal>;
connor4312 marked this conversation as resolved.
Show resolved Hide resolved
configHelper: ITerminalConfigHelper;
isProcessSupportRegistered: boolean;
readonly connectionState: TerminalConnectionState;
Expand Down Expand Up @@ -170,6 +177,13 @@ export interface ITerminalService extends ITerminalInstanceHost {
*/
createTerminal(options?: ICreateTerminalOptions): Promise<ITerminalInstance>;

/**
* Creates a detached xterm instance which is not attached to the DOM or
* tracked as a terminal instance.
* @params options The options to create the terminal with
*/
createDetachedXterm(options: IDetachedXTermOptions): Promise<IXtermTerminal>;

/**
* Creates a raw terminal instance, this should not be used outside of the terminal part.
*/
Expand Down Expand Up @@ -707,11 +721,6 @@ export interface ITerminalInstance {
*/
resetFocusContextKey(): void;

/**
* Select all text in the terminal.
*/
selectAll(): void;

/**
* Focuses the terminal instance if it's able to (the xterm.js instance must exist).
*
Expand Down Expand Up @@ -946,7 +955,14 @@ export const enum XtermTerminalConstants {
SearchHighlightLimit = 1000
}

export interface IXtermTerminal {
export interface IXtermAttachToElementOptions {
/**
* Whether GPU rendering should be enabled for this element, defaults to true.
*/
enableGpu?: boolean;
}

export interface IXtermTerminal extends IDisposable {
/**
* An object that tracks when commands are run and enables navigating and selecting between
* them.
Expand All @@ -961,6 +977,11 @@ export interface IXtermTerminal {
readonly onDidChangeSelection: Event<void>;
readonly onDidChangeFindResults: Event<{ resultIndex: number; resultCount: number }>;

/**
* Event fired when focus enters (fires with true) or leaves (false) the terminal.
*/
readonly onDidChangeFocus: Event<boolean>;

/**
* Gets a view of the current texture atlas used by the renderers.
*/
Expand All @@ -971,6 +992,18 @@ export interface IXtermTerminal {
*/
readonly isStdinDisabled: boolean;

/**
* Whether the terminal is currently focused.
*/
readonly isFocused: boolean;

/**
* Attached the terminal to the given element
* @param container Container the terminal will be rendered in
* @param options Additional options for mounting the terminal in an element
*/
attachToElement(container: HTMLElement, options?: IXtermAttachToElementOptions): void;

findResult?: { resultIndex: number; resultCount: number };

/**
Expand All @@ -988,11 +1021,26 @@ export interface IXtermTerminal {
*/
forceRedraw(): void;

/**
* Writes data to the terminal.
*/
write(data: string | Uint8Array): void;

/**
* Resizes the terminal.
*/
resize(columns: number, rows: number): void;
connor4312 marked this conversation as resolved.
Show resolved Hide resolved

/**
* Gets the font metrics of this xterm.js instance.
*/
getFont(): ITerminalFont;

/**
* Prevents the terminal from handling keyboard events.
*/
setReadonly(): void;
connor4312 marked this conversation as resolved.
Show resolved Hide resolved

connor4312 marked this conversation as resolved.
Show resolved Hide resolved
/** Scroll the terminal buffer down 1 line. */ scrollDownLine(): void;
/** Scroll the terminal buffer down 1 page. */ scrollDownPage(): void;
/** Scroll the terminal buffer to the bottom. */ scrollToBottom(): void;
Expand Down Expand Up @@ -1021,6 +1069,11 @@ export interface IXtermTerminal {
*/
getBufferReverseIterator(): IterableIterator<string>;

/**
* Gets the buffer contents as HTML.
*/
getContentsAsHtml(): Promise<string>;

/**
* Refreshes the terminal after it has been moved.
*/
Expand Down
Loading