├── CHANGELOG.md ├── .npmignore ├── spec ├── activate-power-mode-view-spec.coffee └── activate-power-mode-spec.coffee ├── .gitattributes ├── styles └── activate-power-mode.less ├── keymaps └── activate-power-mode.cson ├── menus └── activate-power-mode.cson ├── README.md ├── .gitignore ├── LICENSE.md ├── package.json └── lib └── activate-power-mode.coffee /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | npm-debug.log 3 | node_modules 4 | -------------------------------------------------------------------------------- /spec/activate-power-mode-view-spec.coffee: -------------------------------------------------------------------------------- 1 | ActivatePowerModeView = require '../lib/activate-power-mode-view' 2 | 3 | describe "ActivatePowerModeView", -> 4 | it "has one valid test", -> 5 | expect("life").toBe "easy" 6 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /styles/activate-power-mode.less: -------------------------------------------------------------------------------- 1 | // The ui-variables file is provided by base themes provided by Atom. 2 | // 3 | // See https://github.com/atom/atom-dark-ui/blob/master/styles/ui-variables.less 4 | // for a full listing of what's available. 5 | @import "ui-variables"; 6 | 7 | .power-mode { 8 | transform: translate3d(0, 0, 0); 9 | } 10 | 11 | .power-mode-canvas { 12 | position: absolute; 13 | top: 0; 14 | left: 0; 15 | pointer-events: none; 16 | } 17 | -------------------------------------------------------------------------------- /keymaps/activate-power-mode.cson: -------------------------------------------------------------------------------- 1 | # Keybindings require three things to be fully defined: A selector that is 2 | # matched against the focused element, the keystroke and the command to 3 | # execute. 4 | # 5 | # Below is a basic keybinding which registers on all platforms by applying to 6 | # the root workspace element. 7 | 8 | # For more detailed documentation see 9 | # https://atom.io/docs/latest/behind-atom-keymaps-in-depth 10 | 'atom-workspace': 11 | 'ctrl-alt-o': 'activate-power-mode:toggle' 12 | -------------------------------------------------------------------------------- /menus/activate-power-mode.cson: -------------------------------------------------------------------------------- 1 | # See https://atom.io/docs/latest/hacking-atom-package-word-count#menus for more details 2 | 'context-menu': 3 | 'atom-text-editor': [ 4 | { 5 | 'label': 'Toggle activate-power-mode' 6 | 'command': 'activate-power-mode:toggle' 7 | } 8 | ] 9 | 'menu': [ 10 | { 11 | 'label': 'Packages' 12 | 'submenu': [ 13 | 'label': 'activate-power-mode' 14 | 'submenu': [ 15 | { 16 | 'label': 'Toggle' 17 | 'command': 'activate-power-mode:toggle' 18 | } 19 | ] 20 | ] 21 | } 22 | ] 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # activate-power-mode atom package 2 | This is the version I made based on the original author **Joel Besada**. 3 | Here is the original work in progress package for Atom to replicate https://github.com/codeinthedark/editor/pull/1 by popular demand. 4 | 5 | 6 | 7 | Activate with `ctrl-alt-o` or through the command panel with `Activate Power Mode: Toggle`. In this 8 | early version it only affects the current tab, to run it in a new tab you need to run `Window: Reload` first. 9 | 10 | **NOTE THAT THIS VERSION IS VERY BUGGY RIGHT NOW** 11 | **NOTE THAT THERE IS NO VIBRATION IN THIS VERSION** 12 | ![activate-power-mode](https://cloud.githubusercontent.com/assets/688415/11453297/b8f249ec-9605-11e5-978c-eb3bb21eecd8.gif) 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear in the root of a volume 35 | .DocumentRevisions-V100 36 | .fseventsd 37 | .Spotlight-V100 38 | .TemporaryItems 39 | .Trashes 40 | .VolumeIcon.icns 41 | 42 | # Directories potentially created on remote AFP share 43 | .AppleDB 44 | .AppleDesktop 45 | Network Trash Folder 46 | Temporary Items 47 | .apdisk 48 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /spec/activate-power-mode-spec.coffee: -------------------------------------------------------------------------------- 1 | ActivatePowerMode = require '../lib/activate-power-mode' 2 | 3 | # Use the command `window:run-package-specs` (cmd-alt-ctrl-p) to run specs. 4 | # 5 | # To run a specific `it` or `describe` block add an `f` to the front (e.g. `fit` 6 | # or `fdescribe`). Remove the `f` to unfocus the block. 7 | 8 | describe "ActivatePowerMode", -> 9 | [workspaceElement, activationPromise] = [] 10 | 11 | beforeEach -> 12 | workspaceElement = atom.views.getView(atom.workspace) 13 | activationPromise = atom.packages.activatePackage('activate-power-mode') 14 | 15 | describe "when the activate-power-mode:toggle event is triggered", -> 16 | it "hides and shows the modal panel", -> 17 | # Before the activation event the view is not on the DOM, and no panel 18 | # has been created 19 | expect(workspaceElement.querySelector('.activate-power-mode')).not.toExist() 20 | 21 | # This is an activation event, triggering it will cause the package to be 22 | # activated. 23 | atom.commands.dispatch workspaceElement, 'activate-power-mode:toggle' 24 | 25 | waitsForPromise -> 26 | activationPromise 27 | 28 | runs -> 29 | expect(workspaceElement.querySelector('.activate-power-mode')).toExist() 30 | 31 | activatePowerModeElement = workspaceElement.querySelector('.activate-power-mode') 32 | expect(activatePowerModeElement).toExist() 33 | 34 | activatePowerModePanel = atom.workspace.panelForItem(activatePowerModeElement) 35 | expect(activatePowerModePanel.isVisible()).toBe true 36 | atom.commands.dispatch workspaceElement, 'activate-power-mode:toggle' 37 | expect(activatePowerModePanel.isVisible()).toBe false 38 | 39 | it "hides and shows the view", -> 40 | # This test shows you an integration test testing at the view level. 41 | 42 | # Attaching the workspaceElement to the DOM is required to allow the 43 | # `toBeVisible()` matchers to work. Anything testing visibility or focus 44 | # requires that the workspaceElement is on the DOM. Tests that attach the 45 | # workspaceElement to the DOM are generally slower than those off DOM. 46 | jasmine.attachToDOM(workspaceElement) 47 | 48 | expect(workspaceElement.querySelector('.activate-power-mode')).not.toExist() 49 | 50 | # This is an activation event, triggering it causes the package to be 51 | # activated. 52 | atom.commands.dispatch workspaceElement, 'activate-power-mode:toggle' 53 | 54 | waitsForPromise -> 55 | activationPromise 56 | 57 | runs -> 58 | # Now we can test for view visibility 59 | activatePowerModeElement = workspaceElement.querySelector('.activate-power-mode') 60 | expect(activatePowerModeElement).toBeVisible() 61 | atom.commands.dispatch workspaceElement, 'activate-power-mode:toggle' 62 | expect(activatePowerModeElement).not.toBeVisible() 63 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "activate-power-mode", 3 | "main": "./lib/activate-power-mode", 4 | "version": "0.3.2", 5 | "description": "Activate POWER MODE to write your code in style.", 6 | "keywords": [], 7 | "activationCommands": { 8 | "atom-workspace": "activate-power-mode:toggle" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "https://github.com/JJack27/activate-power-mode" 13 | }, 14 | "license": "MIT", 15 | "engines": { 16 | "atom": ">=1.0.0 <2.0.0" 17 | }, 18 | "dependencies": { 19 | "lodash.throttle": "^3.0.4" 20 | }, 21 | "readme": "# activate-power-mode atom package\nA work in progress package for Atom to replicate https://github.com/codeinthedark/editor/pull/1 by popular demand.\n\nActivate with `ctrl-alt-o` or through the command panel with `Activate Power Mode: Toggle`. In this\nearly version it only affects the current tab, to run it in a new tab you need to run `Window: Reload` first.\n\n**NOTE THAT THIS VERSION IS VERY BUGGY RIGHT NOW**\n\n![activate-power-mode](https://cloud.githubusercontent.com/assets/688415/11453297/b8f249ec-9605-11e5-978c-eb3bb21eecd8.gif)\n", 22 | "readmeFilename": "README.md", 23 | "bugs": { 24 | "url": "https://github.com/JoelBesada/activate-power-mode/issues" 25 | }, 26 | "homepage": "https://github.com/JJack27/activate-power-mode#readme", 27 | "_id": "activate-power-mode@0.3.2", 28 | "_shasum": "4f832638f75311688cdf4912b46a9af9048dc0df", 29 | "_resolved": "file:..\\d-1151030-4852-igd3k0\\package.tgz", 30 | "_from": "..\\d-1151030-4852-igd3k0\\package.tgz", 31 | "_atomModuleCache": { 32 | "version": 1, 33 | "dependencies": [ 34 | { 35 | "name": "lodash.throttle", 36 | "version": "3.0.4", 37 | "path": "node_modules\\lodash.throttle\\index.js" 38 | }, 39 | { 40 | "name": "lodash.debounce", 41 | "version": "3.1.1", 42 | "path": "node_modules\\lodash.throttle\\node_modules\\lodash.debounce\\index.js" 43 | }, 44 | { 45 | "name": "lodash._getnative", 46 | "version": "3.9.1", 47 | "path": "node_modules\\lodash.throttle\\node_modules\\lodash.debounce\\node_modules\\lodash._getnative\\index.js" 48 | } 49 | ], 50 | "extensions": { 51 | ".coffee": [ 52 | "lib\\activate-power-mode.coffee" 53 | ], 54 | ".js": [ 55 | "node_modules\\lodash.throttle\\index.js", 56 | "node_modules\\lodash.throttle\\node_modules\\lodash.debounce\\index.js", 57 | "node_modules\\lodash.throttle\\node_modules\\lodash.debounce\\node_modules\\lodash._getnative\\index.js" 58 | ], 59 | ".json": [ 60 | "node_modules\\lodash.throttle\\node_modules\\lodash.debounce\\node_modules\\lodash._getnative\\package.json", 61 | "node_modules\\lodash.throttle\\node_modules\\lodash.debounce\\package.json", 62 | "node_modules\\lodash.throttle\\package.json", 63 | "package.json" 64 | ] 65 | }, 66 | "folders": [ 67 | { 68 | "paths": [ 69 | "lib", 70 | "", 71 | "spec" 72 | ], 73 | "dependencies": { 74 | "lodash.throttle": "^3.0.4" 75 | } 76 | }, 77 | { 78 | "paths": [ 79 | "node_modules\\lodash.throttle" 80 | ], 81 | "dependencies": { 82 | "lodash.debounce": "^3.0.0" 83 | } 84 | }, 85 | { 86 | "paths": [ 87 | "node_modules\\lodash.throttle\\node_modules\\lodash.debounce" 88 | ], 89 | "dependencies": { 90 | "lodash._getnative": "^3.0.0" 91 | } 92 | } 93 | ] 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /lib/activate-power-mode.coffee: -------------------------------------------------------------------------------- 1 | throttle = require "lodash.throttle" 2 | {CompositeDisposable} = require 'atom' 3 | 4 | module.exports = ActivatePowerMode = 5 | activatePowerModeView: null 6 | modalPanel: null 7 | subscriptions: null 8 | 9 | activate: (state) -> 10 | @subscriptions = new CompositeDisposable 11 | 12 | @subscriptions.add atom.commands.add "atom-workspace", 13 | "activate-power-mode:toggle": => @toggle() 14 | 15 | @throttledShake = throttle @shake.bind(this), 100, trailing: false 16 | @throttledSpawnParticles = throttle @spawnParticles.bind(this), 25, trailing: false 17 | 18 | @editor = atom.workspace.getActiveTextEditor() 19 | @editorElement = atom.views.getView @editor 20 | @editorElement.classList.add "power-mode" 21 | 22 | @subscriptions.add @editor.getBuffer().onDidChange(@onChange.bind(this)) 23 | @setupCanvas() 24 | 25 | setupCanvas: -> 26 | @canvas = document.createElement "canvas" 27 | @context = @canvas.getContext "2d" 28 | @canvas.classList.add "power-mode-canvas" 29 | @canvas.width = @editorElement.offsetWidth 30 | @canvas.height = @editorElement.offsetHeight 31 | @editorElement.parentNode.appendChild @canvas 32 | 33 | calculateCursorOffset: -> 34 | editorRect = @editorElement.getBoundingClientRect() 35 | scrollViewRect = @editorElement.shadowRoot.querySelector(".scroll-view").getBoundingClientRect() 36 | 37 | top: scrollViewRect.top - editorRect.top + @editor.getLineHeightInPixels() / 2 38 | left: scrollViewRect.left - editorRect.left 39 | 40 | onChange: (e) -> 41 | spawnParticles = true 42 | if e.newText 43 | spawnParticles = e.newText isnt "\n" 44 | range = e.newRange.end 45 | else 46 | range = e.newRange.start 47 | 48 | @throttledSpawnParticles(range) if spawnParticles 49 | @throttledShake() 50 | 51 | shake: -> 52 | intensity = 0 53 | x = intensity * (if Math.random() > 0.5 then -1 else 1) 54 | y = intensity * (if Math.random() > 0.5 then -1 else 1) 55 | 56 | @editorElement.style.top = "#{y}px" 57 | @editorElement.style.left = "#{x}px" 58 | 59 | setTimeout => 60 | @editorElement.style.top = "" 61 | @editorElement.style.left = "" 62 | , 75 63 | 64 | spawnParticles: (range) -> 65 | cursorOffset = @calculateCursorOffset() 66 | 67 | {left, top} = @editor.pixelPositionForScreenPosition range 68 | left += cursorOffset.left - @editor.getScrollLeft() 69 | top += cursorOffset.top - @editor.getScrollTop() 70 | 71 | color = @getColorAtPosition left, top 72 | numParticles = 5 + Math.round(Math.random() * 10) 73 | while numParticles-- 74 | part = @createParticle left, top, color 75 | @particles[@particlePointer] = part 76 | @particlePointer = (@particlePointer + 1) % 500 77 | 78 | _randomNum: (max,min=0) -> 79 | return Math.floor(Math.random() * (max - min) + min) 80 | # min is set to 0 by default but a different value can be passed to function 81 | 82 | getColorAtPosition: (left, top) -> 83 | offset = @editorElement.getBoundingClientRect() 84 | el = atom.views.getView(@editor).shadowRoot.elementFromPoint( 85 | left + offset.left 86 | top + offset.top 87 | ) 88 | 89 | if el 90 | r = @_randomNum(255) 91 | g = @_randomNum(255) 92 | b = @_randomNum(255) 93 | "rgb( #{r},#{g},#{b})" 94 | else 95 | r = @_randomNum(255) 96 | g = @_randomNum(255) 97 | b = @_randomNum(255) 98 | "rgb( #{r},#{g},#{b})" 99 | 100 | createParticle: (x, y, color) -> 101 | x: x 102 | y: y 103 | alpha: 1 104 | color: color 105 | velocity: 106 | x: -1 + Math.random() * 2 107 | y: -3.5 + Math.random() * 2 108 | 109 | drawParticles: -> 110 | requestAnimationFrame @drawParticles.bind(this) 111 | @context.clearRect 0, 0, @canvas.width, @canvas.height 112 | 113 | for particle in @particles 114 | continue if particle.alpha <= 0.1 115 | 116 | particle.velocity.y += 0.075 117 | particle.x += particle.velocity.x 118 | particle.y += particle.velocity.y 119 | particle.alpha *= 0.96 120 | 121 | @context.fillStyle = "rgba(#{particle.color[4...-1]}, #{particle.alpha})" 122 | @context.fillRect( 123 | Math.round(particle.x - 1.5) 124 | Math.round(particle.y - 1.5) 125 | 3, 3 126 | ) 127 | 128 | toggle: -> 129 | console.log 'ActivatePowerMode was toggled!' 130 | @particlePointer = 0 131 | @particles = [] 132 | requestAnimationFrame @drawParticles.bind(this) 133 | --------------------------------------------------------------------------------