Backspace hopefully fixed

This commit is contained in:
Luxferre
2022-08-16 16:35:32 +03:00
parent 8234f91baa
commit 1f05ca0e90
+10 -2
View File
@@ -35,6 +35,7 @@
#define uchar unsigned char /* basic 8-bit integer */
#define WS sizeof(ushort) /* Equi word size in bytes */
#define BS 8u /* Backspace character code */
#define DEL 0x7fu /* Delete key code */
#define CR 13u /* Character return code */
#define LF 10u /* Line feed code */
@@ -751,11 +752,18 @@ int main(int argc, char* argv[]) {
instr = cgetc(); /* Fetch the next instruction from the keyboard/stdin */
if(instr == 0xFFU || instr == 0U || instr == 3U || instr == 4U) /* exit on zero byte or ctrl+C or ctrl+D */
break;
else if(instr == BS || instr == CR || instr == LF || instr == ' ' || instr == '\t') { /* ignore the backspace or whitespaces */
else if(instr == BS || instr == DEL || instr == CR || instr == LF || instr == ' ' || instr == '\t') { /* ignore the backspace or whitespaces */
if(!smode)
cputc(instr); /* echo it if not in silent mode */
if(instr == CR)
cputc(LF);
if(instr == DEL || instr == BS) { /* simulate backspace */
cputc(BS);
cputc(0x20);
cputc(BS);
if(ram.ibp > 0)
--ram.ibp;
}
} else if(instr == INS_IISTART) { /* process II start */
if(!smode)
cputc(instr); /* echo it if not in silent mode */
@@ -796,7 +804,7 @@ int main(int argc, char* argv[]) {
cputc(instr); /* echo it if not in silent mode */
}
} /* command mode loop end */
#if !defined __CC65__ && !defined __TINYC__
#ifndef __CC65__
/* restore the terminal settings */
tcsetattr(STDIN_FILENO, TCSANOW, &tty_opts_backup);
#endif