Categorygithub.com/kopoli/go-terminal-size
modulepackage
0.0.0-20170219200355-5c97524c8b54
Repository: https://github.com/kopoli/go-terminal-size.git
Documentation: pkg.go.dev

# README

Go terminal size

GoDoc Build Status Go Report Card

Features:

  • Get the size of the current terminal as rows and columns.
  • Listen on terminal size changes and receive the new size via a channel.
  • Supports Linux and Windows.

Installation

$ go get github.com/kopoli/go-terminal-size

Usage

For a complete example see _example/example.go.

Abbreviated example:

package main

import (
	"fmt"

	tsize "github.com/kopoli/go-terminal-size"
)

func main() {
	var s tsize.Size

	s, err := tsize.GetSize()
	if err == nil {
		fmt.Println("Current size is", s.Width, "by", s.Height)
	}
}

License

MIT license

# Functions

FgetSize gets the terminal size of a given os.File.
GetSize gets the current terminal size.
NewSizeListener creates a new size change listener.

# Variables

ErrNotATerminal is the error to return if the given file to FgetSize isn't a terminal.

# Structs

Size represents terminal size in columns and rows as Width and Height, respectively.
SizeListener listens to terminal size changes.