x/term: ReadKey() interface #13299
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Now that there is x/term (#13104) there should be some user stories.
The story here is that in LXC we have console client and server separated by websocket channel. Client uses os.Stdin to read the input from user. Server interprets what is being sent to it (passes it to pty?) Client most likely uses Read function from https://golang.org/pkg/io/#Reader, for which os.Stdin.Read() returns nothing on Windows.
This interface on Linux is flawed in the first place, because I personally don't understand what it should return on read from os.Stdin if I hit arrow key. What cryptic code it returns/expects on Linux part is a separate mystery to me.
So perhaps there should be a better interface - synchronous ReadKey() and that will return keys in a sequence, and combinations of keys are also tracked.
And if we catch keys, it is better to returns values that are serializable in some cross-platform formats to avoid dependency on certain import and receive ability to switch packages who provide ReadKey() interface easily. I'd use strings like Ctrl-Q etc.
Hopefully that's clear. And I want to use Ctrl-Q in golang programs and Ctrl-V for my own purposes. And I also don't want Linux terminal to hang if I kill go process somewhere in the middle after go already switched terminal to some non-friendly state for its own purpose.
The text was updated successfully, but these errors were encountered: