Started lisp implementation
This commit is contained in:
parent
7f01d369ed
commit
cfc30f518e
@ -10,7 +10,7 @@ app.win = null
|
|||||||
app.on('ready', () => {
|
app.on('ready', () => {
|
||||||
app.win = new BrowserWindow({
|
app.win = new BrowserWindow({
|
||||||
width: 660,
|
width: 660,
|
||||||
height: 390,
|
height: 392,
|
||||||
minWidth: 320,
|
minWidth: 320,
|
||||||
minHeight: 320,
|
minHeight: 320,
|
||||||
backgroundColor: '#000',
|
backgroundColor: '#000',
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
<script type="text/javascript" src="scripts/commander.js"></script>
|
<script type="text/javascript" src="scripts/commander.js"></script>
|
||||||
<script type="text/javascript" src="scripts/surface.js"></script>
|
<script type="text/javascript" src="scripts/surface.js"></script>
|
||||||
<script type="text/javascript" src="scripts/lisp.js"></script>
|
<script type="text/javascript" src="scripts/lisp.js"></script>
|
||||||
|
<script type="text/javascript" src="scripts/library.js"></script>
|
||||||
<link rel="stylesheet" type="text/css" href="links/reset.css"/>
|
<link rel="stylesheet" type="text/css" href="links/reset.css"/>
|
||||||
<link rel="stylesheet" type="text/css" href="links/fonts.css"/>
|
<link rel="stylesheet" type="text/css" href="links/fonts.css"/>
|
||||||
<link rel="stylesheet" type="text/css" href="links/main.css"/>
|
<link rel="stylesheet" type="text/css" href="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;}
|
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; }
|
*:focus {outline: none; }
|
||||||
|
|
||||||
yu { display:block; }
|
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 { 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 textarea { background: none; width: 100%; height: calc(100vh - 75px); resize: none; font-size: 12px;color: white; }
|
||||||
#ronin #commander div#status { color:#555; }
|
#ronin #commander div#status { color:#555; }
|
||||||
|
|
||||||
#ronin canvas#surface { background:red; position: absolute; left:50vw; }
|
#ronin canvas#surface { position: absolute; right:15px; top:15px; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20'><circle cx='10' cy='10' r='1' fill='%23555'></circle></svg>"); background-size: 10px 10px; background-position: -4px -4px;}
|
@ -1,4 +1,4 @@
|
|||||||
function Commander () {
|
function Commander (ronin) {
|
||||||
this.el = document.createElement('yu')
|
this.el = document.createElement('yu')
|
||||||
this.el.id = 'commander'
|
this.el.id = 'commander'
|
||||||
this._input = document.createElement('textarea')
|
this._input = document.createElement('textarea')
|
||||||
@ -34,6 +34,10 @@ function Commander () {
|
|||||||
this._input.focus()
|
this._input.focus()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.run = function (txt = this.el.value) {
|
||||||
|
console.log(new Lisp(txt, ronin.library))
|
||||||
|
}
|
||||||
|
|
||||||
this.update = function () {
|
this.update = function () {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
5
desktop/sources/scripts/library.js
Normal file
5
desktop/sources/scripts/library.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
function Library (ronin) {
|
||||||
|
this.hello = function () {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -1,10 +1,7 @@
|
|||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
// Originally created by maryrosecook
|
function Lisp (input, lib) {
|
||||||
// https://github.com/maryrosecook/littlelisp
|
const TYPES = { identifier: 0, number: 1, string: 2, bool: 3 }
|
||||||
|
|
||||||
function Lisp (input, lib, tables, host) {
|
|
||||||
const TYPES = { identifier: 0, keyword: 1, number: 2, string: 3, bool: 4 }
|
|
||||||
const Context = function (scope, parent) {
|
const Context = function (scope, parent) {
|
||||||
this.scope = scope
|
this.scope = scope
|
||||||
this.parent = parent
|
this.parent = parent
|
||||||
@ -56,8 +53,6 @@ function Lisp (input, lib, tables, host) {
|
|||||||
return interpretList(input, context)
|
return interpretList(input, context)
|
||||||
} else if (input.type === TYPES.identifier) {
|
} else if (input.type === TYPES.identifier) {
|
||||||
return context.get(input.value)
|
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) {
|
} else if (input.type === TYPES.number || input.type === TYPES.string || input.type === TYPES.bool) {
|
||||||
return input.value
|
return input.value
|
||||||
}
|
}
|
||||||
@ -68,8 +63,6 @@ function Lisp (input, lib, tables, host) {
|
|||||||
return { type: TYPES.number, value: parseFloat(input) }
|
return { type: TYPES.number, value: parseFloat(input) }
|
||||||
} else if (input[0] === '"' && input.slice(-1) === '"') {
|
} else if (input[0] === '"' && input.slice(-1) === '"') {
|
||||||
return { type: TYPES.string, value: input.slice(1, -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') {
|
} else if (input === 'true' || input === 'false') {
|
||||||
return { type: TYPES.bool, value: input === 'true' }
|
return { type: TYPES.bool, value: input === 'true' }
|
||||||
} else {
|
} else {
|
||||||
@ -79,9 +72,7 @@ function Lisp (input, lib, tables, host) {
|
|||||||
|
|
||||||
const parenthesize = function (input, list) {
|
const parenthesize = function (input, list) {
|
||||||
if (list === undefined) { return parenthesize(input, []) }
|
if (list === undefined) { return parenthesize(input, []) }
|
||||||
|
|
||||||
const token = input.shift()
|
const token = input.shift()
|
||||||
|
|
||||||
if (token === undefined) {
|
if (token === undefined) {
|
||||||
return list.pop()
|
return list.pop()
|
||||||
} else if (token === '(') {
|
} else if (token === '(') {
|
||||||
@ -102,7 +93,7 @@ function Lisp (input, lib, tables, host) {
|
|||||||
return parenthesize(tokenize(input))
|
return parenthesize(tokenize(input))
|
||||||
}
|
}
|
||||||
|
|
||||||
this.toString = function () {
|
this.toPixels = function () {
|
||||||
return `${interpret(this.parse(input))}`
|
return interpret(this.parse(input))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,16 +15,15 @@ function Ronin () {
|
|||||||
this.el.id = 'ronin'
|
this.el.id = 'ronin'
|
||||||
|
|
||||||
this.theme = new Theme(defaultTheme)
|
this.theme = new Theme(defaultTheme)
|
||||||
this.commander = new Commander()
|
this.commander = new Commander(this)
|
||||||
this.surface = new Surface()
|
this.surface = new Surface(this)
|
||||||
|
this.library = new Library(this)
|
||||||
|
|
||||||
this.install = function (host = document.body) {
|
this.install = function (host = document.body) {
|
||||||
host.appendChild(this.el)
|
|
||||||
|
|
||||||
this.commander.install(this.el)
|
this.commander.install(this.el)
|
||||||
this.surface.install(this.el)
|
this.surface.install(this.el)
|
||||||
|
host.appendChild(this.el)
|
||||||
this.theme.install(host, () => { this.update() })
|
this.theme.install()
|
||||||
}
|
}
|
||||||
|
|
||||||
this.start = function () {
|
this.start = function () {
|
||||||
@ -32,15 +31,6 @@ function Ronin () {
|
|||||||
this.commander.start()
|
this.commander.start()
|
||||||
this.surface.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')
|
console.log('Ronin', 'Started')
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,10 +38,6 @@ function Ronin () {
|
|||||||
this.theme.reset()
|
this.theme.reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
this.update = function () {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
this.load = function (content = this.default()) {
|
this.load = function (content = this.default()) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,35 @@
|
|||||||
function Surface () {
|
function Surface (ronin) {
|
||||||
this.el = document.createElement('canvas')
|
this.el = document.createElement('canvas')
|
||||||
this.el.id = 'surface'
|
this.el.id = 'surface'
|
||||||
|
this.ratio = window.devicePixelRatio
|
||||||
|
|
||||||
this.install = function (host) {
|
this.install = function (host) {
|
||||||
host.appendChild(this.el)
|
host.appendChild(this.el)
|
||||||
|
window.addEventListener('resize', (e) => { this.onResize() }, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.start = function () {
|
this.start = function () {
|
||||||
|
this.maximize()
|
||||||
|
console.log('Surface', `Ratio:${this.ratio}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.update = function () {
|
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()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user