Skip to content

Commit

Permalink
Change keybindings to be more similar to Sonic Pi's; add check for ac…
Browse files Browse the repository at this point in the history
…tive text editor; attribute euwbah/sonic-pi-autocomplete

Also: update README.md to include the correct commands.
  • Loading branch information
SunderB committed Mar 3, 2018
1 parent 5287d00 commit d5f42ba
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 26 deletions.
15 changes: 13 additions & 2 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright notice for modifications of rkh/atom-sonic in sunderb/sb-atom-sonic-pi from 24/02/2018 to present
# Copyright notice for modifications of rkh/atom-sonic in sunderb/sb-atom-sonic-pi from 24/02/2018 to present:
Copyright (c) 2018 SunderB

Permission is hereby granted, free of charge, to any person obtaining
Expand All @@ -20,7 +20,8 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

# Copyright notice for rkh/atom-sonic
# This package is a fork of [rkh/atom-sonic](https://github.com/rkh/atom-sonic) (https://github.com/rkh/atom-sonic).
# Copyright notice for rkh/atom-sonic:
Copyright (c) 2015 rkh

Permission is hereby granted, free of charge, to any person obtaining
Expand All @@ -41,3 +42,13 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

# This package contains some code from [euwbah/sonic-pi-autocomplete](https://github.com/euwbah/sonic-pi-autocomplete) (https://github.com/euwbah/sonic-pi-autocomplete).
# Copyright notice for euwbah/sonic-pi-autocomplete:
Copyright (c) 2016 euwbah

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Sonic Pi Atom integration

