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

proposal: x/sys: move crypto/terminal to sys repository #12101

Closed
binarycrusader opened this issue Aug 10, 2015 · 16 comments
Closed

proposal: x/sys: move crypto/terminal to sys repository #12101

binarycrusader opened this issue Aug 10, 2015 · 16 comments

Comments

@binarycrusader
Copy link
Contributor

I would like to propose the addition of a set of functions and supporting data types to support getting / setting terminal window size across platforms.

This would also likely require the addition of something like this to x/sys:

func GetWindowSize(fd int) (winsize *Winsize, err error) {}
func SetWindowSize(fd int, ws *Winsize) (err error) {}
type Winsize struct {
    Row    uint16
    Col    uint16
    Xpixel uint16
    Ypixel uint16
}

On Linux, OS X, etc. this is done via syscalls using ioctl(), etc. On Windows, this is done possibly via GetConsoleScreenBufferInfo and SetConsoleWindowInfo. On Solaris, this is done via libc.ioctl().

Docker (pkg/term/*) and other Go-based projects like to retrieve or set this information, it would be helpful if this was abstracted away for various projects as can be seen in a simple github search of Go source files:

https://github.com/search?utf8=%E2%9C%93&q=%22TIOCGWINSZ%22+extension%3Ago&type=Code&ref=advsearch&l=

I am willing to provide the implementation and tests for Solaris, and Linux, and I can attempt one for Windows.

I have not proposed an addition before to any of the Go packages or tools, so please forgive me if I have not adhered to the correct process ( I'm attempting to follow https://github.com/golang/proposal#readme ).

I don't know if the sys package is the most appropriate place for this or not; I'm just trying to figure out how to avoid the current situation of duplicating terminal information code across various Go projects in the community leading to them not working as expected or being unsupported on some platforms.

@ianlancetaylor ianlancetaylor added this to the Unreleased milestone Aug 11, 2015
@mikioh mikioh changed the title x/sys/unix: proposal: want platform-independent way to get and set terminal size proposal: x/sys/unix: want platform-independent way to get and set terminal size Aug 13, 2015
@binarycrusader
Copy link
Contributor Author

@bradfitz
Copy link
Contributor

Seems non-controversial to live somewhere.

Note that we already have stuff like http://godoc.org/golang.org/x/crypto/ssh/terminal#GetSize

Maybe that's the right package to complete the work.

@binarycrusader
Copy link
Contributor Author

@bradfitz Actually, that looks like exactly the functionality I was desiring, with the exception that it lives in an odd place (crypto/ssh, where I never would have thought to look for it).

I wonder if it should be moved to a top-level package instead of being part of crypto/ssh or is it too late to fix the namespacing?

@davecheney
Copy link
Contributor

I've always felt the ssh/terminal package was a storage outlier. I'd
support moving this, and other termios functions into x/sys/termios (or
another less geeky name)

On Wed, 16 Sep 2015 06:21 Shawn notifications@github.com wrote:

Actually, that looks like exactly the functionality I was desiring, with
the exception that it lives in an odd place (crypto/ssh, where I never
would have thought to look for it).

I wonder if it should be moved to a top-level package instead of being
part of crypto/ssh or is it too late to fix the namespacing?


Reply to this email directly or view it on GitHub
#12101 (comment).

@binarycrusader
Copy link
Contributor Author

and other termios functions into x/sys/termios (or another less geeky name)

Well, it's not really "termios" since that's a *NIX concept, so while I hate to engage in bikeshedding, I'd suggest it either belongs in x/sys, x/terminal, or x/term.

I'm happy to do the work if someone wants to suggest the desired direction as I have no particular preference here.

@davecheney
Copy link
Contributor

I'm happy with term, and can contribute Darwin and Linux implementations
from my github.com/pkg/term project.

golang.org/x/sys/term

Sounds fine to me.

On Wed, 16 Sep 2015 09:37 Shawn notifications@github.com wrote:

and other termios functions into x/sys/termios (or another less geeky name)

Well, it's not really "termios" since that's a *NIX concept, so while I
had to engage in bikeshedding, I'd suggest it either belongs in x/sys,
x/terminal, or x/term.

I'm happy to do the work if someone wants to suggest the desired direction
as I have no particular preference here.


Reply to this email directly or view it on GitHub
#12101 (comment).

@techtonik
Copy link

x/sys/console, because terminal is a limited, slow and messy stuff with its windows control channel mixed into input stream.

I have a Python Windows code for GetWindowSize in case somebody would like to port it, see https://bitbucket.org/techtonik/python-pager/src/2936adb19c9407b8e890949f9e88bf4f0461a524/pager.py?at=default&fileviewer=file-view-default#pager.py-35

@techtonik
Copy link

The console interfaces of the future look like those created with https://bitbucket.org/libtcod/libtcod/ so it would be good to plan for that now.

@adg adg added Proposal and removed Proposal labels Sep 25, 2015
@adg adg changed the title proposal: x/sys/unix: want platform-independent way to get and set terminal size x/sys: move crypto/terminal to sys repository Oct 21, 2015
@adg
Copy link
Contributor

adg commented Oct 21, 2015

Seems there's consensus to move this code. There's a question about precisely where it should go, but I'm marking this as accepted since it's so uncontroversial. (famous last words)

I'd like to hear from @agl who I believe originally authored the terminal package.

@agl
Copy link
Contributor

agl commented Oct 21, 2015

I'm happy with moving terminal to x/sys. There might be some tension from the fact that terminal mostly implements a line-based input system. That is fairly separate from the utility functions like GetSize, MakeRaw etc which suggests that the package might want to be split in half when moved. Say, into x/sys/terminal and x/sys/terminal/lineterm. (No thought went into those names.)

@rsc
Copy link
Contributor

rsc commented Oct 24, 2015

I unaccept this proposal. Except at the lowest levels this has nothing to do with system calls. It seems pretty clear to me that x/sys is not appropriate (nor is x/crypto but at least it's already there).

@rsc rsc changed the title x/sys: move crypto/terminal to sys repository proposal: x/sys: move crypto/terminal to sys repository Oct 24, 2015
@rsc rsc modified the milestones: Proposal, Unreleased Oct 24, 2015
@davecheney
Copy link
Contributor

@rsc it seems overkill to create an x/term subrepo, but would you consider something like x/os with an expanded scope including terminal handling ?

@minux
Copy link
Member

minux commented Oct 24, 2015 via email

@techtonik
Copy link

@minux terminal is slow and inefficient legacy system that is only good for abusing Linux through COM ports. What users really need is either modern cross-platform console interfaces, such as https://bitbucket.org/libtcod/libtcod/wiki/Features or fast remote access https://mosh.mit.edu/ So choose the name carefully.

@fazalmajid
Copy link

Another terminal library worth mentioning: http://garrett.damore.org/2015/10/tcell-terminal-functionality-for-pure.html

@rsc
Copy link
Contributor

rsc commented Oct 30, 2015

I think we can decline this in favor of #13104 (not that 13104 is completely decided yet).

@rsc rsc closed this as completed Oct 30, 2015
@golang golang locked and limited conversation to collaborators Nov 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests