From 72ad54d73de4bac350c3daeae6ea4e76ad868070 Mon Sep 17 00:00:00 2001 From: Dan Yerushalmi Date: Wed, 7 Jul 2021 10:44:56 +0300 Subject: [PATCH 1/2] Added backspace functionality --- js/app.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/js/app.js b/js/app.js index 754d2fa..af94561 100644 --- a/js/app.js +++ b/js/app.js @@ -129,6 +129,14 @@ function handleNotifications(event) { for (let i = 0; i < value.byteLength; i++) { str += String.fromCharCode(value.getUint8(i)); } + + if(value.getUint8(0) == 127){ + console.log('send backspace'); + window.term_.cursorLeft(1); + window.term_.eraseToRight(1); + } + + console.log('send to term' + str + ' ' + value.getUint8(0)); window.term_.io.print(str); } From 24d5c6cd4354bb96b83358f529027de750f7ae41 Mon Sep 17 00:00:00 2001 From: Dan Yerushalmi Date: Wed, 7 Jul 2021 10:59:21 +0300 Subject: [PATCH 2/2] handle backspace last char --- js/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/app.js b/js/app.js index af94561..7e2e8e1 100644 --- a/js/app.js +++ b/js/app.js @@ -130,7 +130,7 @@ function handleNotifications(event) { str += String.fromCharCode(value.getUint8(i)); } - if(value.getUint8(0) == 127){ + if(value.getUint8(value.byteLength - 1) == 127){ console.log('send backspace'); window.term_.cursorLeft(1); window.term_.eraseToRight(1);