aboutsummaryrefslogtreecommitdiffhomepage
path: root/desktop
diff options
context:
space:
mode:
authorDevine Lu Linvega <[email protected]>2019-04-14 15:54:01 +0900
committerDevine Lu Linvega <[email protected]>2019-04-14 15:54:01 +0900
commitef1b1d6e67c0b8500b7b1e34de9453db02932a6c (patch)
treed34201703f213b3e5482a80bc6d8c44ef18a831c /desktop
parent80638d41b5045d38ee2a441d0244665d4a0500cb (diff)
downloadOrca-ef1b1d6e67c0b8500b7b1e34de9453db02932a6c.tar.gz
Orca-ef1b1d6e67c0b8500b7b1e34de9453db02932a6c.zip
Cleanup Commander
Diffstat (limited to 'desktop')
-rw-r--r--desktop/sources/scripts/clock.js4
-rw-r--r--desktop/sources/scripts/commander.js34
2 files changed, 21 insertions, 17 deletions
diff --git a/desktop/sources/scripts/clock.js b/desktop/sources/scripts/clock.js
index 52d0af4..ef22f70 100644
--- a/desktop/sources/scripts/clock.js
+++ b/desktop/sources/scripts/clock.js
@@ -77,6 +77,10 @@ function Clock (terminal) {
terminal.orca.f = 0
}
+ this.setFrame = function (f) {
+ terminal.orca.f = f
+ }
+
// UI
this.toString = function () {
diff --git a/desktop/sources/scripts/commander.js b/desktop/sources/scripts/commander.js
index 1dc6884..5657fc1 100644
--- a/desktop/sources/scripts/commander.js
+++ b/desktop/sources/scripts/commander.js
@@ -36,22 +36,23 @@ function Commander (terminal) {
}
this.operations = {
- 'p': (val) => { terminal.clock.play() },
- 's': (val) => { terminal.clock.stop() },
- 'f': (val) => { terminal.clock.resetFrame() },
- 'r': (val) => { terminal.run() },
- 'b': (val) => { terminal.clock.set(parseInt(val), parseInt(val), true) },
- 'a': (val) => { terminal.clock.set(null, parseInt(val)) },
- '/': (val) => { terminal.cursor.goto(val) }
+ 'play': (val) => { terminal.clock.play() },
+ 'stop': (val) => { terminal.clock.stop() },
+ 'time': (val) => { terminal.clock.setFrame(val) },
+ 'goto': (val) => { terminal.cursor.goto(val) },
+ 'run': (val) => { terminal.run() },
+ 'bpm': (val) => { terminal.clock.set(parseInt(val), parseInt(val), true) },
+ 'apm': (val) => { terminal.clock.set(null, parseInt(val)) }
}
this.trigger = function (msg = this.query) {
- const cmd = `${msg}`.substr(0, 1).toLowerCase()
+ const cmd = `${msg}`.split(':')[0].toLowerCase()
+ const val = `${msg}`.substr(cmd.length + 1)
if (this.operations[cmd]) {
- this.operations[cmd](msg.substr(1))
+ this.operations[cmd](val)
} else if (this.patterns[msg]) {
- this.inject(this.patterns[cmd])
+ this.inject(this.patterns[msg])
} else {
console.warn(`Unknown message: ${msg}`)
}
@@ -61,16 +62,15 @@ function Commander (terminal) {
// Injections
- this.inject = function (val = this.query) {
- const result = this.patterns[val] ? this.patterns[val].trim().split('\n') : null
- if (!result) { return }
- terminal.cursor.writeBlock(result)
+ this.inject = function (pattern) {
+ if (!pattern) { return }
+ terminal.cursor.writeBlock(pattern.trim().split('\n'))
terminal.cursor.reset()
}
this.preview = function () {
- const result = this.patterns[this.query] ? this.patterns[this.query].trim().split('\n') : null
- if (!result) { terminal.cursor.reset(); return }
+ if (!this.patterns[this.query]) { terminal.cursor.reset(); return }
+ const result = this.patterns[this.query].trim().split('\n')
terminal.cursor.resize(result[0].length, result.length)
}
@@ -108,7 +108,7 @@ function Commander (terminal) {
if (event.key === '>') { terminal.clock.mod(1); event.preventDefault(); return }
if (event.key === '<') { terminal.clock.mod(-1); event.preventDefault(); return }
- // Route key to Commander or Cursor
+ // Route key to Operator or Cursor
terminal[this.isActive === true ? 'commander' : 'cursor'].write(event.key)
}