本文整理汇总了TypeScript中copy-paste.paste函数的典型用法代码示例。如果您正苦于以下问题:TypeScript paste函数的具体用法?TypeScript paste怎么用?TypeScript paste使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了paste函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: callRestService
let restJson2ts = vscode.commands.registerCommand("rest.json2ts", () => {
copyPaste.paste((error, content) => {
if (content && content.indexOf("http") > -1) {
callRestService(content);
} else {
vscode.window.showInputBox({ prompt: "Insert your REST-Service URL." })
.then((userInput) => {
if (userInput && userInput.indexOf("http") > -1) {
callRestService(userInput);
} else {
vscode.window.showErrorMessage("No valid REST-Service URL.");
}
});
}
});
function callRestService(url: string) {
vscode.window.setStatusBarMessage("Call " + url + "...");
request(url, (error, response, body) => {
if (extension.isJson(body)) {
convert(body);
} else {
vscode.window.showErrorMessage("REST-Service has no valid JSON result.");
}
});
}
});
示例2: getSelection
const disposable = vscode.commands.registerCommand("extension.consoleWrapper", () => {
const editor = vscode.window.activeTextEditor;
if (!editor) {
return;
}
const expandedSelection = getSelection(editor);
if (expandedSelection) {
const text = editor.document.getText(expandedSelection);
if (text) {
editor.edit((currentText) => {
currentText.insert(new vscode.Position(expandedSelection.end.line, 100000), consoleWrapper.wrap(text, getLineIndentation(expandedSelection)));
});
}
} else {
paste((cb, clipboardContent) => {
if (!!clipboardContent) {
const selection = editor.selection;
editor.edit((currentText) => {
currentText.insert(new vscode.Position(selection.active.line, selection.active.character), consoleWrapper.wrap(clipboardContent));
});
}
});
}
});
示例3: convertUrlJsonToTs
function convertUrlJsonToTs() {
copyPaste.paste((error, content) => {
if (content.indexOf("http") > -1) {
request(content, (error, response, body) => {
convert(body);
});
}
});
}
示例4: convert
let clipboardJson2ts = vscode.commands.registerCommand("convert.json2ts", () => {
copyPaste.paste((error, content) => {
if (extension.isJson(content)) {
convert(content);
} else {
vscode.window.showErrorMessage("Clipboard has no valid JSON content.");
}
});
});
示例5: test
test("delete should copy to clipboard", async () => {
const expectedText = "Hello World";
await TextEditor.insert(expectedText);
const range = vscode.window.activeTextEditor.document.lineAt(0).range;
await TextEditor.delete(range);
const actualText = paste();
assert.equal(actualText, expectedText);
});
示例6:
return new Promise<string>((resolve, reject) => {
clipboard.paste((err: any, result: string) => {
if (err) {
reject(err);
return;
}
resolve(result);
});
});
示例7: paste
return new Promise<void>((resolve, reject) => {
paste(async (err, data) => {
if (err) {
reject();
} else {
await TextEditor.insertAt(data, start.getRight());
this.modeHandler.currentMode.motion.moveTo(start.line, start.getRight().character);
resolve();
}
});
});
示例8: convert
let clipboardJson2ts = vscode.commands.registerCommand("convert.json2ts", () => {
copyPaste.paste((error, content) => {
if (error == null) {
if (extension.isJson(content)) {
convert(content);
} else {
vscode.window.showErrorMessage("Clipboard has no valid JSON content.");
}
} else {
if (error["path"] == "xclip") {
vscode.window.showErrorMessage("Clipboard can not be read. Have you installed xclip?");
} else {
vscode.window.showErrorMessage("Clipboard can not be read.");
}
}
});
});
示例9: TestClass
/// <reference types="node" />
import * as CopyPaste from 'copy-paste';
class TestClass {}
let strRet: string = CopyPaste.copy("content");
strRet = CopyPaste.copy("content", (err: Error) => { return; });
let objRet: TestClass = CopyPaste.copy(new TestClass());
objRet = CopyPaste.copy(new TestClass(), (err: Error) => { return; });
strRet = CopyPaste.paste();
CopyPaste.paste((err: Error, content: string) => { return; });
示例10: convertJsonToTs
function convertJsonToTs() {
copyPaste.paste((error, content) => {
convert(content);
});
}