Skip to content

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

Closed
@binarycrusader

Description

@binarycrusader

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions