-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[vscode] Support EnvironmentVariableCollection description #12696
* show information in UI Contributed on behalf of STMicroelectronics Signed-off-by: Johannes Faltermeier <[email protected]>
- Loading branch information
1 parent
f45ef07
commit 60625a5
Showing
9 changed files
with
183 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
packages/terminal/src/browser/terminal-info-toolbar-item.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
// ***************************************************************************** | ||
// Copyright (C) 2023 STMicroelectronics and others. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License v. 2.0 which is available at | ||
// http://www.eclipse.org/legal/epl-2.0. | ||
// | ||
// This Source Code may also be made available under the following Secondary | ||
// Licenses when the conditions for such availability set forth in the Eclipse | ||
// Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
// with the GNU Classpath Exception which is available at | ||
// https://www.gnu.org/software/classpath/license.html. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 | ||
// ***************************************************************************** | ||
import { ReactTabBarToolbarItem } from '@theia/core/lib/browser/shell/tab-bar-toolbar'; | ||
import { ReactNode } from '@theia/core/shared/react'; | ||
import React = require('@theia/core/shared/react'); | ||
import { HoverService } from '@theia/core/lib/browser'; | ||
import { TerminalWidget } from './base/terminal-widget'; | ||
import { MarkdownRenderer } from '@theia/core/lib/browser/markdown-rendering/markdown-renderer'; | ||
import { MarkdownStringImpl } from '@theia/core/lib/common/markdown-rendering/markdown-string'; | ||
import { DisposableCollection } from '@theia/core'; | ||
|
||
export class TerminalInfoToolbarItem implements ReactTabBarToolbarItem { | ||
readonly id = 'terminal:info'; | ||
|
||
protected toDispose = new DisposableCollection(); | ||
|
||
constructor( | ||
protected readonly hoverService: HoverService, | ||
protected readonly terminal: () => TerminalWidget | undefined, | ||
protected readonly markdownRenderer: MarkdownRenderer | ||
) {} | ||
|
||
render(): ReactNode { | ||
return ( | ||
<div | ||
id={this.id} | ||
className='codicon codicon-terminal-bash action-label' | ||
onMouseEnter={e => this.onMouseEnter(e)} | ||
onMouseLeave={this.onMouseEnter} | ||
></div> | ||
); | ||
} | ||
|
||
protected async onMouseEnter( | ||
event: React.MouseEvent<HTMLElement, MouseEvent> | ||
): Promise<void> { | ||
const currentTarget = event.currentTarget; | ||
const currentTerminal = this.terminal(); | ||
if (currentTerminal) { | ||
const extensions = await currentTerminal.contributingExtensions; | ||
const processId = await currentTerminal.processId; | ||
const processInfo = await currentTerminal.processInfo; | ||
|
||
const mainDiv = document.createElement('div'); | ||
|
||
const pid = document.createElement('div'); | ||
pid.textContent = 'Process ID: ' + processId; | ||
mainDiv.appendChild(pid); | ||
|
||
const commandLine = document.createElement('div'); | ||
commandLine.textContent = | ||
'Command line: ' + | ||
processInfo.executable + | ||
' ' + | ||
processInfo.arguments.join(' '); | ||
mainDiv.appendChild(commandLine); | ||
|
||
mainDiv.appendChild(document.createElement('hr')); | ||
|
||
const header = document.createElement('div'); | ||
header.textContent = | ||
'The following extensions have contributed to this terminal\'s environment:'; | ||
mainDiv.appendChild(header); | ||
|
||
const list = document.createElement('ul'); | ||
mainDiv.appendChild(list); | ||
|
||
extensions.forEach((value, key) => { | ||
const item = document.createElement('li'); | ||
let markdown; | ||
if (value === undefined) { | ||
markdown = new MarkdownStringImpl(''); | ||
markdown.appendText(key); | ||
} else if (typeof value === 'string') { | ||
markdown = new MarkdownStringImpl(''); | ||
markdown.appendText(key + ': ' + value); | ||
} else { | ||
markdown = new MarkdownStringImpl('', value); | ||
markdown.appendText(key + ': '); | ||
markdown.appendMarkdown(value.value); | ||
} | ||
const result = this.markdownRenderer.render(markdown); | ||
this.toDispose.push(result); | ||
item.appendChild(result.element); | ||
list.appendChild(item); | ||
}); | ||
|
||
this.hoverService.requestHover({ | ||
content: mainDiv, | ||
target: currentTarget, | ||
position: 'right', | ||
}); | ||
} | ||
} | ||
|
||
protected async onMouseLeave(): Promise<void> { | ||
this.toDispose.dispose(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters