panel 1: the terminal driver: an interface that hasn't changed since the 80s person: “I pressed an arrow key and it just printed out ^[[D???” terminal driver: “what's an arrow key?" panel 2: when you're typing text, there are two situations 1. by default: the terminal driver (part of the OS) is responsible "canonical mode" 2. the program is responsible “raw mode” panel 3: "canonical mode" is a terrible way to edit text because the terminal driver hasn't changed much since the 80s, you can only do: 1. backspace 2. Ctrl+W (delete word) 3. Ctrl+U (delete line) panel 4: how canonical mode works 1. you type "helll" + backspace 2. the terminal emulator turns what you typed into bytes 3. the terminal driver passes on "hell" and interprets the backspace 4. the program gets "hello\n" In canonical mode, terminal driver doesn't send anything to the program until you press Enter. In raw mode, the terminal driver just sends “hell\xFFo\n” without changing it panel 5: how to try out canonical mode Run `cat` and type some stuff! Interactive programs almost never use canonical mode because it's so limited. But if you run into it `rlwrap $COMMAND` can help
https://cdn.masto.host/socialjvnsca/media_attachments/files/114/196/639/425/627/496/original/0c4f46cd9086206c.png