├── .gitignore ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── keymaps └── processing.cson ├── lib ├── processing-view.coffee └── processing.coffee ├── menus └── processing.cson ├── package.json ├── spec └── processing-spec.coffee └── styles └── processing.less /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | npm-debug.log 3 | node_modules 4 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.1.0 - First Release 2 | * Every feature added 3 | * Every bug fixed 4 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ___This package is unmaintained___ 2 | 3 | I recommend using the [Script](https://atom.io/packages/script) package for Atom to run Processing sketches (`.pde` files) from Atom. 4 | 5 | # Processing in Atom 6 | 7 | Run Processing sketches from Atom by pressing `ctrl+alt+b` 8 | 9 | ![processing package in action](https://cloud.githubusercontent.com/assets/25792/7103068/73799eda-e04b-11e4-8bbc-8ce625883730.png) 10 | 11 | ### Running a sketch from Atom 12 | 13 | 1. [Download Processing](https://processing.org/) if you don't already have it installed. 14 | 2. Install processing-java: 15 | * Mac OS: Open Processing and install processing-java from the Tools menu: 16 | ![image](https://cloud.githubusercontent.com/assets/25792/7103868/f8b90c1a-e06f-11e4-9dea-c84edab60097.png) 17 | * Linux: Add `processing-java` to your executable search path. This can be done by adding the Processing directory to your `PATH` environment variable or by adding a symlink to any existing directory within your `PATH`. 18 | The following command should do this on most linux distributions (replace `/path/to/processing` with the path where processing is installed): 19 | 20 | ``` 21 | sudo ln -s /path/to/processing/processing-java /usr/local/bin/ 22 | ``` 23 | * Windows: Add `processing-java` to your Command Prompt. This can be done by adding the Processing directory to your `PATH` environment variable: 24 | * Open _Advanced System Settings_ either by running `sysdm.cpl` or searching in _Control Panel_. 25 | * Click the _Environment Variable_ button on the _Advanced_ tab. 26 | * Edit the `PATH` variable to include the Processing directory (e.g. `C:\Program Files\Processing-3.1.1\`) in either the User variables (for just your account) or System variables (for all users). 27 | 3. Open a Processing sketch in Atom and run it: `ctrl+alt+b` 28 | -------------------------------------------------------------------------------- /keymaps/processing.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/advanced/keymaps 10 | 'atom-text-editor': 11 | 'ctrl-alt-b': 'processing:run' 12 | 'cmd-alt-b': 'processing:run' 13 | 'ctrl-alt-c': 'processing:close' 14 | 'cmd-alt-c': 'processing:close' 15 | -------------------------------------------------------------------------------- /lib/processing-view.coffee: -------------------------------------------------------------------------------- 1 | {View, $$} = require 'atom-space-pen-views' 2 | 3 | module.exports = 4 | class ProcessingView extends View 5 | 6 | @content: -> 7 | @div => 8 | # Display layout and outlets 9 | css = 'tool-panel panel panel-bottom padding script-view native-key-bindings' 10 | @div class: css, outlet: 'script', tabindex: -1, => 11 | @div class: 'panel-body padded output', outlet: 'output' 12 | log: (line) -> 13 | #console.log(line); 14 | @output.append $$ -> 15 | @pre class: "line", => 16 | @raw line 17 | height = @script[0].scrollHeight; 18 | @script.scrollTop(height); 19 | clear: -> 20 | @output.empty() 21 | -------------------------------------------------------------------------------- /lib/processing.coffee: -------------------------------------------------------------------------------- 1 | {CompositeDisposable, BufferedProcess} = require 'atom' 2 | fs = require 'fs' 3 | path = require 'path' 4 | psTree = require 'ps-tree' 5 | ProcessingView = require './processing-view' 6 | 7 | module.exports = Processing = 8 | config: 9 | 'processing-executable': 10 | type:"string", 11 | default:"processing-java" 12 | 13 | activate: (state) -> 14 | atom.commands.add 'atom-workspace', 'processing:run': => 15 | @runSketch() 16 | atom.commands.add 'atom-workspace', 'processing:present': => 17 | @runSketchPresent() 18 | atom.commands.add 'atom-workspace', 'processing:close': => 19 | @closeSketch() 20 | 21 | saveSketch: -> 22 | editor = atom.workspace.getActivePaneItem() 23 | file = editor?.buffer.file 24 | 25 | if file?.existsSync() 26 | editor.save() 27 | else 28 | num = Math.floor(Math.random() * 10000) 29 | dir = fs.mkdirSync("/tmp/sketch_#{num}/") 30 | editor.saveAs("/tmp/sketch_#{num}/sketch_#{num}.pde") 31 | 32 | buildSketch: -> 33 | console.log("build and run time") 34 | editor = atom.workspace.getActivePaneItem() 35 | file = editor?.buffer.file 36 | folder = file.getParent().getPath() 37 | build_dir = path.join(folder, "build") 38 | command = path.normalize(atom.config.get("processing.processing-executable")) 39 | args = ["--force", "--sketch=#{folder}", "--output=#{build_dir}", "--run"] 40 | options = {} 41 | console.log("Running command #{command} #{args.join(" ")}") 42 | stdout = (output) => @display output 43 | stderr = (output) => @display output 44 | exit = (code) -> 45 | console.log("Error code: #{code}") 46 | if !@view 47 | @view = new ProcessingView 48 | atom.workspace.addBottomPanel(item: @view) 49 | if @process 50 | psTree @process.process.pid, (err, children) => 51 | for child in children 52 | process.kill(child.PID) 53 | @view.clear() 54 | @process = new BufferedProcess({command, args, stdout, stderr, exit}) 55 | 56 | 57 | runSketch: -> 58 | @saveSketch() 59 | @buildSketch() 60 | 61 | display: (line) -> 62 | @view.log(line) 63 | 64 | closeSketch: -> 65 | if @view 66 | @view.clear() 67 | if @process 68 | psTree @process.process.pid, (err, children) => 69 | for child in children 70 | process.kill(child.PID) 71 | -------------------------------------------------------------------------------- /menus/processing.cson: -------------------------------------------------------------------------------- 1 | # See https://atom.io/docs/latest/creating-a-package#menus for more details 2 | 'context-menu': 3 | 'atom-text-editor': [ 4 | { 5 | 'label': 'Run Sketch' 6 | 'command': 'processing:run' 7 | } 8 | ] 9 | 'menu': [ 10 | { 11 | 'label': 'Packages' 12 | 'submenu': [ 13 | 'label': 'Processing' 14 | 'submenu': [ 15 | { 16 | 'label': 'Run' 17 | 'command': 'processing:run' 18 | } 19 | ] 20 | ] 21 | } 22 | ] 23 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "processing", 3 | "main": "./lib/processing", 4 | "version": "0.13.0", 5 | "description": "Run Processing sketches in Atom", 6 | "activationCommands": { 7 | "atom-workspace": "processing:run" 8 | }, 9 | "repository": "https://github.com/bleikamp/processing", 10 | "license": "MIT", 11 | "engines": { 12 | "atom": ">0.187.0" 13 | }, 14 | "dependencies": { 15 | "ps-tree": "^1.0.0", 16 | "atom-space-pen-views": "^2.0.3" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /spec/processing-spec.coffee: -------------------------------------------------------------------------------- 1 | Processing = require '../lib/processing' 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 "Processing", -> 9 | [workspaceElement, activationPromise] = [] 10 | 11 | beforeEach -> 12 | workspaceElement = atom.views.getView(atom.workspace) 13 | activationPromise = atom.packages.activatePackage('processing') 14 | 15 | describe "when the processing: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('.processing')).not.toExist() 20 | 21 | # This is an activation event, triggering it will cause the package to be 22 | # activated. 23 | atom.commands.dispatch workspaceElement, 'processing:run' 24 | 25 | waitsForPromise -> 26 | activationPromise 27 | 28 | runs -> 29 | expect(workspaceElement.querySelector('.processing')).toExist() 30 | 31 | processingElement = workspaceElement.querySelector('.processing') 32 | expect(processingElement).toExist() 33 | 34 | processingPanel = atom.workspace.panelForItem(processingElement) 35 | expect(processingPanel.isVisible()).toBe true 36 | atom.commands.dispatch workspaceElement, 'processing:run' 37 | expect(processingPanel.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('.processing')).not.toExist() 49 | 50 | # This is an activation event, triggering it causes the package to be 51 | # activated. 52 | atom.commands.dispatch workspaceElement, 'processing:run' 53 | 54 | waitsForPromise -> 55 | activationPromise 56 | 57 | runs -> 58 | # Now we can test for view visibility 59 | processingElement = workspaceElement.querySelector('.processing') 60 | expect(processingElement).toBeVisible() 61 | atom.commands.dispatch workspaceElement, 'processing:run' 62 | expect(processingElement).not.toBeVisible() 63 | -------------------------------------------------------------------------------- /styles/processing.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 | .processing { 8 | } 9 | .script-view { 10 | overflow: scroll; 11 | max-height: 300px; 12 | height: auto; 13 | margin-bottom: 0px; 14 | .line{ 15 | padding: 0 9.5px; 16 | font-size: inherit; 17 | } 18 | } 19 | --------------------------------------------------------------------------------