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

View File

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