This plugin, which is forked from [rkh/atom-sonic](https://github.com/rkh/atom-sonic), allows remote controlling [Sonic Pi](http://sonic-pi.net/) via [Atom](https://atom.io/).
This plugin, which is forked from [rkh/atom-sonic](https://github.com/rkh/atom-sonic) and contains a little code from [euwbah/sonic-pi-autocomplete](https://github.com/euwbah/sonic-pi-autocomplete), allows remote controlling [Sonic Pi](http://sonic-pi.net/) via [Atom](https://atom.io/).

This package makes it easier to write and run your Sonic Pi code within Atom. :)

Expand All @@ -13,16 +13,16 @@ The [tool-bar](https://atom.io/packages/tool-bar) package for Atom needs to be i
* Adjusted OSC code to send to Sonic Pi server, and optionally to the Sonic Pi GUI (OSC messages sent to GUI appear in the cue log).
* Added save-and-play-file command, which saves the current file and tells Sonic Pi to play the file. This allows for playback of large buffers. This command can be activated using F5.
* Added integration with the [tool-bar](https://atom.io/packages/tool-bar) package to add buttons which run some commands to a toolbar.
* Changed some of the default key bindings (for example: `atom-sonic:stop` used `ctrl-s`, which is used as the 'save' shortcut on many systems, so I changed that to `ctrl-alt-s`), see below for the key bindings.
* Changed some of the default key bindings to be more similar to Sonic Pi's keyboard shortcuts, see below for the key bindings.
* Added options to change the Sonic Pi server IP address and port, and the Sonic Pi GUI IP address and port.

I'm happy to contribute these changes to rkh/atom-sonic if wanted. :)

## Commands and Default Key Bindings

Key Binding | Action | Description
--------------|--------------------------------|-----------------
`ctrl-f5` | `atom-sonic:play-file` | Sends content of the currently open buffer to Sonic Pi for instant playback.
`f5` | `atom-sonic:save-and-play-file`| Saves the current file and tells Sonic Pi to play the file. Allows for playback of large buffers.
`ctrl-alt-r` | `atom-sonic:play-selection` | Sends currently selected text to Sonic Pi for instant playback.
`ctrl-alt-s` | `atom-sonic:stop` | Tells Sonic Pi to stop all playback.
Key Binding | Action | Description
--------------|---------------------------------------|-----------------
`alt-r` | `sb-atom-sonic-pi:play-file` | Sends content of the currently open buffer to Sonic Pi for instant playback.
`f5` | `sb-atom-sonic-pi:save-and-play-file` | Saves the current file and tells Sonic Pi to play the file. Allows for playback of large buffers.
`ctrl-alt-r` | `sb-atom-sonic-pi:play-selection` | Sends currently selected text to Sonic Pi for instant playback.
`alt-s` | `sb-atom-sonic-pi:stop` | Tells Sonic Pi to stop all playback.
4 changes: 2 additions & 2 deletions keymaps/sb-atom-sonic-pi.cson
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# For more detailed documentation see
# https://atom.io/docs/latest/behind-atom-keymaps-in-depth
'atom-workspace':
'ctrl-f5': 'sb-atom-sonic-pi:play-file'
'alt-r': 'sb-atom-sonic-pi:play-file'
'f5': 'sb-atom-sonic-pi:save-and-play-file'
'ctrl-alt-r': 'sb-atom-sonic-pi:play-selection'
'ctrl-alt-s': 'sb-atom-sonic-pi:stop'
'alt-s': 'sb-atom-sonic-pi:stop'
31 changes: 18 additions & 13 deletions lib/sb-atom-sonic-pi.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{CompositeDisposable} = require 'atom';
osc = require 'node-osc';
provider = require './sb-atom-sonic-pi-autocomplete';
sbAtomSonicPiView = require './sb-atom-sonic-pi-view'; # for test_toggle
sbAtomSonicPiView = require './sb-atom-sonic-pi-view'; # for sbAtomSonicPiView

module.exports = sbAtomSonicPi =
config: # Settings
Expand Down Expand Up @@ -37,9 +37,9 @@ module.exports = sbAtomSonicPi =
type: 'boolean',
default: false
order: 5
sbAtomSonicPiView: null; # for test_toggle
sbAtomSonicPiView: null; # for sbAtomSonicPiView
subscriptions: null;
modalPanel: null; # for test_toggle
modalPanel: null; # for sbAtomSonicPiView
provide: -> provider;

activate: (state) ->
Expand Down Expand Up @@ -116,26 +116,31 @@ module.exports = sbAtomSonicPi =
# Remove any toolbar items added
@toolBar.removeItems();
@toolBar = null;
@modalPanel.destroy(); # for test_toggle
@modalPanel.destroy(); # for sbAtomSonicPiView
@subscriptions.dispose();
@sbAtomSonicPiView.destroy(); # for test_toggle
@sbAtomSonicPiView.destroy(); # for sbAtomSonicPiView

serialize: ->
return sbAtomSonicPiViewState: this.sbAtomSonicPiView.serialize(); # for test_toggle

play: (selector) ->
editor = atom.workspace.getActiveTextEditor();
source = editor[selector]();
@send('/run-code', 'atom', source);
atom.notifications.addSuccess("Sent source code to Sonic Pi.");
if editor == undefined
atom.notifications.addError("No active text editor found.")
else
source = editor[selector]();
@send('/run-code', 'atom', source);
atom.notifications.addSuccess("Sent source code to Sonic Pi.");

saveAndPlay: ->
editor = atom.workspace.getActiveTextEditor();
editor.save();
fullPath = editor.getPath().replace(/\\/g,"/");
title = editor.getTitle();
@send('/run-code', 'atom', "run_file \"" + fullPath + "\"");
atom.notifications.addSuccess("Saved file and told Sonic Pi to start playing.");
if editor == undefined
atom.notifications.addError("No active text editor found.");
else
editor.save();
fullPath = editor.getPath().replace(/\\/g,"/"); # Replace back-slashes in the file path with forward-slashes. Useful for Windows file paths.
@send('/run-code', 'atom', "run_file \"" + fullPath + "\"");
atom.notifications.addSuccess("Saved file and told Sonic Pi to start playing.");

stop: ->
@send('/stop-all-jobs');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "sb-atom-sonic-pi",
"main": "./lib/sb-atom-sonic-pi",
"version": "1.0.0-dev.03-03-2018-1",
"version": "1.0.0-dev.03-03-2018-2",
"description": "Sonic Pi Atom integration. Based on rkh/atom-sonic.",
"keywords": [],
"providedServices": {
Expand Down

0 comments on commit d5f42ba

Please sign in to comment.