-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support "{char} registers and clipboard access via "* register. (#543)
* add register '*' * add copy-paste to access system clipboard * read and write to clipboard when register * is accessed * unit tests for registers * support alphanameric registers & update roadmap * trying to fix ci build * Fix gulp:tslint errors * use new test style in register.test.ts
- Loading branch information
1 parent
12d7927
commit 1744906
Showing
11 changed files
with
187 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
"use strict"; | ||
|
||
import { ModeHandler } from "../../src/mode/modeHandler"; | ||
import { setupWorkspace, cleanUpWorkspace, assertEqualLines } from '../testUtils'; | ||
import { getTestingFunctions } from '../testSimplifier'; | ||
import * as clipboard from 'copy-paste'; | ||
|
||
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"], | ||
}); | ||
|
||
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 use two registers together", | ||
start: ['|one', "two"], | ||
keysPressed: '"*yyjyy"*pp', | ||
end: ["one", "two", "one", "|two"], | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Generated by typings | ||
// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/5421783adfaf9b99e9274f4488cfc0ee73f17a56/copy-paste/copy-paste.d.ts | ||
declare module 'copy-paste' { | ||
|
||
export type CopyCallback = (err: Error) => void; | ||
export type PasteCallback = (err: Error, content: string) => void; | ||
|
||
/** | ||
* Asynchronously replaces the current contents of the clip board with text. | ||
* | ||
* @param {T} content Takes either a string, array, object, or readable stream. | ||
* @return {T} Returns the same value passed in. | ||
*/ | ||
export function copy<T>(content: T): T; | ||
|
||
/** | ||
* Asynchronously replaces the current contents of the clip board with text. | ||
* | ||
* @param {T} content Takes either a string, array, object, or readable stream. | ||
* @param {CopyCallback} callback will fire when the copy operation is complete. | ||
* @return {T} Returns the same value passed in. | ||
*/ | ||
export function copy<T>(content: T, callback: CopyCallback): T; | ||
|
||
|
||
/** | ||
* Synchronously returns the current contents of the system clip board. | ||
* | ||
* Note: The synchronous version of paste is not always availabled. | ||
* An error message is shown if the synchronous version of paste is used on an unsupported platform. | ||
* The asynchronous version of paste is always available. | ||
* | ||
* @return {string} Returns the current contents of the system clip board. | ||
*/ | ||
export function paste(): string; | ||
|
||
/** | ||
* Asynchronously returns the current contents of the system clip board. | ||
* | ||
* @param {PasteCallback} callback The contents of the system clip board are passed to the callback as the second parameter. | ||
*/ | ||
export function paste(callback: PasteCallback): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"resolution": "main", | ||
"tree": { | ||
"src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/5421783adfaf9b99e9274f4488cfc0ee73f17a56/copy-paste/copy-paste.d.ts", | ||
"raw": "registry:dt/copy-paste#1.1.3+20160117130525", | ||
"typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/5421783adfaf9b99e9274f4488cfc0ee73f17a56/copy-paste/copy-paste.d.ts" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters