本文整理汇总了TypeScript中copy-paste.copy函数的典型用法代码示例。如果您正苦于以下问题:TypeScript copy函数的具体用法?TypeScript copy怎么用?TypeScript copy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了copy函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test("put ' brown' into 'the dog'", async () => {
const phrase = "brown ";
const expectedText = `the ${phrase}dog`;
const position = new Position(0, 3, PositionOptions.CharacterWiseExclusive);
const mode = new ModeHandler();
const put = new PutOperator(mode);
copy(phrase);
// using ^ to show the cusor position
// before : the dog
// ^
// after : the brown dog
// ^
await put.run(position, position);
const actualText = TextEditor.readLineAt(0);
const cursorPosition = vscode.window.activeTextEditor.selection.active;
assert.equal(actualText, expectedText,
"did not paste expected content");
assert.equal(cursorPosition.line, position.getRight().line,
"cursor should be on the same line");
assert.equal(cursorPosition.character, position.getRight().character,
"cursor should be on start of put content");
});
示例2:
return new Promise<string>((resolve, reject) => {
clipboard.copy(text, (err: any, result: string) => {
if (err) {
reject(err);
return;
}
resolve(result);
});
});
示例3: RegExp
(up): void => {
const text = up.inlines.join('\n');
const foundPatterns = [];
text.replace(new RegExp(up.userinputs[0], 'g'), (all, ...p) => {
const len = p.length - 2;
const captures = [];
for (let i = 0; i < len; i++) {
captures.push(p[i]);
}
foundPatterns.push(captures.join('\t'));
return all;
});
copyPaste.copy(foundPatterns.join('\n'));
});
示例4:
vscode.window.showInformationMessage.apply(vscode.window, args).then((cmd) => {
if (cmd === "Copy") {
copypaste.copy(value);
}
if (cmd === "Insert") {
var activeEditor = vscode.window.activeTextEditor;
if (activeEditor && activeEditor.selection && activeEditor.selection.active) {
activeEditor.edit((editor) => {
editor.insert(activeEditor.selection.active, value);
});
}
}
});
示例5: suite
suite("register", () => {
let modeHandler: ModeHandler = new ModeHandler();
let {
newTest,
newTestOnly,
} = getTestingFunctions(modeHandler);
setup(async () => {
await setupWorkspace();
});
suiteTeardown(cleanUpWorkspace);
newTest({
title: "Can copy to a register",
start: ['|one', 'two'],
keysPressed: '"add"ap',
end: ["two", "|one"],
});
clipboard.copy("12345");
newTest({
title: "Can access '*' (clipboard) register",
start: ['|one'],
keysPressed: '"*P',
end: ["1234|5one"],
});
newTest({
title: "Can access '+' (clipboard) register",
start: ['|one'],
keysPressed: '"+P',
end: ["1234|5one"],
});
newTest({
title: "Can use two registers together",
start: ['|one', "two"],
keysPressed: '"ayyj"byy"ap"bp',
end: ["one", "two", "one", "|two"],
});
});
示例6: copyIds
function copyIds() {
let e = wing.window.activeTextEditor;
if (!e) {
return;
}
let fileName = e.document.fileName;
let ext = path.extname(fileName);
if (ext != '.exml') {
return;
}
let content = e.document.getText();
let result = findIds(content);
if (result) {
clipboard.copy(result, () => {
wing.window.showInformationMessage("已成功解析exml中id,并复制对应的ts代码到剪切板,可使用粘贴操作到指定位置.");
});
} else {
wing.window.showInformationMessage("exml中不存在id属性的节点.");
}
}
示例7: 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; });
示例8:
.then(onlineLink => {
copyPaste.copy(onlineLink);
vscode.window.showInformationMessage("The link has been copied to the clipboard.");
});
示例9: suite
suite("register", () => {
let modeHandler: ModeHandler;
let {
newTest,
newTestOnly,
} = getTestingFunctions();
setup(async () => {
await setupWorkspace();
modeHandler = new ModeHandler();
});
suiteTeardown(cleanUpWorkspace);
newTest({
title: "Can copy to a register",
start: ['|one', 'two'],
keysPressed: '"add"ap',
end: ["two", "|one"],
});
clipboard.copy("12345");
newTest({
title: "Can access '*' (clipboard) register",
start: ['|one'],
keysPressed: '"*P',
end: ["1234|5one"],
});
newTest({
title: "Can access '+' (clipboard) register",
start: ['|one'],
keysPressed: '"+P',
end: ["1234|5one"],
});
newTest({
title: "Can use two registers together",
start: ['|one', "two"],
keysPressed: '"ayyj"byy"ap"bp',
end: ["one", "two", "one", "|two"],
});
test("Yank stores text in Register '0'", async () => {
modeHandler.vimState.editor = vscode.window.activeTextEditor!;
await modeHandler.handleMultipleKeyEvents(
'itest1\ntest2\ntest3'.split('')
);
await modeHandler.handleMultipleKeyEvents([
'<Esc>',
'g', 'g',
'y', 'y',
'j',
'y', 'y',
'g', 'g',
'd', 'd',
'"', '0',
'P'
]);
assertEqualLines([
'test2',
'test2',
'test3'
]);
});
test("Register '1'-'9' stores delete content", async () => {
modeHandler.vimState.editor = vscode.window.activeTextEditor!;
await modeHandler.handleMultipleKeyEvents(
'itest1\ntest2\ntest3\n'.split('')
);
await modeHandler.handleMultipleKeyEvents([
'<Esc>',
'g', 'g',
'd', 'd',
'd', 'd',
'd', 'd',
'"', '1', 'p',
'"', '2', 'p',
'"', '3', 'p'
]);
assertEqualLines([
'',
'test3',
'test2',
'test1'
]);
});
test("\"A appends linewise text to \"a", async() => {
modeHandler.vimState.editor = vscode.window.activeTextEditor!;
//.........这里部分代码省略.........