diff options
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | desktop/sources/scripts/commander.js | 8 | ||||
-rw-r--r-- | desktop/sources/scripts/cursor.js | 6 |
3 files changed, 16 insertions, 1 deletions
@@ -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) |