aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDevine Lu Linvega <[email protected]>2019-04-17 20:21:01 +0900
committerDevine Lu Linvega <[email protected]>2019-04-17 20:21:01 +0900
commitb193a8a02b0c8c064e1279904ec91eea440a5b15 (patch)
tree36798c977a23492f773d388b897314d262a9da9e
parent7c5121ef86ffad17afdb741f9c0ac621ef08b84d (diff)
downloadOrca-b193a8a02b0c8c064e1279904ec91eea440a5b15.tar.gz
Orca-b193a8a02b0c8c064e1279904ec91eea440a5b15.zip
Added move: command
-rw-r--r--README.md3
-rw-r--r--desktop/sources/scripts/commander.js8
-rw-r--r--desktop/sources/scripts/cursor.js6
3 files changed, 16 insertions, 1 deletions
diff --git a/README.md b/README.md
index fbfbb21..35ac1b0 100644
--- a/README.md
+++ b/README.md
@@ -100,7 +100,8 @@ All commands have a shorthand equivalent to their first character, for example,
- `stop` Stops program.
- `run` Runs current frame.
- `time:0` Sets the frame value to `0`.
-- `goto:aV` Sends cursor to `aV`.
+- `goto:aV` Sends cursor to string `aV`.
+- `move:3;4` Move cursor to position `3,4`.
- `bpm:140` Sets bpm speed to `140`.
- `apm:160` Animates bpm speed to `160`.
- `write:H12;34` Write glyph `H`, at `12,34`.
diff --git a/desktop/sources/scripts/commander.js b/desktop/sources/scripts/commander.js
index b64dce4..c79ddbd 100644
--- a/desktop/sources/scripts/commander.js
+++ b/desktop/sources/scripts/commander.js
@@ -40,6 +40,14 @@ function Commander (terminal) {
'apm': (val) => { terminal.clock.set(null, parseInt(val)) },
'bpm': (val) => { terminal.clock.set(parseInt(val), parseInt(val), true) },
'goto': (val) => { terminal.cursor.goto(val) },
+ 'move': (val) => {
+ const pos = val.split(';')
+ const x = parseInt(pos[0])
+ const y = parseInt(pos[1])
+ if (!isNaN(x) && !isNaN(y)) {
+ terminal.cursor.moveTo(x, y)
+ }
+ },
'play': (val) => { terminal.clock.play() },
'run': (val) => { terminal.run() },
'stop': (val) => { terminal.clock.stop() },
diff --git a/desktop/sources/scripts/cursor.js b/desktop/sources/scripts/cursor.js
index 004df49..69aea1e 100644
--- a/desktop/sources/scripts/cursor.js
+++ b/desktop/sources/scripts/cursor.js
@@ -16,6 +16,12 @@ function Cursor (terminal) {
terminal.update()
}
+ this.moveTo = function (x, y) {
+ this.x = clamp(x, 0, terminal.orca.w - 1)
+ this.y = clamp(y, 0, terminal.orca.h - 1)
+ terminal.update()
+ }
+
this.scale = function (x, y) {
this.w = clamp(this.w + x, 1, terminal.orca.w - this.x)
this.h = clamp(this.h - y, 1, terminal.orca.h - this.y)