termsize

package module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2021 License: BSD-3-Clause Imports: 1 Imported by: 7

README

termsize

Go module to return the terminal width and height

The Releases Page contains command-line binaries for Windows, MacOS and Linux.

NOTES

When a terminal is not available such as when using a pipe or redirecting to a file, then the DefaultWidth and DefaultHeight as defined in defaults.go will be used. These defaults can be changed by setting termsize.DefaultWidth and termsize.DefaultHeight.

INSTALL

Go version 1.16 or newer is required for compilation.

go get github.com/jftuga/termsize

ACKNOWLEDGEMENTS

This code is adapted from https://github.com/jessevdk/go-flags.

Example

// Tested on Windows 10, Raspberry Pi OS Linux, and MacOS Big Sur 11.1

package main

import (
	"fmt"
	"github.com/jftuga/termsize"
)

func main() {
	termsize.DefaultHeight = 133
	w := termsize.Width()
	h := termsize.Height()
	fmt.Printf("%dx%d\n", w, h)
}

Output

PS C:\termsize> .\termsize.exe
133x46

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultWidth  int = 120
	DefaultHeight int = 24
)

Functions

func Height

func Height() int

func Width

func Width() int

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL