From 4c00c11b681747898b7bcce1c495741af14305d5 Mon Sep 17 00:00:00 2001 From: minie4 Date: Sun, 25 Apr 2021 18:16:08 +0200 Subject: [PATCH] Added copy and paste functionality --- index.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index eef1c39..9ed8083 100644 --- a/index.js +++ b/index.js @@ -70,6 +70,21 @@ function onConsoleOutput(char) { var debugcnt = 0; var debugword = "+++debug+++" function onConsoleInput(key) { + // If key is Strg+V + if((key.domEvent.key == "v") && key.domEvent.altKey && key.domEvent.ctrlKey) { + debug("paste") + navigator.clipboard.readText().then((text) => { + emulator.serial0_send(text) + }) + return; + } + + if((key.domEvent.key == "c") && key.domEvent.altKey && key.domEvent.ctrlKey) { + debug("copy") + document.execCommand("copy") + return; + } + // Send keys from xterm to v86 emulator.serial0_send(key.key) @@ -82,7 +97,7 @@ function onConsoleInput(key) { if(debugcnt == debugword.length) { document.getElementById("screen").classList.toggle("visible"); } - console.log(debugcnt) + debug("debugcnt "+debugcnt) } var previous_line = ""; @@ -98,4 +113,8 @@ function onConsoleLine(line) { // Fit xterm to the container on window resize window.addEventListener("resize", () => { termfit.fit() -}) \ No newline at end of file +}) + +function debug(text) { + console.debug("DEBUG: "+text) +} \ No newline at end of file