From ab309d2a008d4eda57ac7148b0853bdb8b5dd5f1 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Tue, 16 Oct 2018 19:37:42 +1200 Subject: Added Pause/Play --- README.md | 6 ------ cli/terminal.js | 8 ++++---- desktop/sources/index.html | 19 +++++++++---------- desktop/sources/scripts/cursor.js | 15 ++++++++++----- desktop/sources/scripts/keyboard.js | 4 ++-- desktop/sources/scripts/terminal.js | 10 +++++----- 6 files changed, 30 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 29bdf1f..7615f56 100644 --- a/README.md +++ b/README.md @@ -62,10 +62,6 @@ - `BPM`, **bpm**: Set the speed for the Pico terminal. - `VOL`, **volume**: Set the volume for the Pico terminal. -### queries functions - -- `BPM`, **bpm**: Set the speed for the Pico terminal. - ## Logic Functions The logic functions are passive, and they are `a`, `f`, `m`, `y`. @@ -89,11 +85,9 @@ npm start The idea is to build a synth/mini sequencer, here's some tasks I need to tackle before then. -[ ] Migrate Electron build to new core. [ ] custom synth functions, like `:SYN[ADSR](C)` [ ] "I wanna be able to 1000x fastforward my pico programs" [ ] sub programs scope -[ ] block add glyph ## Extras diff --git a/cli/terminal.js b/cli/terminal.js index 70b402d..60978fa 100644 --- a/cli/terminal.js +++ b/cli/terminal.js @@ -11,7 +11,7 @@ function Terminal (pico) { this._inspector = blessed.box({ bottom: 2, left: 2, height: 1, width: '100%-4', style: { fg: '#efefef' } }) this._log = blessed.box({ bottom: 3, left: 2, height: 1, width: '100%-4', style: { fg: '#efefef' } }) - this.is_paused = false + this.isPaused = false this.cursor = { x: 0, @@ -71,15 +71,15 @@ function Terminal (pico) { } this.run = function () { - if (this.is_paused) { return } + if (this.isPaused) { return } this.pico.run() this.update() } this.pause = function () { - this.is_paused = !this.is_paused - this.log(this.is_paused ? "Paused" : "Unpaused") + this.isPaused = !this.isPaused + this.log(this.isPaused ? "Paused" : "Unpaused") } this.load = function (path) { diff --git a/desktop/sources/index.html b/desktop/sources/index.html index fa09315..72c6825 100644 --- a/desktop/sources/index.html +++ b/desktop/sources/index.html @@ -26,23 +26,22 @@ terminal.install(document.body) - terminal.controller.add("default","*","About",() => { require('electron').shell.openExternal('https://github.com/hundredrabbits/Donsol'); },"CmdOrCtrl+,") + terminal.controller.add("default","*","About",() => { require('electron').shell.openExternal('https://github.com/hundredrabbits/Pico'); },"CmdOrCtrl+,") terminal.controller.add("default","*","Fullscreen",() => { app.toggle_fullscreen(); },"CmdOrCtrl+Enter") terminal.controller.add("default","*","Hide",() => { app.toggle_visible(); },"CmdOrCtrl+H") terminal.controller.add("default","*","Inspect",() => { app.inspect(); },"CmdOrCtrl+.") - terminal.controller.add("default","*","Reset",() => { pico.reset(); },"CmdOrCtrl+Backspace") + terminal.controller.add("default","*","Reset",() => { terminal.reset(); },"CmdOrCtrl+Backspace") terminal.controller.add("default","*","Quit",() => { app.exit(); },"CmdOrCtrl+Q") - terminal.controller.add("default","File","New",() => { pico.new(); },"CmdOrCtrl+N") - terminal.controller.add("default","File","Save",() => { pico.save(); },"CmdOrCtrl+S") - terminal.controller.add("default","File","Open",() => { pico.open(); },"CmdOrCtrl+O") + terminal.controller.add("default","File","New",() => { terminal.new(); },"CmdOrCtrl+N") + terminal.controller.add("default","File","Save",() => { terminal.save(); },"CmdOrCtrl+S") + terminal.controller.add("default","File","Open",() => { terminal.open(); },"CmdOrCtrl+O") - terminal.controller.add("default","Program","Play/Pause",() => { pico.pause(); },"CmdOrCtrl+P") - terminal.controller.add("default","Program","Run",() => { pico.run(true); },"Enter") + terminal.controller.add("default","Program","Play/Pause",() => { terminal.pause(); },"Space") - terminal.controller.add("default","Theme","Noir",() => { pico.theme.noir(); },"CmdOrCtrl+Shift+1") - terminal.controller.add("default","Theme","Pale",() => { pico.theme.pale(); },"CmdOrCtrl+Shift+2") - terminal.controller.add("default","Theme","Invert",() => { pico.theme.invert(); },"CmdOrCtrl+Shift+I") + terminal.controller.add("default","Theme","Noir",() => { terminal.theme.noir(); },"CmdOrCtrl+Shift+1") + terminal.controller.add("default","Theme","Pale",() => { terminal.theme.pale(); },"CmdOrCtrl+Shift+2") + terminal.controller.add("default","Theme","Invert",() => { terminal.theme.invert(); },"CmdOrCtrl+Shift+I") terminal.controller.add("default","Theme","Install",() => { require('electron').shell.openExternal('https://github.com/hundredrabbits/Themes'); }) terminal.controller.commit() diff --git a/desktop/sources/scripts/cursor.js b/desktop/sources/scripts/cursor.js index e2f893c..26fcb44 100644 --- a/desktop/sources/scripts/cursor.js +++ b/desktop/sources/scripts/cursor.js @@ -28,17 +28,17 @@ function Cursor (terminal) { } this.copy = function () { - this.terminal.log(`Copy ${this.x},${this.y}[${this.w}x${this.h}]`) + this.terminal.log(`Copy ${this._position()}`) this.block = this.terminal.pico.getBlock(this.x, this.y, this.w, this.h) } this.paste = function () { - this.terminal.log(`Paste ${this.x},${this.y}[${this.w}x${this.h}]`) + this.terminal.log(`Paste ${this._position()}`) this.terminal.pico.addBlock(this.x, this.y, this.block) } this.cut = function () { - this.terminal.log(`Cut ${this.x},${this.y}[${this.w}x${this.h}]`) + this.terminal.log(`Cut ${this._position()}`) this.copy() this.erase() } @@ -48,13 +48,18 @@ function Cursor (terminal) { } this.erase = function (g) { - this.terminal.log(`Erase ${this.x},${this.y}[${this.w}x${this.h}]`) + this.terminal.log(`Erase ${this._position()}`) this.terminal.pico.removeBlock(this.x, this.y, this.w, this.h) } this.inspect = function () { const g = pico.glyphAt(this.x, this.y) - return pico.docs[g] ? pico.docs[g] : `${this.x},${this.y}[${this.w}x${this.h}]` + return pico.docs[g] ? pico.docs[g] : this._position() + } + + this._position = function() + { + return `${this.x},${this.y}`+(this.w != 1 || this.h != 1 ? `[${this.w}x${this.h}]` : '') } function clamp (v, min, max) { return v < min ? min : v > max ? max : v } diff --git a/desktop/sources/scripts/keyboard.js b/desktop/sources/scripts/keyboard.js index 11465e9..917dd74 100644 --- a/desktop/sources/scripts/keyboard.js +++ b/desktop/sources/scripts/keyboard.js @@ -31,8 +31,8 @@ function Keyboard () { if (event.ctrlKey) { return } if (event.key == 'Backspace') { terminal.cursor.erase(); return } - if (event.key == 'Space') { terminal.cursor.insert('.'); event.preventDefault(); return } - if (event.key == 'Escape') { terminal.clear(); terminal.cursor.reset(); return } + if (event.key == ' ') { terminal.pause(); event.preventDefault(); return } + if (event.key == 'Escape') { terminal.clear(); terminal.isPaused = false; terminal.cursor.reset(); return } if (event.key.length == 1) { terminal.cursor.insert(event.key) diff --git a/desktop/sources/scripts/terminal.js b/desktop/sources/scripts/terminal.js index b1a5dd3..6ba4e50 100644 --- a/desktop/sources/scripts/terminal.js +++ b/desktop/sources/scripts/terminal.js @@ -11,7 +11,7 @@ function Terminal (pico) { this.pico = pico this.el = document.createElement('canvas') - this.is_paused = false + this.isPaused = false this.tile = { w: 12, h: 20 } this.debug = 'hello.' this.timer = null @@ -59,15 +59,15 @@ function Terminal (pico) { } this.run = function () { - if (this.is_paused) { return } + if (this.isPaused) { return } this.pico.run() this.update() } this.pause = function () { - this.is_paused = !this.is_paused - this.log(this.is_paused ? 'Paused' : 'Unpaused') + this.isPaused = !this.isPaused + this.log(this.isPaused ? 'Paused' : 'Unpaused') } this.load = function (path) { @@ -211,7 +211,7 @@ function Terminal (pico) { } else { ctx.fillStyle = 'white' } - ctx.fillText(styles.isCursor && g == '.' ? (!pico.is_paused ? '@' : '~') : g.toUpperCase(), (x + 0.5) * this.tile.w, (y + 1) * this.tile.h) + ctx.fillText(styles.isCursor && g == '.' ? (!pico.isPaused ? '@' : '~') : g.toUpperCase(), (x + 0.5) * this.tile.w, (y + 1) * this.tile.h) } function clamp (v, min, max) { return v < min ? min : v > max ? max : v } } -- cgit v1.2.3