Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

WIP: Sketch using OSC sequences to interact with openFile and openMedia #1163

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/classes/filesystem.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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];
Expand Down
17 changes: 17 additions & 0 deletions src/classes/terminal.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down