withoutboats / notty

A new kind of terminal
GNU Affero General Public License v3.0
2.31k stars 41 forks source link

Local echo & line discipline #1

Open withoutboats opened 8 years ago

withoutboats commented 8 years ago

I :heart: issue blogging.

ANSI terminals have no concept of "local echo" - nothing entered at the keyboard of a terminal is written to the screen unless it is written to the output side of the tty connection. However, the tty subsystem of a UNIX kernel does implement an echo feature, in which it echos characters it receives back to the terminal. A number of options exist to modify this feature (such as determining how ctrl characters and backspace ought to be echoed), and it is often combined with the tty's "canonical line discipline," which buffers input until a newline character is received.

These features of the tty make implementing simple programs much easier, but they have two limitations:

The simplest solution to the second issue is to implement echo features inside the terminal. The solution to the first is for this echo to be more featureful than the tty's echo.

These are the MVP features of local echo. Each needs to be independently togglable:

Other than the last two points, these are features supported by the tty line discipline. The tty also does a few other things. It generates signals from input; this is basically the only feature that makes the most sense to keep in the tty, because it needs to be on the remote machine but it can't be in the controlling process. Input can be turned off with Ctrl+S, this feature does not seem worthwhile to re-implement.

Beyond this, there are a number of really radical extensions that could be implemented by notty, but may not be good ideas:

waynr commented 8 years ago

Input can be turned off with Ctrl+S, this feature does not seem worthwhile to re-implement.

Just a quick note, Ctrl+S, aka DC3/XOFF is a flow control mechanism by which the remote end may indicate that it cannot handle additional input. The pnuemonic I think of is "suspend" since input continues to queue and will be send once Ctrl+Q, aka DC1/XON is indicated by the remote end.

If we implement local echo at the terminal level, we should consider some means of visualizing for the user the difference in what has reached the remote end vs what is only displayed locally...unless I am misunderstanding, the kind of local echo being discussed here is similar to the local echo a mosh client shows when there is a large amount of network latency.