The VT220 is fascinating as an example of "old" computer technology that still influences the devices we use on a daily basis.
I've recently had to understand exactly which control characters are sent between the app and the terminal (emulator) for delete and backspace.
Guess which ASCII control characters is sent by the Backspace key on your PC keyboard? ASCII DEL (0x7F/^?)! All modern terminal emulators on Linux and OS X (including the Linux console, xterm and libvte-based terminals, OS X Terminal.app and iTerm2) now default to sending DEL [1] when you press the Backspace key... now it makes much more sense that on a Mac keyboard, that key is labeled "Delete" and used to have the same symbol as on the VT220!
Oh, and what character is sent when you press the (forward) Delete key? Why, the escape sequence 1B 5B 33 7E (ESC [ 3 ~), of course :) Because the terminals we emulate didn't have a key for forward delete ;)
For bonus credit, lookup the historical usage of the Linefeed (LF/0xA/^J) and CarriageReturn (CR/0xD/^M) characters [2]. There was much more than just the Unix/Mac/Windows divide in text files...
[1] yes, you can swap for ASCII BS (8/^H), but if your app needs that, consider updating it.
I've recently had to understand exactly which control characters are sent between the app and the terminal (emulator) for delete and backspace.
Guess which ASCII control characters is sent by the Backspace key on your PC keyboard? ASCII DEL (0x7F/^?)! All modern terminal emulators on Linux and OS X (including the Linux console, xterm and libvte-based terminals, OS X Terminal.app and iTerm2) now default to sending DEL [1] when you press the Backspace key... now it makes much more sense that on a Mac keyboard, that key is labeled "Delete" and used to have the same symbol as on the VT220!
Oh, and what character is sent when you press the (forward) Delete key? Why, the escape sequence 1B 5B 33 7E (ESC [ 3 ~), of course :) Because the terminals we emulate didn't have a key for forward delete ;)
For bonus credit, lookup the historical usage of the Linefeed (LF/0xA/^J) and CarriageReturn (CR/0xD/^M) characters [2]. There was much more than just the Unix/Mac/Windows divide in text files...
[1] yes, you can swap for ASCII BS (8/^H), but if your app needs that, consider updating it.
[2] https://en.wikipedia.org/wiki/Newline#Representations