diff --git a/src/classes/filesystem.class.js b/src/classes/filesystem.class.js index b02847f7..133fe503 100644 --- a/src/classes/filesystem.class.js +++ b/src/classes/filesystem.class.js @@ -547,7 +547,7 @@ class FilesystemDisplay { } this.openFile = (name, path, type) => { //Might add text formatting at some point, not now though - Surge - let block; + let block = { name, path }; if (typeof name === "number") { block = this.cwd[name]; @@ -635,7 +635,7 @@ class FilesystemDisplay { }; this.openMedia = (name, path, type) => { - let block, html; + let block = { name, path }, html; if (typeof name === "number") { block = this.cwd[name]; diff --git a/src/classes/terminal.class.js b/src/classes/terminal.class.js index 41c9fbbd..7f3dc27f 100644 --- a/src/classes/terminal.class.js +++ b/src/classes/terminal.class.js @@ -143,6 +143,23 @@ class Terminal { window.keyboard.keydownHandler(e); return true; }); + this.term.parser.registerOscHandler(1024, str => { + try { + let obj = JSON.parse(str); + switch(obj.cmd) { + case "openMedia": + fsDisp.openMedia(obj.path, obj.path, fsDisp.fileIconsMatcher(obj.path)); + break; + case "openFile": + fsDisp.openFile(obj.path, obj.path, fsDisp.fileIconsMatcher(obj.path)); + break; + default: + console.log("Bad cmd:", obj); + } + } catch (e) { + console.log("Error:", str, e); + } + }); // Prevent soft-keyboard on touch devices #733 document.querySelectorAll('.xterm-helper-textarea').forEach(textarea => textarea.setAttribute('readonly', 'readonly')) this.term.focus();