🐢

Terminal

I built a terminal editor and had to dig deep into understanding the terminal better

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

FlagDescription
ICANONcanonical flag to indicate that the input is read line by line
ISIGControls signals like ctrl+c, ctrl+z and others.
ECHOEchoing the input to the terminal. i.e. seeing what you are typing
IXONControls ctrl+s,ctrl+q the name comes from the signals these send, XOFF and XON
IEXTENControls ctrl+v. This command sends all the bytes to the program. i.e. ctrl+v and
ctrl+c would send the ctrl+c to the program instead
ICRNLMaps the Carriage Return (Return to the new line) to New Line character.
OPOSTControls 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