diff options
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | desktop/core/io/osc.js | 8 | ||||
-rw-r--r-- | desktop/core/io/udp.js | 6 | ||||
-rw-r--r-- | desktop/sources/scripts/commander.js | 21 | ||||
-rw-r--r-- | desktop/sources/scripts/terminal.js | 2 |
5 files changed, 30 insertions, 11 deletions
@@ -86,13 +86,13 @@ It sends a value **between 0-127**, where the value is calculated as a ratio of ## UDP -The [UDP](https://nodejs.org/api/dgram.html#dgram_socket_send_msg_offset_length_port_address_callback) operator `;` locks each consecutive eastwardly ports. For example, `;hello`, will send the string "hello", on bang, to the port `49160` on `localhost`. In console, use `terminal.io.udp.select()` to select a **custom UDP port**. +The [UDP](https://nodejs.org/api/dgram.html#dgram_socket_send_msg_offset_length_port_address_callback) operator `;` locks each consecutive eastwardly ports. For example, `;hello`, will send the string "hello", on bang, to the port `49160` on `localhost`. In commander, use `udp:7777` to select the **custom UDP port 7777**. You can use the [listener.js](https://github.com/hundredrabbits/Orca/blob/master/listener.js) to test UDP messages. See it in action with [udp.orca](https://github.com/hundredrabbits/Orca/blob/master/examples/_udp.orca). ## OSC -The [OSC](https://github.com/MylesBorins/node-osc) operator `=` locks each consecutive eastwardly ports. The first character is used for the path, the following characters are sent as integers using the [base36 Table](https://github.com/hundredrabbits/Orca#base36-table). In console, use `terminal.io.osc.select()` to select a **custom osc port**. +The [OSC](https://github.com/MylesBorins/node-osc) operator `=` locks each consecutive eastwardly ports. The first character is used for the path, the following characters are sent as integers using the [base36 Table](https://github.com/hundredrabbits/Orca#base36-table). In commander, use `osc:7777` to select the **custom OSC port 7777**. For example, `=1abc` will send `10`, `11` and `12` to `/1`, via the port `49162` on `localhost`; `=a123` will send `1`, `2` and `3`, to the path `/a`. You can use the [listener.js](https://github.com/hundredrabbits/Orca/blob/master/listener.js) to test OSC messages. See it in action with [osc.orca](https://github.com/hundredrabbits/Orca/blob/master/examples/_osc.orca) or try it with [SonicPi](https://github.com/hundredrabbits/Orca/blob/master/TUTORIAL.md#sonicpi). diff --git a/desktop/core/io/osc.js b/desktop/core/io/osc.js index 19f7502..cbc9080 100644 --- a/desktop/core/io/osc.js +++ b/desktop/core/io/osc.js @@ -5,7 +5,7 @@ const osc = require('node-osc') export default function Osc (terminal) { this.stack = [] this.port = null - this.options = { default: 49162, tidalCycles: 6010, sonicPi: 4559, superCollider: 57120, openStageControl: 7777 } + this.options = { default: 49162, tidalCycles: 6010, sonicPi: 4559, superCollider: 57120 } this.start = function () { console.info('OSC Starting..') @@ -39,14 +39,14 @@ export default function Osc (terminal) { } this.select = function (port = this.options.default) { - if (port < 1000) { console.warn('Unavailable port'); return } - this.port = port + if (isNaN(port) || port < 1000) { console.warn('Unavailable port'); return } + console.info('OSC', `Selected port: ${port}`) + this.port = parseInt(port) this.setup() this.update() } this.update = function () { - console.log(`OSC Port: ${this.port}`) terminal.controller.clearCat('default', 'OSC') for (const id in this.options) { terminal.controller.add('default', 'OSC', `${id.charAt(0).toUpperCase() + id.substr(1)}(${this.options[id]}) ${this.port === this.options[id] ? ' — Active' : ''}`, () => { terminal.io.osc.select(this.options[id]) }, '') diff --git a/desktop/core/io/udp.js b/desktop/core/io/udp.js index 97b108a..c464c3b 100644 --- a/desktop/core/io/udp.js +++ b/desktop/core/io/udp.js @@ -33,13 +33,13 @@ export default function Udp (terminal) { } this.select = function (port = this.options.default) { - if (port < 1000) { console.warn('Unavailable port'); return } - this.port = port + if (isNaN(port) || port < 1000) { console.warn('Unavailable port'); return } + console.info('OSC', `Selected port: ${port}`) + this.port = parseInt(port) this.update() } this.update = function () { - console.log(`UDP Port: ${this.port}`) terminal.controller.clearCat('default', 'UDP') for (const id in this.options) { terminal.controller.add('default', 'UDP', `${id.charAt(0).toUpperCase() + id.substr(1)}(${this.options[id]}) ${this.port === this.options[id] ? ' — Active' : ''}`, () => { terminal.io.udp.select(this.options[id]) }, '') diff --git a/desktop/sources/scripts/commander.js b/desktop/sources/scripts/commander.js index a4c3e25..8b7fd57 100644 --- a/desktop/sources/scripts/commander.js +++ b/desktop/sources/scripts/commander.js @@ -3,6 +3,8 @@ export default function Commander (terminal) { this.isActive = false this.query = '' + this.history = [] + this.historyIndex = 0 // Library @@ -15,6 +17,8 @@ export default function Commander (terminal) { } this.actives = { + 'osc': (val) => { terminal.io.osc.select(parseInt(val)) }, + 'udp': (val) => { terminal.io.udp.select(parseInt(val)) }, 'copy': (val) => { terminal.cursor.copy() }, 'paste': (val) => { terminal.cursor.paste(true) }, 'erase': (val) => { terminal.cursor.erase() }, @@ -29,7 +33,7 @@ export default function Commander (terminal) { 'color': (val) => { const parts = val.split(';'); terminal.theme.set('b_med', parts[0]); terminal.theme.set('b_inv', parts[1]); terminal.theme.set('b_high', parts[2]) }, 'graphic': (val) => { terminal.theme.setImage(terminal.source.locate(val + '.jpg')) }, 'inject': (val) => { terminal.source.inject(val, true) }, - 'write': (val) => { const parts = val.split(';') ; terminal.cursor.select(parts[1], parts[2], parts[0].length) ; terminal.cursor.writeBlock([parts[0].split('')]) } + 'write': (val) => { const parts = val.split(';'); terminal.cursor.select(parts[1], parts[2], parts[0].length); terminal.cursor.writeBlock([parts[0].split('')]) } } // Make shorthands @@ -48,6 +52,7 @@ export default function Commander (terminal) { this.stop = function () { this.isActive = false this.query = '' + this.historyIndex = this.history.length terminal.update() } @@ -74,6 +79,8 @@ export default function Commander (terminal) { if (!this.actives[cmd]) { console.warn(`Unknown message: ${msg}`); this.stop(); return } console.info('Commander', msg) this.actives[cmd](val, true) + this.history.push(msg) + this.historyIndex = this.history.length this.stop() } @@ -137,6 +144,12 @@ export default function Commander (terminal) { } this.onArrowUp = function (mod = false, skip = false, drag = false) { + // Navigate History + if (this.isActive === true) { + this.historyIndex -= this.historyIndex > 0 ? 1 : 0 + this.start(this.history[this.historyIndex]) + return + } const leap = skip ? terminal.grid.h : 1 terminal.toggleGuide(false) if (drag) { @@ -149,6 +162,12 @@ export default function Commander (terminal) { } this.onArrowDown = function (mod = false, skip = false, drag = false) { + // Navigate History + if (this.isActive === true) { + this.historyIndex += this.historyIndex < this.history.length ? 1 : 0 + this.start(this.history[this.historyIndex]) + return + } const leap = skip ? terminal.grid.h : 1 terminal.toggleGuide(false) if (drag) { diff --git a/desktop/sources/scripts/terminal.js b/desktop/sources/scripts/terminal.js index 813244c..bf41f20 100644 --- a/desktop/sources/scripts/terminal.js +++ b/desktop/sources/scripts/terminal.js @@ -12,7 +12,7 @@ import Controller from './lib/controller.js' import library from '../../core/library.js' export default function Terminal () { - this.version = 130 + this.version = 131 this.library = library this.orca = new Orca(this) |