Minor cleanup
This commit is contained in:
parent
97eb426e17
commit
fded35991b
@ -40,7 +40,7 @@ Ronin helpers are keywords that facilitates adding coordinates from the canvas i
|
||||
|
||||
- `(import path shape ~alpha)` Imports a graphic file with format.
|
||||
- `(export path ~format ~quality)` Exports a graphic file with format.
|
||||
- `(open path ~ratio)` Imports a graphic file and resizes the frame.
|
||||
- `(open path ~ratio ~orientation ~mirrorx ~mirrory)` Imports a graphic file and resizes the frame.
|
||||
- `(exit ~force)` Exits Ronin.
|
||||
- `(pos ~x ~y)` Returns a position shape.
|
||||
- `(line ax ay bx by)` Returns a line shape.
|
||||
@ -62,7 +62,7 @@ Ronin helpers are keywords that facilitates adding coordinates from the canvas i
|
||||
- `(drag ~rect)` Drag a part of the canvas.
|
||||
- `(view a b)` View a part of the canvas.
|
||||
- `(pick ~shape)` Returns the color of a pixel at pos, or of the average of the pixels in rect.
|
||||
- `(transform)` The transform toolkit, see examples.
|
||||
- `(transform)` The transform toolkit.
|
||||
- `(stroke shape color ~thickness)` Strokes a shape.
|
||||
- `(fill ~rect)` Fills a shape.
|
||||
- `(clear ~rect)` Clears a rect.
|
||||
@ -139,7 +139,6 @@ Ronin helpers are keywords that facilitates adding coordinates from the canvas i
|
||||
- `(on event f)` Triggers on event.
|
||||
- `(test name a b)`
|
||||
- `(benchmark fn)` Logs time taken to execute a function.
|
||||
- `(theme)` Get theme values.
|
||||
|
||||
<img src='https://raw.githubusercontent.com/hundredrabbits/Ronin/master/PREVIEW2.jpg' width='600'/>
|
||||
|
||||
|
@ -11,7 +11,6 @@
|
||||
<script type="text/javascript" src="scripts/lisp.js"></script>
|
||||
<script type="text/javascript" src="scripts/library.js"></script>
|
||||
<script type="text/javascript" src="scripts/osc.js"></script>
|
||||
|
||||
<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/main.css"/>
|
||||
@ -23,7 +22,6 @@
|
||||
const {dialog,app} = require('electron').remote;
|
||||
const fs = require('fs')
|
||||
const ronin = new Ronin()
|
||||
|
||||
ronin.controller = new Controller()
|
||||
ronin.controller.add("default","*","About",() => { require('electron').shell.openExternal('https://github.com/hundredrabbits/Ronin'); },"CmdOrCtrl+,");
|
||||
ronin.controller.add("default","*","Fullscreen",() => { app.toggleFullscreen() },"CmdOrCtrl+Enter");
|
||||
@ -58,7 +56,6 @@
|
||||
ronin.controller.addSpacer('default', 'Theme', 'Download')
|
||||
ronin.controller.add("default","Theme","Download Themes..",() => { require('electron').shell.openExternal('https://github.com/hundredrabbits/Themes') })
|
||||
ronin.controller.commit()
|
||||
|
||||
ronin.install(document.body)
|
||||
window.addEventListener('load', () => { ronin.start() })
|
||||
</script>
|
||||
|
@ -3,15 +3,11 @@ function Commander (ronin) {
|
||||
this.el = document.createElement('div')
|
||||
this.el.id = 'commander'
|
||||
this._input = document.createElement('textarea')
|
||||
this._status = document.createElement('div')
|
||||
this._status.id = 'status'
|
||||
this._log = document.createElement('div')
|
||||
this._log.id = 'log'
|
||||
this._docs = document.createElement('div')
|
||||
this._docs.id = 'help'
|
||||
this._run = document.createElement('a')
|
||||
this._run.id = 'run'
|
||||
this._run.setAttribute('title', 'Run(c-R)')
|
||||
this._status = document.createElement('div'); this._status.id = 'status'
|
||||
this._log = document.createElement('div'); this._log.id = 'log'
|
||||
this._docs = document.createElement('div'); this._docs.id = 'help'
|
||||
this._run = document.createElement('a'); this._run.id = 'run'
|
||||
|
||||
this.isVisible = true
|
||||
|
||||
this.install = function (host) {
|
||||
@ -21,6 +17,7 @@ function Commander (ronin) {
|
||||
this._status.appendChild(this._run)
|
||||
this.el.appendChild(this._status)
|
||||
host.appendChild(this.el)
|
||||
this._run.setAttribute('title', 'Run(c-R)')
|
||||
this._input.addEventListener('input', this.onInput)
|
||||
this._input.addEventListener('click', this.onClick)
|
||||
this._run.addEventListener('click', () => { this.run() })
|
||||
@ -57,8 +54,32 @@ function Commander (ronin) {
|
||||
this.load('')
|
||||
}
|
||||
|
||||
this.cleanup = function () {
|
||||
this._input.value = this.clean(this._input.value)
|
||||
this.reindent()
|
||||
this.run()
|
||||
}
|
||||
|
||||
this.update = function () {
|
||||
|
||||
}
|
||||
|
||||
this.onInput = () => {
|
||||
this.setStatus()
|
||||
}
|
||||
|
||||
this.onClick = () => {
|
||||
this.setStatus()
|
||||
}
|
||||
|
||||
this.getLastfn = function () {
|
||||
const pos = this._input.value.substr(0, this._input.selectionStart).lastIndexOf('(')
|
||||
return this._input.value.substr(pos).split(' ')[0].replace(/\(/g, '').replace(/\)/g, '').trim()
|
||||
}
|
||||
|
||||
|
||||
this.reindent = function () {
|
||||
let val = this._input.value.replace(/\n/g, '').replace(/ +(?= )/g, '').replace(/\( \(/g, '((').replace(/\) \)/g, '))').trim()
|
||||
let val = this._input.value.replace(/\n/g, '').replace(/ \)/g, ')').replace(/ +(?= )/g, '').replace(/\( \(/g, '((').replace(/\) \)/g, '))').trim()
|
||||
let depth = 0
|
||||
if (val.split('(').length !== val.split(')').length) {
|
||||
ronin.log('Uneven number of parens.')
|
||||
@ -89,12 +110,6 @@ function Commander (ronin) {
|
||||
return input
|
||||
}
|
||||
|
||||
this.cleanup = function () {
|
||||
this._input.value = this.clean(this._input.value)
|
||||
this.reindent()
|
||||
this.run()
|
||||
}
|
||||
|
||||
this.setStatus = function (msg) {
|
||||
// Logs
|
||||
if (msg && msg !== this._log.textContent) {
|
||||
@ -109,23 +124,6 @@ function Commander (ronin) {
|
||||
}
|
||||
}
|
||||
|
||||
this.update = function () {
|
||||
|
||||
}
|
||||
|
||||
this.onInput = () => {
|
||||
this.setStatus()
|
||||
}
|
||||
|
||||
this.onClick = () => {
|
||||
this.setStatus()
|
||||
}
|
||||
|
||||
this.getLastfn = function () {
|
||||
const pos = this._input.value.substr(0, this._input.selectionStart).lastIndexOf('(')
|
||||
return this._input.value.substr(pos).split(' ')[0].replace(/\(/g, '').replace(/\)/g, '').trim()
|
||||
}
|
||||
|
||||
// Injection
|
||||
|
||||
this.cache = this._input.value
|
||||
|
@ -1,5 +1,7 @@
|
||||
function Docs (ronin) {
|
||||
|
||||
this.dict = {}
|
||||
|
||||
this.load = () => {
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
@ -8,6 +10,7 @@ function Docs (ronin) {
|
||||
const lines = fs.readFileSync(p, 'utf8').split('\n').filter((line) => { return line.substr(0, 7) === ' this.' })
|
||||
return lines.map((line) => { return line.trim().substr(5).trim() })
|
||||
}
|
||||
|
||||
this.install = (payload = this.load()) => {
|
||||
for (const id in payload) {
|
||||
const name = payload[id].substr(0, payload[id].indexOf(' = '))
|
||||
@ -21,6 +24,7 @@ function Docs (ronin) {
|
||||
console.log('Docs', `Loaded ${Object.keys(this.dict).length} functions.`)
|
||||
console.log(this.toMarkdown())
|
||||
}
|
||||
|
||||
this.toMarkdown = () => {
|
||||
return Object.keys(this.dict).reduce((acc, item, key) => {
|
||||
const example = `${item} ${this.dict[item].params.reduce((acc, item) => {
|
||||
@ -29,9 +33,11 @@ function Docs (ronin) {
|
||||
return `${acc}- \`(${example.trim()})\` ${this.dict[item].note}\n`
|
||||
}, '')
|
||||
}
|
||||
|
||||
this.hasDocs = (name) => {
|
||||
return !!this.dict[name]
|
||||
}
|
||||
|
||||
this.print = (name) => {
|
||||
return `(${name} ${this.dict[name].params.reduce((acc, item) => { return `${acc}${item} ` }, '').trim()})`
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ function Library (ronin) {
|
||||
|
||||
// Transforms
|
||||
|
||||
this.transform = { // The transform toolkit, use like (transform:move 10 10).
|
||||
this.transform = { // The transform toolkit.
|
||||
push: () => {
|
||||
ronin.surface.context.save()
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user