mirror of
https://codeberg.org/TicklishHoneyBee/CLIte.git
synced 2026-03-11 09:04:37 +00:00
backspace on the tty
This commit is contained in:
parent
abf9dbad6c
commit
41353aab1a
2 changed files with 28 additions and 0 deletions
|
|
@ -471,6 +471,10 @@ bios.input.keyboard = {
|
|||
k.char = String.fromCharCode(127);
|
||||
k.lchr = k.char;
|
||||
k.code = 127;
|
||||
case "Backspace":
|
||||
k.char = String.fromCharCode(8);
|
||||
k.lchr = k.char;
|
||||
k.code = 8;
|
||||
break;
|
||||
default:
|
||||
k.code = key;
|
||||
|
|
|
|||
|
|
@ -2157,6 +2157,10 @@ clite.tty = {
|
|||
var updateY = clite.tty.data.ttys[id].y;
|
||||
|
||||
switch (cc) {
|
||||
case 8: //BS
|
||||
clite.tty.data.ttys[id].x--;
|
||||
updateLine = true;
|
||||
break;
|
||||
case 10: //LF
|
||||
clite.tty.data.ttys[id].y++;
|
||||
break;
|
||||
|
|
@ -2169,6 +2173,14 @@ clite.tty = {
|
|||
clite.tty.data.ttys[id].x++;
|
||||
}
|
||||
|
||||
if (clite.tty.data.ttys[id].x < 0) {
|
||||
clite.tty.data.ttys[id].y--;
|
||||
clite.tty.data.ttys[id].x = 79;
|
||||
}
|
||||
|
||||
if (clite.tty.data.ttys[id].y < 0)
|
||||
clite.tty.data.ttys[id].y = 0;
|
||||
|
||||
if (clite.tty.data.ttys[id].x > 79) {
|
||||
clite.tty.data.ttys[id].y++;
|
||||
clite.tty.data.ttys[id].x = 0;
|
||||
|
|
@ -2290,6 +2302,15 @@ clite.tty = {
|
|||
}
|
||||
return;
|
||||
}
|
||||
// Backspace
|
||||
if (key.code == 8) {
|
||||
if (t.buff.pop() && t.echo) {
|
||||
clite.tty.write(t.id,String.fromCharCode(8));
|
||||
clite.tty.write(t.id,' ');
|
||||
clite.tty.write(t.id,String.fromCharCode(8));
|
||||
}
|
||||
return;
|
||||
}
|
||||
t.buff.push(key);
|
||||
if (typeof t.rcb !== 'function')
|
||||
return;
|
||||
|
|
@ -2348,6 +2369,9 @@ clite.tty = {
|
|||
// TODO: escape/control sequences
|
||||
if (cc < 32 || cc > 126) {
|
||||
switch (cc) {
|
||||
case 8:
|
||||
clite.tty.internal.write(id,String.fromCharCode(8));
|
||||
break;
|
||||
case 10: // NL/LF to CR+LF
|
||||
clite.tty.internal.write(id,String.fromCharCode(13));
|
||||
clite.tty.internal.write(id,String.fromCharCode(10));
|
||||
|
|
|
|||
Loading…
Reference in a new issue