From c882b1eccbf25d52c543cd0ca621a3b39792c78a Mon Sep 17 00:00:00 2001 From: fanoush Date: Thu, 5 Sep 2024 13:33:16 +0200 Subject: [PATCH 1/3] allow empty lines too it is typical to just press enter to see if console input is working --- examples/rtt/web.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/rtt/web.html b/examples/rtt/web.html index 3de0878..846a610 100644 --- a/examples/rtt/web.html +++ b/examples/rtt/web.html @@ -120,12 +120,13 @@ const printable = !ev.altKey && !ev.ctrlKey && !ev.metaKey; if (ev.keyCode === 13) { // process newline - if (line_input.length) { + // allow empty lines too + // if (line_input.length) { term.write('\r\n'); cmd = line_input; console.log('sending: \"' + line_input + '\"'); line_input = ""; - } + //} } else if (ev.keyCode === 8) { // process backspace if (term._core.buffer.x > 0) { term.write('\b \b'); From ebfe8f9f426ed7e76c954434d23516655ab54cbf Mon Sep 17 00:00:00 2001 From: fanoush Date: Thu, 5 Sep 2024 20:22:13 +0200 Subject: [PATCH 2/3] fix also cmd being empty on empty line --- examples/rtt/web.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/rtt/web.html b/examples/rtt/web.html index 846a610..b00696c 100644 --- a/examples/rtt/web.html +++ b/examples/rtt/web.html @@ -123,7 +123,7 @@ // allow empty lines too // if (line_input.length) { term.write('\r\n'); - cmd = line_input; + cmd = line_input + "\r\n"; console.log('sending: \"' + line_input + '\"'); line_input = ""; //} @@ -165,7 +165,7 @@ // send to target if (cmd.length) { - cmdBytes = new TextEncoder().encode(cmd + "\r\n"); + cmdBytes = new TextEncoder().encode(cmd); ret = await rtt.write(0, cmdBytes); if (ret < 0) console.log("cannot write", cmdBytes, "chars"); From fd8a34e71ed8580515bf6fe03ef99afd544b6f6d Mon Sep 17 00:00:00 2001 From: fanoush Date: Mon, 30 Sep 2024 11:53:08 +0200 Subject: [PATCH 3/3] remove commented code --- examples/rtt/web.html | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/examples/rtt/web.html b/examples/rtt/web.html index b00696c..8f24b5b 100644 --- a/examples/rtt/web.html +++ b/examples/rtt/web.html @@ -120,13 +120,10 @@ const printable = !ev.altKey && !ev.ctrlKey && !ev.metaKey; if (ev.keyCode === 13) { // process newline - // allow empty lines too - // if (line_input.length) { - term.write('\r\n'); - cmd = line_input + "\r\n"; - console.log('sending: \"' + line_input + '\"'); - line_input = ""; - //} + term.write('\r\n'); + cmd = line_input + "\r\n"; + console.log('sending: \"' + line_input + '\"'); + line_input = ""; } else if (ev.keyCode === 8) { // process backspace if (term._core.buffer.x > 0) { term.write('\b \b');