-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow to copy non interactive shell output
- Loading branch information
1 parent
5a67e65
commit a186930
Showing
12 changed files
with
147 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { LitElement, css, html } from 'lit' | ||
import { customElement, property } from 'lit/decorators.js' | ||
|
||
import '@vscode/webview-ui-toolkit/dist/button/index' | ||
|
||
import { getContext } from '../utils' | ||
import { ClientMessage } from '../../types' | ||
import { ClientMessages } from '../../constants' | ||
|
||
@customElement('shell-output-items') | ||
export class ShellOutputItems extends LitElement { | ||
// Define scoped styles right with your component, in plain CSS | ||
static styles = css` | ||
.output-items { | ||
display: flex; | ||
width: 101%; | ||
justify-content: flex-end; | ||
} | ||
vscode-button { | ||
background: transparent; | ||
color: #ccc; | ||
transform: scale(.9); | ||
} | ||
vscode-button:hover { | ||
background: var(--button-secondary-background); | ||
} | ||
vscode-button:focus { | ||
outline: #007fd4 1px solid; | ||
} | ||
.icon { | ||
width: 13px; | ||
margin: 0 5px 0 -5px; | ||
padding: 0; | ||
} | ||
` | ||
|
||
@property({ type: String }) | ||
content = '' | ||
|
||
// Render the UI as a function of component state | ||
render() { | ||
return html`<section class="output-items"> | ||
<vscode-button appearance="secondary" @click="${this.#copy}"> | ||
<svg | ||
class="icon" width="16" height="16" viewBox="0 0 16 16" | ||
xmlns="http://www.w3.org/2000/svg" fill="currentColor" | ||
> | ||
<path fill-rule="evenodd" clip-rule="evenodd" | ||
d="M4 4l1-1h5.414L14 6.586V14l-1 1H5l-1-1V4zm9 3l-3-3H5v10h8V7z"/> | ||
<path fill-rule="evenodd" clip-rule="evenodd" | ||
d="M3 1L2 2v10l1 1V2h6.414l-1-1H3z"/> | ||
</svg> | ||
Copy | ||
</vscode-button> | ||
</span>` | ||
} | ||
|
||
#copy () { | ||
const ctx = getContext() | ||
|
||
if (!ctx.postMessage) { | ||
return | ||
} | ||
|
||
return navigator.clipboard.writeText(this.content).then( | ||
() => ctx.postMessage!(<ClientMessage<ClientMessages.infoMessage>>{ | ||
type: ClientMessages.infoMessage, | ||
output: 'Copied result content to clipboard!' | ||
}), | ||
(err) => ctx.postMessage!(<ClientMessage<ClientMessages.errorMessage>>{ | ||
type: ClientMessages.errorMessage, | ||
output: `'Failed to copy to clipboard: ${err.message}!'` | ||
}) | ||
) | ||
} | ||
} |
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
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