-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support "{char} registers and clipboard access via "* register. #543
Changes from 5 commits
2dfa17c
321de69
323a62b
60e2ed2
f3ecd40
3809e76
b7d21de
bf4f2a7
20610e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
"use strict"; | ||
|
||
import { ModeHandler } from "../../src/mode/modeHandler"; | ||
import { setupWorkspace, cleanUpWorkspace, assertEqualLines } from '../testUtils'; | ||
|
||
suite("register", () => { | ||
|
||
let modeHandler: ModeHandler; | ||
|
||
setup(async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer these to be done in the style of newTest - I find that to be much easier to read. :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, feel free to comment on things I've missed ;-) I will fix them tomorrow (3am here) Get Outlook for Android On Mon, Aug 1, 2016 at 2:57 AM +0430, "Grant Mathews" notifications@github.com wrote:
I would prefer these to be done in the style of newTest - I find that to be much easier to read. :) You are receiving this because you authored the thread. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @johnfn Where can i find an example of "style of newTest" you mentioned ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. modeNormal.test.ts is a good place to look. :) |
||
await setupWorkspace(); | ||
|
||
modeHandler = new ModeHandler(); | ||
}); | ||
|
||
suiteTeardown(cleanUpWorkspace); | ||
|
||
test("basic register put test", async () => { | ||
await modeHandler.handleMultipleKeyEvents( | ||
'iblah blah'.split('') | ||
); | ||
|
||
await modeHandler.handleMultipleKeyEvents([ | ||
'<esc>', | ||
'^', '"', '"', 'D', '"', '"', 'p', '"', '"', 'p' | ||
]); | ||
|
||
await assertEqualLines(["blah blahblah blah"]); | ||
}); | ||
|
||
test("test yy and '*' register", async () => { | ||
await modeHandler.handleMultipleKeyEvents( | ||
'iblah blah\nblah'.split('') | ||
); | ||
|
||
await modeHandler.handleMultipleKeyEvents([ | ||
'<esc>', | ||
'^', '"', '*', 'y', 'y', '"', '*', 'p' | ||
]); | ||
|
||
await assertEqualLines(["blah blah", "blah", "blah"]); | ||
}); | ||
|
||
test("test two seperate registers", async () => { | ||
await modeHandler.handleMultipleKeyEvents( | ||
'iblah blah\nblah'.split('') | ||
); | ||
/* Register '"' is the default register */ | ||
await modeHandler.handleMultipleKeyEvents([ | ||
'<esc>', | ||
'g', 'g', '"', '*', 'y', 'y', 'j', 'y', 'y', '"', '*', 'p', 'p', | ||
]); | ||
|
||
await assertEqualLines(["blah blah", "blah", "blah blah", "blah"]); | ||
}); | ||
|
||
}); |
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; | ||
} |
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" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, this is excellent.
(Yay, someone understands my abstractions... other than me... hehe)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've done a great job designing project source code, well done @johnfn 👍