Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/term: ReadKey() interface #13299

Open
techtonik opened this issue Nov 18, 2015 · 1 comment
Open

x/term: ReadKey() interface #13299

techtonik opened this issue Nov 18, 2015 · 1 comment
Milestone

Comments

@techtonik
Copy link

@techtonik techtonik commented Nov 18, 2015

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.

@techtonik
Copy link
Author

@techtonik techtonik commented Nov 18, 2015

Updated.

Loading

@rsc rsc added this to the Unreleased milestone Dec 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants