├── .gitignore ├── keymaps └── clipboard-plus.cson ├── .travis.yml ├── styles └── clipboard-plus.less ├── menus └── clipboard-plus.cson ├── CHANGELOG.md ├── package.json ├── LICENSE.md ├── lib ├── clipboard-list-view.coffee ├── main.coffee └── clipboard-items.coffee ├── README.md ├── spec ├── clipboard-plus-spec.coffee └── clipboard-items-spec.coffee └── coffeelint.json /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | npm-debug.log 3 | node_modules 4 | -------------------------------------------------------------------------------- /keymaps/clipboard-plus.cson: -------------------------------------------------------------------------------- 1 | '.select-list.with-action': 2 | 'tab': 'select-list:select-action' 3 | 'ctrl-i': 'select-list:select-action' 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | 3 | notifications: 4 | email: 5 | on_success: never 6 | on_failure: change 7 | 8 | script: 'curl -s https://raw.githubusercontent.com/atom/ci/master/build-package.sh | sh' -------------------------------------------------------------------------------- /styles/clipboard-plus.less: -------------------------------------------------------------------------------- 1 | @import "ui-variables"; 2 | 3 | atom-panel.clipboard-plus { 4 | .select-list ol.list-group { 5 | li { 6 | pre { 7 | background: transparent; 8 | .character-match { 9 | color: @text-color-highlight; 10 | font-weight: bold; 11 | } 12 | } 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /menus/clipboard-plus.cson: -------------------------------------------------------------------------------- 1 | # See https://atom.io/docs/latest/hacking-atom-package-word-count#menus for more details 2 | 'menu': [ 3 | { 4 | 'label': 'Packages' 5 | 'submenu': [ 6 | 'label': 'Clipboard Plus' 7 | 'submenu': [ 8 | { 9 | 'label': 'Toggle' 10 | 'command': 'clipboard-plus:toggle' 11 | } 12 | { 13 | 'label': 'Clear' 14 | 'command': 'clipboard-plus:clear' 15 | } 16 | ] 17 | ] 18 | } 19 | ] 20 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.5.1 2 | * Replace SelectListActionView with @aki77/atom-select-action 3 | 4 | ## 0.5.0 5 | * Update view 6 | * Support remove one item 7 | 8 | ## 0.4.2 9 | * Remove keymaps/clipboard-plus.cson 10 | 11 | ## 0.4.1 12 | * Fix #3 13 | 14 | ## 0.4.0 15 | * ui improvements 16 | 17 | ## 0.3.0 18 | * Support services api 19 | 20 | ## 0.2.1 21 | * Update README 22 | 23 | ## 0.2.0 24 | * Basic support system clipboard 25 | 26 | ## 0.1.0 - First Release 27 | * Every feature added 28 | * Every bug fixed 29 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "clipboard-plus", 3 | "main": "./lib/main", 4 | "version": "0.5.1", 5 | "description": "Keeps your clipboard history.", 6 | "keywords": [ 7 | "clipboard", 8 | "kill-ring", 9 | "emacs" 10 | ], 11 | "repository": "https://github.com/aki77/atom-clipboard-plus", 12 | "license": "MIT", 13 | "engines": { 14 | "atom": ">=0.174.0 <2.0.0" 15 | }, 16 | "dependencies": { 17 | "@aki77/atom-select-action": "^0.1.0", 18 | "fuzzaldrin": "^2.1.0" 19 | }, 20 | "providedServices": { 21 | "clipboard-plus": { 22 | "description": "", 23 | "versions": { 24 | "0.1.0": "provide" 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /lib/clipboard-list-view.coffee: -------------------------------------------------------------------------------- 1 | {match} = require 'fuzzaldrin' 2 | ActionSelectListView = require '@aki77/atom-select-action' 3 | 4 | module.exports = 5 | class ClipboardListView extends ActionSelectListView 6 | panelClass: 'clipboard-plus' 7 | 8 | constructor: (@clipboardItems) -> 9 | super({ 10 | items: @getItems 11 | filterKey: 'text' 12 | actions: [ 13 | { 14 | name: 'Paste' 15 | callback: @paste 16 | } 17 | { 18 | name: 'Remove' 19 | callback: @remove 20 | } 21 | ] 22 | }) 23 | 24 | @registerPasteAction(@defaultPasteAction) 25 | 26 | getItems: => 27 | @clipboardItems.entries().reverse() 28 | 29 | # Insert item in clipboardItems and set item to the head 30 | paste: (item) => 31 | @clipboardItems.delete(item) 32 | atom.clipboard.write(item.text, item.metadata) 33 | editor = atom.workspace.getActiveTextEditor() 34 | @pasteAction(editor, item) 35 | 36 | remove: (item) => 37 | @clipboardItems.delete(item) 38 | 39 | registerPasteAction: (fn) -> 40 | @pasteAction = fn 41 | 42 | defaultPasteAction: (editor, item) -> 43 | editor.pasteText() 44 | 45 | contentForItem: ({text}, filterQuery) => 46 | matches = match(text, filterQuery) 47 | {truncateText} = this 48 | 49 | ({highlighter}) -> 50 | @li => 51 | @div => 52 | @pre -> highlighter(truncateText(text), matches, 0) 53 | 54 | truncateText: (text) -> 55 | maximumLinesNumber = atom.config.get('clipboard-plus.maximumLinesNumber') 56 | return text if maximumLinesNumber is 0 57 | return text if text.split("\n").length <= maximumLinesNumber 58 | 59 | newText = text.split("\n").slice(0, maximumLinesNumber).join("\n") 60 | "#{newText}[...]" 61 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # clipboard-plus package 2 | 3 | Keeps your clipboard history. 4 | [![Build Status](https://travis-ci.org/aki77/atom-clipboard-plus.svg)](https://travis-ci.org/aki77/atom-clipboard-plus) 5 | 6 | [![Gyazo](http://i.gyazo.com/48cfc66c8f8b7666efb7334d928f1a9e.gif)](http://gyazo.com/48cfc66c8f8b7666efb7334d928f1a9e) 7 | 8 | ## Features 9 | * can use the copy/cut command of core. 10 | * support for multiple cursors 11 | * basic support system clipboard 12 | * coexist with [emacs-plus package](https://atom.io/packages/emacs-plus). 13 | 14 | ## Commands 15 | * `clipboard-plus:toggle` 16 | * `clipboard-plus:clear` 17 | 18 | ## Keymap 19 | 20 | edit `~/.atom/keymap.cson` 21 | 22 | **general** 23 | 24 | ```coffeescript 25 | '.platform-darwin atom-text-editor:not([mini])': 26 | 'cmd-shift-v': 'clipboard-plus:toggle' 27 | 28 | '.platform-win32 atom-text-editor:not([mini])': 29 | 'ctrl-shift-v': 'clipboard-plus:toggle' 30 | 31 | '.platform-linux atom-text-editor:not([mini])': 32 | 'ctrl-shift-v': 'clipboard-plus:toggle' 33 | ``` 34 | 35 | **emacs user** 36 | 37 | ```coffeescript 38 | 'atom-text-editor:not([mini])': 39 | 'alt-y': 'clipboard-plus:toggle' 40 | ``` 41 | 42 | **vim user** 43 | 44 | Please use [vim-mode-clipboard-plus](https://atom.io/packages/vim-mode-clipboard-plus). 45 | 46 | ## Settings 47 | 48 | * `limit` (default: 50) 49 | * `unique` (default: true) 50 | * `minimumTextLength`: (default: 3) 51 | * `maximumTextLength`: (default: 1000) 52 | * `maximumLinesNumber`: (default: 5) 53 | 54 | ## Usage 55 | 56 | **remove one item from the history** 57 | 58 | [![Gyazo](http://i.gyazo.com/17d3a26bfb5b069b71aedb64acab846f.gif)](http://gyazo.com/17d3a26bfb5b069b71aedb64acab846f) 59 | 60 | ## TODO 61 | 62 | - [x] ui improvements 63 | - [x] watch system clipboard 64 | - [ ] Share a history with multiple projects 65 | - [x] remove one item from the history 66 | -------------------------------------------------------------------------------- /lib/main.coffee: -------------------------------------------------------------------------------- 1 | {CompositeDisposable} = require 'atom' 2 | ClipboardListView = null 3 | ClipboardItems = require './clipboard-items' 4 | 5 | module.exports = 6 | subscription: null 7 | clipboardListView: null 8 | 9 | config: 10 | limit: 11 | order: 1 12 | description: 'limit of the history count' 13 | type: 'integer' 14 | default: 50 15 | minimum: 2 16 | maximum: 500 17 | unique: 18 | order: 2 19 | description: 'remove duplicate' 20 | type: 'boolean' 21 | default: true 22 | minimumTextLength: 23 | order: 3 24 | type: 'integer' 25 | default: 3 26 | minimum: 1 27 | maximum: 10 28 | maximumTextLength: 29 | order: 4 30 | type: 'integer' 31 | default: 1000 32 | minimum: 10 33 | maximum: 5000 34 | maximumLinesNumber: 35 | order: 5 36 | type: 'integer' 37 | default: 5 38 | minimum: 0 39 | maximum: 20 40 | description: 'Max number of lines displayed per history.If zero (disabled), don\'t truncate candidate, show all.' 41 | 42 | activate: (state) -> 43 | @clipboardItems = new ClipboardItems(state.clipboardItemsState) 44 | 45 | @subscriptions = new CompositeDisposable 46 | @subscriptions.add(atom.commands.add('atom-text-editor', 47 | 'clipboard-plus:toggle': => @toggle() 48 | 'clipboard-plus:clear': => @clipboardItems.clear() 49 | )) 50 | @subscriptions.add(atom.config.onDidChange('clipboard-plus.useSimpleView', => 51 | @destroyView() 52 | )) 53 | 54 | deactivate: -> 55 | @subscriptions?.dispose() 56 | @subscriptions = null 57 | @clipboardItems?.destroy() 58 | @clipboardItems = null 59 | @destroyView() 60 | 61 | serialize: -> 62 | clipboardItemsState: @clipboardItems.serialize() 63 | 64 | toggle: -> 65 | @getView().toggle() 66 | 67 | provide: -> 68 | view = @getView() 69 | { 70 | registerPasteAction: view.registerPasteAction.bind(view) 71 | } 72 | 73 | getView: -> 74 | ClipboardListView ?= require './clipboard-list-view' 75 | @clipboardListView ?= new ClipboardListView(@clipboardItems) 76 | 77 | destroyView: -> 78 | @clipboardListView?.destroy() 79 | @clipboardListView = null 80 | -------------------------------------------------------------------------------- /lib/clipboard-items.coffee: -------------------------------------------------------------------------------- 1 | {CompositeDisposable, Disposable} = require 'atom' 2 | 3 | module.exports = 4 | class ClipboardItems 5 | limit: 15 6 | items: [] 7 | destroyed: false 8 | 9 | constructor: (state = {}) -> 10 | @subscriptions = new CompositeDisposable 11 | @subscriptions.add(@wrapClipboard()) 12 | @subscriptions.add(atom.config.observe('clipboard-plus.limit', (limit) => 13 | @limit = limit 14 | )) 15 | @items = state.items ? [] 16 | 17 | destroy: -> 18 | return if @destroyed 19 | @subscriptions?.dispose() 20 | @subscriptions = null 21 | @clear() 22 | @destroyed = true 23 | 24 | wrapClipboard: -> 25 | {clipboard} = atom 26 | {write, readWithMetadata} = clipboard 27 | 28 | clipboard.write = (text, metadata = {}) => 29 | ignore = metadata.ignore ? false 30 | delete metadata.ignore 31 | replace = metadata.replace ? false 32 | delete metadata.replace 33 | 34 | write.call(clipboard, text, metadata) 35 | return if ignore 36 | return if @isIgnoreText(text) 37 | 38 | {text, metadata} = clipboard.readWithMetadata() 39 | metadata ?= {} 40 | metadata.time = Date.now() 41 | 42 | @items.pop() if replace 43 | @push({text, metadata}) 44 | 45 | clipboard.readWithMetadata = -> 46 | result = readWithMetadata.call(clipboard) 47 | # copy from system clipboard to atom clipboard 48 | clipboard.write(result.text) unless result.hasOwnProperty('metadata') 49 | result 50 | 51 | new Disposable -> 52 | clipboard.write = write 53 | clipboard.readWithMetadata = readWithMetadata 54 | 55 | push: ({text, metadata}) -> 56 | @deleteByText(text) if atom.config.get('clipboard-plus.unique') 57 | @items.push({text, metadata}) 58 | deleteCount = @items.length - @limit 59 | @items.splice(0, deleteCount) if deleteCount > 0 60 | # console.log @items if atom.devMode 61 | 62 | size: -> 63 | @items.length 64 | 65 | delete: (item) -> 66 | @items.splice(@items.indexOf(item), 1) 67 | 68 | deleteByText: (text) -> 69 | @items = @items.filter((item) -> item.text isnt text) 70 | 71 | clear: -> 72 | @items.length = 0 73 | 74 | entries: -> 75 | @items.slice() 76 | 77 | get: (index) -> 78 | @items[index] 79 | 80 | serialize: -> 81 | items: @items.slice() 82 | 83 | syncSystemClipboard: -> 84 | atom.clipboard.readWithMetadata() 85 | this 86 | 87 | isIgnoreText: (text) -> 88 | return true if text.match(/^\s+$/) 89 | trimmed = text.trim() 90 | 91 | if trimmed.length < atom.config.get('clipboard-plus.minimumTextLength') 92 | return true 93 | if trimmed.length > atom.config.get('clipboard-plus.maximumTextLength') 94 | return true 95 | 96 | false 97 | -------------------------------------------------------------------------------- /spec/clipboard-plus-spec.coffee: -------------------------------------------------------------------------------- 1 | # Use the command `window:run-package-specs` (cmd-alt-ctrl-p) to run specs. 2 | # 3 | # To run a specific `it` or `describe` block add an `f` to the front (e.g. `fit` 4 | # or `fdescribe`). Remove the `f` to unfocus the block. 5 | 6 | describe "ClipboardPlus", -> 7 | [workspaceElement, editor, editorElement, clipboardPlus] = [] 8 | 9 | beforeEach -> 10 | workspaceElement = atom.views.getView(atom.workspace) 11 | jasmine.attachToDOM(workspaceElement) 12 | 13 | waitsForPromise -> 14 | atom.packages.activatePackage('clipboard-plus').then (pack) -> 15 | clipboardPlus = pack.mainModule 16 | 17 | waitsForPromise -> 18 | atom.workspace.open().then (_editor) -> 19 | editor = _editor 20 | editorElement = atom.views.getView(editor) 21 | 22 | describe "when the clipboard-plus:toggle event is triggered", -> 23 | it "hides and shows the modal panel", -> 24 | expect(workspaceElement.querySelector('.clipboard-plus')).not.toExist() 25 | atom.commands.dispatch editorElement, 'clipboard-plus:toggle' 26 | 27 | expect(workspaceElement.querySelector('.clipboard-plus')).toExist() 28 | 29 | clipboardPlusPanel = atom.workspace.getModalPanels()[0] 30 | expect(clipboardPlusPanel.isVisible()).toBe true 31 | atom.commands.dispatch editorElement, 'clipboard-plus:toggle' 32 | expect(clipboardPlusPanel.isVisible()).toBe false 33 | 34 | it "hides and shows the view", -> 35 | # This test shows you an integration test testing at the view level. 36 | expect(workspaceElement.querySelector('.clipboard-plus')).not.toExist() 37 | 38 | # This is an activation event, triggering it causes the package to be 39 | # activated. 40 | atom.commands.dispatch editorElement, 'clipboard-plus:toggle' 41 | 42 | # Now we can test for view visibility 43 | clipboardPlusElement = workspaceElement.querySelector('.clipboard-plus') 44 | expect(clipboardPlusElement).toBeVisible() 45 | atom.commands.dispatch editorElement, 'clipboard-plus:toggle' 46 | expect(clipboardPlusElement).not.toBeVisible() 47 | 48 | describe 'provide', -> 49 | [clipboardListView, clipboardItems, service] = [] 50 | 51 | beforeEach -> 52 | {clipboardItems} = clipboardPlus 53 | service = clipboardPlus.provide() 54 | 55 | it 'registerPasteAction', -> 56 | service.registerPasteAction((_editor, item) -> 57 | text = "hello #{item.text}" 58 | _editor.insertText(text) 59 | ) 60 | 61 | expect(editor.getText()).toBe('') 62 | atom.clipboard.write('world') 63 | 64 | atom.commands.dispatch(editorElement, 'clipboard-plus:toggle') 65 | clipboardListView = atom.workspace.getModalPanels()[0].getItem() 66 | 67 | clipboardListView.confirmed(clipboardItems.get(0)) 68 | expect(editor.getText()).toBe('hello world') 69 | -------------------------------------------------------------------------------- /coffeelint.json: -------------------------------------------------------------------------------- 1 | { 2 | "arrow_spacing": { 3 | "level": "ignore" 4 | }, 5 | "braces_spacing": { 6 | "level": "ignore", 7 | "spaces": 0, 8 | "empty_object_spaces": 0 9 | }, 10 | "camel_case_classes": { 11 | "level": "error" 12 | }, 13 | "coffeescript_error": { 14 | "level": "error" 15 | }, 16 | "colon_assignment_spacing": { 17 | "level": "ignore", 18 | "spacing": { 19 | "left": 0, 20 | "right": 0 21 | } 22 | }, 23 | "cyclomatic_complexity": { 24 | "value": 10, 25 | "level": "ignore" 26 | }, 27 | "duplicate_key": { 28 | "level": "error" 29 | }, 30 | "empty_constructor_needs_parens": { 31 | "level": "ignore" 32 | }, 33 | "ensure_comprehensions": { 34 | "level": "warn" 35 | }, 36 | "eol_last": { 37 | "level": "ignore" 38 | }, 39 | "indentation": { 40 | "value": 2, 41 | "level": "error" 42 | }, 43 | "line_endings": { 44 | "level": "ignore", 45 | "value": "unix" 46 | }, 47 | "max_line_length": { 48 | "value": 128, 49 | "level": "error", 50 | "limitComments": true 51 | }, 52 | "missing_fat_arrows": { 53 | "level": "ignore", 54 | "is_strict": false 55 | }, 56 | "newlines_after_classes": { 57 | "value": 3, 58 | "level": "ignore" 59 | }, 60 | "no_backticks": { 61 | "level": "error" 62 | }, 63 | "no_debugger": { 64 | "level": "warn", 65 | "console": false 66 | }, 67 | "no_empty_functions": { 68 | "level": "ignore" 69 | }, 70 | "no_empty_param_list": { 71 | "level": "ignore" 72 | }, 73 | "no_implicit_braces": { 74 | "level": "ignore", 75 | "strict": true 76 | }, 77 | "no_implicit_parens": { 78 | "strict": true, 79 | "level": "ignore" 80 | }, 81 | "no_interpolation_in_single_quotes": { 82 | "level": "ignore" 83 | }, 84 | "no_plusplus": { 85 | "level": "ignore" 86 | }, 87 | "no_stand_alone_at": { 88 | "level": "ignore" 89 | }, 90 | "no_tabs": { 91 | "level": "error" 92 | }, 93 | "no_this": { 94 | "level": "ignore" 95 | }, 96 | "no_throwing_strings": { 97 | "level": "error" 98 | }, 99 | "no_trailing_semicolons": { 100 | "level": "error" 101 | }, 102 | "no_trailing_whitespace": { 103 | "level": "ignore", 104 | "allowed_in_comments": false, 105 | "allowed_in_empty_lines": true 106 | }, 107 | "no_unnecessary_double_quotes": { 108 | "level": "ignore" 109 | }, 110 | "no_unnecessary_fat_arrows": { 111 | "level": "warn" 112 | }, 113 | "non_empty_constructor_needs_parens": { 114 | "level": "ignore" 115 | }, 116 | "prefer_english_operator": { 117 | "level": "ignore", 118 | "doubleNotLevel": "ignore" 119 | }, 120 | "space_operators": { 121 | "level": "ignore" 122 | }, 123 | "spacing_after_comma": { 124 | "level": "ignore" 125 | }, 126 | "transform_messes_up_line_numbers": { 127 | "level": "warn" 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /spec/clipboard-items-spec.coffee: -------------------------------------------------------------------------------- 1 | systemClipboard = require 'clipboard' 2 | ClipboardItems = require '../lib/clipboard-items' 3 | 4 | # Use the command `window:run-package-specs` (cmd-alt-ctrl-p) to run specs. 5 | # 6 | # To run a specific `it` or `describe` block add an `f` to the front (e.g. `fit` 7 | # or `fdescribe`). Remove the `f` to unfocus the block. 8 | 9 | describe "ClipboardItems", -> 10 | [clipboardItems, limit] = [] 11 | 12 | beforeEach -> 13 | limit = 3 14 | atom.config.set('clipboard-plus.limit', limit) 15 | atom.config.set('clipboard-plus.unique', false) 16 | atom.config.set('clipboard-plus.minimumTextLength', 1) 17 | atom.config.set('clipboard-plus.maximumTextLength', 1000) 18 | clipboardItems = new ClipboardItems 19 | 20 | afterEach -> 21 | clipboardItems.destroy() 22 | 23 | describe 'write', -> 24 | it "atom clipboard", -> 25 | expect(clipboardItems.size()).toBe 0 26 | atom.clipboard.write('next') 27 | expect(clipboardItems.size()).toBe 1 28 | 29 | it "system clipboard", -> 30 | expect(clipboardItems.size()).toBe 0 31 | atom.clipboard.write('abc') 32 | systemClipboard.writeText('123') 33 | expect(clipboardItems.size()).toBe 1 34 | expect(clipboardItems.get(0).text).toBe 'abc' 35 | clipboardItems.syncSystemClipboard() 36 | expect(clipboardItems.size()).toBe 2 37 | expect(clipboardItems.get(1).text).toBe '123' 38 | 39 | it "limit", -> 40 | expect(clipboardItems.size()).toBe 0 41 | atom.clipboard.write('1') 42 | atom.clipboard.write('2') 43 | atom.clipboard.write('3') 44 | atom.clipboard.write('4') 45 | expect(clipboardItems.size()).toBe limit 46 | 47 | it "with metadata", -> 48 | expect(clipboardItems.size()).toBe 0 49 | atom.clipboard.write('1', {fullLine: false}) 50 | atom.clipboard.write('2', {fullLine: false}) 51 | expect(clipboardItems.size()).toBe 2 52 | {text, metadata} = clipboardItems.get(1) 53 | expect(text).toBe '2' 54 | expect(metadata.fullLine).toBe false 55 | 56 | it "with metadata replace", -> 57 | expect(clipboardItems.size()).toBe 0 58 | atom.clipboard.write('1', {fullLine: false}) 59 | atom.clipboard.write('2', {fullLine: false}) 60 | atom.clipboard.write('3', {fullLine: false, replace: true}) 61 | expect(clipboardItems.size()).toBe 2 62 | {text, metadata} = clipboardItems.get(1) 63 | expect(text).toBe '3' 64 | expect(metadata.fullLine).toBe false 65 | expect(metadata.replace).not.toBeExists 66 | 67 | it "destroy", -> 68 | clipboardItems.destroy() 69 | expect(clipboardItems.size()).toBe 0 70 | atom.clipboard.write('1', {fullLine: false}) 71 | atom.clipboard.write('2', {fullLine: false}) 72 | expect(clipboardItems.size()).toBe 0 73 | 74 | it "unique", -> 75 | atom.clipboard.write('1', {fullLine: false}) 76 | atom.clipboard.write('1', {fullLine: false}) 77 | expect(clipboardItems.size()).toBe 2 78 | clipboardItems.clear() 79 | 80 | atom.config.set('clipboard-plus.unique', true) 81 | atom.clipboard.write('1', {fullLine: false}) 82 | atom.clipboard.write('1', {fullLine: false}) 83 | expect(clipboardItems.size()).toBe 1 84 | 85 | it "delete", -> 86 | atom.clipboard.write('1', {fullLine: false}) 87 | atom.clipboard.write('2', {fullLine: false}) 88 | atom.clipboard.write('3', {fullLine: false}) 89 | expect(clipboardItems.size()).toBe 3 90 | clipboardItems.delete(clipboardItems.get(1)) 91 | expect(clipboardItems.size()).toBe 2 92 | item1 = clipboardItems.get(0) 93 | expect(item1.text).toBe '1' 94 | item2 = clipboardItems.get(1) 95 | expect(item2.text).toBe '3' 96 | 97 | describe 'isIgnoreText', -> 98 | it 'ignore blank', -> 99 | atom.clipboard.write('1', {fullLine: false}) 100 | atom.clipboard.write(" \n\n ", {fullLine: true}) 101 | atom.clipboard.write(" \t ", {fullLine: true}) 102 | expect(clipboardItems.size()).toBe 1 103 | item = clipboardItems.get(0) 104 | expect(item.text).toBe '1' 105 | 106 | it 'minimumTextLength', -> 107 | expect(clipboardItems.size()).toBe 0 108 | atom.clipboard.write('1', {fullLine: false}) 109 | expect(clipboardItems.size()).toBe 1 110 | atom.config.set('clipboard-plus.minimumTextLength', 3) 111 | atom.clipboard.write('ab', {fullLine: false}) 112 | expect(clipboardItems.size()).toBe 1 113 | atom.clipboard.write('abc', {fullLine: false}) 114 | expect(clipboardItems.size()).toBe 2 115 | atom.clipboard.write(' ab ', {fullLine: false}) 116 | expect(clipboardItems.size()).toBe 2 117 | 118 | it 'maximumTextLength', -> 119 | expect(clipboardItems.size()).toBe 0 120 | atom.clipboard.write('abcdeabcde1', {fullLine: false}) 121 | expect(clipboardItems.size()).toBe 1 122 | atom.config.set('clipboard-plus.maximumTextLength', 10) 123 | atom.clipboard.write('abcdeabcde1', {fullLine: false}) 124 | expect(clipboardItems.size()).toBe 1 125 | atom.clipboard.write('abcdeabcde', {fullLine: false}) 126 | expect(clipboardItems.size()).toBe 2 127 | --------------------------------------------------------------------------------