-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: create subrepo for terminal, console, pty and tty related packages #13104
Comments
👍 x 256 |
yes, please. especially the |
I am not sure about this one: terminal handling may not be significant enough for its own subrepo. In general the subrepos seem to be mirroring our top-level standard library directories (sync, net, crypto, ...). It's certainly true that the ssh terminal code does not belong in crypto. That said, I don't know where else to put it either. Let's see if any other suggestions arrive. |
yes! I am willing to help here. I'd like some higher level primitives, and frankly expressing things in terms of POSIX termio functions would be really nice. It could even be possible to express Windows console APIs in such terms. In addition to just enabling / disabling raw & cooked mode (and echo/noecho), I see specific needs around:
I'd far rather this all be expressed in terms of POSIX termios than some other way, at least to applications. (Using ioctls or whatever under the hood is fine.) |
@rsc wrote:
Perhaps in that spirit we create |
Yes, please. I'm the author of github.com/distributed/sers, a way too noncomprehensive serial port library. I basically wrote it because I needed to set "non standard" baud rates to speak with hardware. I would be glad to help out, should the proposed subrepo become reality. |
I have some preliminary code I wrote for the Posix tc functions that I have tested on Illumos. I could contribute that if people think it would be useful. I created a branch of x/sys in my local copy and have the code in x/sys/term. |
With respect, I disagree that there isn't enough terminal handling to warrant its own subrepo. The termcap/terminfo parser alone would probably be a decent size, in addition to all the other things already mentioned. Plus all the os-specific versions of the interfaces for output (colours/styles/cursor positioning) and input (Ctrl-, Alt-, Fn-, Arrow-, etc keys) on non-Unix-like OSes. I looked at the links in the proposal, and (like my own liner) none appear to support terminfo (or... is there a Plan 9 equivalent?). That's probably because everybody independently figured it wasn't worth the effort to write a terminfo parser for a single project. If the library and the effort are going to be shared, I'd be more likely to help. |
If we go beyond just termios, into terminfo parsing and so forth, yes, this I wrote a fairly complete terminfo parser in tcell see (Its a little special purpose, because I don’t pick up all terminfo The low level half of tcell (basically everything in the base tcell On Fri, Oct 30, 2015 at 11:52 AM, Peter Harris notifications@github.com
|
I quite agree like Brad |
One problem I have with x/os, is that if we think of this functionality as That is, I agree that the implementation is OS-specific. But having So while the location is not terribly important to me — especially if it is On Fri, Oct 30, 2015 at 12:50 PM, Jens Frederich notifications@github.com
|
+1. I also agree that functionality needs to be as OS agnostic/unified as possible akin to the majority of the standard library. Would a package like this also include higher level constructs akin to curses panel, menu and form or would that be a community extension with the standard library package being solely low level? |
I would vote no to that. I think we'll be struggling with the scope as it is. However, I would hope this package would provide all the raw materials needed to construct such a library. |
Indeed. I could use that functionality and I believe the work I'm doing in tcell today goes substantially towards addressing the other higher level needs. (With views, widgets and so forth.) Sent from my iPhone
|
It would be also nice if the package exposed performance metrics // tests both for terminal and for windows-like console. |
I think |
@adg golang.org/x/os sounds good to me ! |
As long as we strive for an API that is consistent across the different OS's, sounds ok to me. |
Yes please! That would NOT be consistent with the other stuff in x/os however. Mostly On Wed, Nov 4, 2015 at 11:47 AM, Kim Shrier notifications@github.com
|
Some unix-isms crept in for historical reasons, but on the whole the |
Also, x/term and x/tty are already unixisms. |
I agree, but this that is unavoidable. I'm sure there will also be packages that only make sense for the Windows command subsystem. I hope that in addition to these operating system specific packages we can develop high level ones For example, console control providing cursor control for text mode interfaces, Garrett has shown that this is possible for Windows with the same high level api. Similarly I want to see a high level serial Comms package that operates across Linux, Mac and Windows. It's exported api should be agnostic, but will probably call on operating system specific packages to provide the implementation. See my github.com/pkg/term package.
|
@davecheney Windows console is more powerful/responsive in terms of user experience, because it provides a separate channel for controlling console window object (independent orthogonal API from C standard streams), while in terminal it is all garbled into one stream, which is slow and inefficient (and requires complex state machine to maintain). So decide carefully based on data if you need this Comms port and why - maybe there is a better way.. |
Proposal accepted. Assigning to @adg for subrepo creation. |
Sounds perfectly reasonable I think. Are we at consensus finally? Sent from my iPhone
|
I am not exactly sure what we have consensus on other than the repo name. I do think we should factor out things like the Posix tc* routines into their own subdirectory/package. I agree that something like a full curses replacement is outside the scope of this repository. I am not exactly sure where we should draw the line between these two extremes. What I am hoping to see is that whatever we put into the packages inside this repo isolates me from needing cgo or needing os specific code. |
Hi Kim, A cursors interface is out of scope, both by the original proposal, and also because none of the underlying plumbing exists. I suggest we work on that plumbing and we'll probably find the natural boundary around the level of a type that represents the attributes of a tty or console; its echo state, its raw dimensions, possibly its speed (if necessary). Anything above that is probably out of scope for this package |
Here alexbrainman/winapi@2657113 are some serial port related APIs. Alex |
@cznic about performance of Linux terminal vs Windows console. As I said, it is my perception that Gnome terminal (which is default on Ubuntu) is slow as hell. And quick search reveals that Linux terminals are indeed slow https://unix.stackexchange.com/questions/41225/can-a-terminal-emulator-be-as-fast-as-tty-1-6 As for your "windows console slow" the first thing I've got is this https://stackoverflow.com/questions/14295570/why-is-console-animation-so-slow-on-windows-and-is-there-a-way-to-improve-spee and there user runs "CLS" external process for every frame. As for https://groups.google.com/forum/#!msg/golang-codereviews/hq63SCACMJo/KL97UzWeEQAJ which says
If you have any idea how to measure FPS of Linux terminal vs Windows console, I'll be happy to run tests on my machine. Please also note that stdout.print() performance is not the only parameter for measuring speed - keyboard response equally matters (if not even more important). |
I'd say 2 and 3. Because I believe that dealing with windows console is impossible in the same way as ttys and ptys. |
WinAPI contains stateless getch() and kbhit() functions that are more clean and I think more useful. See this implementation in Python Still there is a big problem how to get exact keycode indifferent of language layout and encoding. Something kind of readKey() function. For some reason I think it is impossible on Linux, but it would be nice if Go could provide an interface for that once kernel is patched to forward that information to active user space process. |
And JFYI, I am working on Windows client for LXC (yes, Linux Containers) and we've just committed ANSI colors support there with the help of external package that parses them and now I am looking how to read arrow keypresses to forward to remote server - lxc/incus#1317 |
Um. I did this. (Get a key etc.) Windows actually has a pretty sane API, These don’t play entirely perfectly well with simple input/output I recommend you have a look at my tcell package, this file in particular: On Tue, Nov 17, 2015 at 3:24 PM, anatoly techtonik <notifications@github.com
|
Update golang/go#13104 Change-Id: I62ae7ebb97ebcf578d3e322bbf6f536e288a603b Reviewed-on: https://go-review.googlesource.com/17019 Reviewed-by: Dave Cheney <dave@cheney.net>
CL https://golang.org/cl/17020 mentions this issue. |
Update golang/go#13104 Change-Id: I76102038d8dc87503c9a8994f9008b1a9fdb19d4 Reviewed-on: https://go-review.googlesource.com/17020 Reviewed-by: Dave Cheney <dave@cheney.net>
The term repo is now created. |
Great! =) Now how can I track all issues there? (and also, is it already possible to use it right from the start in Go 1.5.x?) |
We still use a centralized bug tracker. Related bugs should have the prefix 'x/term'. |
Okay. Github doesn't allow to subscribe to that. So the only strategy I see is to create all the issues myself. =0 |
@davecheney @adg I think this package shouldn't expose a unix-like TTY interface but should rather build something smarter and cleaner on top of it. By separating concerns, it should then be even easier to port this package on non unix-like OSes. TTY and PTY are low-level POSIX/*NIX interfaces that should go to In my opinion, this package should only provide an abstraction based on the canonical-mode API (line disciplines + terminal capabilities? + readline?). And make the most out of go's beautiful IO stack: this package should see a serial device as nothing more than a stream of bytes ( It is commonly admitted that the TTY API is a messy melting pot of distinct concerns:
Of course it made sense at the time it was built (the 80's is synonym of high space and time constraints), but only time constraints require special kernel attention nowadays (i.e. save time/be fast by letting a kernel handling special cases like clocking a serial line transmission or handling C-z signal asap)... I even think the 100% user-land implementation in pure go could be experienced given the CPU/serial device speed ratio. This is for example what GNU readline does. |
Following the lead of #13058 towards smaller, more focused, sub repositories, I would like to propose the creation of a sub repo for packages related to handling the interaction with tty like things. This includes
Much of the code for this exists in various packages, some in other sub repos like x/crypto/ssh/terminal, others has been duplicated incompletely by package authors with a specific use case; most times without a comprehensive story for windows.
Various informal proposal have been made, like #12853, relating to posix termios.
Other proposals like #12101 for the creation of an x/sys/terminal group of packages have been rejected on the grounds that sys is too low level, which also dovetails into the desire for more smaller sub repos, rather than larger ones.
There is also the the long standing question of why the code to disable terminal echo lives in the x/crypto/ssh package.
With the exception of the name of the repository, which I'm sure will require debate, is there general support for a sub repository along the lines outlined in this proposal ?
The text was updated successfully, but these errors were encountered: