當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript env.clipboard.writeText方法代碼示例

本文整理匯總了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}>` : ''}`
        );
    }
開發者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.writeText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。