本文整理匯總了TypeScript中vscode.env.clipboard類的典型用法代碼示例。如果您正苦於以下問題:TypeScript env.clipboard類的具體用法?TypeScript env.clipboard怎麽用?TypeScript env.clipboard使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了env.clipboard類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: contributorCopyToClipboard
private async contributorCopyToClipboard(node: ContributorNode) {
if (!(node instanceof ContributorNode)) return;
await env.clipboard.writeText(
`${node.contributor.name}${node.contributor.email ? ` <${node.contributor.email}>` : ''}`
);
}
示例2: execute
async execute(editor?: TextEditor, uri?: Uri, args: CopyShaToClipboardCommandArgs = {}) {
uri = getCommandUri(uri, editor);
try {
args = { ...args };
// If we don't have an editor then get the sha of the last commit to the branch
if (uri == null) {
const repoPath = await Container.git.getActiveRepoPath(editor);
if (!repoPath) return undefined;
const log = await Container.git.getLog(repoPath, { maxCount: 1 });
if (!log) return undefined;
args.sha = Iterables.first(log.commits.values()).sha;
}
else if (args.sha === undefined) {
const blameline = (editor && editor.selection.active.line) || 0;
if (blameline < 0) return undefined;
try {
const gitUri = await GitUri.fromUri(uri);
const blame =
editor && editor.document && editor.document.isDirty
? await Container.git.getBlameForLineContents(gitUri, blameline, editor.document.getText())
: await Container.git.getBlameForLine(gitUri, blameline);
if (blame === undefined) return undefined;
args.sha = blame.commit.sha;
}
catch (ex) {
Logger.error(ex, 'CopyShaToClipboardCommand', `getBlameForLine(${blameline})`);
return Messages.showGenericErrorMessage('Unable to copy commit id');
}
}
void (await env.clipboard.writeText(args.sha));
return undefined;
}
catch (ex) {
if (ex.message.includes("Couldn't find the required `xsel` binary")) {
window.showErrorMessage(
'Unable to copy commit id, xsel is not installed. Please install it via your package manager, e.g. `sudo apt install xsel`'
);
return undefined;
}
Logger.error(ex, 'CopyShaToClipboardCommand');
return Messages.showGenericErrorMessage('Unable to copy commit id');
}
}
示例3: writeBytecodeToBuffer
export async function writeBytecodeToBuffer(uri: Uri): Promise<void> {
const contract = await readCompiledContract(uri);
env.clipboard.writeText(contract[Constants.contractProperties.bytecode]);
}
示例4: writeAbiToBuffer
export async function writeAbiToBuffer(uri: Uri): Promise<void> {
const contract = await readCompiledContract(uri);
env.clipboard.writeText(JSON.stringify(contract[Constants.contractProperties.abi]));
}
示例5: addDataInClipboard
export async function addDataInClipboard(typeOfData: string, data?: string | null) {
if (data) {
await env.clipboard.writeText(data);
window.showInformationMessage(typeOfData + Constants.dataCopied);
}
}