diff --git a/desktop/sources/scripts/commander.js b/desktop/sources/scripts/commander.js index 36d0891..13a42de 100644 --- a/desktop/sources/scripts/commander.js +++ b/desktop/sources/scripts/commander.js @@ -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 } - const reader = new FileReader() - reader.onload = function (e) { - ronin.commander.load(e.target.result) + 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) } - reader.readAsText(file) } } diff --git a/desktop/sources/scripts/library.js b/desktop/sources/scripts/library.js index c4a5342..f7ec9b4 100644 --- a/desktop/sources/scripts/library.js +++ b/desktop/sources/scripts/library.js @@ -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) => {