terminal
I built a terminal editor and had to dig deep into understanding the terminal better
August 8, 2024 · 196 words · 1 min read · tech, programming
Raw mode in a terminal is receiving the raw bytes from the STDIN file.
terminal usually gets opened in canonical mode which means input is fed to the program one line at a time, instead of character by character. This can be done by unsetting the ICANON flag. There are a lot of these bitflags
| Flag | Description |
|---|---|
ICANON | canonical flag to indicate that the input is read line by line |
ISIG | Controls signals like ctrl+c, ctrl+z and others. |
ECHO | Echoing the input to the terminal. i.e. seeing what you are typing |
IXON | Controls ctrl+s,ctrl+q the name comes from the signals these send, XOFF and XON |
IEXTEN | Controls ctrl+v. This command sends all the bytes to the program. i.e. ctrl+v andctrl+c would send the ctrl+c to the program instead |
ICRNL | Maps the Carriage Return (Return to the new line) to New Line character. |
OPOST | Controls the post processing of characters. (e.g.) \n character is generally rendered out as \r\n this is to move the cursor to the begining + newline |
| ` | |
| ` |
ctrl+s freezes the program and ctrl+q continues it
ctrl+z runs it in the background fg can be used to run it in the foreground
The things that matter most can’t be copied: you can copy goals, you can’t copy discipline. You can copy ideas, you can’t copy execution. You can copy answers, you can’t copy understanding. You can copy thinking, you can’t copy thinking for yourself. ― Shane Parrish