aboutsummaryrefslogtreecommitdiffhomepage
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
parentb193a8a02b0c8c064e1279904ec91eea440a5b15 (diff)
downloadOrca-dff99f5bc187a09c5181be4e09ba9790977589cd.tar.gz
Orca-dff99f5bc187a09c5181be4e09ba9790977589cd.zip
Implemented case sensitive operators, fixes #83
-rw-r--r--desktop/core/library/a.js2
-rw-r--r--desktop/core/library/c.js2
-rw-r--r--desktop/core/library/i.js2
-rw-r--r--desktop/core/library/j.js4
-rw-r--r--desktop/core/library/m.js2
-rw-r--r--desktop/core/library/r.js2
-rw-r--r--desktop/core/library/v.js3
-rw-r--r--desktop/core/library/y.js4
-rw-r--r--desktop/core/operator.js20
-rw-r--r--examples/benchmark.orca18
10 files changed, 36 insertions, 23 deletions
diff --git a/desktop/core/library/a.js b/desktop/core/library/a.js
index 2152213..ed23246 100644
--- a/desktop/core/library/a.js
+++ b/desktop/core/library/a.js
@@ -16,7 +16,7 @@ function OperatorA (orca, x, y, passive) {
const a = this.listen(this.ports.input.a, true)
const b = this.listen(this.ports.input.b, true)
const res = orca.keyOf(a + b)
- this.output(`${res}`)
+ this.output(`${res}`, false, true)
}
}
diff --git a/desktop/core/library/c.js b/desktop/core/library/c.js
index 394b5a3..c09fa7c 100644
--- a/desktop/core/library/c.js
+++ b/desktop/core/library/c.js
@@ -17,7 +17,7 @@ function OperatorC (orca, x, y, passive) {
const mod = this.listen(this.ports.input.mod, true)
const val = (Math.floor(orca.f / rate) % (mod || 10))
const res = orca.keyOf(val)
- this.output(`${res}`)
+ this.output(`${res}`, false, true)
}
}
diff --git a/desktop/core/library/i.js b/desktop/core/library/i.js
index 5655d51..7f6117a 100644
--- a/desktop/core/library/i.js
+++ b/desktop/core/library/i.js
@@ -23,7 +23,7 @@ function OperatorI (orca, x, y, passive) {
const next = val + (min < max ? 1 : -1)
const res = next >= real.max ? real.min : next < real.min ? real.max - 1 : next
- this.output(`${orca.keyOf(res)}`)
+ this.output(`${orca.keyOf(res)}`, false, true)
}
}
diff --git a/desktop/core/library/j.js b/desktop/core/library/j.js
index 1cea27e..dbdad31 100644
--- a/desktop/core/library/j.js
+++ b/desktop/core/library/j.js
@@ -16,8 +16,8 @@ function OperatorJ (orca, x, y, passive) {
}
this.run = function () {
- const val = this.listen(this.ports.haste.val)
- this.output(val)
+ const res = this.listen(this.ports.haste.val)
+ this.output(`${res}`)
}
}
diff --git a/desktop/core/library/m.js b/desktop/core/library/m.js
index f63b6af..4b54a79 100644
--- a/desktop/core/library/m.js
+++ b/desktop/core/library/m.js
@@ -17,7 +17,7 @@ function OperatorM (orca, x, y, passive) {
const mod = this.listen(this.ports.input.mod, true)
const key = val % (mod !== 0 ? mod : 1)
const res = orca.keyOf(key)
- this.output(`${res}`)
+ this.output(`${res}`, false, true)
}
}
diff --git a/desktop/core/library/r.js b/desktop/core/library/r.js
index a590cdd..49e48e9 100644
--- a/desktop/core/library/r.js
+++ b/desktop/core/library/r.js
@@ -17,7 +17,7 @@ function OperatorR (orca, x, y, passive) {
const max = this.listen(this.ports.input.max, true)
const val = parseInt((Math.random() * ((max || 10) - min)) + min)
const res = orca.keyOf(val)
- this.output(`${res}`)
+ this.output(`${res}`, false, true)
}
}
diff --git a/desktop/core/library/v.js b/desktop/core/library/v.js
index c83b47e..10a578b 100644
--- a/desktop/core/library/v.js
+++ b/desktop/core/library/v.js
@@ -28,7 +28,8 @@ function OperatorV (orca, x, y, passive) {
if (write !== '.') {
orca.values[write] = read
} else {
- this.output(orca.values[read])
+ const res = orca.values[read]
+ this.output(`${res}`)
}
}
}
diff --git a/desktop/core/library/y.js b/desktop/core/library/y.js
index 7394cea..d077233 100644
--- a/desktop/core/library/y.js
+++ b/desktop/core/library/y.js
@@ -16,8 +16,8 @@ function OperatorY (orca, x, y, passive) {
}
this.run = function () {
- const val = this.listen(this.ports.haste.val)
- this.output(val)
+ const res = this.listen(this.ports.haste.val)
+ this.output(`${res}`)
}
}
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 }
}
diff --git a/examples/benchmark.orca b/examples/benchmark.orca
index 73a20a5..11a24b7 100644
--- a/examples/benchmark.orca
+++ b/examples/benchmark.orca
@@ -1,17 +1,17 @@
.........................................
.#.BENCHMARK.#...........................
.........................................
-.5C5........C5...........................
-..15T012C...25T012C......................
-..aV1.......bV2..........................
-.........................................
-.2Kab..2Kab..2Kab..2Kab..2Kab............
-..A12...F12...I12...M12...R12............
-..3...........1.....1.....1..............
-.........................................
-.........................................
+.8C8.............C8......................
+..38T012AGag.....68T012AGag..............
+..aVA............bVg.....................
.........................................
+..2Kab..2Kab..2Kab..2Kab..2Kab...........
+...AAg...FAg...IAg...MAg...RAg...........
+...q...........a.....a.....f.............
.........................................
+.3Ka.b.3Ka.b.............................
+...ACg...ADg.............................
+....c....................................
.........................................
.........................................
......................................... \ No newline at end of file