Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RTT example - allow empty lines too #116

Merged
merged 5 commits into from
Oct 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions examples/rtt/web.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,10 @@
const printable = !ev.altKey && !ev.ctrlKey && !ev.metaKey;

if (ev.keyCode === 13) { // process newline
if (line_input.length) {
term.write('\r\n');
cmd = line_input;
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');
Expand Down Expand Up @@ -164,7 +162,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");
Expand Down
Loading