当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript vscode.env.clipboard类代码示例

本文整理汇总了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}>` : ''}`
        );
    }
开发者ID:eamodio,项目名称:vscode-git-codelens,代码行数:7,代码来源:viewCommands.ts

示例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');
        }
    }
开发者ID:chrisleaman,项目名称:vscode-gitlens,代码行数:51,代码来源:copyShaToClipboard.ts

示例3: writeBytecodeToBuffer

  export async function writeBytecodeToBuffer(uri: Uri): Promise<void> {
    const contract = await readCompiledContract(uri);

    env.clipboard.writeText(contract[Constants.contractProperties.bytecode]);
  }
开发者ID:chrisseg,项目名称:vscode-azure-blockchain-ethereum,代码行数:5,代码来源:TruffleCommands.ts

示例4: writeAbiToBuffer

  export async function writeAbiToBuffer(uri: Uri): Promise<void> {
    const contract = await readCompiledContract(uri);

    env.clipboard.writeText(JSON.stringify(contract[Constants.contractProperties.abi]));
  }
开发者ID:chrisseg,项目名称:vscode-azure-blockchain-ethereum,代码行数:5,代码来源:TruffleCommands.ts

示例5: addDataInClipboard

 export async function addDataInClipboard(typeOfData: string, data?: string | null) {
   if (data) {
     await env.clipboard.writeText(data);
     window.showInformationMessage(typeOfData + Constants.dataCopied);
   }
 }
开发者ID:chrisseg,项目名称:vscode-azure-blockchain-ethereum,代码行数:6,代码来源:AzureBlockchain.ts


注:本文中的vscode.env.clipboard类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。