diff --git a/desktop/main.js b/desktop/main.js index cd5529f..cb41d2c 100644 --- a/desktop/main.js +++ b/desktop/main.js @@ -10,7 +10,7 @@ app.win = null app.on('ready', () => { app.win = new BrowserWindow({ width: 660, - height: 390, + height: 392, minWidth: 320, minHeight: 320, backgroundColor: '#000', diff --git a/desktop/sources/index.html b/desktop/sources/index.html index ec7de92..576fbff 100644 --- a/desktop/sources/index.html +++ b/desktop/sources/index.html @@ -7,6 +7,7 @@ + diff --git a/desktop/sources/links/main.css b/desktop/sources/links/main.css index 1a4195d..9d3af84 100644 --- a/desktop/sources/links/main.css +++ b/desktop/sources/links/main.css @@ -1,13 +1,12 @@ body { margin:0px; padding:0px; overflow:hidden; font-family:"input_mono_regular",courier,monospace; background:000; -webkit-app-region: drag; -webkit-user-select: none; font-size:12px;} + *:focus {outline: none; } yu { display:block; } -:root { --background: "#222"; --f_high: "#fff";--f_med: "#777";--f_low: "#444";--f_inv: "#000";--b_high: "#000";--b_med: "#affec7";--b_low: "#000";--b_inv: "#affec7"; } - #ronin { background:var(--b_low); height: 100vh; width:100vw; } -#ronin #commander { z-index: 9000; top: 15px; position: absolute; transition: all 150ms; left: 15px; width: calc(50vw - 60px); height: calc(100vh - 60px); padding: 15px; border-right: 1px solid #333;} +#ronin #commander { z-index: 9000; top: 15px; position: absolute; left: 15px; width: calc(50vw - 60px); height: calc(100vh - 60px); padding: 15px; border-right: 1px solid #333;} #ronin #commander textarea { background: none; width: 100%; height: calc(100vh - 75px); resize: none; font-size: 12px;color: white; } #ronin #commander div#status { color:#555; } -#ronin canvas#surface { background:red; position: absolute; left:50vw; } \ No newline at end of file +#ronin canvas#surface { position: absolute; right:15px; top:15px; background-image: url("data:image/svg+xml;utf8,"); background-size: 10px 10px; background-position: -4px -4px;} \ No newline at end of file diff --git a/desktop/sources/scripts/commander.js b/desktop/sources/scripts/commander.js index 1495c23..dcc2fc3 100644 --- a/desktop/sources/scripts/commander.js +++ b/desktop/sources/scripts/commander.js @@ -1,4 +1,4 @@ -function Commander () { +function Commander (ronin) { this.el = document.createElement('yu') this.el.id = 'commander' this._input = document.createElement('textarea') @@ -34,6 +34,10 @@ function Commander () { this._input.focus() } + this.run = function (txt = this.el.value) { + console.log(new Lisp(txt, ronin.library)) + } + this.update = function () { } diff --git a/desktop/sources/scripts/library.js b/desktop/sources/scripts/library.js new file mode 100644 index 0000000..daa5c0a --- /dev/null +++ b/desktop/sources/scripts/library.js @@ -0,0 +1,5 @@ +function Library (ronin) { + this.hello = function () { + + } +} diff --git a/desktop/sources/scripts/lisp.js b/desktop/sources/scripts/lisp.js index 4adba58..c54763e 100644 --- a/desktop/sources/scripts/lisp.js +++ b/desktop/sources/scripts/lisp.js @@ -1,10 +1,7 @@ 'use strict' -// Originally created by maryrosecook -// https://github.com/maryrosecook/littlelisp - -function Lisp (input, lib, tables, host) { - const TYPES = { identifier: 0, keyword: 1, number: 2, string: 3, bool: 4 } +function Lisp (input, lib) { + const TYPES = { identifier: 0, number: 1, string: 2, bool: 3 } const Context = function (scope, parent) { this.scope = scope this.parent = parent @@ -56,8 +53,6 @@ function Lisp (input, lib, tables, host) { return interpretList(input, context) } else if (input.type === TYPES.identifier) { return context.get(input.value) - } else if (input.type === TYPES.keyword) { - return host[input.value] ? host[input.value] : null } else if (input.type === TYPES.number || input.type === TYPES.string || input.type === TYPES.bool) { return input.value } @@ -68,8 +63,6 @@ function Lisp (input, lib, tables, host) { return { type: TYPES.number, value: parseFloat(input) } } else if (input[0] === '"' && input.slice(-1) === '"') { return { type: TYPES.string, value: input.slice(1, -1) } - } else if (input[0] === ':') { - return { type: TYPES.keyword, value: input.substr(1, input.length - 1) } } else if (input === 'true' || input === 'false') { return { type: TYPES.bool, value: input === 'true' } } else { @@ -79,9 +72,7 @@ function Lisp (input, lib, tables, host) { const parenthesize = function (input, list) { if (list === undefined) { return parenthesize(input, []) } - const token = input.shift() - if (token === undefined) { return list.pop() } else if (token === '(') { @@ -102,7 +93,7 @@ function Lisp (input, lib, tables, host) { return parenthesize(tokenize(input)) } - this.toString = function () { - return `${interpret(this.parse(input))}` + this.toPixels = function () { + return interpret(this.parse(input)) } } diff --git a/desktop/sources/scripts/ronin.js b/desktop/sources/scripts/ronin.js index 9192da0..fe4a863 100644 --- a/desktop/sources/scripts/ronin.js +++ b/desktop/sources/scripts/ronin.js @@ -15,16 +15,15 @@ function Ronin () { this.el.id = 'ronin' this.theme = new Theme(defaultTheme) - this.commander = new Commander() - this.surface = new Surface() + this.commander = new Commander(this) + this.surface = new Surface(this) + this.library = new Library(this) this.install = function (host = document.body) { - host.appendChild(this.el) - this.commander.install(this.el) this.surface.install(this.el) - - this.theme.install(host, () => { this.update() }) + host.appendChild(this.el) + this.theme.install() } this.start = function () { @@ -32,15 +31,6 @@ function Ronin () { this.commander.start() this.surface.start() - // window.addEventListener('dragover', ronin.io.drag_over) - // window.addEventListener('drop', ronin.io.drop) - // ronin.frame.el.addEventListener('mousedown', ronin.cursor.mouse_down) - // ronin.frame.el.addEventListener('mousemove', ronin.cursor.mouse_move) - // ronin.frame.el.addEventListener('mouseup', ronin.cursor.mouse_up) - // ronin.frame.el.addEventListener('contextmenu', ronin.cursor.mouse_alt) - // window.addEventListener('keydown', ronin.keyboard.key_down) - // window.addEventListener('keyup', ronin.keyboard.key_up) - console.log('Ronin', 'Started') } @@ -48,10 +38,6 @@ function Ronin () { this.theme.reset() } - this.update = function () { - - } - this.load = function (content = this.default()) { } diff --git a/desktop/sources/scripts/surface.js b/desktop/sources/scripts/surface.js index bbea9ab..582b2ea 100644 --- a/desktop/sources/scripts/surface.js +++ b/desktop/sources/scripts/surface.js @@ -1,16 +1,35 @@ -function Surface () { +function Surface (ronin) { this.el = document.createElement('canvas') this.el.id = 'surface' + this.ratio = window.devicePixelRatio this.install = function (host) { host.appendChild(this.el) + window.addEventListener('resize', (e) => { this.onResize() }, false) } this.start = function () { - + this.maximize() + console.log('Surface', `Ratio:${this.ratio}`) } this.update = function () { } + + this.resize = function (size) { + this.el.width = size.w + this.el.height = size.h + this.el.style.width = size.w + 'px' + this.el.style.height = size.h + 'px' + } + + this.maximize = function () { + const size = { w: Math.floor(window.innerWidth / 2) - 15, h: Math.floor(window.innerHeight) - 30 } + this.resize(size) + } + + this.onResize = function () { + this.maximize() + } }