本文整理汇总了TypeScript中vscode.env.clipboard.writeText方法的典型用法代码示例。如果您正苦于以下问题:TypeScript env.clipboard.writeText方法的具体用法?TypeScript env.clipboard.writeText怎么用?TypeScript env.clipboard.writeText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vscode.env.clipboard
的用法示例。
在下文中一共展示了env.clipboard.writeText方法的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);
}
}