putchar and backspace
Posted: Mon Mar 05, 2018 7:03 pm
How does z88dk handle backspace in putchar()?
On most systems, the following statements will print the string "Fox" but in z88dk it prints "Foo?x":
putchar('F');
putchar('o');
putchar('o');
putchar('\b');
putchar('x');
putchar('\n');
The reason I'm asking is that I'm experimenting with porting the Magnetic Scrolls interpreter Magnetic to Spectrum Next. The Magnetic interpreter is a little bit odd in that in can emit backspace characters '\b' to the output function in order to make small corrections to the last printed characters. This seems to be used for things like deleting the last ',' character in an enumeration, e.g. "You have a, b, and c" is corrected to "You have a, b and c".
I saw that the backspace character seems to get special treatment in the console output drivers in z88dk (e.g. console_01_output_fzx_iterm_msg_bs.asm) but I don't know exactly how this relates to putchar(). Maybe it's only handled for input and not output?
On most systems, the following statements will print the string "Fox" but in z88dk it prints "Foo?x":
putchar('F');
putchar('o');
putchar('o');
putchar('\b');
putchar('x');
putchar('\n');
The reason I'm asking is that I'm experimenting with porting the Magnetic Scrolls interpreter Magnetic to Spectrum Next. The Magnetic interpreter is a little bit odd in that in can emit backspace characters '\b' to the output function in order to make small corrections to the last printed characters. This seems to be used for things like deleting the last ',' character in an enumeration, e.g. "You have a, b, and c" is corrected to "You have a, b and c".
I saw that the backspace character seems to get special treatment in the console output drivers in z88dk (e.g. console_01_output_fzx_iterm_msg_bs.asm) but I don't know exactly how this relates to putchar(). Maybe it's only handled for input and not output?