Explain the difference between canonical mode (line-buffered input) and non-canonical mode (raw input) in termios. When would you use each mode?