equi

A self-descriptive stack-based PC platform
git clone git://git.luxferre.top/equi.git
Log | Files | Refs | README | LICENSE

commit 1f05ca0e9090535f02727c62927c23e57eae9909
parent 8234f91baa46b8e89a92c696ddd5543748199ec1
Author: Luxferre <lux@ferre>
Date:   Tue, 16 Aug 2022 16:35:32 +0300

Backspace hopefully fixed

Diffstat:
Mequi.c | 12++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/equi.c b/equi.c @@ -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