I think this link about covers it. Read the whole thing, it's awesome :-)
http://www.linusakesson.net/programming/tty/index.php -- It explains how the terminal (TTY) consists of the terminal driver, which helps controls the sessions, and the line discipline, which can control if set, specific line editing. If it is set in raw mode (line discipline) it can be over-ridden by something like read-line library. The terminal emulator in a way controls the processing of keyboard input and display. The terminal device file under /dev camcan be used to manipulate the line discipline adand the driver. This is how I see it.