diff options
author | Devine Lu Linvega <[email protected]> | 2019-04-14 10:15:31 +0900 |
---|---|---|
committer | Devine Lu Linvega <[email protected]> | 2019-04-14 10:15:31 +0900 |
commit | 085a997806786321bdc1e6002bf1a92c76adb303 (patch) | |
tree | 5ed92394bac884ab90adbb54f5cc80d673ef4de8 | |
parent | f9d146efecf92a28d5ab1835a0bc66fafbad7198 (diff) | |
download | Orca-085a997806786321bdc1e6002bf1a92c76adb303.tar.gz Orca-085a997806786321bdc1e6002bf1a92c76adb303.zip |
Better pattern injection
-rw-r--r-- | desktop/sources/scripts/commander.js | 10 | ||||
-rw-r--r-- | desktop/sources/scripts/patterns.js | 14 |
2 files changed, 16 insertions, 8 deletions
diff --git a/desktop/sources/scripts/commander.js b/desktop/sources/scripts/commander.js index f6cfcec..2a9edde 100644 --- a/desktop/sources/scripts/commander.js +++ b/desktop/sources/scripts/commander.js @@ -51,8 +51,6 @@ function Commander (terminal) { terminal.clock.stop() } else if (key === 'r') { terminal.run() - } else if (key === 'i') { - terminal.commander.inject(val) } else if (key === 'f' && Number.isInteger(int)) { terminal.orca.f = int } else if (key === '/') { @@ -64,6 +62,8 @@ function Commander (terminal) { } else if (key === 'w' && val.length >= 4 && val.indexOf(':') > -1) { const pos = val.substr(1).split(':') terminal.orca.write(parseInt(pos[0]), parseInt(pos[1]), val.substr(0, 1)) + } else if (patterns[msg]) { + terminal.commander.inject(msg) } else { console.warn(`Unknown message: ${msg}`) } @@ -72,7 +72,7 @@ function Commander (terminal) { // Injections - this.inject = function (val) { + this.inject = function (val = this.query) { const result = patterns[val] ? patterns[val].trim().split('\n') : null if (!result) { return } terminal.cursor.writeBlock(result) @@ -80,9 +80,7 @@ function Commander (terminal) { } this.preview = function () { - if (this.query.substr(0, 1) !== 'i') { return } - const val = this.query.substr(1) - const result = patterns[val] ? patterns[val].trim().split('\n') : null + const result = patterns[this.query] ? patterns[this.query].trim().split('\n') : null if (!result) { terminal.cursor.reset(); return } terminal.cursor.resize(result[0].length, result.length) } diff --git a/desktop/sources/scripts/patterns.js b/desktop/sources/scripts/patterns.js index 1a2509f..e3c8fe0 100644 --- a/desktop/sources/scripts/patterns.js +++ b/desktop/sources/scripts/patterns.js @@ -2,15 +2,21 @@ const patterns = {} +patterns['vion'] = ` +iV...oV...nV` + +patterns['vionvl'] = ` +iV...oV...nV...vV...lV` + patterns['3kion'] = ` 3Kion .:...` patterns['5kion'] = ` -5Kionvf +5Kionvl .:.....` -patterns['octave'] = ` +patterns['oct'] = ` .7TCDEFGAB ..C.......` @@ -18,4 +24,8 @@ patterns['c4a4'] = ` .C4 A04` +patterns['dy'] = ` +D8 +.Y` + module.exports = patterns |