gows

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2019 License: MIT Imports: 3 Imported by: 8

README

gows

Golang library to get the terminal or console window size

Usage

package main

import (
	"fmt"
	"os"

	"github.com/karrick/gows"
)

func main() {
	col, row, err := gows.GetWinSize()
	if err != nil {
		exit(err)
	}
	fmt.Printf("%d %d\n", row, col) // output in same order as `stty size`
}

func exit(err error) {
	if err != nil {
		fmt.Fprintf(os.Stderr, "ERROR: %s\n", err)
		os.Exit(1)
	}
	os.Exit(0)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetWinSize

func GetWinSize() (int, int, error)

GetWinSize returns the size of the console window. It returns the number of columns, number of rows, or whatever error was encountered while attempting to get the requested window size. On POSIX it attempts to open the associated controlling terminal from /dev/tty. On Windows it invokes GetConsoleScreenBufferInfo for the process' standard output stream.

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