Another simple extension which remembers last few copied texts and allow you to access them and paste back whenever needed. This will capture Ctrl+C keystrokes and store selected text in its own internal array. Then you can invoke the hot-key Ctrl+Alt+V to launch QuickOpen
window, select and paste back.
This extension won't change how you normally copy text (i.e. Ctrl+C), but it seamlessly keeps history of copied texts for future reference. Clopboard history is really important when you need to copy segments from multiple locations of and paste in another location. Normally you have to copy and paste each segment one after another. But with this extension you can keep on copying these segments and then paste them all in one go.
There are some limitations, but considering 99% of common usage, these limitations won't be that significant.
-
Use Ctrl+C as usual to copy texts and continue work on editor. In background
ClipBox
will capture texts and store. -
Hit Ctrl+Alt+V to invoke
QuickOpen
box to see the history of copied texts, and use Up and Down arrow keys to navigate through the entries. Then hit Enter to paste the selected entry back to the editor. -
Hit Ctrl+Alt+E to clear the stored history.
-
This will store maximum of 10 history entries.
-
No Cut, only Copy In ideal environment this should capture both
Copy
andCut
functionality. However I implemented this just by handling the key event and then accessing the editor. DuringCopy
operation selected text is available on the editor so we can capture a copy of it. But in the event ofCut
system has already removed selected text from the editor so unless you directly access clipboard we don't have access to this text. I'm still not sure how to access clipboard directly using Javascript in this environment so left it for future enhancements.- I could have used direct key binding using
KeyBindingManager
to capture both Ctrl+C and Ctrl+X commands, then I would have implemented both scenarios successfully. Problem is that event brackets editor itself avodes ignoreCommand handling these native commands by itself. Main thing is I just wanted to implement this as a supplementary feature without breaking most primary functionality that any editor has.
- I could have used direct key binding using
-
Won't handle menu action This won't respond if you copy using the
Edit -> Copy
menu option. Because with my knowledge I have so far related to brackets, I cannot register another event handler to same command, so I don't know how to know whether user clicks on this menu item.
-
Didn't want to introduce new hot key to make this extension usable, which will hinder the normal editor usage, instead you can use usual Ctrl+C key combination and extension will capture and build its own clipboard.
-
Didn't use
KeyBindingManaer
to capture the keyevent mainly because these are primary key combinations for any editor so didn't want to mess with them. -
Utilized the
QuickOpen
plugin to show the stored clipboard history as it is easy to navigate and select history item. -
Even though it uses
QuickOpen
it doesn't do any filtering mainly because this isn't a search feature. (probably in future releases)
- Capture both
Cut
andCopy
operations. - Handle
Edit -> Cut
andEdit -> Copy
menu actions. - Filter entries by search string.
- My assumption is that lodash available directly to any extension as it was mentioned in http://brackets.io/docs/current/modules/utils/StringUtils.html#-htmlEscape to use
_.escape()
instead ofhtmlEscape()
, I'm still not sure whether lodash_
is directly available or not. However in order to fix the issue raised by Tomas, I will be use own copy of lodash together with this extension.
- Settings dialog, Now you can change number of history entries and customize shortcut key combinations. (Note: you need to restart brackets in order to apply new shortcut settings)
- Seperated language specific strings to support localization. However it only supports English in this release.
- Code cleanup
Initial release with main functionality.