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/sys: provide termios.h-like functionality #13210

Open
akevinbailey opened this issue Nov 11, 2015 · 6 comments
Open

x/sys: provide termios.h-like functionality #13210

akevinbailey opened this issue Nov 11, 2015 · 6 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@akevinbailey
Copy link

Go needs a way to flush the stdin before prompt and Scanln.

See odeke-em/drive#157 for psoible fix for Linux.

@rakyll rakyll changed the title fmt should be able to flush stdin before printing the prompt and Scanln fmt: be able to flush stdin before printing the prompt and Scanln Nov 11, 2015
@adg
Copy link
Contributor

adg commented Nov 11, 2015

This isn't a fmt issue. It's a feature request for a function that should probably be in the x/sys repo.

This is how @minux implemented it, by calling out to a C library: https://github.com/minux/drive/blob/2b076a3dc02b5fee728e9eeee8c089a414de5fbc/src/tty.go

@adg adg changed the title fmt: be able to flush stdin before printing the prompt and Scanln x/sys: provide termios.h-like functionality Nov 11, 2015
@akevinbailey
Copy link
Author

I disagree. Flushing stdio should be a basic function of GO without having to call an external C library. Java and Python have it built in.

@ianlancetaylor
Copy link
Member

How do you flush standard input in Java and Python? Can you point to the docs?

Note that this issue is not about flushing standard output. Go can already do that perfectly well.

@akevinbailey
Copy link
Author

Sorry, I meant stdin

Java:
System.in.read(new byte[System.in.available()]); // Flushes stdin

Python:
from termios import tcflush, TCIOFLUSH
tcflush(sys.stdin, TCIOFLUSH)

@adg
Copy link
Contributor

adg commented Nov 12, 2015

On 12 November 2015 at 12:18, A. Kevin Bailey notifications@github.com
wrote:

from termios import tcflush, TCIOFLUSH
tcflush(sys.stdin, TCIOFLUSH)

This is the kind of thing I was suggesting in renaming this issue.

@rsc rsc added this to the Unreleased milestone Dec 28, 2015
@tklauser
Copy link
Member

tklauser commented Apr 3, 2018

Some of the termios.h function require more functionality than just mere syscall wrappers (which is the scope of the x/sys package) or they don't use any syscalls at all (like the cf* functions). Thus, it might be more appropriate to implement these functions in the (currently empty) x/term package? We may then make use of x/sys for certain parts of the implementation.

Also, some parts like cfmakeraw are already available in x/crypto/ssh/terminal and I guess we should move/copy them to x/term as well.

@seankhliao seankhliao added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

6 participants