aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDevine Lu Linvega <[email protected]>2018-12-04 17:06:03 +1200
committerDevine Lu Linvega <[email protected]>2018-12-04 17:06:03 +1200
commit1c0015d14814c8c10fa10e2d815470a5752921a3 (patch)
treee8b50238d37de41f9ec6bf1aecca9a733d10dc05
parent2f301aba5ba4d8ae04e95606dcd48a15ec8f3499 (diff)
downloadOrca-1c0015d14814c8c10fa10e2d815470a5752921a3.tar.gz
Orca-1c0015d14814c8c10fa10e2d815470a5752921a3.zip
Improved docs
-rw-r--r--README.md13
-rw-r--r--desktop/core/library/_keys.js4
-rw-r--r--desktop/main.js8
-rw-r--r--desktop/sources/index.html2
-rw-r--r--desktop/sources/scripts/cursor.js8
-rw-r--r--desktop/sources/scripts/io.js10
-rw-r--r--desktop/sources/scripts/keyboard.js16
-rw-r--r--desktop/sources/scripts/lib/controller.js119
-rw-r--r--desktop/sources/scripts/terminal.js2
-rw-r--r--examples/_keys.orca13
-rw-r--r--examples/_midi.orca (renamed from examples/midi.orca)0
-rw-r--r--examples/_udp.orca (renamed from examples/udp.orca)0
-rw-r--r--examples/add.orca13
-rw-r--r--examples/variable.orca13
-rw-r--r--examples/variables.orca13
15 files changed, 65 insertions, 169 deletions
diff --git a/README.md b/README.md
index 20cb36f..9b559b4 100644
--- a/README.md
+++ b/README.md
@@ -57,6 +57,7 @@ npm start
- `enter` toggle insert/write.
- `space` toggle play/pause.
+- `/` toggle insert/keys.
- `shift+arrow` resize cursor size.
- `ctrl/meta+arrow` jump cursor position.
- `>` increase BPM.
@@ -82,11 +83,11 @@ npm start
- `ctrl/meta+}` increase program size horizontally.
- `ctrl/meta+{` decrease program size horizontally.
-## Output
+## Special Operators
### Midi Output
-The midi operator is `:`, it takes up to 5 inputs('channel, 'octave, 'note, velocity, length). For example, `:25C`, is a **C note, on the 5th octave, through the 3rd MIDI channel**, `:04c`, is a **C# note, on the 4th octave, through the 1st MIDI channel**.
+The midi operator `:` takes up to 5 inputs('channel, 'octave, 'note, velocity, length). For example, `:25C`, is a **C note, on the 5th octave, through the 3rd MIDI channel**, `:04c`, is a **C# note, on the 4th octave, through the 1st MIDI channel**. See it in action with [midi.orca](https://github.com/hundredrabbits/Orca/blob/master/examples/_midi.orca).
#### Velocity*
@@ -96,17 +97,17 @@ Velocity is either from `0-9`(10 steps), or `A-Z`(26 steps). For example, `:34C8
Note length is a value from `1-f`, which is a ratio of a full bar, *1* being `1/1`(a full bar), *2* being `1/2`(half), *3* being `1/3`(third).. and *f* being `1/16`. For example, `:27FZ4`, is a **F note, on the 7th octave, through the 3rd MIDI channel with a velocity of 100%, lasting for 1/4 of a bar**.
-To see it in action, see the [midi.orca](https://github.com/hundredrabbits/Orca/blob/master/examples/midi.orca) example.
-
#### Set Device Id
To set the Midi device, open the console with `ctrl+.`, and type `terminal.io.listMidiDevices()` to see the list of available devices, and type `terminal.io.setMidiDevice(2)` to select the 2nd available device. This will be improved soon.
### UDP Output
-The [UDP](https://nodejs.org/api/dgram.html#dgram_socket_send_msg_offset_length_port_address_callback) special function is `3;MSG`, it has one haste input that gets a string length and locks the eastward ports. It sends the message on bang to the port `49160`. You can use the [listener.js](https://github.com/hundredrabbits/Orca/blob/master/listener.js) to test UDP messages.
+The [UDP](https://nodejs.org/api/dgram.html#dgram_socket_send_msg_offset_length_port_address_callback) operator `;`, takes one haste input that is a string length and locks the eastwardly ports. It sends the message on bang to the port `49160`. You can use the [listener.js](https://github.com/hundredrabbits/Orca/blob/master/listener.js) to test UDP messages. See it in action with [udp.orca](https://github.com/hundredrabbits/Orca/blob/master/examples/_udp.orca).
+
+#### Keyboard Input
-To see it in action, see the [udp.orca](https://github.com/hundredrabbits/Orca/blob/master/examples/udp.orca) example.
+The keys operator `!` will bang on a corresponding keyboard keypress when the cursor is in **keyboard mode**(toggle with `/`). For instance, `!a`, will output a bang when pressing the `a` key in **keyboard mode**. See it in action with the [keys.orca](https://github.com/hundredrabbits/Orca/blob/master/examples/_keys.orca).
<img src='https://raw.githubusercontent.com/hundredrabbits/Orca/master/resources/preview.hardware.jpg' width="600"/>
diff --git a/desktop/core/library/_keys.js b/desktop/core/library/_keys.js
index b39d490..f8bb96f 100644
--- a/desktop/core/library/_keys.js
+++ b/desktop/core/library/_keys.js
@@ -8,11 +8,11 @@ function OperatorKeys (orca, x, y, passive) {
this.name = 'keys'
this.info = 'Bangs on keyboard input.'
- this.ports.haste.key = { x: -1, y: 0 }
+ this.ports.input.key = { x: 1, y: 0 }
this.ports.output = { x: 0, y: 1 }
this.run = function () {
- const key = this.listen(this.ports.haste.key)
+ const key = this.listen(this.ports.input.key)
if (key === '.') { return }
diff --git a/desktop/main.js b/desktop/main.js
index 29d7c0c..f9d234b 100644
--- a/desktop/main.js
+++ b/desktop/main.js
@@ -3,7 +3,7 @@ const path = require('path')
const url = require('url')
const shell = require('electron').shell
-let is_shown = true
+let isShown = true
app.win = null
@@ -30,11 +30,11 @@ app.on('ready', () => {
})
app.win.on('hide', function () {
- is_shown = false
+ isShown = false
})
app.win.on('show', function () {
- is_shown = true
+ isShown = true
})
app.on('window-all-closed', () => {
@@ -60,7 +60,7 @@ app.toggle_visible = function () {
if (process.platform === 'win32') {
if (!app.win.isMinimized()) { app.win.minimize() } else { app.win.restore() }
} else {
- if (is_shown && !app.win.isFullScreen()) { app.win.hide() } else { app.win.show() }
+ if (isShown && !app.win.isFullScreen()) { app.win.hide() } else { app.win.show() }
}
}
diff --git a/desktop/sources/index.html b/desktop/sources/index.html
index 09b95ed..1e2fd62 100644
--- a/desktop/sources/index.html
+++ b/desktop/sources/index.html
@@ -55,7 +55,7 @@
terminal.controller.add("default","Program","Incr. Row",() => { terminal.modGrid(0,1); },"}")
terminal.controller.add("default","Program","Decr. Row",() => { terminal.modGrid(0,-1); },"{")
- terminal.controller.add("default","Keyboard","Toggle Play Mode",() => { terminal.keyboard.toggleMode(); },"/")
+ terminal.controller.add("default","Keyboard","Toggle Play Mode",() => { terminal.cursor.toggleMode(2); },"/")
terminal.controller.add("default","Theme","Default Theme",() => { terminal.theme.noir(); },"CmdOrCtrl+Shift+1")
terminal.controller.add("default","Theme","Light Theme",() => { terminal.theme.pale(); },"CmdOrCtrl+Shift+2")
diff --git a/desktop/sources/scripts/cursor.js b/desktop/sources/scripts/cursor.js
index c94465b..ea641b7 100644
--- a/desktop/sources/scripts/cursor.js
+++ b/desktop/sources/scripts/cursor.js
@@ -49,6 +49,10 @@ function Cursor (orca, terminal) {
}
this.write = function (g) {
+ if (this.node === 2) {
+ terminal.io.sendKey(event.key)
+ return
+ }
orca.write(this.x, this.y, g)
if (this.mode === 1) {
this.move(1, 0)
@@ -63,8 +67,8 @@ function Cursor (orca, terminal) {
terminal.history.record()
}
- this.toggleMode = function () {
- this.mode = this.mode === 0 ? 1 : 0
+ this.toggleMode = function (val) {
+ this.mode = this.mode === 0 ? val : 0
}
this.inspect = function (name = true, ports = false) {
diff --git a/desktop/sources/scripts/io.js b/desktop/sources/scripts/io.js
index e9d3b41..2b4f80c 100644
--- a/desktop/sources/scripts/io.js
+++ b/desktop/sources/scripts/io.js
@@ -46,13 +46,9 @@ function IO (terminal) {
this.playUdp = function (data) {
const udp = dgram.createSocket('udp4')
- try {
- udp.send(Buffer.from(`${data}`), 49160, 'localhost', (err) => {
- udp.close()
- })
- } catch (err) {
- console.warn('Udp error?')
- }
+ udp.send(Buffer.from(`${data}`), 49160, 'localhost', (err) => {
+ udp.close()
+ })
}
// Midi
diff --git a/desktop/sources/scripts/keyboard.js b/desktop/sources/scripts/keyboard.js
index fb34a59..d3ab352 100644
--- a/desktop/sources/scripts/keyboard.js
+++ b/desktop/sources/scripts/keyboard.js
@@ -3,11 +3,6 @@
function Keyboard (orca, terminal) {
this.locks = []
this.history = ''
- this.mode = 0
-
- this.toggleMode = function () {
- this.mode = this.mode === 0 ? 1 : 0
- }
this.onKeyDown = function (event) {
// Reset
@@ -34,7 +29,7 @@ function Keyboard (orca, terminal) {
if (event.metaKey) { return }
if (event.ctrlKey) { return }
- if (event.key === 'Enter') { terminal.cursor.toggleMode(); return }
+ if (event.key === 'Enter') { terminal.cursor.toggleMode(1); return }
if (event.key === 'Backspace') { terminal.cursor.erase(); return }
if (event.key === ' ') { terminal.pause(); event.preventDefault(); return }
if (event.key === 'Escape') { terminal.clear(); terminal.isPaused = false; terminal.cursor.reset(); return }
@@ -47,14 +42,7 @@ function Keyboard (orca, terminal) {
if (event.key === '<') { terminal.modSpeed(-1); event.preventDefault(); return }
if (event.key.length === 1) {
- // Send key
- if (this.mode === 1 && event.key !== '/') {
- terminal.io.sendKey(event.key)
- event.preventDefault()
- return
- } else {
- terminal.cursor.write(event.key)
- }
+ terminal.cursor.write(event.key)
terminal.update()
}
}
diff --git a/desktop/sources/scripts/lib/controller.js b/desktop/sources/scripts/lib/controller.js
index d81f3bd..d7a6b80 100644
--- a/desktop/sources/scripts/lib/controller.js
+++ b/desktop/sources/scripts/lib/controller.js
@@ -52,61 +52,6 @@ function Controller () {
this.app.inject_menu(this.format())
}
- this.docs = function () {
- console.log('Generating docs..')
- const svg = this.generate_svg(this.format())
- const txt = this.documentation(this.format())
- dialog.showSaveDialog((fileName) => {
- if (fileName === undefined) { return }
- fileName = fileName.substr(-4, 4) !== '.svg' ? fileName + '.svg' : fileName
- fs.writeFile(fileName, svg)
- fs.writeFile(fileName.replace('.svg', '.md'), txt)
- })
- }
-
- this.generate_svg = function (m) {
- const svg_html = ''
-
- for (const id in this.layout) {
- const key = this.layout[id]
- const acc = this.accelerator_for_key(key.name, m)
- svg_html += `<rect x="${key.x + 1}" y="${key.y + 1}" width="${key.width - 2}" height="${key.height - 2}" rx="4" ry="4" title="${key.name}" stroke="#ccc" fill="none" stroke-width="1"/>`
- svg_html += `<rect x="${key.x + 3}" y="${key.y + 3}" width="${key.width - 6}" height="${key.height - 12}" rx="3" ry="3" title="${key.name}" stroke="${acc.basic ? '#000' : acc.ctrl ? '#ccc' : '#fff'}" fill="${acc.basic ? '#000' : acc.ctrl ? '#ccc' : '#fff'}" stroke-width="1"/>`
- svg_html += `<text x="${key.x + 10}" y="${key.y + 20}" font-size='11' font-family='Input Mono' stroke-width='0' fill='${acc.basic ? '#fff' : '#000'}'>${key.name.toUpperCase()}</text>`
- svg_html += acc && acc.basic ? `<text x="${key.x + 10}" y="${key.y + 35}" font-size='7' font-family='Input Mono' stroke-width='0' fill='#fff'>${acc.basic}</text>` : ''
- svg_html += acc && acc.ctrl ? `<text x="${key.x + 10}" y="${key.y + 45}" font-size='7' font-family='Input Mono' stroke-width='0' fill='#000'>${acc.ctrl}</text>` : ''
- }
- return `<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" width="900" height="300" version="1.0" style="fill:none;stroke:black;stroke-width:2px;">${svg_html}</svg>`
- }
-
- this.documentation = function () {
- const txt = ''
-
- txt += this.documentation_for_mode('default', this.menu.default)
-
- for (name in this.menu) {
- if (name === 'default') { continue }
- txt += this.documentation_for_mode(name, this.menu[name])
- }
- return txt
- }
-
- this.documentation_for_mode = function (name, mode) {
- const txt = `## ${name} Mode\n\n`
-
- for (const id in mode) {
- if (id === '*' || id === 'Edit') { continue }
- txt += `### ${id}\n`
- for (name in mode[id]) {
- const option = mode[id][name]
- txt += `- ${name}: \`${option.accelerator}\`\n`
- }
- txt += '\n'
- }
-
- return txt + '\n'
- }
-
this.accelerator_for_key = function (key, menu) {
const acc = { basic: null, ctrl: null }
for (cat in menu) {
@@ -119,70 +64,6 @@ function Controller () {
}
return acc
}
-
- this.layout = [
- { x: 0, y: 0, width: 60, height: 60, name: 'esc' },
- { x: 60, y: 0, width: 60, height: 60, name: '1' },
- { x: 120, y: 0, width: 60, height: 60, name: '2' },
- { x: 180, y: 0, width: 60, height: 60, name: '3' },
- { x: 240, y: 0, width: 60, height: 60, name: '4' },
- { x: 300, y: 0, width: 60, height: 60, name: '5' },
- { x: 360, y: 0, width: 60, height: 60, name: '6' },
- { x: 420, y: 0, width: 60, height: 60, name: '7' },
- { x: 480, y: 0, width: 60, height: 60, name: '8' },
- { x: 540, y: 0, width: 60, height: 60, name: '9' },
- { x: 600, y: 0, width: 60, height: 60, name: '0' },
- { x: 660, y: 0, width: 60, height: 60, name: '-' },
- { x: 720, y: 0, width: 60, height: 60, name: 'plus' },
- { x: 780, y: 0, width: 120, height: 60, name: 'backspace' },
- { x: 0, y: 60, width: 90, height: 60, name: 'tab' },
- { x: 90, y: 60, width: 60, height: 60, name: 'q' },
- { x: 150, y: 60, width: 60, height: 60, name: 'w' },
- { x: 210, y: 60, width: 60, height: 60, name: 'e' },
- { x: 270, y: 60, width: 60, height: 60, name: 'r' },
- { x: 330, y: 60, width: 60, height: 60, name: 't' },
- { x: 390, y: 60, width: 60, height: 60, name: 'y' },
- { x: 450, y: 60, width: 60, height: 60, name: 'u' },
- { x: 510, y: 60, width: 60, height: 60, name: 'i' },
- { x: 570, y: 60, width: 60, height: 60, name: 'o' },
- { x: 630, y: 60, width: 60, height: 60, name: 'p' },
- { x: 690, y: 60, width: 60, height: 60, name: '[' },
- { x: 750, y: 60, width: 60, height: 60, name: ']' },
- { x: 810, y: 60, width: 90, height: 60, name: '|' },
- { x: 0, y: 120, width: 105, height: 60, name: 'caps' },
- { x: 105, y: 120, width: 60, height: 60, name: 'a' },
- { x: 165, y: 120, width: 60, height: 60, name: 's' },
- { x: 225, y: 120, width: 60, height: 60, name: 'd' },
- { x: 285, y: 120, width: 60, height: 60, name: 'f' },
- { x: 345, y: 120, width: 60, height: 60, name: 'g' },
- { x: 405, y: 120, width: 60, height: 60, name: 'h' },
- { x: 465, y: 120, width: 60, height: 60, name: 'j' },
- { x: 525, y: 120, width: 60, height: 60, name: 'k' },
- { x: 585, y: 120, width: 60, height: 60, name: 'l' },
- { x: 645, y: 120, width: 60, height: 60, name: ';' },
- { x: 705, y: 120, width: 60, height: 60, name: "'" },
- { x: 765, y: 120, width: 135, height: 60, name: 'enter' },
- { x: 0, y: 180, width: 135, height: 60, name: 'shift' },
- { x: 135, y: 180, width: 60, height: 60, name: 'z' },
- { x: 195, y: 180, width: 60, height: 60, name: 'x' },
- { x: 255, y: 180, width: 60, height: 60, name: 'c' },
- { x: 315, y: 180, width: 60, height: 60, name: 'v' },
- { x: 375, y: 180, width: 60, height: 60, name: 'b' },
- { x: 435, y: 180, width: 60, height: 60, name: 'n' },
- { x: 495, y: 180, width: 60, height: 60, name: 'm' },
- { x: 555, y: 180, width: 60, height: 60, name: ',' },
- { x: 615, y: 180, width: 60, height: 60, name: '.' },
- { x: 675, y: 180, width: 60, height: 60, name: '/' },
- { x: 735, y: 180, width: 165, height: 60, name: 'capslock' },
- { x: 0, y: 240, width: 90, height: 60, name: 'ctrl' },
- { x: 90, y: 240, width: 90, height: 60, name: 'cmd' },
- { x: 180, y: 240, width: 90, height: 60, name: 'alt' },
- { x: 270, y: 240, width: 270, height: 60, name: 'space' },
- { x: 810, y: 240, width: 90, height: 60, name: 'ctrl' },
- { x: 720, y: 240, width: 90, height: 60, name: 'pn' },
- { x: 630, y: 240, width: 90, height: 60, name: 'fn' },
- { x: 540, y: 240, width: 90, height: 60, name: 'alt' }
- ]
}
module.exports = new Controller()
diff --git a/desktop/sources/scripts/terminal.js b/desktop/sources/scripts/terminal.js
index 21f3579..5e1d1ea 100644
--- a/desktop/sources/scripts/terminal.js
+++ b/desktop/sources/scripts/terminal.js
@@ -177,7 +177,7 @@ function Terminal (orca, tile = { w: 20, h: 30 }) {
this.write(`${this.cursor.x},${this.cursor.y}`, col * 0, 1, this.size.grid.w)
this.write(`${this.cursor.w}:${this.cursor.h}`, col * 1, 1, this.size.grid.w)
this.write(`${this.cursor.inspect()}`, col * 2, 1, this.size.grid.w)
- this.write(`${this.source}${this.keyboard.mode === 1 ? '^' : this.cursor.mode === 1 ? '+' : ''}`, col * 3, 1, this.size.grid.w)
+ this.write(`${this.source}${this.cursor.mode === 2 ? '^' : this.cursor.mode === 1 ? '+' : ''}`, col * 3, 1, this.size.grid.w)
// Grid
this.write(`${orca.w}x${orca.h}`, col * 0, 0, this.size.grid.w)
this.write(`${this.size.grid.w}/${this.size.grid.h}`, col * 1, 0, this.size.grid.w)
diff --git a/examples/_keys.orca b/examples/_keys.orca
new file mode 100644
index 0000000..568b28a
--- /dev/null
+++ b/examples/_keys.orca
@@ -0,0 +1,13 @@
+.........................................
+.#.KEYS.#................................
+.........................................
+.#.TOGGLE.KEYS.MODE.WITH.SLASH.#.........
+.#.PRESS.a.b.OR.c.#......................
+.........................................
+.........................................
+........!a......!a......!a...............
+.........................................
+.........................................
+.........................................
+.........................................
+......................................... \ No newline at end of file
diff --git a/examples/midi.orca b/examples/_midi.orca
index 6dfc927..6dfc927 100644
--- a/examples/midi.orca
+++ b/examples/_midi.orca
diff --git a/examples/udp.orca b/examples/_udp.orca
index fb75a09..fb75a09 100644
--- a/examples/udp.orca
+++ b/examples/_udp.orca
diff --git a/examples/add.orca b/examples/add.orca
new file mode 100644
index 0000000..cc80345
--- /dev/null
+++ b/examples/add.orca
@@ -0,0 +1,13 @@
+.........................................
+.#.ADD.#.................................
+.........................................
+.........................................
+..A12A34.................................
+..3Y37...................................
+....JJ...................................
+...A37...................................
+...a.....................................
+.........................................
+.........................................
+.........................................
+......................................... \ No newline at end of file
diff --git a/examples/variable.orca b/examples/variable.orca
new file mode 100644
index 0000000..c2479b9
--- /dev/null
+++ b/examples/variable.orca
@@ -0,0 +1,13 @@
+.........................................
+.#.VARIABLES.#...........................
+.........................................
+.#.WRITE.#...............................
+.........................................
+.aV1.bV2.cV3.............................
+.........................................
+.#.READ.#................................
+.........................................
+..Va..Vb..Vc.............................
+..1...2...3..............................
+.........................................
+......................................... \ No newline at end of file
diff --git a/examples/variables.orca b/examples/variables.orca
deleted file mode 100644
index 1a228a5..0000000
--- a/examples/variables.orca
+++ /dev/null
@@ -1,13 +0,0 @@
-.........................................
-.#.VARIABLES.#....R.3.R.3.R.3............
-................aV1.bV2.cV2..............
-...Va.Vb.Vc..............................
-...1..2..2...............................
-...J..J..J.......#.READ.#................
-...1Y12Y22...............................
-.....JJ.JJ...............................
-....A12A22.......Va..Vb..Vc..............
-....3Y34.........1...2...2...............
-......JJ.................................
-......34.................................
-......................................... \ No newline at end of file