diff options
author | Devine Lu Linvega <[email protected]> | 2019-06-08 09:38:49 +0200 |
---|---|---|
committer | Devine Lu Linvega <[email protected]> | 2019-06-08 09:38:49 +0200 |
commit | 99944fae4fd5441c84f11b5ebb99941fbed4c882 (patch) | |
tree | 2442ff240fb33747aca09cb25325f3fc339f8cf4 | |
parent | a13e55a93dee07b44ec9b256aa020a155dcd7147 (diff) | |
download | Orca-99944fae4fd5441c84f11b5ebb99941fbed4c882.tar.gz Orca-99944fae4fd5441c84f11b5ebb99941fbed4c882.zip |
Fixed issue with G
-rw-r--r-- | desktop/core/io/udp.js | 5 | ||||
-rw-r--r-- | desktop/core/library/g.js | 2 | ||||
-rw-r--r-- | desktop/sources/scripts/commander.js | 76 | ||||
-rw-r--r-- | desktop/sources/scripts/terminal.js | 2 | ||||
-rw-r--r-- | examples/benchmarks/rw.orca | 35 |
5 files changed, 66 insertions, 54 deletions
diff --git a/desktop/core/io/udp.js b/desktop/core/io/udp.js index 811a088..293f69d 100644 --- a/desktop/core/io/udp.js +++ b/desktop/core/io/udp.js @@ -54,10 +54,7 @@ export default function Udp (terminal) { // Input this.listener.on('message', (msg, rinfo) => { - const cmd = `${msg}`.split(':')[0].toLowerCase() - const val = `${msg}`.substr(cmd.length + 1) - if (!terminal.commander.actives[cmd]) { console.warn(`Unknown message: ${msg}`); return } - terminal.commander.actives[cmd](val, true) + terminal.commander.trigger(`${msg}`, false) }) this.listener.on('listening', () => { diff --git a/desktop/core/library/g.js b/desktop/core/library/g.js index ba22d83..6f55c07 100644 --- a/desktop/core/library/g.js +++ b/desktop/core/library/g.js @@ -16,7 +16,7 @@ export default function OperatorG (orca, x, y, passive) { const len = this.listen(this.ports.len, true) const x = this.listen(this.ports.x, true) const y = this.listen(this.ports.y, true) + 1 - for (let offset = 0; offset <= len; offset++) { + for (let offset = 0; offset < len; offset++) { if (offset > 0) { orca.lock(this.x + offset, this.y) } diff --git a/desktop/sources/scripts/commander.js b/desktop/sources/scripts/commander.js index fedfa1d..fad4085 100644 --- a/desktop/sources/scripts/commander.js +++ b/desktop/sources/scripts/commander.js @@ -9,41 +9,41 @@ export default function Commander (terminal) { // Library this.passives = { - 'find': (val) => { terminal.cursor.find(val) }, - 'select': (val) => { const rect = val.split(';'); terminal.cursor.select(rect[0], rect[1], rect[2], rect[3]) }, - 'inject': (val) => { terminal.source.inject(val, false) }, - 'write': (val) => { const parts = val.split(';'); terminal.cursor.select(parts[1], parts[2], parts[0].length) } + 'find': (p) => { terminal.cursor.find(p.str) }, + 'select': (p) => { terminal.cursor.select(p.x, p.y, p.w, p.h) }, + 'inject': (p) => { terminal.source.inject(p.str, false) }, + 'write': (p) => { terminal.cursor.select(p.x, p.y, p.length) } } this.actives = { // Ports - 'osc': (val) => { terminal.io.osc.select(parseInt(val)) }, - 'udp': (val) => { terminal.io.udp.select(parseInt(val)) }, - 'ip': (val) => { terminal.io.setIp(val) }, + 'osc': (p) => { terminal.io.osc.select(p.int) }, + 'udp': (p) => { terminal.io.udp.select(p.int) }, + 'ip': (p) => { terminal.io.setIp(p.str) }, // Cursor - 'copy': (val) => { terminal.cursor.copy() }, - 'paste': (val) => { terminal.cursor.paste(true) }, - 'erase': (val) => { terminal.cursor.erase() }, + 'copy': (p) => { terminal.cursor.copy() }, + 'paste': (p) => { terminal.cursor.paste(true) }, + 'erase': (p) => { terminal.cursor.erase() }, // Controls - 'play': (val) => { terminal.clock.play() }, - 'stop': (val) => { terminal.clock.stop() }, - 'run': (val) => { terminal.run() }, + 'play': (p) => { terminal.clock.play() }, + 'stop': (p) => { terminal.clock.stop() }, + 'run': (p) => { terminal.run() }, // Speed - 'apm': (val) => { terminal.clock.set(null, parseInt(val)) }, - 'bpm': (val) => { terminal.clock.set(parseInt(val), parseInt(val), true) }, - 'time': (val) => { terminal.clock.setFrame(parseInt(val)) }, - 'rewind': (val) => { terminal.clock.setFrame(terminal.orca.f - parseInt(val)) }, - 'skip': (val) => { terminal.clock.setFrame(terminal.orca.f + parseInt(val)) }, + 'apm': (p) => { terminal.clock.set(null, p.int) }, + 'bpm': (p) => { terminal.clock.set(p.int, p.int, true) }, + 'time': (p) => { terminal.clock.setFrame(p.int) }, + 'rewind': (p) => { terminal.clock.setFrame(terminal.orca.f - p.int) }, + 'skip': (p) => { terminal.clock.setFrame(terminal.orca.f + p.int) }, // Effects - 'rot': (val) => { terminal.cursor.rotate(parseInt(val)) }, + 'rot': (p) => { terminal.cursor.rotate(p.int) }, // Themeing - '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')) }, + 'color': (p) => { terminal.theme.set('b_med', p.parts[0]); terminal.theme.set('b_inv', p.parts[1]); terminal.theme.set('b_high', p.parts[2]) }, + 'graphic': (p) => { terminal.theme.setImage(terminal.source.locate(p.str + '.jpg')) }, // Edit - 'find': (val) => { terminal.cursor.find(val) }, - 'select': (val) => { const rect = val.split(';'); terminal.cursor.select(rect[0], rect[1], rect[2], rect[3]) }, - '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('')]) } + 'find': (p) => { terminal.cursor.find(p.str) }, + 'select': (p) => { terminal.cursor.select(p.x, p.y, p.w, p.h) }, + 'inject': (p) => { terminal.source.inject(p.str, true) }, + 'write': (p) => { terminal.cursor.select(p.x, p.y, p.length.length); terminal.cursor.writeBlock([p.chars]) } } // Make shorthands @@ -51,6 +51,18 @@ export default function Commander (terminal) { this.actives[id.substr(0, 2)] = this.actives[id] } + function Param (val) { + this.str = `${val}` + this.length = this.str.length + this.chars = this.str.split('') + this.int = !isNaN(val) ? parseInt(val) : null + this.parts = val.split(';') + this.x = parseInt(this.parts[0]) + this.y = parseInt(this.parts[1]) + this.w = parseInt(this.parts[2]) + this.h = parseInt(this.parts[3]) + } + // Begin this.start = function (q = '') { @@ -83,22 +95,24 @@ export default function Commander (terminal) { terminal.update() } - this.trigger = function (msg = this.query) { + this.trigger = function (msg = this.query, touch = true) { const cmd = `${msg}`.split(':')[0].toLowerCase() const val = `${msg}`.substr(cmd.length + 1) if (!this.actives[cmd]) { console.warn('Commander', `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() + this.actives[cmd](new Param(val), true) + if (touch === true) { + this.history.push(msg) + this.historyIndex = this.history.length + this.stop() + } } this.preview = function (msg = this.query) { const cmd = `${msg}`.split(':')[0].toLowerCase() const val = `${msg}`.substr(cmd.length + 1) if (!this.passives[cmd]) { return } - this.passives[cmd](val, false) + this.passives[cmd](new Param(val), false) } // Events diff --git a/desktop/sources/scripts/terminal.js b/desktop/sources/scripts/terminal.js index f8a81a1..b78e9bb 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 = 137 + this.version = 138 this.library = library this.orca = new Orca(this) diff --git a/examples/benchmarks/rw.orca b/examples/benchmarks/rw.orca index d584ad6..f8033a2 100644 --- a/examples/benchmarks/rw.orca +++ b/examples/benchmarks/rw.orca @@ -1,17 +1,18 @@ -...............................2C4....... -.#.READ.#.......................14T0246.. -................................lV2...... -.C8...........Cg...........Vl............ -.30O01234567..b8T01234567..202Q01234567.. -...3............3............23.......... -......................................... -.#.WRITE.#............................... -......................................... -.C8.C8........Cg.C8........Vl............ -.30X3.........b8P3.........202G01........ -...01234567.....01234567......01010101... -......................................... -......................................... -......................................... -......................................... -.........................................
\ No newline at end of file +..................................2C4..... +.#.READ.#........................2M1...... +................................lV2....... +.C8...........Cg...........Vl............. +.30O01234567..b8T01234567..202Q01234567... +...3............3............23........... +.......................................... +.#.WRITE.#................................ +.......................................... +.C8.C8........Cg.C8........Vl............. +.30X3.........b8P3.........202G01......... +...01234567.....01234567......0101.101.... +.......................................... +.......................................... +.......................................... +.......................................... +.......................................... +..........................................
\ No newline at end of file |