aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDevine Lu Linvega <[email protected]>2019-06-03 08:12:04 +0900
committerDevine Lu Linvega <[email protected]>2019-06-03 08:12:04 +0900
commit88917885af238ad975e92c6f2730f3fc520ed4a8 (patch)
treef6d6895fb6177a5fea35be973fdbf6a772e0c686
parent8a9b6ec3aa15bd5cf1be005a93d0d4b62b457900 (diff)
downloadOrca-88917885af238ad975e92c6f2730f3fc520ed4a8.tar.gz
Orca-88917885af238ad975e92c6f2730f3fc520ed4a8.zip
Optimized UC detect
-rw-r--r--desktop/core/io/midi.js2
-rw-r--r--desktop/core/operator.js17
-rw-r--r--desktop/sources/scripts/lib/controller.js9
3 files changed, 13 insertions, 15 deletions
diff --git a/desktop/core/io/midi.js b/desktop/core/io/midi.js
index 3e9f429..01706e9 100644
--- a/desktop/core/io/midi.js
+++ b/desktop/core/io/midi.js
@@ -42,7 +42,7 @@ export default function Midi (terminal) {
const transposed = this.transpose(item.note, item.octave)
const channel = terminal.orca.valueOf(item.channel)
- if(!transposed){ return }
+ if (!transposed) { return }
const c = down === true ? 0x90 + channel : 0x80 + channel
const n = transposed.id
diff --git a/desktop/core/operator.js b/desktop/core/operator.js
index d69b432..f2a9ce5 100644
--- a/desktop/core/operator.js
+++ b/desktop/core/operator.js
@@ -27,7 +27,7 @@ export default function Operator (orca, x, y, glyph = '.', passive = false) {
this.output = function (g) {
if (!this.ports.output) { console.warn(this.name, 'Trying to output, but no port'); return }
if (!g) { return }
- orca.write(this.x + this.ports.output.x, this.y + this.ports.output.y, this.requireUC() === true ? `${g}`.toUpperCase() : g)
+ orca.write(this.x + this.ports.output.x, this.y + this.ports.output.y, this.shouldUpperCase() === true ? `${g}`.toUpperCase() : g)
}
this.bang = function (b) {
@@ -116,15 +116,12 @@ export default function Operator (orca, x, y, glyph = '.', passive = false) {
return a
}
- this.requireUC = function (ports = this.ports) {
- if (this.ports.output.sensitive !== true) { return false }
- for (const id in ports) {
- const value = this.listen(ports[id])
- if (value.length !== 1) { continue }
- if (value.toLowerCase() === value.toUpperCase()) { continue }
- if (`${value}`.toUpperCase() === `${value}`) { return true }
- }
- return false
+ this.shouldUpperCase = function (ports = this.ports) {
+ if (!this.ports.output || !this.ports.output.sensitive) { return false }
+ const value = this.listen({ x: 1, y: 0 })
+ if (value.toLowerCase() === value.toUpperCase()) { return false }
+ if (value.toUpperCase() !== value) { return false }
+ return true
}
// Docs
diff --git a/desktop/sources/scripts/lib/controller.js b/desktop/sources/scripts/lib/controller.js
index 6608a92..ff0ce70 100644
--- a/desktop/sources/scripts/lib/controller.js
+++ b/desktop/sources/scripts/lib/controller.js
@@ -15,10 +15,11 @@ export default function Controller () {
this.add = function (mode, cat, label, fn, accelerator) {
if (!this.menu[mode]) { this.menu[mode] = {} }
if (!this.menu[mode][cat]) { this.menu[mode][cat] = {} }
- this.menu[mode][cat][label] = { fn: function(_menuItem, browserWindow) {
- browserWindow.webContents.focus();
- fn.apply(this, arguments);
- }, accelerator: accelerator }
+ this.menu[mode][cat][label] = { fn: function (_menuItem, browserWindow) {
+ browserWindow.webContents.focus()
+ fn.apply(this, arguments)
+ },
+ accelerator: accelerator }
}
this.addRole = function (mode, cat, label) {