Added path injection

This commit is contained in:
Devine Lu Linvega 2019-07-13 15:24:07 +09:00
parent 7071c8cb8e
commit 40e1f816e7
2 changed files with 19 additions and 7 deletions

View File

@ -89,6 +89,10 @@ function Commander (ronin) {
this.cache = this._input.value
}
this.injectPath = function (path) {
this._input.value = this._input.value.replace('($path)', `(path "${path}")`)
}
this.commit = function () {
let value = this.cache
@ -115,21 +119,25 @@ function Commander (ronin) {
// Events
this.drag = function (e) {
this.drag = (e) => {
e.stopPropagation()
e.preventDefault()
e.dataTransfer.dropEffect = 'copy'
}
this.drop = function (e) {
this.drop = (e) => {
e.preventDefault()
e.stopPropagation()
const file = e.dataTransfer.files[0]
if (!file || !file.name || file.name.indexOf('.lisp') < 0) { console.warn('File', 'Not a .lisp file.'); return }
if (!file || !file.name) { console.warn('File', 'Not a valid file.'); return }
if (file.name.indexOf('.lisp') > -1) {
const reader = new FileReader()
reader.onload = function (e) {
ronin.commander.load(e.target.result)
}
reader.readAsText(file)
} else if (file.path) {
this.injectPath(file.path)
}
}
}

View File

@ -2,6 +2,10 @@ function Library (ronin) {
this.clear = (rect = this.select_all()) => {
}
this.load = (path, rect) => {
console.log(path, rect)
}
// Rects
this.pos = (x, y) => {