diff options
author | Devine Lu Linvega <[email protected]> | 2018-12-14 12:20:24 +1200 |
---|---|---|
committer | Devine Lu Linvega <[email protected]> | 2018-12-14 12:20:24 +1200 |
commit | 7178ae6e00af9d6b826ab059a594e9fe40d71fbb (patch) | |
tree | 88543471522b8276cfff908eb99bbe0e7fa47bf4 | |
parent | 4ddc2a50a3136775c65ebeed1d399d3a678d00c4 (diff) | |
download | Orca-7178ae6e00af9d6b826ab059a594e9fe40d71fbb.tar.gz Orca-7178ae6e00af9d6b826ab059a594e9fe40d71fbb.zip |
Getting there..
-rw-r--r-- | desktop/core/library/_room.js | 1 | ||||
-rw-r--r-- | desktop/sources/index.html | 4 | ||||
-rw-r--r-- | desktop/sources/scripts/cursor.js | 32 | ||||
-rw-r--r-- | desktop/sources/scripts/history.js | 12 | ||||
-rw-r--r-- | desktop/sources/scripts/keyboard.js | 2 | ||||
-rw-r--r-- | desktop/sources/scripts/source.js | 2 | ||||
-rw-r--r-- | desktop/sources/scripts/terminal.js | 18 |
7 files changed, 35 insertions, 36 deletions
diff --git a/desktop/core/library/_room.js b/desktop/core/library/_room.js index 9ca0f24..6610e24 100644 --- a/desktop/core/library/_room.js +++ b/desktop/core/library/_room.js @@ -9,6 +9,7 @@ function OperatorRoom (orca, x, y, passive) { this.info = 'Hosts a nested Orca grid.' this.ports.haste.id = { x: -1, y: 0 } + this.ports.output = { x: 0, y: 1 } this.run = function () { const id = this.listen(this.ports.haste.id) diff --git a/desktop/sources/index.html b/desktop/sources/index.html index 250d33b..ad6e0cd 100644 --- a/desktop/sources/index.html +++ b/desktop/sources/index.html @@ -14,9 +14,7 @@ <body> <script> const Terminal = require('./scripts/terminal') - - const terminal = new Terminal(orca) - + const terminal = new Terminal() const { app } = require('electron').remote terminal.install(document.body) diff --git a/desktop/sources/scripts/cursor.js b/desktop/sources/scripts/cursor.js index c4fbf57..30a0416 100644 --- a/desktop/sources/scripts/cursor.js +++ b/desktop/sources/scripts/cursor.js @@ -1,6 +1,6 @@ 'use strict' -function Cursor (orca, terminal) { +function Cursor (terminal) { this.x = 0 this.y = 0 this.w = 1 @@ -9,18 +9,19 @@ function Cursor (orca, terminal) { this.block = [] this.move = function (x, y) { - this.x = clamp(this.x + x, 0, orca.w - 1) - this.y = clamp(this.y - y, 0, orca.h - 1) + this.x = clamp(this.x + x, 0, terminal.room.w - 1) + this.y = clamp(this.y - y, 0, terminal.room.h - 1) terminal.update() } this.scale = function (x, y) { - this.w = clamp(this.w + x, 1, orca.w - this.x) - this.h = clamp(this.h - y, 1, orca.h - this.y) + this.w = clamp(this.w + x, 1, terminal.room.w - this.x) + this.h = clamp(this.h - y, 1, terminal.room.h - this.y) terminal.update() } this.reset = function () { + this.move(0, 0) this.w = 1 this.h = 1 this.mode = 0 @@ -30,8 +31,8 @@ function Cursor (orca, terminal) { this.selectAll = function () { this.x = 0 this.y = 0 - this.w = orca.w - this.h = orca.h + this.w = terminal.room.w + this.h = terminal.room.h this.mode = 0 terminal.update() } @@ -54,7 +55,7 @@ function Cursor (orca, terminal) { terminal.io.sendKey(event.key) return } - orca.write(this.x, this.y, g) + terminal.room.write(this.x, this.y, g) if (this.mode === 1) { this.move(1, 0) } @@ -62,15 +63,14 @@ function Cursor (orca, terminal) { } this.erase = function () { - if (this.w === 1 && this.h === 1 && orca.glyphAt(this.x, this.y) === '.') { this.move(-1, 0); return } // Backspace Effect + if (this.w === 1 && this.h === 1 && terminal.room.glyphAt(this.x, this.y) === '.') { this.move(-1, 0); return } // Backspace Effect this.eraseBlock(this.x, this.y, this.w, this.h) - this.reset() terminal.history.record() } this.toggleMode = function (val) { - if (orca.glyphAt(this.x, this.y) === '/') { - terminal.enter(orca.s.charAt(orca.indexAt(this.x, this.y) - 1)) + if (terminal.room.glyphAt(this.x, this.y) === '/') { + terminal.enter(terminal.room.s.charAt(terminal.room.indexAt(this.x, this.y) - 1)) return } this.mode = this.mode === 0 ? val : 0 @@ -80,7 +80,7 @@ function Cursor (orca, terminal) { if (this.w > 1 || this.h > 1) { return 'multi' } const port = terminal.portAt(this.x, this.y) if (port) { return `${port.name}` } - if (orca.lockAt(this.x, this.y)) { return 'locked' } + if (terminal.room.lockAt(this.x, this.y)) { return 'locked' } return 'empty' } @@ -91,7 +91,7 @@ function Cursor (orca, terminal) { for (let _y = rect.y; _y < rect.y + rect.h; _y++) { const line = [] for (let _x = rect.x; _x < rect.x + rect.w; _x++) { - line.push(orca.glyphAt(_x, _y)) + line.push(terminal.room.glyphAt(_x, _y)) } block.push(line) } @@ -104,7 +104,7 @@ function Cursor (orca, terminal) { for (const lineId in block) { let _x = rect.x for (const glyphId in block[lineId]) { - orca.write(_x, _y, block[lineId][glyphId]) + terminal.room.write(_x, _y, block[lineId][glyphId]) _x++ } _y++ @@ -115,7 +115,7 @@ function Cursor (orca, terminal) { this.eraseBlock = function (x, y, w, h) { for (let _y = y; _y < y + h; _y++) { for (let _x = x; _x < x + w; _x++) { - orca.write(_x, _y, '.') + terminal.room.write(_x, _y, '.') } } terminal.history.record() diff --git a/desktop/sources/scripts/history.js b/desktop/sources/scripts/history.js index d88cfb6..f591cf8 100644 --- a/desktop/sources/scripts/history.js +++ b/desktop/sources/scripts/history.js @@ -1,6 +1,6 @@ 'use strict' -function History (orca, terminal) { +function History (terminal, orca = terminal.room) { this.index = 0 this.frames = [] @@ -16,13 +16,13 @@ function History (orca, terminal) { this.undo = function () { if (this.index === 0) { console.warn('History', 'Reached beginning'); return } this.index = clamp(this.index - 1, 0, this.frames.lengt - 1) - terminal.load(this.frames[this.index], orca.f) + terminal.load(this.frames[this.index], terminal.rooms.hall.f) } this.redo = function () { if (this.index > this.frames.length - 1) { console.warn('History', 'Reached end'); return } this.index = clamp(this.index + 1, 0, this.frames.lengt - 1) - terminal.load(this.frames[this.index], orca.f) + terminal.load(this.frames[this.index], terminal.rooms.hall.f) } this.reset = function () { @@ -31,12 +31,12 @@ function History (orca, terminal) { } this.append = function () { - this.frames.push(`${orca}`) + // this.frames.push(`${orca}`) } this.fork = function () { - this.frames = this.frames.slice(0, this.index + 1) - this.frames.push(`${orca}`) + // this.frames = this.frames.slice(0, this.index + 1) + // this.frames.push(`${orca}`) } 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 9edae4e..94a84eb 100644 --- a/desktop/sources/scripts/keyboard.js +++ b/desktop/sources/scripts/keyboard.js @@ -1,6 +1,6 @@ 'use strict' -function Keyboard (orca, terminal) { +function Keyboard (terminal) { this.locks = [] this.history = '' diff --git a/desktop/sources/scripts/source.js b/desktop/sources/scripts/source.js index 9486b83..87bc2d7 100644 --- a/desktop/sources/scripts/source.js +++ b/desktop/sources/scripts/source.js @@ -1,6 +1,6 @@ 'use strict' -function Source (orca, terminal) { +function Source (terminal, orca = terminal.room) { const fs = require('fs') const { dialog, app } = require('electron').remote diff --git a/desktop/sources/scripts/terminal.js b/desktop/sources/scripts/terminal.js index 379680b..bac4510 100644 --- a/desktop/sources/scripts/terminal.js +++ b/desktop/sources/scripts/terminal.js @@ -1,24 +1,24 @@ 'use strict' -function Terminal (orca, tile = { w: 20, h: 30 }) { +function Terminal (tile = { w: 20, h: 30 }) { const library = require('../../core/library') - const Orca = require('../core/orca') + const Orca = require('../../core/orca') const Cursor = require('./cursor') const Source = require('./source') const History = require('./history') const Keyboard = require('./keyboard') const IO = require('./io') - this.io = new IO(this) - this.cursor = new Cursor(orca, this) - this.source = new Source(orca, this) - this.history = new History(orca, this) - this.keyboard = new Keyboard(orca, this) - this.controller = new Controller() - this.rooms = { hall: new Orca(library) } this.room = this.rooms.hall + this.io = new IO(this) + this.cursor = new Cursor(this) + this.source = new Source(this) + this.history = new History(this) + this.keyboard = new Keyboard(this) + this.controller = new Controller() + // Themes const noir = { background: '#111111', f_high: '#ffffff', f_med: '#777777', f_low: '#444444', f_inv: '#000000', b_high: '#eeeeee', b_med: '#72dec2', b_low: '#444444', b_inv: '#ffb545' } const pale = { background: '#eeeeee', f_high: '#222222', f_med: '#444444', f_low: '#cccccc', f_inv: '#000000', b_high: '#000000', b_med: '#333333', b_low: '#dddddd', b_inv: '#72dec2' } |