aboutsummaryrefslogtreecommitdiffhomepage
path: root/desktop/core/operator.js
diff options
context:
space:
mode:
authorDevine Lu Linvega <[email protected]>2019-04-18 08:28:18 +0900
committerDevine Lu Linvega <[email protected]>2019-04-18 08:28:18 +0900
commitdff99f5bc187a09c5181be4e09ba9790977589cd (patch)
tree50bf506ad0fd7b9408a7d6807aa94244e77476e6 /desktop/core/operator.js
parentb193a8a02b0c8c064e1279904ec91eea440a5b15 (diff)
downloadOrca-dff99f5bc187a09c5181be4e09ba9790977589cd.tar.gz
Orca-dff99f5bc187a09c5181be4e09ba9790977589cd.zip
Implemented case sensitive operators, fixes #83
Diffstat (limited to 'desktop/core/operator.js')
-rw-r--r--desktop/core/operator.js20
1 files changed, 16 insertions, 4 deletions
diff --git a/desktop/core/operator.js b/desktop/core/operator.js
index a8aad9f..dc8e79d 100644
--- a/desktop/core/operator.js
+++ b/desktop/core/operator.js
@@ -18,10 +18,11 @@ function Operator (orca, x, y, glyph = '.', passive = false) {
return toValue ? clamp(orca.valueOf(g), min, max) : g
}
- this.output = function (g, lock = false) {
- if (!this.ports.output) { return }
- if (!g) { return }
- orca.write(this.x + this.ports.output.x, this.y + this.ports.output.y, g)
+ this.output = function (g, lock = false, casesensitive = false) {
+ if (!this.ports.output || !g) { return }
+ const uppercase = casesensitive === true ? this.getCase() : false
+ const glyph = uppercase === true ? `${g}`.toUpperCase() : g
+ orca.write(this.x + this.ports.output.x, this.y + this.ports.output.y, glyph)
if (lock) {
orca.lock(this.x + this.ports.output.x, this.y + this.ports.output.y)
}
@@ -115,10 +116,21 @@ function Operator (orca, x, y, glyph = '.', passive = false) {
return a
}
+ this.getCase = function (ports = this.ports.input) {
+ for (const id in ports) {
+ const value = this.listen(ports[id])
+ if (isUpperCase(value) === false) {
+ return false
+ }
+ }
+ return true
+ }
+
this.docs = function () {
return `\`${this.glyph.toUpperCase()}\` **${this.name}**: ${this.info}`
}
+ function isUpperCase (a) { return `${a}`.toUpperCase() === `${a}` }
function clamp (v, min, max) { return v < min ? min : v > max ? max : v }
}